From dfd6ce5dd42b632ffe07c70b117268e94c5b2de7 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Thu, 30 Apr 2015 20:30:42 +0000 Subject: [PATCH] For llvm-objdump, with the -archive-headers and -macho options, use the -non-verbose option to print the archive headers using raw numeric values. Also add the -archive-member-offsets for use with these to also trigger printing of the offset of the archive member from the start of the archive. llvm-svn: 236252 --- .../X86/macho-archive-headers.test | 18 ++++++++++++++++++ tools/llvm-objdump/MachODump.cpp | 14 ++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/test/tools/llvm-objdump/X86/macho-archive-headers.test b/test/tools/llvm-objdump/X86/macho-archive-headers.test index 3d9043e671a..1253b46529b 100644 --- a/test/tools/llvm-objdump/X86/macho-archive-headers.test +++ b/test/tools/llvm-objdump/X86/macho-archive-headers.test @@ -1,5 +1,9 @@ RUN: llvm-objdump %p/Inputs/macho-universal-archive.x86_64.i386 -macho -archive-headers -arch all \ RUN: | FileCheck %s +RUN: llvm-objdump %p/Inputs/macho-universal-archive.x86_64.i386 -macho -archive-headers -arch all -archive-member-offsets \ +RUN: | FileCheck %s -check-prefix=OFFSETS +RUN: llvm-objdump %p/Inputs/macho-universal-archive.x86_64.i386 -macho -archive-headers -arch all -non-verbose \ +RUN: | FileCheck %s -check-prefix=NON-VERBOSE # Note the date as printed by ctime(3) is time zone dependent and not checked. CHECK: Archive : {{.*}}/macho-universal-archive.x86_64.i386 (architecture x86_64) @@ -8,3 +12,17 @@ CHECK: -rw-r--r--124/0 860 {{.*}} hello.o CHECK: Archive : {{.*}}/macho-universal-archive.x86_64.i386 (architecture i386) CHECK: -rw-r--r--124/11 60 {{.*}} __.SYMDEF SORTED CHECK: -rw-r--r--124/0 388 {{.*}} foo.o + +OFFSETS: Archive : {{.*}}/macho-universal-archive.x86_64.i386 (architecture x86_64) +OFFSETS: 8 -rw-r--r--124/11 44 {{.*}} __.SYMDEF SORTED +OFFSETS: 112 -rw-r--r--124/0 860 {{.*}} hello.o +OFFSETS: Archive : {{.*}}/macho-universal-archive.x86_64.i386 (architecture i386) +OFFSETS: 8 -rw-r--r--124/11 60 {{.*}} __.SYMDEF SORTED +OFFSETS: 128 -rw-r--r--124/0 388 {{.*}} foo.o + +NON-VERBOSE: Archive : {{.*}}/macho-universal-archive.x86_64.i386 (architecture x86_64) +NON-VERBOSE: 0100644 124/11 44 1399572709 #1/20 +NON-VERBOSE: 0100644 124/0 860 1399501499 #1/12 +NON-VERBOSE: Archive : {{.*}}/macho-universal-archive.x86_64.i386 (architecture i386) +NON-VERBOSE: 0100644 124/11 60 1399572709 #1/20 +NON-VERBOSE: 0100644 124/0 388 1399572697 #1/12 diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index 4fa6495f87f..b173ce92a0a 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -80,6 +80,12 @@ cl::opt cl::desc("Print archive headers for Mach-O archives " "(requires -macho)")); +cl::opt + ArchiveMemberOffsets("archive-member-offsets", + cl::desc("Print the offset to each archive member for " + "Mach-O archives (requires -macho and " + "-archive-headers)")); + cl::opt llvm::IndirectSymbols("indirect-symbols", cl::desc("Print indirect symbol table for Mach-O " @@ -1559,7 +1565,7 @@ void llvm::ParseInputMachO(StringRef Filename) { if (Archive *A = dyn_cast(&Bin)) { outs() << "Archive : " << Filename << "\n"; if (ArchiveHeaders) - printArchiveHeaders(A, true, false); + printArchiveHeaders(A, !NonVerbose, ArchiveMemberOffsets); for (Archive::child_iterator I = A->child_begin(), E = A->child_end(); I != E; ++I) { ErrorOr> ChildOrErr = I->getAsBinary(); @@ -1606,7 +1612,7 @@ void llvm::ParseInputMachO(StringRef Filename) { outs() << " (architecture " << ArchitectureName << ")"; outs() << "\n"; if (ArchiveHeaders) - printArchiveHeaders(A.get(), true, false); + printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets); for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end(); AI != AE; ++AI) { @@ -1648,7 +1654,7 @@ void llvm::ParseInputMachO(StringRef Filename) { std::unique_ptr &A = *AOrErr; outs() << "Archive : " << Filename << "\n"; if (ArchiveHeaders) - printArchiveHeaders(A.get(), true, false); + printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets); for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end(); AI != AE; ++AI) { @@ -1685,7 +1691,7 @@ void llvm::ParseInputMachO(StringRef Filename) { outs() << " (architecture " << ArchitectureName << ")"; outs() << "\n"; if (ArchiveHeaders) - printArchiveHeaders(A.get(), true, false); + printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets); for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end(); AI != AE; ++AI) { ErrorOr> ChildOrErr = AI->getAsBinary();