Skip to content

Commit bffb26f

Browse files
committed
[ELF] Add LinkerDriver::ctx. NFC
1 parent 4886403 commit bffb26f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lld/ELF/Config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class BitcodeCompiler;
4848
class OutputSection;
4949
class LinkerScript;
5050
class TargetInfo;
51+
struct Ctx;
5152
struct Partition;
5253
struct PhdrEntry;
5354

@@ -149,11 +150,14 @@ struct VersionDefinition {
149150

150151
class LinkerDriver {
151152
public:
153+
LinkerDriver(Ctx &ctx);
154+
LinkerDriver(LinkerDriver &) = delete;
152155
void linkerMain(ArrayRef<const char *> args);
153156
void addFile(StringRef path, bool withLOption);
154157
void addLibrary(StringRef name);
155158

156159
private:
160+
Ctx &ctx;
157161
void createFiles(llvm::opt::InputArgList &args);
158162
void inferMachineType();
159163
template <class ELFT> void link(llvm::opt::InputArgList &args);
@@ -652,6 +656,7 @@ struct Ctx {
652656
// STT_SECTION symbol associated to the .toc input section.
653657
llvm::DenseSet<std::pair<const Symbol *, uint64_t>> ppc64noTocRelax;
654658

659+
Ctx();
655660
void reset();
656661

657662
llvm::raw_fd_ostream openAuxiliaryFile(llvm::StringRef, std::error_code &);

lld/ELF/Driver.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ void elf::errorOrWarn(const Twine &msg) {
9191
error(msg);
9292
}
9393

94+
Ctx::Ctx() : driver(*this) {}
95+
9496
void Ctx::reset() {
95-
driver = LinkerDriver();
97+
driver.~LinkerDriver();
98+
new (&driver) LinkerDriver(*this);
9699
script = nullptr;
97100
target = nullptr;
98101

@@ -613,6 +616,8 @@ constexpr const char *saveTempsValues[] = {
613616
"resolution", "preopt", "promote", "internalize", "import",
614617
"opt", "precodegen", "prelink", "combinedindex"};
615618

619+
LinkerDriver::LinkerDriver(Ctx &ctx) : ctx(ctx) {}
620+
616621
void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
617622
ELFOptTable parser;
618623
opt::InputArgList args = parser.parse(argsArr.slice(1));

0 commit comments

Comments
 (0)