pe: check a page-spanning TLS template and two callbacks in table order #876
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/883"
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 R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T15:43:57Z.
Refs #870, Refs #165
What this changes
Extends the existing
cpu_native_tls_valuetest (tests/cpu/tls_value.cpp,tests/cpu/native_tls_value_check.py) instead of adding a parallel fixture. This is the loader TLS follow-up listed on #870. The #870 checkpoint of 15:20Z reports two TLS callbacks in the static intake of the main executable, so this checks two-callback ordering on a source-built image. No game-derived data is used. No change totools/pe_map.cpporCMakeLists.txt.Fixture (
cpu_tls_value, MSVC, static CRT):span_word(i)), so the template spans a 4 KiB page boundary with different values on each side..CRT$XLM(caller 3) follows the existing one in.CRT$XLB(caller 1). Each callback and the entry point (caller 2) report the int in the low 16 bits and the number of array words that differ from the template above them. A fresh block reports 7.tls_value_workerkeeps a worker alive while another worker writes.Harness, under
LoadLibraryWandpe_map, each in a fresh child process:pefile: the array crosses a page boundary inside the template, and the two callbacks appear in the callback table in that order.Negative controls patch copies of the built DLL. Both loaders must reject each one with a named diagnostic, or the test fails:
callback order: ('main', 1) ran callers [3, 1, 2]template: main observed 0x6380007, expected 0x7 (value 7, 1592 array words differ from the template)(dev)A mutation that removes the order check makes the test fail on the swapped control. This shows the test fails closed.
Scope
This checks the TLS stage ahead of the current #870 boundary. Per the maintainer's checkpoints, the real mapping probe still stops at import binding (#880). This PR does not move that boundary and makes no claim about the executable's TLS or entry run. It is separate from #872 (conversion driver).
Test
Commit
02cd2ac, rebased onorigin/main. Windows 10 Pro 10.0.19045.6466, MSVC 19.44.35207.1 x64, Ninja.Both presets reject both negative controls under both loaders. The three Python checks pass. No capability skips. The other TLS tests (
cpu_native_tls,cpu_native_tls_data) were not rerun: their sources and the sink are unchanged.🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T15:53:00Z.
Review follow-up at
54b6781: the layout now selects the first boundary strictly inside the array even when the linker places the start exactly on a page boundary. Both presets passed all three TLS CTests on Windows 11 with MSVC 19.51. Native and mapped runs rejected the swapped callback order and the damaged later-page controls separately, and the positive runs matched on both worker threads. CI is rerunning on the new head. This is the DLL/TLS slice of #165; the EXE acceptance remains open.