mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-08 16:18:41 +12:00
Long overdue clang-format pass on most of the project (#773)
Some checks are pending
Android Build / x64 (release) (push) Waiting to run
Android Build / arm64 (release) (push) Waiting to run
HTTP Server Build / build (push) Waiting to run
Hydra Core Build / Windows (push) Waiting to run
Hydra Core Build / MacOS (push) Waiting to run
Hydra Core Build / Linux (push) Waiting to run
Hydra Core Build / Android-x64 (push) Waiting to run
Hydra Core Build / ARM-Libretro (push) Waiting to run
Linux AppImage Build / build (push) Waiting to run
Linux Build / build (push) Waiting to run
MacOS Build / MacOS-arm64 (push) Waiting to run
MacOS Build / MacOS-x86_64 (push) Waiting to run
MacOS Build / MacOS-Universal (push) Blocked by required conditions
Qt Build / Windows (push) Waiting to run
Qt Build / MacOS-arm64 (push) Waiting to run
Qt Build / MacOS-x86_64 (push) Waiting to run
Qt Build / MacOS-Universal (push) Blocked by required conditions
Qt Build / Linux (push) Waiting to run
Windows Build / build (push) Waiting to run
iOS Simulator Build / build (push) Waiting to run
Some checks are pending
Android Build / x64 (release) (push) Waiting to run
Android Build / arm64 (release) (push) Waiting to run
HTTP Server Build / build (push) Waiting to run
Hydra Core Build / Windows (push) Waiting to run
Hydra Core Build / MacOS (push) Waiting to run
Hydra Core Build / Linux (push) Waiting to run
Hydra Core Build / Android-x64 (push) Waiting to run
Hydra Core Build / ARM-Libretro (push) Waiting to run
Linux AppImage Build / build (push) Waiting to run
Linux Build / build (push) Waiting to run
MacOS Build / MacOS-arm64 (push) Waiting to run
MacOS Build / MacOS-x86_64 (push) Waiting to run
MacOS Build / MacOS-Universal (push) Blocked by required conditions
Qt Build / Windows (push) Waiting to run
Qt Build / MacOS-arm64 (push) Waiting to run
Qt Build / MacOS-x86_64 (push) Waiting to run
Qt Build / MacOS-Universal (push) Blocked by required conditions
Qt Build / Linux (push) Waiting to run
Windows Build / build (push) Waiting to run
iOS Simulator Build / build (push) Waiting to run
This commit is contained in:
parent
d1f4ae2911
commit
8e20bd6220
65 changed files with 13445 additions and 26224 deletions
|
@ -1,10 +1,11 @@
|
|||
#include "services/ldr_ro.hpp"
|
||||
#include "ipc.hpp"
|
||||
#include "kernel.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
#include "ipc.hpp"
|
||||
#include "kernel.hpp"
|
||||
|
||||
namespace LDRCommands {
|
||||
enum : u32 {
|
||||
Initialize = 0x000100C2,
|
||||
|
@ -66,10 +67,13 @@ namespace SegmentTable {
|
|||
|
||||
namespace SegmentID {
|
||||
enum : u32 {
|
||||
TEXT, RODATA, DATA, BSS,
|
||||
TEXT,
|
||||
RODATA,
|
||||
DATA,
|
||||
BSS,
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace SegmentTable
|
||||
|
||||
namespace NamedExportTable {
|
||||
enum : u32 {
|
||||
|
@ -119,8 +123,8 @@ namespace RelocationPatch {
|
|||
enum : u32 {
|
||||
SegmentOffset = 0,
|
||||
PatchType = 4,
|
||||
IsLastEntry = 5, // For import patches
|
||||
SegmentIndex = 5, // For relocation patches
|
||||
IsLastEntry = 5, // For import patches
|
||||
SegmentIndex = 5, // For relocation patches
|
||||
IsResolved = 6,
|
||||
Addend = 8,
|
||||
};
|
||||
|
@ -130,7 +134,7 @@ namespace RelocationPatch {
|
|||
AbsoluteAddress = 2,
|
||||
};
|
||||
};
|
||||
};
|
||||
}; // namespace RelocationPatch
|
||||
|
||||
struct CROHeaderEntry {
|
||||
u32 offset, size;
|
||||
|
@ -145,12 +149,12 @@ static const std::string CRR_MAGIC("CRR0");
|
|||
class CRO {
|
||||
Memory &mem;
|
||||
|
||||
u32 croPointer; // Origin address of CRO in RAM
|
||||
u32 croPointer; // Origin address of CRO in RAM
|
||||
u32 oldDataSegmentOffset;
|
||||
|
||||
bool isCRO; // False if CRS
|
||||
bool isCRO; // False if CRS
|
||||
|
||||
public:
|
||||
public:
|
||||
CRO(Memory &mem, u32 croPointer, bool isCRO) : mem(mem), croPointer(croPointer), oldDataSegmentOffset(0), isCRO(isCRO) {}
|
||||
~CRO() = default;
|
||||
|
||||
|
@ -238,7 +242,7 @@ public:
|
|||
|
||||
for (u32 namedExport = 0; namedExport < namedExportTable.size; namedExport++) {
|
||||
const u32 nameOffset = mem.read32(namedExportTable.offset + 8 * namedExport + NamedExportTable::NameOffset);
|
||||
|
||||
|
||||
const std::string exportSymbolName = mem.readString(nameOffset, exportStringSize);
|
||||
|
||||
if (symbolName.compare(exportSymbolName) == 0) {
|
||||
|
@ -713,7 +717,7 @@ public:
|
|||
for (u32 namedImport = 0; namedImport < namedImportTable.size; namedImport++) {
|
||||
const u32 nameOffset = mem.read32(namedImportTable.offset + 8 * namedImport + NamedImportTable::NameOffset);
|
||||
const u32 relocationOffset = mem.read32(namedImportTable.offset + 8 * namedImport + NamedImportTable::RelocationOffset);
|
||||
|
||||
|
||||
const std::string symbolName = mem.readString(nameOffset, importStringSize);
|
||||
|
||||
if (symbolName.compare(std::string("__aeabi_atexit")) == 0) {
|
||||
|
@ -725,7 +729,7 @@ public:
|
|||
const u32 exportSymbolAddr = cro.getNamedExportSymbolAddr(std::string("nnroAeabiAtexit_"));
|
||||
if (exportSymbolAddr != 0) {
|
||||
patchBatch(relocationOffset, exportSymbolAddr);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -755,7 +759,7 @@ public:
|
|||
|
||||
if (isResolved == 0) {
|
||||
const u32 nameOffset = mem.read32(namedImportTable.offset + 8 * namedImport + NamedImportTable::NameOffset);
|
||||
|
||||
|
||||
const std::string symbolName = mem.readString(nameOffset, importStringSize);
|
||||
|
||||
// Check every loaded CRO for the symbol (the pain)
|
||||
|
@ -864,7 +868,7 @@ public:
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool clearModules() {
|
||||
const u32 onUnresolvedAddr = getOnUnresolvedAddr();
|
||||
|
||||
|
@ -879,7 +883,7 @@ public:
|
|||
if (indexedOffset == 0) {
|
||||
Helpers::panic("Indexed symbol offset is NULL");
|
||||
}
|
||||
|
||||
|
||||
const u32 relocationOffset = mem.read32(indexedOffset + 8 * indexedImport + IndexedImportTable::RelocationOffset);
|
||||
|
||||
patchBatch(relocationOffset, onUnresolvedAddr, true);
|
||||
|
@ -924,7 +928,7 @@ public:
|
|||
|
||||
if (isResolved == 0) {
|
||||
const u32 nameOffset = mem.read32(namedImportTable.offset + 8 * namedImport + NamedImportTable::NameOffset);
|
||||
|
||||
|
||||
const std::string symbolName = mem.readString(nameOffset, importStringSize);
|
||||
|
||||
// Check our current CRO for the symbol
|
||||
|
@ -988,7 +992,7 @@ public:
|
|||
u32 currentCROPointer = loadedCRS;
|
||||
while (currentCROPointer != 0) {
|
||||
CRO cro(mem, currentCROPointer, true);
|
||||
|
||||
|
||||
const u32 onUnresolvedAddr = cro.getOnUnresolvedAddr();
|
||||
|
||||
const u32 importStringSize = mem.read32(currentCROPointer + CROHeader::ImportStringSize);
|
||||
|
@ -1003,7 +1007,7 @@ public:
|
|||
|
||||
if (isResolved != 0) {
|
||||
const u32 nameOffset = mem.read32(namedImportTable.offset + 8 * namedImport + NamedImportTable::NameOffset);
|
||||
|
||||
|
||||
const std::string symbolName = mem.readString(nameOffset, importStringSize);
|
||||
|
||||
// Check our current CRO for the symbol
|
||||
|
@ -1111,7 +1115,7 @@ public:
|
|||
}
|
||||
|
||||
CRO crs(mem, loadedCRS, false);
|
||||
|
||||
|
||||
u32 headAddr = crs.getPrevCRO();
|
||||
if (autoLink) {
|
||||
headAddr = crs.getNextCRO();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue