This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH-bfd] i386-mingw32-ld crash on x86_64 linux
Alan Modra wrote:
>> @@ -157,10 +157,10 @@
>> if (unused_section_number <= sec->target_index)
>> unused_section_number = sec->target_index + 1;
>>
>> - name = bfd_alloc (abfd, (bfd_size_type) strlen (in->n_name) + 10);
>> + name = bfd_alloc (abfd, (bfd_size_type) SYMNMLEN + 1);
>
> Better to use char[SYMNMLEN + 1] rather than bfd_alloc.
> - name = bfd_alloc (abfd, (bfd_size_type) strlen (in->n_name) + 10);
> - if (name == NULL)
> - return;
> - strcpy (name, in->n_name);
> flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
> sec = bfd_make_section_anyway_with_flags (abfd, name, flags);
I'm not sure that bfd_make_section_anyway_with_flags copies the name. I
think it stashes the value of the pointer passed in (twice in fact, once in
the asection itself and once in the root bfd_hash_entry to which the section
is anchored), so we do need to allocate some memory after all. So I'll try
re-adding that and we'll see if it helps.
cheers,
DaveK