blob: b1f54009110e2258aab5b78746ac4183fa03fc60 [file] [log] [blame]
## 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