brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · ef11711 Raw
56 lines · yaml
1## Test that yaml2obj handles load commands with cmdsize smaller than the2## actual structure size without crashing (due to integer underflow).3 4## Test with a known load command (LC_SEGMENT_64).5# RUN: yaml2obj %s --docnum=1 -o %t1 2>&1 | FileCheck %s --check-prefix=WARNING-KNOWN6# RUN: not llvm-readobj --file-headers %t1 2>&1 | FileCheck %s --check-prefix=MALFORMED7 8# WARNING-KNOWN: warning: load command 0 LC_SEGMENT_64 cmdsize too small (56 bytes) for actual size (72 bytes)9 10# MALFORMED: error: {{.*}}: truncated or malformed object (load command 0 LC_SEGMENT_64 cmdsize too small)11 12--- !mach-o13FileHeader:14  magic:           0xFEEDFACF15  cputype:         0x0100000716  cpusubtype:      0x0000000317  filetype:        0x0000000118  ncmds:           119  sizeofcmds:      5620  flags:           0x0000200021  reserved:        0x0000000022LoadCommands:23  - cmd:             LC_SEGMENT_6424    cmdsize:         56          ## Should be 72 for LC_SEGMENT_6425    segname:         '__TEXT'26    vmaddr:          0x100027    vmsize:          0x1028    fileoff:         029    filesize:        030    maxprot:         731    initprot:        532    nsects:          033    flags:           034...35 36## Test with an unknown load command value.37# RUN: yaml2obj %s --docnum=2 -o %t2 2>&1 | FileCheck %s --check-prefix=WARNING-UNKNOWN38 39# WARNING-UNKNOWN: warning: load command 0 (0xdeadbeef) cmdsize too small (8 bytes) for actual size (20 bytes)40 41--- !mach-o42FileHeader:43  magic:           0xFEEDFACF44  cputype:         0x0100000745  cpusubtype:      0x0000000346  filetype:        0x0000000147  ncmds:           148  sizeofcmds:      2049  flags:           0x0000200050  reserved:        0x0000000051LoadCommands:52  - cmd:             0xDEADBEEF53    cmdsize:         854    PayloadBytes:    [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C]55...56