13#ifndef LLVM_EXECUTIONENGINE_JITLINK_I386_H
14#define LLVM_EXECUTIONENGINE_JITLINK_I386_H
198 return Value <= std::numeric_limits<uint16_t>::max();
203 return (
Value >= std::numeric_limits<int16_t>::min() &&
204 Value <= std::numeric_limits<int16_t>::max());
209 return (
Value >= std::numeric_limits<int32_t>::min() &&
210 Value <= std::numeric_limits<int32_t>::max());
215 const Symbol *GOTSymbol) {
216 using namespace i386;
219 char *BlockWorkingMem =
B.getAlreadyMutableContent().data();
220 char *FixupPtr = BlockWorkingMem +
E.getOffset();
221 auto FixupAddress =
B.getAddress() +
E.getOffset();
223 switch (
E.getKind()) {
229 uint32_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
236 E.getTarget().getAddress() - (FixupAddress + 4) +
E.getAddend();
242 uint32_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
252 E.getTarget().getAddress() - (FixupAddress + 4) +
E.getAddend();
261 int32_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
267 assert(GOTSymbol &&
"No GOT section symbol");
269 E.getTarget().getAddress() - GOTSymbol->
getAddress() +
E.getAddend();
278 E.getTarget().getAddress() - (FixupAddress + 4) +
E.getAddend();
284 return make_error<JITLinkError>(
285 "In graph " +
G.getName() +
", section " +
B.getSection().getName() +
316 Symbol *InitialTarget =
nullptr,
321 B.addEdge(
Pointer32, 0, *InitialTarget, InitialAddend);
322 return G.addAnonymousSymbol(
B, 0,
PointerSize,
false,
false);
339 2, PointerSymbol, 0);
350 return G.addAnonymousSymbol(
362 switch (
E.getKind()) {
376 "Fell through switch, but no new kind to set");
378 dbgs() <<
" Fixing " <<
G.getEdgeKindName(
E.getKind()) <<
" edge at "
379 <<
B->getFixupAddress(
E) <<
" (" <<
B->getAddress() <<
" + "
380 <<
formatv(
"{0:x}",
E.getOffset()) <<
")\n";
382 E.setKind(KindToSet);
411 dbgs() <<
" Fixing " <<
G.getEdgeKindName(
E.getKind()) <<
" edge at "
412 <<
B->getFixupAddress(
E) <<
" (" <<
B->getAddress() <<
" + "
413 <<
formatv(
"{0:x}",
E.getOffset()) <<
")\n";
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_LIKELY(EXPR)
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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)
Return the constructed entry.
Global Offset Table Builder.
Symbol & createEntry(LinkGraph &G, Symbol &Target)
bool visitEdge(LinkGraph &G, Block *B, Edge &E)
static StringRef getSectionName()
Procedure Linkage Table Builder.
static StringRef getSectionName()
Symbol & createEntry(LinkGraph &G, Symbol &Target)
bool visitEdge(LinkGraph &G, Block *B, Edge &E)
Section & getStubsSection(LinkGraph &G)
PLTTableManager(GOTTableManager &GOT)
Represents an address in the executor process.
Block & createPointerJumpStubBlock(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)
Create a jump stub block that jumps via the pointer at the given symbol.
bool isInRangeForImmS32(int64_t Value)
Returns true if the given int64_t value is in range for an int32_t.
Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const Symbol *GOTSymbol)
Apply fixup expression for edge to block 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...
constexpr uint32_t PointerSize
i386 pointer size.
Error optimizeGOTAndStubAccesses(LinkGraph &G)
Optimize the GOT and Stub relocations if the edge target address is in range.
const char PointerJumpStubContent[6]
i386 pointer jump stub content.
EdgeKind_i386
Represets i386 fixups.
@ BranchPCRel32ToPtrJumpStubBypassable
A relaxable version of BranchPCRel32ToPtrJumpStub.
@ Delta32FromGOT
A 32-bit GOT delta.
@ PCRel32
A 32-bit PC-relative relocation.
@ BranchPCRel32ToPtrJumpStub
A 32-bit PC-relative branch to a pointer jump stub.
@ PCRel16
A 16-bit PC-relative relocation.
@ RequestGOTAndTransformToDelta32FromGOT
A GOT entry offset within GOT getter/constructor, transformed to Delta32FromGOT pointing at the GOT e...
@ BranchPCRel32
A 32-bit PC-relative branch.
@ Pointer32
A plain 32-bit pointer value relocation.
@ Pointer16
A plain 16-bit pointer value relocation.
const char NullPointerContent[PointerSize]
i386 null pointer content.
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.
bool isInRangeForImmS16(int32_t Value)
Returns true if the given int32_t value is in range for an int16_t.
bool isInRangeForImmU16(uint32_t Value)
Returns true if the given uint32_t value is in range for a uint16_t.
const char * getEdgeKindName(Edge::Kind K)
Returns a string name for the given i386 edge.
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.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.