rust/tests/codegen/sanitizer/cfi/add-cfi-normalize-integers-flag.rs
Sami Tolvanen 40f1d9d154 Add missing module flags for CFI and KCFI sanitizers
Set the cfi-normalize-integers and kcfi-offset module flags when
Control-Flow Integrity sanitizers are used, so functions generated by
the LLVM backend use the same CFI/KCFI options as rustc.

cfi-normalize-integers tells LLVM to also use integer normalization
for generated functions when -Zsanitizer-cfi-normalize-integers is
used.

kcfi-offset specifies the number of prefix nops between the KCFI
type hash and the function entry when -Z patchable-function-entry is
used. Note that LLVM assumes all indirectly callable functions use the
same number of prefix NOPs with -Zsanitizer=kcfi.
2024-08-21 20:23:56 +00:00

11 lines
305 B
Rust

// Verifies that "cfi-normalize-integers" module flag is added.
//
//@ needs-sanitizer-cfi
//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers
#![crate_type = "lib"]
pub fn foo() {}
// CHECK: !{{[0-9]+}} = !{i32 4, !"cfi-normalize-integers", i32 1}