1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
//===-- lib/MC/MCDisassembler.cpp - Disassembler interface ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCDisassembler.h"
#include "llvm/MC/MCExternalSymbolizer.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
MCDisassembler::~MCDisassembler() {
}
void
MCDisassembler::setupForSymbolicDisassembly(
LLVMOpInfoCallback GetOpInfo,
LLVMSymbolLookupCallback SymbolLookUp,
void *DisInfo,
MCContext *Ctx,
OwningPtr<MCRelocationInfo> &RelInfo) {
this->GetOpInfo = GetOpInfo;
this->SymbolLookUp = SymbolLookUp;
this->DisInfo = DisInfo;
this->Ctx = Ctx;
assert(Ctx != 0 && "No MCContext given for symbolic disassembly");
if (!Symbolizer)
Symbolizer.reset(new MCExternalSymbolizer(*Ctx, RelInfo, GetOpInfo,
SymbolLookUp, DisInfo));
}
bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
uint64_t Address, bool IsBranch,
uint64_t Offset,
uint64_t InstSize) const {
raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
if (Symbolizer)
return Symbolizer->tryAddingSymbolicOperand(Inst, cStream, Value, Address,
IsBranch, Offset, InstSize);
return false;
}
void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value,
uint64_t Address) const {
raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
if (Symbolizer)
Symbolizer->tryAddingPcLoadReferenceComment(cStream, Value, Address);
}
void MCDisassembler::setSymbolizer(OwningPtr<MCSymbolizer> &Symzer) {
Symbolizer.reset(Symzer.release());
}
|