[lld] [ELF] Synthesize STT_FILE if necessary (PR #209087)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 22:19:57 PDT 2026
================
@@ -669,6 +671,16 @@ class SymbolTableBaseSection : public SyntheticSection {
// A vector of symbols and their string table offsets.
SmallVector<SymbolTableEntry, 0> symbols;
+ // Synthetic STT_FILE with an empty name, added by maybeAddSttFile and placed
+ // by sortSymTabSymbols before all symbols demoted to STB_LOCAL.
+ Defined *synthSttFileSym = nullptr;
+
+ // symbols[firstGlobalIdx, synthSttFileIdx) were originally non-local and may
+ // be converted to local. synthSttFileIdx is where synthSttFileSym lands.
+ // Locals added later (thunks via addSyntheticLocal) fall outside and stay
----------------
MaskRay wrote:
Thanks for the suggestion.
I've gone ahead and attributed thunk symbols to the synthesized STT_FILE symbol with empty name. Simplified the comment here. Since there are extensive comments in SymbolTableBaseSection::sortSymTabSymbols and SymbolTableBaseSection::maybeAddSttFile, I've trimmed the comment here.
https://github.com/llvm/llvm-project/pull/209087
More information about the llvm-commits
mailing list