Skip to content

Commit e1a1f18

Browse files
committed
[ELF] Make Config config part of Ctx ctx
1 parent 6521945 commit e1a1f18

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

lld/ELF/Config.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,6 @@ struct Config {
484484
llvm::SmallVector<std::pair<llvm::GlobPattern, llvm::StringRef>, 0>
485485
remapInputsWildcards;
486486
};
487-
struct ConfigWrapper {
488-
Config c;
489-
Config *operator->() { return &c; }
490-
};
491-
492-
LLVM_LIBRARY_VISIBILITY extern ConfigWrapper config;
493487

494488
// Some index properties of a symbol are stored separately in this auxiliary
495489
// struct to decrease sizeof(SymbolUnion) in the majority of cases.
@@ -544,7 +538,7 @@ struct InStruct {
544538
};
545539

546540
struct Ctx {
547-
Config &arg;
541+
Config arg;
548542
LinkerDriver driver;
549543
LinkerScript *script;
550544
TargetInfo *target;

lld/ELF/Driver.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ using namespace llvm::support;
7878
using namespace lld;
7979
using namespace lld::elf;
8080

81-
ConfigWrapper elf::config;
8281
Ctx elf::ctx;
8382

8483
static void setConfigs(Ctx &ctx, opt::InputArgList &args);
@@ -91,9 +90,11 @@ void elf::errorOrWarn(const Twine &msg) {
9190
error(msg);
9291
}
9392

94-
Ctx::Ctx() : arg(config.c), driver(*this) {}
93+
Ctx::Ctx() : driver(*this) {}
9594

9695
void Ctx::reset() {
96+
arg.~Config();
97+
new (&arg) Config();
9798
driver.~LinkerDriver();
9899
new (&driver) LinkerDriver(*this);
99100
script = nullptr;
@@ -163,8 +164,6 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
163164
"too many errors emitted, stopping now (use "
164165
"--error-limit=0 to see all errors)";
165166

166-
config = ConfigWrapper();
167-
168167
LinkerScript script(ctx);
169168
ctx.script = &script;
170169
ctx.symAux.emplace_back();

0 commit comments

Comments
 (0)