diff options
-rw-r--r-- | lld/COFF/SymbolTable.cpp | 2 | ||||
-rw-r--r-- | lld/COFF/Symbols.h | 2 | ||||
-rw-r--r-- | lld/COFF/Writer.cpp | 31 |
3 files changed, 15 insertions, 20 deletions
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp index b71ab878653..23c79ca936c 100644 --- a/lld/COFF/SymbolTable.cpp +++ b/lld/COFF/SymbolTable.cpp @@ -325,7 +325,7 @@ void SymbolTable::printMap(llvm::raw_ostream &OS) { OS << File->getShortName() << ":\n"; for (SymbolBody *Body : File->getSymbols()) if (auto *R = dyn_cast<DefinedRegular>(Body)) - if (!R->isCOMDAT() || R->isLive()) + if (R->getChunk()->isLive()) OS << Twine::utohexstr(Config->ImageBase + R->getRVA()) << " " << R->getName() << "\n"; } diff --git a/lld/COFF/Symbols.h b/lld/COFF/Symbols.h index b51d9069c97..7423d9b9819 100644 --- a/lld/COFF/Symbols.h +++ b/lld/COFF/Symbols.h @@ -181,8 +181,6 @@ public: uint64_t getRVA() { return (*Data)->getRVA() + Sym->Value; } bool isCOMDAT() { return IsCOMDAT; } - bool isLive() const { return (*Data)->isLive(); } - void markLive() { (*Data)->markLive(); } SectionChunk *getChunk() { return *Data; } uint32_t getValue() { return Sym->Value; } diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp index b133d1c5701..82502ea7078 100644 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -257,14 +257,17 @@ void Writer::markLive() { if (SC->isLive()) Worklist.push_back(SC); + auto Enqueue = [&](SectionChunk *C) { + if (C->isLive()) + return; + C->markLive(); + Worklist.push_back(C); + }; + // Add GC root chunks. - for (Undefined *U : Config->GCRoot) { - auto *D = dyn_cast<DefinedRegular>(U->repl()); - if (!D || D->isLive()) - continue; - D->markLive(); - Worklist.push_back(D->getChunk()); - } + for (Undefined *U : Config->GCRoot) + if (auto *D = dyn_cast<DefinedRegular>(U->repl())) + Enqueue(D->getChunk()); while (!Worklist.empty()) { SectionChunk *SC = Worklist.pop_back_val(); @@ -273,17 +276,11 @@ void Writer::markLive() { // Mark all symbols listed in the relocation table for this section. for (SymbolBody *S : SC->symbols()) if (auto *D = dyn_cast<DefinedRegular>(S->repl())) - if (!D->isLive()) { - D->markLive(); - Worklist.push_back(D->getChunk()); - } + Enqueue(D->getChunk()); // Mark associative sections if any. - for (SectionChunk *ChildSC : SC->children()) - if (!ChildSC->isLive()) { - ChildSC->markLive(); - Worklist.push_back(ChildSC); - } + for (SectionChunk *C : SC->children()) + Enqueue(C); } } @@ -434,7 +431,7 @@ size_t Writer::addEntryToStringTable(StringRef Str) { Optional<coff_symbol16> Writer::createSymbol(Defined *Def) { if (auto *D = dyn_cast<DefinedRegular>(Def)) - if (!D->isLive()) + if (!D->getChunk()->isLive()) return None; coff_symbol16 Sym; |