llvm-project/llvm/test/tools/llvm-readobj/hex-dump.test

60 lines
2.8 KiB
Plaintext

## Test that the -x alias can be used flexibly. Create a baseline and ensure
## all other combinations are identical.
# RUN: llvm-readelf --file-header --hex-dump=.text \
# RUN: %p/Inputs/trivial.obj.elf-x86-64 > %t.hexdump.out
# RUN: llvm-readelf -h --hex-dump .text %p/Inputs/trivial.obj.elf-x86-64 > %t.hexdump.1
# RUN: llvm-readelf -h -x .text %p/Inputs/trivial.obj.elf-x86-64 > %t.hexdump.2
# RUN: llvm-readelf -h -x=.text %p/Inputs/trivial.obj.elf-x86-64 > %t.hexdump.3
# RUN: llvm-readelf -h -x.text %p/Inputs/trivial.obj.elf-x86-64 > %t.hexdump.4
# RUN: llvm-readelf -hx .text %p/Inputs/trivial.obj.elf-x86-64 > %t.hexdump.5
# RUN: llvm-readelf -hx=.text %p/Inputs/trivial.obj.elf-x86-64 > %t.hexdump.6
# RUN: llvm-readelf -hx.text %p/Inputs/trivial.obj.elf-x86-64 > %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
# RUN: llvm-readelf -S %p/Inputs/trivial.obj.elf-x86-64 | FileCheck %s --check-prefix=ELF-SEC
## Both 9 and .strtab refer to .strtab. Test we dump the section only once.
# RUN: llvm-readobj -x 9 -x 9 -x .strtab -x .strtab %p/Inputs/trivial.obj.elf-x86-64 2>&1 | \
# RUN: FileCheck %s --check-prefix=ELF
# RUN: llvm-readobj -x 9 -x .strtab -x 10 -x not_exist \
# RUN: %p/Inputs/trivial.obj.elf-x86-64 2>&1 | FileCheck %s --check-prefixes=ELF-WARN,ELF
# ELF-SEC: [ 9] .strtab
# ELF-WARN: warning: could not find section 'not_exist'
# ELF-WARN: warning: could not find section 10
# ELF: Hex dump of section '.strtab':
# ELF-NEXT: 0x00000000 00747269 7669616c 2e6c6c00 6d61696e .trivial.ll.main
# ELF-NEXT: 0x00000010 002e4c2e 73747200 70757473 00536f6d ..L.str.puts.Som
# ELF-NEXT: 0x00000020 654f7468 65724675 6e637469 6f6e005f eOtherFunction._
# ELF-NEXT: 0x00000030 474c4f42 414c5f4f 46465345 545f5441 GLOBAL_OFFSET_TA
# ELF-NEXT: 0x00000040 424c455f 00 BLE_.
# ELF-NOT: {{.}}
## Below we test -x can be used for other binary formats.
# RUN: llvm-readobj -x 1 %p/Inputs/trivial.obj.coff-x86-64 \
# RUN: | FileCheck %s --check-prefix COFF
# COFF: 0x00000000 4883ec28 488d0d00 000000e8 00000000 H..(H...........
# COFF: 0x00000010 e8000000 0031c048 83c428c3 .....1.H..(.
# RUN: llvm-readobj -x 1 %p/Inputs/trivial.obj.macho-x86-64 \
# RUN: | FileCheck %s --check-prefix MACHO
# MACHO: 0x00000000 50488d3d 00000000 e8000000 00e80000 PH.=............
# MACHO: 0x00000010 000031c0 5ac3 ..1.Z.
# RUN: llvm-readobj -x 1 %p/Inputs/trivial.obj.wasm \
# RUN: | FileCheck %s --check-prefix WASM
# WASM: 0x00000000 04600001 7f60017f 017f6000 0060017f .`...`....`..`..
# WASM: 0x00000010 00 .