[PATCH] D59618: [llvm-objdump] Support llvm-objdump -sj.foo

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 15:07:46 PDT 2019


rupprecht created this revision.
rupprecht added reviewers: ormris, jhenderson, ikudrin.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

r354375 added support for most objdump groupings, but didn't add support for -j|--sections, because that wasn't possible.
r355185 supported values for grouped options.

This just puts the two of them together. This supports -j in modes like `-s -j .foo`, `-sj .foo`, `-sj=.foo`, or `-sj.foo`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59618

Files:
  llvm/test/tools/llvm-objdump/section-filter.test
  llvm/tools/llvm-objdump/llvm-objdump.cpp


Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -197,7 +197,7 @@
 llvm::FilterSections("section", cl::desc("Operate on the specified sections only. "
                                          "With -macho dump segment,section"));
 cl::alias static FilterSectionsj("j", cl::desc("Alias for --section"),
-                                 cl::NotHidden,
+                                 cl::NotHidden, cl::Grouping, cl::Prefix,
                                  cl::aliasopt(llvm::FilterSections));
 
 cl::list<std::string>
Index: llvm/test/tools/llvm-objdump/section-filter.test
===================================================================
--- llvm/test/tools/llvm-objdump/section-filter.test
+++ llvm/test/tools/llvm-objdump/section-filter.test
@@ -1,7 +1,24 @@
-// This test checks that --section works correctly
+// This test checks that --section works correctly.
 // RUN: llvm-objdump -h %p/Inputs/section-filter.obj -j=.text \
 // RUN: --section=.bss | FileCheck %s
 
 # CHECK: .text
 # CHECK-NOT: .data
-# CHECK: .bss
\ No newline at end of file
+# CHECK: .bss
+
+// Test that the -j alias can be used flexibly. Create a baseline and ensure
+// all other combinations are identical.
+// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s --section .symtab > %t.full
+// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s -j .symtab > %t.1
+// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s -j=.symtab > %t.2
+// RUN: llvm-objdump %p/Inputs/section-filter.obj -h -s -j.symtab > %t.3
+// RUN: llvm-objdump %p/Inputs/section-filter.obj -hsj .symtab > %t.4
+// RUN: llvm-objdump %p/Inputs/section-filter.obj -hsj=.symtab > %t.5
+// RUN: llvm-objdump %p/Inputs/section-filter.obj -hsj.symtab > %t.6
+
+// RUN: cmp %t.full %t.1
+// RUN: cmp %t.full %t.2
+// RUN: cmp %t.full %t.3
+// RUN: cmp %t.full %t.4
+// RUN: cmp %t.full %t.5
+// RUN: cmp %t.full %t.6


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59618.191593.patch
Type: text/x-patch
Size: 2036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190320/db841911/attachment.bin>


More information about the llvm-commits mailing list