brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.1 KiB · 327003a Raw
374 lines · plain
1; RUN: rm -rf %t2; RUN: split-file %s %t3; RUN: yaml2obj %t/payload-extended.yaml -o %t/payload-extended.dylib4; RUN: llvm-objdump --macho --exports-trie %t/payload-extended.dylib 2>&1 | FileCheck %s5 6; CHECK: 0x00003FB0  _foo7 8; RUN: yaml2obj %t/payload-truncated.yaml -o %t/payload-truncated.dylib9; RUN: not llvm-objdump --macho --exports-trie %t/payload-truncated.dylib 2>&1 | FileCheck %s --check-prefix=WRONG_SIZE10 11; WRONG_SIZE: truncated or malformed object (inconsistent export info size: 0x2 where actual size was: 0x3 in export trie data at node: 0x8)12 13# Yaml was manually crafted to have an export trie with a node entry14# where it's payload is larger than the size needed to read it.15;--- payload-extended.yaml16--- !mach-o17FileHeader:18  magic:           0xFEEDFACF19  cputype:         0x100000C20  cpusubtype:      0x021  filetype:        0x622  ncmds:           1323  sizeofcmds:      68024  flags:           0x10008525  reserved:        0x026LoadCommands:27  - cmd:             LC_SEGMENT_6428    cmdsize:         23229    segname:         __TEXT30    vmaddr:          031    vmsize:          1638432    fileoff:         033    filesize:        1638434    maxprot:         535    initprot:        536    nsects:          237    flags:           038    Sections:39      - sectname:        __text40        segname:         __TEXT41        addr:            0x3FB042        size:            843        offset:          0x3FB044        align:           245        reloff:          0x046        nreloc:          047        flags:           0x8000040048        reserved1:       0x049        reserved2:       0x050        reserved3:       0x051        content:         20008052C0035FD652      - sectname:        __unwind_info53        segname:         __TEXT54        addr:            0x3FB855        size:            7256        offset:          0x3FB857        align:           258        reloff:          0x059        nreloc:          060        flags:           0x061        reserved1:       0x062        reserved2:       0x063        reserved3:       0x064        content:         010000001C000000000000001C000000000000001C00000002000000B03F00003400000034000000B93F00000000000034000000030000000C00010010000100000000000000000265  - cmd:             LC_SEGMENT_6466    cmdsize:         7267    segname:         __LINKEDIT68    vmaddr:          1638469    vmsize:          1638470    fileoff:         1638471    filesize:        36172    maxprot:         173    initprot:        174    nsects:          075    flags:           076  - cmd:             LC_ID_DYLIB77    cmdsize:         4878    dylib:79      name:            2480      timestamp:       181      current_version: 082      compatibility_version: 083    Content:         '@rpath/libfoo.dylib'84    ZeroPadBytes:    585  - cmd:             LC_DYLD_INFO_ONLY86    cmdsize:         4887    rebase_off:      088    rebase_size:     089    bind_off:        090    bind_size:       091    weak_bind_off:   092    weak_bind_size:  093    lazy_bind_off:   094    lazy_bind_size:  095    export_off:      1638496    export_size:     1697  - cmd:             LC_SYMTAB98    cmdsize:         2499    symoff:          16408100    nsyms:           2101    stroff:          16440102    strsize:         24103  - cmd:             LC_DYSYMTAB104    cmdsize:         80105    ilocalsym:       0106    nlocalsym:       0107    iextdefsym:      0108    nextdefsym:      1109    iundefsym:       1110    nundefsym:       1111    tocoff:          0112    ntoc:            0113    modtaboff:       0114    nmodtab:         0115    extrefsymoff:    0116    nextrefsyms:     0117    indirectsymoff:  0118    nindirectsyms:   0119    extreloff:       0120    nextrel:         0121    locreloff:       0122    nlocrel:         0123  - cmd:             LC_UUID124    cmdsize:         24125    uuid:            A2CF51D8-828B-3E0F-B8FA-0DF9C5D1C91A126  - cmd:             LC_BUILD_VERSION127    cmdsize:         32128    platform:        1129    minos:           721664130    sdk:             917504131    ntools:          1132    Tools:133      - tool:            3134        version:         59441152135  - cmd:             LC_SOURCE_VERSION136    cmdsize:         16137    version:         0138  - cmd:             LC_LOAD_DYLIB139    cmdsize:         56140    dylib:141      name:            24142      timestamp:       2143      current_version: 87556096144      compatibility_version: 65536145    Content:         '/usr/lib/libSystem.B.dylib'146    ZeroPadBytes:    6147  - cmd:             LC_FUNCTION_STARTS148    cmdsize:         16149    dataoff:         16400150    datasize:        8151  - cmd:             LC_DATA_IN_CODE152    cmdsize:         16153    dataoff:         16408154    datasize:        0155  - cmd:             LC_CODE_SIGNATURE156    cmdsize:         16157    dataoff:         16464158    datasize:        281159LinkEditData:160  ExportTrie:161    TerminalSize:    0162    NodeOffset:      0163    Name:            ''164    Flags:           0x0165    Address:         0x0166    Other:           0x0167    ImportName:      ''168    Children:169      - TerminalSize:    4 170        NodeOffset:      8171        Name:            _foo172        Flags:           0x0173        Address:         0x3FB0174        Other:           0x0175        ImportName:      ''176  NameList:177    - n_strx:          2178      n_type:          0xF179      n_sect:          1180      n_desc:          0181      n_value:         16304182    - n_strx:          7183      n_type:          0x1184      n_sect:          0185      n_desc:          256186      n_value:         0187  StringTable:188    - ' '189    - _foo190    - dyld_stub_binder191  FunctionStarts:  [ 0x3FB0 ]192...193 194# Yaml was manually crafted to have an export trie with a node entry195# where it's payload is smaller than the size needed to read it.196;--- payload-truncated.yaml197--- !mach-o198FileHeader:199  magic:           0xFEEDFACF200  cputype:         0x100000C201  cpusubtype:      0x0202  filetype:        0x6203  ncmds:           13204  sizeofcmds:      680205  flags:           0x100085206  reserved:        0x0207LoadCommands:208  - cmd:             LC_SEGMENT_64209    cmdsize:         232210    segname:         __TEXT211    vmaddr:          0212    vmsize:          16384213    fileoff:         0214    filesize:        16384215    maxprot:         5216    initprot:        5217    nsects:          2218    flags:           0219    Sections:220      - sectname:        __text221        segname:         __TEXT222        addr:            0x3FB0223        size:            8224        offset:          0x3FB0225        align:           2226        reloff:          0x0227        nreloc:          0228        flags:           0x80000400229        reserved1:       0x0230        reserved2:       0x0231        reserved3:       0x0232        content:         20008052C0035FD6233      - sectname:        __unwind_info234        segname:         __TEXT235        addr:            0x3FB8236        size:            72237        offset:          0x3FB8238        align:           2239        reloff:          0x0240        nreloc:          0241        flags:           0x0242        reserved1:       0x0243        reserved2:       0x0244        reserved3:       0x0245        content:         010000001C000000000000001C000000000000001C00000002000000B03F00003400000034000000B93F00000000000034000000030000000C000100100001000000000000000002246  - cmd:             LC_SEGMENT_64247    cmdsize:         72248    segname:         __LINKEDIT249    vmaddr:          16384250    vmsize:          16384251    fileoff:         16384252    filesize:        361253    maxprot:         1254    initprot:        1255    nsects:          0256    flags:           0257  - cmd:             LC_ID_DYLIB258    cmdsize:         48259    dylib:260      name:            24261      timestamp:       1262      current_version: 0263      compatibility_version: 0264    Content:         '@rpath/libfoo.dylib'265    ZeroPadBytes:    5266  - cmd:             LC_DYLD_INFO_ONLY267    cmdsize:         48268    rebase_off:      0269    rebase_size:     0270    bind_off:        0271    bind_size:       0272    weak_bind_off:   0273    weak_bind_size:  0274    lazy_bind_off:   0275    lazy_bind_size:  0276    export_off:      16384277    export_size:     16278  - cmd:             LC_SYMTAB279    cmdsize:         24280    symoff:          16408281    nsyms:           2282    stroff:          16440283    strsize:         24284  - cmd:             LC_DYSYMTAB285    cmdsize:         80286    ilocalsym:       0287    nlocalsym:       0288    iextdefsym:      0289    nextdefsym:      1290    iundefsym:       1291    nundefsym:       1292    tocoff:          0293    ntoc:            0294    modtaboff:       0295    nmodtab:         0296    extrefsymoff:    0297    nextrefsyms:     0298    indirectsymoff:  0299    nindirectsyms:   0300    extreloff:       0301    nextrel:         0302    locreloff:       0303    nlocrel:         0304  - cmd:             LC_UUID305    cmdsize:         24306    uuid:            A2CF51D8-828B-3E0F-B8FA-0DF9C5D1C91A307  - cmd:             LC_BUILD_VERSION308    cmdsize:         32309    platform:        1310    minos:           721664311    sdk:             917504312    ntools:          1313    Tools:314      - tool:            3315        version:         59441152316  - cmd:             LC_SOURCE_VERSION317    cmdsize:         16318    version:         0319  - cmd:             LC_LOAD_DYLIB320    cmdsize:         56321    dylib:322      name:            24323      timestamp:       2324      current_version: 87556096325      compatibility_version: 65536326    Content:         '/usr/lib/libSystem.B.dylib'327    ZeroPadBytes:    6328  - cmd:             LC_FUNCTION_STARTS329    cmdsize:         16330    dataoff:         16400331    datasize:        8332  - cmd:             LC_DATA_IN_CODE333    cmdsize:         16334    dataoff:         16408335    datasize:        0336  - cmd:             LC_CODE_SIGNATURE337    cmdsize:         16338    dataoff:         16464339    datasize:        281340LinkEditData:341  ExportTrie:342    TerminalSize:    0343    NodeOffset:      0344    Name:            ''345    Flags:           0x0346    Address:         0x0347    Other:           0x0348    ImportName:      ''349    Children:350      - TerminalSize:    2 351        NodeOffset:      8352        Name:            _foo353        Flags:           0x0354        Address:         0x3FB0355        Other:           0x0356        ImportName:      ''357  NameList:358    - n_strx:          2359      n_type:          0xF360      n_sect:          1361      n_desc:          0362      n_value:         16304363    - n_strx:          7364      n_type:          0x1365      n_sect:          0366      n_desc:          256367      n_value:         0368  StringTable:369    - ' '370    - _foo371    - dyld_stub_binder372  FunctionStarts:  [ 0x3FB0 ]373...374