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 10 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 22 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 41 42# DYSYMTAB: nindirectsyms 10 43 44#--- libfoo.s 45 46.globl _foo, _foo_fn, _bar, _bar_fn 47_foo: 48_foo_fn: 49_bar: 50_bar_fn: 51 52.section __DATA,__thread_vars,thread_local_variables 53.globl _foo_tlv, _bar_tlv 54_foo_tlv: 55_bar_tlv: 56 57#--- test.s 58 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 70 71#--- bar.s 72.data 73.globl _baz,_quux 74.private_extern _baz,_quux 75_baz: 76.asciz "baz" 77_quux: 78.asciz "quux" 79