| 1 |
// RUN: %clang -c -o %t %s |
| 2 |
// RUN: %llvm_jitlink %t |
| 3 |
// |
| 4 |
// Test that basic MachO TLVs work by adding together TLVs with values |
| 5 |
// 0, 1, and -1, and returning the result (0 for success). This setup |
| 6 |
// tests both zero-initialized (__thread_bss) and non-zero-initialized |
| 7 |
// (__thread_data) secitons. |
| 8 |
|
| 9 |
.section __TEXT,__text,regular,pure_instructions |
| 10 |
.build_version macos, 11, 0 |
| 11 |
|
| 12 |
.globl _main |
| 13 |
.p2align 4, 0x90 |
| 14 |
_main: |
| 15 |
pushq %rax |
| 16 |
movq _x@TLVP(%rip), %rdi |
| 17 |
callq *(%rdi) |
| 18 |
movq %rax, %rcx |
| 19 |
movq _y@TLVP(%rip), %rdi |
| 20 |
callq *(%rdi) |
| 21 |
movl (%rax), %edx |
| 22 |
addl (%rcx), %edx |
| 23 |
movq _z@TLVP(%rip), %rdi |
| 24 |
callq *(%rdi) |
| 25 |
addl (%rax), %edx |
| 26 |
movl %edx, %eax |
| 27 |
popq %rcx |
| 28 |
retq |
| 29 |
|
| 30 |
.tbss _x$tlv$init, 4, 2 |
| 31 |
|
| 32 |
.section __DATA,__thread_vars,thread_local_variables |
| 33 |
.globl _x |
| 34 |
_x: |
| 35 |
.quad __tlv_bootstrap |
| 36 |
.quad 0 |
| 37 |
.quad _x$tlv$init |
| 38 |
|
| 39 |
.section __DATA,__thread_data,thread_local_regular |
| 40 |
.p2align 2 |
| 41 |
_y$tlv$init: |
| 42 |
.long 4294967295 |
| 43 |
|
| 44 |
.section __DATA,__thread_vars,thread_local_variables |
| 45 |
.globl _y |
| 46 |
_y: |
| 47 |
.quad __tlv_bootstrap |
| 48 |
.quad 0 |
| 49 |
.quad _y$tlv$init |
| 50 |
|
| 51 |
.section __DATA,__thread_data,thread_local_regular |
| 52 |
.p2align 2 |
| 53 |
_z$tlv$init: |
| 54 |
.long 1 |
| 55 |
|
| 56 |
.section __DATA,__thread_vars,thread_local_variables |
| 57 |
.globl _z |
| 58 |
_z: |
| 59 |
.quad __tlv_bootstrap |
| 60 |
.quad 0 |
| 61 |
.quad _z$tlv$init |
| 62 |
|
| 63 |
.subsections_via_symbols |