fix(libs): bind the system libraries eagerly on Linux #3214

Merged
fma-rc merged 1 commit from upstream-pr/3214 into main 2026-10-11 06:35:34 +00:00
fma-rc commented 2026-10-11 01:34:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-11T01:34:55Z.


What

The system libraries were linked with lazy binding, so the first call through one of their PLT slots runs the dynamic linker's symbol lookup on whatever stack the title is on. Titles call our exports on stacks sized for the console: Astro's Playroom (PPSA01325) runs a fiber on a 2 KiB context, and on its first sceFiberRun the lookup for the call from the fiber trampoline wrote below that context into the neighbouring heap chunks. The title's own libc then found the damage on a later free and reported it.

This links libc and every prx library with -z now on Linux, so nothing is resolved at call time. The relinked executable and guest modules already bind eagerly.

Tested

Arch Linux, GCC 16.2.1, glibc. fiber gains a case that runs a fiber on a 2 KiB context at the top of a pattern-filled area as the first fiber run of the process and requires nothing below the context to change: it fails on main d31b57a4c and passes with the linker change. All 121 built libraries carry BIND_NOW afterwards. Full ctest: 752/752 on RADV gfx1036; on an RTX 5080 only agc_driver_dcc_keys_first_write fails, an AGC test this change does not touch. tools/check_conventions.py --base origin/main passes.

Astro's Playroom needs libSceJobManager to load, so the title runs used this change on top of the branch of #3170: without it the title stops on sceLibcInternalHeapErrorReportForGame_nid_postfix not implemented (2 of 2 runs), with it that stop is gone and it stops later on image descriptor is incompatible with the static runtime image interface: descriptor format 71 (2 of 2 runs).

Not tested: Windows and macOS (the change does not touch them), and host libraries that a distribution ships with lazy binding.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4815795985 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3214). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-11T01:34:55Z. --- ### What The system libraries were linked with lazy binding, so the first call through one of their PLT slots runs the dynamic linker's symbol lookup on whatever stack the title is on. Titles call our exports on stacks sized for the console: Astro's Playroom (PPSA01325) runs a fiber on a 2 KiB context, and on its first `sceFiberRun` the lookup for the call from the fiber trampoline wrote below that context into the neighbouring heap chunks. The title's own libc then found the damage on a later free and reported it. This links `libc` and every `prx` library with `-z now` on Linux, so nothing is resolved at call time. The relinked executable and guest modules already bind eagerly. ### Tested Arch Linux, GCC 16.2.1, glibc. `fiber` gains a case that runs a fiber on a 2 KiB context at the top of a pattern-filled area as the first fiber run of the process and requires nothing below the context to change: it fails on `main` d31b57a4c and passes with the linker change. All 121 built libraries carry `BIND_NOW` afterwards. Full ctest: 752/752 on RADV gfx1036; on an RTX 5080 only `agc_driver_dcc_keys_first_write` fails, an AGC test this change does not touch. `tools/check_conventions.py --base origin/main` passes. Astro's Playroom needs libSceJobManager to load, so the title runs used this change on top of the branch of #3170: without it the title stops on `sceLibcInternalHeapErrorReportForGame_nid_postfix not implemented` (2 of 2 runs), with it that stop is gone and it stops later on `image descriptor is incompatible with the static runtime image interface: descriptor format 71` (2 of 2 runs). Not tested: Windows and macOS (the change does not touch them), and host libraries that a distribution ships with lazy binding. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-11 01:35:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T01:35:04Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104243552 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3214#issuecomment-6104243552). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T01:35:04Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
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!3214
No description provided.