@@ -468,6 +468,13 @@ static void checkOptions() {
468468 error (" -z pauth-report only supported on AArch64" );
469469 }
470470
471+ if (config->emachine != EM_RISCV) {
472+ if (config->zZicfilpReport != " none" )
473+ error (" -z zicfilip-report only support on RISCV32/RISCV64" );
474+ if (config->zZicfissReport != " none" )
475+ error (" -z zicfiss-report only support on RISCV32/RISCV64" );
476+ }
477+
471478 if (config->emachine != EM_386 && config->emachine != EM_X86_64 &&
472479 config->zCetReport != " none" )
473480 error (" -z cet-report only supported on X86 and X86_64" );
@@ -1465,6 +1472,8 @@ static void readConfigs(opt::InputArgList &args) {
14651472 config->zWxneeded = hasZOption (args, " wxneeded" );
14661473 setUnresolvedSymbolPolicy (args);
14671474 config->power10Stubs = args.getLastArgValue (OPT_power10_stubs_eq) != " no" ;
1475+ config->zForceZicfilp = hasZOption (args, " force-zicfilp" );
1476+ config->zForceZicfiss = hasZOption (args, " force-zicfiss" );
14681477
14691478 if (opt::Arg *arg = args.getLastArg (OPT_eb, OPT_el)) {
14701479 if (arg->getOption ().matches (OPT_eb))
@@ -1508,7 +1517,9 @@ static void readConfigs(opt::InputArgList &args) {
15081517
15091518 auto reports = {std::make_pair (" bti-report" , &config->zBtiReport ),
15101519 std::make_pair (" cet-report" , &config->zCetReport ),
1511- std::make_pair (" pauth-report" , &config->zPauthReport )};
1520+ std::make_pair (" pauth-report" , &config->zPauthReport ),
1521+ std::make_pair (" zicfilp-report" , &config->zZicfilpReport ),
1522+ std::make_pair (" zicfiss-report" , &config->zZicfissReport )};
15121523 for (opt::Arg *arg : args.filtered (OPT_z)) {
15131524 std::pair<StringRef, StringRef> option =
15141525 StringRef (arg->getValue ()).split (' =' );
@@ -2685,6 +2696,16 @@ static void readSecurityNotes() {
26852696 toString (f) + " : -z cet-report: file does not have "
26862697 " GNU_PROPERTY_X86_FEATURE_1_SHSTK property" );
26872698
2699+ checkAndReportMissingFeature (
2700+ config->zZicfilpReport , features, GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_SIMPLE,
2701+ toString (f) + " : -z zicfilp-report: file does not have "
2702+ " GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_SIMPLE property" );
2703+
2704+ checkAndReportMissingFeature (
2705+ config->zZicfissReport , features, GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS,
2706+ toString (f) + " : -z zicfiss-report: file does not have "
2707+ " GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property" );
2708+
26882709 if (config->zForceBti && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) {
26892710 features |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
26902711 if (config->zBtiReport == " none" )
@@ -2697,6 +2718,23 @@ static void readSecurityNotes() {
26972718 " GNU_PROPERTY_X86_FEATURE_1_IBT property" );
26982719 features |= GNU_PROPERTY_X86_FEATURE_1_IBT;
26992720 }
2721+
2722+ if (config->zForceZicfilp &&
2723+ !(features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_SIMPLE)) {
2724+ features |= GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_SIMPLE;
2725+ if (config->zZicfilpReport == " none" )
2726+ warn (toString (f) + " : -z force-zicfilp: file does not have "
2727+ " GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_SIMPLE property" );
2728+ }
2729+
2730+ if (config->zForceZicfiss &&
2731+ !(features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS)) {
2732+ features |= GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS;
2733+ if (config->zZicfissReport == " none" )
2734+ warn (toString (f) + " : -z force-zicfiss: file does not have "
2735+ " GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property" );
2736+ }
2737+
27002738 if (config->zPacPlt && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
27012739 warn (toString (f) + " : -z pac-plt: file does not have "
27022740 " GNU_PROPERTY_AARCH64_FEATURE_1_PAC property" );
0 commit comments