Files
AnyPS5/core/libs/tests/GuestImageAnonymous.cpp
EdouardSenceandClaude Opus 5.5 24d6bfe355 fix(libc): back the main image's writable mappings with anonymous memory on Linux
amdgpu userptr, which RADV uses for VK_EXT_external_memory_host, refuses
file-backed VMAs (libdrm sets AMDGPU_GEM_USERPTR_ANONONLY). The executable's
writable PT_LOAD mappings are file-backed MAP_PRIVATE, so on RADV they are
never imported and become writable image mirrors that every address-based
build compares in full.

At load, libc replaces each rw-p mapping of /proc/self/exe with an anonymous
copy at the same address, before any guest code runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 18:43:37 +02:00

28 lines
907 B
C++

#include "prx/libc/include/GuestAllocations.hpp"
#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <sstream>
#include <string>
static void Require(bool value) { if (!value) std::abort(); }
int initialized = 0x5a5a5a5a;
int main() {
Require(GuestAllocations::GuestAllocationsGeneration_nid_postfix() != 0);
Require(initialized == 0x5a5a5a5a);
initialized = 1;
Require(initialized == 1);
const auto image = std::filesystem::read_symlink("/proc/self/exe").string();
std::ifstream maps("/proc/self/maps");
for (std::string line; std::getline(maps, line);) {
std::istringstream fields(line);
std::string span, permissions, offset, device, inode, path;
fields >> span >> permissions >> offset >> device >> inode >> std::ws;
std::getline(fields, path);
Require(permissions != "rw-p" || path != image);
}
return 0;
}