1## Test that the -x alias can be used flexibly. Create a baseline and ensure 2## all other combinations are identical. 3# RUN: yaml2obj --docnum=1 %s -o %t 4# RUN: llvm-readelf --file-header --hex-dump=.shstrtab %t > %t.hexdump.out 5# RUN: llvm-readelf -h --hex-dump .shstrtab %t > %t.hexdump.1 6# RUN: llvm-readelf -h -x .shstrtab %t > %t.hexdump.2 7# RUN: llvm-readelf -h -x=.shstrtab %t > %t.hexdump.3 8# RUN: llvm-readelf -h -x.shstrtab %t > %t.hexdump.4 9# RUN: llvm-readelf -hx .shstrtab %t > %t.hexdump.5 10# RUN: llvm-readelf -hx=.shstrtab %t > %t.hexdump.6 11# RUN: llvm-readelf -hx.shstrtab %t > %t.hexdump.7 12 13# RUN: cmp %t.hexdump.out %t.hexdump.1 14# RUN: cmp %t.hexdump.out %t.hexdump.2 15# RUN: cmp %t.hexdump.out %t.hexdump.3 16# RUN: cmp %t.hexdump.out %t.hexdump.4 17# RUN: cmp %t.hexdump.out %t.hexdump.5 18# RUN: cmp %t.hexdump.out %t.hexdump.6 19# RUN: cmp %t.hexdump.out %t.hexdump.7 20 21## A sanity check to verify that the .shstrtab section has index 2. 22# RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=ELF-SEC 23# ELF-SEC: [ 2] .shstrtab 24 25## Test we dump the section only once when the option is specified multiple times for the same section. 26# RUN: llvm-readobj -x 2 -x 2 -x .shstrtab -x .shstrtab %t 2>&1 \ 27# RUN: | FileCheck %s --check-prefix=ELF 28## Test warnings reported when an unknown section name and index are specified. 29# RUN: llvm-readobj -x 2 -x .shstrtab -x 3 -x not_exist %t 2>&1 \ 30# RUN: | FileCheck %s -DFILE=%t --check-prefixes=ELF-WARN,ELF 31 32# ELF-WARN: warning: '[[FILE]]': could not find section 'not_exist' 33# ELF-WARN: warning: '[[FILE]]': could not find section 3 34# ELF: Hex dump of section '.shstrtab': 35# ELF-NEXT: 0x00000000 002e7368 73747274 6162002e 73747274 ..shstrtab..strt 36# ELF-NEXT: 0x00000010 616200 ab. 37# ELF-NOT: {{.}} 38 39## This test shows that we include the tool name in an error/warning message. 40# RUN: llvm-readelf -x 10 %t 2>&1 | FileCheck --check-prefix=WARN %s -DTOOL=readelf 41# RUN: llvm-readobj -x 10 %t 2>&1 | FileCheck --check-prefix=WARN %s -DTOOL=readobj 42 43# WARN: llvm-[[TOOL]]{{(\.exe)?}}: warning: '{{.*}}': could not find section 10 44 45--- !ELF 46FileHeader: 47 Class: ELFCLASS32 48 Data: ELFDATA2LSB 49 Type: ET_DYN 50 51## Test that llvm-readelf emits the correct number of spaces between the hex data 52## and its ascii representation. 53 54## a) When the hex data doesn't fill a column other than the last one. 55# RUN: yaml2obj --docnum=2 -DSIZE=18 %s -o %t2.out1 56# RUN: llvm-readelf --hex-dump=.sec %t2.out1 | \ 57# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SPACES1 58 59# SPACES1:Hex dump of section '.sec': 60# SPACES1-NEXT:0x00000000 00000000 00000000 00000000 00000000 ................ 61# SPACES1-NEXT:0x00000010 0000 .. 62 63## b) When the hex data doesn't fill the last column. 64# RUN: yaml2obj --docnum=2 -DSIZE=30 %s -o %t2.out2 65# RUN: llvm-readelf --hex-dump=.sec %t2.out2 | \ 66# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SPACES2 67 68# SPACES2:Hex dump of section '.sec': 69# SPACES2-NEXT:0x00000000 00000000 00000000 00000000 00000000 ................ 70# SPACES2-NEXT:0x00000010 00000000 00000000 00000000 0000 .............. 71 72## c) When the hex data fills a column. 73# RUN: yaml2obj --docnum=2 -DSIZE=28 %s -o %t2.out3 74# RUN: llvm-readelf --hex-dump=.sec %t2.out3 | \ 75# RUN: FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SPACES3 76 77# SPACES3:Hex dump of section '.sec': 78# SPACES3-NEXT:0x00000000 00000000 00000000 00000000 00000000 ................ 79# SPACES3-NEXT:0x00000010 00000000 00000000 00000000 ............ 80 81--- !ELF 82FileHeader: 83 Class: ELFCLASS32 84 Data: ELFDATA2LSB 85 Type: ET_DYN 86Sections: 87 - Name: .sec 88 Type: SHT_PROGBITS 89 Size: [[SIZE]] 90