14 #ifndef LLVM_RUNTIME_DYLD_IMPL_H
15 #define LLVM_RUNTIME_DYLD_IMPL_H
35 using namespace llvm::object;
72 :
Name(name), Address(address), Size(size), LoadAddress((uintptr_t)address),
73 StubOffset(size), ObjAddress(objAddress) {}
104 : SectionID(id), Offset(offset), RelType(type), Addend(addend),
105 SymOffset(0), IsPCRel(
false), Size(0) {}
109 : SectionID(id), Offset(offset), RelType(type), Addend(addend),
110 SymOffset(symoffset), IsPCRel(
false), Size(0) {}
113 bool IsPCRel,
unsigned Size)
114 : SectionID(id), Offset(offset), RelType(type), Addend(addend),
115 SymOffset(0), IsPCRel(IsPCRel), Size(Size) {}
133 if (Offset != Other.
Offset)
134 return Offset < Other.
Offset;
135 if (Addend != Other.
Addend)
136 return Addend < Other.
Addend;
152 #define RTDYLD_INVALID_SECTION_ID ((SID)(-1))
185 typedef std::map<RelocationValueRef, uintptr_t>
StubMap;
202 virtual unsigned getMaxStubSize() = 0;
203 virtual unsigned getStubAlignment() = 0;
210 ErrorStr = Msg.
str();
216 return Sections[SectionID].LoadAddress;
220 return (uint8_t*)Sections[SectionID].Address;
224 if (IsTargetLittleEndian)
226 *Addr = (Value >> 8) & 0xFF;
227 *(Addr+1) = Value & 0xFF;
231 if (IsTargetLittleEndian)
233 *Addr = (Value >> 24) & 0xFF;
234 *(Addr+1) = (Value >> 16) & 0xFF;
235 *(Addr+2) = (Value >> 8) & 0xFF;
236 *(Addr+3) = Value & 0xFF;
240 if (IsTargetLittleEndian)
242 *Addr = (Value >> 56) & 0xFF;
243 *(Addr+1) = (Value >> 48) & 0xFF;
244 *(Addr+2) = (Value >> 40) & 0xFF;
245 *(Addr+3) = (Value >> 32) & 0xFF;
246 *(Addr+4) = (Value >> 24) & 0xFF;
247 *(Addr+5) = (Value >> 16) & 0xFF;
248 *(Addr+6) = (Value >> 8) & 0xFF;
249 *(Addr+7) = Value & 0xFF;
256 const CommonSymbolMap &CommonSymbols,
258 SymbolTableMap &SymbolTable);
276 ObjSectionToIDMap &LocalSections);
279 void addRelocationForSection(
const RelocationEntry &RE,
unsigned SectionID);
287 uint8_t* createStubFunction(uint8_t *Addr);
290 void resolveRelocationList(
const RelocationList &Relocs, uint64_t
Value);
299 virtual void processRelocationRef(
unsigned SectionID,
302 ObjSectionToIDMap &ObjSectionToID,
303 const SymbolTableMap &Symbols,
307 void resolveExternalSymbols();
325 if (pos == GlobalSymbolTable.end())
328 return getSectionAddress(Loc.first) + Loc.second;
335 if (pos == GlobalSymbolTable.end())
338 return getSectionLoadAddress(Loc.first) + Loc.second;
341 void resolveRelocations();
343 void reassignSectionAddress(
unsigned SectionID, uint64_t Addr);
345 void mapSectionAddress(
const void *LocalAddress, uint64_t TargetAddress);
356 virtual bool isCompatibleFormat(
const ObjectBuffer *Buffer)
const = 0;
358 virtual void registerEHFrames();
360 virtual void deregisterEHFrames();
size_t Size
Size - section size. Doesn't include the stubs.
void writeInt16BE(uint8_t *Addr, uint16_t Value)
StringMap< SymbolLoc > SymbolTableMap
bool operator<(const DataRefImpl &a, const DataRefImpl &b)
uint64_t getSectionLoadAddress(unsigned SectionID)
uint8_t * Address
Address - address in the linker's memory where the section resides.
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend, uint64_t symoffset)
uint64_t getSymbolLoadAddress(StringRef Name)
bool IsPCRel
True if this is a PCRel relocation (MachO specific).
unsigned SectionID
SectionID - the section this relocation points to.
bool IsTargetLittleEndian
std::string str() const
str - Return the twine contents as a std::string.
std::map< RelocationValueRef, uintptr_t > StubMap
uint8_t * getSectionAddress(unsigned SectionID)
StringRef getErrorString()
StringRef Name
Name - section name.
void * getSymbolAddress(StringRef Name)
RuntimeDyldImpl(RTDyldMemoryManager *mm)
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend)
std::pair< unsigned, uintptr_t > SymbolLoc
bool Error(const Twine &Msg)
virtual void finalizeLoad(ObjSectionToIDMap &SectionMap)
DenseMap< unsigned, RelocationList > Relocations
SmallVector< SectionEntry, 64 > SectionList
void writeInt32BE(uint8_t *Addr, uint32_t Value)
std::pair< unsigned, unsigned > CommonSymbolInfo
virtual void updateGOTEntries(StringRef Name, uint64_t Addr)
Update GOT entries for external symbols.
RTDyldMemoryManager * MemMgr
uint32_t RelType
RelType - relocation type.
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend, bool IsPCRel, unsigned Size)
unsigned char SwapByteOrder(unsigned char C)
SectionEntry(StringRef name, uint8_t *address, size_t size, uintptr_t objAddress)
uint64_t Offset
Offset - offset into the section.
std::map< SectionRef, unsigned > ObjSectionToIDMap
std::map< SymbolRef, CommonSymbolInfo > CommonSymbolMap
void writeInt64BE(uint8_t *Addr, uint64_t Value)
LLVM Value Representation.
unsigned Size
The size of this relocation (MachO specific).
SymbolTableMap GlobalSymbolTable
bool operator==(const RelocationValueRef &Other) const
StringMap< RelocationList > ExternalSymbolRelocations
SmallVector< RelocationEntry, 64 > RelocationList