[lld] [llvm] IRSymTab: Record _GLOBAL_OFFSET_TABLE_ for ELF x86 (PR #89463)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 14:02:10 PDT 2024


MaskRay wrote:

> The intent was always that LTO would tell the linker which symbols may be used by the combined object file, and that it wouldn't be handled by the individual bitcode files. See `LTO::getRuntimeLibcallSymbols()` which is where the list currently comes from (it currently refers to "library functions" but I don't see why it should be limited to that). So I am not sure that `_GLOBAL_OFFSET_TABLE_` should be a special case here.

The commit message states:

> The PreservedSymbols mechanism
([reviews.llvm.org/D112595](https://reviews.llvm.org/D112595)) that just sets FB_used is not
applicable.

That mechanism and `LTO::getRuntimeLibcallSymbols()`  handle lazy symbols that appear in the symbol table before LTO compilation. `_GLOBAL_OFFSET_TABLE_` is a special case that it may not be in the symbol table when LTO compilation occurs.

Technically linkers can add the special case to `handleLibcall` by ensuring `_GLOBAL_OFFSET_TABLE_` is always present (thigh might only be needed for x86). Personally I feel that LLVMLTO, which is equipped with more information, is the best place to implement this to benefit all linkers (GNU ld might always define `_GLOBAL_OFFSET_TABLE_` when dynamic sections are needed).

https://github.com/llvm/llvm-project/pull/89463


More information about the llvm-commits mailing list