]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/asm/x86_64/sym.rs
6 #![feature(thread_local)]
10 extern "C" fn f1() -> i32 {
14 // The compiler will generate a shim to hide the caller location parameter.
24 asm
!("call {}", sym $func
,
26 out("rcx") _
, out("rdx") _
, out("rdi") _
, out("rsi") _
,
27 out("r8") _
, out("r9") _
, out("r10") _
, out("r11") _
,
28 out("xmm0") _
, out("xmm1") _
, out("xmm2") _
, out("xmm3") _
,
29 out("xmm4") _
, out("xmm5") _
, out("xmm6") _
, out("xmm7") _
,
30 out("xmm8") _
, out("xmm9") _
, out("xmm10") _
, out("xmm11") _
,
31 out("xmm12") _
, out("xmm13") _
, out("xmm14") _
, out("xmm15") _
,
38 macro_rules
! static_addr
{
41 let result
: *const u32;
42 // LEA performs a RIP-relative address calculation and returns the address
43 asm
!("lea {}, [rip + {}]", out(reg
) result
, sym $s
);
48 macro_rules
! static_tls_addr
{
51 let result
: *const u32;
54 # Load TLS base address
55 mov {out}, qword ptr fs:[0]
56 # Calculate the address of sym in the TLS block. The @tpoff
57 # relocation gives the offset of the symbol from the start
59 lea {out}, [{out} + {sym}@tpoff]
61 out
= out(reg
) result
,
74 assert_eq
!(call
!(f1
), 111);
75 assert_eq
!(call
!(f2
), 222);
76 assert_eq
!(static_addr
!(S1
), &S1
as *const u32);
77 assert_eq
!(static_tls_addr
!(S2
), &S2
as *const u32);
78 std
::thread
::spawn(|| {
79 assert_eq
!(static_addr
!(S1
), &S1
as *const u32);
80 assert_eq
!(static_tls_addr
!(S2
), &S2
as *const u32);