10 #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDMACHOARM_H
11 #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDMACHOARM_H
13 #include "../RuntimeDyldMachO.h"
16 #define DEBUG_TYPE "dyld"
48 return SignExtend32<26>(Temp << 2);
66 return processHALFSECTDIFFRelocation(SectionID, RelI, Obj,
85 return make_error<RuntimeDyldError>((
"MachO ARM relocation type " +
87 " is out of range").str());
97 return ValueOrErr.takeError();
103 processBranchRelocation(RE, Value, Stubs);
124 Value -= FinalAddress;
142 uint64_t FinalValue = Value & 0xffffff;
156 assert((Value == SectionABase || Value == SectionBBase) &&
157 "Unexpected HALFSECTDIFF relocation value.");
158 Value = SectionABase - SectionBBase + RE.
Addend;
160 Value = (Value >> 16);
164 Insn = (Insn & 0xfff0f000) | ((Value & 0xf000) << 4) | (Value & 0x0fff);
179 if (Name ==
"__nl_symbol_ptr")
193 RuntimeDyldMachO::StubMap::const_iterator
i = Stubs.find(Value);
195 if (i != Stubs.end()) {
232 if (HalfDiffKindBits & 0x2)
238 uint64_t
Offset = RelI->getOffset();
241 Immediate = ((Immediate >> 4) & 0xf000) | (Immediate & 0xfff);
249 uint64_t SectionABase = SAI->getAddress();
250 uint64_t SectionAOffset = AddrA - SectionABase;
252 bool IsCode = SectionA.
isText();
254 if (
auto SectionAIDOrErr =
256 SectionAID = *SectionAIDOrErr;
258 return SectionAIDOrErr.takeError();
263 uint64_t SectionBBase = SBI->getAddress();
264 uint64_t SectionBOffset = AddrB - SectionBBase;
267 if (
auto SectionBIDOrErr =
269 SectionBID = *SectionBIDOrErr;
271 return SectionBIDOrErr.takeError();
274 unsigned Shift = (HalfDiffKindBits & 0x1) ? 16 : 0;
275 uint32_t FullImmVal = (Immediate << Shift) | (OtherHalf << (16 - Shift));
276 int64_t Addend = FullImmVal - (AddrA - AddrB);
281 DEBUG(
dbgs() <<
"Found SECTDIFF: AddrA: " << AddrA <<
", AddrB: " << AddrB
282 <<
", Addend: " << Addend <<
", SectionA ID: " << SectionAID
283 <<
", SectionAOffset: " << SectionAOffset
284 <<
", SectionB ID: " << SectionBID
285 <<
", SectionBOffset: " << SectionBOffset <<
"\n");
287 SectionAOffset, SectionBID, SectionBOffset, IsPCRel,
unsigned getStubAlignment() override
RelocationEntry - used to represent relocations internally in the dynamic linker. ...
void writeBytesUnaligned(uint64_t Value, uint8_t *Dst, unsigned Size) const
Endian-aware write.
unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const
uint8_t * getAddress() const
This class is the base class for all object file types.
unsigned getMaxStubSize() override
bool IsPCRel
True if this is a PCRel relocation (MachO specific).
unsigned SectionID
SectionID - the section this relocation points to.
int64_t decodeAddend(const RelocationEntry &RE) const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
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 ...
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...
int64_t memcpyAddend(const RelocationEntry &RE) const
This convenience method uses memcpy to extract a contiguous addend (the addend size and offset are ta...
std::map< RelocationValueRef, uintptr_t > StubMap
Tagged union holding either a T or a Error.
uint32_t getScatteredRelocationValue(const MachO::any_relocation_info &RE) const
std::error_code getName(StringRef &Result) const
uint64_t getLoadAddressWithOffset(unsigned OffsetBytes) const
Return the load address of this section with an offset.
RuntimeDyldMachOARM(RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver)
void dumpRelocationToResolve(const RelocationEntry &RE, uint64_t Value) const
Dump information about the relocation entry (RE) and resolved value.
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)
uint8_t * getAddressWithOffset(unsigned OffsetBytes) const
Return the address of this section with an offset.
unsigned getAnyRelocationAddress(const MachO::any_relocation_info &RE) const
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
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.
unsigned getAnyRelocationPCRel(const MachO::any_relocation_info &RE) const
uintptr_t getStubOffset() const
Expected< relocation_iterator > processScatteredVANILLA(unsigned SectionID, relocation_iterator RelI, const ObjectFile &BaseObjT, RuntimeDyldMachO::ObjSectionToIDMap &ObjSectionToID)
Process a scattered vanilla relocation.
Expected< unsigned > findOrEmitSection(const ObjectFile &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections)
Find Section in LocalSections.
static section_iterator getSectionByAddress(const MachOObjectFile &Obj, uint64_t Addr)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static ErrorSuccess success()
Create a success value.
unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const
int64_t Addend
Addend - the relocation addend encoded in the instruction itself.
uint32_t RelType
RelType - relocation type.
JITSymbolResolver & Resolver
uint8_t * createStubFunction(uint8_t *Addr, unsigned AbiVariant=0)
Emits long jump instruction to Addr.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
uint64_t Offset
Offset - offset into the section.
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.
void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override
A object file specific relocation resolver.
Lightweight error class with error context and mandatory checking.
unsigned Size
The size of this relocation (MachO specific).
section_iterator section_end() const override
#define UNIMPLEMENTED_RELOC(RelType)
Error populateIndirectSymbolPointersSection(const MachOObjectFile &Obj, const SectionRef &PTSection, unsigned PTSectionID)
void advanceStubOffset(unsigned StubSize)
StringRef - Represent a constant reference to a string, i.e.
void makeValueAddendPCRel(RelocationValueRef &Value, const relocation_iterator &RI, unsigned OffsetToNextPC)
Make the RelocationValueRef addend PC-relative.
bool isRelocationScattered(const MachO::any_relocation_info &RE) const
This is a value type class that represents a single section in the list of sections in the object fil...