Skip to content

Commit a09df64

Browse files
committed
[ELF] postParse: remove some branches in the fast path
1 parent 603d41a commit a09df64

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,14 +1219,17 @@ template <class ELFT> void ObjFile<ELFT>::postParse() {
12191219

12201220
// Handle non-COMMON defined symbol below. !sym.file allows a symbol
12211221
// assignment to redefine a symbol without an error.
1222-
if (!sym.file || !sym.isDefined() || secIdx == SHN_UNDEF ||
1223-
secIdx == SHN_COMMON)
1222+
if (!sym.file || !sym.isDefined() || secIdx == SHN_UNDEF)
12241223
continue;
1224+
if (LLVM_UNLIKELY(secIdx >= SHN_LORESERVE)) {
1225+
if (secIdx == SHN_COMMON)
1226+
continue;
1227+
if (secIdx == SHN_XINDEX)
1228+
secIdx = check(getExtendedSymbolTableIndex<ELFT>(eSym, i, shndxTable));
1229+
else
1230+
secIdx = 0;
1231+
}
12251232

1226-
if (LLVM_UNLIKELY(secIdx == SHN_XINDEX))
1227-
secIdx = check(getExtendedSymbolTableIndex<ELFT>(eSym, i, shndxTable));
1228-
else if (secIdx >= SHN_LORESERVE)
1229-
secIdx = 0;
12301233
if (LLVM_UNLIKELY(secIdx >= sections.size()))
12311234
Fatal(ctx) << this << ": invalid section index: " << secIdx;
12321235
InputSectionBase *sec = sections[secIdx];

0 commit comments

Comments
 (0)