[LLD][COFF] Introduce Symbol::getDefined helper. (NFC) (#151253)
This commit is contained in:
parent
1e504bef20
commit
aac70d69f6
@ -1318,13 +1318,9 @@ void LinkerDriver::convertResources() {
|
||||
}
|
||||
|
||||
void LinkerDriver::maybeCreateECExportThunk(StringRef name, Symbol *&sym) {
|
||||
Defined *def;
|
||||
if (!sym)
|
||||
return;
|
||||
if (auto undef = dyn_cast<Undefined>(sym))
|
||||
def = undef->getDefinedWeakAlias();
|
||||
else
|
||||
def = dyn_cast<Defined>(sym);
|
||||
Defined *def = sym->getDefined();
|
||||
if (!def)
|
||||
return;
|
||||
|
||||
@ -1356,11 +1352,7 @@ void LinkerDriver::createECExportThunks() {
|
||||
Symbol *sym = ctx.symtab.find(targetName);
|
||||
if (!sym)
|
||||
continue;
|
||||
Defined *targetSym;
|
||||
if (auto undef = dyn_cast<Undefined>(sym))
|
||||
targetSym = undef->getDefinedWeakAlias();
|
||||
else
|
||||
targetSym = dyn_cast<Defined>(sym);
|
||||
Defined *targetSym = sym->getDefined();
|
||||
if (!targetSym)
|
||||
continue;
|
||||
|
||||
|
@ -91,6 +91,14 @@ bool Symbol::isLive() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
Defined *Symbol::getDefined() {
|
||||
if (auto d = dyn_cast<Defined>(this))
|
||||
return d;
|
||||
if (auto u = dyn_cast<Undefined>(this))
|
||||
return u->getDefinedWeakAlias();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Symbol::replaceKeepingName(Symbol *other, size_t size) {
|
||||
StringRef origName = getName();
|
||||
memcpy(this, other, size);
|
||||
|
@ -95,6 +95,10 @@ public:
|
||||
symbolKind == LazyDLLSymbolKind;
|
||||
}
|
||||
|
||||
// Get the Defined symbol associated with this symbol, either itself or its
|
||||
// weak alias.
|
||||
Defined *getDefined();
|
||||
|
||||
private:
|
||||
void computeName();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user