[clang][Modules] Raise empty.modulemap expected size to <70KB to fix RISC-V failure...
[llvm-project.git] / llvm / test / tools / llvm-objcopy / MachO / linkedit-order-1.test
blob4915f344c1e7e2757ebc5deb95deb7e625d839fd
1 ## This test verifies that the linkedit segment is
2 ## laid out in the right order.
4 # RUN: yaml2obj %s -o %t.original
5 # RUN: llvm-objcopy %t.original %t.copy
6 # RUN: obj2yaml %t.copy > %t.yaml
7 ## Print the results several times in order to capture the linkedit offsets
8 ## in the order they are needed, but still following the order of the load
9 ## commands where they appear.
10 # RUN: cat %t.yaml %t.yaml %t.yaml | FileCheck %s
12 # CHECK: cmd:             LC_SEGMENT_64
13 # CHECK: segname:         __LINKEDIT
14 # CHECK: fileoff:         [[#LINKEDIT_FILEOFF:]]
15 # CHECK: filesize:        [[#LINKEDIT_FILESIZE:]]
17 # CHECK: cmd:             LC_DYLD_INFO_ONLY
18 # CHECK: rebase_off:      [[#REBASE_OFF: LINKEDIT_FILEOFF]]
19 # CHECK: rebase_size:     [[#REBASE_SIZE:]]
20 # CHECK: bind_off:        [[#BIND_OFF: REBASE_OFF + REBASE_SIZE]]
21 # CHECK: bind_size:       [[#BIND_SIZE:]]
22 # CHECK: weak_bind_off:   [[#WEAK_BIND_OFF: BIND_OFF + BIND_SIZE]]
23 # CHECK: weak_bind_size:  [[#WEAK_BIND_SIZE:]]
24 # CHECK: lazy_bind_off:   [[#LAZY_BIND_OFF: WEAK_BIND_OFF + WEAK_BIND_SIZE]]
25 # CHECK: lazy_bind_size:  [[#LAZY_BIND_SIZE:]]
26 # CHECK: export_off:      [[#EXPORTS_OFF:LAZY_BIND_OFF + LAZY_BIND_SIZE]]
27 # CHECK: export_size:     [[#EXPORTS_SIZE:]]
29 # CHECK: cmd:             LC_FUNCTION_STARTS
30 # CHECK: dataoff:         [[#FUNCTION_STARTS_FILEOFF: EXPORTS_OFF + EXPORTS_SIZE]]
31 # CHECK: datasize:        [[#FUNCTION_STARTS_FILESIZE:]]
33 # CHECK: cmd:             LC_DATA_IN_CODE
34 # CHECK: dataoff:         [[#DATA_IN_CODE_FILEOFF: FUNCTION_STARTS_FILEOFF + FUNCTION_STARTS_FILESIZE]]
35 # CHECK: datasize:        [[#DATA_IN_CODE_FILESIZE:]]
37 ## Jump over LC_CODE_SIGNATURE, which needs to be checked last
39 # CHECK: --- !mach-o
41 # CHECK: cmd:             LC_SYMTAB
42 # CHECK: symoff:          [[#SYMTAB_SYMOFF: DATA_IN_CODE_FILEOFF + DATA_IN_CODE_FILESIZE]]
43 # CHECK: nsyms:           [[#SYMTAB_NSYMS:]]
45 ## Skip over the strings table offset/size (part of LC_SYMTAB) until next loop.
47 # CHECK: cmd:             LC_DYSYMTAB
48 # CHECK: indirectsymoff:  [[#DYSYMTAB_INDIRECTSYMOFF: SYMTAB_SYMOFF + mul(SYMTAB_NSYMS, 16)]]
49 # CHECK: nindirectsyms:   [[#DYSYMTAB_NINDIRECTSYMS:]]
51 # CHECK: --- !mach-o
53 # CHECK: cmd:             LC_SYMTAB
54 # CHECK: stroff:          [[#SYMTAB_STROFF: DYSYMTAB_INDIRECTSYMOFF + mul(DYSYMTAB_NINDIRECTSYMS, 4)]]
55 # CHECK: strsize:         [[#SYMTAB_STRSIZE:]]
57 # CHECK: cmd:             LC_CODE_SIGNATURE
58 ## LC_CODE_SIGNATURE needs to be aligned to 16 bytes boundaries.
59 # CHECK: dataoff:         [[#CODE_SIGNATURE_FILEOFF: mul(div(SYMTAB_STROFF + SYMTAB_STRSIZE + 8, 16), 16)]]
60 # CHECK: datasize:        [[#CODE_SIGNATURE_FILESIZE:LINKEDIT_FILEOFF + LINKEDIT_FILESIZE - CODE_SIGNATURE_FILEOFF]]
62 --- !mach-o
63 FileHeader:
64   magic:           0xFEEDFACF
65   cputype:         0x1000007
66   cpusubtype:      0x3
67   filetype:        0x2
68   ncmds:           18
69   sizeofcmds:      1352
70   flags:           0x210085
71   reserved:        0x0
72 LoadCommands:
73   - cmd:             LC_SEGMENT_64
74     cmdsize:         72
75     segname:         __PAGEZERO
76     vmaddr:          0
77     vmsize:          4294967296
78     fileoff:         0
79     filesize:        0
80     maxprot:         0
81     initprot:        0
82     nsects:          0
83     flags:           0
84   - cmd:             LC_SEGMENT_64
85     cmdsize:         392
86     segname:         __TEXT
87     vmaddr:          4294967296
88     vmsize:          16384
89     fileoff:         0
90     filesize:        16384
91     maxprot:         5
92     initprot:        5
93     nsects:          4
94     flags:           0
95     Sections:
96       - sectname:        __text
97         segname:         __TEXT
98         addr:            0x100003F80
99         size:            16
100         offset:          0x3F80
101         align:           2
102         reloff:          0x0
103         nreloc:          0
104         flags:           0x80000400
105         reserved1:       0x0
106         reserved2:       0x0
107         reserved3:       0x0
108         content:         E80B000000E80C000000C39000000000
109       - sectname:        __stubs
110         segname:         __TEXT
111         addr:            0x100003F90
112         size:            12
113         offset:          0x3F90
114         align:           1
115         reloff:          0x0
116         nreloc:          0
117         flags:           0x80000408
118         reserved1:       0x0
119         reserved2:       0x6
120         reserved3:       0x0
121         content:         FF256A400000FF256C400000
122       - sectname:        __stub_helper
123         segname:         __TEXT
124         addr:            0x100003F9C
125         size:            26
126         offset:          0x3F9C
127         align:           2
128         reloff:          0x0
129         nreloc:          0
130         flags:           0x80000400
131         reserved1:       0x0
132         reserved2:       0x0
133         reserved3:       0x0
134         content:         4C8D1D6D4000004153FF2555000000906800000000E9E6FFFFFF
135       - sectname:        __unwind_info
136         segname:         __TEXT
137         addr:            0x100003FB8
138         size:            72
139         offset:          0x3FB8
140         align:           2
141         reloff:          0x0
142         nreloc:          0
143         flags:           0x0
144         reserved1:       0x0
145         reserved2:       0x0
146         reserved3:       0x0
147         content:         010000001C000000000000001C000000000000001C00000002000000803F00003400000034000000913F00000000000034000000030000000C000100100001000000000000000000
148   - cmd:             LC_SEGMENT_64
149     cmdsize:         152
150     segname:         __DATA_CONST
151     vmaddr:          4294983680
152     vmsize:          16384
153     fileoff:         16384
154     filesize:        16384
155     maxprot:         3
156     initprot:        3
157     nsects:          1
158     flags:           16
159     Sections:
160       - sectname:        __got
161         segname:         __DATA_CONST
162         addr:            0x100004000
163         size:            8
164         offset:          0x4000
165         align:           3
166         reloff:          0x0
167         nreloc:          0
168         flags:           0x6
169         reserved1:       0x2
170         reserved2:       0x0
171         reserved3:       0x0
172         content:         '0000000000000000'
173   - cmd:             LC_SEGMENT_64
174     cmdsize:         232
175     segname:         __DATA
176     vmaddr:          4295000064
177     vmsize:          16384
178     fileoff:         32768
179     filesize:        16384
180     maxprot:         3
181     initprot:        3
182     nsects:          2
183     flags:           0
184     Sections:
185       - sectname:        __la_symbol_ptr
186         segname:         __DATA
187         addr:            0x100008000
188         size:            16
189         offset:          0x8000
190         align:           3
191         reloff:          0x0
192         nreloc:          0
193         flags:           0x7
194         reserved1:       0x3
195         reserved2:       0x0
196         reserved3:       0x0
197         content:         AC3F0000010000000000000000000000
198       - sectname:        __data
199         segname:         __DATA
200         addr:            0x100008010
201         size:            8
202         offset:          0x8010
203         align:           3
204         reloff:          0x0
205         nreloc:          0
206         flags:           0x0
207         reserved1:       0x0
208         reserved2:       0x0
209         reserved3:       0x0
210         content:         '0000000000000000'
211   - cmd:             LC_SEGMENT_64
212     cmdsize:         72
213     segname:         __LINKEDIT
214     vmaddr:          4295016448
215     vmsize:          16384
216     fileoff:         49152
217     filesize:        920
218     maxprot:         1
219     initprot:        1
220     nsects:          0
221     flags:           0
222   - cmd:             LC_DYLD_INFO_ONLY
223     cmdsize:         48
224     rebase_off:      49152
225     rebase_size:     8
226     bind_off:        49160
227     bind_size:       56
228     weak_bind_off:   49216
229     weak_bind_size:  32
230     lazy_bind_off:   49248
231     lazy_bind_size:  16
232     export_off:      49264
233     export_size:     48
234   - cmd:             LC_SYMTAB
235     cmdsize:         24
236     symoff:          49328
237     nsyms:           6
238     stroff:          49448
239     strsize:         80
240   - cmd:             LC_DYSYMTAB
241     cmdsize:         80
242     ilocalsym:       0
243     nlocalsym:       1
244     iextdefsym:      1
245     nextdefsym:      2
246     iundefsym:       3
247     nundefsym:       3
248     tocoff:          0
249     ntoc:            0
250     modtaboff:       0
251     nmodtab:         0
252     extrefsymoff:    0
253     nextrefsyms:     0
254     indirectsymoff:  49424
255     nindirectsyms:   5
256     extreloff:       0
257     nextrel:         0
258     locreloff:       0
259     nlocrel:         0
260   - cmd:             LC_LOAD_DYLINKER
261     cmdsize:         32
262     name:            12
263     Content:         '/usr/lib/dyld'
264     ZeroPadBytes:    7
265   - cmd:             LC_UUID
266     cmdsize:         24
267     uuid:            D565F8BE-1140-391A-BD6E-9CED386430F2
268   - cmd:             LC_BUILD_VERSION
269     cmdsize:         32
270     platform:        1
271     minos:           786432
272     sdk:             787200
273     ntools:          1
274     Tools:
275       - tool:            3
276         version:         50069504
277   - cmd:             LC_SOURCE_VERSION
278     cmdsize:         16
279     version:         0
280   - cmd:             LC_MAIN
281     cmdsize:         24
282     entryoff:        16256
283     stacksize:       0
284   - cmd:             LC_LOAD_DYLIB
285     cmdsize:         48
286     dylib:
287       name:            24
288       timestamp:       2
289       current_version: 0
290       compatibility_version: 0
291     Content:         libFoo-classic.dylib
292     ZeroPadBytes:    4
293   - cmd:             LC_LOAD_DYLIB
294     cmdsize:         56
295     dylib:
296       name:            24
297       timestamp:       2
298       current_version: 85943299
299       compatibility_version: 65536
300     Content:         '/usr/lib/libSystem.B.dylib'
301     ZeroPadBytes:    6
302   - cmd:             LC_FUNCTION_STARTS
303     cmdsize:         16
304     dataoff:         49312
305     datasize:        8
306   - cmd:             LC_DATA_IN_CODE
307     cmdsize:         16
308     dataoff:         49320
309     datasize:        8
310   - cmd:             LC_CODE_SIGNATURE
311     cmdsize:         16
312     dataoff:         49536
313     datasize:        536
314 LinkEditData:
315   RebaseOpcodes:
316     - Opcode:          REBASE_OPCODE_SET_TYPE_IMM
317       Imm:             1
318     - Opcode:          REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
319       Imm:             3
320       ExtraData:       [ 0x0 ]
321     - Opcode:          REBASE_OPCODE_DO_REBASE_IMM_TIMES
322       Imm:             1
323     - Opcode:          REBASE_OPCODE_DONE
324       Imm:             0
325   BindOpcodes:
326     - Opcode:          BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
327       Imm:             1
328       Symbol:          ''
329     - Opcode:          BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
330       Imm:             0
331       Symbol:          _weak_foo
332     - Opcode:          BIND_OPCODE_SET_TYPE_IMM
333       Imm:             1
334       Symbol:          ''
335     - Opcode:          BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
336       Imm:             3
337       ULEBExtraData:   [ 0x8 ]
338       Symbol:          ''
339     - Opcode:          BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB
340       Imm:             0
341       ULEBExtraData:   [ 0xFFFFFFFFFFFFFFF8 ]
342       Symbol:          ''
343     - Opcode:          BIND_OPCODE_DO_BIND
344       Imm:             0
345       Symbol:          ''
346     - Opcode:          BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
347       Imm:             2
348       Symbol:          ''
349     - Opcode:          BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
350       Imm:             0
351       Symbol:          dyld_stub_binder
352     - Opcode:          BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
353       Imm:             2
354       ULEBExtraData:   [ 0x0 ]
355       Symbol:          ''
356     - Opcode:          BIND_OPCODE_DO_BIND
357       Imm:             0
358       Symbol:          ''
359     - Opcode:          BIND_OPCODE_DONE
360       Imm:             0
361       Symbol:          ''
362   WeakBindOpcodes:
363     - Opcode:          BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
364       Imm:             0
365       Symbol:          _weak_foo
366     - Opcode:          BIND_OPCODE_SET_TYPE_IMM
367       Imm:             1
368       Symbol:          ''
369     - Opcode:          BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
370       Imm:             3
371       ULEBExtraData:   [ 0x8 ]
372       Symbol:          ''
373     - Opcode:          BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB
374       Imm:             0
375       ULEBExtraData:   [ 0xFFFFFFFFFFFFFFF8 ]
376       Symbol:          ''
377     - Opcode:          BIND_OPCODE_DO_BIND
378       Imm:             0
379       Symbol:          ''
380     - Opcode:          BIND_OPCODE_DONE
381       Imm:             0
382       Symbol:          ''
383   LazyBindOpcodes:
384     - Opcode:          BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
385       Imm:             3
386       ULEBExtraData:   [ 0x0 ]
387       Symbol:          ''
388     - Opcode:          BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
389       Imm:             1
390       Symbol:          ''
391     - Opcode:          BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
392       Imm:             0
393       Symbol:          _foo
394     - Opcode:          BIND_OPCODE_DO_BIND
395       Imm:             0
396       Symbol:          ''
397     - Opcode:          BIND_OPCODE_DONE
398       Imm:             0
399       Symbol:          ''
400     - Opcode:          BIND_OPCODE_DONE
401       Imm:             0
402       Symbol:          ''
403     - Opcode:          BIND_OPCODE_DONE
404       Imm:             0
405       Symbol:          ''
406     - Opcode:          BIND_OPCODE_DONE
407       Imm:             0
408       Symbol:          ''
409     - Opcode:          BIND_OPCODE_DONE
410       Imm:             0
411       Symbol:          ''
412     - Opcode:          BIND_OPCODE_DONE
413       Imm:             0
414       Symbol:          ''
415   ExportTrie:
416     TerminalSize:    0
417     NodeOffset:      0
418     Name:            ''
419     Flags:           0x0
420     Address:         0x0
421     Other:           0x0
422     ImportName:      ''
423     Children:
424       - TerminalSize:    0
425         NodeOffset:      5
426         Name:            _
427         Flags:           0x0
428         Address:         0x0
429         Other:           0x0
430         ImportName:      ''
431         Children:
432           - TerminalSize:    2
433             NodeOffset:      33
434             Name:            _mh_execute_header
435             Flags:           0x0
436             Address:         0x0
437             Other:           0x0
438             ImportName:      ''
439           - TerminalSize:    3
440             NodeOffset:      37
441             Name:            main
442             Flags:           0x0
443             Address:         0x3F80
444             Other:           0x0
445             ImportName:      ''
446   NameList:
447     - n_strx:          60
448       n_type:          0xE
449       n_sect:          7
450       n_desc:          0
451       n_value:         4295000080
452     - n_strx:          2
453       n_type:          0xF
454       n_sect:          1
455       n_desc:          16
456       n_value:         4294967296
457     - n_strx:          22
458       n_type:          0xF
459       n_sect:          1
460       n_desc:          0
461       n_value:         4294983552
462     - n_strx:          28
463       n_type:          0x1
464       n_sect:          0
465       n_desc:          256
466       n_value:         0
467     - n_strx:          33
468       n_type:          0x1
469       n_sect:          0
470       n_desc:          384
471       n_value:         0
472     - n_strx:          43
473       n_type:          0x1
474       n_sect:          0
475       n_desc:          512
476       n_value:         0
477   StringTable:
478     - ' '
479     - __mh_execute_header
480     - _main
481     - _foo
482     - _weak_foo
483     - dyld_stub_binder
484     - __dyld_private
485     - ''
486     - ''
487     - ''
488     - ''
489     - ''
490   IndirectSymbols: [ 0x3, 0x4, 0x5, 0x3, 0x4 ]
491   FunctionStarts:  [ 0x3F80 ]
492   DataInCode:
493     - Offset:          0x3F8C
494       Length:          4
495       Kind:            0x4