fix(relinker): map zero-flag ps5 load segments as rwx
This commit is contained in:
parent
9d4c87b686
commit
bc14e4743c
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<uintptr_t>(result);
|
||||
if (r >= start && r < end) { fprintf(stderr, "maps: %s", line); break; }
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
*addr = result;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue