diff options
Diffstat (limited to 'runtime/src/tls_host.cpp')
| -rw-r--r-- | runtime/src/tls_host.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/runtime/src/tls_host.cpp b/runtime/src/tls_host.cpp index ab234cbd9..a55941873 100644 --- a/runtime/src/tls_host.cpp +++ b/runtime/src/tls_host.cpp | |||
| @@ -5,6 +5,11 @@ | |||
| 5 | // __declspec(thread) access in mapped code reads a valid TEB slot. The anchor itself is never used; the loader saves | 5 | // __declspec(thread) access in mapped code reads a valid TEB slot. The anchor itself is never used; the loader saves |
| 6 | // and restores the helper's own block, so the helper's CRT TLS state is not disturbed. | 6 | // and restores the helper's own block, so the helper's CRT TLS state is not disturbed. |
| 7 | // | 7 | // |
| 8 | // One more clone, leonida_tls_host_<pid>_home.dll, is loaded the first time an executable is mapped: the runtime's | ||
| 9 | // own EXE, which Windows gave module TLS index 0, moves its block to that clone's index on every thread so the mapped | ||
| 10 | // executable can take index 0. That clone stays loaded until the process ends, and its slot then holds the runtime's | ||
| 11 | // live TLS, so nothing in this DLL may read or write its own TLS (gta6rt_tls_host_keep is never called). | ||
| 12 | // | ||
| 8 | // The Windows loader also calls this DLL's DllMain with DLL_THREAD_ATTACH on every new thread (after it has built that | 13 | // The Windows loader also calls this DLL's DllMain with DLL_THREAD_ATTACH on every new thread (after it has built that |
| 9 | // thread's TLS array) and with DLL_THREAD_DETACH when a thread exits (before it frees the array). The loader registers | 14 | // thread's TLS array) and with DLL_THREAD_DETACH when a thread exits (before it frees the array). The loader registers |
| 10 | // a callback here so it can give each new thread its own copy of the mapped image's TLS, and put this DLL's block back | 15 | // a callback here so it can give each new thread its own copy of the mapped image's TLS, and put this DLL's block back |