Debian Codegraph @

llvm/test/tools/llvm-objcopy/ELF/invalid-p_filesz-p_offset.test

raw
1 ## In this case, we have a program header with a file size that
2 ## overflows the binary size. Check llvm-objcopy doesn't crash
3 ## and report this error properly.
4
5 # RUN: yaml2obj --docnum=1 %s -o %t1.o
6 # RUN: not llvm-objcopy %t1.o 2>&1 | FileCheck %s --check-prefix=ERR1
7 # ERR1: error: program header with offset 0x78 and file size 0x100000 goes past the end of the file
8
9 --- !ELF
10 FileHeader:
11 Class: ELFCLASS64
12 Data: ELFDATA2LSB
13 Type: ET_EXEC
14 Machine: EM_X86_64
15 Sections:
16 - Name: .foo
17 Type: SHT_PROGBITS
18 ProgramHeaders:
19 - Type: PT_LOAD
20 FileSize: 0x100000
21 FirstSec: .foo
22 LastSec: .foo
23
24 ## A similar case, but now the p_offset property of the program header is too large.
25
26 # RUN: yaml2obj --docnum=2 %s -o %t2.o
27 # RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s --check-prefix=ERR2
28 # ERR2: error: program header with offset 0x100000 and file size 0x1 goes past the end of the file
29
30 --- !ELF
31 FileHeader:
32 Class: ELFCLASS64
33 Data: ELFDATA2LSB
34 Type: ET_EXEC
35 Machine: EM_X86_64
36 ProgramHeaders:
37 - Type: PT_LOAD
38 Offset: 0x100000
39 FileSize: 1