@@ -578,31 +578,32 @@ static GcsPolicy getZGcs(Ctx &ctx, opt::InputArgList &args) {
578578
579579static void getZGcsReport (Ctx &ctx, opt::InputArgList &args) {
580580 bool reportDynamicDefined = false ;
581-
582581 for (auto *arg : args.filtered (OPT_z)) {
583582 std::pair<StringRef, StringRef> kv = StringRef (arg->getValue ()).split (' =' );
584- if ((kv.first == " gcs-report" ) || kv.first == " gcs-report-dynamic" ) {
585- arg->claim ();
586- GcsReportPolicy value = StringSwitch<GcsReportPolicy>(kv.second )
587- .Case (" none" , GcsReportPolicy::None)
588- .Case (" warning" , GcsReportPolicy::Warning)
589- .Case (" error" , GcsReportPolicy::Error)
590- .Default (GcsReportPolicy::Unknown);
591- if (value == GcsReportPolicy::Unknown)
592- ErrAlways (ctx) << " unknown -z " << kv.first << " = value: " << kv.second ;
593-
594- if (kv.first == " gcs-report" )
595- ctx.arg .zGcsReport = value;
596- else if (kv.first == " gcs-report-dynamic" ) {
597- ctx.arg .zGcsReportDynamic = value;
598- reportDynamicDefined = true ;
599- }
583+ if (kv.first != " gcs-report" && kv.first != " gcs-report-dynamic" )
584+ continue ;
585+ arg->claim ();
586+ GcsReportPolicy value;
587+ if (kv.second == " none" )
588+ value = GcsReportPolicy::None;
589+ else if (kv.second == " warning" )
590+ value = GcsReportPolicy::Warning;
591+ else if (kv.second == " error" )
592+ value = GcsReportPolicy::Error;
593+ else {
594+ ErrAlways (ctx) << " unknown -z " << kv.first << " = value: " << kv.second ;
595+ continue ;
596+ }
597+ if (kv.first == " gcs-report" ) {
598+ ctx.arg .zGcsReport = value;
599+ } else if (kv.first == " gcs-report-dynamic" ) {
600+ ctx.arg .zGcsReportDynamic = value;
601+ reportDynamicDefined = true ;
600602 }
601603 }
602604
603- // The behaviour of -zgnu-report-dynamic matches that of GNU ld. When
604- // -zgcs-report is set to `warning` or `error`, -zgcs-report-dynamic will
605- // inherit this value if there is no user set value. This detects shared
605+ // When -zgcs-report is set to `warning` or `error`, -zgcs-report-dynamic will
606+ // inherit this value if unspecified, matching GNU ld. This detects shared
606607 // libraries without the GCS property but does not the shared-libraries to be
607608 // rebuilt for successful linking
608609 if (!reportDynamicDefined && ctx.arg .zGcsReport != GcsReportPolicy::None &&
@@ -1589,9 +1590,6 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
15891590 ctx.arg .zForceBti = hasZOption (args, " force-bti" );
15901591 ctx.arg .zForceIbt = hasZOption (args, " force-ibt" );
15911592 ctx.arg .zGcs = getZGcs (ctx, args);
1592- // getZGcsReport assings the values for `ctx.arg.zGcsReport` and
1593- // `ctx.arg.zGcsReportDynamic within the function. By doing this, it saves
1594- // calling the function twice, as both values can be parsed at once.
15951593 getZGcsReport (ctx, args);
15961594 ctx.arg .zGlobal = hasZOption (args, " global" );
15971595 ctx.arg .zGnustack = getZGnuStack (args);
@@ -2827,6 +2825,17 @@ static void redirectSymbols(Ctx &ctx, ArrayRef<WrappedSymbol> wrapped) {
28272825 ctx.symtab ->wrap (w.sym , w.real , w.wrap );
28282826}
28292827
2828+ static StringRef gcsReportPolicytoString (GcsReportPolicy value) {
2829+ StringRef ret;
2830+ if (value == GcsReportPolicy::Warning)
2831+ ret = " warning" ;
2832+ else if (value == GcsReportPolicy::Error)
2833+ ret = " error" ;
2834+ else
2835+ ret = " none" ;
2836+ return ret;
2837+ }
2838+
28302839// To enable CET (x86's hardware-assisted control flow enforcement), each
28312840// source file must be compiled with -fcf-protection. Object files compiled
28322841// with the flag contain feature flags indicating that they are compatible
0 commit comments