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"
30extern "C" void resolveSymbol(
void);
35 NOTICE(
"Value: " << value);
37 if (
reinterpret_cast<uintptr_t
>(got) == value) {
38 WARNING(
"DynamicLinker: Global offset table not found!");
41 NOTICE(
"got: " <<
reinterpret_cast<uintptr_t
>(got));
43 *got = value & 0xFFFFFFFF;
48 uintptr_t resolveLocation = 0;
54 for (uintptr_t i = 0x40000000; i < 0x50000000; i += pageSize) {
63 if (resolveLocation == 0) {
64 ERROR(
"DynamicLinker: nowhere to put resolve function.");
70 physPage,
reinterpret_cast<void*
>(resolveLocation),
74 ERROR(
"DynamicLinker: Could not map resolve function.");
79 MemoryCopy(
reinterpret_cast<uint8_t*
>(resolveLocation),
80 reinterpret_cast<uint8_t*
>(&::resolveSymbol), pageSize);
82 *got = resolveLocation;
86uintptr_t DynamicLinker::resolvePltSymbol(uintptr_t libraryId, uintptr_t symIdx) {
89 uintptr_t loadBase = libraryId;
94 SharedObject* pSo = m_Objects.lookup(libraryId);
100 ERROR(
"DynamicLinker::resolvePltSymbol: No library found for id `" <<
Hex << libraryId <<
"'");
109 NOTICE(
"Resolve " << symIdx <<
", lib: " << libraryId <<
"; " << result);
void initPlt(Elf *pElf, uintptr_t value)
uintptr_t applySpecificRelocation(uintptr_t off, SymbolTable *pSymtab, uintptr_t loadBase, SymbolTable::Policy policy=SymbolTable::LocalFirst)
uintptr_t getGlobalOffsetTable()
virtual physical_uintptr_t allocatePage(size_t pageConstraints=0)=0
static PhysicalMemoryManager & instance()
static constexpr size_t getPageSize() PURE
static ProcessorInformation & information()
static const size_t Write
static const size_t Execute