2020-12-11 00:06:29 +00:00
|
|
|
// Verifies that no_sanitize attribute can be used to
|
2020-01-12 00:00:00 +00:00
|
|
|
// selectively disable sanitizer instrumentation.
|
|
|
|
//
|
2020-06-05 00:00:00 +00:00
|
|
|
//@ needs-sanitizer-address
|
2023-10-07 00:29:42 +00:00
|
|
|
//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -Copt-level=0
|
2020-01-12 00:00:00 +00:00
|
|
|
|
2024-05-29 04:11:20 +00:00
|
|
|
#![crate_type = "lib"]
|
2020-01-12 00:00:00 +00:00
|
|
|
#![feature(no_sanitize)]
|
|
|
|
|
2024-07-08 13:49:50 +00:00
|
|
|
// 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;
|
|
|
|
|
2023-07-30 01:04:26 +00:00
|
|
|
// CHECK-LABEL: ; no_sanitize::unsanitized
|
2020-01-12 00:00:00 +00:00
|
|
|
// CHECK-NEXT: ; Function Attrs:
|
|
|
|
// CHECK-NOT: sanitize_address
|
|
|
|
// CHECK: start:
|
|
|
|
// CHECK-NOT: call void @__asan_report_load
|
|
|
|
// CHECK: }
|
|
|
|
#[no_sanitize(address)]
|
|
|
|
pub fn unsanitized(b: &mut u8) -> u8 {
|
|
|
|
*b
|
|
|
|
}
|
|
|
|
|
2023-07-30 01:04:26 +00:00
|
|
|
// CHECK-LABEL: ; no_sanitize::sanitized
|
2020-01-12 00:00:00 +00:00
|
|
|
// CHECK-NEXT: ; Function Attrs:
|
|
|
|
// CHECK: sanitize_address
|
|
|
|
// CHECK: start:
|
|
|
|
// CHECK: call void @__asan_report_load
|
|
|
|
// CHECK: }
|
|
|
|
pub fn sanitized(b: &mut u8) -> u8 {
|
|
|
|
*b
|
|
|
|
}
|