mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-17 08:57:34 +00:00
Add the option, -dis-symname to llvm-objdump used with -macho and
-disassemble to disassemble just one symbol’s instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232503 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6e4a97dfce
commit
73cd697dec
19
test/tools/llvm-objdump/X86/macho-dis-symname.test
Normal file
19
test/tools/llvm-objdump/X86/macho-dis-symname.test
Normal file
@ -0,0 +1,19 @@
|
||||
# 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:
|
@ -116,6 +116,10 @@ cl::opt<bool>
|
||||
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);
|
||||
@ -3181,6 +3185,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
||||
// 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);
|
||||
@ -3191,8 +3196,14 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
||||
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;
|
||||
@ -3235,6 +3246,10 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *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();
|
||||
|
@ -43,6 +43,7 @@ extern cl::opt<bool> LinkOptHints;
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user