[PATCH] D56588: [llvm-objdump] - Change the output for --all-headers.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 11 04:15:13 PST 2019
grimar created this revision.
grimar added reviewers: jhenderson, echristo, dblaikie.
Herald added a subscriber: rupprecht.
This is for https://bugs.llvm.org/show_bug.cgi?id=40008,
it starts printing the file headers when --all-headers is given and
do a few cosmetic changes.
https://reviews.llvm.org/D56588
Files:
test/tools/llvm-objdump/all-headers.test
tools/llvm-objdump/llvm-objdump.cpp
Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp
+++ tools/llvm-objdump/llvm-objdump.cpp
@@ -2301,8 +2301,7 @@
StringRef Fmt = o->getBytesInAddress() > 4 ? "%016" PRIx64 : "%08" PRIx64;
uint64_t Address = StartAddrOrErr.get();
outs() << "start address: "
- << "0x" << format(Fmt.data(), Address)
- << "\n";
+ << "0x" << format(Fmt.data(), Address) << "\n\n";
}
static void printArchiveChild(StringRef Filename, const Archive::Child &C) {
@@ -2382,6 +2381,8 @@
outs() << ":\tfile format " << o->getFileFormatName() << "\n\n";
}
+ if (FileHeaders)
+ printFileHeaders(o);
if (ArchiveHeaders && !MachOOpt && c)
printArchiveChild(ArchiveName, *c);
if (Disassemble)
@@ -2400,8 +2401,6 @@
PrintUnwindInfo(o);
if (PrivateHeaders || FirstPrivateHeader)
printPrivateFileHeaders(o, FirstPrivateHeader);
- if (FileHeaders)
- printFileHeaders(o);
if (ExportsTrie)
printExportsTrie(o);
if (Rebase)
@@ -2510,7 +2509,8 @@
InputFilenames.push_back("a.out");
if (AllHeaders)
- PrivateHeaders = Relocations = SectionHeaders = SymbolTable = true;
+ FileHeaders = PrivateHeaders = Relocations = SectionHeaders = SymbolTable =
+ true;
if (DisassembleAll || PrintSource || PrintLines)
Disassemble = true;
Index: test/tools/llvm-objdump/all-headers.test
===================================================================
--- /dev/null
+++ test/tools/llvm-objdump/all-headers.test
@@ -0,0 +1,20 @@
+# RUN: yaml2obj %s > %t
+# RUN: llvm-objdump --all-headers %t | FileCheck %s
+
+## Check we print file format, architecture and start address before
+## anything else when using --all-headers.
+
+# CHECK: file format ELF64-x86-64
+# CHECK-EMPTY:
+# CHECK-NEXT: architecture: x86_64
+# CHECK-NEXT: start address: 0x0000000000000000
+# CHECK-EMPTY:
+# CHECK-NEXT: Sections:
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56588.181242.patch
Type: text/x-patch
Size: 2134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190111/3a3d7c57/attachment.bin>
More information about the llvm-commits
mailing list