Formatting

This commit is contained in:
Maschell 2021-09-23 18:30:08 +02:00
parent ba389535a9
commit 57163d6103
8 changed files with 18 additions and 11 deletions

View File

@ -22,7 +22,8 @@
#include "ElfUtils.h"
// 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) {
return true;
}

View File

@ -59,5 +59,6 @@ extern "C" {
class ElfUtils {
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);
};

View File

@ -16,6 +16,7 @@
****************************************************************************/
#pragma once
#include <cstdint>
typedef enum RelocationTrampolinStatus{

View File

@ -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) {
for (auto const &curReloc : relocData) {
const RelocationData& cur = curReloc;
for (auto const &curReloc: relocData) {
const RelocationData &cur = curReloc;
std::string functionName = cur.getName();
std::string rplName = cur.getImportRPLInformation().getName();
int32_t isData = cur.getImportRPLInformation().isData();

View File

@ -20,7 +20,7 @@
std::string ModuleData::toString() const {
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();
}
return res;

View File

@ -25,7 +25,8 @@
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;
ModuleData moduleData;
@ -37,7 +38,7 @@ std::optional<ModuleData> ModuleDataFactory::load(const std::string &path, uint3
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;
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);
for (auto const &reloc : relocationData) {
for (auto const &reloc: relocationData) {
moduleData.addRelocationData(reloc);
}
@ -202,7 +203,8 @@ std::vector<RelocationData> ModuleDataFactory::getImportRelocationData(const elf
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();
for (uint32_t i = 0; i < sec_num; ++i) {

View File

@ -28,7 +28,8 @@ class ModuleDataFactory {
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 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);
};

View File

@ -19,5 +19,6 @@
#include "utils/StringTools.h"
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());
}