mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Added annotations for x86 pc relative loads to llvm's 'C' disassembler.
So with darwin's otool(1) an x86_64 hello world .o file will print: leaq L_.str(%rip), %rax ## literal pool for: Hello world git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151769 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9c826d2d3c
commit
8bee081a2c
@ -287,6 +287,27 @@ static bool tryAddingSymbolicOperand(int64_t Value, bool isBranch,
|
||||
return true;
|
||||
}
|
||||
|
||||
/// tryAddingPcLoadReferenceComment - trys to add a comment as to what is being
|
||||
/// referenced by a load instruction with the base register that is the rip.
|
||||
/// These can often be addresses in a literal pool. The Address of the
|
||||
/// instruction and its immediate Value are used to determine the address
|
||||
/// being referenced in the literal pool entry. The SymbolLookUp call back will
|
||||
/// return a pointer to a literal 'C' string if the referenced address is an
|
||||
/// address into a section with 'C' string literals.
|
||||
static void tryAddingPcLoadReferenceComment(uint64_t Address, uint64_t Value,
|
||||
const void *Decoder) {
|
||||
const MCDisassembler *Dis = static_cast<const MCDisassembler*>(Decoder);
|
||||
LLVMSymbolLookupCallback SymbolLookUp = Dis->getLLVMSymbolLookupCallback();
|
||||
if (SymbolLookUp) {
|
||||
void *DisInfo = Dis->getDisInfoBlock();
|
||||
uint64_t ReferenceType = LLVMDisassembler_ReferenceType_In_PCrel_Load;
|
||||
const char *ReferenceName;
|
||||
(void)SymbolLookUp(DisInfo, Value, &ReferenceType, Address, &ReferenceName);
|
||||
if(ReferenceType == LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr)
|
||||
(*Dis->CommentStream) << "literal pool for: " << ReferenceName;
|
||||
}
|
||||
}
|
||||
|
||||
/// translateImmediate - Appends an immediate operand to an MCInst.
|
||||
///
|
||||
/// @param mcInst - The MCInst to append to.
|
||||
@ -502,6 +523,9 @@ static bool translateRMMemory(MCInst &mcInst, InternalInstruction &insn,
|
||||
if (insn.mode == MODE_64BIT){
|
||||
pcrel = insn.startLocation +
|
||||
insn.displacementOffset + insn.displacementSize;
|
||||
tryAddingPcLoadReferenceComment(insn.startLocation +
|
||||
insn.displacementOffset,
|
||||
insn.displacement + pcrel, Dis);
|
||||
baseReg = MCOperand::CreateReg(X86::RIP); // Section 2.2.1.6
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user