Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -942,8 +942,8 @@ for (InputFile *File : Files) if (auto *F = dyn_cast(File)) if (All || Libs.count(path::filename(F->getName()))) - for (Symbol *Sym : F->getSymbols()) - Sym->VersionId = VER_NDX_LOCAL; + for (SymbolBody *Sym : F->getSymbols()) + Sym->symbol()->VersionId = VER_NDX_LOCAL; } // Do actual linking. Note that when this function is called, Index: ELF/InputFiles.h =================================================================== --- ELF/InputFiles.h +++ ELF/InputFiles.h @@ -126,11 +126,11 @@ uint32_t getSectionIndex(const Elf_Sym &Sym) const; - Elf_Sym_Range getGlobalSymbols(); - Elf_Sym_Range getELFSymbols() const { return Symbols; } + Elf_Sym_Range getGlobalELFSymbols(); + Elf_Sym_Range getELFSymbols() const { return ELFSymbols; } protected: - ArrayRef Symbols; + ArrayRef ELFSymbols; uint32_t FirstNonLocal = 0; ArrayRef SymtabSHNDX; StringRef StringTable; @@ -244,7 +244,7 @@ InputFile *fetch(); private: - std::vector getSymbols(); + std::vector getSymbolNames(); template std::vector getElfSymbols(); std::vector getBitcodeSymbols(); @@ -258,7 +258,7 @@ explicit ArchiveFile(std::unique_ptr &&File); static bool classof(const InputFile *F) { return F->kind() == ArchiveKind; } template void parse(); - ArrayRef getSymbols() { return Symbols; } + ArrayRef getSymbols() { return Symbols; } // Returns a memory buffer for a given symbol and the offset in the archive // for the member. An empty memory buffer and an offset of zero @@ -269,7 +269,7 @@ private: std::unique_ptr File; llvm::DenseSet Seen; - std::vector Symbols; + std::vector Symbols; }; class BitcodeFile : public InputFile { @@ -279,12 +279,12 @@ static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; } template void parse(llvm::DenseSet &ComdatGroups); - ArrayRef getSymbols() { return Symbols; } + ArrayRef getSymbols() { return Symbols; } std::unique_ptr Obj; static std::vector Instances; private: - std::vector Symbols; + std::vector Symbols; }; // .so file. Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -133,13 +133,13 @@ } template -typename ELFT::SymRange ELFFileBase::getGlobalSymbols() { - return makeArrayRef(Symbols.begin() + FirstNonLocal, Symbols.end()); +typename ELFT::SymRange ELFFileBase::getGlobalELFSymbols() { + return makeArrayRef(ELFSymbols.begin() + FirstNonLocal, ELFSymbols.end()); } template uint32_t ELFFileBase::getSectionIndex(const Elf_Sym &Sym) const { - return check(getObj().getSectionIndex(&Sym, Symbols, SymtabSHNDX), + return check(getObj().getSectionIndex(&Sym, ELFSymbols, SymtabSHNDX), toString(this)); } @@ -147,8 +147,8 @@ void ELFFileBase::initSymtab(ArrayRef Sections, const Elf_Shdr *Symtab) { FirstNonLocal = Symtab->sh_info; - Symbols = check(getObj().symbols(Symtab), toString(this)); - if (FirstNonLocal == 0 || FirstNonLocal > Symbols.size()) + ELFSymbols = check(getObj().symbols(Symtab), toString(this)); + if (FirstNonLocal == 0 || FirstNonLocal > ELFSymbols.size()) fatal(toString(this) + ": invalid sh_info in symbol table"); StringTable = check(getObj().getStringTableForSymtab(*Symtab, Sections), @@ -188,13 +188,13 @@ const Elf_Shdr &Sec) { // Group signatures are stored as symbol names in object files. // sh_info contains a symbol index, so we fetch a symbol and read its name. - if (this->Symbols.empty()) + if (this->ELFSymbols.empty()) this->initSymtab( Sections, check(object::getSection(Sections, Sec.sh_link), toString(this))); const Elf_Sym *Sym = check( - object::getSymbol(this->Symbols, Sec.sh_info), toString(this)); + object::getSymbol(this->ELFSymbols, Sec.sh_info), toString(this)); StringRef Signature = check(Sym->getName(this->StringTable), toString(this)); // As a special case, if a symbol is a section symbol and has no name, @@ -523,8 +523,8 @@ } template void ObjFile::initializeSymbols() { - SymbolBodies.reserve(this->Symbols.size()); - for (const Elf_Sym &Sym : this->Symbols) + SymbolBodies.reserve(this->ELFSymbols.size()); + for (const Elf_Sym &Sym : this->ELFSymbols) SymbolBodies.push_back(createSymbolBody(&Sym)); } @@ -617,7 +617,7 @@ template void ArchiveFile::parse() { Symbols.reserve(File->getNumberOfSymbols()); for (const Archive::Symbol &Sym : File->symbols()) - Symbols.push_back(Symtab->addLazyArchive(this, Sym)); + Symbols.push_back(Symtab->addLazyArchive(this, Sym)->body()); } // Returns a buffer pointing to a member file containing a given symbol. @@ -654,7 +654,7 @@ const typename ELFT::Shdr * SharedFile::getSection(const Elf_Sym &Sym) const { return check( - this->getObj().getSection(&Sym, this->Symbols, this->SymtabSHNDX), + this->getObj().getSection(&Sym, this->ELFSymbols, this->SymtabSHNDX), toString(this)); } @@ -689,7 +689,7 @@ } } - if (this->VersymSec && this->Symbols.empty()) + if (this->VersymSec && this->ELFSymbols.empty()) error("SHT_GNU_versym should be associated with symbol table"); // Search for a DT_SONAME tag to initialize this->SoName. @@ -756,7 +756,7 @@ const Elf_Versym *Versym = nullptr; std::vector Verdefs = parseVerdefs(Versym); - Elf_Sym_Range Syms = this->getGlobalSymbols(); + Elf_Sym_Range Syms = this->getGlobalELFSymbols(); for (const Elf_Sym &Sym : Syms) { unsigned VersymIndex = 0; if (Versym) { @@ -899,7 +899,8 @@ KeptComdats.push_back(ComdatGroups.insert(CachedHashStringRef(S)).second); for (const lto::InputFile::Symbol &ObjSym : Obj->symbols()) - Symbols.push_back(createBitcodeSymbol(KeptComdats, ObjSym, this)); + Symbols.push_back( + createBitcodeSymbol(KeptComdats, ObjSym, this)->body()); } static ELFKind getELFKind(MemoryBufferRef MB) { @@ -1001,7 +1002,7 @@ } template void LazyObjFile::parse() { - for (StringRef Sym : getSymbols()) + for (StringRef Sym : getSymbolNames()) Symtab->addLazyObject(Sym, *this); } @@ -1041,7 +1042,7 @@ } // Returns a vector of globally-visible defined symbol names. -std::vector LazyObjFile::getSymbols() { +std::vector LazyObjFile::getSymbolNames() { if (isBitcode(this->MB)) return getBitcodeSymbols(); Index: ELF/LTO.cpp =================================================================== --- ELF/LTO.cpp +++ ELF/LTO.cpp @@ -127,15 +127,15 @@ void BitcodeCompiler::add(BitcodeFile &F) { lto::InputFile &Obj = *F.Obj; unsigned SymNum = 0; - std::vector Syms = F.getSymbols(); + std::vector Syms = F.getSymbols(); std::vector Resols(Syms.size()); // Provide a resolution to the LTO API for each symbol. for (const lto::InputFile::Symbol &ObjSym : Obj.symbols()) { - Symbol *Sym = Syms[SymNum]; + SymbolBody *B = Syms[SymNum]; + Symbol *Sym = B->symbol(); lto::SymbolResolution &R = Resols[SymNum]; ++SymNum; - SymbolBody *B = Sym->body(); // Ideally we shouldn't check for SF_Undefined but currently IRObjectFile // reports two symbols for module ASM defined. Without this check, lld Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -457,7 +457,7 @@ uint64_t Value = SS->getValue(); std::vector Ret; - for (const Elf_Sym &S : File->getGlobalSymbols()) { + for (const Elf_Sym &S : File->getGlobalELFSymbols()) { if (S.st_shndx != Shndx || S.st_value != Value) continue; StringRef Name = check(S.getName(File->getStringTable()));