Bug 3679 - sh_entsize not set for .rel.dyn cause an assert to detonate with mips-linux-elf-ld -shared -q
Summary: sh_entsize not set for .rel.dyn cause an assert to detonate with mips-linux-e...
Status: RESOLVED WORKSFORME
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.17
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-08 11:50 UTC by Cedric Hombourger
Modified: 2008-01-21 05:43 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: mips-linux-elf
Build: i686-pc-linux-gnu
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cedric Hombourger 2006-12-08 11:50:40 UTC
I have an assert detonating in bfd/elflink.c with the following code linked with
mips-linux-elf-ld -shared -q:

main.c:

/* 'a' goes into .data */
int a = 1; 

/* 'b' goes into .rodata and creates a reloc for .rodata against .data */
const int *b = &a; 

when linking with mips-linux-elf-ld version 2.17, we end-up with:

mips-linux-elf-ld: BFD 2.17 assertion fail elflink.c:7973

After some investigations, I have observed the following:

   - the section for which we have an assert is '.rel.dyn'
   - sh_entsize for this section is zero
   - we reach this code because reloc_count is greater than zero (and is equals
to sec->reloc_count because of the -q option passed to ld)
   - '.rel.dyn' section is created by mips_elf_rel_dyn_section()
   - room is reserved for our .rel.dyn section by
mips_elf_allocate_dynamic_relocations()
   - I have a '.rel.rel.dyn' section in the output

I was surprised to see in mips_elf_allocate_dynamic_relocations() that
reloc_count is incremented only for the 1st entries and ins't for subsequent
entries. I was under the impression that asection::reloc_count is the number
of relocations to be applied to a section; is it the number of relocs for
a relocation section.

I have the feeling that the incrementation of reloc_count in
bfd/elfxx-mips.c:mips_elf_allocate_dynamic_relocations:4710 should be removed
but are we breaking something with this change?
Comment 1 Nick Clifton 2007-02-22 11:31:15 UTC
Hi Cedric,

  Can you produce a full test case that demonstrates this problem please ?

  Also, have you checked to see if the problem still exists with a linker built
from the current mainline binutils sources ?

Cheers
  Nick
Comment 2 Alan Modra 2008-01-21 05:43:57 UTC
Closing due to lack of feedback