[PATCH] D55298: [llvm-readelf] Add -e/--headers support to readobj/elf

Sid Manning via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 7 09:24:24 PST 2018


sidneym updated this revision to Diff 177236.
sidneym added a comment.

Output each option test result to different files and verify that each of the files contains identical content.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55298/new/

https://reviews.llvm.org/D55298

Files:
  test/tools/llvm-readobj/headers.test
  tools/llvm-readobj/llvm-readobj.cpp


Index: tools/llvm-readobj/llvm-readobj.cpp
===================================================================
--- tools/llvm-readobj/llvm-readobj.cpp
+++ tools/llvm-readobj/llvm-readobj.cpp
@@ -57,6 +57,14 @@
                    "--section-groups and --elf-hash-histogram."));
   cl::alias AllShort("a", cl::desc("Alias for --all"), cl::aliasopt(All));
 
+  // --headers -e
+  cl::opt<bool>
+      Headers("headers",
+          cl::desc("Equivalent to setting: --file-headers, --program-headers, "
+                   "--section-headers"));
+  cl::alias HeadersShort("e", cl::desc("Alias for --headers"),
+     cl::aliasopt(Headers));
+
   // -wide, -W
   cl::opt<bool>
       WideOutput("wide", cl::desc("Ignored for compatibility with GNU readelf"),
@@ -666,6 +674,12 @@
     opts::HashHistogram = true;
   }
 
+  if (opts::Headers) {
+    opts::FileHeaders = true;
+    opts::ProgramHeaders = true;
+    opts::SectionHeaders = true;
+  }
+
   // Default to stdin if no filename is specified.
   if (opts::InputFilenames.size() == 0)
     opts::InputFilenames.push_back("-");
Index: test/tools/llvm-readobj/headers.test
===================================================================
--- /dev/null
+++ test/tools/llvm-readobj/headers.test
@@ -0,0 +1,5 @@
+RUN: llvm-readelf -e %p/Inputs/trivial.obj.elf-i386 > %t.e
+RUN: llvm-readelf --headers %p/Inputs/trivial.obj.elf-i386 > %t.headers
+RUN: llvm-readelf -h -l -S %p/Inputs/trivial.obj.elf-i386 > %t.hlS
+RUN: cmp %t.e %t.headers
+RUN: cmp %t.e %t.hlS


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55298.177236.patch
Type: text/x-patch
Size: 1511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181207/8b131bfa/attachment.bin>


More information about the llvm-commits mailing list