If a constructor has a non-default priority, it is placed in a section
.ctors.1234 instead of the default .ctors.

With the default sorting, .ctors.1234 would be sorted after .ctors$zzz,
which would make such a constructor be missed.

Instead of implementing a custom sorting, ordering .ctors.1234 before
.ctors$zzz, just use .ctors.99999 as sentinel here instead.

This depends on a lld patch that uses period '.' as section suffix
separator: https://reviews.llvm.org/D40408

Signed-off-by: Martin Storsjö <mar...@martin.st>
---
 mingw-w64-crt/crt/crtdll.c | 4 ++--
 mingw-w64-crt/crt/crtexe.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c
index 6b5418b..77ebecc 100644
--- a/mingw-w64-crt/crt/crtdll.c
+++ b/mingw-w64-crt/crt/crtdll.c
@@ -43,8 +43,8 @@ extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
 #ifdef __clang__
 __attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void *)))) 
const void * __CTOR_LIST__ = (void *) -1;
 __attribute__ (( __section__ (".dtors"), __used__ , aligned(sizeof(void *)))) 
const void * __DTOR_LIST__ = (void *) -1;
-__attribute__ (( __section__ (".ctors$zzz"), __used__ , aligned(sizeof(void 
*)))) const void * __CTOR_END__ = (void *) 0;
-__attribute__ (( __section__ (".dtors$zzz"), __used__ , aligned(sizeof(void 
*)))) const void * __DTOR_END__ = (void *) 0;
+__attribute__ (( __section__ (".ctors.99999"), __used__ , aligned(sizeof(void 
*)))) const void * __CTOR_END__ = (void *) 0;
+__attribute__ (( __section__ (".dtors.99999"), __used__ , aligned(sizeof(void 
*)))) const void * __DTOR_END__ = (void *) 0;
 #endif
 
 /* TLS initialization hook.  */
diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
index baa8d81..b4b694d 100644
--- a/mingw-w64-crt/crt/crtexe.c
+++ b/mingw-w64-crt/crt/crtexe.c
@@ -63,8 +63,8 @@ extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
 #ifdef __clang__
 __attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void *)))) 
const void * __CTOR_LIST__ = (void *) -1;
 __attribute__ (( __section__ (".dtors"), __used__ , aligned(sizeof(void *)))) 
const void * __DTOR_LIST__ = (void *) -1;
-__attribute__ (( __section__ (".ctors$zzz"), __used__ , aligned(sizeof(void 
*)))) const void * __CTOR_END__ = (void *) 0;
-__attribute__ (( __section__ (".dtors$zzz"), __used__ , aligned(sizeof(void 
*)))) const void * __DTOR_END__ = (void *) 0;
+__attribute__ (( __section__ (".ctors.99999"), __used__ , aligned(sizeof(void 
*)))) const void * __CTOR_END__ = (void *) 0;
+__attribute__ (( __section__ (".dtors.99999"), __used__ , aligned(sizeof(void 
*)))) const void * __DTOR_END__ = (void *) 0;
 #endif
 
 /* TLS initialization hook.  */
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to