This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] elf: don't modify file names used with .file/.appfile
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Jan Beulich <JBeulich at novell dot com>
- Cc: binutils at sourceware dot org
- Date: Sat, 25 Jul 2009 15:32:03 +0930
- Subject: Re: [PATCH] elf: don't modify file names used with .file/.appfile
- References: <4A69C24D020000780000C222@vpn.id2.novell.com>
On Fri, Jul 24, 2009 at 01:16:45PM +0100, Jan Beulich wrote:
> --- 2009-07-24/gas/config/obj-elf.c 2009-07-23 15:06:32.000000000 +0200
> +++ 2009-07-24/gas/config/obj-elf.c 2009-07-24 10:18:46.000000000 +0200
> @@ -260,9 +260,20 @@ elf_file_symbol (const char *s, int appf
> || (symbol_rootP->bsym->flags & BSF_FILE) == 0)
> {
> symbolS *sym;
> + unsigned int name_length;
>
> sym = symbol_new (s, absolute_section, 0, NULL);
> symbol_set_frag (sym, &zero_address_frag);
> +
> + name_length = strlen (s);
> + if (name_length > strlen (S_GET_NAME (sym)))
> + {
> + obstack_grow (¬es, s, name_length + 1);
> + S_SET_NAME (sym, obstack_finish (¬es));
> + }
> + else
No need for any of the above, just do the strcpy. We know the
size allocated is large enough for the original name even when
tc_canonicalize_symbol_name trims the symbol name.
> + strcpy ((char *)S_GET_NAME (sym), s);
Space after cast. OK otherwise.
--
Alan Modra
Australia Development Lab, IBM