[PATCH] D59549: [ELF] Don't emit weak undefined symbols in .dynsym for static executables

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 08:55:18 PDT 2019


MaskRay added a comment.

I surveyed ld.bfd's architecture-varying rules:

- x86 uses UNDEFINED_WEAK_RESOLVED_TO_ZERO which basicaly does isLocal() || (!Shared && zero_undefweak). zero_undefweak has two bits: + Bit 0: Symbol has no GOT nor PLT relocations. + Bit 1: Symbol has non-GOT/non-PLT relocations in text sections.
- Other architectures mostly use UNDEFWEAK_NO_DYNAMIC_RELOC which checks Visibility != STV_DEFAULT || dynamic_undefined_weak. The variable has different initial values on different architectures and is controlled by -z {,no-}dynamic-undefined-weak.

The GOT/PLT relocation type differentiation is only implemented on x86.

I definitely missed some rules but just wanted to give you an impression why following it in every corner case is unreasonable :)

I've found a previous attempt that is related: https://reviews.llvm.org/D39392


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59549/new/

https://reviews.llvm.org/D59549





More information about the llvm-commits mailing list