1 # REQUIRES: x86_64-linux
2 # RUN: rm -rf %t && mkdir -p %t
3 # RUN: split-file %s %t
4 # RUN: llvm-mc -triple=x86_64-unknown-linux -filetype=obj -o %t/test_runner.o %t/test_runner.s
5 # RUN: llvm-mc -triple=x86_64-unknown-linux -filetype=obj -o %t/external_tls.o %t/external_tls.s
6 # RUN: llvm-rtdyld -triple=x86_64-unknown-linux -execute %t/test_runner.o %t/external_tls.o
13 # load the address of the GOT in rbx for the large code model tests
14 lea _GLOBAL_OFFSET_TABLE_
(%rip
), %rbx
16 # Test Local Exec TLS Model
17 mov
%fs:tls_foo@tpoff
, %eax
24 mov
%fs:tls_bar@tpoff
, %eax
31 # Test Initial Exec TLS Model
32 mov tls_foo@gottpoff
(%rip
), %rax
40 mov tls_bar@gottpoff
(%rip
), %rax
48 # Test Local Dynamic TLS Model (small code model)
49 lea tls_foo@tlsld
(%rip
), %rdi
50 call __tls_get_addr@plt
51 mov tls_foo@dtpoff
(%rax
), %eax
58 lea tls_bar@tlsld
(%rip
), %rdi
59 call __tls_get_addr@plt
60 mov tls_bar@dtpoff
(%rax
), %eax
67 # Test Local Dynamic TLS Model (large code model)
68 lea tls_foo@tlsld
(%rip
), %rdi
69 movabs $__tls_get_addr@pltoff
, %rax
72 mov tls_foo@dtpoff
(%rax
), %eax
79 lea tls_bar@tlsld
(%rip
), %rdi
80 movabs $__tls_get_addr@pltoff
, %rax
83 mov tls_bar@dtpoff
(%rax
), %eax
90 # Test Global Dynamic TLS Model (small code model)
92 leaq tls_foo@tlsgd
(%rip
), %rdi
93 .byte 0x66, 0x66, 0x48
94 call __tls_get_addr@plt
103 leaq tls_bar@tlsgd
(%rip
), %rdi
104 .byte 0x66, 0x66, 0x48
105 call __tls_get_addr@plt
113 # Test Global Dynamic TLS Model (large code model)
114 lea tls_foo@tlsgd
(%rip
), %rdi
115 movabs $__tls_get_addr@pltoff
, %rax
125 lea tls_bar@tlsgd
(%rip
), %rdi
126 movabs $__tls_get_addr@pltoff
, %rax
136 # External TLS variable, Local Exec TLS Model (small code model)
137 mov
%fs:external_tls_var@tpoff
, %eax
144 # External TLS variable, Global Dynamic TLS Model (small code model)
146 leaq external_tls_var@tlsgd
(%rip
), %rdi
147 .byte 0x66, 0x66, 0x48
148 call __tls_get_addr@plt
157 # Return 0 if all tests are successful
165 .section .tdata, "awT", @progbits
168 .type tls_foo, @object
175 .type tls_bar, @object
183 .section .tdata, "awT", @progbits
185 .global external_tls_var
186 .type external_tls_var, @object
187 .size external_tls_var, 4