@@ -85,7 +85,7 @@ static void setConfigs(Ctx &ctx, opt::InputArgList &args);
85
85
static void readConfigs (Ctx &ctx, opt::InputArgList &args);
86
86
87
87
void elf::errorOrWarn (const Twine &msg) {
88
- if (config-> noinhibitExec )
88
+ if (ctx. arg . noinhibitExec )
89
89
warn (msg);
90
90
else
91
91
error (msg);
@@ -172,7 +172,7 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
172
172
ctx.partitions .clear ();
173
173
ctx.partitions .emplace_back ();
174
174
175
- config-> progName = args[0 ];
175
+ ctx. arg . progName = args[0 ];
176
176
177
177
ctx.driver .linkerMain (args);
178
178
@@ -853,7 +853,7 @@ static ICFLevel getICF(opt::InputArgList &args) {
853
853
static StripPolicy getStrip (opt::InputArgList &args) {
854
854
if (args.hasArg (OPT_relocatable))
855
855
return StripPolicy::None;
856
- if (!config-> zSectionHeader )
856
+ if (!ctx. arg . zSectionHeader )
857
857
return StripPolicy::All;
858
858
859
859
auto *arg = args.getLastArg (OPT_strip_all, OPT_strip_debug);
@@ -964,7 +964,7 @@ static void readCallGraph(MemoryBufferRef mb) {
964
964
auto findSection = [&](StringRef name) -> InputSectionBase * {
965
965
Symbol *sym = map.lookup (name);
966
966
if (!sym) {
967
- if (config-> warnSymbolOrdering )
967
+ if (ctx. arg . warnSymbolOrdering )
968
968
warn (mb.getBufferIdentifier () + " : no such symbol: " + name);
969
969
return nullptr ;
970
970
}
@@ -987,7 +987,7 @@ static void readCallGraph(MemoryBufferRef mb) {
987
987
988
988
if (InputSectionBase *from = findSection (fields[0 ]))
989
989
if (InputSectionBase *to = findSection (fields[1 ]))
990
- config-> callGraphProfile [std::make_pair (from, to)] += count;
990
+ ctx. arg . callGraphProfile [std::make_pair (from, to)] += count;
991
991
}
992
992
}
993
993
@@ -1025,14 +1025,14 @@ processCallGraphRelocations(SmallVector<uint32_t, 32> &symbolIndices,
1025
1025
ArrayRef<typename ELFT::Rela> relas =
1026
1026
CHECK (obj.relas (sec), " could not retrieve cg profile rela section" );
1027
1027
for (const typename ELFT::Rela &rel : relas)
1028
- symbolIndices.push_back (rel.getSymbol (config-> isMips64EL ));
1028
+ symbolIndices.push_back (rel.getSymbol (ctx. arg . isMips64EL ));
1029
1029
break ;
1030
1030
}
1031
1031
if (sec.sh_type == SHT_REL) {
1032
1032
ArrayRef<typename ELFT::Rel> rels =
1033
1033
CHECK (obj.rels (sec), " could not retrieve cg profile rel section" );
1034
1034
for (const typename ELFT::Rel &rel : rels)
1035
- symbolIndices.push_back (rel.getSymbol (config-> isMips64EL ));
1035
+ symbolIndices.push_back (rel.getSymbol (ctx. arg . isMips64EL ));
1036
1036
break ;
1037
1037
}
1038
1038
}
@@ -1065,7 +1065,7 @@ template <class ELFT> static void readCallGraphsFromObjectFiles() {
1065
1065
auto *from = dyn_cast_or_null<InputSectionBase>(fromSym->section );
1066
1066
auto *to = dyn_cast_or_null<InputSectionBase>(toSym->section );
1067
1067
if (from && to)
1068
- config-> callGraphProfile [{from, to}] += cgpe.cgp_weight ;
1068
+ ctx. arg . callGraphProfile [{from, to}] += cgpe.cgp_weight ;
1069
1069
}
1070
1070
}
1071
1071
}
@@ -1188,7 +1188,7 @@ getOldNewOptionsExtra(opt::InputArgList &args, unsigned id) {
1188
1188
static SmallVector<StringRef, 0 > getSymbolOrderingFile (MemoryBufferRef mb) {
1189
1189
SetVector<StringRef, SmallVector<StringRef, 0 >> names;
1190
1190
for (StringRef s : args::getLines (mb))
1191
- if (!names.insert (s) && config-> warnSymbolOrdering )
1191
+ if (!names.insert (s) && ctx. arg . warnSymbolOrdering )
1192
1192
warn (mb.getBufferIdentifier () + " : duplicate ordered symbol: " + s);
1193
1193
1194
1194
return names.takeVector ();
@@ -1198,7 +1198,7 @@ static bool getIsRela(opt::InputArgList &args) {
1198
1198
// The psABI specifies the default relocation entry format.
1199
1199
bool rela = is_contained ({EM_AARCH64, EM_AMDGPU, EM_HEXAGON, EM_LOONGARCH,
1200
1200
EM_PPC, EM_PPC64, EM_RISCV, EM_S390, EM_X86_64},
1201
- config-> emachine );
1201
+ ctx. arg . emachine );
1202
1202
// If -z rel or -z rela is specified, use the last option.
1203
1203
for (auto *arg : args.filtered (OPT_z)) {
1204
1204
StringRef s (arg->getValue ());
@@ -1217,7 +1217,7 @@ static void parseClangOption(StringRef opt, const Twine &msg) {
1217
1217
std::string err;
1218
1218
raw_string_ostream os (err);
1219
1219
1220
- const char *argv[] = {config-> progName .data (), opt.data ()};
1220
+ const char *argv[] = {ctx. arg . progName .data (), opt.data ()};
1221
1221
if (cl::ParseCommandLineOptions (2 , argv, " " , &os))
1222
1222
return ;
1223
1223
error (msg + " : " + StringRef (err).trim ());
@@ -1237,9 +1237,9 @@ static bool remapInputs(StringRef line, const Twine &location) {
1237
1237
return true ;
1238
1238
}
1239
1239
if (!hasWildcard (fields[0 ]))
1240
- config-> remapInputs [fields[0 ]] = fields[1 ];
1240
+ ctx. arg . remapInputs [fields[0 ]] = fields[1 ];
1241
1241
else if (Expected<GlobPattern> pat = GlobPattern::create (fields[0 ]))
1242
- config-> remapInputsWildcards .emplace_back (std::move (*pat), fields[1 ]);
1242
+ ctx. arg . remapInputsWildcards .emplace_back (std::move (*pat), fields[1 ]);
1243
1243
else {
1244
1244
error (location + " : " + toString (pat.takeError ()) + " : " + fields[0 ]);
1245
1245
return true ;
@@ -2093,14 +2093,14 @@ static uint64_t getCommonPageSize(Ctx &ctx, opt::InputArgList &args) {
2093
2093
error (" common-page-size: value isn't a power of 2" );
2094
2094
return ctx.target ->defaultCommonPageSize ;
2095
2095
}
2096
- if (config-> nmagic || config-> omagic ) {
2096
+ if (ctx. arg . nmagic || ctx. arg . omagic ) {
2097
2097
if (val != ctx.target ->defaultCommonPageSize )
2098
2098
warn (" -z common-page-size set, but paging disabled by omagic or nmagic" );
2099
2099
return 1 ;
2100
2100
}
2101
2101
// commonPageSize can't be larger than maxPageSize.
2102
- if (val > config-> maxPageSize )
2103
- val = config-> maxPageSize ;
2102
+ if (val > ctx. arg . maxPageSize )
2103
+ val = ctx. arg . maxPageSize ;
2104
2104
return val;
2105
2105
}
2106
2106
@@ -2381,7 +2381,7 @@ static void markAddrsig(Symbol *s) {
2381
2381
if (d->section )
2382
2382
// We don't need to keep text sections unique under --icf=all even if they
2383
2383
// are address-significant.
2384
- if (config-> icf == ICFLevel::Safe || !(d->section ->flags & SHF_EXECINSTR))
2384
+ if (ctx. arg . icf == ICFLevel::Safe || !(d->section ->flags & SHF_EXECINSTR))
2385
2385
d->section ->keepUnique = true ;
2386
2386
}
2387
2387
@@ -2477,10 +2477,10 @@ static void readSymbolPartitionSection(InputSectionBase *s) {
2477
2477
if (ctx.script ->hasPhdrsCommands ())
2478
2478
error (toString (s->file ) +
2479
2479
" : partitions cannot be used with the PHDRS command" );
2480
- if (!config-> sectionStartMap .empty ())
2480
+ if (!ctx. arg . sectionStartMap .empty ())
2481
2481
error (toString (s->file ) + " : partitions cannot be used with "
2482
2482
" --section-start, -Ttext, -Tdata or -Tbss" );
2483
- if (config-> emachine == EM_MIPS)
2483
+ if (ctx. arg . emachine == EM_MIPS)
2484
2484
error (toString (s->file ) + " : partitions cannot be used on this target" );
2485
2485
2486
2486
// Impose a limit of no more than 254 partitions. This limit comes from the
@@ -2651,7 +2651,7 @@ static void combineVersionedSymbol(Symbol &sym,
2651
2651
sym.isUsedInRegularObj = false ;
2652
2652
} else if (auto *sym1 = dyn_cast<Defined>(&sym)) {
2653
2653
if (sym2->versionId > VER_NDX_GLOBAL
2654
- ? config-> versionDefinitions [sym2->versionId ].name == suffix1 + 1
2654
+ ? ctx. arg . versionDefinitions [sym2->versionId ].name == suffix1 + 1
2655
2655
: sym1->section == sym2->section && sym1->value == sym2->value ) {
2656
2656
// Due to an assembler design flaw, if foo is defined, .symver foo,
2657
2657
// foo@v1 defines both foo and foo@v1. Unless foo is bound to a
@@ -2728,14 +2728,14 @@ static void checkAndReportMissingFeature(StringRef config, uint32_t features,
2728
2728
// match. Missing info for some object files with matching info for remaining
2729
2729
// ones can be allowed (see -z pauth-report).
2730
2730
static void readSecurityNotes () {
2731
- if (config-> emachine != EM_386 && config-> emachine != EM_X86_64 &&
2732
- config-> emachine != EM_AARCH64)
2731
+ if (ctx. arg . emachine != EM_386 && ctx. arg . emachine != EM_X86_64 &&
2732
+ ctx. arg . emachine != EM_AARCH64)
2733
2733
return ;
2734
2734
2735
- config-> andFeatures = -1 ;
2735
+ ctx. arg . andFeatures = -1 ;
2736
2736
2737
2737
StringRef referenceFileName;
2738
- if (config-> emachine == EM_AARCH64) {
2738
+ if (ctx. arg . emachine == EM_AARCH64) {
2739
2739
auto it = llvm::find_if (ctx.objectFiles , [](const ELFFileBase *f) {
2740
2740
return !f->aarch64PauthAbiCoreInfo .empty ();
2741
2741
});
@@ -2749,49 +2749,49 @@ static void readSecurityNotes() {
2749
2749
uint32_t features = f->andFeatures ;
2750
2750
2751
2751
checkAndReportMissingFeature (
2752
- config-> zBtiReport , features, GNU_PROPERTY_AARCH64_FEATURE_1_BTI,
2752
+ ctx. arg . zBtiReport , features, GNU_PROPERTY_AARCH64_FEATURE_1_BTI,
2753
2753
toString (f) + " : -z bti-report: file does not have "
2754
2754
" GNU_PROPERTY_AARCH64_FEATURE_1_BTI property" );
2755
2755
2756
2756
checkAndReportMissingFeature (
2757
- config-> zGcsReport , features, GNU_PROPERTY_AARCH64_FEATURE_1_GCS,
2757
+ ctx. arg . zGcsReport , features, GNU_PROPERTY_AARCH64_FEATURE_1_GCS,
2758
2758
toString (f) + " : -z gcs-report: file does not have "
2759
2759
" GNU_PROPERTY_AARCH64_FEATURE_1_GCS property" );
2760
2760
2761
2761
checkAndReportMissingFeature (
2762
- config-> zCetReport , features, GNU_PROPERTY_X86_FEATURE_1_IBT,
2762
+ ctx. arg . zCetReport , features, GNU_PROPERTY_X86_FEATURE_1_IBT,
2763
2763
toString (f) + " : -z cet-report: file does not have "
2764
2764
" GNU_PROPERTY_X86_FEATURE_1_IBT property" );
2765
2765
2766
2766
checkAndReportMissingFeature (
2767
- config-> zCetReport , features, GNU_PROPERTY_X86_FEATURE_1_SHSTK,
2767
+ ctx. arg . zCetReport , features, GNU_PROPERTY_X86_FEATURE_1_SHSTK,
2768
2768
toString (f) + " : -z cet-report: file does not have "
2769
2769
" GNU_PROPERTY_X86_FEATURE_1_SHSTK property" );
2770
2770
2771
- if (config-> zForceBti && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) {
2771
+ if (ctx. arg . zForceBti && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) {
2772
2772
features |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
2773
- if (config-> zBtiReport == " none" )
2773
+ if (ctx. arg . zBtiReport == " none" )
2774
2774
warn (toString (f) + " : -z force-bti: file does not have "
2775
2775
" GNU_PROPERTY_AARCH64_FEATURE_1_BTI property" );
2776
- } else if (config-> zForceIbt &&
2776
+ } else if (ctx. arg . zForceIbt &&
2777
2777
!(features & GNU_PROPERTY_X86_FEATURE_1_IBT)) {
2778
- if (config-> zCetReport == " none" )
2778
+ if (ctx. arg . zCetReport == " none" )
2779
2779
warn (toString (f) + " : -z force-ibt: file does not have "
2780
2780
" GNU_PROPERTY_X86_FEATURE_1_IBT property" );
2781
2781
features |= GNU_PROPERTY_X86_FEATURE_1_IBT;
2782
2782
}
2783
- if (config-> zPacPlt && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
2783
+ if (ctx. arg . zPacPlt && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
2784
2784
warn (toString (f) + " : -z pac-plt: file does not have "
2785
2785
" GNU_PROPERTY_AARCH64_FEATURE_1_PAC property" );
2786
2786
features |= GNU_PROPERTY_AARCH64_FEATURE_1_PAC;
2787
2787
}
2788
- config-> andFeatures &= features;
2788
+ ctx. arg . andFeatures &= features;
2789
2789
2790
2790
if (ctx.aarch64PauthAbiCoreInfo .empty ())
2791
2791
continue ;
2792
2792
2793
2793
if (f->aarch64PauthAbiCoreInfo .empty ()) {
2794
- reportMissingFeature (config-> zPauthReport ,
2794
+ reportMissingFeature (ctx. arg . zPauthReport ,
2795
2795
toString (f) +
2796
2796
" : -z pauth-report: file does not have AArch64 "
2797
2797
" PAuth core info while '" +
@@ -2808,14 +2808,14 @@ static void readSecurityNotes() {
2808
2808
}
2809
2809
2810
2810
// Force enable Shadow Stack.
2811
- if (config-> zShstk )
2812
- config-> andFeatures |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
2811
+ if (ctx. arg . zShstk )
2812
+ ctx. arg . andFeatures |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
2813
2813
2814
2814
// Force enable/disable GCS
2815
- if (config-> zGcs == GcsPolicy::Always)
2816
- config-> andFeatures |= GNU_PROPERTY_AARCH64_FEATURE_1_GCS;
2817
- else if (config-> zGcs == GcsPolicy::Never)
2818
- config-> andFeatures &= ~GNU_PROPERTY_AARCH64_FEATURE_1_GCS;
2815
+ if (ctx. arg . zGcs == GcsPolicy::Always)
2816
+ ctx. arg . andFeatures |= GNU_PROPERTY_AARCH64_FEATURE_1_GCS;
2817
+ else if (ctx. arg . zGcs == GcsPolicy::Never)
2818
+ ctx. arg . andFeatures &= ~GNU_PROPERTY_AARCH64_FEATURE_1_GCS;
2819
2819
}
2820
2820
2821
2821
static void initSectionsAndLocalSyms (ELFFileBase *file, bool ignoreComdats) {
@@ -2869,7 +2869,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2869
2869
2870
2870
// Handle -u/--undefined before input files. If both a.a and b.so define foo,
2871
2871
// -u foo a.a b.so will extract a.a.
2872
- for (StringRef name : config-> undefined )
2872
+ for (StringRef name : ctx. arg . undefined )
2873
2873
symtab.addUnusedUndefined (name)->referenced = true ;
2874
2874
2875
2875
parseFiles (files, armCmseImpLib);
0 commit comments