diff options
| author | Fangrui Song <i@maskray.me> | 2024-12-01 14:18:09 -0800 |
|---|---|---|
| committer | Fangrui Song <i@maskray.me> | 2024-12-01 14:18:10 -0800 |
| commit | a09df64f406be162b0bd096dbe2466603b7a4f29 (patch) | |
| tree | 0c566d39285b5b17f6e41ec068192ecc1c5794d2 /lld/ELF/InputFiles.cpp | |
| parent | 603d41ab7b4078a00a5d3b899d3b9d14eea2d8ff (diff) | |
[ELF] postParse: remove some branches in the fast path
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
| -rw-r--r-- | lld/ELF/InputFiles.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index f262e537a6d0..373292b4391c 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1219,14 +1219,17 @@ template <class ELFT> void ObjFile<ELFT>::postParse() { // Handle non-COMMON defined symbol below. !sym.file allows a symbol // assignment to redefine a symbol without an error. - if (!sym.file || !sym.isDefined() || secIdx == SHN_UNDEF || - secIdx == SHN_COMMON) + if (!sym.file || !sym.isDefined() || secIdx == SHN_UNDEF) continue; + if (LLVM_UNLIKELY(secIdx >= SHN_LORESERVE)) { + if (secIdx == SHN_COMMON) + continue; + if (secIdx == SHN_XINDEX) + secIdx = check(getExtendedSymbolTableIndex<ELFT>(eSym, i, shndxTable)); + else + secIdx = 0; + } - if (LLVM_UNLIKELY(secIdx == SHN_XINDEX)) - secIdx = check(getExtendedSymbolTableIndex<ELFT>(eSym, i, shndxTable)); - else if (secIdx >= SHN_LORESERVE) - secIdx = 0; if (LLVM_UNLIKELY(secIdx >= sections.size())) Fatal(ctx) << this << ": invalid section index: " << secIdx; InputSectionBase *sec = sections[secIdx]; |
