13 #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFFTHUMB_H 14 #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFFTHUMB_H 16 #include "../RuntimeDyldCOFF.h" 20 #define DEBUG_TYPE "dyld" 41 return cast<object::COFFObjectFile>(Obj)
42 .getCOFFSection(*Section)
65 auto Symbol = RelI->getSymbol();
74 auto SectionOrErr =
Symbol->getSection();
76 return SectionOrErr.takeError();
79 uint64_t RelType = RelI->getType();
80 uint64_t
Offset = RelI->getOffset();
86 uint8_t *Displacement = (uint8_t *)ObjTarget;
100 RelI->getTypeName(RelTypeName);
102 LLVM_DEBUG(
dbgs() <<
"\t\tIn Section " << SectionID <<
" Offset " << Offset
103 <<
" RelType: " << RelTypeName <<
" TargetName: " 104 << TargetName <<
" Addend " << Addend <<
"\n");
106 unsigned TargetSectionID = -1;
108 RelocationEntry RE(SectionID, Offset, RelType, 0, -1, 0, 0, 0,
false, 0);
111 if (
auto TargetSectionIDOrErr =
113 TargetSectionID = *TargetSectionIDOrErr;
115 return TargetSectionIDOrErr.takeError();
128 SectionID, Offset, RelType, Addend, TargetSectionID,
154 SectionID, Offset, RelType, Addend, TargetSectionID,
190 Result |= ISASelectionBit;
191 assert(Result <= UINT32_MAX &&
"relocation overflow");
193 <<
" RelType: IMAGE_REL_ARM_ADDR32" 195 <<
" Value: " <<
format(
"0x%08" PRIx32, Result)
205 assert(Result <= UINT32_MAX &&
"relocation overflow");
207 <<
" RelType: IMAGE_REL_ARM_ADDR32NB" 209 <<
" Value: " <<
format(
"0x%08" PRIx32, Result)
211 Result |= ISASelectionBit;
218 "relocation overflow");
220 <<
" RelType: IMAGE_REL_ARM_SECTION Value: " 226 assert(static_cast<uint64_t>(RE.
Addend) <= UINT32_MAX &&
227 "relocation overflow");
229 <<
" RelType: IMAGE_REL_ARM_SECREL Value: " << RE.
Addend 237 assert(Result <= UINT32_MAX &&
"relocation overflow");
239 <<
" RelType: IMAGE_REL_ARM_MOV32T" 241 <<
" Value: " <<
format(
"0x%08" PRIx32, Result)
249 auto EncodeImmediate = [](uint8_t *Bytes,
uint16_t Immediate) {
250 Bytes[0] |= ((Immediate & 0xf000) >> 12);
251 Bytes[1] |= ((Immediate & 0x0800) >> 11);
252 Bytes[2] |= ((Immediate & 0x00ff) >> 0);
253 Bytes[3] |= (((Immediate & 0x0700) >> 8) << 4);
256 EncodeImmediate(&Target[0],
257 (static_cast<uint32_t>(Result) >> 00) | ISASelectionBit);
258 EncodeImmediate(&Target[4], static_cast<uint32_t>(Result) >> 16);
267 "relocation overflow");
269 "relocation underflow");
271 <<
" RelType: IMAGE_REL_ARM_BRANCH20T" 272 <<
" Value: " << static_cast<int32_t>(Value) <<
'\n');
273 static_cast<void>(
Value);
282 "relocation overflow");
284 "relocation underflow");
286 <<
" RelType: IMAGE_REL_ARM_BRANCH24T" 287 <<
" Value: " << static_cast<int32_t>(Value) <<
'\n');
288 static_cast<void>(
Value);
297 "relocation overflow");
299 "relocation underflow");
301 <<
" RelType: IMAGE_REL_ARM_BLX23T" 302 <<
" Value: " << static_cast<int32_t>(Value) <<
'\n');
303 static_cast<void>(
Value);
RelocationEntry - used to represent relocations internally in the dynamic linker. ...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
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 registerEHFrames() override
void writeBytesUnaligned(uint64_t Value, uint8_t *Dst, unsigned Size) const
Endian-aware write.
unsigned SectionID
SectionID - the section this relocation points to.
static bool isThumbFunc(object::symbol_iterator Symbol, const object::ObjectFile &Obj, object::section_iterator Section)
std::map< RelocationValueRef, uintptr_t > StubMap
Tagged union holding either a T or a Error.
RuntimeDyldCOFFThumb(RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver)
void addRelocationForSymbol(const RelocationEntry &RE, StringRef SymbolName)
void addRelocationForSection(const RelocationEntry &RE, unsigned SectionID)
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Symbol resolution interface.
virtual basic_symbol_iterator symbol_end() const =0
uintptr_t getObjAddress() const
Expected< unsigned > findOrEmitSection(const ObjectFile &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections)
Find Section in LocalSections.
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Expected< SymbolRef::Type > getType() const
int64_t Addend
Addend - the relocation addend encoded in the instruction itself.
uint32_t RelType
RelType - relocation type.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Target - Wrapper for Target specific information.
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 ...
uint64_t Offset
Offset - offset into the section.
virtual section_iterator section_end() const =0
std::map< SectionRef, unsigned > ObjSectionToIDMap
unsigned getStubAlignment() override
SectionEntry - represents a section emitted into memory by the dynamic linker.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
LLVM Value Representation.
void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override
A object file specific relocation resolver.
StringRef - Represent a constant reference to a string, i.e.