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
>>> Alan Modra <amodra@bigpond.net.au> 25.07.09 08:02 >>>
>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.
I don't think that would work: mmix, for example, strips a leading ':' by
just incrementing the pointer to the beginning of the string (and without
looking further I'd expect that to be the preferable method of stripping
a prefix), and hence we can't make assumptions on the amount of space
valid past what S_GET_NAME() returns.
>> + strcpy ((char *)S_GET_NAME (sym), s);
>
>Space after cast. OK otherwise.
With the above comment, and with the space added - okay with no
other changes?
Jan