]> git.lizzy.rs Git - rust.git/blob - tests/assembly/pie-relocation-model.rs
Rollup merge of #107777 - compiler-errors:derive_const-actually-derive-const, r=fee1...
[rust.git] / tests / assembly / pie-relocation-model.rs
1 // revisions: x64
2 // assembly-output: emit-asm
3 // [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie
4 // [x64] needs-llvm-components: x86
5
6
7 #![feature(no_core, lang_items)]
8 #![no_core]
9 #![crate_type="rlib"]
10
11 #[lang = "sized"]
12 trait Sized {}
13 #[lang = "copy"]
14 trait Copy {}
15
16 // CHECK-LABEL: call_other_fn:
17 // With PIE local functions are called "directly".
18 // CHECK:       {{(jmp|callq)}} other_fn
19 #[no_mangle]
20 pub fn call_other_fn() -> u8 {
21     unsafe {
22         other_fn()
23     }
24 }
25
26 // CHECK-LABEL: other_fn:
27 // External functions are still called through GOT, since we don't know if the symbol
28 // is defined in the binary or in the shared library.
29 // CHECK:       callq *foreign_fn@GOTPCREL(%rip)
30 #[no_mangle]
31 #[inline(never)]
32 pub fn other_fn() -> u8 {
33     unsafe {
34         foreign_fn()
35     }
36 }
37
38 extern "C" {fn foreign_fn() -> u8;}