Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / dylib-stub.yaml
blob617fbfc056cca09d63a285539d216f2960848ca2
1 ## Stub dylibs differ from "real" dylibs in that they lack any content in their
2 ## sections. What they do have are export tries and symbol tables, which means
3 ## we can still link against them. I (jezng) am unclear how to properly create
4 ## these stub dylibs; XCode 11.3's `lipo` is able to create stub dylibs, but
5 ## those lack LC_ID_DYLIB load commands and are considered invalid by most
6 ## tooling. Newer versions of `lipo` aren't able to create stub dylibs at all.
7 ## However, recent SDKs in XCode still come with valid stub dylibs, so it still
8 ## seems worthwhile to support them. The YAML in this test was generated by
9 ## taking a non-stub dylib and editing the appropriate fields.
11 # REQUIRES: x86
12 # RUN: rm -rf %t; split-file %s %t
13 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
14 # RUN: yaml2obj %t/fat.dylib.yaml > %t/fat.dylib
15 # RUN: %lld -lSystem %t/test.o %t/fat.dylib -o %t/test
16 # RUN: llvm-objdump --macho --lazy-bind %t/test | FileCheck %s
17 # CHECK: __DATA   __la_symbol_ptr    0x100002000 foo  _foo
19 #--- test.s
20 .globl _main
21 _main:
22   callq _foo
23   ret
25 #--- fat.dylib.yaml
26 --- !fat-mach-o
27 FatHeader:
28   magic:           0xCAFEBABE
29   nfat_arch:       1
30 FatArchs:
31   - cputype:         0x01000007
32     cpusubtype:      0x00000003
33     offset:          0x0000000000001000
34     size:            16432
35     align:           12
36 Slices:
37   - !mach-o
38     FileHeader:
39       magic:           0xFEEDFACF
40       cputype:         0x01000007
41       cpusubtype:      0x00000003
42       filetype:        0x00000009
43       ncmds:           5
44       sizeofcmds:      568
45       flags:           0x00100085
46       reserved:        0x00000000
47     LoadCommands:
48       - cmd:             LC_SEGMENT_64
49         cmdsize:         232
50         segname:         __TEXT
51         vmaddr:          0
52         vmsize:          16384
53         fileoff:         0
54         filesize:        16384
55         maxprot:         5
56         initprot:        5
57         nsects:          1
58         flags:           0
59         Sections:
60           - sectname:        __text
61             segname:         __TEXT
62             addr:            0x0000000000000000
63             size:            0
64             offset:          0x00003FB7
65             align:           0
66             reloff:          0x00000000
67             nreloc:          0
68             flags:           0x80000400
69             reserved1:       0x00000000
70             reserved2:       0x00000000
71             reserved3:       0x00000000
72             content:         ''
73       - cmd:             LC_SEGMENT_64
74         cmdsize:         72
75         segname:         __LINKEDIT
76         vmaddr:          16384
77         vmsize:          16384
78         fileoff:         16384
79         filesize:        48
80         maxprot:         1
81         initprot:        1
82         nsects:          0
83         flags:           0
84       - cmd:             LC_ID_DYLIB
85         cmdsize:         40
86         dylib:
87           name:            24
88           timestamp:       1
89           current_version: 0
90           compatibility_version: 0
91         Content:         foo.dylib
92         ZeroPadBytes:    7
93       - cmd:             LC_DYLD_INFO_ONLY
94         cmdsize:         48
95         rebase_off:      0
96         rebase_size:     0
97         bind_off:        0
98         bind_size:       0
99         weak_bind_off:   0
100         weak_bind_size:  0
101         lazy_bind_off:   0
102         lazy_bind_size:  0
103         export_off:      16384
104         export_size:     16
105       - cmd:             LC_SYMTAB
106         cmdsize:         24
107         symoff:          16408
108         nsyms:           1
109         stroff:          16424
110         strsize:         8
111     LinkEditData:
112       ExportTrie:
113         TerminalSize:    0
114         NodeOffset:      0
115         Name:            ''
116         Flags:           0x0000000000000000
117         Address:         0x0000000000000000
118         Other:           0x0000000000000000
119         ImportName:      ''
120         Children:
121           - TerminalSize:    3
122             NodeOffset:      8
123             Name:            _foo
124             Flags:           0x0000000000000000
125             Address:         0x0000000000003FB7
126             Other:           0x0000000000000000
127             ImportName:      ''
128       NameList:
129         - n_strx:          2
130           n_type:          0x0F
131           n_sect:          1
132           n_desc:          0
133           n_value:         16311
134       StringTable:
135         - ' '
136         - _foo
137         - ''