|
66 | 66 | #include "llvm/Support/CommandLine.h" |
67 | 67 | #include "llvm/Support/ConvertUTF.h" |
68 | 68 | #include "llvm/Support/ErrorHandling.h" |
| 69 | +#include "llvm/Support/Hash.h" |
69 | 70 | #include "llvm/Support/TimeProfiler.h" |
70 | 71 | #include "llvm/TargetParser/RISCVISAInfo.h" |
71 | 72 | #include "llvm/TargetParser/Triple.h" |
@@ -1272,6 +1273,12 @@ void CodeGenModule::Release() { |
1272 | 1273 | CodeGenOpts.PatchableFunctionEntryOffset); |
1273 | 1274 | if (CodeGenOpts.SanitizeKcfiArity) |
1274 | 1275 | getModule().addModuleFlag(llvm::Module::Override, "kcfi-arity", 1); |
| 1276 | + // Store the hash algorithm choice for use in LLVM passes |
| 1277 | + getModule().addModuleFlag( |
| 1278 | + llvm::Module::Override, "kcfi-hash", |
| 1279 | + llvm::MDString::get( |
| 1280 | + getLLVMContext(), |
| 1281 | + llvm::stringifyKCFIHashAlgorithm(CodeGenOpts.SanitizeKcfiHash))); |
1275 | 1282 | } |
1276 | 1283 |
|
1277 | 1284 | if (CodeGenOpts.CFProtectionReturn && |
@@ -2450,7 +2457,8 @@ llvm::ConstantInt *CodeGenModule::CreateKCFITypeId(QualType T, StringRef Salt) { |
2450 | 2457 | if (getCodeGenOpts().SanitizeCfiICallGeneralizePointers) |
2451 | 2458 | Out << ".generalized"; |
2452 | 2459 |
|
2453 | | - return llvm::ConstantInt::get(Int32Ty, llvm::getKCFITypeID(OutName)); |
| 2460 | + return llvm::ConstantInt::get( |
| 2461 | + Int32Ty, llvm::getKCFITypeID(OutName, getCodeGenOpts().SanitizeKcfiHash)); |
2454 | 2462 | } |
2455 | 2463 |
|
2456 | 2464 | void CodeGenModule::SetLLVMFunctionAttributes(GlobalDecl GD, |
|
0 commit comments