This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] PR gas/19896: Don't change defined symbol to undefined
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Sat, 2 Apr 2016 14:26:07 +1030
- Subject: Re: [PATCH] PR gas/19896: Don't change defined symbol to undefined
- Authentication-results: sourceware.org; auth=none
- References: <20160401155239 dot GA30449 at intel dot com>
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
> + .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.
* 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
@@ -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 ();
/* If the symbol is volatile, copy the symbol and replace the
original with the copy, so that previous uses of the symbol will
Australia Development Lab, IBM