llvm-project
63 строки · 2.0 Кб
1# REQUIRES: aarch64
2
3# RUN: rm -rf %t; split-file %s %t
4# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/main.s -o %t/main.o
5# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/foobar.s -o %t/foobar.o
6
7# RUN: %lld -lSystem -arch arm64 -o %t/static %t/main.o %t/foobar.o
8# RUN: llvm-objdump --no-print-imm-hex --macho -d --no-show-raw-insn --syms %t/static | FileCheck %s --check-prefix=STATIC
9
10# RUN: %lld -lSystem -arch arm64 -dylib -o %t/libfoo.dylib %t/foobar.o
11# RUN: %lld -lSystem -arch arm64 -o %t/main %t/main.o %t/libfoo.dylib
12# RUN: llvm-objdump --no-print-imm-hex --macho -d --no-show-raw-insn --section-headers %t/main | FileCheck %s --check-prefix=DYLIB
13
14# STATIC-LABEL: _main:
15# STATIC-NEXT: adrp x8, [[#]] ; 0x[[#%x,PAGE:]]
16# STATIC-NEXT: add x8, x8, #[[#%u,FOO_OFF:]]
17# STATIC-NEXT: adrp x8, [[#]] ; 0x[[#PAGE]]
18# STATIC-NEXT: add x8, x8, #[[#%u,BAR_OFF:]]
19# STATIC-NEXT: ret
20
21# STATIC-LABEL: SYMBOL TABLE:
22# STATIC-DAG: {{0*}}[[#%x,PAGE+FOO_OFF]] g O __DATA,__thread_vars _foo
23# STATIC-DAG: {{0*}}[[#%x,PAGE+BAR_OFF]] g O __DATA,__thread_vars _bar
24
25# DYLIB-LABEL: _main:
26# DYLIB-NEXT: adrp x8, [[#]] ; 0x[[#%x,TLV:]]
27# DYLIB-NEXT: ldr x8, [x8, #8] ; literal pool symbol address: _foo
28# DYLIB-NEXT: adrp x8, [[#]] ; 0x[[#TLV]]
29# DYLIB-NEXT: ldr x8, [x8] ; literal pool symbol address: _bar
30# DYLIB-NEXT: ret
31# DYLIB-EMPTY:
32# DYLIB-NEXT: Sections:
33# DYLIB-NEXT: Idx Name Size VMA Type
34# DYLIB: [[#]] __thread_ptrs 00000010 {{0*}}[[#TLV]] DATA
35
36#--- main.s
37.globl _main, _foo, _bar
38.p2align 2
39_main:
40adrp x8, _foo@TLVPPAGE
41ldr x8, [x8, _foo@TLVPPAGEOFF]
42adrp x8, _bar@TLVPPAGE
43ldr x8, [x8, _bar@TLVPPAGEOFF]
44ret
45
46#--- foobar.s
47.globl _foo, _bar
48
49.section __DATA,__thread_data,thread_local_regular
50_foo$tlv$init:
51.long 123
52_bar$tlv$init:
53.long 123
54
55.section __DATA,__thread_vars,thread_local_variables
56_foo:
57.quad __tlv_bootstrap
58.quad 0
59.quad _foo$tlv$init
60_bar:
61.quad __tlv_bootstrap
62.quad 0
63.quad _bar$tlv$init
64