Flush the caches after doing the relocations

This commit is contained in:
Maschell 2021-12-28 02:18:06 +01:00
parent 2db63bafab
commit e3b8de0204
4 changed files with 25 additions and 5 deletions

View File

@ -122,9 +122,6 @@ bool ElfUtils::doRelocation(std::vector<std::shared_ptr<RelocationData>> &relocD
if (err != OS_DYNLOAD_OK || rplHandle == 0) {
// only acquire if not already loaded.
auto res = OSDynLoad_Acquire(rplName.c_str(), &rplHandle);
DEBUG_FUNCTION_LINE("OSDynLoad_Acquire %s: %d", rplName.c_str(), res);
} else {
DEBUG_FUNCTION_LINE("already acquired %08X", rplHandle);
}
uint32_t functionAddress = 0;

View File

@ -110,6 +110,9 @@ int main(int argc, char **argv) {
DEBUG_FUNCTION_LINE("Relocation done");
}
DCFlushRange((void *) moduleData.value()->getStartAddress(), moduleData.value()->getEndAddress() - moduleData.value()->getStartAddress());
ICInvalidateRange((void *) moduleData.value()->getStartAddress(), moduleData.value()->getEndAddress() - moduleData.value()->getStartAddress());
DEBUG_FUNCTION_LINE("Calling entrypoint @%08X", moduleData.value()->getEntrypoint());
char *arr[1];
arr[0] = (char *) environment_path.c_str();

View File

@ -45,7 +45,25 @@ public:
return entrypoint;
}
void setStartAddress(uint32_t addr) {
this->startAddress = addr;
}
void setEndAddress(uint32_t _endAddress) {
this->endAddress = _endAddress;
}
[[nodiscard]] uint32_t getStartAddress() const {
return startAddress;
}
[[nodiscard]] uint32_t getEndAddress() const {
return endAddress;
}
private:
std::vector<std::shared_ptr<RelocationData>> relocation_data_list;
uint32_t entrypoint = 0;
uint32_t startAddress = 0;
uint32_t endAddress = 0;
};

View File

@ -136,6 +136,8 @@ ModuleDataFactory::load(const std::string &path, uint32_t *destination_address_p
free(destinations);
moduleData->setStartAddress(*destination_address_ptr);
moduleData->setEndAddress(endAddress);
moduleData->setEntrypoint(entrypoint);
DEBUG_FUNCTION_LINE("Saved entrypoint as %08X", entrypoint);