From fe0d0a9e627f606cd2356cc5b2ee0266e8e3ef38 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 8 Dec 2024 15:59:03 -0800 Subject: [ELF] Merge numSymbols and numELFSyms --- lld/ELF/InputFiles.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'lld/ELF/InputFiles.cpp') diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 2006b3ba3520..0714c8ce6c16 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -528,7 +528,7 @@ template void ELFFileBase::init(InputFile::Kind k) { Fatal(ctx) << this << ": invalid sh_info in symbol table"; elfSyms = reinterpret_cast(eSyms.data()); - numELFSyms = uint32_t(eSyms.size()); + numSymbols = eSyms.size(); stringTable = CHECK2(obj.getStringTableForSymtab(*symtabSec, sections), this); } @@ -1089,10 +1089,8 @@ InputSectionBase *ObjFile::createInputSection(uint32_t idx, template void ObjFile::initializeSymbols(const object::ELFFile &obj) { ArrayRef eSyms = this->getELFSyms(); - if (numSymbols == 0) { - numSymbols = eSyms.size(); + if (!symbols) symbols = std::make_unique(numSymbols); - } // Some entries have been filled by LazyObjFile. auto *symtab = ctx.symtab.get(); @@ -1432,8 +1430,6 @@ template void SharedFile::parse() { const Elf_Shdr *versymSec = nullptr; const Elf_Shdr *verdefSec = nullptr; const Elf_Shdr *verneedSec = nullptr; - - numSymbols = numELFSyms; symbols = std::make_unique(numSymbols); // Search for .dynsym, .dynamic, .symtab, .gnu.version and .gnu.version_d. @@ -1457,7 +1453,7 @@ template void SharedFile::parse() { } } - if (versymSec && numELFSyms == 0) { + if (versymSec && numSymbols == 0) { ErrAlways(ctx) << "SHT_GNU_versym should be associated with symbol table"; return; } @@ -1500,7 +1496,7 @@ template void SharedFile::parse() { // Parse ".gnu.version" section which is a parallel array for the symbol // table. If a given file doesn't have a ".gnu.version" section, we use // VER_NDX_GLOBAL. - size_t size = numELFSyms - firstGlobal; + size_t size = numSymbols - firstGlobal; std::vector versyms(size, VER_NDX_GLOBAL); if (versymSec) { ArrayRef versym = -- cgit v1.2.3