@@ -553,65 +553,14 @@ static uint8_t getZStartStopVisibility(opt::InputArgList &args) {
553553 return ret;
554554}
555555
556- constexpr const char *knownZFlags[] = {
557- " combreloc" ,
558- " copyreloc" ,
559- " defs" ,
560- " execstack" ,
561- " force-bti" ,
562- " force-ibt" ,
563- " global" ,
564- " hazardplt" ,
565- " ifunc-noplt" ,
566- " initfirst" ,
567- " interpose" ,
568- " keep-text-section-prefix" ,
569- " lazy" ,
570- " muldefs" ,
571- " nocombreloc" ,
572- " nocopyreloc" ,
573- " nodefaultlib" ,
574- " nodelete" ,
575- " nodlopen" ,
576- " noexecstack" ,
577- " nognustack" ,
578- " nokeep-text-section-prefix" ,
579- " nopack-relative-relocs" ,
580- " norelro" ,
581- " noseparate-code" ,
582- " nostart-stop-gc" ,
583- " notext" ,
584- " now" ,
585- " origin" ,
586- " pac-plt" ,
587- " pack-relative-relocs" ,
588- " rel" ,
589- " rela" ,
590- " relro" ,
591- " retpolineplt" ,
592- " rodynamic" ,
593- " separate-code" ,
594- " separate-loadable-segments" ,
595- " shstk" ,
596- " start-stop-gc" ,
597- " text" ,
598- " undefs" ,
599- " wxneeded" ,
600- };
601-
602- static bool isKnownZFlag (StringRef s) {
603- return llvm::is_contained (knownZFlags, s) ||
604- s.starts_with (" common-page-size=" ) || s.starts_with (" bti-report=" ) ||
605- s.starts_with (" cet-report=" ) ||
606- s.starts_with (" dead-reloc-in-nonalloc=" ) ||
607- s.starts_with (" max-page-size=" ) || s.starts_with (" stack-size=" ) ||
608- s.starts_with (" start-stop-visibility=" );
609- }
610-
611556// Report a warning for an unknown -z option.
612557static void checkZOptions (opt::InputArgList &args) {
558+ // This function is called before getTarget(), when certain options are not
559+ // initialized yet. Claim them here.
560+ args::getZOptionValue (args, OPT_z, " max-page-size" , 0 );
561+ args::getZOptionValue (args, OPT_z, " common-page-size" , 0 );
613562 for (auto *arg : args.filtered (OPT_z))
614- if (!isKnownZFlag ( arg->getValue () ))
563+ if (!arg->isClaimed ( ))
615564 warn (" unknown -z value: " + StringRef (arg->getValue ()));
616565}
617566
@@ -629,7 +578,6 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
629578 args.hasFlag (OPT_fatal_warnings, OPT_no_fatal_warnings, false ) &&
630579 !args.hasArg (OPT_no_warnings);
631580 errorHandler ().suppressWarnings = args.hasArg (OPT_no_warnings);
632- checkZOptions (args);
633581
634582 // Handle -help
635583 if (args.hasArg (OPT_help)) {
@@ -672,6 +620,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
672620 }
673621
674622 readConfigs (args);
623+ checkZOptions (args);
675624
676625 // The behavior of -v or --version is a bit strange, but this is
677626 // needed for compatibility with GNU linkers.
0 commit comments