9#ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDMACHOX86_64_H
10#define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDMACHOX86_64_H
12#include "../RuntimeDyldMachO.h"
14#define DEBUG_TYPE "dyld"
44 return processSubtractRelocation(SectionID, RelI, Obj, ObjSectionToID);
47 "Scattered relocations not supported on X86_64");
55 return ValueOrErr.takeError();
65 return make_error<RuntimeDyldError>((
"MachO X86_64 relocation type " +
67 " is out of range").str());
73 processGOTRelocation(RE,
Value, Stubs);
88 uint8_t *LocalAddress = Section.getAddressWithOffset(RE.
Offset);
95 uint64_t FinalAddress = Section.getLoadAddressWithOffset(RE.
Offset);
96 Value -= FinalAddress + 4;
114 "Unexpected SUBTRACTOR relocation value.");
134 RuntimeDyldMachO::StubMap::const_iterator i = Stubs.find(
Value);
136 if (i != Stubs.end()) {
137 Addr = Section.getAddressWithOffset(i->second);
139 Stubs[
Value] = Section.getStubOffset();
140 uint8_t *GOTEntry = Section.getAddressWithOffset(Section.getStubOffset());
144 if (
Value.SymbolName)
148 Section.advanceStubOffset(8);
167 uint8_t *LocalAddress =
Sections[SectionID].getAddressWithOffset(
Offset);
168 unsigned NumBytes = 1 <<
Size;
172 unsigned SectionBID = ~0
U;
182 if (!SubtrahendNameOrErr)
185 SectionBID = SubtrahendI->second.getSectionID();
186 SectionBOffset = SubtrahendI->second.getOffset();
189 bool IsCode = SecB.
isText();
192 if (!SectionBIDOrErr)
194 SectionBID = *SectionBIDOrErr;
200 unsigned SectionAID = ~0
U;
208 if (!MinuendNameOrErr)
211 SectionAID = MinuendI->second.getSectionID();
212 SectionAOffset = MinuendI->second.getOffset();
215 bool IsCode = SecA.
isText();
218 if (!SectionAIDOrErr)
220 SectionAID = *SectionAIDOrErr;
225 SectionAID, SectionAOffset, SectionBID, SectionBOffset,
#define UNIMPLEMENTED_RELOC(RelType)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
Symbol resolution interface.
RelocationEntry - used to represent relocations internally in the dynamic linker.
unsigned Size
The size of this relocation (MachO specific).
uint32_t RelType
RelType - relocation type.
uint64_t Offset
Offset - offset into the section.
bool IsPCRel
True if this is a PCRel relocation (MachO specific).
int64_t Addend
Addend - the relocation addend encoded in the instruction itself.
unsigned SectionID
SectionID - the section this relocation points to.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
std::map< SectionRef, unsigned > ObjSectionToIDMap
std::map< RelocationValueRef, uintptr_t > StubMap
void addRelocationForSymbol(const RelocationEntry &RE, StringRef SymbolName)
void addRelocationForSection(const RelocationEntry &RE, unsigned SectionID)
Expected< unsigned > findOrEmitSection(const ObjectFile &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections)
Find Section in LocalSections.
void writeBytesUnaligned(uint64_t Value, uint8_t *Dst, unsigned Size) const
Endian-aware write.
uint64_t readBytesUnaligned(uint8_t *Src, unsigned Size) const
Endian-aware read Read the least significant Size bytes from Src.
RTDyldSymbolTable GlobalSymbolTable
RuntimeDyldMachOTarget - Templated base class for generic MachO linker algorithms and data structures...
Expected< relocation_iterator > processRelocationRef(unsigned SectionID, relocation_iterator RelI, const ObjectFile &BaseObjT, ObjSectionToIDMap &ObjSectionToID, StubMap &Stubs) override
Parses one or more object file relocations (some object files use relocation pairs) and stores it to ...
unsigned getMaxStubSize() const override
Align getStubAlignment() override
void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override
A object file specific relocation resolver.
Error finalizeSection(const ObjectFile &Obj, unsigned SectionID, const SectionRef &Section)
RuntimeDyldMachOX86_64(RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver)
int64_t memcpyAddend(const RelocationEntry &RE) const
This convenience method uses memcpy to extract a contiguous addend (the addend size and offset are ta...
void makeValueAddendPCRel(RelocationValueRef &Value, const relocation_iterator &RI, unsigned OffsetToNextPC)
Make the RelocationValueRef addend PC-relative.
RelocationEntry getRelocationEntry(unsigned SectionID, const ObjectFile &BaseTObj, const relocation_iterator &RI) const
Given a relocation_iterator for a non-scattered relocation, construct a RelocationEntry and fill in t...
Expected< RelocationValueRef > getRelocationValueRef(const ObjectFile &BaseTObj, const relocation_iterator &RI, const RelocationEntry &RE, ObjSectionToIDMap &ObjSectionToID)
Construct a RelocationValueRef representing the relocation target.
void dumpRelocationToResolve(const RelocationEntry &RE, uint64_t Value) const
Dump information about the relocation entry (RE) and resolved value.
SectionEntry - represents a section emitted into memory by the dynamic linker.
iterator find(StringRef Key)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
SectionRef getAnyRelocationSection(const MachO::any_relocation_info &RE) const
unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const
bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const
unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
bool isRelocationScattered(const MachO::any_relocation_info &RE) const
This class is the base class for all object file types.
This is a value type class that represents a single section in the list of sections in the object fil...
uint64_t getAddress() const
bool isText() const
Whether this section contains instructions.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ X86_64_RELOC_SUBTRACTOR
This is an optimization pass for GlobalISel generic memory operations.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
This struct is a compact representation of a valid (non-zero power of two) alignment.