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?
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
Closing due to lack of feedback