Add initial support for DataFlowSanitizer
Adds initial support for DataFlowSanitizer to the Rust compiler. It currently supports `-Zsanitizer-dataflow-abilist`. Additional options for it can be passed to LLVM command line argument processor via LLVM arguments using `llvm-args` codegen option (e.g., `-Cllvm-args=-dfsan-combine-pointer-labels-on-load=false`).
This commit is contained in:
parent
eaee1e9453
commit
dee4e02102
20 changed files with 678 additions and 10 deletions
|
@ -42,6 +42,7 @@
|
|||
#endif
|
||||
#include "llvm/Transforms/Instrumentation.h"
|
||||
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
|
||||
#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
|
||||
#include "llvm/Support/TimeProfiler.h"
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
#include "llvm/Support/PGOOptions.h"
|
||||
|
@ -686,6 +687,9 @@ struct LLVMRustSanitizerOptions {
|
|||
bool SanitizeAddress;
|
||||
bool SanitizeAddressRecover;
|
||||
bool SanitizeCFI;
|
||||
bool SanitizeDataFlow;
|
||||
char **SanitizeDataFlowABIList;
|
||||
size_t SanitizeDataFlowABIListLen;
|
||||
bool SanitizeKCFI;
|
||||
bool SanitizeMemory;
|
||||
bool SanitizeMemoryRecover;
|
||||
|
@ -883,6 +887,18 @@ LLVMRustOptimize(
|
|||
}
|
||||
|
||||
if (SanitizerOptions) {
|
||||
if (SanitizerOptions->SanitizeDataFlow) {
|
||||
std::vector<std::string> ABIListFiles(
|
||||
SanitizerOptions->SanitizeDataFlowABIList,
|
||||
SanitizerOptions->SanitizeDataFlowABIList +
|
||||
SanitizerOptions->SanitizeDataFlowABIListLen);
|
||||
OptimizerLastEPCallbacks.push_back(
|
||||
[ABIListFiles](ModulePassManager &MPM, OptimizationLevel Level) {
|
||||
MPM.addPass(DataFlowSanitizerPass(ABIListFiles));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (SanitizerOptions->SanitizeMemory) {
|
||||
MemorySanitizerOptions Options(
|
||||
SanitizerOptions->SanitizeMemoryTrackOrigins,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue