[lld] [llvm] IRSymTab: Record _GLOBAL_OFFSET_TABLE_ for ELF x86 (PR #89463)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 19 16:41:52 PDT 2024
MaskRay wrote:
> I was trying to understand why we couldn't resolve `_GLOBAL_OFFSET_TABLE_` after LTO in lld. Ideally we wouldn't special case linker-synthesized symbols in LLVM?
lld only defines `_GLOBAL_OFFSET_TABLE_` when it is referenced. The symbol table should be finalized before LTO.
Codegen passes may reference a runtime library function or linker-defined symbols `_GLOBAL_OFFSET_TABLE_` that is not in the referencer's symbol table. In such a case, if we don't "workaround" it, we will get an "undefined symbol" error.
This behavior is not lld specific and applies to other linkers). I feel that LTO is the right place to implement the special logic. If we have other symbols that are not ELF-specific, a linker-oriented solution would require to patch every linker.
https://github.com/llvm/llvm-project/pull/89463
More information about the llvm-commits
mailing list