[PATCH] D55298: [llvm-readelf] Add -e/--headers support to readobj/elf
Sid Manning via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 4 14:53:47 PST 2018
sidneym created this revision.
sidneym added reviewers: rupprecht, phosek, mcgrathr, jhenderson.
Several new options have been recently added to align with GNU. This patch adds -e/--headers.
Repository:
rL LLVM
https://reviews.llvm.org/D55298
Files:
test/tools/llvm-readobj/justheader.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>
+ JustHeaders("headers",
+ cl::desc("Equivalent to setting: --file-headers, --program-headers, "
+ "--section-headers"));
+ cl::alias JustHeadersShort("e", cl::desc("Alias for --headers"),
+ cl::aliasopt(JustHeaders));
+
// -wide, -W
cl::opt<bool>
WideOutput("wide", cl::desc("Ignored for compatibility with GNU readelf"),
@@ -666,6 +674,12 @@
opts::HashHistogram = true;
}
+ if (opts::JustHeaders) {
+ 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/justheader.test
===================================================================
--- /dev/null
+++ test/tools/llvm-readobj/justheader.test
@@ -0,0 +1,11 @@
+RUN: llvm-readelf -e %p/Inputs/trivial.obj.elf-i386 \
+RUN: | FileCheck %s
+RUN: llvm-readelf --headers %p/Inputs/trivial.obj.elf-i386 \
+RUN: | FileCheck %s
+
+CHECK: ELF Header:
+CHECK: Section Headers:
+CHECK: Program Headers:
+CHECK-NOT: Relocation section
+CHECK-NOT: Symbol table
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55298.176715.patch
Type: text/x-patch
Size: 1578 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181204/0b5a944b/attachment.bin>
More information about the llvm-commits
mailing list