diff options
author | Rui Ueyama <ruiu@google.com> | 2015-07-02 01:32:23 +0300 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2015-07-02 01:32:23 +0300 |
commit | 489759672814aab8af90985efef1d4812266e9a5 (patch) | |
tree | e72e9f5404f512740d1a4ea4975981b285d1860c /lld/COFF | |
parent | 958dab71b3bbc4d2051a93ac3eda2693e5f82d0a (diff) |
COFF: Chagne weak alias' type from SymbolBody** to SymbolBody*. NFC.
llvm-svn: 241198
Diffstat (limited to 'lld/COFF')
-rw-r--r-- | lld/COFF/InputFiles.cpp | 4 | ||||
-rw-r--r-- | lld/COFF/SymbolTable.cpp | 13 | ||||
-rw-r--r-- | lld/COFF/Symbols.cpp | 4 | ||||
-rw-r--r-- | lld/COFF/Symbols.h | 8 |
4 files changed, 14 insertions, 15 deletions
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index 9187504280cb..845f3e502c35 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -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, diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp index 8a4ad59e5190..51cf3de1d1d7 100644 --- a/lld/COFF/SymbolTable.cpp +++ b/lld/COFF/SymbolTable.cpp @@ -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(); diff --git a/lld/COFF/Symbols.cpp b/lld/COFF/Symbols.cpp index 883666e5780b..58eb1908043c 100644 --- a/lld/COFF/Symbols.cpp +++ b/lld/COFF/Symbols.cpp @@ -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: diff --git a/lld/COFF/Symbols.h b/lld/COFF/Symbols.h index ae7e3b5075e8..86ed2b321f0c 100644 --- a/lld/COFF/Symbols.h +++ b/lld/COFF/Symbols.h @@ -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. |