hex-dump.test
2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Test that the -x alias can be used flexibly. Create a baseline and ensure
## all other combinations are identical.
# RUN: yaml2obj %s -o %t
# RUN: llvm-readelf --file-header --hex-dump=.shstrtab %t > %t.hexdump.out
# RUN: llvm-readelf -h --hex-dump .shstrtab %t > %t.hexdump.1
# RUN: llvm-readelf -h -x .shstrtab %t > %t.hexdump.2
# RUN: llvm-readelf -h -x=.shstrtab %t > %t.hexdump.3
# RUN: llvm-readelf -h -x.shstrtab %t > %t.hexdump.4
# RUN: llvm-readelf -hx .shstrtab %t > %t.hexdump.5
# RUN: llvm-readelf -hx=.shstrtab %t > %t.hexdump.6
# RUN: llvm-readelf -hx.shstrtab %t > %t.hexdump.7
# RUN: cmp %t.hexdump.out %t.hexdump.1
# RUN: cmp %t.hexdump.out %t.hexdump.2
# RUN: cmp %t.hexdump.out %t.hexdump.3
# RUN: cmp %t.hexdump.out %t.hexdump.4
# RUN: cmp %t.hexdump.out %t.hexdump.5
# RUN: cmp %t.hexdump.out %t.hexdump.6
# RUN: cmp %t.hexdump.out %t.hexdump.7
## A sanity check to verify that the .shstrtab section has index 2.
# RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=ELF-SEC
# ELF-SEC: [ 2] .shstrtab
## Test we dump the section only once when the option is specified multiple times for the same section.
# RUN: llvm-readobj -x 2 -x 2 -x .shstrtab -x .shstrtab %t 2>&1 \
# RUN: | FileCheck %s --check-prefix=ELF
## Test warnings reported when an unknown section name and index are specified.
# RUN: llvm-readobj -x 2 -x .shstrtab -x 3 -x not_exist %t 2>&1 \
# RUN: | FileCheck %s -DFILE=%t --check-prefixes=ELF-WARN,ELF
# ELF-WARN: warning: '[[FILE]]': could not find section 'not_exist'
# ELF-WARN: warning: '[[FILE]]': could not find section 3
# ELF: Hex dump of section '.shstrtab':
# ELF-NEXT: 0x00000000 002e7368 73747274 6162002e 73747274 ..shstrtab..strt
# ELF-NEXT: 0x00000010 616200 ab.
# ELF-NOT: {{.}}
## This test shows that we include the tool name in an error/warning message.
# RUN: llvm-readelf -x 10 %t 2>&1 | FileCheck --check-prefix=WARN %s -DTOOL=readelf
# RUN: llvm-readobj -x 10 %t 2>&1 | FileCheck --check-prefix=WARN %s -DTOOL=readobj
# WARN: llvm-[[TOOL]]{{(\.exe)?}}: warning: '{{.*}}': could not find section 10
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386