diff --git a/llvm/test/tools/llvm-readobj/hexdump.test b/llvm/test/tools/llvm-readobj/hexdump.test --- a/llvm/test/tools/llvm-readobj/hexdump.test +++ b/llvm/test/tools/llvm-readobj/hexdump.test @@ -3,3 +3,30 @@ CHECK: Hex dump of section '.text': CHECK-NEXT: {{^}}0x00400460 + +// Test that the -j 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/../../Object/Inputs/hello-world.elf-x86-64 > %t.hexdump.out +RUN: llvm-readelf -h --hex-dump .text \ +RUN: %p/../../Object/Inputs/hello-world.elf-x86-64 > %t.hexdump.1 +RUN: llvm-readelf -h -x .text \ +RUN: %p/../../Object/Inputs/hello-world.elf-x86-64 > %t.hexdump.2 +RUN: llvm-readelf -h -x=.text \ +RUN: %p/../../Object/Inputs/hello-world.elf-x86-64 > %t.hexdump.3 +RUN: llvm-readelf -h -x.text \ +RUN: %p/../../Object/Inputs/hello-world.elf-x86-64 > %t.hexdump.4 +RUN: llvm-readelf -hx .text \ +RUN: %p/../../Object/Inputs/hello-world.elf-x86-64 > %t.hexdump.5 +RUN: llvm-readelf -hx=.text \ +RUN: %p/../../Object/Inputs/hello-world.elf-x86-64 > %t.hexdump.6 +RUN: llvm-readelf -hx.text \ +RUN: %p/../../Object/Inputs/hello-world.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 diff --git a/llvm/test/tools/llvm-readobj/string-dump.test b/llvm/test/tools/llvm-readobj/string-dump.test --- a/llvm/test/tools/llvm-readobj/string-dump.test +++ b/llvm/test/tools/llvm-readobj/string-dump.test @@ -1,13 +1,41 @@ # Check the dumping of a section as strings. # RUN: yaml2obj %s > %t -# RUN: llvm-readobj --string-dump=.strings --string-dump=.not_null_terminated %t | FileCheck %s -# RUN: llvm-readobj -p=.strings -p=.not_null_terminated %t | FileCheck %s -# RUN: llvm-readobj --string-dump=1 --string-dump=2 %t | FileCheck %s +# RUN: llvm-readobj --string-dump=.strings \ +# RUN: --string-dump=.not_null_terminated %t > %t.readobj.out +# RUN: FileCheck %s --input-file=%t.readobj.out -# RUN: llvm-readelf --string-dump=.strings --string-dump=.not_null_terminated %t | FileCheck %s -# RUN: llvm-readelf -p=.strings -p=.not_null_terminated %t | FileCheck %s -# RUN: llvm-readelf --string-dump=1 --string-dump=2 %t | FileCheck %s +# RUN: llvm-readobj -p=.strings -p=.not_null_terminated %t > %t.readobj.1 +# RUN: llvm-readobj -p.strings -p.not_null_terminated %t > %t.readobj.2 +# RUN: llvm-readobj --string-dump=1 --string-dump=2 %t > %t.readobj.3 +# RUN: llvm-readobj -p1 -p2 %t > %t.readobj.4 +# RUN: llvm-readobj -p=1 -p=2 %t > %t.readobj.5 + +# RUN: cmp %t.readobj.out %t.readobj.1 +# RUN: cmp %t.readobj.out %t.readobj.2 +# RUN: cmp %t.readobj.out %t.readobj.3 +# RUN: cmp %t.readobj.out %t.readobj.4 +# RUN: cmp %t.readobj.out %t.readobj.5 + +# Run readelf tests with --file-header as well so we can group -p with +# something. +# RUN: llvm-readelf --file-header --string-dump=.strings \ +# RUN: --string-dump=.not_null_terminated %t > %t.readelf.out +# RUN: FileCheck %s --input-file=%t.readelf.out + +# RUN: llvm-readelf -h -p=.strings -p=.not_null_terminated %t > %t.readelf.1 +# RUN: llvm-readelf -p.strings -hp.not_null_terminated %t > %t.readelf.2 +# RUN: llvm-readelf -h --string-dump=1 --string-dump=2 %t > %t.readelf.3 +# RUN: llvm-readelf -hp1 -p2 %t > %t.readelf.4 +# RUN: llvm-readelf -hp 1 -p.not_null_terminated %t > %t.readelf.5 +# RUN: llvm-readelf -p=1 -hp=2 %t > %t.readelf.6 + +# RUN: cmp %t.readelf.out %t.readelf.1 +# RUN: cmp %t.readelf.out %t.readelf.2 +# RUN: cmp %t.readelf.out %t.readelf.3 +# RUN: cmp %t.readelf.out %t.readelf.4 +# RUN: cmp %t.readelf.out %t.readelf.5 +# RUN: cmp %t.readelf.out %t.readelf.6 # CHECK: String dump of section '.strings': # CHECK-NEXT: [ 0] here diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp --- a/llvm/tools/llvm-readobj/llvm-readobj.cpp +++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -180,13 +180,13 @@ cl::list StringDump("string-dump", cl::desc(""), cl::ZeroOrMore); cl::alias StringDumpShort("p", cl::desc("Alias for --string-dump"), - cl::aliasopt(StringDump)); + cl::aliasopt(StringDump), cl::Prefix); // -hex-dump, -x cl::list HexDump("hex-dump", cl::desc(""), cl::ZeroOrMore); cl::alias HexDumpShort("x", cl::desc("Alias for --hex-dump"), - cl::aliasopt(HexDump)); + cl::aliasopt(HexDump), cl::Prefix); // -demangle, -C cl::opt Demangle("demangle",