COFF: Chagne weak alias' type from SymbolBody** to SymbolBody*. NFC.
llvm-svn: 241198
This commit is contained in:
parent
958dab71b3
commit
4897596728
|
@ -195,8 +195,10 @@ Undefined *ObjectFile::createUndefined(COFFSymbolRef Sym) {
|
|||
Undefined *ObjectFile::createWeakExternal(COFFSymbolRef Sym, const void *AuxP) {
|
||||
StringRef Name;
|
||||
COFFObj->getSymbolName(Sym, Name);
|
||||
auto *U = new (Alloc) Undefined(Name);
|
||||
auto *Aux = (const coff_aux_weak_external *)AuxP;
|
||||
return new (Alloc) Undefined(Name, &SparseSymbolBodies[Aux->TagIndex]);
|
||||
U->WeakAlias = SparseSymbolBodies[Aux->TagIndex];
|
||||
return U;
|
||||
}
|
||||
|
||||
Defined *ObjectFile::createDefined(COFFSymbolRef Sym, const void *AuxP,
|
||||
|
|
|
@ -123,11 +123,9 @@ bool SymbolTable::reportRemainingUndefines() {
|
|||
continue;
|
||||
StringRef Name = Undef->getName();
|
||||
// The weak alias may have been resovled, so check for that.
|
||||
if (SymbolBody *Alias = Undef->getWeakAlias()) {
|
||||
if (auto *D = dyn_cast<Defined>(Alias->getReplacement())) {
|
||||
Sym->Body = D;
|
||||
continue;
|
||||
}
|
||||
if (auto *D = dyn_cast_or_null<Defined>(Undef->WeakAlias)) {
|
||||
Sym->Body = D;
|
||||
continue;
|
||||
}
|
||||
// If we can resolve a symbol by removing __imp_ prefix, do that.
|
||||
// This odd rule is for compatibility with MSVC linker.
|
||||
|
@ -181,8 +179,11 @@ std::error_code SymbolTable::addSymbol(SymbolBody *New) {
|
|||
// let the lazy symbol to read a member file.
|
||||
SymbolBody *Existing = Sym->Body;
|
||||
if (auto *L = dyn_cast<Lazy>(Existing)) {
|
||||
// Undefined symbols with weak aliases need not to be resolved,
|
||||
// since they would be replaced with weak aliases if they remain
|
||||
// undefined.
|
||||
if (auto *U = dyn_cast<Undefined>(New))
|
||||
if (!U->getWeakAlias())
|
||||
if (!U->WeakAlias)
|
||||
return addMemberFile(L);
|
||||
Sym->Body = New;
|
||||
return std::error_code();
|
||||
|
|
|
@ -49,7 +49,7 @@ int SymbolBody::compare(SymbolBody *Other) {
|
|||
if (LK != RK) {
|
||||
|
||||
if (RK > LastDefinedKind) {
|
||||
if (LK == LazyKind && cast<Undefined>(Other)->getWeakAlias())
|
||||
if (LK == LazyKind && cast<Undefined>(Other)->WeakAlias)
|
||||
return -1;
|
||||
|
||||
// The LHS is either defined or lazy and so it wins.
|
||||
|
@ -121,7 +121,7 @@ int SymbolBody::compare(SymbolBody *Other) {
|
|||
|
||||
case UndefinedKind:
|
||||
// Don't tie, just pick the LHS unless the RHS has a weak alias.
|
||||
return cast<Undefined>(Other)->getWeakAlias() ? -1 : 1;
|
||||
return cast<Undefined>(Other)->WeakAlias ? -1 : 1;
|
||||
|
||||
case DefinedLocalImportKind:
|
||||
case DefinedImportThunkKind:
|
||||
|
|
|
@ -239,8 +239,7 @@ private:
|
|||
// Undefined symbols.
|
||||
class Undefined : public SymbolBody {
|
||||
public:
|
||||
explicit Undefined(StringRef N, SymbolBody **S = nullptr)
|
||||
: SymbolBody(UndefinedKind, N), Alias(S) {}
|
||||
explicit Undefined(StringRef N) : SymbolBody(UndefinedKind, N) {}
|
||||
|
||||
static bool classof(const SymbolBody *S) {
|
||||
return S->kind() == UndefinedKind;
|
||||
|
@ -250,10 +249,7 @@ public:
|
|||
// undefined symbol a second chance if it would remain undefined.
|
||||
// If it remains undefined, it'll be replaced with whatever the
|
||||
// Alias pointer points to.
|
||||
SymbolBody *getWeakAlias() { return Alias ? *Alias : nullptr; }
|
||||
|
||||
private:
|
||||
SymbolBody **Alias;
|
||||
SymbolBody *WeakAlias = nullptr;
|
||||
};
|
||||
|
||||
// Windows-specific classes.
|
||||
|
|
Loading…
Reference in New Issue