From b9d63e10b9cfc78f5248a47fed51035c6b320c5c Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 29 Aug 2022 12:39:50 -0400 Subject: [PATCH] [llvm-otool] Print dyld_info output before chained_fixup output This matches otool. Differential Revision: https://reviews.llvm.org/D132865 --- llvm/test/tools/llvm-objdump/MachO/dyld-info.test | 11 ++++++++++- llvm/tools/llvm-objdump/MachODump.cpp | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/llvm/test/tools/llvm-objdump/MachO/dyld-info.test b/llvm/test/tools/llvm-objdump/MachO/dyld-info.test index 20a08b9..a3c11e6 100644 --- a/llvm/test/tools/llvm-objdump/MachO/dyld-info.test +++ b/llvm/test/tools/llvm-objdump/MachO/dyld-info.test @@ -3,7 +3,6 @@ RUN: FileCheck -DNAME=%p/Inputs/chained-fixups.macho-x86_64 %s RUN: llvm-otool -dyld_info %p/Inputs/chained-fixups.macho-x86_64 | \ RUN: FileCheck -DNAME=%p/Inputs/chained-fixups.macho-x86_64 %s - ## See chained-fixups.test for how the test input was generated. CHECK: [[NAME]]: CHECK-NEXT: dyld information: @@ -16,7 +15,17 @@ CHECK-NEXT: __DATA __data 0x1410 0x8000000000000003 bind 0x0 weak CHECK-NEXT: __DATA __data 0x3410 0x8010000000000002 bind 0x0 libdylib _dylib CHECK-NEXT: __DATA __data 0x3418 0x800000002A000002 bind 0x2A libdylib _dylib + ## TODO: Print opcode-based fixups/binds as well ## For now, test that execution doesn't fail if the input uses those. RUN: llvm-objdump --macho --dyld-info %p/Inputs/bind.macho-x86_64 RUN: llvm-objdump --macho --dyld-info %p/Inputs/bind.macho-x86_64 + + +## If both -chained_fixups and -dyld_info are passed, otool prints dyld_info +## output first. Match that. +RUN: llvm-otool -chained_fixups -dyld_info \ +RUN: %p/Inputs/chained-fixups.macho-x86_64 | \ +RUN: FileCheck --check-prefix=BOTH %s +BOTH: dyld information: +BOTH: chained fixups header diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index c082038..1146d36 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -2182,10 +2182,10 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF, DumpSectionContents(FileName, MachOOF, Verbose); if (InfoPlist) DumpInfoPlistSectionContents(FileName, MachOOF); - if (ChainedFixups) - PrintChainedFixups(MachOOF); if (DyldInfo) PrintDyldInfo(MachOOF); + if (ChainedFixups) + PrintChainedFixups(MachOOF); if (DylibsUsed) PrintDylibs(MachOOF, false); if (DylibId) -- 2.7.4