mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
[VCRUNTIME] Add TLS callback support
This commit is contained in:
parent
7f050e0a6d
commit
32c349d30e
3 changed files with 55 additions and 0 deletions
|
@ -24,6 +24,7 @@ list(APPEND VCRT_COMMON_SOURCES
|
|||
_fltused.c
|
||||
initializers.cpp
|
||||
isa_available.cpp
|
||||
tlssup.c
|
||||
)
|
||||
|
||||
list(APPEND VCRT_RUNTIME_SOURCES
|
||||
|
|
|
@ -38,6 +38,20 @@ extern "C" {
|
|||
#pragma section(".CRT$XPZ", long, read)
|
||||
#pragma section(".CRT$XTA", long, read)
|
||||
#pragma section(".CRT$XTZ", long, read)
|
||||
|
||||
|
||||
#pragma section(".CRT$XDA",long,read)
|
||||
#pragma section(".CRT$XDC",long,read)
|
||||
#pragma section(".CRT$XDZ",long,read)
|
||||
|
||||
#pragma section(".CRT$XLA",long,read) // TLS callback start
|
||||
#pragma section(".CRT$XLC",long,read) // TLS constructors
|
||||
#pragma section(".CRT$XLD",long,read) // TLS destructors
|
||||
#pragma section(".CRT$XLZ",long,read) // TLS callback end
|
||||
|
||||
#pragma section(".tls",long,read,write)
|
||||
#pragma section(".tls$AAA",long,read,write)
|
||||
#pragma section(".tls$ZZZ",long,read,write)
|
||||
#endif
|
||||
|
||||
extern _PIFV __xi_a[];
|
||||
|
@ -51,6 +65,8 @@ extern _PVFV __xt_z[];
|
|||
|
||||
extern char __ImageBase;
|
||||
|
||||
extern const IMAGE_TLS_DIRECTORY _tls_used;
|
||||
|
||||
#define CRT_WARNING_DISABLE_PUSH(wn, message) \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable: wn))
|
||||
|
|
38
sdk/lib/vcruntime/tlssup.c
Normal file
38
sdk/lib/vcruntime/tlssup.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// tlssup.c
|
||||
//
|
||||
// Copyright (c) 2025 Timo Kreuzer
|
||||
//
|
||||
// TLS callback support
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
|
||||
#include <internal_shared.h>
|
||||
|
||||
// Dummy TLS undex
|
||||
unsigned int _tls_index;
|
||||
|
||||
// The TLS data
|
||||
_CRTALLOC(".tls") char *_tls_start = NULL;
|
||||
_CRTALLOC(".tls$ZZZ") char *_tls_end = NULL;
|
||||
|
||||
// Describes the range of TLS callbacks.
|
||||
_CRTALLOC(".CRT$XLA") PIMAGE_TLS_CALLBACK __xl_a = 0;
|
||||
_CRTALLOC(".CRT$XLZ") PIMAGE_TLS_CALLBACK __xl_z = 0;
|
||||
|
||||
//
|
||||
// The TLS directory.
|
||||
// The linker will point the executables TLS data directory entry to this.
|
||||
// Must be force-included with "#pragma comment(linker, "/INCLUDE:_tls_used")"
|
||||
// or by referencing it from another compilation unit.
|
||||
//
|
||||
const IMAGE_TLS_DIRECTORY _tls_used =
|
||||
{
|
||||
(ULONG_PTR)&_tls_start,
|
||||
(ULONG_PTR)&_tls_end,
|
||||
(ULONG_PTR)&_tls_index,
|
||||
(ULONG_PTR)(&__xl_a + 1),
|
||||
(ULONG)0,
|
||||
(ULONG)0
|
||||
};
|
Loading…
Reference in a new issue