fix(relinker): load Linux executables at 0x400000 by default #8973

Merged
rooklz merged 1 commit from upstream-pr/8973 into main 2026-10-22 02:24:39 +00:00
rooklz commented 2026-10-21 07:59:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-21T07:59:58Z.


What

Linux output is a PIE that the loader puts at 0x5555..., above 2^40. Titles that ship their own libc.prx create an mspace over a static buffer inside the executable, and that sceLibcMspaceCreate rejects a buffer at or above 2^40 (#3043). Start-up then fails before main. #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 0x400000 the default Linux base, using the existing fixed-base path from #4593 (ET_EXEC, every address rebased). Why 0x400000 rather than the Windows 0x140000000:

  • it's the only console load address we have evidence for: Ruffle, VLC and XPSemu read their GOT at 0x400000 + offset (#4013) and run on a PS5;
  • it's inside the 40-bit window and below the guest arena (0x200000000);
  • it's outside ASan's shadow gap, where 0x140000000 and 0x400000000 both are.

Details:

  • --linux-fixed-base still picks another address. --lazy-binding keeps 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.
  • The relinker already refuses an image that spans 2 GiB or more, with or without this change (Entry stub call exceeds rel32 range), so at the default base the executable ends below the guest arena at 0x200000000. test_linux_fixed_base pins both, and the debt entry says it.
  • The default is applied in Relinker::Conversion, so the web converter gets it too.
  • --verify-output refused ET_EXEC, which would have made it useless on default output. The conversion now writes linux_base to <output>.patches.toml when the executable is ET_EXEC, and --verify-output checks entries at va + linux_base. An ET_EXEC output without linux_base, or an ET_DYN output with it, is an error. Reported addresses stay the manifest's va.
  • Tests that compared Linux output addresses with the input now expect the base. test_linux_fixed_base pins the default (byte-identical to --linux-fixed-base 0x400000), compares two bases instead of PIE vs fixed, and checks that --lazy-binding stays ET_DYN. MappedImage in ElfFixture.hpp placed segments at their vaddr counted from 0, so it now counts from the image's first page (no change for PIE images).
  • USAGE.md and a relinker debt entry describe the default; the gap is that where the console loads an executable that doesn't need an address isn't measured.

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_CALLS prints a caller in an ET_EXEC executable as app.elf+<absolute address>, because it takes the offset from dlpi_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 0x400000 or 0x400000000. VLC (#5732) and XPSemu (#5600) need exactly 0x400000.

  • After review, head 123ba7083 rebased on main 950388bfd: the relinker CI matrix on this PR passes (Ubuntu, which runs the converted executables, Windows, macOS arm64 and x86_64, ASan). test_linux_fixed_base now also checks the --lazy-binding warning and the largest accepted image.
  • Before the review changes, head c4a116f62:
    • Ubuntu 24.04 x86-64 (GitHub-hosted runner), GCC 13.3, full build with the CI configure flags (ANYPS5_ENABLE_SPIRV_TOOLS=ON), tests on lavapipe with ANYPS5_REQUIRE_VULKAN=1, run on my fork for this branch and for its base 7ab4b2e56: 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_stubs crashed before the MappedImage fix.
    • Windows Server 2025 (GitHub-hosted), WinLibs GCC 15.2.0, relinker-only build: 232/232 on this branch and on the base.
    • macOS 26.2 (Apple M5), AppleClang 21, relinker-only build: 228/228.
  • check_conventions.py passes. pr_overlap.py reports no conflicting lines; the shared files it couldn't compare belong to PRs that conflict with main.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA24191 #7972, PPSA85300 #5732, PPSA97358 #5600
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4948345263 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T07:59:58Z. --- ### What Linux output is a PIE that the loader puts at `0x5555...`, above 2^40. Titles that ship their own `libc.prx` create an mspace over a static buffer inside the executable, and that `sceLibcMspaceCreate` rejects a buffer at or above 2^40 (#3043). Start-up then fails before `main`. #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 `0x400000` the default Linux base, using the existing fixed-base path from #4593 (`ET_EXEC`, every address rebased). Why `0x400000` rather than the Windows `0x140000000`: - it's the only console load address we have evidence for: Ruffle, VLC and XPSemu read their GOT at `0x400000` + offset (#4013) and run on a PS5; - it's inside the 40-bit window and below the guest arena (`0x200000000`); - it's outside ASan's shadow gap, where `0x140000000` and `0x400000000` both are. Details: - `--linux-fixed-base` still picks another address. `--lazy-binding` keeps 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. - The relinker already refuses an image that spans 2 GiB or more, with or without this change (`Entry stub call exceeds rel32 range`), so at the default base the executable ends below the guest arena at `0x200000000`. `test_linux_fixed_base` pins both, and the debt entry says it. - The default is applied in `Relinker::Conversion`, so the web converter gets it too. - `--verify-output` refused `ET_EXEC`, which would have made it useless on default output. The conversion now writes `linux_base` to `<output>.patches.toml` when the executable is `ET_EXEC`, and `--verify-output` checks entries at `va + linux_base`. An `ET_EXEC` output without `linux_base`, or an `ET_DYN` output with it, is an error. Reported addresses stay the manifest's `va`. - Tests that compared Linux output addresses with the input now expect the base. `test_linux_fixed_base` pins the default (byte-identical to `--linux-fixed-base 0x400000`), compares two bases instead of PIE vs fixed, and checks that `--lazy-binding` stays `ET_DYN`. `MappedImage` in `ElfFixture.hpp` placed segments at their vaddr counted from 0, so it now counts from the image's first page (no change for PIE images). - USAGE.md and a relinker debt entry describe the default; the gap is that where the console loads an executable that doesn't need an address isn't measured. 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_CALLS` prints a caller in an `ET_EXEC` executable as `app.elf+<absolute address>`, because it takes the offset from `dlpi_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 0x400000` or `0x400000000`. VLC (#5732) and XPSemu (#5600) need exactly `0x400000`. - After review, head `123ba7083` rebased on `main` `950388bfd`: the relinker CI matrix on this PR passes (Ubuntu, which runs the converted executables, Windows, macOS arm64 and x86_64, ASan). `test_linux_fixed_base` now also checks the `--lazy-binding` warning and the largest accepted image. - Before the review changes, head `c4a116f62`: - Ubuntu 24.04 x86-64 (GitHub-hosted runner), GCC 13.3, full build with the CI configure flags (`ANYPS5_ENABLE_SPIRV_TOOLS=ON`), tests on lavapipe with `ANYPS5_REQUIRE_VULKAN=1`, run on my fork for this branch and for its base `7ab4b2e56`: 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_stubs` crashed before the `MappedImage` fix. - Windows Server 2025 (GitHub-hosted), WinLibs GCC 15.2.0, relinker-only build: 232/232 on this branch and on the base. - macOS 26.2 (Apple M5), AppleClang 21, relinker-only build: 228/228. - `check_conventions.py` passes. `pr_overlap.py` reports no conflicting lines; the shared files it couldn't compare belong to PRs that conflict with `main`. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: PPSA24191 #7972, PPSA85300 #5732, PPSA97358 #5600 <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
github-actions[bot] commented 2026-10-21 08:21:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T08:21:53Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 9408 docs/user/USAGE.md L66-67

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.

Pull request Shared files not compared
PR 5021 docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 5925 docs/user/USAGE.md
PR 6171 docs/user/USAGE.md
PR 6788 docs/user/USAGE.md
PR 6924 docs/user/USAGE.md
PR 7594 core/relinker/relinker/tests/test_linux_entry_argv.py
PR 7642 docs/user/USAGE.md
PR 7800 docs/user/USAGE.md
PR 7918 docs/dev/debt/relinker.md
docs/user/USAGE.md
PR 8076 docs/dev/debt/relinker.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311450249 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973#issuecomment-6311450249). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T08:21:53Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 9408](https://www.github.com/boykopovar/AnyPS5/pull/9408) | `docs/user/USAGE.md` [L66-67](https://github.com/boykopovar/AnyPS5/blob/a6dcea9279b53b3a39c13695eac66f7c8b5b503c/docs/user/USAGE.md#L66-L67) | | | 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. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `docs/user/USAGE.md` | | [PR 6171](https://www.github.com/boykopovar/AnyPS5/pull/6171) | `docs/user/USAGE.md` | | [PR 6788](https://www.github.com/boykopovar/AnyPS5/pull/6788) | `docs/user/USAGE.md` | | [PR 6924](https://www.github.com/boykopovar/AnyPS5/pull/6924) | `docs/user/USAGE.md` | | [PR 7594](https://www.github.com/boykopovar/AnyPS5/pull/7594) | `core/relinker/relinker/tests/test_linux_entry_argv.py` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `docs/user/USAGE.md` | | [PR 7800](https://www.github.com/boykopovar/AnyPS5/pull/7800) | `docs/user/USAGE.md` | | [PR 7918](https://www.github.com/boykopovar/AnyPS5/pull/7918) | `docs/dev/debt/relinker.md`<br>`docs/user/USAGE.md` | | [PR 8076](https://www.github.com/boykopovar/AnyPS5/pull/8076) | `docs/dev/debt/relinker.md` |
mpratsaki commented 2026-10-21 13:04:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mpratsaki on 2026-10-21T13:04:26Z.


Independent conversion check on public homebrew. Conversion only, nothing was run.

Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release. Base: main 2abfb1beb. Candidate: the same main with this PR's head c4a116f62 merged on top (no conflicts), so the only difference is this PR. Inputs: 18 distinct ELFs from public ps5-payload-dev releases (gdbsrv, klogsrv, elfldr, shsrv from the daemons bundle; websrv v0.34 bundles EDuke32, LakeSnes, Omnispeak, OpenJazz, PKGInstall, Wolf4SDL ×2, DevilutionX, FFplay, LinkDev, OffAct, Mednafen, VVVVVV; JTPlay, TVHP). All conversions use --trap-sdk-syscall-stubs --skip-sce-module.

For all 18:

  • --windows and --macos outputs are byte-identical between base and candidate.
  • Default Linux output: base ET_DYN with segments from 0, candidate ET_EXEC with the lowest PT_LOAD at 0x400000. The highest segment end is 0x5fc4040 (Mednafen), well below 2^40 and the guest arena at 0x200000000.
  • The candidate's default output is byte-identical to --linux-fixed-base 0x400000 from both the candidate and base.
  • --lazy-binding output is byte-identical between base and candidate and stays ET_DYN.
  • --to-intel default output (6 inputs get INSERTQ or EXTRQ stubs) is ET_EXEC and byte-identical to base --to-intel --linux-fixed-base 0x400000.

Six other ps5-payload-dev images (four *-install.elf, ftpsrv and websrv) are refused identically on both sides at the mount wrapper from #8624.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6316764303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973#issuecomment-6316764303). Originally posted by [mpratsaki](https://github.com/mpratsaki) on 2026-10-21T13:04:26Z. --- Independent conversion check on public homebrew. Conversion only, nothing was run. Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release. Base: `main` `2abfb1beb`. Candidate: the same `main` with this PR's head `c4a116f62` merged on top (no conflicts), so the only difference is this PR. Inputs: 18 distinct ELFs from public ps5-payload-dev releases (gdbsrv, klogsrv, elfldr, shsrv from the daemons bundle; websrv v0.34 bundles EDuke32, LakeSnes, Omnispeak, OpenJazz, PKGInstall, Wolf4SDL ×2, DevilutionX, FFplay, LinkDev, OffAct, Mednafen, VVVVVV; JTPlay, TVHP). All conversions use `--trap-sdk-syscall-stubs --skip-sce-module`. For all 18: - `--windows` and `--macos` outputs are byte-identical between base and candidate. - Default Linux output: base `ET_DYN` with segments from 0, candidate `ET_EXEC` with the lowest `PT_LOAD` at `0x400000`. The highest segment end is `0x5fc4040` (Mednafen), well below 2^40 and the guest arena at `0x200000000`. - The candidate's default output is byte-identical to `--linux-fixed-base 0x400000` from both the candidate and base. - `--lazy-binding` output is byte-identical between base and candidate and stays `ET_DYN`. - `--to-intel` default output (6 inputs get INSERTQ or EXTRQ stubs) is `ET_EXEC` and byte-identical to base `--to-intel --linux-fixed-base 0x400000`. Six other ps5-payload-dev images (four `*-install.elf`, ftpsrv and websrv) are refused identically on both sides at the mount wrapper from #8624. AI-assisted: yes (Claude Code).
rooklz commented 2026-10-21 13:06:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-21T13:06:01Z.


Thanks for running that, it covers a lot more real inputs than my fixtures did. Good to see --windows, --macos and --lazy-binding stay byte-identical and that the largest image ends far below the arena.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6316799311 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973#issuecomment-6316799311). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T13:06:01Z. --- Thanks for running that, it covers a lot more real inputs than my fixtures did. Good to see `--windows`, `--macos` and `--lazy-binding` stay byte-identical and that the largest image ends far below the arena.
mpratsaki commented 2026-10-21 13:33:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mpratsaki on 2026-10-21T13:33:19Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6317384938 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973#issuecomment-6317384938). Originally posted by [mpratsaki](https://github.com/mpratsaki) on 2026-10-21T13:33:19Z. --- 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 commented 2026-10-21 17:56:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-21T17:56:26Z.

Review: COMMENTED


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 0x400000 or 0x400000000, and VLC and XPSemu need exactly 0x400000. So 0x400000 is 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 0x400000 collides with anything the host places low (a title with a large static image, a preload, a different vm.mmap_min_addr, a compatibility layer). --linux-fixed-base made 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 at 0x200000000 (a title with a very large executable), and add a test with an image that spans the range.
  • --lazy-binding keeps 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 va while the process runs at va + linux_base; APS5_TRACE_CALLS prints app.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.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5603984534 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973#pullrequestreview-5603984534). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-21T17:56:26Z. **Review:** COMMENTED --- 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 `0x400000` *or* `0x400000000`, and VLC and XPSemu need exactly `0x400000`. So `0x400000` is 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 `0x400000` collides with anything the host places low (a title with a large static image, a preload, a different `vm.mmap_min_addr`, a compatibility layer). `--linux-fixed-base` made 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 at `0x200000000` (a title with a very large executable), and add a test with an image that spans the range. - `--lazy-binding` keeps 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 `va` while the process runs at `va + linux_base`; `APS5_TRACE_CALLS` prints `app.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.
rooklz commented 2026-10-21 18:33:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-21T18:33:37Z.


Thanks for going through it this carefully. I pushed 123ba7083 for the second and third points. Point by point:

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 --linux-fixed-base 0x400000; that's the first thing test_linux_fixed_base checks. #7852 reports the title on that flag: "Relinked with --linux-fixed-base 0x400000 or 0x400000000, the title compiles its shaders, presents frames and checks its save data within 5 minutes." So 0x400000 gets the retail case past the mspace check too, not only the homebrew. I agree a run of this exact head beats an inference, though. @Lindamea1, if you have a few minutes: converting PPSA24191 with this branch and no base option should give the same result as your fixed-base runs. The log past the point where it used to stop would be enough.

An image that doesn't fit before the arena. On main the relinker already refuses any image that spans 2 GiB or more, PIE or not: its entry stub reaches the image with rel32 calls, and conversion fails with Entry stub call exceeds rel32 range. So the largest image it accepts ends around 0x80400000 at the default base, well below 0x200000000. test_linux_fixed_base now pins this. An image whose last segment is just under 2 GiB up converts, ends below the arena and runs at the base. Images reaching 0x80000000 or the arena start are refused the same way with and without --lazy-binding, so the default doesn't change which images convert. The debt entry says so too. If that limit is ever lifted, the arena still copes: SeedHostUsedRanges in GuestArena.cpp reads /proc/self/maps and keeps every host mapping inside the arena range out of guest allocations. That's the same path any host mapping there takes today.

On the other collisions: 0x400000 is also GNU ld's default text address for x86-64 non-PIE executables. A host that can't map an executable there can't run ordinary non-PIE binaries either. The kernel maps the executable before ld.so and any preloaded libraries, and the usual vm.mmap_min_addr values (4096 to 65536) are far below it.

--lazy-binding. The usage row already says the executable stays position independent. The converter now also warns when it does that for Linux output: Warning: with --lazy-binding the Linux executable stays position independent and is not placed at 0x400000; a title whose own sceLibcMspaceCreate checks the 40-bit address window stops at start-up. The test checks that the warning appears with the option and not without it.

Trace offsets. #8974 is that follow-up. It counts the offset from the image's first loaded page, so an ET_EXEC executable prints app.elf+0x... the same way a PIE does. The two PRs are independent. I left the USAGE note out because it would go stale once #8974 lands. If you'd rather this PR not depend on the merge order, I'll add it.

Relinker CI on the new head passes on Ubuntu (which runs the converted executables), Windows, both macOS jobs and ASan.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6323581803 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973#issuecomment-6323581803). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T18:33:37Z. --- Thanks for going through it this carefully. I pushed `123ba7083` for the second and third points. Point by point: **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 `--linux-fixed-base 0x400000`; that's the first thing `test_linux_fixed_base` checks. #7852 reports the title on that flag: "Relinked with `--linux-fixed-base 0x400000` or `0x400000000`, the title compiles its shaders, presents frames and checks its save data within 5 minutes." So `0x400000` gets the retail case past the mspace check too, not only the homebrew. I agree a run of this exact head beats an inference, though. @Lindamea1, if you have a few minutes: converting PPSA24191 with this branch and no base option should give the same result as your fixed-base runs. The log past the point where it used to stop would be enough. **An image that doesn't fit before the arena.** On `main` the relinker already refuses any image that spans 2 GiB or more, PIE or not: its entry stub reaches the image with rel32 calls, and conversion fails with `Entry stub call exceeds rel32 range`. So the largest image it accepts ends around `0x80400000` at the default base, well below `0x200000000`. `test_linux_fixed_base` now pins this. An image whose last segment is just under 2 GiB up converts, ends below the arena and runs at the base. Images reaching `0x80000000` or the arena start are refused the same way with and without `--lazy-binding`, so the default doesn't change which images convert. The debt entry says so too. If that limit is ever lifted, the arena still copes: `SeedHostUsedRanges` in `GuestArena.cpp` reads `/proc/self/maps` and keeps every host mapping inside the arena range out of guest allocations. That's the same path any host mapping there takes today. On the other collisions: `0x400000` is also GNU ld's default text address for x86-64 non-PIE executables. A host that can't map an executable there can't run ordinary non-PIE binaries either. The kernel maps the executable before `ld.so` and any preloaded libraries, and the usual `vm.mmap_min_addr` values (4096 to 65536) are far below it. **`--lazy-binding`.** The usage row already says the executable stays position independent. The converter now also warns when it does that for Linux output: `Warning: with --lazy-binding the Linux executable stays position independent and is not placed at 0x400000; a title whose own sceLibcMspaceCreate checks the 40-bit address window stops at start-up`. The test checks that the warning appears with the option and not without it. **Trace offsets.** #8974 is that follow-up. It counts the offset from the image's first loaded page, so an `ET_EXEC` executable prints `app.elf+0x...` the same way a PIE does. The two PRs are independent. I left the USAGE note out because it would go stale once #8974 lands. If you'd rather this PR not depend on the merge order, I'll add it. Relinker CI on the new head passes on Ubuntu (which runs the converted executables), Windows, both macOS jobs and ASan.
jotitadev commented 2026-10-21 22:49:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-21T22:49:16Z.

Review: COMMENTED


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 0x400000
  • test_game_patches → expected linux_base = 0x400000 not in the dumped patch inputs
  • test_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 to 0x400000, 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607171166 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973#pullrequestreview-5607171166). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-21T22:49:16Z. **Review:** COMMENTED --- 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 0x400000` - `test_game_patches` → expected `linux_base = 0x400000` not in the dumped patch inputs - `test_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 to `0x400000`, 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.
DavidSamir commented 2026-10-22 01:24:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T01:24:15Z.


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: 0x140010000 (the Windows and macOS layout), not 0x400000.

  • GamePatchTests.cpp:388 asserted that --verify-output refuses an ET_EXEC output. Once ET_EXEC output is verifiable the expectation has to change, as it does here. I only saw it because relinker_game_patch failed on Windows once I built that test's own target: an earlier run that built only the relinker passed.
  • An A/B on Linux (WSL2, Xvfb, lavapipe) over the 111 catalog titles that relink, 40 s each, --linux-position-independent (main's output) against the new default at 0x140010000. The first pass differed for 13 titles that ran before and stopped after, and 9 the other way. None of it reproduced: two repeats, and three interleaved rounds on the 10 doubtful titles, gave the same result under both settings. The first-run differences came from games rewriting config files that my runs kept between them. So no title that ran at the position-independent base stopped at a fixed low base.

That was 0x140010000; I did not run the catalog at 0x400000.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330401902 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973#issuecomment-6330401902). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-22T01:24:15Z. --- 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: `0x140010000` (the Windows and macOS layout), not `0x400000`. - `GamePatchTests.cpp:388` asserted that `--verify-output` refuses an `ET_EXEC` output. Once `ET_EXEC` output is verifiable the expectation has to change, as it does here. I only saw it because `relinker_game_patch` failed on Windows once I built that test's own target: an earlier run that built only the relinker passed. - An A/B on Linux (WSL2, Xvfb, lavapipe) over the 111 catalog titles that relink, 40 s each, `--linux-position-independent` (`main`'s output) against the new default at `0x140010000`. The first pass differed for 13 titles that ran before and stopped after, and 9 the other way. None of it reproduced: two repeats, and three interleaved rounds on the 10 doubtful titles, gave the same result under both settings. The first-run differences came from games rewriting config files that my runs kept between them. So no title that ran at the position-independent base stopped at a fixed low base. That was `0x140010000`; I did not run the catalog at `0x400000`.
rooklz commented 2026-10-22 01:29:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-22T01:29:09Z.


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 GamePatchTests.cpp point matches what this PR changes there. I'll run the same catalog A/B at 0x400000 once I have a Linux machine with a GPU set up, and post it here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330463355 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8973#issuecomment-6330463355). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-22T01:29:09Z. --- 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 `GamePatchTests.cpp` point matches what this PR changes there. I'll run the same catalog A/B at `0x400000` once I have a Linux machine with a GPU set up, and post it here.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8973
No description provided.