[LLD][COFF] Move getChunk to LinkerDriver (NFC) (#123103)
The `getChunk` function returns all chunks, not just those specific to a symbol table. Move it out of the `SymbolTable` class to clarify its scope.
This commit is contained in:
parent
d004947ac5
commit
1bd5f34d76
@ -175,6 +175,15 @@ llvm::Triple::ArchType LinkerDriver::getArch() {
|
|||||||
return getMachineArchType(ctx.config.machine);
|
return getMachineArchType(ctx.config.machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Chunk *> LinkerDriver::getChunks() const {
|
||||||
|
std::vector<Chunk *> res;
|
||||||
|
for (ObjFile *file : ctx.objFileInstances) {
|
||||||
|
ArrayRef<Chunk *> v = file->getChunks();
|
||||||
|
res.insert(res.end(), v.begin(), v.end());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static bool compatibleMachineType(COFFLinkerContext &ctx, MachineTypes mt) {
|
static bool compatibleMachineType(COFFLinkerContext &ctx, MachineTypes mt) {
|
||||||
if (mt == IMAGE_FILE_MACHINE_UNKNOWN)
|
if (mt == IMAGE_FILE_MACHINE_UNKNOWN)
|
||||||
return true;
|
return true;
|
||||||
@ -1093,7 +1102,7 @@ void LinkerDriver::parseOrderFile(StringRef arg) {
|
|||||||
|
|
||||||
// Get a list of all comdat sections for error checking.
|
// Get a list of all comdat sections for error checking.
|
||||||
DenseSet<StringRef> set;
|
DenseSet<StringRef> set;
|
||||||
for (Chunk *c : ctx.symtab.getChunks())
|
for (Chunk *c : ctx.driver.getChunks())
|
||||||
if (auto *sec = dyn_cast<SectionChunk>(c))
|
if (auto *sec = dyn_cast<SectionChunk>(c))
|
||||||
if (sec->sym)
|
if (sec->sym)
|
||||||
set.insert(sec->sym->getName());
|
set.insert(sec->sym->getName());
|
||||||
|
@ -94,6 +94,9 @@ public:
|
|||||||
|
|
||||||
void enqueuePath(StringRef path, bool wholeArchive, bool lazy);
|
void enqueuePath(StringRef path, bool wholeArchive, bool lazy);
|
||||||
|
|
||||||
|
// Returns a list of chunks of selected symbols.
|
||||||
|
std::vector<Chunk *> getChunks() const;
|
||||||
|
|
||||||
std::unique_ptr<llvm::TarWriter> tar; // for /linkrepro
|
std::unique_ptr<llvm::TarWriter> tar; // for /linkrepro
|
||||||
|
|
||||||
void pullArm64ECIcallHelper();
|
void pullArm64ECIcallHelper();
|
||||||
|
@ -264,7 +264,7 @@ void ICF::run() {
|
|||||||
|
|
||||||
// Collect only mergeable sections and group by hash value.
|
// Collect only mergeable sections and group by hash value.
|
||||||
uint32_t nextId = 1;
|
uint32_t nextId = 1;
|
||||||
for (Chunk *c : ctx.symtab.getChunks()) {
|
for (Chunk *c : ctx.driver.getChunks()) {
|
||||||
if (auto *sc = dyn_cast<SectionChunk>(c)) {
|
if (auto *sc = dyn_cast<SectionChunk>(c)) {
|
||||||
if (isEligible(sc))
|
if (isEligible(sc))
|
||||||
chunks.push_back(sc);
|
chunks.push_back(sc);
|
||||||
|
@ -31,7 +31,7 @@ void markLive(COFFLinkerContext &ctx) {
|
|||||||
// COMDAT section chunks are dead by default. Add non-COMDAT chunks. Do not
|
// COMDAT section chunks are dead by default. Add non-COMDAT chunks. Do not
|
||||||
// traverse DWARF sections. They are live, but they should not keep other
|
// traverse DWARF sections. They are live, but they should not keep other
|
||||||
// sections alive.
|
// sections alive.
|
||||||
for (Chunk *c : ctx.symtab.getChunks())
|
for (Chunk *c : ctx.driver.getChunks())
|
||||||
if (auto *sc = dyn_cast<SectionChunk>(c))
|
if (auto *sc = dyn_cast<SectionChunk>(c))
|
||||||
if (sc->live && !sc->isDWARF())
|
if (sc->live && !sc->isDWARF())
|
||||||
worklist.push_back(sc);
|
worklist.push_back(sc);
|
||||||
|
@ -945,15 +945,6 @@ void SymbolTable::addLibcall(StringRef name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Chunk *> SymbolTable::getChunks() const {
|
|
||||||
std::vector<Chunk *> res;
|
|
||||||
for (ObjFile *file : ctx.objFileInstances) {
|
|
||||||
ArrayRef<Chunk *> v = file->getChunks();
|
|
||||||
res.insert(res.end(), v.begin(), v.end());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
Symbol *SymbolTable::find(StringRef name) const {
|
Symbol *SymbolTable::find(StringRef name) const {
|
||||||
return symMap.lookup(CachedHashStringRef(name));
|
return symMap.lookup(CachedHashStringRef(name));
|
||||||
}
|
}
|
||||||
|
@ -67,9 +67,6 @@ public:
|
|||||||
void loadMinGWSymbols();
|
void loadMinGWSymbols();
|
||||||
bool handleMinGWAutomaticImport(Symbol *sym, StringRef name);
|
bool handleMinGWAutomaticImport(Symbol *sym, StringRef name);
|
||||||
|
|
||||||
// Returns a list of chunks of selected symbols.
|
|
||||||
std::vector<Chunk *> getChunks() const;
|
|
||||||
|
|
||||||
// Returns a symbol for a given name. Returns a nullptr if not found.
|
// Returns a symbol for a given name. Returns a nullptr if not found.
|
||||||
Symbol *find(StringRef name) const;
|
Symbol *find(StringRef name) const;
|
||||||
Symbol *findUnderscore(StringRef name) const;
|
Symbol *findUnderscore(StringRef name) const;
|
||||||
|
@ -1077,7 +1077,7 @@ void Writer::createSections() {
|
|||||||
dtorsSec = createSection(".dtors", data | r | w);
|
dtorsSec = createSection(".dtors", data | r | w);
|
||||||
|
|
||||||
// Then bin chunks by name and output characteristics.
|
// Then bin chunks by name and output characteristics.
|
||||||
for (Chunk *c : ctx.symtab.getChunks()) {
|
for (Chunk *c : ctx.driver.getChunks()) {
|
||||||
auto *sc = dyn_cast<SectionChunk>(c);
|
auto *sc = dyn_cast<SectionChunk>(c);
|
||||||
if (sc && !sc->live) {
|
if (sc && !sc->live) {
|
||||||
if (ctx.config.verbose)
|
if (ctx.config.verbose)
|
||||||
@ -2219,7 +2219,7 @@ void Writer::createECChunks() {
|
|||||||
void Writer::createRuntimePseudoRelocs() {
|
void Writer::createRuntimePseudoRelocs() {
|
||||||
std::vector<RuntimePseudoReloc> rels;
|
std::vector<RuntimePseudoReloc> rels;
|
||||||
|
|
||||||
for (Chunk *c : ctx.symtab.getChunks()) {
|
for (Chunk *c : ctx.driver.getChunks()) {
|
||||||
auto *sc = dyn_cast<SectionChunk>(c);
|
auto *sc = dyn_cast<SectionChunk>(c);
|
||||||
if (!sc || !sc->live)
|
if (!sc || !sc->live)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user