fix(relinker): accept the input's directory as a module directory #3850
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3850"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-11T17:58:18Z.
What
--module-dir .did not work for modules kept next to the executable, the layout Hades (PPSA03355) uses forlibfmod.prxandlibfmodstudio.prx, which it loads withdlopen("/app0/libfmod.prx")(#2724). Three problems:ELF is not a shared module, reported in #2724). The input executable is now skipped when scanning module directories.app0/./<name>.guest.prxas output, runtime and LinuxDT_NEEDEDpath. They now getapp0/<name>.guest.prx, which is wheredlopenlooks (<requested path>.guest.prx,DynamicLoader.cpp:131). One helper builds the path for both uses.(root / ".").lexically_normal()keeps a trailing separator, so the directory did not match the module's parent and the module was not treated as runtime-loaded (it went into LinuxDT_NEEDEDand was started without start arguments). #3509 fixes that normalization; this branch carries its commit unchanged.Non-ELF files are still skipped, and the scan stays non-recursive, so
sce_sys/and dump folders are not walked (#2708).USAGE.mddocuments..Tested
Ubuntu 24.04, GCC 13.3.0, relinker-only build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Release): 114/114 tests pass.guest_module_dirgains two cases, run for both Linux and Windows output:--module-dir .: it is written toapp0/root.prx.guest.prx, stays out ofDT_NEEDEDon Linux, and exports__aps5_guest_initializeon Windows;DT_NEEDEDis$ORIGIN/app0/needed.prx.guest.prx.input.elf: Invalid string or symbol table), and with only the scan fix the path is$ORIGIN/app0/./root.prx.guest.prx.relinker --windows --module-dir . game/eboot.elf app.exewithlibfmod.prxnext toeboot.elf: it writesgame/app0/libfmod.prx.guest.prx. A second Linux run with the output.elfinside the module directory stops with the existing "Executable output would overwrite an input module" error. The output is deliberately not skipped by the scan, since skipping it would bypass that guard when the output path names a real module. An earlier relinked output left in a module directory is scanned like any other ELF there (true of every--module-dir), so the output belongs outside the game directory.tools/check_conventions.pyfrommainpasses on this branch with this title and body.Not tested: Windows host (the
.exerun in the test only runs on Windows) or the title itself. I don't have a Hades dump. The reporter's workaround in #2724 (copying the.guest.prxfiles toapp0/) is the layout this change produces.Checklist
What
--module-dir .did not work for modules kept next to the executable, the layout Hades (PPSA03355) uses forlibfmod.prxandlibfmodstudio.prx, which it loads withdlopen("/app0/libfmod.prx")(#2724). Three problems:ELF is not a shared module, reported in #2724). The input executable is now skipped when scanning module directories.app0/./<name>.guest.prxas output, runtime and LinuxDT_NEEDEDpath. They now getapp0/<name>.guest.prx, which is wheredlopenlooks (<requested path>.guest.prx,DynamicLoader.cpp:131). One helper builds the path for both uses.(root / ".").lexically_normal()keeps a trailing separator, so the directory did not match the module's parent and the module was not treated as runtime-loaded (it went into LinuxDT_NEEDEDand was started without start arguments). #3509 fixes that normalization; this branch carries its commit unchanged.Non-ELF files are still skipped, and the scan stays non-recursive, so
sce_sys/and dump folders are not walked (#2708).USAGE.mddocuments..Tested
Ubuntu 24.04, GCC 13.3.0, relinker-only build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Release): 114/114 tests pass.guest_module_dirgains two cases, run for both Linux and Windows output:--module-dir .: it is written toapp0/root.prx.guest.prx, stays out ofDT_NEEDEDon Linux, and exports__aps5_guest_initializeon Windows;DT_NEEDEDis$ORIGIN/app0/needed.prx.guest.prx.input.elf: Invalid string or symbol table), and with only the scan fix the path is$ORIGIN/app0/./root.prx.guest.prx.relinker --windows --module-dir . game/eboot.elf app.exewithlibfmod.prxnext toeboot.elf: it writesgame/app0/libfmod.prx.guest.prx. A second Linux run with the output.elfinside the module directory stops with the existing "Executable output would overwrite an input module" error. The output is deliberately not skipped by the scan, since skipping it would bypass that guard when the output path names a real module. An earlier relinked output left in a module directory is scanned like any other ELF there (true of every--module-dir), so the output belongs outside the game directory.tools/check_conventions.pyfrommainpasses on this branch with this title and body.Not tested: Windows host (the
.exerun in the test only runs on Windows) or the title itself. I don't have a Hades dump. The reporter's workaround in #2724 (copying the.guest.prxfiles toapp0/) is the layout this change produces.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Fixes #2724
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-11T21:33:51Z.
Windows test of this PR with Hades (PPSA03355), as asked in #2724: Windows 10, MinGW/Ninja Release build of
mainc5da8233awith this PR merged in (merge was clean), relinked from the reconstructed ELF with--windows --registry --module-dir .(the input directory holdseboot.elf,sce_module/and the two root-level modules).app0/libfmod.prx.guest.prxandapp0/libfmodstudio.prx.guest.prxare written at theapp0root, where the title'sdlopen("/app0/libfmod.prx")looks. I did not copy anything by hand.dlopenfailure from #2724) is gone. The title opens about 1200 files, mounts its save data and compiles shaders (223 shaders in the first 10 s).RenderThread(unhandled exception 0xc0000005,libc.prx.guest.prx+0x13a15, write of0x0): a title loop atapp.exe+0x318059calls amemcpy-like routine for 0x1830 bytes with a null destination (rdi = 0, base pointer read from the loop's stack frame). That is a separate stop that I have not explained; I will put it on #2724.Not tested: Linux, and a run without
.(the old workaround layout) for comparison.AI-assisted (Claude Code).