@@ -197,7 +197,8 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
197197} // namespace lld
198198
199199// Parses a linker -m option.
200- static std::tuple<ELFKind, uint16_t , uint8_t > parseEmulation (StringRef emul) {
200+ static std::tuple<ELFKind, uint16_t , uint8_t > parseEmulation (Ctx &ctx,
201+ StringRef emul) {
201202 uint8_t osabi = 0 ;
202203 StringRef s = emul;
203204 if (s.ends_with (" _fbsd" )) {
@@ -578,7 +579,7 @@ static GnuStackKind getZGnuStack(opt::InputArgList &args) {
578579 return ret;
579580}
580581
581- static uint8_t getZStartStopVisibility (opt::InputArgList &args) {
582+ static uint8_t getZStartStopVisibility (Ctx &ctx, opt::InputArgList &args) {
582583 uint8_t ret = STV_PROTECTED;
583584 for (auto *arg : args.filtered (OPT_z)) {
584585 std::pair<StringRef, StringRef> kv = StringRef (arg->getValue ()).split (' =' );
@@ -1556,7 +1557,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
15561557 ctx.arg .zStackSize = args::getZOptionValue (args, OPT_z, " stack-size" , 0 );
15571558 ctx.arg .zStartStopGC =
15581559 getZFlag (args, " start-stop-gc" , " nostart-stop-gc" , true );
1559- ctx.arg .zStartStopVisibility = getZStartStopVisibility (args);
1560+ ctx.arg .zStartStopVisibility = getZStartStopVisibility (ctx, args);
15601561 ctx.arg .zText = getZFlag (args, " text" , " notext" , true );
15611562 ctx.arg .zWxneeded = hasZOption (args, " wxneeded" );
15621563 setUnresolvedSymbolPolicy (ctx, args);
@@ -1759,7 +1760,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
17591760 if (auto *arg = args.getLastArg (OPT_m)) {
17601761 StringRef s = arg->getValue ();
17611762 std::tie (ctx.arg .ekind , ctx.arg .emachine , ctx.arg .osabi ) =
1762- parseEmulation (s);
1763+ parseEmulation (ctx, s);
17631764 ctx.arg .mipsN32Abi =
17641765 (s.starts_with (" elf32btsmipn32" ) || s.starts_with (" elf32ltsmipn32" ));
17651766 ctx.arg .emulation = s;
@@ -2756,17 +2757,19 @@ static void redirectSymbols(Ctx &ctx, ArrayRef<WrappedSymbol> wrapped) {
27562757 ctx.symtab ->wrap (w.sym , w.real , w.wrap );
27572758}
27582759
2759- static void reportMissingFeature (StringRef config, const Twine &report) {
2760+ static void reportMissingFeature (Ctx &ctx, StringRef config,
2761+ const Twine &report) {
27602762 if (config == " error" )
27612763 ErrAlways (ctx) << report;
27622764 else if (config == " warning" )
27632765 Warn (ctx) << report;
27642766}
27652767
2766- static void checkAndReportMissingFeature (StringRef config, uint32_t features,
2767- uint32_t mask, const Twine &report) {
2768+ static void checkAndReportMissingFeature (Ctx &ctx, StringRef config,
2769+ uint32_t features, uint32_t mask,
2770+ const Twine &report) {
27682771 if (!(features & mask))
2769- reportMissingFeature (config, report);
2772+ reportMissingFeature (ctx, config, report);
27702773}
27712774
27722775// To enable CET (x86's hardware-assisted control flow enforcement), each
@@ -2805,22 +2808,22 @@ static void readSecurityNotes(Ctx &ctx) {
28052808 uint32_t features = f->andFeatures ;
28062809
28072810 checkAndReportMissingFeature (
2808- ctx.arg .zBtiReport , features, GNU_PROPERTY_AARCH64_FEATURE_1_BTI,
2811+ ctx, ctx .arg .zBtiReport , features, GNU_PROPERTY_AARCH64_FEATURE_1_BTI,
28092812 toString (f) + " : -z bti-report: file does not have "
28102813 " GNU_PROPERTY_AARCH64_FEATURE_1_BTI property" );
28112814
28122815 checkAndReportMissingFeature (
2813- ctx.arg .zGcsReport , features, GNU_PROPERTY_AARCH64_FEATURE_1_GCS,
2816+ ctx, ctx .arg .zGcsReport , features, GNU_PROPERTY_AARCH64_FEATURE_1_GCS,
28142817 toString (f) + " : -z gcs-report: file does not have "
28152818 " GNU_PROPERTY_AARCH64_FEATURE_1_GCS property" );
28162819
28172820 checkAndReportMissingFeature (
2818- ctx.arg .zCetReport , features, GNU_PROPERTY_X86_FEATURE_1_IBT,
2821+ ctx, ctx .arg .zCetReport , features, GNU_PROPERTY_X86_FEATURE_1_IBT,
28192822 toString (f) + " : -z cet-report: file does not have "
28202823 " GNU_PROPERTY_X86_FEATURE_1_IBT property" );
28212824
28222825 checkAndReportMissingFeature (
2823- ctx.arg .zCetReport , features, GNU_PROPERTY_X86_FEATURE_1_SHSTK,
2826+ ctx, ctx .arg .zCetReport , features, GNU_PROPERTY_X86_FEATURE_1_SHSTK,
28242827 toString (f) + " : -z cet-report: file does not have "
28252828 " GNU_PROPERTY_X86_FEATURE_1_SHSTK property" );
28262829
@@ -2852,7 +2855,7 @@ static void readSecurityNotes(Ctx &ctx) {
28522855 continue ;
28532856
28542857 if (f->aarch64PauthAbiCoreInfo .empty ()) {
2855- reportMissingFeature (ctx.arg .zPauthReport ,
2858+ reportMissingFeature (ctx, ctx .arg .zPauthReport ,
28562859 toString (f) +
28572860 " : -z pauth-report: file does not have AArch64 "
28582861 " PAuth core info while '" +
0 commit comments