diff options
Diffstat (limited to 'lld/ELF/Driver.cpp')
| -rw-r--r-- | lld/ELF/Driver.cpp | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 6150fe072156..12dac82c614a 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -419,8 +419,18 @@ static void checkOptions(Ctx &ctx) { << "--pcrel-optimize is only supported on PowerPC64 targets"; } - if (ctx.arg.relaxGP && ctx.arg.emachine != EM_RISCV) - ErrAlways(ctx) << "--relax-gp is only supported on RISC-V targets"; + if (ctx.arg.emachine != EM_RISCV) { + if (ctx.arg.relaxGP) + ErrAlways(ctx) << "--relax-gp is only supported on RISC-V targets"; + if (ctx.arg.zZicfilpUnlabeledReport != ReportPolicy::None) + ErrAlways(ctx) << "-z zicfilip-unlabeled-report is only supported on " + "RISC-V targets"; + if (ctx.arg.zZicfilpFuncSigReport != ReportPolicy::None) + ErrAlways(ctx) << "-z zicfilip-func-sig-report is only supported on " + "RISC-V targets"; + if (ctx.arg.zZicfissReport != ReportPolicy::None) + ErrAlways(ctx) << "-z zicfiss-report is only supported on RISC-V targets"; + } if (ctx.arg.emachine != EM_386 && ctx.arg.emachine != EM_X86_64 && ctx.arg.zCetReport != ReportPolicy::None) @@ -1635,7 +1645,11 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { std::make_pair("execute-only-report", &ctx.arg.zExecuteOnlyReport), std::make_pair("gcs-report", &ctx.arg.zGcsReport), std::make_pair("gcs-report-dynamic", &ctx.arg.zGcsReportDynamic), - std::make_pair("pauth-report", &ctx.arg.zPauthReport)}; + std::make_pair("pauth-report", &ctx.arg.zPauthReport), + std::make_pair("zicfilp-unlabeled-report", + &ctx.arg.zZicfilpUnlabeledReport), + std::make_pair("zicfilp-func-sig-report", &ctx.arg.zZicfilpFuncSigReport), + std::make_pair("zicfiss-report", &ctx.arg.zZicfissReport)}; bool hasGcsReportDynamic = false; for (opt::Arg *arg : args.filtered(OPT_z)) { std::pair<StringRef, StringRef> option = @@ -2829,9 +2843,12 @@ static void redirectSymbols(Ctx &ctx, ArrayRef<WrappedSymbol> wrapped) { // For AArch64 PAuth-enabled object files, the core info of all of them must // match. Missing info for some object files with matching info for remaining // ones can be allowed (see -z pauth-report). +// +// RISC-V Zicfilp/Zicfiss extension also use the same mechanism to record +// enabled features in the GNU_PROPERTY_RISCV_FEATURE_1_AND bit mask. static void readSecurityNotes(Ctx &ctx) { if (ctx.arg.emachine != EM_386 && ctx.arg.emachine != EM_X86_64 && - ctx.arg.emachine != EM_AARCH64) + ctx.arg.emachine != EM_AARCH64 && ctx.arg.emachine != EM_RISCV) return; ctx.arg.andFeatures = -1; @@ -2883,6 +2900,33 @@ static void readSecurityNotes(Ctx &ctx) { << ": -z cet-report: file does not have " "GNU_PROPERTY_X86_FEATURE_1_SHSTK property"; + if (ctx.arg.emachine == EM_RISCV) { + reportUnless(ctx.arg.zZicfilpUnlabeledReport, + features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED) + << f + << ": -z zicfilp-unlabeled-report: file does not have " + "GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property"; + + reportUnless(ctx.arg.zZicfilpFuncSigReport, + features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG) + << f + << ": -z zicfilp-func-sig-report: file does not have " + "GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property"; + + if ((features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED) && + (features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG)) + Err(ctx) << f + << ": file has conflicting properties: " + "GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED and " + "GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG"; + + reportUnless(ctx.arg.zZicfissReport, + features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS) + << f + << ": -z zicfiss-report: file does not have " + "GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property"; + } + if (ctx.arg.zForceBti && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) { features |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI; if (ctx.arg.zBtiReport == ReportPolicy::None) |
