mirror of
https://github.com/wiiu-env/CustomRPXLoader.git
synced 2024-11-15 23:15:06 +01:00
Formatting
This commit is contained in:
parent
ba389535a9
commit
57163d6103
@ -22,7 +22,8 @@
|
|||||||
#include "ElfUtils.h"
|
#include "ElfUtils.h"
|
||||||
|
|
||||||
// See https://github.com/decaf-emu/decaf-emu/blob/43366a34e7b55ab9d19b2444aeb0ccd46ac77dea/src/libdecaf/src/cafe/loader/cafe_loader_reloc.cpp#L144
|
// See https://github.com/decaf-emu/decaf-emu/blob/43366a34e7b55ab9d19b2444aeb0ccd46ac77dea/src/libdecaf/src/cafe/loader/cafe_loader_reloc.cpp#L144
|
||||||
bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length, RelocationType reloc_type) {
|
bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,
|
||||||
|
RelocationType reloc_type) {
|
||||||
if (type == R_PPC_NONE) {
|
if (type == R_PPC_NONE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -59,5 +59,6 @@ extern "C" {
|
|||||||
class ElfUtils {
|
class ElfUtils {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length, RelocationType reloc_type);
|
static bool elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,
|
||||||
|
RelocationType reloc_type);
|
||||||
};
|
};
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
typedef enum RelocationTrampolinStatus{
|
typedef enum RelocationTrampolinStatus{
|
||||||
|
@ -181,8 +181,8 @@ int do_start(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length) {
|
bool doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length) {
|
||||||
for (auto const &curReloc : relocData) {
|
for (auto const &curReloc: relocData) {
|
||||||
const RelocationData& cur = curReloc;
|
const RelocationData &cur = curReloc;
|
||||||
std::string functionName = cur.getName();
|
std::string functionName = cur.getName();
|
||||||
std::string rplName = cur.getImportRPLInformation().getName();
|
std::string rplName = cur.getImportRPLInformation().getName();
|
||||||
int32_t isData = cur.getImportRPLInformation().isData();
|
int32_t isData = cur.getImportRPLInformation().isData();
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
std::string ModuleData::toString() const {
|
std::string ModuleData::toString() const {
|
||||||
std::string res = StringTools::strfmt("Entrypoint %08X, bss: %08X (%d), bss: %08X (%d)\n", getEntrypoint(), getBSSAddr(), getBSSSize(), getSBSSAddr(), getSBSSSize());
|
std::string res = StringTools::strfmt("Entrypoint %08X, bss: %08X (%d), bss: %08X (%d)\n", getEntrypoint(), getBSSAddr(), getBSSSize(), getSBSSAddr(), getSBSSSize());
|
||||||
for (auto const &reloc : relocation_data_list) {
|
for (auto const &reloc: relocation_data_list) {
|
||||||
res += reloc.toString();
|
res += reloc.toString();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
|
|
||||||
using namespace ELFIO;
|
using namespace ELFIO;
|
||||||
|
|
||||||
std::optional<ModuleData> ModuleDataFactory::load(const std::string &path, uint32_t destination_address, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length) {
|
std::optional<ModuleData>
|
||||||
|
ModuleDataFactory::load(const std::string &path, uint32_t destination_address, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length) {
|
||||||
elfio reader;
|
elfio reader;
|
||||||
ModuleData moduleData;
|
ModuleData moduleData;
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ std::optional<ModuleData> ModuleDataFactory::load(const std::string &path, uint3
|
|||||||
|
|
||||||
uint32_t sec_num = reader.sections.size();
|
uint32_t sec_num = reader.sections.size();
|
||||||
|
|
||||||
auto **destinations = (uint8_t **) malloc(sizeof(uint8_t *) * sec_num);
|
auto **destinations = (uint8_t **) malloc(sizeof(uint8_t * ) * sec_num);
|
||||||
|
|
||||||
uint32_t sizeOfModule = 0;
|
uint32_t sizeOfModule = 0;
|
||||||
for (uint32_t i = 0; i < sec_num; ++i) {
|
for (uint32_t i = 0; i < sec_num; ++i) {
|
||||||
@ -133,7 +134,7 @@ std::optional<ModuleData> ModuleDataFactory::load(const std::string &path, uint3
|
|||||||
}
|
}
|
||||||
std::vector<RelocationData> relocationData = getImportRelocationData(reader, destinations);
|
std::vector<RelocationData> relocationData = getImportRelocationData(reader, destinations);
|
||||||
|
|
||||||
for (auto const &reloc : relocationData) {
|
for (auto const &reloc: relocationData) {
|
||||||
moduleData.addRelocationData(reloc);
|
moduleData.addRelocationData(reloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +203,8 @@ std::vector<RelocationData> ModuleDataFactory::getImportRelocationData(const elf
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleDataFactory::linkSection(const elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length) {
|
bool ModuleDataFactory::linkSection(const elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data,
|
||||||
|
uint32_t trampolin_data_length) {
|
||||||
uint32_t sec_num = reader.sections.size();
|
uint32_t sec_num = reader.sections.size();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < sec_num; ++i) {
|
for (uint32_t i = 0; i < sec_num; ++i) {
|
||||||
|
@ -28,7 +28,8 @@ class ModuleDataFactory {
|
|||||||
public:
|
public:
|
||||||
static std::optional<ModuleData> load(const std::string &path, uint32_t destination_address, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
static std::optional<ModuleData> load(const std::string &path, uint32_t destination_address, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
||||||
|
|
||||||
static bool linkSection(const ELFIO::elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
static bool linkSection(const ELFIO::elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data,
|
||||||
|
uint32_t trampolin_data_length);
|
||||||
|
|
||||||
static std::vector<RelocationData> getImportRelocationData(const ELFIO::elfio &reader, uint8_t **destinations);
|
static std::vector<RelocationData> getImportRelocationData(const ELFIO::elfio &reader, uint8_t **destinations);
|
||||||
};
|
};
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
#include "utils/StringTools.h"
|
#include "utils/StringTools.h"
|
||||||
|
|
||||||
std::string RelocationData::toString() const {
|
std::string RelocationData::toString() const {
|
||||||
return StringTools::strfmt("%s destination: %08X offset: %08X type: %02X addend: %d rplName: %s isData: %d \n", name.c_str(), destination, offset, type, addend, rplInfo.getName().c_str(), rplInfo.isData());
|
return StringTools::strfmt("%s destination: %08X offset: %08X type: %02X addend: %d rplName: %s isData: %d \n", name.c_str(), destination, offset, type, addend, rplInfo.getName().c_str(),
|
||||||
|
rplInfo.isData());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user