13#ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFFI386_H
14#define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFFI386_H
16#include "../RuntimeDyldCOFF.h"
20#define DEBUG_TYPE "dyld"
43 auto Symbol = RelI->getSymbol();
52 auto SectionOrErr = Symbol->getSection();
54 return SectionOrErr.takeError();
55 auto Section = *SectionOrErr;
61 unsigned TargetSectionID = -1;
64 TargetSectionID = SectionID;
68 }
else if (!IsExtern) {
70 Obj, *Section, Section->isText(), ObjSectionToID))
71 TargetSectionID = *TargetSectionIDOrErr;
73 return TargetSectionIDOrErr.takeError();
82 uint8_t *Displacement = (uint8_t *)ObjTarget;
98 RelI->getTypeName(RelTypeName);
101 <<
" RelType: " << RelTypeName <<
" TargetName: "
102 << TargetName <<
" Addend " << Addend <<
"\n");
118 TargetOffset, 0, 0,
false, 0);
144 uint8_t *
Target = Section.getAddressWithOffset(RE.
Offset);
157 assert(Result <= UINT32_MAX &&
"relocation overflow");
159 <<
" RelType: IMAGE_REL_I386_DIR32"
161 <<
" Value: " <<
format(
"0x%08" PRIx32, Result)
172 assert(Result <= UINT32_MAX &&
"relocation overflow");
174 <<
" RelType: IMAGE_REL_I386_DIR32NB"
176 <<
" Value: " <<
format(
"0x%08" PRIx32, Result)
186 Result = Result - Section.getLoadAddress() + RE.
Addend - 4 - RE.
Offset;
187 assert(
static_cast<int64_t
>(Result) <= INT32_MAX &&
188 "relocation overflow");
189 assert(
static_cast<int64_t
>(Result) >= INT32_MIN &&
190 "relocation underflow");
192 <<
" RelType: IMAGE_REL_I386_REL32"
194 <<
" Value: " <<
format(
"0x%08" PRIx32, Result)
202 "relocation overflow");
204 <<
" RelType: IMAGE_REL_I386_SECTION Value: "
211 "relocation overflow");
213 <<
" RelType: IMAGE_REL_I386_SECREL Value: "
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
uint32_t RelType
RelType - relocation type.
uint64_t Offset
Offset - offset into the section.
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.
Align getStubAlignment() override
void registerEHFrames() override
Expected< object::relocation_iterator > processRelocationRef(unsigned SectionID, object::relocation_iterator RelI, const object::ObjectFile &Obj, ObjSectionToIDMap &ObjSectionToID, StubMap &Stubs) override
Parses one or more object file relocations (some object files use relocation pairs) and stores it to ...
RuntimeDyldCOFFI386(RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver)
unsigned getMaxStubSize() const override
void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override
A object file specific relocation resolver.
uint64_t getSymbolOffset(const SymbolRef &Sym)
static constexpr StringRef getImportSymbolPrefix()
uint64_t getDLLImportOffset(unsigned SectionID, StubMap &Stubs, StringRef Name, bool SetSectionIDMinus1=false)
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.
SectionEntry - represents a section emitted into memory by the dynamic linker.
uintptr_t getObjAddress() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Target - Wrapper for Target specific information.
LLVM Value Representation.
This class is the base class for all object file types.
virtual section_iterator section_end() const =0
virtual basic_symbol_iterator symbol_end() const =0
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_REL_I386_ABSOLUTE
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
This struct is a compact representation of a valid (non-zero power of two) alignment.