[PATCH v2] elf: Always honor the first definition in shared object and archive
Andreas Schwab
schwab@suse.de
Tue Apr 9 13:13:14 GMT 2024
That creates an indirect symbol that referes to itself.
(gdb) p h
$16 = (struct bfd_link_hash_entry *) 0x5587749387d0
(gdb) p *h
$17 = {root = {next = 0x5587538db760,
string = 0x5587749387b8 "ldexp@@GLIBC_2.2.5", hash = 337613448},
type = bfd_link_hash_indirect, non_ir_ref_regular = 1,
non_ir_ref_dynamic = 1, ref_real = 0, linker_def = 0, ldscript_def = 0,
rel_from_abs = 0, u = {undef = {next = 0x5587749387d0,
abfd = 0x5587749387d0}, def = {next = 0x5587749387d0,
section = 0x5587749387d0, value = 96846}, i = {next = 0x5587749387d0,
link = 0x5587749387d0,
warning = 0x17a4e <error: Cannot access memory at address 0x17a4e>},
c = {next = 0x5587749387d0, p = 0x5587749387d0, size = 96846}}}
(gdb) f
#0 _bfd_generic_link_add_one_symbol (info=0x5587520c24c0 <link_info>,
abfd=0x558774615960, name=0x55875a81f1b8 "ldexp", flags=<optimized out>,
section=0x5587520c1cc8 <_bfd_std_section+840>, value=0,
string=0x55875a81f1a0 "ldexp@@GLIBC_2.2.5", copy=false, collect=false,
hashp=0x7fff0a2321d0) at ../../bfd/linker.c:1773
1773 h = h->u.i.link;
(gdb) l
1768
1769 case REFC:
1770 /* A reference to an indirect symbol. */
1771 if (h->u.undef.next == NULL && info->hash->undefs_tail != h)
1772 h->u.undef.next = h;
1773 h = h->u.i.link;
1774 cycle = true;
1775 break;
1776
1777 case WARN:
This happens when linking mold with LTO.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
More information about the Binutils
mailing list