fix(relinker): relocate Windows guest TLS from its thread pointer #4739
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4739"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-12T20:17:33Z.
What
A Windows guest module with an 8-byte TLS image aligned to 0, 1 or 8 bytes receives a TPOFF64 displacement of -16 even though its actual thread pointer is 8 bytes after the template. Its TLS getter reads another location instead of the initialized value. Compute TPOFF64 relative to the same thread-pointer offset used by WindowsTlsBuilder; keep the physical block allocation and minimum 16-byte alignment unchanged.
The native TLS regression uses the existing dynamic/executable fixtures. Move those two functions unchanged into guest_import_fixtures.py, imported by both guest_tls and windows_import_modules; retain their old Windows-module re-exports for existing callers. This removes the circular import reported when #3579 imports guest_with_tls and data_directory in the opposite direction. No second fixture implementation or #3579 production change is added here.
Tested
Windows, MinGW-w64 GCC 15.2.0, Python 3.14, Release, relinker-only, main
cac4e9688.67ddb3624: reproduced circular ImportError in 14 of 65 Python modules; each PR alone imports successfully. Fixed combination: all 66 modules import in fresh subprocesses, both entrypoint orders pass, and 17 fixture profiles are byte-identical, including all six TLS getters.The committed conventions check and git diff --check pass. No game or PS5 console was run; Linux/macOS runtime validation was not performed locally. No performance improvement is claimed.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T04:52:44Z.
Windows test: head
a135491d9merged onto currentmaine51428bf2(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j2: full build 0 errors; ctest with the filter^guest_tls$: guest_tls passed (1 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T08:00:59Z.
Heads-up for #3579 and #4739 (posting the same note on both): they merge without a textual conflict, but together they create a circular import between two relinker test modules.
from test_guest_tls import data_directory, guest_with_tlstotest_windows_import_modules.py.from test_windows_import_modules import dynamic, executabletotest_guest_tls.py.Linux (Arch, Python 3.14, Release),
main7e181fcc3with both merged:guest_tls,guest_symbol_names,windows_import_modulesandweak_importsfail withand the tests that import those modules fail the same way (
guest_none_relocations,guest_gnu_hash,guest_module_identity,tls_diagnostics, ...). With either PR alone,guest_tlsandwindows_import_modulespass. Whichever lands second will need to move the shared helpers (for example into a small common test module) instead of importing across.Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-13T09:09:22Z.
Thanks for catching this. I reproduced the circular import with #3579 and moved dynamic/executable unchanged into guest_import_fixtures.py, retaining their Windows-module re-exports for existing callers.
#4739 is updated at
723d02c6b. Its full relinker suite passes 140/140 tests. I also built the exact combination with #3579 at67ddb3624and ran all 14 affected runtime tests successfully, including guest_tls and windows_import_modules. Both import orders and all 66 Python modules now load successfully.AI-assisted: yes. — Codex
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T16:34:18Z.
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.
main)core/relinker/relinker/tests/test_windows_import_modules.pyL115-121core/relinker/relinker/tests/test_windows_import_modules.pyL115-121, L190-215core/relinker/relinker/tests/test_windows_import_modules.pyL190-215