Rollup merge of #127483 - BertalanD:no_sanitize-global-var, r=rcvalle
Allow disabling ASan instrumentation for globals AddressSanitizer adds instrumentation to global variables unless the [`no_sanitize_address`](https://llvm.org/docs/LangRef.html#global-attributes) attribute is set on them. This commit extends the existing `#[no_sanitize(address)]` attribute to set this; previously it only had the desired effect on functions. (cc https://github.com/rust-lang/rust/issues/39699)
This commit is contained in:
commit
c6d36256a6
10 changed files with 137 additions and 34 deletions
|
@ -2051,6 +2051,25 @@ extern "C" bool LLVMRustLLVMHasZstdCompressionForDebugSymbols() {
|
|||
return llvm::compression::zstd::isAvailable();
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustSetNoSanitizeAddress(LLVMValueRef Global) {
|
||||
GlobalValue &GV = *unwrap<GlobalValue>(Global);
|
||||
GlobalValue::SanitizerMetadata MD;
|
||||
if (GV.hasSanitizerMetadata())
|
||||
MD = GV.getSanitizerMetadata();
|
||||
MD.NoAddress = true;
|
||||
MD.IsDynInit = false;
|
||||
GV.setSanitizerMetadata(MD);
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustSetNoSanitizeHWAddress(LLVMValueRef Global) {
|
||||
GlobalValue &GV = *unwrap<GlobalValue>(Global);
|
||||
GlobalValue::SanitizerMetadata MD;
|
||||
if (GV.hasSanitizerMetadata())
|
||||
MD = GV.getSanitizerMetadata();
|
||||
MD.NoHWAddress = true;
|
||||
GV.setSanitizerMetadata(MD);
|
||||
}
|
||||
|
||||
// Operations on composite constants.
|
||||
// These are clones of LLVM api functions that will become available in future
|
||||
// releases. They can be removed once Rust's minimum supported LLVM version
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue