Repository navigation
Loader: preserve an empty import table for Windows 10 static TLS - #28
Conversation
|
Looks good to me, and the fallback when the last 20 bytes aren't a zero descriptor keeps the old behaviour ( |
Windows 10 maps the prepared image with both entries empty. The binder already retains the original slot RVAs, so preparation need not locate a linker-provided terminator.
|
Update: A static TLS check changed the conclusion below. See the corrected results and fix. @Sunkiller-qc I tested your suggestion on Windows 10 22H2 (19045.7846). The prepared executable and all four DLLs mapped and unloaded with both layouts. VIctory's map-only run with the import and IAT directories cleared also bound all five images with zero missing imports. I switched to clearing both entries in 4da3d63. The binder uses the slot RVAs saved from the original image. A regression test now covers an import-directory size that excludes the terminator and checks that the original IAT slots survive preparation. All 13 loader and PE library tests passed. |
|
@Sunkiller-qc, correction to my previous result: mapping and binding succeeded, but my test missed Windows static TLS initialization. I checked the index through the mapped TLS directory on Windows 10 19045.7846, before running any title code. In fresh processes, the executable and both TLS-bearing DLLs each received index 6 with an empty import descriptor. With both directory entries cleared, all three index slots remained at their on-disk zero. The execution test failed during startup with that layout. 25a3e95 restores the empty descriptor and locates it using the parsed descriptor count, so the linker can exclude the terminator from its reported size. All five prepared images match the original working layout byte for byte, and the corrected map-only command reported static TLS redirection and zero missing imports. All 14 loader and PE tests passed, including a Windows test that checks the assigned TLS index on a prepared DLL. |
|
Tested
AI-assisted (DeepSeek V4.1 Flash coding agent). |
Use the descriptor count already validated by the PE parser, so the directory size need not include the null terminator. Check the OS-assigned static TLS index on a mapped test DLL.
|
Re-checked the new head
AI-assisted (DeepSeek V4.1 Flash coding agent). |
|
Tested
|
|
Re-checked the new head
AI-assisted (DeepSeek V4.1 Flash coding agent). |
|
Additional Windows 10 execution data for the merged change, included in main d2a4bae (not tested in isolation): Windows 10 Enterprise 22H2, Ryzen 5 3600, GTX 1660 Ti, Agility SDK 1.620.2. The prepared title executable had an empty import descriptor and retained its IAT directory. The executable and four DLLs mapped and bound with zero missing imports, and the title reached the prologue in two runs. The build also had diagnostic logging and local Agility exports; one run included PR #233. The loader library tests passed 19/19, including windows_assigns_static_tls_to_a_prepared_dll. The later GPU DEVICE_HUNG does not establish a loader defect. AI-assisted testing and report (OpenAI Codex). |
Loader: preserve an empty import table for Windows 10 static TLS
What changed
Keep a valid empty import table in the DLL VIctory prepares for Windows. Point the import-directory entry at the existing null descriptor and retain the original IAT directory. VIctory binds the slots recorded when it parsed the original image.
The PE parser already walks the descriptors to their null terminator. Using the number of descriptors it read handles linkers whose import-directory size excludes the terminator.
Tested
AI assistance: Codex prepared the patch and ran the checks above.