@@ -578,31 +578,29 @@ 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
+ auto 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 ;
600
599
}
601
600
}
602
601
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
602
+ // When -zgcs-report is set to `warning` or `error`, -zgcs-report-dynamic will
603
+ // inherit this value if unspecified, matching GNU ld. This detects shared
606
604
// libraries without the GCS property but does not the shared-libraries to be
607
605
// rebuilt for successful linking
608
606
if (!reportDynamicDefined && ctx.arg .zGcsReport != GcsReportPolicy::None &&
@@ -1589,9 +1587,6 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
1589
1587
ctx.arg .zForceBti = hasZOption (args, " force-bti" );
1590
1588
ctx.arg .zForceIbt = hasZOption (args, " force-ibt" );
1591
1589
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
1590
getZGcsReport (ctx, args);
1596
1591
ctx.arg .zGlobal = hasZOption (args, " global" );
1597
1592
ctx.arg .zGnustack = getZGnuStack (args);
@@ -2827,6 +2822,17 @@ static void redirectSymbols(Ctx &ctx, ArrayRef<WrappedSymbol> wrapped) {
2827
2822
ctx.symtab ->wrap (w.sym , w.real , w.wrap );
2828
2823
}
2829
2824
2825
+ static StringRef gcsReportPolicytoString (GcsReportPolicy value) {
2826
+ StringRef ret;
2827
+ if (value == GcsReportPolicy::Warning)
2828
+ ret = " warning" ;
2829
+ else if (value == GcsReportPolicy::Error)
2830
+ ret = " error" ;
2831
+ else
2832
+ ret = " none" ;
2833
+ return ret;
2834
+ }
2835
+
2830
2836
// To enable CET (x86's hardware-assisted control flow enforcement), each
2831
2837
// source file must be compiled with -fcf-protection. Object files compiled
2832
2838
// with the flag contain feature flags indicating that they are compatible
0 commit comments