From: Sergei Trofimovich <[email protected]>
gcc is known to be too smart about __xd_a / _xd_z aliasing,
thus the workarounds with uintptr exist.
'_CRTALLOC(".CRT$XDA")' has no meaning for 'static' allocated
variables thus code never worked as intended.
The patch now relies on externally defined by binutils entries.
Signed-off-by: Sergei Trofimovich <[email protected]>
---
crt/tlssup.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/crt/tlssup.c b/crt/tlssup.c
index 3a0e635..bd652cc 100644
--- a/crt/tlssup.c
+++ b/crt/tlssup.c
@@ -66,8 +66,13 @@ _CRTALLOC(".tls") const IMAGE_TLS_DIRECTORY _tls_used = {
#define DISABLE_MS_TLS 1
-static _CRTALLOC(".CRT$XDA") _PVFV __xd_a = 0;
-static _CRTALLOC(".CRT$XDZ") _PVFV __xd_z = 0;
+extern _PVFV __crt_xd_start__; /* defined by linker script */
+/*
+ * Content between '__crt_xd_start__' and '__crt_xd_end__'
+ * must is defined in ".CRT$XD"* sections and
+ * will be merged by linker script (see binutils part).
+ */
+extern _PVFV __crt_xd_end__; /* defined by linker script */
#if !defined (DISABLE_MS_TLS)
static __CRT_THREAD TlsDtorNode *dtor_list;
@@ -92,7 +97,6 @@ BOOL WINAPI
__dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
_PVFV *pfunc;
- uintptr_t ps;
#ifndef _WIN64
if (_winmajor < 4)
@@ -129,13 +133,10 @@ __dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID
lpreserved)
return TRUE;
}
- ps = (uintptr_t) &__xd_a;
- ps += sizeof (uintptr_t);
- for ( ; ps != (uintptr_t) &__xd_z; ps += sizeof (uintptr_t))
+ for (pfunc = &__crt_xd_start__; pfunc != &__crt_xd_end__; ++pfunc)
{
- pfunc = (_PVFV *) ps;
- if (*pfunc != NULL)
- (*pfunc)();
+ if (*pfunc)
+ (*pfunc)();
}
return TRUE;
}
--
1.7.12
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public