1# RUN: ld64.lld -arch arm64 %s %p/Inputs/hello-world-arm64.yaml -o %t
2# RUN: llvm-nm -m -n %t | FileCheck %s
3# RUN: llvm-objdump --private-headers %t | FileCheck %s --check-prefix=CHECK-PRIVATE-HEADER
4#
5# Test that arm64 hello-world can be linked into a mach-o executable
6#
7
8--- !mach-o
9arch:            arm64
10file-type:       MH_OBJECT
11flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
12sections:
13  - segment:         __TEXT
14    section:         __text
15    type:            S_REGULAR
16    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
17    alignment:       2
18    address:         0x0000000000000000
19    content:         [ 0xFD, 0x7B, 0xBF, 0xA9, 0xFD, 0x03, 0x00, 0x91,
20                       0x08, 0x00, 0x00, 0x90, 0x08, 0x01, 0x40, 0xF9,
21                       0x00, 0x01, 0x40, 0xF9, 0x01, 0x00, 0x00, 0x90,
22                       0x21, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x94,
23                       0x00, 0x00, 0x80, 0x52, 0xFD, 0x7B, 0xC1, 0xA8,
24                       0xC0, 0x03, 0x5F, 0xD6 ]
25    relocations:
26      - offset:          0x0000001C
27        type:            ARM64_RELOC_BRANCH26
28        length:          2
29        pc-rel:          true
30        extern:          true
31        symbol:          5
32      - offset:          0x00000018
33        type:            ARM64_RELOC_PAGEOFF12
34        length:          2
35        pc-rel:          false
36        extern:          true
37        symbol:          1
38      - offset:          0x00000014
39        type:            ARM64_RELOC_PAGE21
40        length:          2
41        pc-rel:          true
42        extern:          true
43        symbol:          1
44      - offset:          0x0000000C
45        type:            ARM64_RELOC_GOT_LOAD_PAGEOFF12
46        length:          2
47        pc-rel:          false
48        extern:          true
49        symbol:          4
50      - offset:          0x00000008
51        type:            ARM64_RELOC_GOT_LOAD_PAGE21
52        length:          2
53        pc-rel:          true
54        extern:          true
55        symbol:          4
56  - segment:         __TEXT
57    section:         __cstring
58    type:            S_CSTRING_LITERALS
59    attributes:      [  ]
60    address:         0x000000000000002C
61    content:         [ 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x0A, 0x00 ]
62local-symbols:
63  - name:            ltmp0
64    type:            N_SECT
65    sect:            1
66    value:           0x0000000000000000
67  - name:            l_.str
68    type:            N_SECT
69    sect:            2
70    value:           0x000000000000002C
71  - name:            ltmp1
72    type:            N_SECT
73    sect:            2
74    value:           0x000000000000002C
75global-symbols:
76  - name:            _main
77    type:            N_SECT
78    scope:           [ N_EXT ]
79    sect:            1
80    value:           0x0000000000000000
81undefined-symbols:
82  - name:            ___stdoutp
83    type:            N_UNDF
84    scope:           [ N_EXT ]
85    value:           0x0000000000000000
86  - name:            _fprintf
87    type:            N_UNDF
88    scope:           [ N_EXT ]
89    value:           0x0000000000000000
90...
91
92# CHECK:	(undefined) external ___stdoutp (from libSystem)
93# CHECK:	(undefined) external _fprintf (from libSystem)
94# CHECK:	(undefined) external dyld_stub_binder (from libSystem)
95# CHECK:	{{[0-9a-f]+}} (__TEXT,__text) external _main
96
97# CHECK-PRIVATE-HEADER: sectname __stubs
98# CHECK-PRIVATE-HEADER-NEXT:  segname __TEXT
99# CHECK-PRIVATE-HEADER-NEXT:     addr
100# CHECK-PRIVATE-HEADER-NEXT:     size
101# CHECK-PRIVATE-HEADER-NEXT:   offset
102# CHECK-PRIVATE-HEADER-NEXT:    align 2^1 (2)
103