From 075eac626b162dd2e23ae337860f4717bf3041fe Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sat, 6 Apr 2024 22:13:19 +0200 Subject: [PATCH] ELF: Fix crash due to not allocating recompiler ranges (#1154) --- src/Cafe/OS/RPL/elf.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Cafe/OS/RPL/elf.cpp b/src/Cafe/OS/RPL/elf.cpp index c61afb21..7ee3ba47 100644 --- a/src/Cafe/OS/RPL/elf.cpp +++ b/src/Cafe/OS/RPL/elf.cpp @@ -50,6 +50,10 @@ typedef struct static_assert(sizeof(elfSectionEntry_t) == 0x28, ""); +#define PF_X (1 << 0) /* Segment is executable */ +#define PF_W (1 << 1) /* Segment is writable */ +#define PF_R (1 << 2) /* Segment is readable */ + // Map elf into memory uint32 ELF_LoadFromMemory(uint8* elfData, sint32 size, const char* name) { @@ -68,6 +72,7 @@ uint32 ELF_LoadFromMemory(uint8* elfData, sint32 size, const char* name) uint32 shSize = (uint32)sectionTable[i].shSize; uint32 shOffset = (uint32)sectionTable[i].shOffset; uint32 shType = (uint32)sectionTable[i].shType; + uint32 shFlags = (uint32)sectionTable[i].shFlags; if (shOffset > (uint32)size) { @@ -89,6 +94,8 @@ uint32 ELF_LoadFromMemory(uint8* elfData, sint32 size, const char* name) } // SHT_NOBITS } + if((shFlags & PF_X) > 0) + PPCRecompiler_allocateRange(shAddr, shSize); } return header->entrypoint; }