[lld] 50460b8 - [ELF] Don't access other eSym members it st_shndx == SHN_UNDEF. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 5 15:50:11 PST 2022
Author: Fangrui Song
Date: 2022-02-05T15:25:23-08:00
New Revision: 50460b800462d32f26346f99e0df12b8adeb2633
URL: https://github.com/llvm/llvm-project/commit/50460b800462d32f26346f99e0df12b8adeb2633
DIFF: https://github.com/llvm/llvm-project/commit/50460b800462d32f26346f99e0df12b8adeb2633.diff
LOG: [ELF] Don't access other eSym members it st_shndx == SHN_UNDEF. NFC
Added:
Modified:
lld/ELF/InputFiles.cpp
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index dcdd80d6a4ea..f0e8067179e7 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1083,6 +1083,11 @@ void ObjFile<ELFT>::initializeSymbols(const object::ELFFile<ELFT> &obj) {
continue;
}
uint32_t secIdx = eSym.st_shndx;
+ if (secIdx == SHN_UNDEF) {
+ undefineds.push_back(i);
+ continue;
+ }
+
if (LLVM_UNLIKELY(secIdx == SHN_XINDEX))
secIdx = check(getExtendedSymbolTableIndex<ELFT>(eSym, i, shndxTable));
else if (secIdx >= SHN_LORESERVE)
@@ -1095,11 +1100,6 @@ void ObjFile<ELFT>::initializeSymbols(const object::ELFFile<ELFT> &obj) {
uint64_t value = eSym.st_value;
uint64_t size = eSym.st_size;
- if (eSym.st_shndx == SHN_UNDEF) {
- undefineds.push_back(i);
- continue;
- }
-
Symbol *sym = symbols[i];
const StringRef name = sym->getName();
if (LLVM_UNLIKELY(eSym.st_shndx == SHN_COMMON)) {
More information about the llvm-commits
mailing list