139 lines · yaml
1## Stub dylibs differ from "real" dylibs in that they lack any content in their2## sections. What they do have are export tries and symbol tables, which means3## we can still link against them. I (jezng) am unclear how to properly create4## these stub dylibs; XCode 11.3's `lipo` is able to create stub dylibs, but5## those lack LC_ID_DYLIB load commands and are considered invalid by most6## 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 still8## seems worthwhile to support them. The YAML in this test was generated by9## taking a non-stub dylib and editing the appropriate fields.10 11# REQUIRES: x8612# RUN: rm -rf %t; split-file %s %t13# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o14# RUN: yaml2obj %t/fat.dylib.yaml > %t/fat.dylib15# RUN: %lld -lSystem %t/test.o %t/fat.dylib -o %t/test16# RUN: llvm-objdump --macho --lazy-bind %t/test | FileCheck %s17# CHECK: __DATA __la_symbol_ptr 0x100002000 foo _foo18 19#--- test.s20.globl _main21_main:22 callq _foo23 ret24 25#--- fat.dylib.yaml26--- !fat-mach-o27FatHeader:28 magic: 0xCAFEBABE29 nfat_arch: 130FatArchs:31 - cputype: 0x0100000732 cpusubtype: 0x0000000333 offset: 0x000000000000100034 size: 1643235 align: 1236Slices:37 - !mach-o38 FileHeader:39 magic: 0xFEEDFACF40 cputype: 0x0100000741 cpusubtype: 0x0000000342 filetype: 0x0000000943 ncmds: 544 sizeofcmds: 56845 flags: 0x0010008546 reserved: 0x0000000047 LoadCommands:48 - cmd: LC_SEGMENT_6449 cmdsize: 23250 segname: __TEXT51 vmaddr: 052 vmsize: 1638453 fileoff: 054 filesize: 1638455 maxprot: 556 initprot: 557 nsects: 158 flags: 059 Sections:60 - sectname: __text61 segname: __TEXT62 addr: 0x000000000000000063 size: 064 offset: 0x00003FB765 align: 066 reloff: 0x0000000067 nreloc: 068 flags: 0x8000040069 reserved1: 0x0000000070 reserved2: 0x0000000071 reserved3: 0x0000000072 content: ''73 - cmd: LC_SEGMENT_6474 cmdsize: 7275 segname: __LINKEDIT76 vmaddr: 1638477 vmsize: 1638478 fileoff: 1638479 filesize: 4880 maxprot: 181 initprot: 182 nsects: 083 flags: 084 - cmd: LC_ID_DYLIB85 cmdsize: 4086 dylib:87 name: 2488 timestamp: 189 current_version: 090 compatibility_version: 091 Content: foo.dylib92 ZeroPadBytes: 793 - cmd: LC_DYLD_INFO_ONLY94 cmdsize: 4895 rebase_off: 096 rebase_size: 097 bind_off: 098 bind_size: 099 weak_bind_off: 0100 weak_bind_size: 0101 lazy_bind_off: 0102 lazy_bind_size: 0103 export_off: 16384104 export_size: 16105 - cmd: LC_SYMTAB106 cmdsize: 24107 symoff: 16408108 nsyms: 1109 stroff: 16424110 strsize: 8111 LinkEditData:112 ExportTrie:113 TerminalSize: 0114 NodeOffset: 0115 Name: ''116 Flags: 0x0000000000000000117 Address: 0x0000000000000000118 Other: 0x0000000000000000119 ImportName: ''120 Children:121 - TerminalSize: 3122 NodeOffset: 8123 Name: _foo124 Flags: 0x0000000000000000125 Address: 0x0000000000003FB7126 Other: 0x0000000000000000127 ImportName: ''128 NameList:129 - n_strx: 2130 n_type: 0x0F131 n_sect: 1132 n_desc: 0133 n_value: 16311134 StringTable:135 - ' '136 - _foo137 - ''138...139