LLVM: lib/MC/MCDisassembler/MCExternalSymbolizer.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

15#include

16

17using namespace llvm;

18

19namespace llvm {

21}

22

23

24

25

26

27

28

29

30

31

32

33

34

39 std::memset(&SymbolicOp, '\0', sizeof(struct LLVMOpInfo1));

41

44

45 std::memset(&SymbolicOp, '\0', sizeof(struct LLVMOpInfo1));

46

47

48

49

50

51

52

53

54

55

56 if (SymbolLookUp || (OpSize == 1 && !IsBranch))

57 return false;

58

60 if (IsBranch)

62 else

64 const char *ReferenceName;

66 &ReferenceName);

67 if (Name) {

70

72 cStream << ReferenceName;

73 }

74

75 else if (IsBranch) {

77 }

79 cStream << "symbol stub for: " << ReferenceName;

81 cStream << "Objc message: " << ReferenceName;

82 if (!Name && !IsBranch)

83 return false;

84 }

85

90 MCSymbol *Sym = Ctx.getOrCreateSymbol(Name);

92 } else {

94 }

95 }

96

101 MCSymbol *Sym = Ctx.getOrCreateSymbol(Name);

103 } else {

105 }

106 }

107

108 const MCExpr *Off = nullptr;

109 if (SymbolicOp.Value != 0)

111

113 if (Sub) {

117 else

119 if (Off)

121 else

122 Expr = LHS;

123 } else if (Add) {

124 if (Off)

126 else

127 Expr = Add;

128 } else {

129 if (Off)

130 Expr = Off;

131 else

133 }

134

135 Expr = RelInfo->createExprForCAPIVariantKind(Expr, SymbolicOp.VariantKind);

136 if (!Expr)

137 return false;

138

140 return true;

141}

142

143

144

145

146

147

148

149

150

151

152

158 const char *ReferenceName;

161 cStream << "literal pool symbol address: " << ReferenceName;

164 cStream << "literal pool for: \"";

166 cStream << "\"";

167 }

170 cStream << "Objc cfstring ref: @\"" << ReferenceName << "\"";

173 cStream << "Objc message: " << ReferenceName;

176 cStream << "Objc message ref: " << ReferenceName;

179 cStream << "Objc selector ref: " << ReferenceName;

182 cStream << "Objc class ref: " << ReferenceName;

183 }

184}

185

190 std::unique_ptr &&RelInfo) {

191 assert(Ctx && "No MCContext given for symbolic disassembly");

192

194 SymbolLookUp, DisInfo);

195}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())

static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)

Context object for machine code objects.

Base class for the full range of assembler expressions which are needed for parsing.

Symbolize using user-provided, C API, callbacks.

void * DisInfo

The pointer to the block of symbolic information for above call back.

LLVMOpInfoCallback GetOpInfo

LLVMSymbolLookupCallback SymbolLookUp

The function to lookup a symbol name.

void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream, int64_t Value, uint64_t Address) override

Try to add a comment on the PC-relative load.

Definition MCExternalSymbolizer.cpp:153

bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, uint64_t OpSize, uint64_t InstSize) override

Try to add a symbolic operand instead of Value to the MCInst.

Definition MCExternalSymbolizer.cpp:35

Instances of this class represent a single low-level machine instruction.

static MCOperand createExpr(const MCExpr *Val)

static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

Symbolize and annotate disassembled instructions.

std::unique_ptr< MCRelocationInfo > RelInfo

static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())

StringRef - Represent a constant reference to a string, i.e.

Triple - Helper class for working with autoconf configuration names.

LLVM Value Representation.

This class implements an extremely fast bulk output stream that can only output to a stream.

raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)

Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...

const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)

The type for the symbol lookup function.

#define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref

#define LLVMDisassembler_ReferenceType_Out_SymbolStub

#define LLVMDisassembler_ReferenceType_In_PCrel_Load

#define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref

#define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr

#define LLVMDisassembler_ReferenceType_In_Branch

#define LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr

#define LLVMDisassembler_ReferenceType_Out_Objc_Message

#define LLVMDisassembler_ReferenceType_InOut_None

The reference types on input and output.

int(* LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t OpSize, uint64_t InstSize, int TagType, void *TagBuf)

The type for the operand information call back function.

#define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref

#define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref

#define LLVMDisassembler_ReferenceType_DeMangled_Name

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI MCSymbolizer * createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo)

Definition MCExternalSymbolizer.cpp:187

@ Sub

Subtraction of integers.

struct LLVMOpInfoSymbol1 SubtractSymbol

struct LLVMOpInfoSymbol1 AddSymbol