forked from OSchip/llvm-project
COFF: Remove the SymbolBodies vector, and rename SparseSymbolBodies to Symbols.
Differential Revision: https://reviews.llvm.org/D40237 llvm-svn: 318683
This commit is contained in:
parent
d01571353d
commit
80f961ab66
|
|
@ -172,8 +172,7 @@ void ObjFile::initializeChunks() {
|
|||
|
||||
void ObjFile::initializeSymbols() {
|
||||
uint32_t NumSymbols = COFFObj->getNumberOfSymbols();
|
||||
SymbolBodies.reserve(NumSymbols);
|
||||
SparseSymbolBodies.resize(NumSymbols);
|
||||
Symbols.resize(NumSymbols);
|
||||
|
||||
SmallVector<std::pair<Symbol *, uint32_t>, 8> WeakAliases;
|
||||
int32_t LastSectionNumber = 0;
|
||||
|
|
@ -197,10 +196,7 @@ void ObjFile::initializeSymbols() {
|
|||
} else {
|
||||
Sym = createDefined(COFFSym, AuxP, IsFirst);
|
||||
}
|
||||
if (Sym) {
|
||||
SymbolBodies.push_back(Sym);
|
||||
SparseSymbolBodies[I] = Sym;
|
||||
}
|
||||
Symbols[I] = Sym;
|
||||
I += COFFSym.getNumberOfAuxSymbols();
|
||||
LastSectionNumber = COFFSym.getSectionNumber();
|
||||
}
|
||||
|
|
@ -208,7 +204,7 @@ void ObjFile::initializeSymbols() {
|
|||
for (auto &KV : WeakAliases) {
|
||||
Symbol *Sym = KV.first;
|
||||
uint32_t Idx = KV.second;
|
||||
checkAndSetWeakAlias(Symtab, this, Sym, SparseSymbolBodies[Idx]);
|
||||
checkAndSetWeakAlias(Symtab, this, Sym, Symbols[Idx]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +297,7 @@ void ObjFile::initializeSEH() {
|
|||
auto *I = reinterpret_cast<const ulittle32_t *>(A.data());
|
||||
auto *E = reinterpret_cast<const ulittle32_t *>(A.data() + A.size());
|
||||
for (; I != E; ++I)
|
||||
SEHandlers.insert(SparseSymbolBodies[*I]);
|
||||
SEHandlers.insert(Symbols[*I]);
|
||||
}
|
||||
|
||||
MachineTypes ObjFile::getMachineType() {
|
||||
|
|
|
|||
|
|
@ -110,12 +110,12 @@ public:
|
|||
MachineTypes getMachineType() override;
|
||||
std::vector<Chunk *> &getChunks() { return Chunks; }
|
||||
std::vector<SectionChunk *> &getDebugChunks() { return DebugChunks; }
|
||||
std::vector<Symbol *> &getSymbols() { return SymbolBodies; }
|
||||
std::vector<Symbol *> &getSymbols() { return Symbols; }
|
||||
|
||||
// Returns a Symbol object for the SymbolIndex'th symbol in the
|
||||
// underlying object file.
|
||||
Symbol *getSymbol(uint32_t SymbolIndex) {
|
||||
return SparseSymbolBodies[SymbolIndex];
|
||||
return Symbols[SymbolIndex];
|
||||
}
|
||||
|
||||
// Returns the underying COFF file.
|
||||
|
|
@ -162,14 +162,11 @@ private:
|
|||
// null pointer.)
|
||||
std::vector<SectionChunk *> SparseChunks;
|
||||
|
||||
// List of all symbols referenced or defined by this file.
|
||||
std::vector<Symbol *> SymbolBodies;
|
||||
|
||||
// This vector contains the same symbols as SymbolBodies, but they
|
||||
// are indexed such that you can get a Symbol by symbol
|
||||
// This vector contains a list of all symbols defined or referenced by this
|
||||
// file. They are indexed such that you can get a Symbol by symbol
|
||||
// index. Nonexistent indices (which are occupied by auxiliary
|
||||
// symbols in the real symbol table) are filled with null pointers.
|
||||
std::vector<Symbol *> SparseSymbolBodies;
|
||||
std::vector<Symbol *> Symbols;
|
||||
};
|
||||
|
||||
// This type represents import library members that contain DLL names
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ static std::vector<DefinedRegular *> getSymbols() {
|
|||
std::vector<DefinedRegular *> V;
|
||||
for (ObjFile *File : ObjFile::Instances)
|
||||
for (Symbol *B : File->getSymbols())
|
||||
if (auto *Sym = dyn_cast<DefinedRegular>(B))
|
||||
if (auto *Sym = dyn_cast_or_null<DefinedRegular>(B))
|
||||
if (Sym && !Sym->getCOFFSymbol().isSectionDefinition())
|
||||
V.push_back(Sym);
|
||||
return V;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ void SymbolTable::reportRemainingUndefines() {
|
|||
|
||||
for (ObjFile *File : ObjFile::Instances)
|
||||
for (Symbol *Sym : File->getSymbols())
|
||||
if (Undefs.count(Sym))
|
||||
if (Sym && Undefs.count(Sym))
|
||||
errorOrWarn(toString(File) + ": undefined symbol: " + Sym->getName());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue