1# REQUIRES: x86
2
3# RUN: ld64.lld.darwinold -arch x86_64 -macosx_version_min 10.8 %s \
4# RUN: %p/Inputs/lazy-bind-x86_64.yaml  %p/Inputs/lazy-bind-x86_64-2.yaml \
5# RUN: %p/Inputs/lazy-bind-x86_64-3.yaml -o %t  \
6# RUN:   %p/Inputs/x86_64/libSystem.yaml
7# RUN: llvm-objdump --macho --lazy-bind %t | FileCheck %s
8# RUN: llvm-nm -m %t | FileCheck --check-prefix=CHECK-NM %s
9# RUN: llvm-objdump --disassemble %t | FileCheck --check-prefix=CHECK-HELPERS %s
10# RUN: llvm-objdump --private-headers %t | FileCheck --check-prefix=CHECK-DYLIBS %s
11#
12# Test that correct two-level namespace ordinals are used for lazy bindings.
13#
14
15--- !mach-o
16arch:            x86_64
17file-type:       MH_OBJECT
18flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
19sections:
20  - segment:         __TEXT
21    section:         __text
22    type:            S_REGULAR
23    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
24    address:         0x0000000000000000
25    content:         [ 0x55, 0x48, 0x89, 0xE5, 0x31, 0xC0, 0xE8, 0x00,
26                       0x00, 0x00, 0x00, 0x31, 0xC0, 0xE8, 0x00, 0x00,
27                       0x00, 0x00, 0x31, 0xC0, 0xE8, 0x00, 0x00, 0x00,
28                       0x00, 0x31, 0xC0, 0x5D, 0xC3 ]
29    relocations:
30      - offset:          0x00000015
31        type:            X86_64_RELOC_BRANCH
32        length:          2
33        pc-rel:          true
34        extern:          true
35        symbol:          3
36      - offset:          0x0000000E
37        type:            X86_64_RELOC_BRANCH
38        length:          2
39        pc-rel:          true
40        extern:          true
41        symbol:          2
42      - offset:          0x00000007
43        type:            X86_64_RELOC_BRANCH
44        length:          2
45        pc-rel:          true
46        extern:          true
47        symbol:          1
48global-symbols:
49  - name:            _main
50    type:            N_SECT
51    scope:           [ N_EXT ]
52    sect:            1
53    value:           0x0000000000000000
54undefined-symbols:
55  - name:            _bar
56    type:            N_UNDF
57    scope:           [ N_EXT ]
58    value:           0x0000000000000000
59  - name:            _baz
60    type:            N_UNDF
61    scope:           [ N_EXT ]
62    value:           0x0000000000000000
63  - name:            _foo
64    type:            N_UNDF
65    scope:           [ N_EXT ]
66    value:           0x0000000000000000
67
68...
69
70
71# CHECK:    libbar        _bar
72# CHECK:    libbaz        _baz
73# CHECK:    libfoo        _foo
74
75
76# CHECK-NM:   (undefined) external _bar (from libbar)
77# CHECK-NM:   (undefined) external _baz (from libbaz)
78# CHECK-NM:   (undefined) external _foo (from libfoo)
79
80
81# CHECK-HELPERS:Disassembly of section __TEXT,__stub_helper:
82# CHECK-HELPERS: 	68 00 00 00 00            pushq	$0
83# CHECK-HELPERS: 	68 0b 00 00 00            pushq	$11
84# CHECK-HELPERS: 	68 16 00 00 00            pushq	$22
85
86# Make sure the stub helper is correctly aligned
87# CHECK-DYLIBS:   sectname __stub_helper
88# CHECK-DYLIBS-NEXT:    segname __TEXT
89# CHECK-DYLIBS-NEXT:       addr
90# CHECK-DYLIBS-NEXT:       size
91# CHECK-DYLIBS-NEXT:     offset
92# CHECK-DYLIBS-NEXT:      align 2^2 (4)
93
94# Make sure the __nl_symbol_ptr section is used instea of __got as this is x86_64
95# CHECK-DYLIBS:   sectname __nl_symbol_ptr
96# CHECK-DYLIBS-NEXT:    segname __DATA
97
98# CHECK-DYLIBS:           cmd LC_LOAD_DYLIB
99# CHECK-DYLIBS:          name /usr/lib/libbar.dylib (offset 24)
100# CHECK-DYLIBS:       current version 2.3.0
101# CHECK-DYLIBS: compatibility version 1.0.0
102# CHECK-DYLIBS:           cmd LC_LOAD_DYLIB
103# CHECK-DYLIBS:          name /usr/lib/libfoo.dylib (offset 24)
104# CHECK-DYLIBS:       current version 3.4.0
105# CHECK-DYLIBS: compatibility version 2.0.0
106# CHECK-DYLIBS:           cmd LC_LOAD_DYLIB
107# CHECK-DYLIBS:          name /usr/lib/libbaz.dylib (offset 24)
108# CHECK-DYLIBS:       current version 4.5.0
109# CHECK-DYLIBS: compatibility version 3.0.0
110
111
112