diff options
| author | Fangrui Song <i@maskray.me> | 2024-12-08 09:33:48 -0800 |
|---|---|---|
| committer | Fangrui Song <i@maskray.me> | 2024-12-08 09:33:48 -0800 |
| commit | c6508809585505ffb88f5f724da04bbc058eabf8 (patch) | |
| tree | d252beceaf745abbf5ff281327d8483df8990734 /lld/ELF/InputFiles.cpp | |
| parent | aedc81b9d8880a60877a53469aeb89ff62466f6f (diff) | |
[ELF] Simplify handling of exportDynamic and canBeOmittedFromSymbolTable
When computing whether a defined symbol is exported, we set
`exportDynamic` in Defined and CommonSymbol's ctor and merge the bit in
symbol resolution. The complexity is for the LTO special case
canBeOmittedFromSymbolTable, which can be simplified by introducing a
new bit.
We might simplify the state by caching includeInDynsym in exportDynamic
in the future.
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
| -rw-r--r-- | lld/ELF/InputFiles.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 97b3e164bdc3..9ff6ed58688c 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1742,8 +1742,11 @@ static void createBitcodeSymbol(Ctx &ctx, Symbol *&sym, } else { Defined newSym(ctx, &f, StringRef(), binding, visibility, type, 0, 0, nullptr); - if (objSym.canBeOmittedFromSymbolTable()) - newSym.exportDynamic = false; + // The definition can be omitted if all bitcode definitions satisfy + // `canBeOmittedFromSymbolTable()` and isUsedInRegularObj is false. + // The latter condition is tested in Symbol::includeInDynsym. + sym->ltoCanOmit = objSym.canBeOmittedFromSymbolTable() && + (!sym->isDefined() || sym->ltoCanOmit); sym->resolve(ctx, newSym); } } |
