mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-28 12:05:06 +00:00
guest_flexible_memory_declared loads a host-built .guest.prx fixture whose 512 MiB array must count against the flexible memory budget. On macOS, dl_iterate_phdr reports only images that carry the relinker's __APS5DATA,__meta program headers, which every relinked guest module has but the host-built fixture does not. GuestImageSegmentBytes left the fixture out and the test failed at its budget check. On macOS the fixture now fills its own __APS5DATA,__meta at load with one PT_LOAD header for the array, as ProcessParametersFixture does for the test program. Linux and Windows are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
#ifdef __APPLE__
|
|
#include "prx/libc/include/specifics/linux/ElfTypes.hpp"
|
|
#include <dlfcn.h>
|
|
#include <cstring>
|
|
#endif
|
|
|
|
extern "C" {
|
|
unsigned char guestFlexibleMemoryModuleData[512u * 1024u * 1024u] = {};
|
|
}
|
|
|
|
#ifdef __APPLE__
|
|
namespace {
|
|
|
|
[[gnu::section("__APS5DATA,__meta"), gnu::used]] alignas(8) std::byte metadata[0x60 + sizeof(Elf64_Phdr)]{};
|
|
|
|
[[maybe_unused]] const bool described = [] {
|
|
Dl_info image{};
|
|
if (dladdr(guestFlexibleMemoryModuleData, &image) == 0) return false;
|
|
const std::uint64_t loadBias = reinterpret_cast<std::uintptr_t>(image.dli_fbase);
|
|
Elf64_Phdr header{};
|
|
header.p_type = PT_LOAD;
|
|
header.p_flags = PF_R | PF_W;
|
|
header.p_offset = reinterpret_cast<std::uintptr_t>(guestFlexibleMemoryModuleData) - loadBias;
|
|
header.p_vaddr = header.p_offset;
|
|
header.p_paddr = header.p_offset;
|
|
header.p_memsz = sizeof(guestFlexibleMemoryModuleData);
|
|
const std::uint64_t version = 2;
|
|
const std::uint64_t count = 1;
|
|
std::memcpy(metadata + 0x08, &loadBias, sizeof(loadBias));
|
|
std::memcpy(metadata + 0x58, &count, sizeof(count));
|
|
std::memcpy(metadata + 0x60, &header, sizeof(header));
|
|
std::memcpy(metadata, &version, sizeof(version));
|
|
return true;
|
|
}();
|
|
|
|
}
|
|
#endif
|