27 using namespace llvm::object;
29 #define DEBUG_TYPE "dyld"
34 GenericRTDyldError = 1
42 const char *
name()
const noexcept
override {
return "runtimedyld"; }
44 std::string message(
int Condition)
const override {
45 switch (static_cast<RuntimeDyldErrorCode>(Condition)) {
46 case GenericRTDyldError:
return "Generic RuntimeDyld error";
63 return std::error_code(GenericRTDyldError, *RTDyldErrorCategory);
80 dbgs() <<
"----- Contents of section " << S.
getName() <<
" " << State
84 dbgs() <<
"\n <section not emitted>\n";
88 const unsigned ColsPerRow = 16;
93 unsigned StartPadding = LoadAddr & (ColsPerRow - 1);
94 unsigned BytesRemaining = S.
getSize();
98 LoadAddr & ~(uint64_t)(ColsPerRow - 1)) <<
":";
99 while (StartPadding--)
103 while (BytesRemaining > 0) {
104 if ((LoadAddr & (ColsPerRow - 1)) == 0)
105 dbgs() <<
"\n" <<
format(
"0x%016" PRIx64, LoadAddr) <<
":";
124 for (
int i = 0, e = Sections.size();
i != e; ++
i)
129 resolveExternalSymbols();
132 for (
auto it = Relocations.begin(), e = Relocations.end(); it != e; ++it) {
137 uint64_t Addr = Sections[Idx].getLoadAddress();
138 DEBUG(
dbgs() <<
"Resolving relocations Section #" << Idx <<
"\t"
139 <<
format(
"%p", (uintptr_t)Addr) <<
"\n");
140 resolveRelocationList(it->second, Addr);
146 for (
int i = 0, e = Sections.size(); i != e; ++
i)
153 uint64_t TargetAddress) {
155 for (
unsigned i = 0, e = Sections.size();
i != e; ++
i) {
156 if (Sections[
i].getAddress() == LocalAddress) {
157 reassignSectionAddress(
i, TargetAddress);
184 if (MemMgr.needsToReserveAllocationSpace()) {
185 uint64_t CodeSize = 0, RODataSize = 0, RWDataSize = 0;
186 uint32_t CodeAlign = 1, RODataAlign = 1, RWDataAlign = 1;
187 if (
auto Err = computeTotalAllocSize(Obj,
189 RODataSize, RODataAlign,
190 RWDataSize, RWDataAlign))
191 return std::move(Err);
192 MemMgr.reserveAllocationSpace(CodeSize, CodeAlign, RODataSize, RODataAlign,
193 RWDataSize, RWDataAlign);
213 CommonSymbols.push_back(*
I);
218 if (
auto SymTypeOrErr =
I->getType())
219 SymType = *SymTypeOrErr;
221 return SymTypeOrErr.takeError();
225 if (
auto NameOrErr =
I->getName())
228 return NameOrErr.takeError();
237 if (JITSymFlags.
isWeak()) {
240 if (GlobalSymbolTable.count(Name))
244 if (
auto Sym = Resolver.findSymbolInLogicalDylib(Name))
245 if (Sym.getFlags().isStrongDefinition())
254 if (
auto AddrOrErr =
I->getAddress())
257 return AddrOrErr.takeError();
259 unsigned SectionID = AbsoluteSymbolSection;
261 DEBUG(
dbgs() <<
"\tType: " << SymType <<
" (absolute) Name: " << Name
262 <<
" SID: " << SectionID <<
" Offset: "
263 <<
format(
"%p", (uintptr_t)Addr)
264 <<
" flags: " << Flags <<
"\n");
265 GlobalSymbolTable[
Name] =
273 if (
auto SIOrErr =
I->getSection())
276 return SIOrErr.takeError();
283 if (
auto Err =
getOffset(*
I, *SI, SectOffset))
284 return std::move(Err);
286 bool IsCode = SI->isText();
288 if (
auto SectionIDOrErr = findOrEmitSection(Obj, *SI, IsCode,
290 SectionID = *SectionIDOrErr;
292 return SectionIDOrErr.takeError();
294 DEBUG(
dbgs() <<
"\tType: " << SymType <<
" Name: " << Name
295 <<
" SID: " << SectionID <<
" Offset: "
296 <<
format(
"%p", (uintptr_t)SectOffset)
297 <<
" flags: " << Flags <<
"\n");
298 GlobalSymbolTable[
Name] =
305 if (
auto Err = emitCommonSymbols(Obj, CommonSymbols))
306 return std::move(Err);
315 if (RelocatedSection == SE)
321 if (I == E && !ProcessAllSections)
324 bool IsCode = RelocatedSection->isText();
325 unsigned SectionID = 0;
326 if (
auto SectionIDOrErr = findOrEmitSection(Obj, *RelocatedSection, IsCode,
328 SectionID = *SectionIDOrErr;
330 return SectionIDOrErr.takeError();
332 DEBUG(
dbgs() <<
"\tSectionID: " << SectionID <<
"\n");
335 if (
auto IOrErr = processRelocationRef(SectionID, I, Obj, LocalSections, Stubs))
338 return IOrErr.takeError();
343 Checker->registerStubMap(Obj.
getFileName(), SectionID, Stubs);
347 if (
auto Err = finalizeLoad(Obj, LocalSections))
348 return std::move(Err);
353 return LocalSections;
361 uint64_t Alignment) {
362 uint64_t TotalSize = 0;
363 for (
size_t Idx = 0, Cnt = SectionSizes.size(); Idx < Cnt; Idx++) {
364 uint64_t AlignedSize =
365 (SectionSizes[Idx] + Alignment - 1) / Alignment * Alignment;
366 TotalSize += AlignedSize;
373 if (isa<object::ELFObjectFileBase>(Obj))
375 if (
auto *COFFObj = dyn_cast<object::COFFObjectFile>(Obj)) {
376 const coff_section *CoffSection = COFFObj->getCOFFSection(Section);
387 return HasContent && !IsDiscardable;
390 assert(isa<MachOObjectFile>(Obj));
396 if (isa<object::ELFObjectFileBase>(Obj))
399 if (
auto *COFFObj = dyn_cast<object::COFFObjectFile>(Obj))
400 return ((COFFObj->getCOFFSection(Section)->Characteristics &
408 assert(isa<MachOObjectFile>(Obj));
414 if (isa<object::ELFObjectFileBase>(Obj))
416 if (
auto *COFFObj = dyn_cast<object::COFFObjectFile>(Obj))
417 return COFFObj->getCOFFSection(Section)->Characteristics &
420 auto *MachO = cast<MachOObjectFile>(Obj);
421 unsigned SectionType = MachO->getSectionType(Section);
431 uint64_t &RODataSize,
433 uint64_t &RWDataSize,
436 std::vector<uint64_t> CodeSectionSizes;
437 std::vector<uint64_t> ROSectionSizes;
438 std::vector<uint64_t> RWSectionSizes;
450 uint64_t DataSize = Section.
getSize();
452 unsigned Alignment = (
unsigned)Alignment64 & 0xffffffffL;
453 bool IsCode = Section.
isText();
457 if (
auto EC = Section.
getName(Name))
460 uint64_t StubBufSize = computeSectionStubBufSize(Obj, Section);
468 if (Name ==
".eh_frame")
475 CodeAlign = std::max(CodeAlign, Alignment);
476 CodeSectionSizes.push_back(SectionSize);
477 }
else if (IsReadOnly) {
478 RODataAlign = std::max(RODataAlign, Alignment);
479 ROSectionSizes.push_back(SectionSize);
481 RWDataAlign = std::max(RWDataAlign, Alignment);
482 RWSectionSizes.push_back(SectionSize);
488 uint64_t CommonSize = 0;
495 uint64_t Size =
I->getCommonSize();
501 CommonSize =
alignTo(CommonSize, Align) + Size;
504 if (CommonSize != 0) {
505 RWSectionSizes.push_back(CommonSize);
506 RWDataAlign = std::max(RWDataAlign, CommonAlign);
524 unsigned StubSize = getMaxStubSize();
531 unsigned StubBufSize = 0;
535 if (!(RelSecI == Section))
539 if (relocationNeedsStub(Reloc))
540 StubBufSize += StubSize;
544 uint64_t DataSize = Section.
getSize();
548 unsigned Alignment = (
unsigned)Alignment64 & 0xffffffffL;
549 unsigned StubAlignment = getStubAlignment();
550 unsigned EndAlignment = (DataSize | Alignment) & -(DataSize | Alignment);
551 if (StubAlignment > EndAlignment)
552 StubBufSize += StubAlignment - EndAlignment;
557 unsigned Size)
const {
559 if (IsTargetLittleEndian) {
562 Result = (Result << 8) | *Src--;
565 Result = (Result << 8) | *Src++;
571 unsigned Size)
const {
572 if (IsTargetLittleEndian) {
574 *Dst++ = Value & 0xFF;
580 *Dst-- = Value & 0xFF;
588 if (CommonSymbols.empty())
591 uint64_t CommonSize = 0;
592 uint32_t CommonAlign = CommonSymbols.begin()->getAlignment();
595 DEBUG(
dbgs() <<
"Processing common symbols...\n");
597 for (
const auto &Sym : CommonSymbols) {
599 if (
auto NameOrErr = Sym.getName())
602 return NameOrErr.takeError();
605 if (GlobalSymbolTable.count(Name)) {
606 DEBUG(
dbgs() <<
"\tSkipping already emitted common symbol '" << Name
611 if (
auto Sym = Resolver.findSymbolInLogicalDylib(Name)) {
612 if (!Sym.getFlags().isCommon()) {
613 DEBUG(
dbgs() <<
"\tSkipping common symbol '" << Name
614 <<
"' in favor of stronger definition.\n");
618 uint32_t Align = Sym.getAlignment();
619 uint64_t Size = Sym.getCommonSize();
621 CommonSize =
alignTo(CommonSize, Align) + Size;
623 SymbolsToAllocate.push_back(Sym);
627 unsigned SectionID = Sections.size();
628 uint8_t *Addr = MemMgr.allocateDataSection(CommonSize, CommonAlign, SectionID,
629 "<common symbols>",
false);
634 SectionEntry(
"<common symbols>", Addr, CommonSize, CommonSize, 0));
635 memset(Addr, 0, CommonSize);
637 DEBUG(
dbgs() <<
"emitCommonSection SectionID: " << SectionID <<
" new addr: "
638 <<
format(
"%p", Addr) <<
" DataSize: " << CommonSize <<
"\n");
641 for (
auto &Sym : SymbolsToAllocate) {
642 uint32_t Align = Sym.getAlignment();
643 uint64_t Size = Sym.getCommonSize();
645 if (
auto NameOrErr = Sym.getName())
648 return NameOrErr.takeError();
653 Offset += AlignOffset;
656 DEBUG(
dbgs() <<
"Allocating common symbol " << Name <<
" address "
657 <<
format(
"%p", Addr) <<
"\n");
658 GlobalSymbolTable[
Name] =
665 Checker->registerSection(Obj.
getFileName(), SectionID);
677 unsigned Alignment = (
unsigned)Alignment64 & 0xffffffffL;
678 unsigned PaddingSize = 0;
679 unsigned StubBufSize = 0;
684 uint64_t DataSize = Section.
getSize();
687 if (
auto EC = Section.
getName(Name))
690 StubBufSize = computeSectionStubBufSize(Obj, Section);
695 if (Name ==
".eh_frame")
699 unsigned SectionID = Sections.size();
701 const char *pData =
nullptr;
705 if (!IsVirtual && !IsZeroInit) {
717 Alignment = std::max(Alignment, getStubAlignment());
722 Allocate = DataSize + PaddingSize + StubBufSize;
725 Addr = IsCode ? MemMgr.allocateCodeSection(Allocate, Alignment, SectionID,
727 : MemMgr.allocateDataSection(Allocate, Alignment, SectionID,
733 if (IsZeroInit || IsVirtual)
734 memset(Addr, 0, DataSize);
736 memcpy(Addr, pData, DataSize);
739 if (PaddingSize != 0) {
740 memset(Addr + DataSize, 0, PaddingSize);
742 DataSize += PaddingSize;
745 DEBUG(
dbgs() <<
"emitSection SectionID: " << SectionID <<
" Name: " << Name
746 <<
" obj addr: " <<
format(
"%p", pData)
747 <<
" new addr: " <<
format(
"%p", Addr)
748 <<
" DataSize: " << DataSize <<
" StubBufSize: " << StubBufSize
749 <<
" Allocate: " << Allocate <<
"\n");
756 DEBUG(
dbgs() <<
"emitSection SectionID: " << SectionID <<
" Name: " << Name
757 <<
" obj addr: " <<
format(
"%p", data.
data()) <<
" new addr: 0"
758 <<
" DataSize: " << DataSize <<
" StubBufSize: " << StubBufSize
759 <<
" Allocate: " << Allocate <<
"\n");
763 SectionEntry(Name, Addr, DataSize, Allocate, (uintptr_t)pData));
766 Checker->registerSection(Obj.
getFileName(), SectionID);
777 unsigned SectionID = 0;
778 ObjSectionToIDMap::iterator
i = LocalSections.find(Section);
779 if (i != LocalSections.end())
780 SectionID = i->second;
782 if (
auto SectionIDOrErr = emitSection(Obj, Section, IsCode))
783 SectionID = *SectionIDOrErr;
785 return SectionIDOrErr.takeError();
786 LocalSections[
Section] = SectionID;
792 unsigned SectionID) {
793 Relocations[SectionID].push_back(RE);
802 if (Loc == GlobalSymbolTable.end()) {
803 ExternalSymbolRelocations[SymbolName].push_back(RE);
807 const auto &SymInfo = Loc->
second;
808 RECopy.
Addend += SymInfo.getOffset();
809 Relocations[SymInfo.getSectionID()].push_back(RECopy);
814 unsigned AbiVariant) {
820 writeBytesUnaligned(0xd2e00010, Addr, 4);
821 writeBytesUnaligned(0xf2c00010, Addr+4, 4);
822 writeBytesUnaligned(0xf2a00010, Addr+8, 4);
823 writeBytesUnaligned(0xf2800010, Addr+12, 4);
824 writeBytesUnaligned(0xd61f0200, Addr+16, 4);
830 writeBytesUnaligned(0xe51ff004, Addr, 4);
832 }
else if (IsMipsO32ABI) {
837 const unsigned LuiT9Instr = 0x3c190000, AdduiT9Instr = 0x27390000;
838 const unsigned NopInstr = 0x0;
839 unsigned JrT9Instr = 0x03200008;
841 JrT9Instr = 0x03200009;
843 writeBytesUnaligned(LuiT9Instr, Addr, 4);
844 writeBytesUnaligned(AdduiT9Instr, Addr+4, 4);
845 writeBytesUnaligned(JrT9Instr, Addr+8, 4);
846 writeBytesUnaligned(NopInstr, Addr+12, 4);
852 writeInt32BE(Addr, 0x3D800000);
853 writeInt32BE(Addr+4, 0x618C0000);
854 writeInt32BE(Addr+8, 0x798C07C6);
855 writeInt32BE(Addr+12, 0x658C0000);
856 writeInt32BE(Addr+16, 0x618C0000);
857 if (AbiVariant == 2) {
860 writeInt32BE(Addr+20, 0xF8410018);
861 writeInt32BE(Addr+24, 0x7D8903A6);
862 writeInt32BE(Addr+28, 0x4E800420);
867 writeInt32BE(Addr+20, 0xF8410028);
868 writeInt32BE(Addr+24, 0xE96C0000);
869 writeInt32BE(Addr+28, 0xE84C0008);
870 writeInt32BE(Addr+32, 0x7D6903A6);
871 writeInt32BE(Addr+36, 0xE96C0010);
872 writeInt32BE(Addr+40, 0x4E800420);
876 writeInt16BE(Addr, 0xC418);
877 writeInt16BE(Addr+2, 0x0000);
878 writeInt16BE(Addr+4, 0x0004);
879 writeInt16BE(Addr+6, 0x07F1);
906 DEBUG(
dbgs() <<
"Reassigning address for section " << SectionID <<
" ("
907 << Sections[SectionID].
getName() <<
"): "
908 <<
format(
"0x%016" PRIx64, Sections[SectionID].getLoadAddress())
909 <<
" -> " <<
format(
"0x%016" PRIx64, Addr) <<
"\n");
910 Sections[SectionID].setLoadAddress(Addr);
915 for (
unsigned i = 0, e = Relocs.
size();
i != e; ++
i) {
918 if (Sections[RE.
SectionID].getAddress() ==
nullptr)
920 resolveRelocation(RE, Value);
925 while (!ExternalSymbolRelocations.empty()) {
929 if (Name.
size() == 0) {
931 DEBUG(
dbgs() <<
"Resolving absolute relocations."
934 resolveRelocationList(Relocs, 0);
938 if (Loc == GlobalSymbolTable.end()) {
942 Addr = Resolver.findSymbolInLogicalDylib(Name.
data()).getAddress();
945 Addr = Resolver.findSymbol(Name.
data()).getAddress();
952 i = ExternalSymbolRelocations.find(Name);
956 const auto &SymInfo = Loc->
second;
957 Addr = getSectionLoadAddress(SymInfo.getSectionID()) +
964 "' which could not be resolved!");
968 if (Addr != UINT64_MAX) {
969 DEBUG(
dbgs() <<
"Resolving relocations Name: " << Name <<
"\t"
970 <<
format(
"0x%lx", Addr) <<
"\n");
974 resolveRelocationList(Relocs, Addr);
978 ExternalSymbolRelocations.erase(i);
988 auto I = ObjSecToIDMap.find(Sec);
989 if (
I != ObjSecToIDMap.end())
990 return RTDyld.Sections[
I->second].getLoadAddress();
995 void RuntimeDyld::MemoryManager::anchor() {}
996 void JITSymbolResolver::anchor() {}
1000 : MemMgr(MemMgr), Resolver(Resolver) {
1008 ProcessAllSections =
false;
1014 static std::unique_ptr<RuntimeDyldCOFF>
1018 std::unique_ptr<RuntimeDyldCOFF> Dyld =
1020 Dyld->setProcessAllSections(ProcessAllSections);
1021 Dyld->setRuntimeDyldChecker(Checker);
1025 static std::unique_ptr<RuntimeDyldELF>
1029 std::unique_ptr<RuntimeDyldELF> Dyld =
1031 Dyld->setProcessAllSections(ProcessAllSections);
1032 Dyld->setRuntimeDyldChecker(Checker);
1036 static std::unique_ptr<RuntimeDyldMachO>
1039 bool ProcessAllSections,
1041 std::unique_ptr<RuntimeDyldMachO> Dyld =
1043 Dyld->setProcessAllSections(ProcessAllSections);
1044 Dyld->setRuntimeDyldChecker(Checker);
1048 std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
1054 MemMgr, Resolver, ProcessAllSections, Checker);
1057 static_cast<Triple::ArchType>(Obj.
getArch()), MemMgr, Resolver,
1058 ProcessAllSections, Checker);
1061 static_cast<Triple::ArchType>(Obj.
getArch()), MemMgr, Resolver,
1062 ProcessAllSections, Checker);
1067 if (!Dyld->isCompatibleFile(Obj))
1070 auto LoadedObjInfo = Dyld->loadObject(Obj);
1072 return LoadedObjInfo;
1078 return Dyld->getSymbolLocalAddress(Name);
1084 return Dyld->getSymbol(Name);
1090 Dyld->reassignSectionAddress(SectionID, Addr);
1094 uint64_t TargetAddress) {
1095 Dyld->mapSectionAddress(LocalAddress, TargetAddress);
1103 bool MemoryFinalizationLocked = MemMgr.FinalizationLocked;
1104 MemMgr.FinalizationLocked =
true;
1107 if (!MemoryFinalizationLocked) {
1109 MemMgr.FinalizationLocked =
false;
1115 Dyld->registerEHFrames();
1120 Dyld->deregisterEHFrames();
Error emitCommonSymbols(const ObjectFile &Obj, CommonSymbolList &CommonSymbols)
Given the common symbols discovered in the object file, emit a new section for them and update the sy...
RelocationEntry - used to represent relocations internally in the dynamic linker. ...
void writeBytesUnaligned(uint64_t Value, uint8_t *Dst, unsigned Size) const
Endian-aware write.
std::unique_ptr< LoadedObjectInfo > loadObject(const object::ObjectFile &O)
Add the referenced object file to the list of objects to be loaded and relocated. ...
void registerEHFrames()
Register any EH frame sections that have been loaded but not previously registered with the memory ma...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
StringRef getErrorString()
void resolveExternalSymbols()
Resolve relocations to external symbols.
static bool isReadOnlyData(const SectionRef Section)
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
uint8_t * getAddress() const
This class is the base class for all object file types.
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Error takeError()
Take ownership of the stored error.
uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const override
Obtain the Load Address of a section by SectionRef.
void deregisterEHFrames()
virtual unsigned getArch() const =0
static std::unique_ptr< RuntimeDyldELF > create(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
virtual basic_symbol_iterator symbol_begin() const =0
unsigned SectionID
SectionID - the section this relocation points to.
struct fuzzer::@269 Flags
void resolveRelocationList(const RelocationList &Relocs, uint64_t Value)
Resolves relocations from Relocs list with address from Value.
This is a value type class that represents a single relocation in the list of relocations in the obje...
static StringRef getName(Value *V)
static bool isRequiredForExecution(const SectionRef Section)
std::map< RelocationValueRef, uintptr_t > StubMap
Tagged union holding either a T or a Error.
void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
virtual void registerEHFrames()
static std::unique_ptr< RuntimeDyldMachO > create(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
Create a RuntimeDyldMachO instance for the given target architecture.
support::ulittle32_t VirtualSize
static uint64_t computeAllocationSizeForSections(std::vector< uint64_t > &SectionSizes, uint64_t Alignment)
std::error_code getName(StringRef &Result) const
virtual ~RuntimeDyldImpl()
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
JITEvaluatedSymbol getSymbol(StringRef Name) const
Get the target address and flags for the named symbol.
void * getSymbolLocalAddress(StringRef Name) const
Get the address of our local copy of the symbol.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver)
Construct a RuntimeDyld instance.
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
uint64_t getAlignment() const
Get the alignment of this section as the actual value (not log 2).
Instances of this class acquire a given Mutex Lock when constructed and hold that lock until destruct...
support::ulittle32_t Characteristics
void addRelocationForSymbol(const RelocationEntry &RE, StringRef SymbolName)
virtual bool finalizeMemory(std::string *ErrMsg=nullptr)=0
This method is called when object loading is complete and section page permissions can be applied...
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
S_GB_ZEROFILL - Zero fill on demand section (that can be larger than 4 gigabytes).
virtual void notifyObjectLoaded(RuntimeDyld &RTDyld, const object::ObjectFile &Obj)
This method is called after an object has been loaded into memory but before relocations are applied ...
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.
static ManagedStatic< _object_error_category > error_category
Error computeTotalAllocSize(const ObjectFile &Obj, uint64_t &CodeSize, uint32_t &CodeAlign, uint64_t &RODataSize, uint32_t &RODataAlign, uint64_t &RWDataSize, uint32_t &RWDataAlign)
Flags for symbols in the JIT.
static JITSymbolFlags fromObjectSymbol(const object::BasicSymbolRef &Symbol)
Construct a JITSymbolFlags value based on the flags of the given libobject symbol.
std::vector< SymbolRef > CommonSymbolList
virtual basic_symbol_iterator symbol_end() const =0
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Expected< unsigned > findOrEmitSection(const ObjectFile &Obj, const SectionRef &Section, bool IsCode, ObjSectionToIDMap &LocalSections)
Find Section in LocalSections.
support::ulittle32_t SizeOfRawData
uint64_t getAddress() const
StringRef getFileName() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const ObjectFile * getObject() const
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
static void dumpSectionMemory(const SectionEntry &S, StringRef State)
static ErrorSuccess success()
Create a success value.
unsigned computeSectionStubBufSize(const ObjectFile &Obj, const SectionRef &Section)
virtual section_iterator section_begin() const =0
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
int64_t Addend
Addend - the relocation addend encoded in the instruction itself.
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.
Symbol info for RuntimeDyld.
static std::unique_ptr< RuntimeDyldCOFF > createRuntimeDyldCOFF(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver, bool ProcessAllSections, RuntimeDyldCheckerImpl *Checker)
void reassignSectionAddress(unsigned SectionID, uint64_t Addr)
Represents a symbol that has been evaluated to an address already.
std::error_code getContents(StringRef &Result) const
This is a value type class that represents a single symbol in the list of symbols in the object file...
static std::unique_ptr< RuntimeDyldELF > createRuntimeDyldELF(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver, bool ProcessAllSections, RuntimeDyldCheckerImpl *Checker)
static bool isZeroInit(const SectionRef Section)
virtual section_iterator section_end() const =0
std::map< SectionRef, unsigned > ObjSectionToIDMap
void resolveRelocations()
void finalizeWithMemoryManagerLocking()
Perform all actions needed to make the code owned by this RuntimeDyld instance executable: ...
static std::unique_ptr< RuntimeDyldCOFF > create(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Expected< unsigned > emitSection(const ObjectFile &Obj, const SectionRef &Section, bool IsCode)
Emits section data from the object file to the MemoryManager.
bool isLittleEndian() const
static std::unique_ptr< RuntimeDyldMachO > createRuntimeDyldMachO(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MM, JITSymbolResolver &Resolver, bool ProcessAllSections, RuntimeDyldCheckerImpl *Checker)
uint64_t getLoadAddress() const
void resolveRelocations()
Resolve the relocations for all symbols we currently know about.
SectionEntry - represents a section emitted into memory by the dynamic linker.
virtual void deregisterEHFrames()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
bool isWeak() const
Returns true is the Weak flag is set.
Lightweight error class with error context and mandatory checking.
uint64_t OffsetToAlignment(uint64_t Value, uint64_t Align)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
This class implements an extremely fast bulk output stream that can only output to a stream...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
void reassignSectionAddress(unsigned SectionID, uint64_t Addr)
StringRef - Represent a constant reference to a string, i.e.
Expected< ObjSectionToIDMap > loadObjectImpl(const object::ObjectFile &Obj)
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
S_ZEROFILL - Zero fill on demand section.
void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress)
Map a section to its target address space value.
StringRef getName() const
SectionType
These are the section type and attributes fields.
This is a value type class that represents a single section in the list of sections in the object fil...
uint64_t getFlags() const