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) { if (err != OS_DYNLOAD_OK || rplHandle == 0) {
// only acquire if not already loaded. // only acquire if not already loaded.
auto res = OSDynLoad_Acquire(rplName.c_str(), &rplHandle); 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; uint32_t functionAddress = 0;

View File

@ -77,8 +77,8 @@ int main(int argc, char **argv) {
VPADRead(VPAD_CHAN_0, &vpad_data, 1, &err); VPADRead(VPAD_CHAN_0, &vpad_data, 1, &err);
uint32_t btn = 0; uint32_t btn = 0;
if(err == VPAD_READ_SUCCESS) { if (err == VPAD_READ_SUCCESS) {
btn = vpad_data.hold | vpad_data.trigger; btn = vpad_data.hold | vpad_data.trigger;
} }
std::string environment_path = "fs:/vol/external01/wiiu/environments/default"; std::string environment_path = "fs:/vol/external01/wiiu/environments/default";
@ -110,6 +110,9 @@ int main(int argc, char **argv) {
DEBUG_FUNCTION_LINE("Relocation done"); 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()); DEBUG_FUNCTION_LINE("Calling entrypoint @%08X", moduleData.value()->getEntrypoint());
char *arr[1]; char *arr[1];
arr[0] = (char *) environment_path.c_str(); arr[0] = (char *) environment_path.c_str();

View File

@ -45,7 +45,25 @@ public:
return entrypoint; 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: private:
std::vector<std::shared_ptr<RelocationData>> relocation_data_list; std::vector<std::shared_ptr<RelocationData>> relocation_data_list;
uint32_t entrypoint = 0; 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); free(destinations);
moduleData->setStartAddress(*destination_address_ptr);
moduleData->setEndAddress(endAddress);
moduleData->setEntrypoint(entrypoint); moduleData->setEntrypoint(entrypoint);
DEBUG_FUNCTION_LINE("Saved entrypoint as %08X", entrypoint); DEBUG_FUNCTION_LINE("Saved entrypoint as %08X", entrypoint);