mirror of
https://github.com/wiiu-env/CustomRPXLoader.git
synced 2024-11-12 21:45:06 +01:00
Removed unused code
This commit is contained in:
parent
c1457a2801
commit
3cd6ff16e7
@ -26,29 +26,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAXIMUM_MODULE_PATH_NAME_LENGTH 256
|
||||
#define MAXIMUM_MODULE_NAME_LENGTH 51
|
||||
|
||||
#define DYN_LINK_RELOCATION_LIST_LENGTH 500
|
||||
|
||||
struct module_information_single_t {
|
||||
char path[MAXIMUM_MODULE_PATH_NAME_LENGTH] = ""; // Path where the module is stored
|
||||
dyn_linking_relocation_entry_t linking_entries[DYN_LINK_RELOCATION_LIST_LENGTH];
|
||||
int32_t priority; // Priority of this module
|
||||
uint32_t bssAddr;
|
||||
uint32_t bssSize;
|
||||
uint32_t sbssAddr;
|
||||
uint32_t sbssSize;
|
||||
uint32_t entrypoint;
|
||||
};
|
||||
|
||||
#define MAXIMUM_MODULES 8
|
||||
|
||||
struct module_information_t {
|
||||
int32_t number_used_modules = 0; // Number of used function. Maximum is MAXIMUM_MODULES
|
||||
dyn_linking_relocation_data_t linking_data;
|
||||
relocation_trampolin_entry_t trampolines[DYN_LINK_TRAMPOLIN_LIST_LENGTH];
|
||||
module_information_single_t module_data[MAXIMUM_MODULES];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
12
src/main.cpp
12
src/main.cpp
@ -18,12 +18,9 @@
|
||||
#include "utils/utils.h"
|
||||
#include "utils/sd_fat_devoptab.h"
|
||||
|
||||
#define gModuleData ((module_information_t *) (0x00880000))
|
||||
static_assert(sizeof(module_information_t) <= 0x80000);
|
||||
|
||||
bool doRelocation(std::vector<RelocationData *> &relocData, relocation_trampolin_entry_t * tramp_data, uint32_t tramp_length);
|
||||
|
||||
|
||||
bool CheckRunning() {
|
||||
|
||||
switch(ProcUIProcessMessages(true)) {
|
||||
@ -58,8 +55,15 @@ extern "C" int _start(int argc, char **argv) {
|
||||
uint32_t ApplicationMemoryEnd;
|
||||
|
||||
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd));
|
||||
ApplicationMemoryEnd = (ApplicationMemoryEnd + 0x10000) & 0xFFFF0000;
|
||||
ModuleData * moduleData = ModuleDataFactory::load("sd:/wiiu/payload.rpx", ApplicationMemoryEnd, 0x01000000 - ApplicationMemoryEnd, gModuleData->trampolines, DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
||||
|
||||
ApplicationMemoryEnd = (ApplicationMemoryEnd + 0x100) & 0xFFFFFF00;
|
||||
|
||||
module_information_t * gModuleData = (module_information_t *) ApplicationMemoryEnd;
|
||||
|
||||
uint32_t moduleDataStartAddress = ((uint32_t) gModuleData + sizeof(module_information_t));
|
||||
moduleDataStartAddress = (moduleDataStartAddress + 0x10000) & 0xFFFF0000;
|
||||
|
||||
if(moduleData != NULL) {
|
||||
DEBUG_FUNCTION_LINE("Loaded module data\n");
|
||||
std::vector<RelocationData *> relocData = moduleData->getRelocationDataList();
|
||||
|
@ -1,106 +0,0 @@
|
||||
#include <coreinit/cache.h>
|
||||
|
||||
#include "ModuleDataPersistence.h"
|
||||
#include "DynamicLinkingHelper.h"
|
||||
#include "common/module_defines.h"
|
||||
#include "ModuleData.h"
|
||||
#include "RelocationData.h"
|
||||
|
||||
bool ModuleDataPersistence::saveModuleData(module_information_t * moduleInformation, ModuleData * module) {
|
||||
int32_t module_count = moduleInformation->number_used_modules;
|
||||
|
||||
if(module_count >= MAXIMUM_MODULES) {
|
||||
return false;
|
||||
}
|
||||
// Copy data to global struct.
|
||||
module_information_single_t * module_data = &(moduleInformation->module_data[module_count]);
|
||||
|
||||
// Relocation
|
||||
std::vector<RelocationData *> relocationData = module->getRelocationDataList();
|
||||
for (auto const& reloc : relocationData) {
|
||||
if(!DynamicLinkingHelper::addReloationEntry(&(moduleInformation->linking_data), module_data->linking_entries, DYN_LINK_RELOCATION_LIST_LENGTH, reloc)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module_data->bssAddr = module->getBSSAddr();
|
||||
module_data->bssSize = module->getBSSSize();
|
||||
module_data->sbssAddr = module->getSBSSAddr();
|
||||
module_data->sbssSize = module->getSBSSSize();
|
||||
|
||||
module_data->entrypoint = module->getEntrypoint();
|
||||
|
||||
moduleInformation->number_used_modules++;
|
||||
|
||||
DCFlushRange((void*)moduleInformation,sizeof(module_information_t));
|
||||
ICInvalidateRange((void*)moduleInformation,sizeof(module_information_t));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<ModuleData*> ModuleDataPersistence::loadModuleData(module_information_t * moduleInformation) {
|
||||
std::vector<ModuleData*> result;
|
||||
if(moduleInformation == NULL) {
|
||||
DEBUG_FUNCTION_LINE("moduleInformation == NULL\n");
|
||||
return result;
|
||||
}
|
||||
DCFlushRange((void*)moduleInformation,sizeof(module_information_t));
|
||||
ICInvalidateRange((void*)moduleInformation,sizeof(module_information_t));
|
||||
|
||||
int32_t module_count = moduleInformation->number_used_modules;
|
||||
if(module_count > MAXIMUM_MODULES) {
|
||||
DEBUG_FUNCTION_LINE("moduleInformation->module_count was bigger then allowed. %d > %d. Limiting to %d\n",module_count, MAXIMUM_MODULES, MAXIMUM_MODULES);
|
||||
module_count = MAXIMUM_MODULES;
|
||||
}
|
||||
for(int32_t i = 0; i < module_count; i++) {
|
||||
// Copy data from struct.
|
||||
module_information_single_t * module_data = &(moduleInformation->module_data[i]);
|
||||
ModuleData * moduleData = new ModuleData();
|
||||
if(moduleData == NULL){
|
||||
DEBUG_FUNCTION_LINE("Failed to allocate data for ModuleData object\n");
|
||||
continue;
|
||||
}
|
||||
moduleData->setBSSLocation(module_data->bssAddr, module_data->bssSize);
|
||||
moduleData->setSBSSLocation(module_data->sbssAddr, module_data->sbssSize);
|
||||
moduleData->setEntrypoint(module_data->entrypoint);
|
||||
|
||||
for(uint32_t j = 0; j < DYN_LINK_RELOCATION_LIST_LENGTH; j++) {
|
||||
dyn_linking_relocation_entry_t * linking_entry = &(module_data->linking_entries[j]);
|
||||
if(linking_entry->destination == NULL){
|
||||
break;
|
||||
}
|
||||
dyn_linking_import_t* importEntry = linking_entry->importEntry;
|
||||
if(importEntry == NULL){
|
||||
DEBUG_FUNCTION_LINE("importEntry was NULL, skipping relocation entry\n");
|
||||
continue;
|
||||
}
|
||||
if(importEntry->importName == NULL){
|
||||
DEBUG_FUNCTION_LINE("importEntry->importName was NULL, skipping relocation entry\n");
|
||||
continue;
|
||||
}
|
||||
dyn_linking_function_t* functionEntry = linking_entry->functionEntry;
|
||||
|
||||
if(functionEntry == NULL){
|
||||
DEBUG_FUNCTION_LINE("functionEntry was NULL, skipping relocation entry\n");
|
||||
continue;
|
||||
}
|
||||
if(functionEntry->functionName == NULL){
|
||||
DEBUG_FUNCTION_LINE("functionEntry->functionName was NULL, skipping relocation entry\n");
|
||||
continue;
|
||||
}
|
||||
ImportRPLInformation * rplInfo = new ImportRPLInformation(importEntry->importName, importEntry->isData);
|
||||
if(rplInfo == NULL){
|
||||
DEBUG_FUNCTION_LINE("Failed to allocate ImportRPLInformation object. Skipping relocation entry.\n");
|
||||
continue;
|
||||
}
|
||||
RelocationData * reloc = new RelocationData(linking_entry->type, linking_entry->offset, linking_entry->addend, linking_entry->destination, functionEntry->functionName, rplInfo);
|
||||
if(reloc == NULL){
|
||||
DEBUG_FUNCTION_LINE("Failed to allocate RelocationData object. Skipping relocation entry.\n");
|
||||
continue;
|
||||
}
|
||||
moduleData->addRelocationData(reloc);
|
||||
}
|
||||
result.push_back(moduleData);
|
||||
}
|
||||
return result;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/module_defines.h"
|
||||
#include "ModuleData.h"
|
||||
|
||||
class ModuleDataPersistence {
|
||||
public:
|
||||
static bool saveModuleData(module_information_t * moduleInformation, ModuleData * module);
|
||||
static std::vector<ModuleData*> loadModuleData(module_information_t * moduleInformation);
|
||||
};
|
Loading…
Reference in New Issue
Block a user