@@ -578,31 +578,32 @@ static GcsPolicy getZGcs(Ctx &ctx, opt::InputArgList &args) {
578
578
579
579
static void getZGcsReport (Ctx &ctx, opt::InputArgList &args) {
580
580
bool reportDynamicDefined = false ;
581
-
582
581
for (auto *arg : args.filtered (OPT_z)) {
583
582
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 ;
600
602
}
601
603
}
602
604
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
606
607
// libraries without the GCS property but does not the shared-libraries to be
607
608
// rebuilt for successful linking
608
609
if (!reportDynamicDefined && ctx.arg .zGcsReport != GcsReportPolicy::None &&
@@ -1589,9 +1590,6 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
1589
1590
ctx.arg .zForceBti = hasZOption (args, " force-bti" );
1590
1591
ctx.arg .zForceIbt = hasZOption (args, " force-ibt" );
1591
1592
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.
1595
1593
getZGcsReport (ctx, args);
1596
1594
ctx.arg .zGlobal = hasZOption (args, " global" );
1597
1595
ctx.arg .zGnustack = getZGnuStack (args);
@@ -2827,6 +2825,17 @@ static void redirectSymbols(Ctx &ctx, ArrayRef<WrappedSymbol> wrapped) {
2827
2825
ctx.symtab ->wrap (w.sym , w.real , w.wrap );
2828
2826
}
2829
2827
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
+
2830
2839
// To enable CET (x86's hardware-assisted control flow enforcement), each
2831
2840
// source file must be compiled with -fcf-protection. Object files compiled
2832
2841
// with the flag contain feature flags indicating that they are compatible
0 commit comments