[PATCH] PR gas/19896: Don't change defined symbol to undefined
Alan Modra
amodra@gmail.com
Sat Apr 2 04:04:00 GMT 2016
On Fri, Apr 01, 2016 at 08:52:39AM -0700, H.J. Lu wrote:
> +.*: Assembler messages:
> +.*:6: Error: symbol `mempcpy' is already defined
> +.*:6: Error: can't change defined symbol `mempcpy' to undefined
This is a confusing error message. Where in the user input is mempcpy
being made undefined?
> diff --git a/gas/testsuite/gas/elf/pr19896.s b/gas/testsuite/gas/elf/pr19896.s
> new file mode 100644
> index 0000000..92fbe11
> --- /dev/null
> +++ b/gas/testsuite/gas/elf/pr19896.s
> @@ -0,0 +1,6 @@
> + .globl mempcpy
> + .type mempcpy,%function
> +mempcpy:
> + .byte 0
> + .size mempcpy,.-mempcpy
> + mempcpy = __mempcpy
Also, this testcase doesn't segfault on an old assembler like the
original in your bugzilla. It seems you need an instruction like
"jmp" that sets up a new frag, or something like ".org 8" instead of
.byte. Please commit with the ".org 8" change.
I think what we want instead in read.c:assign_symbol is the following.
It's a little different from the usual ignore_rest_of_line() after an
error because we don't want to skip over EOL in this function. That
happens in the caller of assign_symbol (or caller's caller). I'll
commit this after testing.
PR 19896
* read.c (assign_symbol): Consume rest of line after an error
rather than continuing to process the line.
diff --git a/gas/read.c b/gas/read.c
index 35d44c1..a940ff3 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -3255,7 +3255,9 @@ assign_symbol (char *name, int mode)
&& !S_CAN_BE_REDEFINED (symbolP))
{
as_bad (_("symbol `%s' is already defined"), name);
- symbolP = symbol_clone (symbolP, 0);
+ ignore_rest_of_line ();
+ input_line_pointer--;
+ return;
}
/* If the symbol is volatile, copy the symbol and replace the
original with the copy, so that previous uses of the symbol will
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list