Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lld/COFF
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-07-02 06:59:04 +0300
committerRui Ueyama <ruiu@google.com>2015-07-02 06:59:04 +0300
commit458d74421b002dd670e1ac5f961b703cfb3749b4 (patch)
tree97a31daa60f35ecbad74e91ef54a3ceb550c953b /lld/COFF
parent00396513046275f17c0e321bd8a5cc27080a3fa2 (diff)
COFF: Merge SymbolTable::find{,Symbol}. NFC
llvm-svn: 241238
Diffstat (limited to 'lld/COFF')
-rw-r--r--lld/COFF/Driver.cpp4
-rw-r--r--lld/COFF/SymbolTable.cpp17
-rw-r--r--lld/COFF/SymbolTable.h8
-rw-r--r--lld/COFF/Writer.cpp5
4 files changed, 12 insertions, 22 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 8c51030a7d55..e9be0759e139 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -218,7 +218,7 @@ StringRef LinkerDriver::findDefaultEntry() {
{"wWinMain", "wWinMainCRTStartup"},
};
for (auto E : Entries) {
- Symbol *Sym = Symtab.findSymbol(E[0]);
+ Symbol *Sym = Symtab.find(E[0]);
if (Sym && !isa<Undefined>(Sym->Body))
return E[1];
}
@@ -575,7 +575,7 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) {
for (auto Pair : Config->AlternateNames) {
StringRef From = Pair.first;
StringRef To = Pair.second;
- Symbol* Sym = Symtab.findSymbol(From);
+ Symbol *Sym = Symtab.find(From);
if (!Sym)
continue;
if (auto *U = dyn_cast<Undefined>(Sym->Body))
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index ca4c6fa835bf..53e4ee8c88f0 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -141,8 +141,10 @@ bool SymbolTable::reportRemainingUndefines() {
// If we can resolve a symbol by removing __imp_ prefix, do that.
// This odd rule is for compatibility with MSVC linker.
if (Name.startswith("__imp_")) {
- if (Defined *Imp = find(Name.substr(strlen("__imp_")))) {
- auto *S = new (Alloc) DefinedLocalImport(Name, Imp);
+ Symbol *Imp = find(Name.substr(strlen("__imp_")));
+ if (Imp && isa<Defined>(Imp->Body)) {
+ auto *D = cast<Defined>(Imp->Body);
+ auto *S = new (Alloc) DefinedLocalImport(Name, D);
LocalImportChunks.push_back(S->getChunk());
Sym->Body = S;
continue;
@@ -241,16 +243,7 @@ std::vector<Chunk *> SymbolTable::getChunks() {
return Res;
}
-Defined *SymbolTable::find(StringRef Name) {
- auto It = Symtab.find(Name);
- if (It == Symtab.end())
- return nullptr;
- if (auto *Def = dyn_cast<Defined>(It->second->Body))
- return Def;
- return nullptr;
-}
-
-Symbol *SymbolTable::findSymbol(StringRef Name) {
+Symbol *SymbolTable::find(StringRef Name) {
auto It = Symtab.find(Name);
if (It == Symtab.end())
return nullptr;
diff --git a/lld/COFF/SymbolTable.h b/lld/COFF/SymbolTable.h
index 188b2382fb4b..996732296aa9 100644
--- a/lld/COFF/SymbolTable.h
+++ b/lld/COFF/SymbolTable.h
@@ -53,12 +53,8 @@ public:
// Returns a list of chunks of selected symbols.
std::vector<Chunk *> getChunks();
- // Returns a symbol for a given name. It's not guaranteed that the
- // returned symbol actually has the same name (because of various
- // mechanisms to allow aliases, a name can be resolved to a
- // different symbol). Returns a nullptr if not found.
- Defined *find(StringRef Name);
- Symbol *findSymbol(StringRef Name);
+ // Returns a symbol for a given name. Returns a nullptr if not found.
+ Symbol *find(StringRef Name);
// Occasionally we have to resolve an undefined symbol to its
// mangled symbol. This function tries to find a mangled name
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index ccc6419a4d61..5c242e4dc5df 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -235,7 +235,8 @@ void Writer::createImportTables() {
Sec->addChunk(C);
}
if (!DelayIdata.empty()) {
- DelayIdata.create(Symtab->find("__delayLoadHelper2"));
+ Defined *Helper = cast<Defined>(Symtab->find("__delayLoadHelper2")->Body);
+ DelayIdata.create(Helper);
OutputSection *Sec = createSection(".didat");
for (Chunk *C : DelayIdata.getChunks())
Sec->addChunk(C);
@@ -526,7 +527,7 @@ OutputSection *Writer::createSection(StringRef Name) {
// Dest is .reloc section. Add contents to that section.
void Writer::addBaserels(OutputSection *Dest) {
std::vector<uint32_t> V;
- Defined *ImageBase = cast<Defined>(Symtab->find("__ImageBase"));
+ Defined *ImageBase = cast<Defined>(Symtab->find("__ImageBase")->Body);
for (OutputSection *Sec : OutputSections) {
if (Sec == Dest)
continue;