fix(relinker): export Windows executable symbols #11432

Merged
muhmuhkuh merged 1 commit from upstream-pr/11432 into main 2026-11-04 05:33:36 +00:00
muhmuhkuh commented 2026-10-26 13:15:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by muhmuhkuh on 2026-10-26T13:15:22Z.


What

Converted Windows executables currently have no PE export directory for their defined dynamic ELF symbols. This prevents the loader from resolving executable definitions such as MainProg. Build the export directory for visible code, data and TLS definitions, using the shared PE export writer for executable and guest-module output. Validate unsupported symbol kinds and conflicting aliases instead of emitting invalid RVAs.

Tested

Current update: rebased onto main 231336e48c and fixed identical executable export aliases. Windows Release relinker-only build succeeded with GCC 13.1.0; windows_executable_exports, executable_export_attributes and windows_guest_export_aliases passed (3/3). Conventions passed. Full CTest: 530/538 passed; six select_tests cases and two configure_seed cases failed during CMake fixture setup. Their captured logs do not reveal the underlying CMake error; no main comparison was performed. Earlier review update: rebased onto current main 7903201bb426f7f1e8565e98cc3df299d849edc7, which includes the requested 035ac96edd. Updated head: f11378f4d8805f94696beadc7dda6d9484c2023a. The intervening main commits and the rebase leave core/relinker unchanged. Fresh isolated relinker-only Release configure/build succeeded, and all eight focused Windows tests passed with 0 failures and 0 skips: windows_guest_export_aliases, windows_executable_exports, windows_fixed_base, executable_tls_relocations, executable_export_bounds, guest_tls_export_references, guest_absolute_symbols, windows_import_modules. Conventions were rerun against the updated origin/main.

Prior full-suite qualification:

Windows 11 x64, WinLibs GCC 15.2.0, Python 3.9.5. Isolated Release/Ninja build at commit 9e0260be05c9f1195fb86af8c2021ff5a5e63cdc, based on 7b415520b6079ff5a96898487eb91d7650000e49, with ANYPS5_RELINKER_ONLY=ON and BUILD_TESTING=ON: build succeeded. Full CTest run: 306/308 passed. All relinker tests passed, including windows_executable_exports (native LoadLibraryExW/GetProcAddress, function calls, data, TLS descriptors, aliases and invalid-input rejection).

build_eligibility initially used Node 14.16.1 and failed parsing ||=; it passed when rerun with Node 24.22.1. The remaining check_compile_preprocessor failure also reproduces on a clean detached 7b415520 worktree using the same command and environment: 10 assertions count unit.c twice on Windows. Its test and implementation have identical SHA-256 hashes on main and this branch. No source workaround is included.

python tools/check_conventions.py --base origin/main passed. No Linux or macOS run was performed.

In the prior qualified combined workspace, Death Stranding 2 (PPSA02015) converted with 83 named executable exports, including MainProg, and passed its previous executable-symbol lookup failure. The game still stops at a loading arrow; this PR does not claim a menu or gameplay.

tools/pr_overlap.py --branch codex/windows-executable-exports --repo boykopovar/AnyPS5 completed without shared lines or exports among PRs that merge with main. It reported four conflicting PRs for manual shared-file review: #5021, #6713, #10792 and #10861. Their macOS fixtures, Windows process parameters, pathconf routing and syscall continuations do not implement executable PE exports. CMake registrations and debt entries are separate. #10861 touches the same TLS-builder call: a future merge must preserve this PR's &tlsIndex output and its additional dynamicSection.SyscallContinuations argument. No functional dependency is required. Related #11381 validates executable export attributes across targets; it does not emit Windows executable exports.

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: PPSA02015 #5424 (Windows executable-symbol lookup prerequisite; no menu confirmed)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5018051386 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11432). Originally posted by [muhmuhkuh](https://github.com/muhmuhkuh) on 2026-10-26T13:15:22Z. --- ### What Converted Windows executables currently have no PE export directory for their defined dynamic ELF symbols. This prevents the loader from resolving executable definitions such as `MainProg`. Build the export directory for visible code, data and TLS definitions, using the shared PE export writer for executable and guest-module output. Validate unsupported symbol kinds and conflicting aliases instead of emitting invalid RVAs. ### Tested Current update: rebased onto main 231336e48c4 and fixed identical executable export aliases. Windows Release relinker-only build succeeded with GCC 13.1.0; windows_executable_exports, executable_export_attributes and windows_guest_export_aliases passed (3/3). Conventions passed. Full CTest: 530/538 passed; six select_tests cases and two configure_seed cases failed during CMake fixture setup. Their captured logs do not reveal the underlying CMake error; no main comparison was performed. Earlier review update: rebased onto current main `7903201bb426f7f1e8565e98cc3df299d849edc7`, which includes the requested `035ac96edd`. Updated head: `f11378f4d8805f94696beadc7dda6d9484c2023a`. The intervening main commits and the rebase leave `core/relinker` unchanged. Fresh isolated relinker-only Release configure/build succeeded, and all eight focused Windows tests passed with 0 failures and 0 skips: `windows_guest_export_aliases`, `windows_executable_exports`, `windows_fixed_base`, `executable_tls_relocations`, `executable_export_bounds`, `guest_tls_export_references`, `guest_absolute_symbols`, `windows_import_modules`. Conventions were rerun against the updated `origin/main`. Prior full-suite qualification: Windows 11 x64, WinLibs GCC 15.2.0, Python 3.9.5. Isolated Release/Ninja build at commit `9e0260be05c9f1195fb86af8c2021ff5a5e63cdc`, based on `7b415520b6079ff5a96898487eb91d7650000e49`, with `ANYPS5_RELINKER_ONLY=ON` and `BUILD_TESTING=ON`: build succeeded. Full CTest run: 306/308 passed. All relinker tests passed, including `windows_executable_exports` (native `LoadLibraryExW`/`GetProcAddress`, function calls, data, TLS descriptors, aliases and invalid-input rejection). `build_eligibility` initially used Node 14.16.1 and failed parsing `||=`; it passed when rerun with Node 24.22.1. The remaining `check_compile_preprocessor` failure also reproduces on a clean detached `7b415520` worktree using the same command and environment: 10 assertions count `unit.c` twice on Windows. Its test and implementation have identical SHA-256 hashes on main and this branch. No source workaround is included. `python tools/check_conventions.py --base origin/main` passed. No Linux or macOS run was performed. In the prior qualified combined workspace, Death Stranding 2 (PPSA02015) converted with 83 named executable exports, including `MainProg`, and passed its previous executable-symbol lookup failure. The game still stops at a loading arrow; this PR does not claim a menu or gameplay. <!-- 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. --> `tools/pr_overlap.py --branch codex/windows-executable-exports --repo boykopovar/AnyPS5` completed without shared lines or exports among PRs that merge with main. It reported four conflicting PRs for manual shared-file review: #5021, #6713, #10792 and #10861. Their macOS fixtures, Windows process parameters, pathconf routing and syscall continuations do not implement executable PE exports. CMake registrations and debt entries are separate. #10861 touches the same TLS-builder call: a future merge must preserve this PR's `&tlsIndex` output and its additional `dynamicSection.SyscallContinuations` argument. No functional dependency is required. Related #11381 validates executable export attributes across targets; it does not emit Windows executable exports. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> PPSA02015 #5424 (Windows executable-symbol lookup prerequisite; no menu confirmed) - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
THEMANnt commented 2026-10-26 15:35:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T15:35:55Z.

Review: APPROVED


Reviewed f11378f4d880 against 7903201bb426. No actionable findings.

The change routes Windows executables through the shared PE export writer while preserving the guest-module export path. It filters non-exportable symbols, validates aliases and mapped RVAs, bounds TLS references to PT_TLS, and derives the export module name from the output filename. The reviewed changes fit the existing writer and symbol model.

Validation: The isolated Windows Release relinker build succeeded; windows_executable_exports and windows_guest_export_aliases passed (2/2). Four review-only checks also passed for output-name encoding, malformed symbol-name offsets and termination, and the PT_TLS end boundary. Hosted conventions and labels jobs passed.

The local checkout used the exact pinned base with GitHub’s patch because the canonical head object could not be fetched. No hosted compile or test job was reported for this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5654672951 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11432#pullrequestreview-5654672951). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-26T15:35:55Z. **Review:** APPROVED --- Reviewed `f11378f4d880` against `7903201bb426`. No actionable findings. The change routes Windows executables through the shared PE export writer while preserving the guest-module export path. It filters non-exportable symbols, validates aliases and mapped RVAs, bounds TLS references to PT_TLS, and derives the export module name from the output filename. The reviewed changes fit the existing writer and symbol model. **Validation:** The isolated Windows Release relinker build succeeded; `windows_executable_exports` and `windows_guest_export_aliases` passed (2/2). Four review-only checks also passed for output-name encoding, malformed symbol-name offsets and termination, and the PT_TLS end boundary. Hosted conventions and labels jobs passed. The local checkout used the exact pinned base with GitHub’s patch because the canonical head object could not be fetched. No hosted compile or test job was reported for this head.
jotitadev commented 2026-10-30 19:01:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T19:01:56Z.

Review: COMMENTED


Merge check of head f11378f4d880 against current main 4570612f40 (Linux x86-64, Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON). The PR merges without text conflicts, but two relinker tests fail after the merge:

  • windows_executable_exports (new here): fails 3/3 on the merge, passes 3/3 on the PR head alone.
  • executable_export_attributes (already on main): fails 3/3 on the merge with FAIL: Duplicate executable export: obj for identical_objects-windows, where the test expects exit 0.

A first-parent bisect over main since this PR's base 7903201bb4, with the PR merged at each step, points to 46031052fc, the merge of #11381 ("validate executable export names and attributes like guest modules", 28/10). #11381 checks executable exports in RelinkerPipeline before any target-specific code:

  • Conflicting #-stripped aliases now fail earlier with Conflicting executable exports after stripping #: alpha, so the conflict case never reaches Duplicate executable export.
  • An STT_GNU_IFUNC export now fails with Unsupported executable export attributes: bad, not Unsupported executable export type.
  • Identical aliases of any type are accepted on every target. WindowsExportBuilder::BuildExecutable still uses IdenticalOrdinaryFunctionExport, which only accepts STT_FUNC. Two identical STT_OBJECT aliases are therefore rejected on Windows only. This is a behavior conflict, not just a message change.

Minimal fix verified on the merge: accept a duplicate whose Info, Visibility, Section, Value and Size all match, since #11381 has already rejected the conflicting ones. Also update the two expected messages in the test:

--- a/core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp
+++ b/core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp
@@ BuildExecutable
         if (!inserted) {
-            if (!Relinker::IdenticalOrdinaryFunctionExport(previous->second, symbol)) throw Domain::RelinkerException("Duplicate executable export: " + symbolName);
+            const auto& first = previous->second;
+            if (first.Info != symbol.Info || first.Visibility != symbol.Visibility || first.Section != symbol.Section || first.Value != symbol.Value || first.Size != symbol.Size) throw Domain::RelinkerException("Duplicate executable export: " + symbolName);
             continue;
         }
--- a/core/relinker/relinker/tests/test_windows_executable_exports.py
+++ b/core/relinker/relinker/tests/test_windows_executable_exports.py
-                ('conflict', symbols[:2] + [('alpha#C#B', 0x12, 0, 1, 0x4020, 6)], 'Duplicate executable export'),
+                ('conflict', symbols[:2] + [('alpha#C#B', 0x12, 0, 1, 0x4020, 6)], 'Conflicting executable exports after stripping #: alpha'),
@@
-                ('ifunc', [('bad', 0x1a, 0, 1, 0x4000, 6)], 'Unsupported executable export type')):
+                ('ifunc', [('bad', 0x1a, 0, 1, 0x4000, 6)], 'Unsupported executable export attributes: bad')):

With this patch applied to the merge, both tests pass 3/3. The full relinker-only suite (ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON) passes 534/534. A rebase onto current main should show the same failures in CI.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5717335969 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11432#pullrequestreview-5717335969). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-30T19:01:56Z. **Review:** COMMENTED --- Merge check of head `f11378f4d880` against current `main` `4570612f40` (Linux x86-64, Ubuntu 26.04, GCC 15.2, Release, `BUILD_TESTING=ON`). The PR merges without text conflicts, but two relinker tests fail after the merge: - `windows_executable_exports` (new here): fails 3/3 on the merge, passes 3/3 on the PR head alone. - `executable_export_attributes` (already on `main`): fails 3/3 on the merge with `FAIL: Duplicate executable export: obj` for `identical_objects-windows`, where the test expects exit 0. A first-parent bisect over `main` since this PR's base `7903201bb4`, with the PR merged at each step, points to `46031052fc`, the merge of #11381 ("validate executable export names and attributes like guest modules", 28/10). #11381 checks executable exports in `RelinkerPipeline` before any target-specific code: - Conflicting `#`-stripped aliases now fail earlier with `Conflicting executable exports after stripping #: alpha`, so the `conflict` case never reaches `Duplicate executable export`. - An `STT_GNU_IFUNC` export now fails with `Unsupported executable export attributes: bad`, not `Unsupported executable export type`. - Identical aliases of any type are accepted on every target. `WindowsExportBuilder::BuildExecutable` still uses `IdenticalOrdinaryFunctionExport`, which only accepts `STT_FUNC`. Two identical `STT_OBJECT` aliases are therefore rejected on Windows only. This is a behavior conflict, not just a message change. Minimal fix verified on the merge: accept a duplicate whose `Info`, `Visibility`, `Section`, `Value` and `Size` all match, since #11381 has already rejected the conflicting ones. Also update the two expected messages in the test: ```diff --- a/core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp +++ b/core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp @@ BuildExecutable if (!inserted) { - if (!Relinker::IdenticalOrdinaryFunctionExport(previous->second, symbol)) throw Domain::RelinkerException("Duplicate executable export: " + symbolName); + const auto& first = previous->second; + if (first.Info != symbol.Info || first.Visibility != symbol.Visibility || first.Section != symbol.Section || first.Value != symbol.Value || first.Size != symbol.Size) throw Domain::RelinkerException("Duplicate executable export: " + symbolName); continue; } --- a/core/relinker/relinker/tests/test_windows_executable_exports.py +++ b/core/relinker/relinker/tests/test_windows_executable_exports.py - ('conflict', symbols[:2] + [('alpha#C#B', 0x12, 0, 1, 0x4020, 6)], 'Duplicate executable export'), + ('conflict', symbols[:2] + [('alpha#C#B', 0x12, 0, 1, 0x4020, 6)], 'Conflicting executable exports after stripping #: alpha'), @@ - ('ifunc', [('bad', 0x1a, 0, 1, 0x4000, 6)], 'Unsupported executable export type')): + ('ifunc', [('bad', 0x1a, 0, 1, 0x4000, 6)], 'Unsupported executable export attributes: bad')): ``` With this patch applied to the merge, both tests pass 3/3. The full relinker-only suite (`ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON`) passes 534/534. A rebase onto current `main` should show the same failures in CI. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
jotitadev commented 2026-10-30 20:31:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T20:31:49Z.

Review: COMMENTED


Re-checked 77cb5f907c on Linux: both relinker failures are gone.

Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. Head merged (--no-commit) onto current main 16345cad6a; clean merge, full build OK.

  • windows_executable_exports and executable_export_attributes: pass 3/3.
  • Full non-GPU suite: 1840/1840.
  • Red control: with the old IdenticalOrdinaryFunctionExport check put back in BuildExecutable, executable_export_attributes fails 3/3 with FAIL: Duplicate executable export: obj, so the identical STT_OBJECT alias case stays covered.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5718307059 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11432#pullrequestreview-5718307059). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-30T20:31:49Z. **Review:** COMMENTED --- Re-checked `77cb5f907c` on Linux: both relinker failures are gone. Ubuntu 26.04, i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. Head merged (`--no-commit`) onto current `main` `16345cad6a`; clean merge, full build OK. - `windows_executable_exports` and `executable_export_attributes`: pass 3/3. - Full non-GPU suite: 1840/1840. - Red control: with the old `IdenticalOrdinaryFunctionExport` check put back in `BuildExecutable`, `executable_export_attributes` fails 3/3 with `FAIL: Duplicate executable export: obj`, so the identical `STT_OBJECT` alias case stays covered. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Superseabas commented 2026-11-02 17:37:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-02T17:37:55Z.

Review: APPROVED


Windows run of head 77cb5f907c merged onto current main b28bb77217 (clean merge, local only), including the native part of windows_executable_exports, which only runs on Windows.

Windows 11 Home 10.0.26200, Ryzen 7 7700X, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Python 3.13, Release, ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON.

main b28bb77217 merged
Relinker-only suite 579 of 579 pass 580 of 580 pass
windows_executable_exports, executable_export_attributes, windows_guest_export_aliases - 3 of 3 each
  • native_lookup ran: with os.name == 'nt', LoadLibraryExW loaded the converted lookup.exe, GetProcAddress found alpha, weak, zeta and data, the calls returned 42, 43 and 42, data read 0x123456789abcdef0, and hidden was not found. I wrapped the function in a counting shim to confirm it is called, since the Linux runs above skip it.
  • No new compiler warnings in the changed files with GCC 16.2.

Read through the change: the export table is written through the shared WindowsExportBuilder::Build for both executables and guest modules, names come out sorted from the std::map, local, hidden and internal symbols are skipped, identical duplicates are accepted after #11381's checks, TLS references get a base relocation and are bounded by PT_TLS. I found nothing to change.

Overlap: #15032 (opened today) conflicts textually on WindowsElfPatcher.hpp and WindowsPePatcher.cpp. Both add a trailing WindowsPePatcher constructor parameter, and both change the WindowsTlsBuilder().Build(...) call in Patch: this PR passes &tlsIndex for the nullptr, #15032 adds a functionSymbolRoots argument. Whichever lands second keeps both. Conversion.cpp merges cleanly.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5740712584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11432#pullrequestreview-5740712584). Originally posted by [Superseabas](https://github.com/Superseabas) on 2026-11-02T17:37:55Z. **Review:** APPROVED --- Windows run of head `77cb5f907c` merged onto current `main` `b28bb77217` (clean merge, local only), including the native part of `windows_executable_exports`, which only runs on Windows. Windows 11 Home 10.0.26200, Ryzen 7 7700X, WinLibs GCC 16.2.0 (`x86_64-ucrt-posix-seh`, r3), Python 3.13, Release, `ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON`. | | `main` `b28bb77217` | merged | |---|---|---| | Relinker-only suite | 579 of 579 pass | 580 of 580 pass | | `windows_executable_exports`, `executable_export_attributes`, `windows_guest_export_aliases` | - | 3 of 3 each | - `native_lookup` ran: with `os.name == 'nt'`, `LoadLibraryExW` loaded the converted `lookup.exe`, `GetProcAddress` found `alpha`, `weak`, `zeta` and `data`, the calls returned 42, 43 and 42, `data` read `0x123456789abcdef0`, and `hidden` was not found. I wrapped the function in a counting shim to confirm it is called, since the Linux runs above skip it. - No new compiler warnings in the changed files with GCC 16.2. Read through the change: the export table is written through the shared `WindowsExportBuilder::Build` for both executables and guest modules, names come out sorted from the `std::map`, local, hidden and internal symbols are skipped, identical duplicates are accepted after #11381's checks, TLS references get a base relocation and are bounded by `PT_TLS`. I found nothing to change. Overlap: #15032 (opened today) conflicts textually on `WindowsElfPatcher.hpp` and `WindowsPePatcher.cpp`. Both add a trailing `WindowsPePatcher` constructor parameter, and both change the `WindowsTlsBuilder().Build(...)` call in `Patch`: this PR passes `&tlsIndex` for the `nullptr`, #15032 adds a `functionSymbolRoots` argument. Whichever lands second keeps both. `Conversion.cpp` merges cleanly. AI-assisted: yes (Claude Code)
XairRrR commented 2026-11-02 21:14:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T21:14:37Z.

Review: APPROVED


Reviewed — approved

Windows executables now get a PE export directory, written by the export builder that guest modules also use. The merge is clean, conventions pass, the focused relinker tests pass, the new test fails when the production wiring is reverted, and I found nothing blocking.

What I ran

Head 77cb5f907c944984d6a04400f6819d9fd9742c2d, merged with --no-ff into main 9090972b7e91fd266819cbd77a8b058e177b5682 (merged tree d67b2f6cdc144b93f57af155b01a1bcf234d9ff6). Debian 13 VM, GCC 14.2.0, Release, Ninja, BUILD_TESTING=ON.

git diff --check 9090972b7e91fd266819cbd77a8b058e177b5682...77cb5f907c944984d6a04400f6819d9fd9742c2d
python3 tools/check_conventions.py --base 9090972b7e91fd266819cbd77a8b058e177b5682
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "windows_executable_exports|executable_export|windows_guest_export_aliases|windows_fixed_base|executable_tls|guest_tls_export|guest_absolute|windows_import_modules"
# negative control
git show 9090972b7e91:<path> > <path>   # WindowsPePatcher.cpp, WindowsElfPatcher.hpp, Conversion.cpp
ninja -C build -j32 -l32 relinker
ctest --test-dir build --output-on-failure -R "^windows_executable_exports$"
git show d67b2f6cdc14:<path> > <path>   # same three files
ninja -C build -j32 -l32 relinker
ctest --test-dir build --output-on-failure -R "^(windows_executable_exports|executable_export_attributes|windows_fixed_base)$"
git status --porcelain
# edge probe: the test's fixture() with a TLS export (value, size) = (64, 0) and (56, 8), PT_TLS memsz 64
relinker --windows --skip-sce-module a.elf a.exe

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Build (script) configure, build and libs OK
Script test run 703 ran, 701 passed, 1 expected skip; unwrap_self also fails on main (known failure); no new failures or timeouts
Focused relinker tests (10) 10/10 passed: windows_executable_exports, windows_fixed_base, linux_executable_exports, macos_executable_exports, executable_tls_relocations, executable_export_bounds, executable_export_attributes, guest_tls_export_references, guest_absolute_symbols, windows_import_modules
windows_guest_export_aliases not registered on this host: CMake adds it only under WIN32
Vulkan validation skipped: the PR changes no AGC driver, shader recompiler or VideoOut files

Negative control

I restored only WindowsPePatcher.cpp, WindowsElfPatcher.hpp and Conversion.cpp from main, which removes the executable export wiring, and rebuilt relinker. windows_executable_exports then failed:

output
  File ".../test_windows_executable_exports.py", line 102, in main
    assert actual == {'alpha': 0x10000, 'data': 0x10f00,
AssertionError: {}

I then restored the merged files and rebuilt. The tests passed again, and git status --porcelain showed the worktree back at the merged tree.

Findings

Blocking

None.

Non-blocking

  • A zero-size TLS export at the end of PT_TLS is rejected on Windows only. The check is at core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp:67 (link). It rejects Value >= MemorySize and treats size 0 as 1. The pipeline check accepts value == MemorySize with size 0 (RelinkerPipeline.cpp L520-L521), and so does the macOS patcher (MacOsMachOPatcher.cpp L91-L92). I ran the relinker on the test's fixture with PT_TLS memsz 64:

    • (value, size) = (64, 0): fails with FAIL: Executable TLS export is outside its TLS block: tls_value.
    • (56, 8): converts.

    This only matters for an end-of-block marker symbol, which is uncommon, so it does not block. Suggested fix: use the same bound as the pipeline (Value > MemorySize || Size > MemorySize - Value), or record the stricter rule in the debt entry the PR adds.

On the existing reviews: jotitadev reported, on the earlier head, that identical STT_OBJECT aliases were rejected and that two expected messages were stale. Both are fixed in this head. BuildExecutable now compares the whole symbol tuple, and executable_export_attributes passes on this merge.

Not verified

  • I could not run the native LoadLibraryExW/GetProcAddress part of windows_executable_exports or windows_guest_export_aliases: both run only on Windows. Superseabas's review reports both passing on Windows.
  • I could not check that the guest-module .edata output is byte-identical after the refactor. I compared the code, and the moved block matches the removed one.
  • I did not reproduce the Death Stranding 2 (PPSA02015) conversion, because titles are not run here.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5743443245 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11432#pullrequestreview-5743443245). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-02T21:14:37Z. **Review:** APPROVED --- # Reviewed — approved Windows executables now get a PE export directory, written by the export builder that guest modules also use. The merge is clean, conventions pass, the focused relinker tests pass, the new test fails when the production wiring is reverted, and I found nothing blocking. ## What I ran Head `77cb5f907c944984d6a04400f6819d9fd9742c2d`, merged with `--no-ff` into `main` `9090972b7e91fd266819cbd77a8b058e177b5682` (merged tree `d67b2f6cdc144b93f57af155b01a1bcf234d9ff6`). Debian 13 VM, GCC 14.2.0, Release, Ninja, `BUILD_TESTING=ON`. ``` git diff --check 9090972b7e91fd266819cbd77a8b058e177b5682...77cb5f907c944984d6a04400f6819d9fd9742c2d python3 tools/check_conventions.py --base 9090972b7e91fd266819cbd77a8b058e177b5682 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "windows_executable_exports|executable_export|windows_guest_export_aliases|windows_fixed_base|executable_tls|guest_tls_export|guest_absolute|windows_import_modules" # negative control git show 9090972b7e91:<path> > <path> # WindowsPePatcher.cpp, WindowsElfPatcher.hpp, Conversion.cpp ninja -C build -j32 -l32 relinker ctest --test-dir build --output-on-failure -R "^windows_executable_exports$" git show d67b2f6cdc14:<path> > <path> # same three files ninja -C build -j32 -l32 relinker ctest --test-dir build --output-on-failure -R "^(windows_executable_exports|executable_export_attributes|windows_fixed_base)$" git status --porcelain # edge probe: the test's fixture() with a TLS export (value, size) = (64, 0) and (56, 8), PT_TLS memsz 64 relinker --windows --skip-sce-module a.elf a.exe ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Build (script) | configure, build and `libs` OK | | Script test run | 703 ran, 701 passed, 1 expected skip; `unwrap_self` also fails on `main` (known failure); no new failures or timeouts | | Focused relinker tests (10) | 10/10 passed: `windows_executable_exports`, `windows_fixed_base`, `linux_executable_exports`, `macos_executable_exports`, `executable_tls_relocations`, `executable_export_bounds`, `executable_export_attributes`, `guest_tls_export_references`, `guest_absolute_symbols`, `windows_import_modules` | | `windows_guest_export_aliases` | not registered on this host: CMake adds it only under `WIN32` | | Vulkan validation | skipped: the PR changes no AGC driver, shader recompiler or VideoOut files | ## Negative control I restored only `WindowsPePatcher.cpp`, `WindowsElfPatcher.hpp` and `Conversion.cpp` from `main`, which removes the executable export wiring, and rebuilt `relinker`. `windows_executable_exports` then failed: <details><summary>output</summary> ``` File ".../test_windows_executable_exports.py", line 102, in main assert actual == {'alpha': 0x10000, 'data': 0x10f00, AssertionError: {} ``` </details> I then restored the merged files and rebuilt. The tests passed again, and `git status --porcelain` showed the worktree back at the merged tree. ## Findings ### Blocking None. ### Non-blocking - **A zero-size TLS export at the end of PT_TLS is rejected on Windows only.** The check is at `core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp:67` ([link](https://github.com/boykopovar/AnyPS5/blob/77cb5f907c944984d6a04400f6819d9fd9742c2d/core/relinker/elfpatcher/src/windows/WindowsExportBuilder.cpp#L67)). It rejects `Value >= MemorySize` and treats size 0 as 1. The pipeline check accepts `value == MemorySize` with size 0 ([RelinkerPipeline.cpp L520-L521](https://github.com/boykopovar/AnyPS5/blob/9090972b7e91fd266819cbd77a8b058e177b5682/core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp#L520-L521)), and so does the macOS patcher ([MacOsMachOPatcher.cpp L91-L92](https://github.com/boykopovar/AnyPS5/blob/9090972b7e91fd266819cbd77a8b058e177b5682/core/relinker/elfpatcher/src/macos/MacOsMachOPatcher.cpp#L91-L92)). I ran the relinker on the test's fixture with PT_TLS `memsz` 64: - `(value, size) = (64, 0)`: fails with `FAIL: Executable TLS export is outside its TLS block: tls_value`. - `(56, 8)`: converts. This only matters for an end-of-block marker symbol, which is uncommon, so it does not block. Suggested fix: use the same bound as the pipeline (`Value > MemorySize || Size > MemorySize - Value`), or record the stricter rule in the debt entry the PR adds. On the existing reviews: jotitadev reported, on the earlier head, that identical `STT_OBJECT` aliases were rejected and that two expected messages were stale. Both are fixed in this head. `BuildExecutable` now compares the whole symbol tuple, and `executable_export_attributes` passes on this merge. ## Not verified - I could not run the native `LoadLibraryExW`/`GetProcAddress` part of `windows_executable_exports` or `windows_guest_export_aliases`: both run only on Windows. Superseabas's review reports both passing on Windows. - I could not check that the guest-module `.edata` output is byte-identical after the refactor. I compared the code, and the moved block matches the removed one. - I did not reproduce the Death Stranding 2 (PPSA02015) conversion, because titles are not run here. <!-- anyps5-bots job=1921 head=77cb5f907c944984d6a04400f6819d9fd9742c2d -->
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!11432
No description provided.