]> git.lizzy.rs Git - rust.git/blob - tests/codegen/pie-relocation-model.rs
Auto merge of #107778 - weihanglo:update-cargo, r=weihanglo
[rust.git] / tests / codegen / pie-relocation-model.rs
1 // compile-flags: -C relocation-model=pie -Copt-level=0
2 // only-x86_64-unknown-linux-gnu
3
4 #![crate_type = "rlib"]
5
6 // With PIE we know local functions cannot be interpositioned, we can mark them
7 // as dso_local.
8 // CHECK: define dso_local i8 @call_foreign_fn()
9 #[no_mangle]
10 pub fn call_foreign_fn() -> u8 {
11     unsafe {
12         foreign_fn()
13     }
14 }
15
16 // External functions are still marked as non-dso_local, since we don't know if the symbol
17 // is defined in the binary or in the shared library.
18 // CHECK: declare zeroext i8 @foreign_fn()
19 extern "C" {fn foreign_fn() -> u8;}
20
21 // CHECK: !{i32 {{[78]}}, !"PIC Level", i32 2}
22 // CHECK: !{i32 7, !"PIE Level", i32 2}