20 #include "modules/system/linker/DynamicLinker.h" 21 #include "pedigree/kernel/Log.h" 22 #include "pedigree/kernel/linker/Elf.h" 23 #include "pedigree/kernel/linker/SymbolTable.h" 24 #include "pedigree/kernel/processor/PhysicalMemoryManager.h" 25 #include "pedigree/kernel/processor/Processor.h" 26 #include "pedigree/kernel/processor/ProcessorInformation.h" 27 #include "pedigree/kernel/processor/VirtualAddressSpace.h" 28 #include "pedigree/kernel/utilities/utility.h" 30 extern "C" void resolveSymbol(
void);
36 NOTICE(
"Value: " << value);
39 if (reinterpret_cast<uintptr_t>(got) == value)
41 WARNING(
"DynamicLinker: Global offset table not found!");
44 NOTICE(
"got: " << reinterpret_cast<uintptr_t>(got));
46 *got = value & 0xFFFFFFFF;
52 uintptr_t resolveLocation = 0;
57 for (uintptr_t i = 0x40000000; i < 0x50000000;
61 reinterpret_cast<void *>(i)))
70 if (resolveLocation == 0)
72 ERROR(
"DynamicLinker: nowhere to put resolve function.");
76 physical_uintptr_t physPage =
79 physPage, reinterpret_cast<void *>(resolveLocation),
84 ERROR(
"DynamicLinker: Could not map resolve function.");
90 reinterpret_cast<uint8_t *>(resolveLocation),
91 reinterpret_cast<uint8_t *>(&::resolveSymbol),
94 *got = resolveLocation;
102 uintptr_t loadBase = libraryId;
105 pElf = m_pProgramElf;
116 "DynamicLinker::resolvePltSymbol: No library found for id `" 117 <<
Hex << libraryId <<
"'");
122 symIdx, m_pProgramElf->getSymbolTable(), loadBase);
125 symIdx, m_pProgramElf->getSymbolTable(), loadBase,
127 NOTICE(
"Resolve " << symIdx <<
", lib: " << libraryId <<
"; " << result);
static PhysicalMemoryManager & instance()
virtual physical_uintptr_t allocatePage(size_t pageConstraints=0)=0
static const size_t Execute
static ProcessorInformation & information()
static const size_t Write
uintptr_t resolvePltSymbol(uintptr_t libraryId, uintptr_t symIdx)
uintptr_t applySpecificRelocation(uintptr_t off, SymbolTable *pSymtab, uintptr_t loadBase, SymbolTable::Policy policy=SymbolTable::LocalFirst)
uintptr_t getGlobalOffsetTable()
void initPlt(Elf *pElf, uintptr_t value)