summaryrefslogtreecommitdiff
path: root/lld/COFF/MinGW.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/COFF/MinGW.cpp')
-rw-r--r--lld/COFF/MinGW.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index 7c1891e67d45..148ebe5eea66 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "MinGW.h"
+#include "COFFLinkerContext.h"
#include "Driver.h"
#include "InputFiles.h"
#include "SymbolTable.h"
@@ -122,7 +123,8 @@ void AutoExporter::addWholeArchive(StringRef path) {
excludeLibs.erase(libName);
}
-bool AutoExporter::shouldExport(Defined *sym) const {
+bool AutoExporter::shouldExport(const COFFLinkerContext &ctx,
+ Defined *sym) const {
if (!sym || !sym->getChunk())
return false;
@@ -141,7 +143,7 @@ bool AutoExporter::shouldExport(Defined *sym) const {
return false;
// If a corresponding __imp_ symbol exists and is defined, don't export it.
- if (symtab->find(("__imp_" + sym->getName()).str()))
+ if (ctx.symtab.find(("__imp_" + sym->getName()).str()))
return false;
// Check that file is non-null before dereferencing it, symbols not
@@ -192,7 +194,7 @@ static StringRef mangle(Twine sym) {
// like they are not being used at all, so we explicitly set some flags so
// that LTO won't eliminate them.
std::vector<WrappedSymbol>
-lld::coff::addWrappedSymbols(opt::InputArgList &args) {
+lld::coff::addWrappedSymbols(COFFLinkerContext &ctx, opt::InputArgList &args) {
std::vector<WrappedSymbol> v;
DenseSet<StringRef> seen;
@@ -201,18 +203,18 @@ lld::coff::addWrappedSymbols(opt::InputArgList &args) {
if (!seen.insert(name).second)
continue;
- Symbol *sym = symtab->findUnderscore(name);
+ Symbol *sym = ctx.symtab.findUnderscore(name);
if (!sym)
continue;
- Symbol *real = symtab->addUndefined(mangle("__real_" + name));
- Symbol *wrap = symtab->addUndefined(mangle("__wrap_" + name));
+ Symbol *real = ctx.symtab.addUndefined(mangle("__real_" + name));
+ Symbol *wrap = ctx.symtab.addUndefined(mangle("__wrap_" + name));
v.push_back({sym, real, wrap});
// These symbols may seem undefined initially, but don't bail out
- // at symtab->reportUnresolvable() due to them, but let wrapSymbols
+ // at symtab.reportUnresolvable() due to them, but let wrapSymbols
// below sort things out before checking finally with
- // symtab->resolveRemainingUndefines().
+ // symtab.resolveRemainingUndefines().
sym->deferUndefined = true;
real->deferUndefined = true;
// We want to tell LTO not to inline symbols to be overwritten
@@ -233,13 +235,14 @@ lld::coff::addWrappedSymbols(opt::InputArgList &args) {
// When this function is executed, only InputFiles and symbol table
// contain pointers to symbol objects. We visit them to replace pointers,
// so that wrapped symbols are swapped as instructed by the command line.
-void lld::coff::wrapSymbols(ArrayRef<WrappedSymbol> wrapped) {
+void lld::coff::wrapSymbols(COFFLinkerContext &ctx,
+ ArrayRef<WrappedSymbol> wrapped) {
DenseMap<Symbol *, Symbol *> map;
for (const WrappedSymbol &w : wrapped) {
map[w.sym] = w.wrap;
map[w.real] = w.sym;
if (Defined *d = dyn_cast<Defined>(w.wrap)) {
- Symbol *imp = symtab->find(("__imp_" + w.sym->getName()).str());
+ Symbol *imp = ctx.symtab.find(("__imp_" + w.sym->getName()).str());
// Create a new defined local import for the wrap symbol. If
// no imp prefixed symbol existed, there's no need for it.
// (We can't easily distinguish whether any object file actually
@@ -247,14 +250,14 @@ void lld::coff::wrapSymbols(ArrayRef<WrappedSymbol> wrapped) {
if (imp) {
DefinedLocalImport *wrapimp = make<DefinedLocalImport>(
saver.save("__imp_" + w.wrap->getName()), d);
- symtab->localImportChunks.push_back(wrapimp->getChunk());
+ ctx.symtab.localImportChunks.push_back(wrapimp->getChunk());
map[imp] = wrapimp;
}
}
}
// Update pointers in input files.
- parallelForEach(ObjFile::instances, [&](ObjFile *file) {
+ parallelForEach(ctx.objFileInstances, [&](ObjFile *file) {
MutableArrayRef<Symbol *> syms = file->getMutableSymbols();
for (size_t i = 0, e = syms.size(); i != e; ++i)
if (Symbol *s = map.lookup(syms[i]))