xref: /llvm-project/lld/test/MachO/dylink-ordinal.s (revision 396f2e9d6d17d4288616218f07aa93daf01fbe5d)
1# REQUIRES: x86
2
3## --no-leading-lines needed for .tbd files.
4# RUN: rm -rf %t; split-file --no-leading-lines %s %t
5
6# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o
7# RUN: %lld -o %t/main -L%t -lFoo -lBar -lSystem %t/main.o
8# RUN: llvm-objdump --lazy-bind -d --no-show-raw-insn %t/main | FileCheck %s
9
10# CHECK: callq 0x[[#%x,FOO_OFF:]]
11# CHECK-NEXT: callq 0x[[#%x,BAR_OFF:]]
12
13# CHECK: [[#%x,BAR_OFF]]: jmpq {{.*}} ## 0x[[#%x,BAR_BIND:]]
14# CHECK: [[#%x,FOO_OFF]]: jmpq {{.*}} ## 0x[[#%x,FOO_BIND:]]
15
16# CHECK-LABEL: Lazy bind table:
17# CHECK-DAG: __DATA __la_symbol_ptr 0x[[#%x,FOO_BIND]] Foo _foo
18# CHECK-DAG: __DATA __la_symbol_ptr 0x[[#%x,BAR_BIND]] Foo _bar
19
20# RUN: llvm-nm -m %t/main | FileCheck --check-prefix=NM %s
21
22# NM-DAG: _bar (from Foo)
23# NM-DAG: _foo (from Foo)
24
25# RUN: llvm-otool -L %t/main | FileCheck %s --check-prefix=LOAD
26
27# LOAD: Foo.dylib
28# LOAD-NOT: Foo.dylib
29
30#--- libFoo.tbd
31--- !tapi-tbd
32tbd-version:      4
33targets:          [ x86_64-macos ]
34uuids:
35  - target:       x86_64-macos
36    value:        00000000-0000-0000-0000-000000000000
37install-name:     'Foo.dylib'
38current-version:  0001.001.1
39exports:
40  - targets:      [ x86_64-macos ]
41    symbols:      [ _foo ]
42...
43
44#--- libBar.tbd
45--- !tapi-tbd
46tbd-version:      4
47targets:          [ x86_64-macos ]
48uuids:
49  - target:       x86_64-macos
50    value:        00000000-0000-0000-0000-000000000000
51## Also uses Foo.dylib as install-name!
52## Normally, this would happen conditionally via an $ld$ symbol.
53install-name:     'Foo.dylib'
54current-version:  0001.001.1
55exports:
56  - targets:      [ x86_64-macos ]
57    symbols:      [ _bar ]
58...
59
60#--- main.s
61.section __TEXT,__text
62.globl _main, _foo, _bar
63
64_main:
65  callq _foo
66  callq _bar
67  ret
68