[llvm-objdump] Fix llvm-objdump --all-headers output order
authorGeorge Rimar <grimar@accesssoftek.com>
Fri, 13 Sep 2019 08:56:28 +0000 (08:56 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Fri, 13 Sep 2019 08:56:28 +0000 (08:56 +0000)
Patch by Justice Adams!

Made llvm-objdump --all-headers output match the order of GNU objdump for compatibility reasons.

Old order of the headers output:
* file header
* section header table
* symbol table
* program header table
* dynamic section

New order of the headers output (GNU compatible):
* file header information
* program header table
* dynamic section
* section header table
* symbol table

(Relevant BugZilla Bug: https://bugs.llvm.org/show_bug.cgi?id=41830)

Differential revision: https://reviews.llvm.org/D67357

llvm-svn: 371826

llvm/test/tools/llvm-objdump/all-headers.test
llvm/tools/llvm-objdump/llvm-objdump.cpp

index 2cb239b..ea45ecc 100644 (file)
@@ -9,10 +9,10 @@
 # CHECK-NEXT:  architecture: x86_64
 # CHECK-NEXT:  start address: 0x0000000000000000
 # CHECK-EMPTY:
-# CHECK-NEXT:  Sections:
-# CHECK: SYMBOL TABLE:
-# CHECK: Program Header:
+# CHECK-NEXT: Program Header:
 # CHECK: Dynamic Section:
+# CHECK: Sections:
+# CHECK: SYMBOL TABLE:
 
 ## Check how we dump the archives.
 ## Check we dump the appropriate headers for each file in the archive.
 # ARCHIVE: architecture: x86_64
 # ARCHIVE: start address: 0x0000000000000000
 # ARCHIVE: rw-r--r--
-# ARCHIVE: Sections:
-# ARCHIVE: SYMBOL TABLE:
 # ARCHIVE: Program Header:
 # ARCHIVE: Dynamic Section:
+# ARCHIVE: Sections:
+# ARCHIVE: SYMBOL TABLE:
 # ARCHIVE: {{.*}}.a({{.*}}2):   file format ELF64-x86-64
 # ARCHIVE: architecture: x86_64
 # ARCHIVE: start address: 0x0000000000000000
 # ARCHIVE: rw-r--r--
-# ARCHIVE: Sections:
-# ARCHIVE: SYMBOL TABLE:
 # ARCHIVE: Program Header:
 # ARCHIVE: Dynamic Section:
+# ARCHIVE: Sections:
+# ARCHIVE: SYMBOL TABLE:
 
 !ELF
 FileHeader:
index e066365..f50d344 100644 (file)
@@ -2087,6 +2087,8 @@ static void dumpObject(ObjectFile *O, const Archive *A = nullptr,
     printRelocations(O);
   if (DynamicRelocations)
     printDynamicRelocations(O);
+  if (PrivateHeaders || FirstPrivateHeader)
+    printPrivateFileHeaders(O, FirstPrivateHeader);
   if (SectionHeaders)
     printSectionHeaders(O);
   if (SectionContents)
@@ -2095,8 +2097,6 @@ static void dumpObject(ObjectFile *O, const Archive *A = nullptr,
     printSymbolTable(O, ArchiveName);
   if (UnwindInfo)
     printUnwindInfo(O);
-  if (PrivateHeaders || FirstPrivateHeader)
-    printPrivateFileHeaders(O, FirstPrivateHeader);
   if (ExportsTrie)
     printExportsTrie(O);
   if (Rebase)