
Linker will resolve an undefined symbol only if it is referenced by relocation. Unreferenced weak undefined symbols serve no purpose. Weak undefined symbols appear in the dynamic symbol table only when they are referenced by dynamic relocation. Mark symbols with relocation and strip undefined weak symbols if they don't have relocation and aren't in the dynamic symbol table. bfd/ PR ld/31652 * elf-bfd.h (elf_link_hash_entry): Add has_reloc. * elf-vxworks.c (elf_vxworks_emit_relocs): Set has_reloc. * elflink.c (_bfd_elf_link_output_relocs): Likewise. (elf_link_output_extsym): Strip undefined weak symbols if they don't have relocation and aren't in the dynamic symbol table. ld/ PR ld/31652 * testsuite/ld-elf/elf.exp: Run undefweak tests. * testsuite/ld-elf/undefweak-1.rd: New file. * testsuite/ld-elf/undefweak-1a.s: Likewise. * testsuite/ld-elf/undefweak-1b.s: Likewise. * testsuite/ld-x86-64/weakundef-1.nd: Likewise. * testsuite/ld-x86-64/weakundef-1a.s: Likewise. * testsuite/ld-x86-64/weakundef-1b.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run undefweak tests.
14 lines
216 B
ArmAsm
14 lines
216 B
ArmAsm
.section .text.foobar,"axG",%progbits,foo,comdat
|
|
.weak foo
|
|
.type foo,%function
|
|
foo:
|
|
.nop
|
|
.size foo, . - foo
|
|
.weak bar
|
|
.set bar, foo
|
|
.text
|
|
.global baz
|
|
.type baz,%function
|
|
baz:
|
|
.dc.a foo
|
|
.size baz, . - baz
|