--- /dev/null
+# RUN: llvm-objdump -m -d %p/Inputs/exeThread.macho-x86_64 -dis-symname start -no-show-raw-insn -full-leading-addr -print-imm-hex | FileCheck %s
+
+# CHECK: (__TEXT,__text) section
+# CHECK: start:
+# CHECK: 0000000100000d00 pushq $0x0
+# CHECK: 0000000100000d02 movq %rsp, %rbp
+# CHECK: 0000000100000d05 andq $-0x10, %rsp
+# CHECK: 0000000100000d09 movq 0x8(%rbp), %rdi
+# CHECK: 0000000100000d0d leaq 0x10(%rbp), %rsi
+# CHECK: 0000000100000d11 movl %edi, %edx
+# CHECK: 0000000100000d13 addl $0x1, %edx
+# CHECK: 0000000100000d16 shll $0x3, %edx
+# CHECK: 0000000100000d19 addq %rsi, %rdx
+# CHECK: 0000000100000d1c callq __start
+# CHECK: 0000000100000d21 hlt
+
+# CHECK-NOT: __start:
+# CHECK-NOT: 0000000100000d22
+# CHECK-NOT: _main:
cl::desc("Print the info for Mach-O objects in "
"non-verbose or numeric form (requires -macho)"));
+cl::opt<std::string> llvm::DisSymName(
+ "dis-symname",
+ cl::desc("disassemble just this symbol's instructions (requires -macho"));
+
static cl::list<std::string>
ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
cl::ZeroOrMore);
// Create a map of symbol addresses to symbol names for use by
// the SymbolizerSymbolLookUp() routine.
SymbolAddressMap AddrMap;
+ bool DisSymNameFound = false;
for (const SymbolRef &Symbol : MachOOF->symbols()) {
SymbolRef::Type ST;
Symbol.getType(ST);
StringRef SymName;
Symbol.getName(SymName);
AddrMap[Address] = SymName;
+ if (!DisSymName.empty() && DisSymName == SymName)
+ DisSymNameFound = true;
}
}
+ if (!DisSymName.empty() && DisSymNameFound == false) {
+ outs() << "Can't find -dis-symname: " << DisSymName << "\n";
+ return;
+ }
// Set up the block of info used by the Symbolizer call backs.
SymbolizerInfo.verbose = true;
SymbolizerInfo.O = MachOOF;
if (!containsSym)
continue;
+ // If we are only disassembling one symbol see if this is that symbol.
+ if (!DisSymName.empty() && DisSymName != SymName)
+ continue;
+
// Start at the address of the symbol relative to the section's address.
uint64_t Start = 0;
uint64_t SectionAddress = Sections[SectIdx].getAddress();
extern cl::opt<bool> InfoPlist;
extern cl::opt<bool> DylibsUsed;
extern cl::opt<bool> DylibId;
+extern cl::opt<std::string> DisSymName;
extern cl::opt<bool> NonVerbose;
extern cl::opt<bool> Relocations;
extern cl::opt<bool> SectionHeaders;