Repository navigation
fix(relinker): load Linux executables at 0x400000 by default - #8973
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Independent conversion check on public homebrew. Conversion only, nothing was run. Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release. Base: For all 18:
Six other ps5-payload-dev images (four AI-assisted: yes (Claude Code). |
|
Thanks for running that, it covers a lot more real inputs than my fixtures did. Good to see |
|
Correction to my count above: the check covered 21 distinct ELFs, not 18. gdbsrv and klogsrv were each converted in two versions (the v0.9 release assets and the pacbrew-repo v0.41.1 daemons bundle), which I had counted once. Every result listed above holds for all 21. |
CnRJay
left a comment
There was a problem hiding this comment.
The failure it targets is real and has a precedent (#4237 did this for Windows: titles that ship their own libc.prx create an mspace over a static buffer, and sceLibcMspaceCreate rejects a buffer at or above 2^40), and the verify-output handling (linux_base written to the patches file, ET_EXEC without it an error) is carefully done. Turning it on by default for every Linux conversion is a bigger step than the evidence supports yet.
- "No title run on my side." The title evidence is from other threads and says Monster Hunter Wilds gets past start-up with
0x400000or0x400000000, and VLC and XPSemu need exactly0x400000. So0x400000is shown to be necessary for two homebrew titles and sufficient for none of the retail ones named. Please get one title that hits the mspace check on the default base (Monster Hunter Wilds, PPSA24191) to boot on the default output of this branch, with the log line, and cite it. Without that the PR changes the default for all Linux output on the strength of CI tests that relink synthetic executables. - The fixed base is only safe while nothing else maps there. A non-PIE image at
0x400000collides with anything the host places low (a title with a large static image, a preload, a differentvm.mmap_min_addr, a compatibility layer).--linux-fixed-basemade that the user's explicit choice; making it the default makes it every user's failure mode. State what happens when the image doesn't fit before the arena at0x200000000(a title with a very large executable), and add a test with an image that spans the range. --lazy-bindingkeeps the PIE layout, so a title that needs lazy binding does not get the fix. Say that in the usage text and have the converter warn when both conditions apply, since a user will hit the original mspace failure again with no hint.- The reported addresses stay the manifest's
vawhile the process runs atva + linux_base;APS5_TRACE_CALLSprintsapp.elf+<absolute address>for it. The PR notes this as a separate libc change. Because the default now produces this for every Linux title, tools and logs that parse those lines will see different numbers from the same executable. A one-line note in USAGE and a follow-up issue number would help.
c4a116f to
123ba70
Compare
|
Thanks for going through it this carefully. I pushed A title on the default output. I don't have Monster Hunter Wilds, so I can't run it myself. The default output of this branch is byte-identical to An image that doesn't fit before the arena. On On the other collisions:
Trace offsets. #8974 is that follow-up. It counts the offset from the image's first loaded page, so an Relinker CI on the new head passes on Ubuntu (which runs the converted executables), Windows, both macOS jobs and ASan. |
jotitadev
left a comment
There was a problem hiding this comment.
Apple-side run of the test suite for this PR. No Apple result was on the thread yet: the independent check above was a Windows conversion smoke-test (byte-identical --macos/--windows/--lazy-binding), and the author reports Linux only.
Machine: Apple M2 Max, macOS 27.2.
Head: 123ba7083, merged onto main a6dcea9279 (clean merge). Relinker-only Release.
- arm64 native: ctest 229/229 (Python test drivers on 3.14).
- x86_64 under Rosetta 2 (
-DCMAKE_OSX_ARCHITECTURES=x86_64 -DPython3_EXECUTABLE=/usr/bin/python3, Python 3.9.6): ctest 229/229. The relinker binary itself runs under Rosetta and produces the same output the suite expects.
Red/green on the relinker binary (ran this PR's updated test drivers against a main a6dcea9279 relinker built without the change):
test_linux_fixed_base→a relink without the option is not placed at 0x400000test_game_patches→ expectedlinux_base = 0x400000not in the dumped patch inputstest_executable_tls_relocations,test_none_relocations,test_overlapping_relocations,test_optional_rela,test_sce_relro,test_linux_eh_frame_header→ rebasing assertions fail (the base no longer defaults to0x400000, so the rebased addresses the tests check diverge).
All of them pass against the PR binary on both arches. The default-0x400000 change and its rebasing are covered by the suite on Apple Silicon and under Rosetta.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
|
Not a review. This is evidence from a branch I had prepared for #7972 and dropped, because this PR was there first. It made the same change, but at a different base:
That was |
|
Thanks, this is the catalog-wide check the review asked for, even if at the other base. 111 titles with no repeatable regression from a fixed low base is the strongest answer yet to the "every Linux title" concern. The |
boykopovar#9332 made 0x400000 the default base of Windows executables, as boykopovar#8973 did on Linux, so the three titles that read their GOT at that base no longer need fixed_base in titles.json: with a plain relink their guest image starts at 0x400000 and all three render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
boykopovar#9332 made 0x400000 the default base of Windows executables, as boykopovar#8973 did on Linux, so the three titles that read their GOT at that base no longer need fixed_base in titles.json: with a plain relink their guest image starts at 0x400000 and all three render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
boykopovar#9332 made 0x400000 the default base of Windows executables, as boykopovar#8973 did on Linux, so the three titles that read their GOT at that base no longer need fixed_base in titles.json: with a plain relink their guest image starts at 0x400000 and all three render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
boykopovar#9332 made 0x400000 the default base of Windows executables, as boykopovar#8973 did on Linux, so the three titles that read their GOT at that base no longer need fixed_base in titles.json: with a plain relink their guest image starts at 0x400000 and all three render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Linux output is a PIE that the loader puts at
0x5555..., above 2^40. Titles that ship their ownlibc.prxcreate an mspace over a static buffer inside the executable, and thatsceLibcMspaceCreaterejects a buffer at or above 2^40 (#3043). Start-up then fails beforemain. #4237 fixed this for Windows by loading the executable low by default; on Linux it still needs--linux-fixed-base, which the web converter doesn't expose at all.This makes
0x400000the default Linux base, using the existing fixed-base path from #4593 (ET_EXEC, every address rebased). Why0x400000rather than the Windows0x140000000:0x400000+ offset (Ruffle, VLC and XPSemu read their GOT at a fixed 0x400000 base from app0/imports.txt and fault once all imports load #4013) and run on a PS5;0x200000000);0x140000000and0x400000000both are.Details:
--linux-fixed-basestill picks another address.--lazy-bindingkeeps the PIE layout, since its PLT slots can't be rebased (same reason the two options already conflict), and the converter warns when it does that for Linux output. Bundled modules are unchanged.Entry stub call exceeds rel32 range), so at the default base the executable ends below the guest arena at0x200000000.test_linux_fixed_basepins both, and the debt entry says it.Relinker::Conversion, so the web converter gets it too.--verify-outputrefusedET_EXEC, which would have made it useless on default output. The conversion now writeslinux_baseto<output>.patches.tomlwhen the executable isET_EXEC, and--verify-outputchecks entries atva + linux_base. AnET_EXECoutput withoutlinux_base, or anET_DYNoutput with it, is an error. Reported addresses stay the manifest'sva.test_linux_fixed_basepins the default (byte-identical to--linux-fixed-base 0x400000), compares two bases instead of PIE vs fixed, and checks that--lazy-bindingstaysET_DYN.MappedImageinElfFixture.hppplaced segments at their vaddr counted from 0, so it now counts from the image's first page (no change for PIE images).Not in this PR: JIT memory within 2 GiB of the code (#5217) is still out of reach, since the arena starts at 8 GiB. PPSA99808 asks for a fixed mapping at
0x400000(libkernel debt); that is refused today because it's outside the arena, and it still is.APS5_TRACE_CALLSprints a caller in anET_EXECexecutable asapp.elf+<absolute address>, because it takes the offset fromdlpi_addr. That already happens with--linux-fixed-base; #8974 counts it from the image's first page instead.Tested
No title run on my side; I don't have these titles. The title evidence is from the bring-up threads: in #7972 and #7852, Monster Hunter Wilds (PPSA24191) stops at the mspace check on the default base and gets past start-up with
--linux-fixed-base 0x400000or0x400000000. VLC (#5732) and XPSemu (#5600) need exactly0x400000.123ba7083rebased onmain950388bfd: the relinker CI matrix on this PR passes (Ubuntu, which runs the converted executables, Windows, macOS arm64 and x86_64, ASan).test_linux_fixed_basenow also checks the--lazy-bindingwarning and the largest accepted image.c4a116f62:ANYPS5_ENABLE_SPIRV_TOOLS=ON), tests on lavapipe withANYPS5_REQUIRE_VULKAN=1, run on my fork for this branch and for its base7ab4b2e56: 1775/1779 on both, and the same four fail on both (agc_driver_sgpr_pattern_fill_keys,net_dontwait_blocking_send,net_dontwait_blocking_sendmsg,net_dontwait_blocking_sendto). The tests that relink an executable and run it against the real libraries pass at the new default:loadexec_arguments,agc_driver_guest_memory_lifetime_converted,linux_executable_exports,linux_entry_argv,linux_fixed_base,game_patches.to_intel_linux_stubscrashed before theMappedImagefix.check_conventions.pypasses.pr_overlap.pyreports no conflicting lines; the shared files it couldn't compare belong to PRs that conflict withmain.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)