fix(relinker): keep host prx references out of guest modules on Linux

On Linux every module resolves its references through one global scope,
and the guest modules are listed ahead of the host prx. When a title
bundles its own libc.prx, the host libc and the other host prx bound
their references to their own NIDs to the guest libc, so the host libc
built its standard streams on top of the guest _Stdout.

The exports of guest modules, and the guest and executable imports that
a guest module satisfies, now carry a #guest suffix. The title's imports
still reach the guest modules first, and a host prx only sees host
definitions, as on Windows. sceKernelDlsym also looks for the suffixed
name.
This commit is contained in:
Nahuel Genchi
2026-10-05 10:58:01 -03:00
parent bc24783e5b
commit 5fab03e4e5
7 changed files with 176 additions and 0 deletions
+11
View File
@@ -1,4 +1,5 @@
#include "prx/libc/include/general/VabiMacros.hpp"
#include "prx/libc/include/general/ExportMacros.hpp"
#ifdef _WIN32
#define MODULE_EXPORT __declspec(dllexport)
#else
@@ -7,3 +8,13 @@
extern "C" MODULE_EXPORT int APS5_VABI GuestModuleAdd_nid_postfix(int a, int b) {
return a + b;
}
#ifndef _WIN32
extern "C" MODULE_EXPORT int APS5_VABI GuestModuleMul_nid_no_patch(int a, int b) {
return a * b;
}
APS5_EXPORT("GuestModuleMul#guest", GuestModuleMul_nid_no_patch);
extern "C" MODULE_EXPORT int APS5_VABI GuestModuleSub_nid_no_patch(int a, int b) {
return a - b;
}
APS5_EXPORT("BOyBJaKwOa8#guest", GuestModuleSub_nid_no_patch);
#endif