9 #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDMACHOX86_64_H 10 #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDMACHOX86_64_H 12 #include "../RuntimeDyldMachO.h" 15 #define DEBUG_TYPE "dyld" 45 return processSubtractRelocation(SectionID, RelI, Obj, ObjSectionToID);
48 "Scattered relocations not supported on X86_64");
56 return ValueOrErr.takeError();
59 if (!IsExtern && RE.IsPCRel)
66 return make_error<RuntimeDyldError>((
"MachO X86_64 relocation type " +
68 " is out of range").str());
74 processGOTRelocation(RE, Value, Stubs);
97 Value -= FinalAddress + 4;
114 assert((Value == SectionABase || Value == SectionBBase) &&
115 "Unexpected SUBTRACTOR relocation value.");
116 Value = SectionABase - SectionBBase + RE.
Addend;
135 RuntimeDyldMachO::StubMap::const_iterator i = Stubs.find(Value);
137 if (i != Stubs.end()) {
167 uint64_t
Offset = RelI->getOffset();
168 uint8_t *LocalAddress =
Sections[SectionID].getAddressWithOffset(Offset);
169 unsigned NumBytes = 1 <<
Size;
173 unsigned SectionBID = ~0U;
174 uint64_t SectionBOffset = 0;
183 if (!SubtrahendNameOrErr)
186 SectionBID = SubtrahendI->second.getSectionID();
187 SectionBOffset = SubtrahendI->second.getOffset();
190 bool IsCode = SecB.
isText();
193 if (!SectionBIDOrErr)
195 SectionBID = *SectionBIDOrErr;
201 unsigned SectionAID = ~0U;
202 uint64_t SectionAOffset = 0;
209 if (!MinuendNameOrErr)
212 SectionAID = MinuendI->second.getSectionID();
213 SectionAOffset = MinuendI->second.getOffset();
216 bool IsCode = SecA.
isText();
219 if (!SectionAIDOrErr)
221 SectionAID = *SectionAIDOrErr;
226 SectionAID, SectionAOffset, SectionBID, SectionBOffset,
RelocationEntry - used to represent relocations internally in the dynamic linker. ...
This class represents lattice values for constants.
unsigned getMaxStubSize() const override
uint64_t readBytesUnaligned(uint8_t *Src, unsigned Size) const
Endian-aware read Read the least significant Size bytes from Src.
uint64_t getLoadAddressWithOffset(unsigned OffsetBytes) const
Return the load address of this section with an offset.
bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const
iterator find(StringRef Key)
void dumpRelocationToResolve(const RelocationEntry &RE, uint64_t Value) const
Dump information about the relocation entry (RE) and resolved value.
This class is the base class for all object file types.
Error takeError()
Take ownership of the stored error.
void writeBytesUnaligned(uint64_t Value, uint8_t *Dst, unsigned Size) const
Endian-aware write.
bool IsPCRel
True if this is a PCRel relocation (MachO specific).
unsigned SectionID
SectionID - the section this relocation points to.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
uint64_t getAddress() const
bool isText() const
Whether this section contains instructions.
std::map< RelocationValueRef, uintptr_t > StubMap
Tagged union holding either a T or a Error.
int64_t memcpyAddend(const RelocationEntry &RE) const
This convenience method uses memcpy to extract a contiguous addend (the addend size and offset are ta...
SectionRef getAnyRelocationSection(const MachO::any_relocation_info &RE) const
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 getAnyRelocationType(const MachO::any_relocation_info &RE) const
RuntimeDyldMachOTarget - Templated base class for generic MachO linker algorithms and data structures...
Error finalizeSection(const ObjectFile &Obj, unsigned SectionID, const SectionRef &Section)
Expected< RelocationValueRef > getRelocationValueRef(const ObjectFile &BaseTObj, const relocation_iterator &RI, const RelocationEntry &RE, ObjSectionToIDMap &ObjSectionToID)
Construct a RelocationValueRef representing the relocation target.
void addRelocationForSymbol(const RelocationEntry &RE, StringRef SymbolName)
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)
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Symbol resolution interface.
Expected< unsigned > findOrEmitSection(const ObjectFile &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections)
Find Section in LocalSections.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isRelocationScattered(const MachO::any_relocation_info &RE) const
static ErrorSuccess success()
Create a success value.
int64_t Addend
Addend - the relocation addend encoded in the instruction itself.
uint32_t RelType
RelType - relocation type.
RuntimeDyldMachOX86_64(RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver)
uintptr_t getStubOffset() const
unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const
unsigned getStubAlignment() override
uint64_t Offset
Offset - offset into the section.
std::map< SectionRef, unsigned > ObjSectionToIDMap
uint8_t * getAddressWithOffset(unsigned OffsetBytes) const
Return the address of this section with an offset.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override
A object file specific relocation resolver.
SectionEntry - represents a section emitted into memory by the dynamic linker.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
RTDyldSymbolTable GlobalSymbolTable
Lightweight error class with error context and mandatory checking.
unsigned Size
The size of this relocation (MachO specific).
#define UNIMPLEMENTED_RELOC(RelType)
void advanceStubOffset(unsigned StubSize)
void makeValueAddendPCRel(RelocationValueRef &Value, const relocation_iterator &RI, unsigned OffsetToNextPC)
Make the RelocationValueRef addend PC-relative.
This is a value type class that represents a single section in the list of sections in the object fil...