280 lines · plain
1# RUN: rm -rf %t && mkdir %t2# RUN: yaml2obj %s -o %t/original3# RUN: llvm-strip --strip-all %t/original -o %t/stripped4# RUN: llvm-readobj --macho-segment --section-headers %t/stripped | FileCheck %s5 6# CHECK-LABEL: Sections [7# CHECK: Index: 08# CHECK-NEXT: Name: __text9# CHECK-NEXT: Segment: __TEXT10# CHECK: Offset: 1638411 12# CHECK-LABEL: Name: __PAGEZERO13# CHECK: fileoff: 014 15# CHECK-LABEL: Name: __TEXT16# CHECK: fileoff: 017 18# The YAML below is the following code19# ```20# static int foo = 12345;21# int bar = 4567;22# int main(int argc, char **argv) { return 0; }23# ```24# Compiled on macOS against the macOS SDK and passing `-Wl,-encryptable`25# Contents are removed, since they are not important for the test. We need a26# small text segment (smaller than a page).27--- !mach-o28FileHeader:29 magic: 0xFEEDFACF30 cputype: 0x100000C31 cpusubtype: 0x032 filetype: 0x233 ncmds: 1834 sizeofcmds: 92035 flags: 0x20008536 reserved: 0x037LoadCommands:38 - cmd: LC_SEGMENT_6439 cmdsize: 7240 segname: __PAGEZERO41 vmaddr: 042 vmsize: 429496729643 fileoff: 044 filesize: 045 maxprot: 046 initprot: 047 nsects: 048 flags: 049 - cmd: LC_SEGMENT_6450 cmdsize: 23251 segname: __TEXT52 vmaddr: 429496729653 vmsize: 3276854 fileoff: 055 filesize: 3276856 maxprot: 557 initprot: 558 nsects: 259 flags: 060 Sections:61 - sectname: __text62 segname: __TEXT63 addr: 0x10000400064 size: 3265 offset: 0x400066 align: 267 reloff: 0x068 nreloc: 069 flags: 0x8000040070 reserved1: 0x071 reserved2: 0x072 reserved3: 0x073 - sectname: __unwind_info74 segname: __TEXT75 addr: 0x10000402076 size: 8877 offset: 0x402078 align: 279 reloff: 0x080 nreloc: 081 flags: 0x082 reserved1: 0x083 reserved2: 0x084 reserved3: 0x085 - cmd: LC_SEGMENT_6486 cmdsize: 15287 segname: __DATA88 vmaddr: 429500006489 vmsize: 1638490 fileoff: 3276891 filesize: 1638492 maxprot: 393 initprot: 394 nsects: 195 flags: 096 Sections:97 - sectname: __data98 segname: __DATA99 addr: 0x100008000100 size: 4101 offset: 0x8000102 align: 2103 reloff: 0x0104 nreloc: 0105 flags: 0x0106 reserved1: 0x0107 reserved2: 0x0108 reserved3: 0x0109 - cmd: LC_SEGMENT_64110 cmdsize: 72111 segname: __LINKEDIT112 vmaddr: 4295016448113 vmsize: 16384114 fileoff: 49152115 filesize: 768116 maxprot: 1117 initprot: 1118 nsects: 0119 flags: 0120 - cmd: LC_DYLD_CHAINED_FIXUPS121 cmdsize: 16122 dataoff: 49152123 datasize: 56124 - cmd: LC_DYLD_EXPORTS_TRIE125 cmdsize: 16126 dataoff: 49208127 datasize: 64128 - cmd: LC_SYMTAB129 cmdsize: 24130 symoff: 49280131 nsyms: 3132 stroff: 49328133 strsize: 40134 - cmd: LC_DYSYMTAB135 cmdsize: 80136 ilocalsym: 0137 nlocalsym: 0138 iextdefsym: 0139 nextdefsym: 3140 iundefsym: 3141 nundefsym: 0142 tocoff: 0143 ntoc: 0144 modtaboff: 0145 nmodtab: 0146 extrefsymoff: 0147 nextrefsyms: 0148 indirectsymoff: 0149 nindirectsyms: 0150 extreloff: 0151 nextrel: 0152 locreloff: 0153 nlocrel: 0154 - cmd: LC_LOAD_DYLINKER155 cmdsize: 32156 name: 12157 Content: '/usr/lib/dyld'158 ZeroPadBytes: 7159 - cmd: LC_UUID160 cmdsize: 24161 uuid: ADDA943C-657A-3A49-9580-168E17A40FFB162 - cmd: LC_BUILD_VERSION163 cmdsize: 32164 platform: 1165 minos: 983040166 sdk: 984320167 ntools: 1168 Tools:169 - tool: 3170 version: 76481537171 - cmd: LC_SOURCE_VERSION172 cmdsize: 16173 version: 0174 - cmd: LC_MAIN175 cmdsize: 24176 entryoff: 16384177 stacksize: 0178 - cmd: LC_ENCRYPTION_INFO_64179 cmdsize: 24180 cryptoff: 16384181 cryptsize: 16384182 cryptid: 0183 pad: 0184 - cmd: LC_LOAD_DYLIB185 cmdsize: 56186 dylib:187 name: 24188 timestamp: 2189 current_version: 88539136190 compatibility_version: 65536191 Content: '/usr/lib/libSystem.B.dylib'192 ZeroPadBytes: 6193 - cmd: LC_FUNCTION_STARTS194 cmdsize: 16195 dataoff: 49272196 datasize: 8197 - cmd: LC_DATA_IN_CODE198 cmdsize: 16199 dataoff: 49280200 datasize: 0201 - cmd: LC_CODE_SIGNATURE202 cmdsize: 16203 dataoff: 49376204 datasize: 544205LinkEditData:206 ExportTrie:207 TerminalSize: 0208 NodeOffset: 0209 Name: ''210 Flags: 0x0211 Address: 0x0212 Other: 0x0213 ImportName: ''214 Children:215 - TerminalSize: 0216 NodeOffset: 25217 Name: _218 Flags: 0x0219 Address: 0x0220 Other: 0x0221 ImportName: ''222 Children:223 - TerminalSize: 2224 NodeOffset: 9225 Name: _mh_execute_header226 Flags: 0x0227 Address: 0x0228 Other: 0x0229 ImportName: ''230 - TerminalSize: 4231 NodeOffset: 13232 Name: bar233 Flags: 0x0234 Address: 0x8000235 Other: 0x0236 ImportName: ''237 - TerminalSize: 4238 NodeOffset: 19239 Name: main240 Flags: 0x0241 Address: 0x4000242 Other: 0x0243 ImportName: ''244 NameList:245 - n_strx: 2246 n_type: 0xF247 n_sect: 1248 n_desc: 16249 n_value: 4294967296250 - n_strx: 22251 n_type: 0xF252 n_sect: 3253 n_desc: 0254 n_value: 4295000064255 - n_strx: 27256 n_type: 0xF257 n_sect: 1258 n_desc: 0259 n_value: 4294983680260 StringTable:261 - ' '262 - __mh_execute_header263 - _bar264 - _main265 - ''266 - ''267 - ''268 - ''269 - ''270 - ''271 - ''272 FunctionStarts: [ 0x4000 ]273 ChainedFixups: [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x34, 0x0,274 0x0, 0x0, 0x34, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,275 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,276 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,277 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,278 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]279...280