brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.3 KiB · 05595ce Raw
256 lines · plain
1# RUN: yaml2obj %s -o %t2 3## Verify that the input file is valid and contains the expected load command.4# RUN: llvm-objdump --private-headers %t | FileCheck %s --check-prefix=CHECK-ORIGINAL5 6# CHECK-ORIGINAL:      cmd LC_CODE_SIGNATURE7# CHECK-ORIGINAL-NEXT: cmdsize 168# CHECK-ORIGINAL-NEXT: dataoff 165449# CHECK-ORIGINAL-NEXT: datasize 28010 11# RUN: llvm-objcopy %t %t.copy12# RUN: obj2yaml %t > %t.yaml13# RUN: obj2yaml %t.copy > %t.copy.yaml14 15## Verify that the copy still includes the load command16# RUN: FileCheck %s --check-prefix=CHECK-COPY < %t.copy.yaml17# CHECK-COPY:      - cmd:             LC_CODE_SIGNATURE18# CHECK-COPY-NEXT:   cmdsize:         1619# CHECK-COPY-NEXT:   dataoff:         1654420# CHECK-COPY-NEXT:   datasize:        30421 22## Remove information changed by regeneration of load command:23## - __LINKEDIT segment filesize may change (4 lines)24## - LC_CODE_SIGNATURE command dataoff and datasize may change (3 lines)25## - __LINKEDIT data locations may change26## NOTE: The {N;N;N;N;d} means delete the next four lines for BSD and GNU sed.27##       The ,+4d is a GNU extension which seems not to work in macOS 10.1528 29# RUN: sed -e '/__LINKEDIT/{N;N;N;N;d;}' \30# RUN:     -e '/LC_CODE_SIGNATURE/{N;N;N;d;}' \31# RUN:     -e '/n_strx/d' \ 32# RUN:     -e '/dyld_stub_binder/d' %t.yaml > %t.clean.yaml33 34# RUN: sed -e '/__LINKEDIT/{N;N;N;N;d;}' \35# RUN:     -e '/LC_CODE_SIGNATURE/{N;N;N;d;}' \36# RUN:     -e '/n_strx/d' \ 37# RUN:     -e '/dyld_stub_binder/d' %t.copy.yaml > %t.copy.clean.yaml38 39## Verify the remainder of the object file remains unchanged40# RUN: diff %t.clean.yaml %t.copy.clean.yaml41 42## Verify the new signature is valid43# RUN: %python %p/Inputs/code-signature-check.py %t.copy 16544 304 0 1654444 45--- !mach-o46FileHeader:47  magic:           0xFEEDFACF48  cputype:         0x100000749  cpusubtype:      0x350  filetype:        0x251  ncmds:           1552  sizeofcmds:      76053  flags:           0x20008554  reserved:        0x055LoadCommands:56  - cmd:             LC_SEGMENT_6457    cmdsize:         7258    segname:         __PAGEZERO59    vmaddr:          060    vmsize:          429496729661    fileoff:         062    filesize:        063    maxprot:         064    initprot:        065    nsects:          066    flags:           067  - cmd:             LC_SEGMENT_6468    cmdsize:         23269    segname:         __TEXT70    vmaddr:          429496729671    vmsize:          1638472    fileoff:         073    filesize:        1638474    maxprot:         575    initprot:        576    nsects:          277    flags:           078    Sections:79      - sectname:        __text80        segname:         __TEXT81        addr:            0x100003FA082        size:            1583        offset:          0x3FA084        align:           485        reloff:          0x086        nreloc:          087        flags:           0x8000040088        reserved1:       0x089        reserved2:       0x090        reserved3:       0x091        content:         554889E531C0C745FC000000005DC392      - sectname:        __unwind_info93        segname:         __TEXT94        addr:            0x100003FB095        size:            7296        offset:          0x3FB097        align:           298        reloff:          0x099        nreloc:          0100        flags:           0x0101        reserved1:       0x0102        reserved2:       0x0103        reserved3:       0x0104        content:         010000001C000000000000001C000000000000001C00000002000000A03F00003400000034000000B03F00000000000034000000030000000C000100100001000000000000000001105  - cmd:             LC_SEGMENT_64106    cmdsize:         72107    segname:         __LINKEDIT108    vmaddr:          4294983680109    vmsize:          16384110    fileoff:         16384111    filesize:        440112    maxprot:         1113    initprot:        1114    nsects:          0115    flags:           0116  - cmd:             LC_DYLD_INFO_ONLY117    cmdsize:         48118    rebase_off:      0119    rebase_size:     0120    bind_off:        0121    bind_size:       0122    weak_bind_off:   0123    weak_bind_size:  0124    lazy_bind_off:   0125    lazy_bind_size:  0126    export_off:      16384127    export_size:     48128  - cmd:             LC_SYMTAB129    cmdsize:         24130    symoff:          16440131    nsyms:           3132    stroff:          16488133    strsize:         48134  - cmd:             LC_DYSYMTAB135    cmdsize:         80136    ilocalsym:       0137    nlocalsym:       0138    iextdefsym:      0139    nextdefsym:      2140    iundefsym:       2141    nundefsym:       1142    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:            42759668-1CBA-3094-8E2D-F01E1A66E815162  - cmd:             LC_BUILD_VERSION163    cmdsize:         32164    platform:        1165    minos:           720896166    sdk:             721664167    ntools:          1168    Tools:169      - tool:            3170        version:         42600704171  - cmd:             LC_SOURCE_VERSION172    cmdsize:         16173    version:         0174  - cmd:             LC_MAIN175    cmdsize:         24176    entryoff:        16288177    stacksize:       0178  - cmd:             LC_LOAD_DYLIB179    cmdsize:         56180    dylib:181      name:            24182      timestamp:       2183      current_version: 84698117184      compatibility_version: 65536185    Content:         '/usr/lib/libSystem.B.dylib'186    ZeroPadBytes:    6187  - cmd:             LC_FUNCTION_STARTS188    cmdsize:         16189    dataoff:         16432190    datasize:        8191  - cmd:             LC_DATA_IN_CODE192    cmdsize:         16193    dataoff:         16440194    datasize:        0195  - cmd:             LC_CODE_SIGNATURE196    cmdsize:         16197    dataoff:         16544198    datasize:        280199LinkEditData:200  ExportTrie:201    TerminalSize:    0202    NodeOffset:      0203    Name:            ''204    Flags:           0x0205    Address:         0x0206    Other:           0x0207    ImportName:      ''208    Children:209      - TerminalSize:    0210        NodeOffset:      5211        Name:            _212        Flags:           0x0213        Address:         0x0214        Other:           0x0215        ImportName:      ''216        Children:217          - TerminalSize:    2218            NodeOffset:      33219            Name:            _mh_execute_header220            Flags:           0x0221            Address:         0x0222            Other:           0x0223            ImportName:      ''224          - TerminalSize:    3225            NodeOffset:      37226            Name:            main227            Flags:           0x0228            Address:         0x3FA0229            Other:           0x0230            ImportName:      ''231  NameList:232    - n_strx:          2233      n_type:          0xF234      n_sect:          1235      n_desc:          16236      n_value:         4294967296237    - n_strx:          22238      n_type:          0xF239      n_sect:          1240      n_desc:          0241      n_value:         4294983584242    - n_strx:          28243      n_type:          0x1244      n_sect:          0245      n_desc:          256246      n_value:         0247  StringTable:248    - ' '249    - __mh_execute_header250    - _main251    - dyld_stub_binder252    - ''253    - ''254    - ''255...256