This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Is this a bfd bug? (binutils version 2.13)


Hello,

I came across a linker crash in binutils version 2.13. (gcc version used is 2.95.3).
(I tried with binutils-2.13.90.0.20 too and I observed the crash).


This is the backtrace.

#0 mips_elf_output_extsym (h=0x15c9a0, data=0xeffff698) at ../../src/bfd/elfxx-mips.c:1319
#1 0x41814 in bfd_hash_traverse (table=0x1462c0, func=0x4d668 <mips_elf_output_extsym>, info=0xeffff698) at ../../src/bfd/hash.c:493
#2 0x41db4 in bfd_link_hash_traverse (table=0x1462c0, func=0x4d668 <mips_elf_output_extsym>, info=0xeffff698) at ../../src/bfd/linker.c:615 #3 0x57ca0 in _bfd_mips_elf_final_link (abfd=0x1402d8, info=0x138180) at ../../src/bfd/elfxx-mips.c:7324
#4 0x2c67c in ldwrite () at ../../src/ld/ldwrite.c:540
#5 0x2a624 in main (argc=10, argv=0xdf400) at ../../src/ld/ldmain.c:415


The line of crash is
sec = hd->root.root.u.def.section; (in function 'mips_elf_output_extsym' in bfd/elfxx-mips.c)


I think it is accessing the wrong member of the union here.

On debugging, I find that the type of hd->root.root.type is bfd_link_hash_undefined
and it is trying to access the union member def, which is some invalid address here.
The other types are already checked for before and so the type of symbol at this place
is likely to be bfd_link_hash_undefweak or bfd_link_hash_undefined.


If the value of hd->root.root.type is either bfd_link_hash_undefined or bfd_link_hash_undefweak,
the right union member to be accessed is hd->root.root.u.undef (inferred from definition of
struct bfd_link_hash_entry in bfdlink.h).


I see that this causes the dump and replacing the line at this place (sec = hd->root.root.u.def.section;) to

if ((hd->root.root.type == bfd_link_hash_undefined) || (hd->root.root.type == bfd_link_hash_undefweak))
if (hd->root.root.u.undef.abfd != NULL)
sec = hd->root.root.u.undef.abfd->sections


seems to solve the problem.

Please correct my understanding. I'm not sure, if its likely to impact anything else.

Thanks,
Bharathi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]