3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
14 * Components which depend upon TLS must express a dependency on the symbol
15 * _tls_used. This will cause said symbol to be emitted.
17 * The linker (in the case of both Microsoft's linker and Binutils, at least)
18 * will point the TLS directory entry in the PE header to _tls_used.
20 * NOTE: On Windows versions < NT 6.0, the TLS support _only_ works for
21 * the main executable and any DLLs loaded as dependencies of it
24 extern char __tls_start__[], __tls_end__[];
25 ULONG _tls_index = TLS_OUT_OF_INDEXES;
27 extern void NTAPI _PDCLIB_runTlsCallbacks(void * image, DWORD reason, PVOID pv);
28 static PIMAGE_TLS_CALLBACK tlsCallbacks[] = {
29 &_PDCLIB_runTlsCallbacks,
34 __attribute__((__section__(".rdata$T")))
36 __declspec(allocate(".rdata$T"))
39 const IMAGE_TLS_DIRECTORY64 _tls_used = {
41 const IMAGE_TLS_DIRECTORY _tls_used = {
43 (uintptr_t) &__tls_start__,
44 (uintptr_t) &__tls_end__,
45 (uintptr_t) &_tls_index, // TLS index
46 (uintptr_t) &tlsCallbacks[0], // TLS callback array
47 (ULONG) 0, // Size of zero fill
48 (ULONG) 0 // Characteristics
53 #include "_PDCLIB_test.h"
55 /* Tested in tss_get.c */