brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.5 KiB · fd4da2c Raw
259 lines · plain
1# RUN: yaml2obj %s -o %t 2 3## The binary used in this test can be built (on OSX) as follows:4## main.c:5##   __attribute__((used)) static int a[1021];6##   __attribute__((used)) static char b = 1;7##   int main() {8##     return 0;9##   }10## build command:11##   clang -fno-exceptions -fno-unwind-tables main.c -o main.exe12## Note, that the variable "b" (whose size is 1) is placed into __DATA,__data section,13## the array "a" (whose size is 4 * 1021 = 4084) is placed into __DATA,__bss and14## __DATA,__bss is 16-byte aligned. In this case the total vmsize narrowly crosses15## the border of one page (4096) and the final value should be equal to 8192.16 17# RUN: llvm-objcopy %t %t.copy18# RUN: cmp %t %t.copy19 20## This additionally verifies that the binary created by llvm-objcopy/yaml2obj is valid.21# RUN: llvm-readobj --sections %t.copy22 23--- !mach-o24FileHeader:25  magic:           0xFEEDFACF26  cputype:         0x0100000727  cpusubtype:      0x8000000328  filetype:        0x0000000229  ncmds:           1530  sizeofcmds:      97631  flags:           0x0020008532  reserved:        0x0000000033LoadCommands:34  - cmd:             LC_SEGMENT_6435    cmdsize:         7236    segname:         __PAGEZERO37    vmaddr:          038    vmsize:          429496729639    fileoff:         040    filesize:        041    maxprot:         042    initprot:        043    nsects:          044    flags:           045  - cmd:             LC_SEGMENT_6446    cmdsize:         23247    segname:         __TEXT48    vmaddr:          429496729649    vmsize:          409650    fileoff:         051    filesize:        409652    maxprot:         553    initprot:        554    nsects:          255    flags:           056    Sections:57      - sectname:        __text58        segname:         __TEXT59        addr:            0x0000000100000FA060        size:            1561        offset:          0x00000FA062        align:           463        reloff:          0x0000000064        nreloc:          065        flags:           0x8000040066        reserved1:       0x0000000067        reserved2:       0x0000000068        reserved3:       0x0000000069        content:         554889E531C0C745FC000000005DC370      - sectname:        __unwind_info71        segname:         __TEXT72        addr:            0x0000000100000FB073        size:            7274        offset:          0x00000FB075        align:           276        reloff:          0x0000000077        nreloc:          078        flags:           0x0000000079        reserved1:       0x0000000080        reserved2:       0x0000000081        reserved3:       0x0000000082        content:         010000001C000000000000001C000000000000001C00000002000000A00F00003400000034000000B00F00000000000034000000030000000C00010010000100000000000000000083  - cmd:             LC_SEGMENT_6484    cmdsize:         23285    segname:         __DATA86    vmaddr:          429497139287    vmsize:          819288    fileoff:         409689    filesize:        409690    maxprot:         391    initprot:        392    nsects:          293    flags:           094    Sections:95      - sectname:        __data96        segname:         __DATA97        addr:            0x000000010000100098        size:            199        offset:          0x00001000100        align:           0101        reloff:          0x00000000102        nreloc:          0103        flags:           0x00000000104        reserved1:       0x00000000105        reserved2:       0x00000000106        reserved3:       0x00000000107        content:         '01'108      - sectname:        __bss109        segname:         __DATA110        addr:            0x0000000100001010111        size:            4084112        offset:          0x00000000113        align:           4114        reloff:          0x00000000115        nreloc:          0116        flags:           0x00000001117        reserved1:       0x00000000118        reserved2:       0x00000000119        reserved3:       0x00000000120  - cmd:             LC_SEGMENT_64121    cmdsize:         72122    segname:         __LINKEDIT123    vmaddr:          4294979584124    vmsize:          4096125    fileoff:         8192126    filesize:        128127    maxprot:         1128    initprot:        1129    nsects:          0130    flags:           0131  - cmd:             LC_DYLD_INFO_ONLY132    cmdsize:         48133    rebase_off:      0134    rebase_size:     0135    bind_off:        0136    bind_size:       0137    weak_bind_off:   0138    weak_bind_size:  0139    lazy_bind_off:   0140    lazy_bind_size:  0141    export_off:      8192142    export_size:     48143  - cmd:             LC_SYMTAB144    cmdsize:         24145    symoff:          8248146    nsyms:           2147    stroff:          8280148    strsize:         40149  - cmd:             LC_DYSYMTAB150    cmdsize:         80151    ilocalsym:       0152    nlocalsym:       0153    iextdefsym:      0154    nextdefsym:      1155    iundefsym:       1156    nundefsym:       1157    tocoff:          0158    ntoc:            0159    modtaboff:       0160    nmodtab:         0161    extrefsymoff:    0162    nextrefsyms:     0163    indirectsymoff:  0164    nindirectsyms:   0165    extreloff:       0166    nextrel:         0167    locreloff:       0168    nlocrel:         0169  - cmd:             LC_LOAD_DYLINKER170    cmdsize:         32171    name:            12172    Content:         '/usr/lib/dyld'173    ZeroPadBytes:    7174  - cmd:             LC_UUID175    cmdsize:         24176    uuid:            11362E8D-D70B-33B3-96F8-A70ADF2583C4177  - cmd:             LC_BUILD_VERSION178    cmdsize:         32179    platform:        1180    minos:           658944181    sdk:             658944182    ntools:          1183    Tools:184      - tool:            3185        version:         34734080186  - cmd:             LC_SOURCE_VERSION187    cmdsize:         16188    version:         0189  - cmd:             LC_MAIN190    cmdsize:         24191    entryoff:        4000192    stacksize:       0193  - cmd:             LC_LOAD_DYLIB194    cmdsize:         56195    dylib:196      name:            24197      timestamp:       2198      current_version: 82115073199      compatibility_version: 65536200    Content:         '/usr/lib/libSystem.B.dylib'201    ZeroPadBytes:    6202  - cmd:             LC_FUNCTION_STARTS203    cmdsize:         16204    dataoff:         8240205    datasize:        8206  - cmd:             LC_DATA_IN_CODE207    cmdsize:         16208    dataoff:         8248209    datasize:        0210LinkEditData:211  ExportTrie:212    TerminalSize:    0213    NodeOffset:      0214    Name:            ''215    Flags:           0x0000000000000000216    Address:         0x0000000000000000217    Other:           0x0000000000000000218    ImportName:      ''219    Children:220      - TerminalSize:    0221        NodeOffset:      5222        Name:            _223        Flags:           0x0000000000000000224        Address:         0x0000000000000000225        Other:           0x0000000000000000226        ImportName:      ''227        Children:228          - TerminalSize:    2229            NodeOffset:      33230            Name:            _mh_execute_header231            Flags:           0x0000000000000000232            Address:         0x0000000000000000233            Other:           0x0000000000000000234            ImportName:      ''235          - TerminalSize:    3236            NodeOffset:      37237            Name:            main238            Flags:           0x0000000000000000239            Address:         0x0000000000000FA0240            Other:           0x0000000000000000241            ImportName:      ''242  NameList:243    - n_strx:          19244      n_type:          0x0F245      n_sect:          1246      n_desc:          16247      n_value:         4294967296248    - n_strx:          2249      n_type:          0x01250      n_sect:          0251      n_desc:          256252      n_value:         0253  StringTable:254    - ' '255    - dyld_stub_binder256    - __mh_execute_header257    - ''258...259