LLVM: lib/Target/AArch64/Disassembler/AArch64ExternalSymbolizer.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

17

18using namespace llvm;

19

20#define DEBUG_TYPE "aarch64-disassembler"

21

24 switch (LLVMDisassembler_VariantKind) {

39 default:

41 }

42}

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

64 return false;

65

66

67

68

69

71 memset(&SymbolicOp, '\0', sizeof(struct LLVMOpInfo1));

74 const char *ReferenceName;

76 1, &SymbolicOp)) {

77 if (IsBranch) {

81 if (Name) {

84 SymbolicOp.Value = 0;

85 } else {

87 }

89 CommentStream << "symbol stub for: " << ReferenceName;

92 CommentStream << "Objc message: " << ReferenceName;

93 } else if (MI.getOpcode() == AArch64::ADRP) {

95

96

98 uint32_t EncodedInst = 0x90000000;

99 EncodedInst |= (Value & 0x3) << 29;

100 EncodedInst |= ((Value >> 2) & 0x7FFFF) << 5;

101 EncodedInst |= MCRI.getEncodingValue(MI.getOperand(0).getReg());

103 &ReferenceName);

104 CommentStream << format("0x%llx", (0xfffffffffffff000LL & Address) +

106 } else if (MI.getOpcode() == AArch64::ADDXri ||

107 MI.getOpcode() == AArch64::LDRXui ||

108 MI.getOpcode() == AArch64::LDRXl ||

109 MI.getOpcode() == AArch64::ADR) {

110 if (MI.getOpcode() == AArch64::ADDXri)

112 else if (MI.getOpcode() == AArch64::LDRXui)

114 if (MI.getOpcode() == AArch64::LDRXl) {

117 &ReferenceName);

118 } else if (MI.getOpcode() == AArch64::ADR) {

121 &ReferenceName);

122 } else {

124

125

126 unsigned EncodedInst =

127 MI.getOpcode() == AArch64::ADDXri ? 0x91000000: 0xF9400000;

128 EncodedInst |= Value << 10;

129 EncodedInst |=

131 EncodedInst |= MCRI.getEncodingValue(MI.getOperand(0).getReg());

132

134 &ReferenceName);

135 }

137 CommentStream << "literal pool symbol address: " << ReferenceName;

140 CommentStream << "literal pool for: \"";

142 CommentStream << "\"";

145 CommentStream << "Objc cfstring ref: @\"" << ReferenceName << "\"";

148 CommentStream << "Objc message: " << ReferenceName;

151 CommentStream << "Objc message ref: " << ReferenceName;

154 CommentStream << "Objc selector ref: " << ReferenceName;

157 CommentStream << "Objc class ref: " << ReferenceName;

158

159

160

161

162 return false;

163 } else {

164 return false;

165 }

166 }

167

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

176 else

178 } else {

180 }

181 }

182

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

189 } else {

191 }

192 }

193

194 const MCExpr *Off = nullptr;

195 if (SymbolicOp.Value != 0)

197

199 if (Sub) {

203 else

205 if (Off)

207 else

208 Expr = LHS;

209 } else if (Add) {

210 if (Off)

212 else

213 Expr = Add;

214 } else {

215 if (Off)

216 Expr = Off;

217 else

219 }

220

222

223 return true;

224}

static AArch64::Specifier getMachOSpecifier(uint64_t LLVMDisassembler_VariantKind)

Definition AArch64ExternalSymbolizer.cpp:23

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

tryAddingSymbolicOperand - tryAddingSymbolicOperand tries to add a symbolic operand in place of the i...

Definition AArch64ExternalSymbolizer.cpp:60

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)

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

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.

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

static MCOperand createExpr(const MCExpr *Val)

MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...

uint16_t getEncodingValue(MCRegister Reg) const

Returns the encoding for Reg.

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 ...

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

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

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...

#define LLVMDisassembler_VariantKind_ARM64_TLVOFF

#define LLVMDisassembler_ReferenceType_In_ARM64_ADR

#define LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF

#define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref

#define LLVMDisassembler_VariantKind_ARM64_TLVP

#define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri

#define LLVMDisassembler_ReferenceType_Out_SymbolStub

#define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref

#define LLVMDisassembler_ReferenceType_In_ARM64_ADRP

#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_VariantKind_ARM64_PAGE

The ARM64 target VariantKinds.

#define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref

#define LLVMDisassembler_VariantKind_ARM64_PAGEOFF

#define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref

#define LLVMDisassembler_VariantKind_ARM64_GOTPAGE

#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl

#define LLVMDisassembler_VariantKind_None

The operand VariantKinds for symbolic disassembly.

#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

This is an optimization pass for GlobalISel generic memory operations.

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

@ Sub

Subtraction of integers.

struct LLVMOpInfoSymbol1 SubtractSymbol

struct LLVMOpInfoSymbol1 AddSymbol