fix(relinker): skip the input executable when scanning modules for --executable #5512
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5512"
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 zaryabzip on 2026-10-13T21:55:15Z.
What
--executablecannot be combined with a module directory that holds the input executable, for example--module-dir .: the run fails when the other executable is converted (input.elf: Invalid string or symbol tablewith the test fixtures).The module scan skips the input executable (#3850). Since #4786
Convert()runs once per executable and passes the executable it is converting as the file to skip. While an--executableis converted, the scan therefore reads the title's input executable as a guest module. An--executablecannot be in a module directory itself (--executable is in a guest module directory), so the input is the only executable the scan can meet.Convert()now passes the input executable toCli::ReadModulesfor every executable, so the scan skips the same file as before #4786. Runs without--executablepass the same argument as before.Tested
Relinker-only build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Release):guest_module_dirandrelinker_executablesamong them. The five that fail there fail the same way onmain:amd64_only_converter,tls_function_coverage_register_address_loads,linux_entry_argv,linux_executable_exportsandlinux_input_program_headers.guest_module_dirgains one case, run for Linux and Windows output:--module-dir . --executable picker/picker.binwith a module next to the input. It checks that the conversion succeeds, thatpicker.picker.bin.elf/picker.picker.bin.exeis written, and thatapp0/root.prx.guest.prxis the only guest module.mainat the return code check and passes with the fix.tools/check_conventions.py --base origin/mainpasses with this title and body.Not tested: a Windows host, or a title.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T22:13:10Z.
Review: APPROVED
The source change keeps the original input executable excluded while each selected executable is converted, and the added regression exercises the reported case for both Linux and Windows output formats. The author reports the relinker-only suite passing (146/146); the current PR checks also pass. I found no issue in the changed path.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T22:13:23Z.
For clarity, the regression uses
--module-dir . --executable picker/picker.binand checks thatpicker.binis not emitted as a guest module. The preceding review body omitted those literal arguments due to formatting.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T16:25:06Z.
macOS data point plus one edge case on the guard this fix relies on.
Apple M2 Max, macOS 27.2 (26B5091g), AppleClang, Ninja Release, relinker-only (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON). Head9954e58afmerged without conflicts intomaine34c47921.ctest --parallel 8 --timeout 30156/156, includingguest_module_dir.-DCMAKE_OSX_ARCHITECTURES=x86_64):guest_module_dirpasses; the remaining failures are the 6 that fail identically on unmodifiedmainon this machine (Python 3.9 incompatibilities in tools tests, and theguest_module_argsfixture #5362 fixes).--module-dir . --executable picker/picker.bincase with--macosoutput also succeeds: exit 0,outputandpicker.picker.binare x86_64 Mach-O executables, andapp0/root.prx.guest.prxis the only guest module.Edge case (pre-existing, same result on
main): the description notes that an--executablecannot be in a module directory, so the input executable is the only one the scan can meet. That check (main.cpp,std::findovermoduleDirectories) compares paths lexically, while the default APFS volume, like NTFS, is case-insensitive. Spelling the directory with a different case bypasses it, and the scan then reads the other executable as a guest module:--module-dir picker --executable picker/picker.bin--executable is in a guest module directory: picker/picker.bin--module-dir Picker --executable picker/picker.bin.../Picker/picker.bin: Invalid string or symbol table--executable SCE_MODULE/picker.bin(directory issce_module).../sce_module/picker.bin: Invalid string or symbol tableBoth bypassed cases still fail, but with the cryptic error this PR removes, not the explicit one. Comparing with
std::filesystem::equivalent(the module scan already does this for the input executable) would make the check hold on case-insensitive volumes. TheDuplicate guest module directorycheck inNativeModules.cpphas the same lexical compare. Out of scope here; mentioning it because the fix's reasoning depends on that check.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T21:36:35Z.
Checked on the PR merged onto current
main: relinker build + ctest 132/132 green. The newguest_module_dircase fails without themain.cppchange and passes with it. Passingargs.inputPathrestores the pre-#4786 skip and leaves runs without--executableunchanged. Merging once the full Build is green.