diff options
| author | bors <bors@rust-lang.org> | 2024-11-23 15:19:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-11-23 15:19:32 +0000 |
| commit | 826b673412d2f579e7865b6f26bc9771c6d3b097 (patch) | |
| tree | d8e6ed3069396c92a1a4c0be5fcc1a4af25815d1 /compiler/rustc_codegen_llvm/src | |
| parent | ff1737bb00913444173658b4e0b274fd79aabf66 (diff) | |
| parent | 96e8c7c7ba96b08e9eca26d1fe1f9ddbf12668e9 (diff) | |
| download | rust-826b673412d2f579e7865b6f26bc9771c6d3b097.tar.gz rust-826b673412d2f579e7865b6f26bc9771c6d3b097.zip | |
Auto merge of #133377 - jieyouxu:rollup-n536hzq, r=jieyouxu
Rollup of 6 pull requests Successful merges: - #127483 (Allow disabling ASan instrumentation for globals) - #131505 (use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` as a `TMPDIR` fallback on Darwin) - #132949 (Add specific diagnostic for using macro_rules macro as attribute/derive) - #133286 (Re-delay a resolve `bug` related to `Self`-ctor in patterns) - #133332 (Mark `<[T; N]>::as_mut_slice` with the `const` specifier.) - #133366 (Remove unnecessary bool from `ExpectedFound::new`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/base.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/consts.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 3 |
3 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index 32793894794..f62310bd948 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -172,3 +172,12 @@ pub(crate) fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility { Visibility::Protected => llvm::Visibility::Protected, } } + +pub(crate) fn set_variable_sanitizer_attrs(llval: &Value, attrs: &CodegenFnAttrs) { + if attrs.no_sanitize.contains(SanitizerSet::ADDRESS) { + unsafe { llvm::LLVMRustSetNoSanitizeAddress(llval) }; + } + if attrs.no_sanitize.contains(SanitizerSet::HWADDRESS) { + unsafe { llvm::LLVMRustSetNoSanitizeHWAddress(llval) }; + } +} diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 6f5ffbb4b34..c7114480d8b 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -470,6 +470,8 @@ impl<'ll> CodegenCx<'ll, '_> { base::set_link_section(g, attrs); } + base::set_variable_sanitizer_attrs(g, attrs); + if attrs.flags.contains(CodegenFnAttrFlags::USED) { // `USED` and `USED_LINKER` can't be used together. assert!(!attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)); diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 7f59264824e..17b0ec4b936 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2460,4 +2460,7 @@ unsafe extern "C" { pub fn LLVMRustIs64BitSymbolicFile(buf_ptr: *const u8, buf_len: usize) -> bool; pub fn LLVMRustIsECObject(buf_ptr: *const u8, buf_len: usize) -> bool; + + pub fn LLVMRustSetNoSanitizeAddress(Global: &Value); + pub fn LLVMRustSetNoSanitizeHWAddress(Global: &Value); } |
