Andrew Brown | 8d6c973 | 2022-01-28 17:48:59 | [diff] [blame] | 1 | // Test that the correct module flags are emitted with different control-flow protection flags. |
| 2 | |
| 3 | // revisions: undefined none branch return full |
| 4 | // needs-llvm-components: x86 |
| 5 | // [undefined] compile-flags: |
| 6 | // [none] compile-flags: -Z cf-protection=none |
| 7 | // [branch] compile-flags: -Z cf-protection=branch |
| 8 | // [return] compile-flags: -Z cf-protection=return |
| 9 | // [full] compile-flags: -Z cf-protection=full |
| 10 | // compile-flags: --target x86_64-unknown-linux-gnu |
| 11 | |
| 12 | #![crate_type = "lib"] |
| 13 | #![feature(no_core, lang_items)] |
| 14 | #![no_core] |
| 15 | |
| 16 | #[lang="sized"] |
| 17 | trait Sized { } |
| 18 | |
| 19 | // A basic test function. |
| 20 | pub fn test() { |
| 21 | } |
| 22 | |
| 23 | // undefined-NOT: !"cf-protection-branch" |
| 24 | // undefined-NOT: !"cf-protection-return" |
| 25 | |
| 26 | // none-NOT: !"cf-protection-branch" |
| 27 | // none-NOT: !"cf-protection-return" |
| 28 | |
| 29 | // branch-NOT: !"cf-protection-return" |
| 30 | // branch: !"cf-protection-branch", i32 1 |
| 31 | // branch-NOT: !"cf-protection-return" |
| 32 | |
| 33 | // return-NOT: !"cf-protection-branch" |
| 34 | // return: !"cf-protection-return", i32 1 |
| 35 | // return-NOT: !"cf-protection-branch" |
| 36 | |
| 37 | // full: !"cf-protection-branch", i32 1 |
| 38 | // full: !"cf-protection-return", i32 1 |