bfd/elf.c assertion for multiple relocations to same section
Joe Lawrence
joe.lawrence@redhat.com
Wed Apr 17 14:32:00 GMT 2019
On 4/16/19 7:19 PM, Alan Modra wrote:
> On Tue, Apr 16, 2019 at 05:13:08PM -0400, Joe Lawrence wrote:
>> I was wondering if anyone could explain the assertion in bfd/elf.c ::
>> bfd_section_from_shdr() where it is processing a SHT_REL/SHT_RELA section
>> and decides to return failure if *p_hdr is already set non-NULL:
>>
>> /* PR 17512: file: 0b4f81b7. */
>> if (*p_hdr != NULL)
>> goto fail;
>
> The BFD library is incapable of handling two rela sections with
> identical sh_info values *as relocation sections*. It might be
> reasonable to modify BFD for the case you describe by creating a
> normal section for the second rela section, as is done for other
> cases. See the comment starting "If this is an alloc section" a few
> lines above the lines you show here. No interpretation of the second
> rela section contents would then be done.
>
Hi Alan,
Thanks for pointing out that source-code comment about handling
relocation sections and ordinary sections:
/* If this is an alloc section in an executable or shared
library, or the reloc section does not use the main symbol
table we don't treat it as a reloc section. BFD can't
adequately represent such a section, so at least for now,
we don't try. We just present it as a normal section. We
also can't use it as a reloc section if it points to the
null section, an invalid section, another reloc section, or
its sh_link points to the null section. */
From this and your comment, if I understand correctly: we've created a
valid ELF file that cannot have a BFD representation since we've doubled
up on relocation sections that share the same sh_info value. However,
an ELF file that contained additional ordinary sections may share
sh_info values and BFD will be happy as it will not process them as
relocation sections.
Thanks,
-- Joe
More information about the Binutils
mailing list