14 #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFF86_64_H
15 #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFF86_64_H
19 #include "../RuntimeDyldCOFF.h"
21 #define DEBUG_TYPE "dyld"
79 Value -= FinalAddress + Delta;
80 uint64_t Result = Value + RE.
Addend;
81 assert(((int64_t)Result <= INT32_MAX) &&
"Relocation overflow");
82 assert(((int64_t)Result >= INT32_MIN) &&
"Relocation underflow");
122 return SectionOrError.takeError();
128 uint64_t RelType = RelI->getType();
129 uint64_t
Offset = RelI->getOffset();
143 uint8_t *Displacement = (uint8_t *)ObjTarget;
149 uint8_t *Displacement = (uint8_t *)ObjTarget;
159 if (!TargetNameOrErr)
163 DEBUG(
dbgs() <<
"\t\tIn Section " << SectionID <<
" Offset " << Offset
164 <<
" RelType: " << RelType <<
" TargetName: " << TargetName
165 <<
" Addend " << Addend <<
"\n");
171 bool IsCode = SecI->isText();
172 unsigned TargetSectionID;
173 if (
auto TargetSectionIDOrErr =
175 TargetSectionID = *TargetSectionIDOrErr;
177 return TargetSectionIDOrErr.takeError();
188 for (
auto const &EHFrameSID : UnregisteredEHFrameSections) {
189 uint8_t *EHFrameAddr =
Sections[EHFrameSID].getAddress();
190 uint64_t EHFrameLoadAddr =
Sections[EHFrameSID].getLoadAddress();
191 size_t EHFrameSize =
Sections[EHFrameSID].getSize();
193 RegisteredEHFrameSections.
push_back(EHFrameSID);
195 UnregisteredEHFrameSections.clear();
203 for (
const auto &SectionPair : SectionMap) {
206 if (
auto EC = Section.
getName(Name))
210 if (Name ==
".xdata") {
211 UnregisteredEHFrameSections.
push_back(SectionPair.second);
RelocationEntry - used to represent relocations internally in the dynamic linker. ...
void push_back(const T &Elt)
void writeBytesUnaligned(uint64_t Value, uint8_t *Dst, unsigned Size) const
Endian-aware write.
Expected< StringRef > getName() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
RuntimeDyld::MemoryManager & MemMgr
uintptr_t getObjAddress() const
This class is the base class for all object file types.
uint64_t getSymbolOffset(const SymbolRef &Sym)
Error takeError()
Take ownership of the stored error.
void deregisterEHFrames() override
unsigned getStubAlignment() override
unsigned SectionID
SectionID - the section this relocation points to.
std::map< RelocationValueRef, uintptr_t > StubMap
Tagged union holding either a T or a Error.
std::error_code getName(StringRef &Result) const
uint64_t getLoadAddressWithOffset(unsigned OffsetBytes) const
Return the load address of this section with an offset.
RuntimeDyldCOFFX86_64(RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver)
void addRelocationForSymbol(const RelocationEntry &RE, StringRef SymbolName)
uint8_t * getAddressWithOffset(unsigned OffsetBytes) const
Return the address of this section with an offset.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
void addRelocationForSection(const RelocationEntry &RE, unsigned SectionID)
uint64_t readBytesUnaligned(uint8_t *Src, unsigned Size) const
Endian-aware read Read the least significant Size bytes from Src.
void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override
A object file specific relocation resolver.
virtual basic_symbol_iterator symbol_end() const =0
Error finalizeLoad(const ObjectFile &Obj, ObjSectionToIDMap &SectionMap) override
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.
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.
JITSymbolResolver & Resolver
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Target - Wrapper for Target specific information.
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
Expected< relocation_iterator > processRelocationRef(unsigned SectionID, relocation_iterator RelI, const ObjectFile &Obj, ObjSectionToIDMap &ObjSectionToID, StubMap &Stubs) override
Parses one or more object file relocations (some object files use relocation pairs) and stores it to ...
uint64_t Offset
Offset - offset into the section.
virtual section_iterator section_end() const =0
std::map< SectionRef, unsigned > ObjSectionToIDMap
SectionEntry - represents a section emitted into memory by the dynamic linker.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size)=0
Register the EH frames with the runtime so that c++ exceptions work.
void registerEHFrames() override
This is a value type class that represents a single section in the list of sections in the object fil...
unsigned getMaxStubSize() override