| 1 | // Test that basic MachO TLVs work by adding together TLVs with values |
| 2 | // 0, 1, and -1, and returning the result (0 for success). This setup |
| 3 | // tests both zero-initialized (__thread_bss) and non-zero-initialized |
| 4 | // (__thread_data) secitons. |
| 5 | // |
| 6 | // RUN: %clang -c -o %t %s |
| 7 | // RUN: %llvm_jitlink %t |
| 8 | |
| 9 | .section __TEXT,__text,regular,pure_instructions |
| 10 | .build_version macos, 12, 0 sdk_version 12, 0 |
| 11 | .globl _main ; -- Begin function main |
| 12 | .p2align 2 |
| 13 | _main: ; @main |
| 14 | .cfi_startproc |
| 15 | ; %bb.0: |
| 16 | sub sp, sp, #32 ; =32 |
| 17 | stp x29, x30, [sp, #16] ; 16-byte Folded Spill |
| 18 | add x29, sp, #16 ; =16 |
| 19 | .cfi_def_cfa w29, 16 |
| 20 | .cfi_offset w30, -8 |
| 21 | .cfi_offset w29, -16 |
| 22 | adrp x0, _x@TLVPPAGE |
| 23 | ldr x0, [x0, _x@TLVPPAGEOFF] |
| 24 | ldr x8, [x0] |
| 25 | blr x8 |
| 26 | mov x8, x0 |
| 27 | adrp x0, _y@TLVPPAGE |
| 28 | ldr x0, [x0, _y@TLVPPAGEOFF] |
| 29 | ldr x9, [x0] |
| 30 | blr x9 |
| 31 | mov x9, x0 |
| 32 | adrp x0, _z@TLVPPAGE |
| 33 | ldr x0, [x0, _z@TLVPPAGEOFF] |
| 34 | ldr x10, [x0] |
| 35 | blr x10 |
| 36 | stur wzr, [x29, #-4] |
| 37 | ldr w8, [x8] |
| 38 | ldr w9, [x9] |
| 39 | add w8, w8, w9 |
| 40 | ldr w9, [x0] |
| 41 | add w0, w8, w9 |
| 42 | ldp x29, x30, [sp, #16] ; 16-byte Folded Reload |
| 43 | add sp, sp, #32 ; =32 |
| 44 | ret |
| 45 | .cfi_endproc |
| 46 | ; -- End function |
| 47 | .tbss _x$tlv$init, 4, 2 ; @x |
| 48 | |
| 49 | .section __DATA,__thread_vars,thread_local_variables |
| 50 | .globl _x |
| 51 | _x: |
| 52 | .quad __tlv_bootstrap |
| 53 | .quad 0 |
| 54 | .quad _x$tlv$init |
| 55 | |
| 56 | .section __DATA,__thread_data,thread_local_regular |
| 57 | .p2align 2 ; @y |
| 58 | _y$tlv$init: |
| 59 | .long 4294967295 ; 0xffffffff |
| 60 | |
| 61 | .section __DATA,__thread_vars,thread_local_variables |
| 62 | .globl _y |
| 63 | _y: |
| 64 | .quad __tlv_bootstrap |
| 65 | .quad 0 |
| 66 | .quad _y$tlv$init |
| 67 | |
| 68 | .section __DATA,__thread_data,thread_local_regular |
| 69 | .p2align 2 ; @z |
| 70 | _z$tlv$init: |
| 71 | .long 1 ; 0x1 |
| 72 | |
| 73 | .section __DATA,__thread_vars,thread_local_variables |
| 74 | .globl _z |
| 75 | _z: |
| 76 | .quad __tlv_bootstrap |
| 77 | .quad 0 |
| 78 | .quad _z$tlv$init |
| 79 | |
| 80 | .subsections_via_symbols |
| 81 | |