diff options
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]; |
