diff --git a/README.md b/README.md index 6ed5a3e87..7fa52594e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Converter for native execution of PlayStation 5 ELF binaries on Linux through bi ## Status -Execution reaches `_start`, stack unwinding and exception handling tables are built. All unimplemented stub functions throw std::runtime_error. `what()` is printed to stderr and the process terminates. Now: `memset_nid_postfix not implemented` +Execution reaches `_start`, stack unwinding and exception handling tables are built. All unimplemented stub functions throw std::runtime_error. `what()` is printed to stderr and the process terminates. Now: `sceSysmoduleLoadModule not implemented` ## Disclaimer diff --git a/core/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp b/core/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp index 4d722ebdc..36245adee 100644 --- a/core/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp +++ b/core/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp @@ -92,6 +92,7 @@ Domain::ProgramHeader ProgramHeaderLayoutBuilder::_makeInterpHeader(std::uint64_ } std::uint32_t ProgramHeaderLayoutBuilder::_fixLoadFlags(std::uint32_t originalFlags) const { + if (originalFlags == 0) return PF_R | PF_W | PF_X; return originalFlags | PF_R; } diff --git a/core/libs/prx/libc/src/Strings.cpp b/core/libs/prx/libc/src/Strings.cpp index 420b6bf64..c103088a3 100644 --- a/core/libs/prx/libc/src/Strings.cpp +++ b/core/libs/prx/libc/src/Strings.cpp @@ -8,7 +8,6 @@ extern "C" { void* memset_nid_postfix(void* s, int c, size_t n) { - NotImplemented_nid_no_patch(__func__); fprintf(stderr, "memset_nid_postfix: s=%p c=%d n=%zu\n", s, c, n); return std::memset(s, c, n); } diff --git a/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp b/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp index 2b3c2ac77..bf5d0d964 100644 --- a/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp +++ b/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp @@ -8,6 +8,7 @@ static int LinuxProtFromSce(int prot) { if (prot & 1) result |= PROT_READ; if (prot & 2) result |= PROT_WRITE; if (prot & 4) result |= PROT_EXEC; + if (prot & ~7) result |= PROT_EXEC; return result; } @@ -25,6 +26,18 @@ int DoMapDirect(void** addr, size_t len, int prot, int flags, int64_t physStart, void* result = mmap(hint, len, LinuxProtFromSce(prot), mmapFlags, -1, 0); if (result == MAP_FAILED) return SCE_KERNEL_ERROR_ENOMEM; fprintf(stderr, "DoMapDirect: mmap result=%p linuxProt=%d\n", result, LinuxProtFromSce(prot)); + FILE* f = fopen("/proc/self/maps", "r"); + if (f) { + char line[256]; + while (fgets(line, sizeof(line), f)) { + uintptr_t start, end; + if (sscanf(line, "%lx-%lx", &start, &end) == 2) { + uintptr_t r = reinterpret_cast(result); + if (r >= start && r < end) { fprintf(stderr, "maps: %s", line); break; } + } + } + fclose(f); + } *addr = result; return 0; }