bfd/elf.c assertion for multiple relocations to same section

Alan Modra amodra@gmail.com
Tue Apr 16 23:19:00 GMT 2019


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.

>   Relocation section [ 4] '.rela.text' for section [ 3] '.text' ...
>   Relocation section [34] '.klp.rela.vmlinux..text' for section [ 3] '.text'

Alternatively, you could accept this was another marvellous idea from
clever kernel people that didn't work out fully in practice.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list