[X86][MC,LLD][NFC] Rename R_X86_64_REX2_GOTPCRELX (#116737)
[llvm-project.git] / lld / test / MachO / indirect-symtab.s
blob52849ccb87455820741bdd1097e719675746861a
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libfoo.s -o %t/libfoo.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/bar.s -o %t/bar.o
6 # RUN: %lld -dylib %t/libfoo.o -o %t/libfoo.dylib -lSystem
7 # RUN: %lld %t/test.o %t/bar.o %t/libfoo.dylib -o %t/test -lSystem
8 # RUN: llvm-objdump --macho -d --no-show-raw-insn --indirect-symbols %t/test | FileCheck %s
9 # RUN: llvm-otool -l %t/test | FileCheck --check-prefix=DYSYMTAB %s
11 # CHECK: (__TEXT,__text) section
12 # CHECK-NEXT: _main:
13 # CHECK-NEXT: movq {{.*}}(%rip), %rax ## literal pool symbol address: _foo
14 # CHECK-NEXT: movq {{.*}}(%rip), %rax ## literal pool symbol address: _bar
15 # CHECK-NEXT: leaq _baz(%rip), %rax
16 # CHECK-NEXT: addq {{.*}}(%rip), %rax
17 # CHECK-NEXT: movq {{.*}}(%rip), %rax ## literal pool symbol address: _foo_tlv
18 # CHECK-NEXT: movq {{.*}}(%rip), %rax ## literal pool symbol address: _bar_tlv
19 # CHECK-NEXT: callq {{.*}} ## symbol stub for: _foo_fn
20 # CHECK-NEXT: callq {{.*}} ## symbol stub for: _bar_fn
21 # CHECK-NEXT: retq
23 # CHECK: Indirect symbols for (__TEXT,__stubs) 2 entries
24 # CHECK-NEXT: address index name
25 # CHECK-NEXT: _bar_fn
26 # CHECK-NEXT: _foo_fn
27 # CHECK-NEXT: Indirect symbols for (__DATA_CONST,__got) 4 entries
28 # CHECK-NEXT: address index name
29 # CHECK-NEXT: LOCAL
30 # CHECK-NEXT: _bar
31 # CHECK-NEXT: _foo
32 # CHECK-NEXT: _stub_binder
33 # CHECK-NEXT: Indirect symbols for (__DATA,__la_symbol_ptr) 2 entries
34 # CHECK-NEXT: address index name
35 # CHECK-NEXT: _bar_fn
36 # CHECK-NEXT: _foo_fn
37 # CHECK-NEXT: Indirect symbols for (__DATA,__thread_ptrs) 2 entries
38 # CHECK-NEXT: address index name
39 # CHECK-NEXT: _bar_tlv
40 # CHECK-NEXT: _foo_tlv
42 # DYSYMTAB: nindirectsyms 10
44 #--- libfoo.s
46 .globl _foo, _foo_fn, _bar, _bar_fn
47 _foo:
48 _foo_fn:
49 _bar:
50 _bar_fn:
52 .section __DATA,__thread_vars,thread_local_variables
53 .globl _foo_tlv, _bar_tlv
54 _foo_tlv:
55 _bar_tlv:
57 #--- test.s
59 .globl _main
60 _main:
61 movq _foo@GOTPCREL(%rip), %rax
62 movq _bar@GOTPCREL(%rip), %rax
63 movq _baz@GOTPCREL(%rip), %rax
64 addq _quux@GOTPCREL(%rip), %rax
65 mov _foo_tlv@TLVP(%rip), %rax
66 mov _bar_tlv@TLVP(%rip), %rax
67 callq _foo_fn
68 callq _bar_fn
69 ret
71 #--- bar.s
72 .data
73 .globl _baz,_quux
74 .private_extern _baz,_quux
75 _baz:
76 .asciz "baz"
77 _quux:
78 .asciz "quux"