fix(relinker): trap guest GS accesses in Windows output instead of refusing the module #6102

Merged
DavidSamir merged 5 commits from upstream-pr/6102 into main 2026-10-18 16:29:03 +00:00
DavidSamir commented 2026-10-14 22:11:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-14T22:11:03Z.


What

Prospero Win (PPSA99995, the catalog's Wine port) cannot be converted for Windows. The relinker refuses its Wine ntdll module:

FAIL: Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x3214c)
Input: ...\PPSA99995\elf\prx\ntdll.prx

65 48 8b 0c 25 78 03 00 00 is mov rcx, gs:[0x378]. The module has six instructions that address memory through GS (gs:0x30, gs:0x330, gs:0x378, objdump of its executable segment), and no FS access. On FreeBSD a program sets its own GS base with sysarch(AMD64_SET_GSBASE); on Windows the host owns GS (the thread environment block), so WindowsTlsBuilder cannot translate a GS access the way it rewrites FS thread-pointer accesses, and it refuses the whole module, so the title cannot start at all.

The builder now overwrites each GS-prefixed instruction in place with ud2 and NOP padding of the instruction's own length. The module converts, and an instruction that is reached faults with STATUS_ILLEGAL_INSTRUCTION, which the crash reporter prints with its address and bytes. This follows --trap-sdk-syscall-stubs, which turns SDK syscall stubs into ud2 the same way. Because the instruction is replaced in place, no jump or stub is needed, branch targets inside it do not matter, and forms shorter than a jump are covered too. FS accesses are unchanged.

Four commits:

  1. fix(relinker): trap guest GS accesses in Windows output instead of refusing the module: the builder change, and the gs-load case of tls_function_coverage_rejected, which encoded the refusal.
  2. test(relinker): cover GS loads, stores and ALU reads trapped in Windows output: a new tls_function_coverage_gs_traps group. Each form (the two loads Wine's ntdll uses, a store, an ALU read and a 4-byte register-address form) converts, and its bytes become ud2 and NOPs with the next instruction in place.
  3. test(relinker): trap a GS access in a module without a TLS segment: the builder returns early for a module without PT_TLS; a GS access there must still be trapped.
  4. docs(debt): record that guest GS accesses trap in Windows output.

Tested

Windows (84f72fc05 on main fa539dd9b, Windows 11 10.0.26300, WinLibs GCC 15.2.0 r7, Release):

  • Prospero Win (PPSA99995, catalog release), converted with --trap-sdk-syscall-stubs as the catalog sweep converts it, run with main's libraries:
    • main's relinker exits 2 with the FAIL above; nothing is written.
    • The branch's relinker converts it. The six GS instructions in ntdll are 9-byte ud2 and NOP sites in the output and none of the original bytes are left. The title then stops at load (exit 0xc0000139) on its next imports: sysarch (b7uXQmnfB2s, #6028) and four libSceVideoOut cursor functions, sceVideoOutCursorEnable, sceVideoOutCursorDisable, sceVideoOutCursorSetImageAddress and sceVideoOutCursorSetPosition, which no library exports yet. So it moves from conversion to its next stop; it does not run on Windows yet.
  • All 51 catalog titles that have an ELF, converted with main's relinker and the branch's, same arguments: every output file of 50 titles is byte-identical. PPSA99995 is the only difference.
  • With WindowsTlsBuilder.cpp as on main, tls_function_coverage_gs_traps fails at its first case with Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00). With the trap applied after the builder's early return for a module without PT_TLS, the third commit's case fails: the instruction is left in place.
  • Each commit alone: the relinker builds and the TLS tests (tls_function_coverage_*, tls_diagnostics, guest_tls, empty_tls) pass, 34 at the first commit and 35 from the second.
  • Full ctest --parallel 4 on a full build: 1233 of 1234 pass. check_main_sync fails on this machine at a file name with é read back through the console code page; it passes with PYTHONUTF8=1, and the branch changes nothing under tools/. Once, tls_function_coverage_register_address_loads hit its 30 s timeout while the overlap check ran alongside; alone it passes 3 of 3 in about 5 s.
  • tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py --branch reports no overlap with open pull requests.

Linux (same commit, WSL2 Ubuntu 24.04, GCC 13.3.0, Release): the relinker builds and the same 35 TLS tests pass.

Not checked on a console. The guest GS base is not emulated; the debt note says so.

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
  • Unblocks: PPSA99995 (Prospero Win) conversion on Windows
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4865265904 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-14T22:11:03Z. --- ### What Prospero Win (PPSA99995, the catalog's Wine port) cannot be converted for Windows. The relinker refuses its Wine `ntdll` module: ``` FAIL: Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x3214c) Input: ...\PPSA99995\elf\prx\ntdll.prx ``` `65 48 8b 0c 25 78 03 00 00` is `mov rcx, gs:[0x378]`. The module has six instructions that address memory through GS (`gs:0x30`, `gs:0x330`, `gs:0x378`, objdump of its executable segment), and no FS access. On FreeBSD a program sets its own GS base with `sysarch(AMD64_SET_GSBASE)`; on Windows the host owns GS (the thread environment block), so [`WindowsTlsBuilder`](https://github.com/boykopovar/AnyPS5/blob/fa539dd9b/core/relinker/elfpatcher/src/windows/WindowsTlsBuilder.cpp) cannot translate a GS access the way it rewrites FS thread-pointer accesses, and it refuses the whole module, so the title cannot start at all. The builder now overwrites each GS-prefixed instruction in place with `ud2` and NOP padding of the instruction's own length. The module converts, and an instruction that is reached faults with `STATUS_ILLEGAL_INSTRUCTION`, which the crash reporter prints with its address and bytes. This follows `--trap-sdk-syscall-stubs`, which turns SDK syscall stubs into `ud2` the same way. Because the instruction is replaced in place, no jump or stub is needed, branch targets inside it do not matter, and forms shorter than a jump are covered too. FS accesses are unchanged. Four commits: 1. `fix(relinker): trap guest GS accesses in Windows output instead of refusing the module`: the builder change, and the `gs-load` case of `tls_function_coverage_rejected`, which encoded the refusal. 2. `test(relinker): cover GS loads, stores and ALU reads trapped in Windows output`: a new `tls_function_coverage_gs_traps` group. Each form (the two loads Wine's `ntdll` uses, a store, an ALU read and a 4-byte register-address form) converts, and its bytes become `ud2` and NOPs with the next instruction in place. 3. `test(relinker): trap a GS access in a module without a TLS segment`: the builder returns early for a module without `PT_TLS`; a GS access there must still be trapped. 4. `docs(debt): record that guest GS accesses trap in Windows output`. ### Tested Windows (84f72fc05 on `main` fa539dd9b, Windows 11 10.0.26300, WinLibs GCC 15.2.0 r7, Release): - Prospero Win (PPSA99995, catalog release), converted with `--trap-sdk-syscall-stubs` as the catalog sweep converts it, run with `main`'s libraries: - `main`'s relinker exits 2 with the `FAIL` above; nothing is written. - The branch's relinker converts it. The six GS instructions in `ntdll` are 9-byte `ud2` and NOP sites in the output and none of the original bytes are left. The title then stops at load (exit 0xc0000139) on its next imports: `sysarch` (`b7uXQmnfB2s`, #6028) and four libSceVideoOut cursor functions, `sceVideoOutCursorEnable`, `sceVideoOutCursorDisable`, `sceVideoOutCursorSetImageAddress` and `sceVideoOutCursorSetPosition`, which no library exports yet. So it moves from conversion to its next stop; it does not run on Windows yet. - All 51 catalog titles that have an ELF, converted with `main`'s relinker and the branch's, same arguments: every output file of 50 titles is byte-identical. PPSA99995 is the only difference. - With `WindowsTlsBuilder.cpp` as on `main`, `tls_function_coverage_gs_traps` fails at its first case with `Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00)`. With the trap applied after the builder's early return for a module without `PT_TLS`, the third commit's case fails: the instruction is left in place. - Each commit alone: the relinker builds and the TLS tests (`tls_function_coverage_*`, `tls_diagnostics`, `guest_tls`, `empty_tls`) pass, 34 at the first commit and 35 from the second. - Full `ctest --parallel 4` on a full build: 1233 of 1234 pass. `check_main_sync` fails on this machine at a file name with `é` read back through the console code page; it passes with `PYTHONUTF8=1`, and the branch changes nothing under `tools/`. Once, `tls_function_coverage_register_address_loads` hit its 30 s timeout while the overlap check ran alongside; alone it passes 3 of 3 in about 5 s. - `tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py --branch` reports no overlap with open pull requests. Linux (same commit, WSL2 Ubuntu 24.04, GCC 13.3.0, Release): the relinker builds and the same 35 TLS tests pass. Not checked on a console. The guest GS base is not emulated; the debt note says so. ### 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 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 - [x] Unblocks: PPSA99995 (Prospero Win) conversion on Windows - [x] AI-assisted: yes
DavidSamir commented 2026-10-14 23:02:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-14T23:02:47Z.


With this PR, #6028 (sysarch) and #6135 (the four VideoOut cursor imports) merged locally on main 922abe6a4, Prospero Win (PPSA99995) reaches its launcher on Windows: still running at 60 s in two runs, and its session log records the keyboard and mouse opening, an empty game library and launcher video=ok pad=ok hid=ok frame=1 apps=0. With only this PR it converts and stops at load on those imports, as described above.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6180403926 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#issuecomment-6180403926). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-14T23:02:47Z. --- With this PR, #6028 (`sysarch`) and #6135 (the four VideoOut cursor imports) merged locally on `main` 922abe6a4, Prospero Win (PPSA99995) reaches its launcher on Windows: still running at 60 s in two runs, and its session log records the keyboard and mouse opening, an empty game library and `launcher video=ok pad=ok hid=ok frame=1 apps=0`. With only this PR it converts and stops at load on those imports, as described above. AI-assisted: yes
jotitadev commented 2026-10-14 23:34:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T23:34:07Z.

Review: COMMENTED


Static note from macOS, head 84f72fc05: the macOS writer has the same refusal, so with this PR PPSA99995's ntdll still won't convert with --macos.

MacOsImage.cpp (the TLS scan around L230-247, unchanged on current main) accepts only 64-prefixed loads/stores and throws for anything else with a segment prefix. I fed the gs-load-rcx body from this PR's gs_traps group (65 48 8b 0c 25 78 03 00 00, via make_image("register", "unwind", ...)) to an existing macOS relinker build (M2 Max, macOS 27.2; mugurc's macos-port @ b7eb6b6b, whose MacOsImage.cpp scan is identical to main's):

relinker --skip-sce-module --macos gs-load-rcx.elf out   -> exit 2
FAIL: Unsupported macOS guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x1240)

An FS load in the same fixture converts fine. On x86-64 macOS the host also owns GS (it holds the pthread TSD base, under Rosetta too), so the reason given in the debt note applies there as well, and the same in-place ud2 trap would fit the macOS scan. Not asking to widen this PR, since it's Windows-scoped. The debt line could say "Windows output" for now and a follow-up could cover macOS. I didn't build this PR's head; the macOS result above is from the existing build.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5526090429 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#pullrequestreview-5526090429). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-14T23:34:07Z. **Review:** COMMENTED --- Static note from macOS, head `84f72fc05`: the macOS writer has the same refusal, so with this PR PPSA99995's `ntdll` still won't convert with `--macos`. `MacOsImage.cpp` (the TLS scan around L230-247, unchanged on current `main`) accepts only `64`-prefixed loads/stores and throws for anything else with a segment prefix. I fed the `gs-load-rcx` body from this PR's `gs_traps` group (`65 48 8b 0c 25 78 03 00 00`, via `make_image("register", "unwind", ...)`) to an existing macOS relinker build (M2 Max, macOS 27.2; mugurc's `macos-port` @ b7eb6b6b, whose `MacOsImage.cpp` scan is identical to `main`'s): ``` relinker --skip-sce-module --macos gs-load-rcx.elf out -> exit 2 FAIL: Unsupported macOS guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x1240) ``` An FS load in the same fixture converts fine. On x86-64 macOS the host also owns GS (it holds the pthread TSD base, under Rosetta too), so the reason given in the debt note applies there as well, and the same in-place `ud2` trap would fit the macOS scan. Not asking to widen this PR, since it's Windows-scoped. The debt line could say "Windows output" for now and a follow-up could cover macOS. I didn't build this PR's head; the macOS result above is from the existing build. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
screamm commented 2026-10-15 02:00:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-15T02:00:24Z.


Cross-check on Windows: #6102 head 84f72fc05 merged onto main 6239ceffc; the merge is clean.

Host: Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, NVIDIA RTX 4070 (Ryzen 7 5700X).

  • Build: full build (cmake --build build -- -k 0) and libs both succeed. One observation: WindowsTlsBuilder.cpp now gives 8 GCC 15.2 -Wstringop-overflow warnings, where main's build of the same file gives none:
    • warning: writing 8 bytes into a region of size between 5 and 6 once, and writing 1 byte into a region of size 0 7 times;
    • all point at WindowsTlsBuilder.cpp:190:50, movedBytes.insert(movedBytes.end(), 4, 0), inlined into WindowsTlsBuilder::Build. That line is main's code, so this looks like a false positive that the changed inlining exposes. It is not an error.
  • Tests, --repeat until-fail:3:
    • tls_function_coverage_gs_traps and tls_function_coverage_rejected: 3/3;
    • the 35 TLS tests (tls_function_coverage_*, tls_diagnostics, guest_tls, empty_tls): 3/3 each, 105 of 105 runs.
  • Suite, ctest -j8 --timeout 120 -E '^agc_driver_|^video_out_flip': 809 tests (main's 808 plus gs_traps). 808 pass, including the 2 skipped. hardware_oracle_compare timed out under host load and passes alone (8.75 s).

Prospero Win (PPSA99995). Catalog release, converted with relinker --windows --trap-sdk-syscall-stubs --module-dir win/wine/lib/wine/x86_64-unix --registry unused-filter=0 src6/eboot.elf ... and run with the display on.

main: the relinker exits 2 and writes nothing:

FAIL: Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x3214c)
Input: ...\PPSA99995\src6\win\wine\lib\wine\x86_64-unix\ntdll.prx

This PR: it converts, with 54 output files. In the input ntdll.prx, objdump of the executable segment finds six GS instructions, at 0x2e14c, 0x2e1a0, 0x2e45f, 0x2e504, 0x2e52b and 0x2e56b:

  • mov %gs:0x378,%rcx ×3;
  • mov %gs:0x30,%r13 ×2;
  • mov %gs:0x330,%r10 ×1.

In the output ntdll.prx.guest.prx, each is 0f 0b followed by 7 90, with the 8 bytes on each side unchanged, and none of the original 9-byte sequences is left.

The title then stops at load, after 0.9 s, with exit 0xC0000139:

FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx
FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx
FAIL: unresolved ELF import fEPEwROdCwM from libSceVideoOut.prx
FAIL: unresolved ELF import u-9bhWQApq8 from libSceVideoOut.prx
FAIL: unresolved ELF import UPZWCH8qTM4 from libSceVideoOut.prx
FAIL: unresolved ELF import N17AK88NdD0 from libSceVideoOut.prx
FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx
GetLastError: 127 - The specified procedure could not be found.

Those are:

  • sysarch, imported by ntdll and wow64native;
  • sceVideoOutCursorDisable, sceVideoOutCursorSetImageAddress, sceVideoOutCursorEnable and sceVideoOutCursorSetPosition, imported by libvulkan.

No frame is presented.

Verdict: confirmed. Conversion now succeeds, and the six GS sites become 9-byte ud2/NOP traps. The next stop is load, on sysarch (#6028) and the four sceVideoOutCursor* imports, exactly as the PR describes.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6182667359 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#issuecomment-6182667359). Originally posted by [screamm](https://github.com/screamm) on 2026-10-15T02:00:24Z. --- **Cross-check on Windows: #6102 head `84f72fc05` merged onto `main` `6239ceffc`; the merge is clean.** Host: Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, NVIDIA RTX 4070 (Ryzen 7 5700X). - **Build:** full build (`cmake --build build -- -k 0`) and `libs` both succeed. One observation: `WindowsTlsBuilder.cpp` now gives 8 GCC 15.2 `-Wstringop-overflow` warnings, where `main`'s build of the same file gives none: - `warning: writing 8 bytes into a region of size between 5 and 6` once, and `writing 1 byte into a region of size 0` 7 times; - all point at `WindowsTlsBuilder.cpp:190:50`, `movedBytes.insert(movedBytes.end(), 4, 0)`, inlined into `WindowsTlsBuilder::Build`. That line is `main`'s code, so this looks like a false positive that the changed inlining exposes. It is not an error. - **Tests, `--repeat until-fail:3`:** - `tls_function_coverage_gs_traps` and `tls_function_coverage_rejected`: 3/3; - the 35 TLS tests (`tls_function_coverage_*`, `tls_diagnostics`, `guest_tls`, `empty_tls`): 3/3 each, 105 of 105 runs. - **Suite, `ctest -j8 --timeout 120 -E '^agc_driver_|^video_out_flip'`:** 809 tests (`main`'s 808 plus `gs_traps`). 808 pass, including the 2 skipped. `hardware_oracle_compare` timed out under host load and passes alone (8.75 s). **Prospero Win (PPSA99995).** Catalog release, converted with `relinker --windows --trap-sdk-syscall-stubs --module-dir win/wine/lib/wine/x86_64-unix --registry unused-filter=0 src6/eboot.elf ...` and run with the display on. `main`: the relinker exits 2 and writes nothing: ``` FAIL: Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x3214c) Input: ...\PPSA99995\src6\win\wine\lib\wine\x86_64-unix\ntdll.prx ``` This PR: it converts, with 54 output files. In the input `ntdll.prx`, objdump of the executable segment finds six GS instructions, at 0x2e14c, 0x2e1a0, 0x2e45f, 0x2e504, 0x2e52b and 0x2e56b: - `mov %gs:0x378,%rcx` ×3; - `mov %gs:0x30,%r13` ×2; - `mov %gs:0x330,%r10` ×1. In the output `ntdll.prx.guest.prx`, each is `0f 0b` followed by 7 `90`, with the 8 bytes on each side unchanged, and none of the original 9-byte sequences is left. The title then stops at load, after 0.9 s, with exit `0xC0000139`: ``` FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx FAIL: unresolved ELF import fEPEwROdCwM from libSceVideoOut.prx FAIL: unresolved ELF import u-9bhWQApq8 from libSceVideoOut.prx FAIL: unresolved ELF import UPZWCH8qTM4 from libSceVideoOut.prx FAIL: unresolved ELF import N17AK88NdD0 from libSceVideoOut.prx FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx GetLastError: 127 - The specified procedure could not be found. ``` Those are: - `sysarch`, imported by `ntdll` and `wow64native`; - `sceVideoOutCursorDisable`, `sceVideoOutCursorSetImageAddress`, `sceVideoOutCursorEnable` and `sceVideoOutCursorSetPosition`, imported by `libvulkan`. No frame is presented. Verdict: confirmed. Conversion now succeeds, and the six GS sites become 9-byte `ud2`/NOP traps. The next stop is load, on `sysarch` (#6028) and the four `sceVideoOutCursor*` imports, exactly as the PR describes. AI-assisted: yes (Claude Code)
DavidSamir commented 2026-10-15 05:23:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-15T05:23:17Z.


@jotitadev thanks for checking the macOS writer. The debt line already reads "In Windows output, …", so it stays accurate for this PR. I'll do the same in-place trap for MacOsImage.cpp's TLS scan as a follow-up PR, as CONTRIBUTING asks, and link it here.

@screamm thanks for the cross-check. I'll look at the -Wstringop-overflow warnings on WindowsTlsBuilder.cpp:190 with GCC 15.2 and report back here.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6185077854 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#issuecomment-6185077854). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-15T05:23:17Z. --- @jotitadev thanks for checking the macOS writer. The debt line already reads "In Windows output, …", so it stays accurate for this PR. I'll do the same in-place trap for `MacOsImage.cpp`'s TLS scan as a follow-up PR, as CONTRIBUTING asks, and link it here. @screamm thanks for the cross-check. I'll look at the `-Wstringop-overflow` warnings on `WindowsTlsBuilder.cpp:190` with GCC 15.2 and report back here. AI-assisted: yes
DavidSamir commented 2026-10-15 05:53:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-15T05:53:03Z.


@screamm confirmed: recompiling WindowsTlsBuilder.cpp alone gives 8 -Wstringop-overflow warnings at movedBytes.insert(movedBytes.end(), 4, 0) with this PR and none on main (WinLibs GCC 15.2.0 r7, Release). Applying the traps inside the scan loop instead of after it did not change that.

f1735f59f writes that line as movedBytes.resize(movedBytes.size() + 4), which appends the same four zero bytes, and the file then builds without warnings. With it:

  • the 35 TLS tests pass;
  • the relinker's output for all 79 catalog titles that have an ELF is byte-identical to that of 84f72fc05, Prospero Win included;
  • tools/check_conventions.py passes.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6185479733 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#issuecomment-6185479733). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-15T05:53:03Z. --- @screamm confirmed: recompiling `WindowsTlsBuilder.cpp` alone gives 8 `-Wstringop-overflow` warnings at `movedBytes.insert(movedBytes.end(), 4, 0)` with this PR and none on `main` (WinLibs GCC 15.2.0 r7, Release). Applying the traps inside the scan loop instead of after it did not change that. f1735f59f writes that line as `movedBytes.resize(movedBytes.size() + 4)`, which appends the same four zero bytes, and the file then builds without warnings. With it: - the 35 TLS tests pass; - the relinker's output for all 79 catalog titles that have an ELF is byte-identical to that of 84f72fc05, Prospero Win included; - `tools/check_conventions.py` passes. AI-assisted: yes
screamm commented 2026-10-15 08:53:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-15T08:53:29Z.


Re-check of head f1735f59f on Windows, merged onto main c0be1f69b (clean). 84f72fc05 was merged onto the same main for comparison.

Windows 11 Pro 26220, Ryzen 7 5700X, RTX 4070 (driver 596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release.

  • Warnings: with 84f72fc05, recompiling WindowsTlsBuilder.cpp still gives the 8 -Wstringop-overflow warnings at WindowsTlsBuilder.cpp:190:50. With f1735f59f the file compiles with no warnings, and the full build and libs afterwards have none either.
  • ctest -R '^(tls_function_coverage_.*|tls_diagnostics|guest_tls|empty_tls)$' --repeat until-fail:3: 35/35, 3 of 3 (105 runs), gs_traps and rejected included. gs_traps with main's relinker still fails on 65 48 8b 0c 25 78 03 00 00.
  • tools/check_conventions.py --base origin/main and git diff --check: pass.
  • Relinker output, 84f72fc05 against f1735f59f, each with the catalog's flags and the same output path, every file hashed. All 114 output files of 9 titles are byte-identical:
    • PPSA99995 Prospero Win (--trap-sdk-syscall-stubs --module-dir win/wine/lib/wine/x86_64-unix, 54 files);
    • PPSA28319 (--module-dir Media/Modules --module-dir Media/Plugins, 15);
    • PPSA99169 (--executable picker/picker.bin, 9);
    • PPSA85300 (--windows-fixed-base 0x400000, 6);
    • PPSA01153 (--trap-sdk-syscall-stubs, 6);
    • PPSA99420, PPSA99002, PPSA97510 and PPSA99082 (6 each).

Verdict: confirmed. The warnings are gone and the conversion output is unchanged, so the earlier Prospero Win result still holds for this head.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6188288605 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#issuecomment-6188288605). Originally posted by [screamm](https://github.com/screamm) on 2026-10-15T08:53:29Z. --- Re-check of head `f1735f59f` on Windows, merged onto `main` `c0be1f69b` (clean). `84f72fc05` was merged onto the same `main` for comparison. Windows 11 Pro 26220, Ryzen 7 5700X, RTX 4070 (driver 596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release. - Warnings: with `84f72fc05`, recompiling `WindowsTlsBuilder.cpp` still gives the 8 `-Wstringop-overflow` warnings at `WindowsTlsBuilder.cpp:190:50`. With `f1735f59f` the file compiles with no warnings, and the full build and `libs` afterwards have none either. - `ctest -R '^(tls_function_coverage_.*|tls_diagnostics|guest_tls|empty_tls)$' --repeat until-fail:3`: 35/35, 3 of 3 (105 runs), `gs_traps` and `rejected` included. `gs_traps` with `main`'s relinker still fails on `65 48 8b 0c 25 78 03 00 00`. - `tools/check_conventions.py --base origin/main` and `git diff --check`: pass. - Relinker output, `84f72fc05` against `f1735f59f`, each with the catalog's flags and the same output path, every file hashed. All 114 output files of 9 titles are byte-identical: - PPSA99995 Prospero Win (`--trap-sdk-syscall-stubs --module-dir win/wine/lib/wine/x86_64-unix`, 54 files); - PPSA28319 (`--module-dir Media/Modules --module-dir Media/Plugins`, 15); - PPSA99169 (`--executable picker/picker.bin`, 9); - PPSA85300 (`--windows-fixed-base 0x400000`, 6); - PPSA01153 (`--trap-sdk-syscall-stubs`, 6); - PPSA99420, PPSA99002, PPSA97510 and PPSA99082 (6 each). Verdict: confirmed. The warnings are gone and the conversion output is unchanged, so the earlier Prospero Win result still holds for this head. AI-assisted (Claude Code).
github-actions[bot] commented 2026-10-15 12:14:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:14:43Z.


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 6974 core/relinker/elfpatcher/src/windows/WindowsTlsBuilder.cpp L100-101

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 2780 core/relinker/CMakeLists.txt
PR 5021 core/relinker/CMakeLists.txt
docs/dev/debt/relinker.md
PR 6044 core/relinker/CMakeLists.txt
PR 6111 docs/dev/debt/relinker.md
PR 6314 core/relinker/CMakeLists.txt
PR 6354 docs/dev/debt/relinker.md
PR 6879 core/relinker/CMakeLists.txt
PR 6977 core/relinker/CMakeLists.txt
docs/dev/debt/relinker.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191796242 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#issuecomment-6191796242). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:14:43Z. --- <!-- 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 6974](https://www.github.com/boykopovar/AnyPS5/pull/6974) | `core/relinker/elfpatcher/src/windows/WindowsTlsBuilder.cpp` [L100-101](https://github.com/boykopovar/AnyPS5/blob/e00260b6b38419e779845b352f051d9b69321649/core/relinker/elfpatcher/src/windows/WindowsTlsBuilder.cpp#L100-L101) | | | 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 2780](https://www.github.com/boykopovar/AnyPS5/pull/2780) | `core/relinker/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/relinker.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/relinker/CMakeLists.txt` | | [PR 6111](https://www.github.com/boykopovar/AnyPS5/pull/6111) | `docs/dev/debt/relinker.md` | | [PR 6314](https://www.github.com/boykopovar/AnyPS5/pull/6314) | `core/relinker/CMakeLists.txt` | | [PR 6354](https://www.github.com/boykopovar/AnyPS5/pull/6354) | `docs/dev/debt/relinker.md` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/relinker/CMakeLists.txt` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/relinker/CMakeLists.txt`<br>`docs/dev/debt/relinker.md` |
DavidSamir commented 2026-10-15 16:18:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-15T16:18:53Z.


@jotitadev the macOS half is up as #6458: GS accesses in macOS output become ud2 and NOP padding in place, the same rule as this PR, and Prospero Win (PPSA99995) converts for macOS with it. It sits on #6410, which first had to stop the macOS scan from refusing OpenSSL's CRYPTOGAMS by <[email protected]> string as a GS access (a decoding that starts inside an earlier instruction, the case 90dcd6256 already skips for Windows); trapping those bytes would have overwritten code in 27 catalog titles. With #6410, #6419, #6448 and #6458, all 79 catalog titles convert for macOS (47 on main).

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6196823525 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#issuecomment-6196823525). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-15T16:18:53Z. --- @jotitadev the macOS half is up as #6458: GS accesses in macOS output become `ud2` and NOP padding in place, the same rule as this PR, and Prospero Win (PPSA99995) converts for macOS with it. It sits on #6410, which first had to stop the macOS scan from refusing OpenSSL's `CRYPTOGAMS by <[email protected]>` string as a GS access (a decoding that starts inside an earlier instruction, the case 90dcd6256 already skips for Windows); trapping those bytes would have overwritten code in 27 catalog titles. With #6410, #6419, #6448 and #6458, all 79 catalog titles convert for macOS (47 on `main`). AI-assisted: yes
screamm commented 2026-10-16 08:24:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-16T08:24:13Z.


Re-check of head f1735f59f on current main 5d9dcc42d, alone and stacked with #6028 (fb0f83ddf) and #6135 (10bc2f05a). My earlier two comments covered conversion and byte-identity on older main; this one runs the title with the libraries.

Windows 11 Pro 26220, Ryzen 7 5700X, NVIDIA RTX 4070 (596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release.

  • Merges: clean alone and in the order #6028 -> #6102 -> #6135. WindowsTlsBuilder.cpp compiles without warnings. Full build with -k 0 on the stack: only agc_driver_gpu_indirect_arguments_misaligned_writer_ahead_tests fails (the 64 KiB alignas that also fails on main, #6452/#6478); libs builds.
  • The 35 TLS tests (tls_function_coverage_*, tls_diagnostics, guest_tls, empty_tls), --repeat until-fail:3: 105 of 105.
  • Negative control: gs_traps with main's relinker fails with Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00), and passes with this PR's.
  • Non-GPU suite on the stack (-j8 --timeout 120 -E '^agc_driver_|^video_out_flip'): 837 of 840 pass, 2 skipped, hardware_oracle_compare timed out under load and passes alone (11.2 s).
  • tools/check_conventions.py --base origin/main and git diff --check: pass.

Prospero Win (PPSA99995), --trap-sdk-syscall-stubs --module-dir win/wine/lib/wine/x86_64-unix, display on, 125 s limit:

  • main: the relinker exits 2 with FAIL: Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x3214c).
  • This PR alone (with main's libraries), 2 runs: it converts; the six GS instructions in ntdll are six 0f 0b + 7x 90 sites in the output. The title then exits 0xC0000139 after about 3 s, 0 frames:
    FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx
    FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx
    FAIL: unresolved ELF import fEPEwROdCwM from libSceVideoOut.prx
    FAIL: unresolved ELF import u-9bhWQApq8 from libSceVideoOut.prx
    FAIL: unresolved ELF import UPZWCH8qTM4 from libSceVideoOut.prx
    FAIL: unresolved ELF import N17AK88NdD0 from libSceVideoOut.prx
    FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx
    GetLastError: 127 - The specified procedure could not be found.
    
  • With #6028 added, 2 runs: only the four libSceVideoOut.prx lines remain.
  • With #6028 and #6135, 2 runs: still running at 125 s, 104 and 119 frames (about 1 FPS), no stop line, launcher library screen, session-0.log has launcher video=ok pad=ok hid=ok frame=1 apps=0. No trapped GS instruction was reached in that time (no illegal-instruction fault).

Verdict: confirmed on current main; with #6028 and #6135 this moves Prospero Win from refused conversion to its launcher on Windows.

Not checked: Linux, macOS, a console, any program run inside Prospero Win.

Written with Claude Code assistance (validation by a subagent, reviewed in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6211311818 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#issuecomment-6211311818). Originally posted by [screamm](https://github.com/screamm) on 2026-10-16T08:24:13Z. --- Re-check of head `f1735f59f` on current main `5d9dcc42d`, alone and stacked with #6028 (`fb0f83ddf`) and #6135 (`10bc2f05a`). My earlier two comments covered conversion and byte-identity on older main; this one runs the title with the libraries. Windows 11 Pro 26220, Ryzen 7 5700X, NVIDIA RTX 4070 (596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release. - Merges: clean alone and in the order #6028 -> #6102 -> #6135. `WindowsTlsBuilder.cpp` compiles without warnings. Full build with `-k 0` on the stack: only `agc_driver_gpu_indirect_arguments_misaligned_writer_ahead_tests` fails (the 64 KiB `alignas` that also fails on `main`, #6452/#6478); `libs` builds. - The 35 TLS tests (`tls_function_coverage_*`, `tls_diagnostics`, `guest_tls`, `empty_tls`), `--repeat until-fail:3`: 105 of 105. - Negative control: `gs_traps` with `main`'s relinker fails with `Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00)`, and passes with this PR's. - Non-GPU suite on the stack (`-j8 --timeout 120 -E '^agc_driver_|^video_out_flip'`): 837 of 840 pass, 2 skipped, `hardware_oracle_compare` timed out under load and passes alone (11.2 s). - `tools/check_conventions.py --base origin/main` and `git diff --check`: pass. **Prospero Win (PPSA99995)**, `--trap-sdk-syscall-stubs --module-dir win/wine/lib/wine/x86_64-unix`, display on, 125 s limit: - `main`: the relinker exits 2 with `FAIL: Unsupported Windows guest TLS instruction (bytes: 65 48 8b 0c 25 78 03 00 00) (offset 0x3214c)`. - This PR alone (with `main`'s libraries), 2 runs: it converts; the six GS instructions in `ntdll` are six `0f 0b` + 7x `90` sites in the output. The title then exits `0xC0000139` after about 3 s, 0 frames: ``` FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx FAIL: unresolved ELF import fEPEwROdCwM from libSceVideoOut.prx FAIL: unresolved ELF import u-9bhWQApq8 from libSceVideoOut.prx FAIL: unresolved ELF import UPZWCH8qTM4 from libSceVideoOut.prx FAIL: unresolved ELF import N17AK88NdD0 from libSceVideoOut.prx FAIL: unresolved ELF import b7uXQmnfB2s from libkernel.prx GetLastError: 127 - The specified procedure could not be found. ``` - With #6028 added, 2 runs: only the four `libSceVideoOut.prx` lines remain. - With #6028 and #6135, 2 runs: still running at 125 s, 104 and 119 frames (about 1 FPS), no stop line, launcher library screen, `session-0.log` has `launcher video=ok pad=ok hid=ok frame=1 apps=0`. No trapped GS instruction was reached in that time (no illegal-instruction fault). Verdict: confirmed on current main; with #6028 and #6135 this moves Prospero Win from refused conversion to its launcher on Windows. Not checked: Linux, macOS, a console, any program run inside Prospero Win. Written with Claude Code assistance (validation by a subagent, reviewed in this session).
adriadam10 commented 2026-10-16 23:12:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:12:17Z.


Checked the merged tree: build and the relinker ctest scope green (autorun_exit_status timed out once under load and passes alone), and tls_function_coverage_gs_traps fails without the WindowsTlsBuilder.cpp change. The debt line is in the right section. Windows evidence from @screamm covers the conversion on that platform; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226419812 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6102#issuecomment-6226419812). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T23:12:17Z. --- Checked the merged tree: build and the relinker ctest scope green (`autorun_exit_status` timed out once under load and passes alone), and `tls_function_coverage_gs_traps` fails without the `WindowsTlsBuilder.cpp` change. The debt line is in the right section. Windows evidence from @screamm covers the conversion on that platform; merging.
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!6102
No description provided.