|
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 && |
@@ -2434,7 +2441,8 @@ llvm::ConstantInt *CodeGenModule::CreateKCFITypeId(QualType T, StringRef Salt) { |
2434 | 2441 | if (getCodeGenOpts().SanitizeCfiICallGeneralizePointers) |
2435 | 2442 | Out << ".generalized"; |
2436 | 2443 |
|
2437 | | - return llvm::ConstantInt::get(Int32Ty, llvm::getKCFITypeID(OutName)); |
| 2444 | + return llvm::ConstantInt::get( |
| 2445 | + Int32Ty, llvm::getKCFITypeID(OutName, getCodeGenOpts().SanitizeKcfiHash)); |
2438 | 2446 | } |
2439 | 2447 |
|
2440 | 2448 | void CodeGenModule::SetLLVMFunctionAttributes(GlobalDecl GD, |
|
0 commit comments