Go to the documentation of this file.
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 = ~0U;
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 = ~0U;
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,
bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const
void dumpRelocationToResolve(const RelocationEntry &RE, uint64_t Value) const
Dump information about the relocation entry (RE) and resolved value.
This is an optimization pass for GlobalISel generic memory operations.
bool IsPCRel
True if this is a PCRel relocation (MachO specific).
static ErrorSuccess success()
Create a success value.
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...
void addRelocationForSection(const RelocationEntry &RE, unsigned SectionID)
Tagged union holding either a T or a Error.
iterator find(StringRef Key)
void addRelocationForSymbol(const RelocationEntry &RE, StringRef SymbolName)
unsigned SectionID
SectionID - the section this relocation points to.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
void makeValueAddendPCRel(RelocationValueRef &Value, const relocation_iterator &RI, unsigned OffsetToNextPC)
Make the RelocationValueRef addend PC-relative.
uint64_t Offset
Offset - offset into the section.
unsigned getMaxStubSize() const override
RuntimeDyldMachOTarget - Templated base class for generic MachO linker algorithms and data structures...
#define UNIMPLEMENTED_RELOC(RelType)
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
This struct is a compact representation of a valid (non-zero power of two) alignment.
void writeBytesUnaligned(uint64_t Value, uint8_t *Dst, unsigned Size) const
Endian-aware write.
int64_t Addend
Addend - the relocation addend encoded in the instruction itself.
This is a value type class that represents a single section in the list of sections in the object fil...
RelocationEntry - used to represent relocations internally in the dynamic linker.
unsigned Size
The size of this relocation (MachO specific).
RuntimeDyldMachOX86_64(RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver)
SectionEntry - represents a section emitted into memory by the dynamic linker.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Expected< RelocationValueRef > getRelocationValueRef(const ObjectFile &BaseTObj, const relocation_iterator &RI, const RelocationEntry &RE, ObjSectionToIDMap &ObjSectionToID)
Construct a RelocationValueRef representing the relocation target.
@ X86_64_RELOC_SUBTRACTOR
SectionRef getAnyRelocationSection(const MachO::any_relocation_info &RE) const
This class is the base class for all object file types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
uint64_t getAddress() const
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
bool isRelocationScattered(const MachO::any_relocation_info &RE) const
unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const
bool isText() const
Whether this section contains instructions.
Symbol resolution interface.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Expected< unsigned > findOrEmitSection(const ObjectFile &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections)
Find Section in LocalSections.
Lightweight error class with error context and mandatory checking.
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 ...
Error takeError()
Take ownership of the stored error.
Align getStubAlignment() override
uint64_t readBytesUnaligned(uint8_t *Src, unsigned Size) const
Endian-aware read Read the least significant Size bytes from Src.
unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const
std::map< RelocationValueRef, uintptr_t > StubMap
Error finalizeSection(const ObjectFile &Obj, unsigned SectionID, const SectionRef &Section)
LLVM Value Representation.
uint32_t RelType
RelType - relocation type.
RTDyldSymbolTable GlobalSymbolTable
std::map< SectionRef, unsigned > ObjSectionToIDMap
void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override
A object file specific relocation 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...