@@ -93,6 +93,7 @@ void elf::errorOrWarn(const Twine &msg) {
93
93
94
94
void Ctx::reset () {
95
95
driver = LinkerDriver ();
96
+ script = nullptr ;
96
97
97
98
bufferStart = nullptr ;
98
99
mainPart = nullptr ;
@@ -160,8 +161,9 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
160
161
" --error-limit=0 to see all errors)" ;
161
162
162
163
config = ConfigWrapper ();
163
- script = ScriptWrapper ();
164
164
165
+ LinkerScript script;
166
+ elf::ctx.script = &script;
165
167
elf::ctx.symAux .emplace_back ();
166
168
167
169
partitions.clear ();
@@ -463,7 +465,7 @@ static void checkOptions() {
463
465
if (config->emachine != EM_AARCH64)
464
466
error (" --execute-only is only supported on AArch64 targets" );
465
467
466
- if (config->singleRoRx && !script->hasSectionsCommand )
468
+ if (config->singleRoRx && !ctx. script ->hasSectionsCommand )
467
469
error (" --execute-only and --no-rosegment cannot be used together" );
468
470
}
469
471
@@ -2456,10 +2458,10 @@ static void readSymbolPartitionSection(InputSectionBase *s) {
2456
2458
// Forbid partitions from being used on incompatible targets, and forbid them
2457
2459
// from being used together with various linker features that assume a single
2458
2460
// set of output sections.
2459
- if (script->hasSectionsCommand )
2461
+ if (ctx. script ->hasSectionsCommand )
2460
2462
error (toString (s->file ) +
2461
2463
" : partitions cannot be used with the SECTIONS command" );
2462
- if (script->hasPhdrsCommands ())
2464
+ if (ctx. script ->hasPhdrsCommands ())
2463
2465
error (toString (s->file ) +
2464
2466
" : partitions cannot be used with the PHDRS command" );
2465
2467
if (!config->sectionStartMap .empty ())
@@ -2873,7 +2875,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2873
2875
// After potential archive member extraction involving ENTRY and
2874
2876
// -u/--undefined-glob, check whether PROVIDE symbols should be defined (the
2875
2877
// RHS may refer to definitions in just extracted object files).
2876
- script->addScriptReferencedSymbolsToSymTable ();
2878
+ ctx. script ->addScriptReferencedSymbolsToSymTable ();
2877
2879
2878
2880
// Prevent LTO from removing any definition referenced by -u.
2879
2881
for (StringRef name : config->undefined )
@@ -2939,7 +2941,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2939
2941
// We want to declare linker script's symbols early,
2940
2942
// so that we can version them.
2941
2943
// They also might be exported if referenced by DSOs.
2942
- script->declareSymbols ();
2944
+ ctx. script ->declareSymbols ();
2943
2945
2944
2946
// Handle --exclude-libs. This is before scanVersionScript() due to a
2945
2947
// workaround for Android ndk: for a defined versioned symbol in an archive
@@ -3158,13 +3160,13 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
3158
3160
llvm::TimeTraceScope timeScope (" Assign sections" );
3159
3161
3160
3162
// Create output sections described by SECTIONS commands.
3161
- script->processSectionCommands ();
3163
+ ctx. script ->processSectionCommands ();
3162
3164
3163
3165
// Linker scripts control how input sections are assigned to output
3164
3166
// sections. Input sections that were not handled by scripts are called
3165
3167
// "orphans", and they are assigned to output sections by the default rule.
3166
3168
// Process that.
3167
- script->addOrphanSections ();
3169
+ ctx. script ->addOrphanSections ();
3168
3170
}
3169
3171
3170
3172
{
@@ -3174,9 +3176,9 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
3174
3176
// merging MergeInputSections into a single MergeSyntheticSection. From this
3175
3177
// point onwards InputSectionDescription::sections should be used instead of
3176
3178
// sectionBases.
3177
- for (SectionCommand *cmd : script->sectionCommands )
3179
+ for (SectionCommand *cmd : ctx. script ->sectionCommands )
3178
3180
if (auto *osd = dyn_cast<OutputDesc>(cmd))
3179
- osd->osec .finalizeInputSections (&script. s );
3181
+ osd->osec .finalizeInputSections (ctx. script );
3180
3182
}
3181
3183
3182
3184
// Two input sections with different output sections should not be folded.
0 commit comments