[llvm] r288199 - Add to llvm-objdump the -no-leading-headers option with the use of the -macho option.
Kevin Enderby via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 29 13:43:41 PST 2016
Author: enderby
Date: Tue Nov 29 15:43:40 2016
New Revision: 288199
URL: http://llvm.org/viewvc/llvm-project?rev=288199&view=rev
Log:
Add to llvm-objdump the -no-leading-headers option with the use of the -macho option.
In some cases the leading headers of the file name, archive member and
architecture slice name in the output of lvm-objdump is not wanted so the
tool’s output can be directly used by scripts. This matches the -X option
of the Apple otool(1) program.
rdar://28491674
Modified:
llvm/trunk/test/tools/llvm-objdump/X86/macho-dylib.test
llvm/trunk/tools/llvm-objdump/MachODump.cpp
Modified: llvm/trunk/test/tools/llvm-objdump/X86/macho-dylib.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/X86/macho-dylib.test?rev=288199&r1=288198&r2=288199&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/X86/macho-dylib.test (original)
+++ llvm/trunk/test/tools/llvm-objdump/X86/macho-dylib.test Tue Nov 29 15:43:40 2016
@@ -1,6 +1,10 @@
RUN: llvm-objdump -m -dylibs-used %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s -check-prefix=USED
RUN: llvm-objdump -m -dylib-id %p/Inputs/dylibLoadKinds.macho-x86_64 | FileCheck %s -check-prefix=ID
+RUN: llvm-objdump -m -dylib-id -no-leading-headers %p/Inputs/dylibLoadKinds.macho-x86_64 | FileCheck %s -check-prefix=IDNOHEADERS
USED: /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
ID: /usr/lib/foo.dylib
+
+IDNOHEADERS-NOT: dylibLoadKinds.macho-x86_64:
+IDNOHEADERS: /usr/lib/foo.dylib
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=288199&r1=288198&r2=288199&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Tue Nov 29 15:43:40 2016
@@ -71,6 +71,9 @@ static cl::opt<bool> FullLeadingAddr("fu
static cl::opt<bool> NoLeadingAddr("no-leading-addr",
cl::desc("Print no leading address"));
+static cl::opt<bool> NoLeadingHeaders("no-leading-headers",
+ cl::desc("Print no leading headers"));
+
cl::opt<bool> llvm::UniversalHeaders("universal-headers",
cl::desc("Print Mach-O universal headers "
"(requires -macho)"));
@@ -1190,12 +1193,14 @@ static void ProcessMachO(StringRef Name,
if (Disassemble || PrivateHeaders || ExportsTrie || Rebase || Bind || SymbolTable ||
LazyBind || WeakBind || IndirectSymbols || DataInCode || LinkOptHints ||
DylibsUsed || DylibId || ObjcMetaData || (FilterSections.size() != 0)) {
- outs() << Name;
- if (!ArchiveMemberName.empty())
- outs() << '(' << ArchiveMemberName << ')';
- if (!ArchitectureName.empty())
- outs() << " (architecture " << ArchitectureName << ")";
- outs() << ":\n";
+ if (!NoLeadingHeaders) {
+ outs() << Name;
+ if (!ArchiveMemberName.empty())
+ outs() << '(' << ArchiveMemberName << ')';
+ if (!ArchitectureName.empty())
+ outs() << " (architecture " << ArchitectureName << ")";
+ outs() << ":\n";
+ }
}
// To use the report_error() form with an ArchiveName and FileName set
// these up based on what is passed for Name and ArchiveMemberName.
More information about the llvm-commits
mailing list