1 ## Check that program headers are output correctly
\r
3 # RUN: yaml2obj --docnum=1 -DBITS=32 -DMACHINE=EM_386 %s -o %t32.elf
\r
4 # RUN: llvm-objdump --private-headers %t32.elf | FileCheck %s --check-prefixes=ELF32
\r
6 # ELF32: Program Header:
\r
7 # ELF32-NEXT: PHDR off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
8 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags -w-
\r
9 # ELF32-NEXT: PHDR off 0x00000317 vaddr 0x00002000 paddr 0x00002000 align 2**0
\r
10 # ELF32-NEXT: filesz 0x00000007 memsz 0x00000007 flags --x
\r
11 # ELF32-NEXT: UNKNOWN off 0x00000317 vaddr 0x00002000 paddr 0x00002000 align 2**0
\r
12 # ELF32-NEXT: filesz 0x00000007 memsz 0x00000007 flags --x
\r
13 # ELF32-NEXT: DYNAMIC off 0x00000324 vaddr 0x00006000 paddr 0x00006000 align 2**0
\r
14 # ELF32-NEXT: filesz 0x00000010 memsz 0x00000010 flags rwx
\r
15 # ELF32-NEXT: INTERP off 0x0000031e vaddr 0x00003000 paddr 0x00003000 align 2**0
\r
16 # ELF32-NEXT: filesz 0x00000004 memsz 0x00000004 flags rw-
\r
17 # ELF32-NEXT: NOTE off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
18 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
19 # ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
20 # ELF32-NEXT: filesz 0x00000001 memsz 0x00000001 flags ---
\r
21 # ELF32-NEXT: TLS off 0x00000322 vaddr 0x00004000 paddr 0x00004000 align 2**0
\r
22 # ELF32-NEXT: filesz 0x00000001 memsz 0x00000001 flags ---
\r
23 # ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
24 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
25 # ELF32-NEXT:EH_FRAME off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
26 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
27 # ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
28 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
29 # ELF32-NEXT: STACK off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
30 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
31 # ELF32-NEXT: RELRO off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
32 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
33 # ELF32-NEXT:PROPERTY off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
34 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
35 # ELF32-NEXT: OPENBSD_RANDOMIZE off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
36 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
37 # ELF32-NEXT: OPENBSD_WXNEEDED off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
38 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
39 # ELF32-NEXT: OPENBSD_BOOTDATA off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
40 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
41 # ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
42 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
43 # ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
44 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
45 # ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
46 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
47 # ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
48 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
49 # ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
50 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
51 # ELF32-NEXT: UNKNOWN off 0x00000314 vaddr 0x00001000 paddr 0x00001000 align 2**0
\r
52 # ELF32-NEXT: filesz 0x00000003 memsz 0x00000003 flags ---
\r
55 # RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_X86_64 %s -o %t64.elf
\r
56 # RUN: llvm-objdump --private-headers %t64.elf | FileCheck %s --check-prefixes=ELF64
\r
58 # ELF64: Program Header:
\r
59 # ELF64-NEXT: PHDR off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
60 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags -w-
\r
61 # ELF64-NEXT: PHDR off 0x000000000000054b vaddr 0x0000000000002000 paddr 0x0000000000002000 align 2**0
\r
62 # ELF64-NEXT: filesz 0x0000000000000007 memsz 0x0000000000000007 flags --x
\r
63 # ELF64-NEXT: UNKNOWN off 0x000000000000054b vaddr 0x0000000000002000 paddr 0x0000000000002000 align 2**0
\r
64 # ELF64-NEXT: filesz 0x0000000000000007 memsz 0x0000000000000007 flags --x
\r
65 # ELF64-NEXT: DYNAMIC off 0x0000000000000558 vaddr 0x0000000000006000 paddr 0x0000000000006000 align 2**0
\r
66 # ELF64-NEXT: filesz 0x0000000000000020 memsz 0x0000000000000020 flags rwx
\r
67 # ELF64-NEXT: INTERP off 0x0000000000000552 vaddr 0x0000000000003000 paddr 0x0000000000003000 align 2**0
\r
68 # ELF64-NEXT: filesz 0x0000000000000004 memsz 0x0000000000000004 flags rw-
\r
69 # ELF64-NEXT: NOTE off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
70 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
71 # ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
72 # ELF64-NEXT: filesz 0x0000000000000001 memsz 0x0000000000000001 flags ---
\r
73 # ELF64-NEXT: TLS off 0x0000000000000556 vaddr 0x0000000000004000 paddr 0x0000000000004000 align 2**0
\r
74 # ELF64-NEXT: filesz 0x0000000000000001 memsz 0x0000000000000001 flags ---
\r
75 # ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
76 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
77 # ELF64-NEXT:EH_FRAME off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
78 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
79 # ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
80 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
81 # ELF64-NEXT: STACK off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
82 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
83 # ELF64-NEXT: RELRO off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
84 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
85 # ELF64-NEXT: PROPERTY off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
86 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
87 # ELF64-NEXT: OPENBSD_RANDOMIZE off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
88 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
89 # ELF64-NEXT: OPENBSD_WXNEEDED off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
90 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
91 # ELF64-NEXT: OPENBSD_BOOTDATA off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
92 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
93 # ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
94 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
95 # ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
96 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
97 # ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
98 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
99 # ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
100 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
101 # ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
102 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
103 # ELF64-NEXT: UNKNOWN off 0x0000000000000548 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
\r
104 # ELF64-NEXT: filesz 0x0000000000000003 memsz 0x0000000000000003 flags ---
\r
109 Class: ELFCLASS[[BITS]]
\r
112 Machine: [[MACHINE]]
\r
116 Flags: [ SHF_ALLOC ]
\r
121 Flags: [ SHF_ALLOC ]
\r
125 Flags: [ SHF_ALLOC ]
\r
130 Flags: [ SHF_ALLOC ]
\r
134 Flags: [ SHF_ALLOC ]
\r
136 Content: "41424300" ## "ABC"
\r
139 Flags: [ SHF_ALLOC, SHF_TLS ]
\r
144 Flags: [ SHF_ALLOC, SHF_TLS ]
\r
149 Flags: [ SHF_ALLOC ]
\r
157 ## Case 1: an arbitrary segment with sections.
\r
161 FirstSec: .foo.begin
\r
163 ## Case 2: another segment with different sections.
\r
167 FirstSec: .bar.begin
\r
169 ## Case 3: the PT_NULL segment.
\r
173 FirstSec: .bar.begin
\r
175 ## Case 4: the PT_DYNAMIC segment.
\r
177 Flags: [ PF_R, PF_W, PF_X ]
\r
181 ## Case 5: the PT_INTERP segment.
\r
183 Flags: [ PF_R, PF_W ]
\r
187 ## Case 6: the PT_NOTE segment.
\r
190 FirstSec: .foo.begin
\r
192 ## Case 7: the PT_SHLIB segment.
\r
195 FirstSec: .foo.begin
\r
196 LastSec: .foo.begin
\r
197 ## Case 8: the PT_TLS segment.
\r
202 ## Case 9: the PT_LOOS segment.
\r
203 - Type: 0x60000000 ## PT_LOOS
\r
205 FirstSec: .foo.begin
\r
207 ## Case 10: the PT_GNU_EH_FRAME segment.
\r
208 - Type: PT_GNU_EH_FRAME
\r
210 FirstSec: .foo.begin
\r
212 ## Case 11: the PT_SUNW_UNWIND segment.
\r
213 - Type: 0x6464e550 ## PT_SUNW_UNWIND
\r
215 FirstSec: .foo.begin
\r
217 ## Case 12: the PT_GNU_STACK segment.
\r
218 - Type: PT_GNU_STACK
\r
220 FirstSec: .foo.begin
\r
222 ## Case 13: the PT_GNU_RELRO segment.
\r
223 - Type: PT_GNU_RELRO
\r
225 FirstSec: .foo.begin
\r
227 ## Case 14: the PT_GNU_PROPERTY segment.
\r
228 - Type: PT_GNU_PROPERTY
\r
230 FirstSec: .foo.begin
\r
232 ## Case 15: the PT_OPENBSD_RANDOMIZE segment.
\r
233 - Type: 0x65a3dbe6 ## PT_OPENBSD_RANDOMIZE
\r
235 FirstSec: .foo.begin
\r
237 ## Case 16: the PT_OPENBSD_WXNEEDED segment.
\r
238 - Type: 0x65a3dbe7 ## PT_OPENBSD_WXNEEDED
\r
240 FirstSec: .foo.begin
\r
242 ## Case 17: the PT_OPENBSD_BOOTDATA segment.
\r
243 - Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA
\r
245 FirstSec: .foo.begin
\r
247 ## Case 18: the PT_HIOS segment.
\r
248 - Type: 0x6fffffff ## PT_HIOS
\r
250 FirstSec: .foo.begin
\r
252 ## Case 19: the PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO segment.
\r
253 - Type: 0x70000000 ## PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO
\r
255 FirstSec: .foo.begin
\r
257 ## Case 20: the PT_ARM_EXIDX/PT_MIPS_RTPROC segment.
\r
258 - Type: 0x70000001 ## PT_ARM_EXIDX, PT_MIPS_RTPROC
\r
260 FirstSec: .foo.begin
\r
262 ## Case 20: the PT_MIPS_OPTIONS segment.
\r
263 - Type: 0x70000002 ## PT_MIPS_OPTIONS
\r
265 FirstSec: .foo.begin
\r
267 ## Case 21: the PT_MIPS_ABIFLAGS segment.
\r
268 - Type: 0x70000003 ## PT_MIPS_ABIFLAGS
\r
270 FirstSec: .foo.begin
\r
272 ## Case 22: the PT_HIPROC segment.
\r
273 - Type: 0x7fffffff ## PT_HIPROC
\r
275 FirstSec: .foo.begin
\r
278 ## Check we report an error / warning when we are unable to read program headers.
\r
279 ## Case A: the e_phentsize field is invalid.
\r
280 # RUN: yaml2obj --docnum=2 -DPHENTSIZE=1 %s -o %t.phdr.err
\r
281 # RUN: not llvm-objdump --private-headers %t.phdr.err 2>&1 | \
\r
282 # RUN: FileCheck %s -DFILE=%t.phdr.err --check-prefix=PHENTSIZE
\r
284 # PHENTSIZE: Program Header:
\r
285 # PHENTSIZE-NEXT: warning: '[[FILE]]': unable to read program headers: invalid e_phentsize: 1
\r
286 # PHENTSIZE-NEXT: error: '[[FILE]]': invalid e_phentsize: 1
\r
293 EPhEntSize: [[PHENTSIZE=<none>]]
\r
294 EPhOff: [[PHOFF=<none>]]
\r
303 ## Case B: the value of the e_phoff field is invalid.
\r
305 ## Check that we do not report a warning when the program header table ends right before the end of the file.
\r
306 ## 0x160 + size of headers (56) == file size.
\r
307 # RUN: yaml2obj --docnum=2 -DPHOFF=0x160 %s -o %t.phdr.no.err2
\r
308 # RUN: llvm-objdump %t.phdr.no.err2 --private-headers 2>&1 | FileCheck %s --implicit-check-not=warning:
\r
310 ## Check we report a warning / error when e_phoff goes 1 byte past the end of the file.
\r
311 # RUN: yaml2obj --docnum=2 -DPHOFF=0x161 %s -o %t.phdr.err2
\r
312 # RUN: not llvm-objdump --private-headers %t.phdr.err2 2>&1 | \
\r
313 # RUN: FileCheck %s -DFILE=%t.phdr.err2 --check-prefix=PHOFF -DOFF=0x161
\r
315 # PHOFF: Program Header:
\r
316 # PHOFF-NEXT: warning: '[[FILE]]': unable to read program headers: program headers are longer than binary of size 408: e_phoff = [[OFF]], e_phnum = 1, e_phentsize = 56
\r
317 # PHOFF-NEXT: error: '[[FILE]]': program headers are longer than binary of size 408: e_phoff = [[OFF]], e_phnum = 1, e_phentsize = 56
\r
320 ## Check we report a warning / error when the value of e_phoff is so large that
\r
321 ## e_phoff + e_phnum * e_phentsize > UINT64_MAX.
\r
322 # RUN: yaml2obj --docnum=2 -DPHOFF=0xffffffffffffffff %s -o %t.phdr.err3
\r
323 # RUN: not llvm-objdump --private-headers %t.phdr.err3 2>&1 | \
\r
324 # RUN: FileCheck %s -DFILE=%t.phdr.err3 --check-prefix=PHOFF -DOFF=0xffffffffffffffff
\r