From 0ca250853c5a3ea73295cf7b4caba2f9dceb9b98 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Tue, 1 Sep 2015 16:29:02 +0000 Subject: [PATCH] [llvm-readobj] MachO -- correctly dump section field 'Reserved3' Before we incorrectly ignored it. llvm-svn: 246556 --- llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s | 1 + llvm/test/tools/llvm-readobj/sections-ext.test | 7 +++++++ llvm/test/tools/llvm-readobj/sections.test | 7 +++++++ llvm/tools/llvm-readobj/MachODumper.cpp | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s b/llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s index a0703f6360db..2ff7fe82e9be 100644 --- a/llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s +++ b/llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s @@ -22,6 +22,7 @@ // CHECK-NEXT: ] // CHECK-NEXT: Reserved1: // CHECK-NEXT: Reserved2: +// CHECK-NEXT: Reserved3: // CHECK-NEXT: Relocations [ // CHECK-NEXT: Relocation { // CHECK-NEXT: Offset: 0x60 diff --git a/llvm/test/tools/llvm-readobj/sections-ext.test b/llvm/test/tools/llvm-readobj/sections-ext.test index 19b7aa0516d1..70ae0f22a0e4 100644 --- a/llvm/test/tools/llvm-readobj/sections-ext.test +++ b/llvm/test/tools/llvm-readobj/sections-ext.test @@ -223,6 +223,7 @@ MACHO-X86-64-NEXT: SomeInstructions (0x4) MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Reserved1: 0x0 MACHO-X86-64-NEXT: Reserved2: 0x0 +MACHO-X86-64-NEXT: Reserved3: 0x0 MACHO-X86-64-NEXT: Relocations [ MACHO-X86-64-NEXT: 0xE 1 2 1 X86_64_RELOC_BRANCH 0 _SomeOtherFunction MACHO-X86-64-NEXT: 0x9 1 2 1 X86_64_RELOC_BRANCH 0 _puts @@ -260,6 +261,7 @@ MACHO-X86-64-NEXT: Attributes [ (0x0) MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Reserved1: 0x0 MACHO-X86-64-NEXT: Reserved2: 0x0 +MACHO-X86-64-NEXT: Reserved3: 0x0 MACHO-X86-64-NEXT: Relocations [ MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Symbols [ @@ -514,6 +516,7 @@ MACHO-PPC64-NEXT: SomeInstructions (0x4) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: Relocation { MACHO-PPC64-NEXT: Offset: 0x24 @@ -587,6 +590,7 @@ MACHO-PPC64-NEXT: SomeInstructions (0x4) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x20 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: Relocation { MACHO-PPC64-NEXT: Offset: 0x14 @@ -639,6 +643,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Symbols [ @@ -672,6 +677,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x1 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Symbols [ @@ -695,6 +701,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x2 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: Relocations [ MACHO-PPC64-NEXT: Relocation { MACHO-PPC64-NEXT: Offset: 0x0 diff --git a/llvm/test/tools/llvm-readobj/sections.test b/llvm/test/tools/llvm-readobj/sections.test index fe734d77e34b..54654e7070ef 100644 --- a/llvm/test/tools/llvm-readobj/sections.test +++ b/llvm/test/tools/llvm-readobj/sections.test @@ -172,6 +172,7 @@ MACHO-X86-64-NEXT: SomeInstructions (0x4) MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Reserved1: 0x0 MACHO-X86-64-NEXT: Reserved2: 0x0 +MACHO-X86-64-NEXT: Reserved3: 0x0 MACHO-X86-64-NEXT: } MACHO-X86-64-NEXT: Section { MACHO-X86-64-NEXT: Index: 1 @@ -188,6 +189,7 @@ MACHO-X86-64-NEXT: Attributes [ (0x0) MACHO-X86-64-NEXT: ] MACHO-X86-64-NEXT: Reserved1: 0x0 MACHO-X86-64-NEXT: Reserved2: 0x0 +MACHO-X86-64-NEXT: Reserved3: 0x0 MACHO-X86-64-NEXT: } MACHO-X86-64-NEXT:] @@ -296,6 +298,7 @@ MACHO-PPC64-NEXT: SomeInstructions (0x4) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: Section { MACHO-PPC64-NEXT: Index: 1 @@ -314,6 +317,7 @@ MACHO-PPC64-NEXT: SomeInstructions (0x4) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x20 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: Section { MACHO-PPC64-NEXT: Index: 2 @@ -330,6 +334,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x0 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: Section { MACHO-PPC64-NEXT: Index: 3 @@ -346,6 +351,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x1 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: Section { MACHO-PPC64-NEXT: Index: 4 @@ -362,6 +368,7 @@ MACHO-PPC64-NEXT: Attributes [ (0x0) MACHO-PPC64-NEXT: ] MACHO-PPC64-NEXT: Reserved1: 0x2 MACHO-PPC64-NEXT: Reserved2: 0x0 +MACHO-PPC64-NEXT: Reserved3: 0x0 MACHO-PPC64-NEXT: } MACHO-PPC64-NEXT: ] diff --git a/llvm/tools/llvm-readobj/MachODumper.cpp b/llvm/tools/llvm-readobj/MachODumper.cpp index e7cda4d84d48..7b99a1ac90ee 100644 --- a/llvm/tools/llvm-readobj/MachODumper.cpp +++ b/llvm/tools/llvm-readobj/MachODumper.cpp @@ -260,6 +260,7 @@ namespace { uint32_t Flags; uint32_t Reserved1; uint32_t Reserved2; + uint32_t Reserved3; }; struct MachOSymbol { @@ -297,6 +298,7 @@ static void getSection(const MachOObjectFile *Obj, Section.Flags = Sect.flags; Section.Reserved1 = Sect.reserved1; Section.Reserved2 = Sect.reserved2; + Section.Reserved3 = Sect.reserved3; } @@ -402,6 +404,8 @@ void MachODumper::printSections(const MachOObjectFile *Obj) { makeArrayRef(MachOSectionAttributes)); W.printHex("Reserved1", MOSection.Reserved1); W.printHex("Reserved2", MOSection.Reserved2); + if (Obj->is64Bit()) + W.printHex("Reserved3", MOSection.Reserved3); if (opts::SectionRelocations) { ListScope D(W, "Relocations");