More rel/rela fixes for ld -r

Alan Modra amodra@gmail.com
Mon Oct 4 08:09:00 GMT 2010


On Fri, Oct 01, 2010 at 07:37:28PM +0200, Bernd Schmidt wrote:
>  * elf64-ppc accesses an uninitialized rel_hdr structure in get_relocs.

I don't think so.  The rel_hdr in question is allocated along with
elf_section_data, and zeroed.

>    This happens for brlt and stub sections which the backend creates.
>    I've changed it to simply allocate memory for rela.hdr; the
>    testcase worked after this change.

Please use bfd_zalloc.

I also see

bfd/elflink.c: In function ‘elf_reloc_link_order’:
bfd/elflink.c:9875: error: ‘reldata’ may be used uninitialized in this function
bfd/elflink.c: In function ‘elf_link_input_bfd’:
bfd/elflink.c:9555: error: ‘rela_hash_list’ may be used uninitialized in this function

> ! Elf_Internal_Shdr *
> ! _bfd_elf_single_rel_hdr (asection *sec)
> ! {
> !   if (elf_section_data (sec)->rel.hdr)
> !     {
> !       BFD_ASSERT (elf_section_data (sec)->rela.hdr == NULL);
> !       return elf_section_data (sec)->rel.hdr;
> !     }
> !   else
> !     {
> !       BFD_ASSERT (elf_section_data (sec)->rel.hdr == NULL);
> !       return elf_section_data (sec)->rela.hdr;
> !     }
> ! }

The second assert here is a little useless.  Otherwise, I think the
patch is OK.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list