diff options
| author | Fangrui Song <i@maskray.me> | 2024-12-08 12:32:55 -0800 |
|---|---|---|
| committer | Fangrui Song <i@maskray.me> | 2024-12-08 12:32:55 -0800 |
| commit | 2b129dacdde667137b5012d52f1d96e0ab26c749 (patch) | |
| tree | d95866c52ad26653cc512d7d2c44053e58c19914 /lld/ELF/InputFiles.cpp | |
| parent | b6dfdd2b1ecc84c77ea4eec3713caa07a1cab198 (diff) | |
[ELF] Optimize parseSymbolVersion
We can just scan objectFiles and sharedFiles that have versioned symbols
to skip scanning the global symtab. While we won't suggest __wrap_foo
for undefined __wrap_foo@v1 when --wrap=foo@v1 is specified
(internalFile isn't scanned), this edge case difference is acceptable.
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
| -rw-r--r-- | lld/ELF/InputFiles.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 9ff6ed58688c..2006b3ba3520 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1217,6 +1217,7 @@ template <class ELFT> void ObjFile<ELFT>::postParse() { Err(ctx) << "TLS attribute mismatch: " << &sym << "\n>>> in " << sym.file << "\n>>> in " << this; + hasVersionSyms |= sym.hasVersionSuffix; // Handle non-COMMON defined symbol below. !sym.file allows a symbol // assignment to redefine a symbol without an error. if (!sym.isDefined() || secIdx == SHN_UNDEF) @@ -1432,6 +1433,9 @@ template <class ELFT> void SharedFile::parse() { const Elf_Shdr *verdefSec = nullptr; const Elf_Shdr *verneedSec = nullptr; + numSymbols = numELFSyms; + symbols = std::make_unique<Symbol *[]>(numSymbols); + // Search for .dynsym, .dynamic, .symtab, .gnu.version and .gnu.version_d. for (const Elf_Shdr &sec : sections) { switch (sec.sh_type) { @@ -1591,6 +1595,8 @@ template <class ELFT> void SharedFile::parse() { s->dsoDefined = true; if (s->file == this) s->versionId = idx; + symbols[firstGlobal + i] = s; + hasVersionSyms = true; } } |
