fix(relinker): retain imports used by sectionless exports #4726

Merged
Ondra97 merged 1 commit from upstream-pr/4726 into main 2026-10-14 06:33:07 +00:00
Ondra97 commented 2026-10-12 19:49:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-12T19:49:06Z.


What

With unused-filter=1, a sectionless ELF could lose a non-PLT import used only by an exported function, because that function was not a reachability root. The same image with a section symbol table kept the import.

Read the existing executable export list before filtering and pass its defined global/weak functions to the level-1 filter as additional roots. Export emission retains its ordering and bytes. This reuses the existing parser and symbol-count contract; it adds no new ELF metadata format.

Tested

Windows x64, supported WinLibs MinGW-w64 GCC 15.2.0 ucrt-posix-seh r7, Ninja Release, Python 3.14. Rebase handoff adopted, then updated to current main dacd78525; head 7b70941f5.

  • git range-diff confirms the patch is identical to the previous PR head c8697b15e. Original author and author timestamp are preserved.
  • On the validated handoff head 660db6f0b, Release relinker-only build succeeds; full CTest suite: 150/150 pass, zero skips, zero failures (112.52 seconds). This includes unused_filter_indirect, export roots, weak imports, CFG and strict filtering.
  • Final rebase onto dacd78525 is also patch-identical by git range-diff. The only inherited changes are the two AGC files from #4949, outside the relinker-only build. Relinker sources, tools, tests, CMake configuration and workflows are identical to validated 660db6f0b; local build/test results above apply to the same relinker code and tests. Fresh current-head CI passed as recorded below.
  • Conventions and whitespace checks pass.
  • Rechecked all 631 current open PR file lists and manually inspected the eight shared-file patches. No other PR implements this export-root fix.

Independent Linux full-build validation is reported in the rebase handoff: 1070/1071, with agc_driver_tessellation failing as a reported existing main regression (#4727). That runtime result was not independently reproduced here; this update changes only the rebase of the original relinker patch. No console title or GPU execution is claimed for the local validation.

Current-head CI for 7b70941f5 passed conventions and eligibility, plus all three relinker builds and complete test suites:

  • relinker (ubuntu-latest, g++): 155 CTest tests, zero failures; unused_filter_indirect passed.
  • relinker (macos-latest, clang++): 146 CTest tests, zero failures; unused_filter_indirect passed.
  • relinker (windows-latest, g++): 150 CTest tests, zero failures; unused_filter_indirect passed.

Full runtime-library jobs were skipped by the repository's PR workflow.

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; silent stubs are listed in technical debt
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4834259922 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4726). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-12T19:49:06Z. --- ### What With `unused-filter=1`, a sectionless ELF could lose a non-PLT import used only by an exported function, because that function was not a reachability root. The same image with a section symbol table kept the import. Read the existing executable export list before filtering and pass its defined global/weak functions to the level-1 filter as additional roots. Export emission retains its ordering and bytes. This reuses the existing parser and symbol-count contract; it adds no new ELF metadata format. ### Tested Windows x64, supported WinLibs MinGW-w64 GCC 15.2.0 ucrt-posix-seh r7, Ninja Release, Python 3.14. Rebase handoff adopted, then updated to current `main` `dacd78525`; head `7b70941f5`. - `git range-diff` confirms the patch is identical to the previous PR head `c8697b15e`. Original author and author timestamp are preserved. - On the validated handoff head `660db6f0b`, Release relinker-only build succeeds; full CTest suite: 150/150 pass, zero skips, zero failures (112.52 seconds). This includes `unused_filter_indirect`, export roots, weak imports, CFG and strict filtering. - Final rebase onto `dacd78525` is also patch-identical by `git range-diff`. The only inherited changes are the two AGC files from #4949, outside the relinker-only build. Relinker sources, tools, tests, CMake configuration and workflows are identical to validated `660db6f0b`; local build/test results above apply to the same relinker code and tests. Fresh current-head CI passed as recorded below. - Conventions and whitespace checks pass. - Rechecked all 631 current open PR file lists and manually inspected the eight shared-file patches. No other PR implements this export-root fix. Independent Linux full-build validation is reported in the [rebase handoff](https://github.com/boykopovar/AnyPS5/pull/4726#issuecomment-6152771757): 1070/1071, with `agc_driver_tessellation` failing as a reported existing main regression (#4727). That runtime result was not independently reproduced here; this update changes only the rebase of the original relinker patch. No console title or GPU execution is claimed for the local validation. Current-head CI for `7b70941f5` passed conventions and eligibility, plus all three relinker builds and complete test suites: - relinker (ubuntu-latest, g++): 155 CTest tests, zero failures; unused_filter_indirect passed. - relinker (macos-latest, clang++): 146 CTest tests, zero failures; unused_filter_indirect passed. - relinker (windows-latest, g++): 150 CTest tests, zero failures; unused_filter_indirect passed. Full runtime-library jobs were skipped by the repository's PR workflow. ### 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 - [x] Unimplemented paths throw; silent stubs are listed in technical debt - [x] No notes, investigation files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 04:52:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T04:52:48Z.


Windows test: head 3d4cf8c7b merged onto current main e51428bf2 (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest with the filter ^unused_filter_indirect$: unused_filter_indirect passed (1 test(s), 0 failed); python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6138509203 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4726#issuecomment-6138509203). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T04:52:48Z. --- Windows test: head `3d4cf8c7b` merged onto current `main` `e51428bf2` (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest with the filter `^unused_filter_indirect$`: unused_filter_indirect passed (1 test(s), 0 failed); `python tools/check_conventions.py --base upstream/main` passed. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
adriadam10 commented 2026-10-13 15:34:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:34:34Z.


Checked the build and the relinker ctest scope (124/124 pass), and the extended unused_filter_indirect test fails without the change and passes with it. Roots from defined global/weak exported functions, local/undefined excluded, levels 0/1/2 with and without section headers all behave as expected; relinker CI green on Linux, Windows and macOS. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6149197303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4726#issuecomment-6149197303). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T15:34:34Z. --- Checked the build and the relinker ctest scope (124/124 pass), and the extended `unused_filter_indirect` test fails without the change and passes with it. Roots from defined global/weak exported functions, local/undefined excluded, levels 0/1/2 with and without section headers all behave as expected; relinker CI green on Linux, Windows and macOS. Merging.
blawesom commented 2026-10-13 18:50:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-13T18:50:00Z.


Rebase handoff — rebased onto current main (staleness only, applied cleanly), authorship unchanged.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 1070/1071 — the only failure is the known main regression (agc_driver_tessellation segfault, #4727)

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4726
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 660db6f0b.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152771757 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4726#issuecomment-6152771757). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-13T18:50:00Z. --- **Rebase handoff** — rebased onto current `main` (staleness only, applied cleanly), authorship unchanged. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite: 1070/1071** — the only failure is the known `main` regression (`agc_driver_tessellation` segfault, #4727) **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/4726 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `660db6f0b`.
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!4726
No description provided.