1# REQUIRES: x86
2# RUN: 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: %lld -dylib %t/libfoo.o -o %t/libfoo.dylib -lSystem
6# RUN: %lld %t/test.o %t/libfoo.dylib -o %t/test -lSystem
7# RUN: llvm-objdump --macho -d --no-show-raw-insn --indirect-symbols %t/test | FileCheck %s
8
9# CHECK:      (__TEXT,__text) section
10# CHECK-NEXT: _main:
11# CHECK-NEXT: movq	{{.*}}(%rip), %rax ## literal pool symbol address: _foo
12# CHECK-NEXT: movq	{{.*}}(%rip), %rax ## literal pool symbol address: _bar
13# CHECK-NEXT: movq	{{.*}}(%rip), %rax ## literal pool symbol address: _foo_tlv
14# CHECK-NEXT: movq	{{.*}}(%rip), %rax ## literal pool symbol address: _bar_tlv
15# CHECK-NEXT: callq	{{.*}} ## symbol stub for: _foo_fn
16# CHECK-NEXT: callq	{{.*}} ## symbol stub for: _bar_fn
17# CHECK-NEXT: retq
18
19# CHECK:      Indirect symbols for (__TEXT,__stubs) 2 entries
20# CHECK-NEXT: address            index name
21# CHECK-NEXT: _bar_fn
22# CHECK-NEXT: _foo_fn
23# CHECK-NEXT: Indirect symbols for (__DATA,__thread_ptrs) 2 entries
24# CHECK-NEXT: address            index name
25# CHECK-NEXT: _bar_tlv
26# CHECK-NEXT: _foo_tlv
27# CHECK-NEXT: Indirect symbols for (__DATA,__la_symbol_ptr) 2 entries
28# CHECK-NEXT: address            index name
29# CHECK-NEXT: _bar_fn
30# CHECK-NEXT: _foo_fn
31# CHECK-NEXT: Indirect symbols for (__DATA_CONST,__got) 3 entries
32# CHECK-NEXT: address            index name
33# CHECK-NEXT: _bar
34# CHECK-NEXT: _foo
35# CHECK-NEXT: _stub_binder
36
37#--- libfoo.s
38
39.globl _foo, _foo_fn, _bar, _bar_fn
40_foo:
41_foo_fn:
42_bar:
43_bar_fn:
44
45.section  __DATA,__thread_vars,thread_local_variables
46.globl _foo_tlv, _bar_tlv
47_foo_tlv:
48_bar_tlv:
49
50#--- test.s
51
52.globl _main
53_main:
54  movq _foo@GOTPCREL(%rip), %rax
55  movq _bar@GOTPCREL(%rip), %rax
56  mov _foo_tlv@TLVP(%rip), %rax
57  mov _bar_tlv@TLVP(%rip), %rax
58  callq _foo_fn
59  callq _bar_fn
60  ret
61