@@ -528,7 +528,7 @@ template <class ELFT> void ELFFileBase::init(InputFile::Kind k) {
528
528
Fatal (ctx) << this << " : invalid sh_info in symbol table" ;
529
529
530
530
elfSyms = reinterpret_cast <const void *>(eSyms.data ());
531
- numELFSyms = uint32_t ( eSyms.size () );
531
+ numSymbols = eSyms.size ();
532
532
stringTable = CHECK2 (obj.getStringTableForSymtab (*symtabSec, sections), this );
533
533
}
534
534
@@ -1089,10 +1089,8 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx,
1089
1089
template <class ELFT >
1090
1090
void ObjFile<ELFT>::initializeSymbols(const object::ELFFile<ELFT> &obj) {
1091
1091
ArrayRef<Elf_Sym> eSyms = this ->getELFSyms <ELFT>();
1092
- if (numSymbols == 0 ) {
1093
- numSymbols = eSyms.size ();
1092
+ if (!symbols)
1094
1093
symbols = std::make_unique<Symbol *[]>(numSymbols);
1095
- }
1096
1094
1097
1095
// Some entries have been filled by LazyObjFile.
1098
1096
auto *symtab = ctx.symtab .get ();
@@ -1432,8 +1430,6 @@ template <class ELFT> void SharedFile::parse() {
1432
1430
const Elf_Shdr *versymSec = nullptr ;
1433
1431
const Elf_Shdr *verdefSec = nullptr ;
1434
1432
const Elf_Shdr *verneedSec = nullptr ;
1435
-
1436
- numSymbols = numELFSyms;
1437
1433
symbols = std::make_unique<Symbol *[]>(numSymbols);
1438
1434
1439
1435
// Search for .dynsym, .dynamic, .symtab, .gnu.version and .gnu.version_d.
@@ -1457,7 +1453,7 @@ template <class ELFT> void SharedFile::parse() {
1457
1453
}
1458
1454
}
1459
1455
1460
- if (versymSec && numELFSyms == 0 ) {
1456
+ if (versymSec && numSymbols == 0 ) {
1461
1457
ErrAlways (ctx) << " SHT_GNU_versym should be associated with symbol table" ;
1462
1458
return ;
1463
1459
}
@@ -1500,7 +1496,7 @@ template <class ELFT> void SharedFile::parse() {
1500
1496
// Parse ".gnu.version" section which is a parallel array for the symbol
1501
1497
// table. If a given file doesn't have a ".gnu.version" section, we use
1502
1498
// VER_NDX_GLOBAL.
1503
- size_t size = numELFSyms - firstGlobal;
1499
+ size_t size = numSymbols - firstGlobal;
1504
1500
std::vector<uint16_t > versyms (size, VER_NDX_GLOBAL);
1505
1501
if (versymSec) {
1506
1502
ArrayRef<Elf_Versym> versym =
0 commit comments