LLVM: include/llvm/ExecutionEngine/JITLink/x86.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_EXECUTIONENGINE_JITLINK_X86_H

14#define LLVM_EXECUTIONENGINE_JITLINK_X86_H

15

19

21

22

24

25

26

27

28

29

30

31

32

33

35

36

37

38

39

40

41

42

43

44

45

46

47

49

50

51

52

53

54

55

56

57

58

60

61

62

63

64

65

66

67

68

69

70

71

72

74

75

76

77

78

79

80

81

82

83

84

86

87

88

89

90

91

92

93

94

95

96

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

118

119

120

121

122

123

124

125

126

127

128

129

130

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

177};

178

179

180

182

183

185 const Symbol *GOTSymbol) {

187

188 char *BlockWorkingMem = B.getAlreadyMutableContent().data();

189 char *FixupPtr = BlockWorkingMem + E.getOffset();

190 auto FixupAddress = B.getAddress() + E.getOffset();

191

192 switch (E.getKind()) {

194 uint32_t Value = E.getTarget().getAddress().getValue() + E.getAddend();

196 break;

197 }

198

200 int32_t Value = E.getTarget().getAddress() - FixupAddress + E.getAddend();

202 break;

203 }

204

206 uint32_t Value = E.getTarget().getAddress().getValue() + E.getAddend();

209 else

211 break;

212 }

213

215 int32_t Value = E.getTarget().getAddress() - FixupAddress + E.getAddend();

218 else

220 break;

221 }

222

224 int32_t Value = E.getTarget().getAddress() - FixupAddress + E.getAddend();

226 break;

227 }

228

230 assert(GOTSymbol && "No GOT section symbol");

232 E.getTarget().getAddress() - GOTSymbol->getAddress() + E.getAddend();

234 break;

235 }

236

240 int32_t Value = E.getTarget().getAddress() - FixupAddress + E.getAddend();

242 break;

243 }

244

245 default:

247 "In graph " + G.getName() + ", section " + B.getSection().getName() +

249 }

250

252}

253

254

256

257

259

260

261

262

263

264

266

267

268

269

270

271

272

273

274

275

276

278 Symbol *InitialTarget = nullptr,

279 uint64_t InitialAddend = 0) {

282 if (InitialTarget)

283 B.addEdge(Pointer32, 0, *InitialTarget, InitialAddend);

284 return G.addAnonymousSymbol(B, 0, PointerSize, false, false);

285}

286

287

288

289

290

291

292

294 Symbol &PointerSymbol) {

298

299

300

301 2, PointerSymbol, 0);

302 return B;

303}

304

305

306

307

308

311 Symbol &PointerSymbol) {

312 return G.addAnonymousSymbol(

314 false);

315}

316

317

319public:

321

323 Edge::Kind KindToSet = Edge::Invalid;

324 switch (E.getKind()) {

326

327

328 getGOTSection(G);

329 return false;

330 }

333 break;

334 default:

335 return false;

336 }

337 assert(KindToSet != Edge::Invalid &&

338 "Fell through switch, but no new kind to set");

340 dbgs() << " Fixing " << G.getEdgeKindName(E.getKind()) << " edge at "

341 << B->getFixupAddress(E) << " (" << B->getAddress() << " + "

342 << formatv("{0:x}", E.getOffset()) << ")\n";

343 });

344 E.setKind(KindToSet);

346 return true;

347 }

348

352

353private:

355 if (!GOTSection)

357 return *GOTSection;

358 }

359

360 Section *GOTSection = nullptr;

361};

362

363

365public:

367

369

371 if (E.getKind() == BranchPCRel32 && E.getTarget().isDefined()) {

373 dbgs() << " Fixing " << G.getEdgeKindName(E.getKind()) << " edge at "

374 << B->getFixupAddress(E) << " (" << B->getAddress() << " + "

375 << formatv("{0:x}", E.getOffset()) << ")\n";

376 });

377

378

381 return true;

382 }

383 return false;

384 }

385

390

391public:

398

401};

402

403

404

405

406

407

408

410

411}

412

413#endif

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

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

#define LLVM_LIKELY(EXPR)

#define DEBUG_WITH_TYPE(TYPE,...)

DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

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

Target - Wrapper for Target specific information.

LLVM Value Representation.

An Addressable with content and edges.

Represents fixups and constraints in the LinkGraph.

Represents an object file section.

orc::ExecutorAddr getAddress() const

Returns the address of this symbol.

A CRTP base for tables that are built on demand, e.g.

Symbol & getEntryForTarget(LinkGraph &G, Symbol &Target)

Global Offset Table Builder.

Definition x86.h:318

static StringRef getSectionName()

Definition x86.h:320

Symbol & createEntry(LinkGraph &G, Symbol &Target)

Definition x86.h:349

bool visitEdge(LinkGraph &G, Block *B, Edge &E)

Definition x86.h:322

Section * PLTSection

Definition x86.h:400

GOTTableManager & GOT

Definition x86.h:399

Symbol & createEntry(LinkGraph &G, Symbol &Target)

Definition x86.h:386

bool visitEdge(LinkGraph &G, Block *B, Edge &E)

Definition x86.h:370

PLTTableManager(GOTTableManager &GOT)

Definition x86.h:366

static StringRef getSectionName()

Definition x86.h:368

Section & getStubsSection(LinkGraph &G)

Definition x86.h:392

Represents an address in the executor process.

EdgeKind_x86

Represets x86 fixups.

Definition x86.h:23

@ BranchPCRel32ToPtrJumpStubBypassable

A relaxable version of BranchPCRel32ToPtrJumpStub.

Definition x86.h:176

@ RequestGOTAndTransformToDelta32FromGOT

A GOT entry offset within GOT getter/constructor, transformed to Delta32FromGOT pointing at the GOT e...

Definition x86.h:117

@ Pointer16

A plain 16-bit pointer value relocation.

Definition x86.h:59

@ BranchPCRel32

A 32-bit PC-relative branch.

Definition x86.h:131

@ PCRel32

A 32-bit PC-relative relocation.

Definition x86.h:48

@ PCRel16

A 16-bit PC-relative relocation.

Definition x86.h:73

@ Delta32

A 32-bit delta.

Definition x86.h:85

@ BranchPCRel32ToPtrJumpStub

A 32-bit PC-relative branch to a pointer jump stub.

Definition x86.h:160

@ Pointer32

A plain 32-bit pointer value relocation.

Definition x86.h:34

@ Delta32FromGOT

A 32-bit GOT delta.

Definition x86.h:97

Block & createPointerJumpStubBlock(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)

Create a jump stub block that jumps via the pointer at the given symbol.

Definition x86.h:293

LLVM_ABI const char NullPointerContent[PointerSize]

x86 null pointer content.

Symbol & createAnonymousPointerJumpStub(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)

Create a jump stub that jumps via the pointer at the given symbol and an anonymous symbol pointing to...

Definition x86.h:309

LLVM_ABI const char * getEdgeKindName(Edge::Kind K)

Returns a string name for the given x86 edge.

LLVM_ABI Error optimizeGOTAndStubAccesses(LinkGraph &G)

Optimize the GOT and Stub relocations if the edge target address is in range.

constexpr uint32_t PointerSize

x86 pointer size.

Definition x86.h:255

Symbol & createAnonymousPointer(LinkGraph &G, Section &PointerSection, Symbol *InitialTarget=nullptr, uint64_t InitialAddend=0)

Creates a new pointer block in the given section and returns an anonymous symbol pointing to it.

Definition x86.h:277

LLVM_ABI const char PointerJumpStubContent[6]

x86 pointer jump stub content.

Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const Symbol *GOTSymbol)

Apply fixup expression for edge to block content.

Definition x86.h:184

LLVM_ABI Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B, const Edge &E)

Create an out of range error for the given edge in the given block.

detail::packed_endian_specific_integral< int16_t, llvm::endianness::little, unaligned > little16_t

detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t

detail::packed_endian_specific_integral< uint16_t, llvm::endianness::little, unaligned > ulittle16_t

detail::packed_endian_specific_integral< int32_t, llvm::endianness::little, unaligned > little32_t

constexpr bool isInt(int64_t x)

Checks if an integer fits into the given bit width.

auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

constexpr bool isUInt(uint64_t x)

Checks if an unsigned integer fits into the given bit width.

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.