mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2026-10-04 07:47:23 -05:00
Format the code via clang-format
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include <coreinit/cache.h>
|
||||
#include "ModuleDataPersistence.h"
|
||||
#include "DynamicLinkingHelper.h"
|
||||
#include <coreinit/cache.h>
|
||||
|
||||
bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformation, const std::shared_ptr<ModuleData> &module) {
|
||||
int32_t module_count = moduleInformation->number_used_modules;
|
||||
@@ -15,7 +15,7 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
|
||||
DEBUG_FUNCTION_LINE("Saving relocation data for module at %08X", module->getEntrypoint());
|
||||
// Relocation
|
||||
auto relocationData = module->getRelocationDataList();
|
||||
for (auto const &reloc: relocationData) {
|
||||
for (auto const &reloc : relocationData) {
|
||||
if (!DynamicLinkingHelper::addRelocationEntry(&(moduleInformation->linking_data), module_data->linking_entries,
|
||||
DYN_LINK_RELOCATION_LIST_LENGTH, reloc)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add relocation entry\n");
|
||||
@@ -24,15 +24,15 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
|
||||
}
|
||||
|
||||
auto exportData = module->getExportDataList();
|
||||
for (auto const &curExport: exportData) {
|
||||
for (auto const &curExport : exportData) {
|
||||
bool found = false;
|
||||
for (auto &export_entry: module_data->export_entries) {
|
||||
for (auto &export_entry : module_data->export_entries) {
|
||||
if (export_entry.address == 0) {
|
||||
export_entry.type = curExport->getType();
|
||||
export_entry.type = curExport->getType();
|
||||
export_entry.name[0] = '\0';
|
||||
strncat(export_entry.name, curExport->getName().c_str(), sizeof(export_entry.name) - 1);
|
||||
export_entry.address = (uint32_t) curExport->getAddress();
|
||||
found = true;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -43,13 +43,13 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
|
||||
}
|
||||
|
||||
auto hookData = module->getHookDataList();
|
||||
for (auto const &curHook: hookData) {
|
||||
for (auto const &curHook : hookData) {
|
||||
bool found = false;
|
||||
for (auto &hook_entry: module_data->hook_entries) {
|
||||
for (auto &hook_entry : module_data->hook_entries) {
|
||||
if (hook_entry.target == 0) {
|
||||
hook_entry.type = curHook->getType();
|
||||
hook_entry.type = curHook->getType();
|
||||
hook_entry.target = (uint32_t) curHook->getTarget();
|
||||
found = true;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -63,36 +63,36 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
|
||||
|
||||
uint32_t entryCount = module->getFunctionSymbolDataList().size();
|
||||
if (entryCount > 0) {
|
||||
auto ptr = &moduleInformation->function_symbols[moduleInformation->number_used_function_symbols];
|
||||
auto ptr = &moduleInformation->function_symbols[moduleInformation->number_used_function_symbols];
|
||||
module_data->function_symbol_entries = ptr;
|
||||
|
||||
uint32_t sym_offset = 0;
|
||||
for (auto &curFuncSym: module->getFunctionSymbolDataList()) {
|
||||
for (auto &curFuncSym : module->getFunctionSymbolDataList()) {
|
||||
if (moduleInformation->number_used_function_symbols >= FUNCTION_SYMBOL_LIST_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Function symbol list is full");
|
||||
break;
|
||||
}
|
||||
module_data->function_symbol_entries[sym_offset].address = curFuncSym->getAddress();
|
||||
module_data->function_symbol_entries[sym_offset].name = (char *) curFuncSym->getName();
|
||||
module_data->function_symbol_entries[sym_offset].size = curFuncSym->getSize();
|
||||
module_data->function_symbol_entries[sym_offset].name = (char *) curFuncSym->getName();
|
||||
module_data->function_symbol_entries[sym_offset].size = curFuncSym->getSize();
|
||||
|
||||
sym_offset++;
|
||||
moduleInformation->number_used_function_symbols++;
|
||||
}
|
||||
module_data->number_used_function_symbols = sym_offset;
|
||||
} else {
|
||||
module_data->function_symbol_entries = nullptr;
|
||||
module_data->function_symbol_entries = nullptr;
|
||||
module_data->number_used_function_symbols = 0;
|
||||
}
|
||||
|
||||
module_data->bssAddr = module->getBSSAddr();
|
||||
module_data->bssSize = module->getBSSSize();
|
||||
module_data->sbssAddr = module->getSBSSAddr();
|
||||
module_data->sbssSize = module->getSBSSSize();
|
||||
module_data->startAddress = module->getStartAddress();
|
||||
module_data->endAddress = module->getEndAddress();
|
||||
module_data->entrypoint = module->getEntrypoint();
|
||||
module_data->skipInitFini = module->isSkipInitFini();
|
||||
module_data->bssAddr = module->getBSSAddr();
|
||||
module_data->bssSize = module->getBSSSize();
|
||||
module_data->sbssAddr = module->getSBSSAddr();
|
||||
module_data->sbssSize = module->getSBSSSize();
|
||||
module_data->startAddress = module->getStartAddress();
|
||||
module_data->endAddress = module->getEndAddress();
|
||||
module_data->entrypoint = module->getEntrypoint();
|
||||
module_data->skipInitFini = module->isSkipInitFini();
|
||||
module_data->initBeforeRelocationDoneHook = module->isInitBeforeRelocationDoneHook();
|
||||
|
||||
moduleInformation->number_used_modules++;
|
||||
@@ -120,7 +120,7 @@ std::vector<std::shared_ptr<ModuleData>> ModuleDataPersistence::loadModuleData(m
|
||||
for (int32_t i = 0; i < module_count; i++) {
|
||||
// Copy data from struct.
|
||||
module_information_single_t *module_data = &(moduleInformation->module_data[i]);
|
||||
auto moduleData = std::make_shared<ModuleData>();
|
||||
auto moduleData = std::make_shared<ModuleData>();
|
||||
moduleData->setBSSLocation(module_data->bssAddr, module_data->bssSize);
|
||||
moduleData->setSBSSLocation(module_data->sbssAddr, module_data->sbssSize);
|
||||
moduleData->setEntrypoint(module_data->entrypoint);
|
||||
@@ -130,7 +130,7 @@ std::vector<std::shared_ptr<ModuleData>> ModuleDataPersistence::loadModuleData(m
|
||||
moduleData->setSkipInitFini(module_data->skipInitFini);
|
||||
moduleData->setInitBeforeRelocationDoneHook(module_data->initBeforeRelocationDoneHook);
|
||||
|
||||
for (auto &export_entrie: module_data->export_entries) {
|
||||
for (auto &export_entrie : module_data->export_entries) {
|
||||
export_data_t *export_entry = &export_entrie;
|
||||
if (export_entry->address == 0) {
|
||||
continue;
|
||||
@@ -139,7 +139,7 @@ std::vector<std::shared_ptr<ModuleData>> ModuleDataPersistence::loadModuleData(m
|
||||
moduleData->addExportData(exportData);
|
||||
}
|
||||
|
||||
for (auto &hook_entry: module_data->hook_entries) {
|
||||
for (auto &hook_entry : module_data->hook_entries) {
|
||||
if (hook_entry.target == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ std::vector<std::shared_ptr<ModuleData>> ModuleDataPersistence::loadModuleData(m
|
||||
moduleData->addHookData(hookData);
|
||||
}
|
||||
|
||||
for (auto &linking_entry: module_data->linking_entries) {
|
||||
for (auto &linking_entry : module_data->linking_entries) {
|
||||
if (linking_entry.destination == nullptr) {
|
||||
break;
|
||||
}
|
||||
@@ -163,14 +163,14 @@ std::vector<std::shared_ptr<ModuleData>> ModuleDataPersistence::loadModuleData(m
|
||||
continue;
|
||||
}
|
||||
auto rplInfo = std::make_shared<ImportRPLInformation>(importEntry->importName, importEntry->isData);
|
||||
auto reloc = std::make_shared<RelocationData>(linking_entry.type, linking_entry.offset, linking_entry.addend, linking_entry.destination, functionEntry->functionName, rplInfo);
|
||||
auto reloc = std::make_shared<RelocationData>(linking_entry.type, linking_entry.offset, linking_entry.addend, linking_entry.destination, functionEntry->functionName, rplInfo);
|
||||
|
||||
moduleData->addRelocationData(reloc);
|
||||
}
|
||||
|
||||
if (module_data->function_symbol_entries != nullptr && module_data->number_used_function_symbols > 0) {
|
||||
for (uint32_t j = 0; j < module_data->number_used_function_symbols; j++) {
|
||||
auto symbol = &module_data->function_symbol_entries[j];
|
||||
auto symbol = &module_data->function_symbol_entries[j];
|
||||
auto functionSymbolData = std::make_shared<FunctionSymbolData>(symbol->name, symbol->address, symbol->size);
|
||||
moduleData->addFunctionSymbolData(functionSymbolData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user