Add kernel-address
sanitizer support for freestanding targets
This commit is contained in:
parent
0416b1a6f6
commit
19714385e0
18 changed files with 142 additions and 12 deletions
|
@ -594,6 +594,8 @@ struct LLVMRustSanitizerOptions {
|
|||
bool SanitizeThread;
|
||||
bool SanitizeHWAddress;
|
||||
bool SanitizeHWAddressRecover;
|
||||
bool SanitizeKernelAddress;
|
||||
bool SanitizeKernelAddressRecover;
|
||||
};
|
||||
|
||||
extern "C" LLVMRustResult
|
||||
|
@ -765,15 +767,17 @@ LLVMRustOptimize(
|
|||
);
|
||||
}
|
||||
|
||||
if (SanitizerOptions->SanitizeAddress) {
|
||||
if (SanitizerOptions->SanitizeAddress || SanitizerOptions->SanitizeKernelAddress) {
|
||||
OptimizerLastEPCallbacks.push_back(
|
||||
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
|
||||
auto CompileKernel = SanitizerOptions->SanitizeKernelAddress;
|
||||
#if LLVM_VERSION_LT(15, 0)
|
||||
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
|
||||
#endif
|
||||
AddressSanitizerOptions opts = AddressSanitizerOptions{
|
||||
/*CompileKernel=*/false,
|
||||
SanitizerOptions->SanitizeAddressRecover,
|
||||
CompileKernel,
|
||||
SanitizerOptions->SanitizeAddressRecover
|
||||
|| SanitizerOptions->SanitizeKernelAddressRecover,
|
||||
/*UseAfterScope=*/true,
|
||||
AsanDetectStackUseAfterReturnMode::Runtime,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue