about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2024-07-08 15:49:50 +0200
committerDaniel Bertalan <dani@danielbertalan.dev>2024-11-02 22:35:34 +0100
commit204b2281fa508cf512d343cb1631955a5dfa9e0e (patch)
tree1221c0c6c1107f69fa573af702b353f867e606b4 /tests/codegen
parent00ed73cdc09a6452cb58202d56a9211fb3c73031 (diff)
downloadrust-204b2281fa508cf512d343cb1631955a5dfa9e0e.tar.gz
rust-204b2281fa508cf512d343cb1631955a5dfa9e0e.zip
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.
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/sanitizer/no-sanitize.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/codegen/sanitizer/no-sanitize.rs b/tests/codegen/sanitizer/no-sanitize.rs
index 47d3fd83f11..2a309f6b9c6 100644
--- a/tests/codegen/sanitizer/no-sanitize.rs
+++ b/tests/codegen/sanitizer/no-sanitize.rs
@@ -7,6 +7,16 @@
 #![crate_type = "lib"]
 #![feature(no_sanitize)]
 
+// CHECK:     @UNSANITIZED = constant{{.*}} no_sanitize_address
+// CHECK-NOT: @__asan_global_UNSANITIZED
+#[no_mangle]
+#[no_sanitize(address)]
+pub static UNSANITIZED: u32 = 0;
+
+// CHECK: @__asan_global_SANITIZED
+#[no_mangle]
+pub static SANITIZED: u32 = 0;
+
 // CHECK-LABEL: ; no_sanitize::unsanitized
 // CHECK-NEXT:  ; Function Attrs:
 // CHECK-NOT:   sanitize_address