Skip to content

Commit 7f7d2b2

Browse files
committed
Move code for symbol resolution from SymbolTable.cpp to Symbols.cpp.
My recent commits separated symbol resolution from the symbol table, so the functions to resolve symbols are now in a somewhat wrong file. This patch moves it to Symbols.cpp. The functions are now member functions of the symbol. This is code move change. I modified function names so that they are appropriate as member functions, though. No functionality change intended. Differential Revision: https://reviews.llvm.org/D62290 llvm-svn: 361474
1 parent 4254840 commit 7f7d2b2

File tree

7 files changed

+364
-351
lines changed

7 files changed

+364
-351
lines changed

lld/ELF/Driver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ static void handleUndefined(StringRef Name) {
13141314
Sym->IsUsedInRegularObj = true;
13151315

13161316
if (Sym->isLazy())
1317-
Symtab->fetchLazy(Sym);
1317+
Sym->fetch();
13181318
}
13191319

13201320
static void handleLibcall(StringRef Name) {
@@ -1329,7 +1329,7 @@ static void handleLibcall(StringRef Name) {
13291329
MB = cast<LazyArchive>(Sym)->getMemberBuffer();
13301330

13311331
if (isBitcode(MB))
1332-
Symtab->fetchLazy(Sym);
1332+
Sym->fetch();
13331333
}
13341334

13351335
// Replaces common symbols with defined symbols reside in .bss sections.

lld/ELF/InputFiles.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -963,8 +963,7 @@ template <class ELFT> void ObjFile<ELFT>::initializeSymbols() {
963963

964964
// Handle global undefined symbols.
965965
if (ESym.st_shndx == SHN_UNDEF) {
966-
resolveSymbol(this->Symbols[I],
967-
Undefined{this, Name, Binding, StOther, Type});
966+
this->Symbols[I]->resolve(Undefined{this, Name, Binding, StOther, Type});
968967
continue;
969968
}
970969

@@ -973,8 +972,8 @@ template <class ELFT> void ObjFile<ELFT>::initializeSymbols() {
973972
if (Value == 0 || Value >= UINT32_MAX)
974973
fatal(toString(this) + ": common symbol '" + StringRef(Name.Data) +
975974
"' has invalid alignment: " + Twine(Value));
976-
resolveSymbol(this->Symbols[I], CommonSymbol{this, Name, Binding, StOther,
977-
Type, Value, Size});
975+
this->Symbols[I]->resolve(
976+
CommonSymbol{this, Name, Binding, StOther, Type, Value, Size});
978977
continue;
979978
}
980979

@@ -984,16 +983,16 @@ template <class ELFT> void ObjFile<ELFT>::initializeSymbols() {
984983
// COMDAT member sections, and if a comdat group is discarded, some
985984
// defined symbol in a .eh_frame becomes dangling symbols.
986985
if (Sec == &InputSection::Discarded) {
987-
resolveSymbol(this->Symbols[I],
988-
Undefined{this, Name, Binding, StOther, Type, SecIdx});
986+
this->Symbols[I]->resolve(
987+
Undefined{this, Name, Binding, StOther, Type, SecIdx});
989988
continue;
990989
}
991990

992991
// Handle global defined symbols.
993992
if (Binding == STB_GLOBAL || Binding == STB_WEAK ||
994993
Binding == STB_GNU_UNIQUE) {
995-
resolveSymbol(this->Symbols[I], Defined{this, Name, Binding, StOther,
996-
Type, Value, Size, Sec});
994+
this->Symbols[I]->resolve(
995+
Defined{this, Name, Binding, StOther, Type, Value, Size, Sec});
997996
continue;
998997
}
999998

@@ -1532,13 +1531,13 @@ template <class ELFT> void LazyObjFile::parse() {
15321531

15331532
// Replace existing symbols with LazyObject symbols.
15341533
//
1535-
// resolveSymbol() may trigger this->fetch() if an existing symbol
1536-
// is an undefined symbol. If that happens, this LazyObjFile has
1537-
// served its purpose, and we can exit from the loop early.
1534+
// resolve() may trigger this->fetch() if an existing symbol is an
1535+
// undefined symbol. If that happens, this LazyObjFile has served
1536+
// its purpose, and we can exit from the loop early.
15381537
for (Symbol *Sym : this->Symbols) {
15391538
if (!Sym)
15401539
continue;
1541-
resolveSymbol(Sym, LazyObject{*this, Sym->getName()});
1540+
Sym->resolve(LazyObject{*this, Sym->getName()});
15421541
if (AddedToLink)
15431542
return;
15441543
}

lld/ELF/LinkerScript.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void LinkerScript::addSymbol(SymbolAssignment *Cmd) {
185185
0, Sec);
186186

187187
Symbol *Sym = Symtab->insert(Cmd->Name);
188-
mergeSymbolProperties(Sym, New);
188+
Sym->mergeProperties(New);
189189
Sym->replace(New);
190190
Cmd->Sym = cast<Defined>(Sym);
191191
}
@@ -202,7 +202,7 @@ static void declareSymbol(SymbolAssignment *Cmd) {
202202

203203
// We can't calculate final value right now.
204204
Symbol *Sym = Symtab->insert(Cmd->Name);
205-
mergeSymbolProperties(Sym, New);
205+
Sym->mergeProperties(New);
206206
Sym->replace(New);
207207

208208
Cmd->Sym = cast<Defined>(Sym);

0 commit comments

Comments
 (0)