crt: Remove support for providing __CTOR_LIST__ for LLD 7 and older
This reverts commit ccda8b5229e428a6fa7036140778b23d11b554e8 and
removes the code for providing __CTOR_LIST__ here.
This was only needed for LLD 7 and older, while LLD 8 got support for
providing __CTOR_LIST__ by the linker, just as GNU ld does.
This gets rid of a brittle configure check and simplifies the code.
Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/configure.ac b/mingw-w64-crt/configure.ac
index b388cb2..6a42109 100644
--- a/mingw-w64-crt/configure.ac
+++ b/mingw-w64-crt/configure.ac
@@ -301,65 +301,6 @@
AM_CONDITIONAL([ENABLE_TESTS_UNICODE],[test x$enable_tests_unicode = xyes])
AC_MSG_RESULT([$enable_tests_unicode])
-AC_MSG_CHECKING([whether the linker provides __CTOR_LIST__])
-saved_LDFLAGS="$LDFLAGS"
-saved_ac_no_link="$ac_no_link"
-LDFLAGS="$LDFLAGS -nostdlib"
-# Note that binutils 2.30 is broken with respect to __CTOR_LIST__ (the change
-# was reverted for 2.31); it does provide __CTOR_LIST__ automatically only if
-# necessary. But as long as there's no other definition of it, a fallback
-# __CTOR_LIST__ gets pulled in from libgcc, and this fallback is only a dummy
-# to prevent linker errors (in general) and isn't assigned to the right
-# sections. Therefore, it'd be better to test whether we can/should provide
-# our own __CTOR_LIST__.
-
-# But we can't test whether we can provide our own __CTOR_LIST__ with binutils
-# ld either; even if our test provides its own symbol __CTOR_LIST__, ld will
-# include it but silently use its own provided __CTOR_LIST__ instead, and
-# won't error out. For actual real use, that'd mean a stray broken pointer in
-# the .ctors section.
-
-# This test uses both mainCRTStartup and main functions, to let lld deduce
-# entry point and subsystem automatically without having to manually specify,
-# anything. And as long as main() is provided, we need to implicitly provide
-# __main as well, since the compiler injects a call to it.
-
-# Run this test manually instead of wrapping it in AC_LINK_IFELSE; when
-# bootstrapping an environment, an earlier linking test will have failed,
-# which both causes autoconf to refuse to run any linker test at all,
-# and even if $ac_no_link is overridden, the linker test iteslf will explicitly
-# check that the linker actually produced output in the given output file.
-# If $ac_exeext is empty, as it is when the earlier linker test failed, gcc
-# will behave differently depending on version. If run with "gcc conftest.c
-# -o conftest", old versions will produce explicitly a file named "conftest",
-# while modern GCC versions will produce "conftest.exe". AC_LINK_IFELSE will
-# explicitly look for the output file named "conftest$ac_exeext", which isn't
-# found, and the test fails even though linking succeeded.
-#
-# Therefore, just do a manual test; run the linking command and check the return
-# code whether it was successful or not.
-cat <<_ACEOF >conftest.$ac_ext
-#include <stdint.h>
-extern const void * __CTOR_LIST__;
-void __main(void) {
-}
-int main(void) {
- return (int)(intptr_t)__CTOR_LIST__;
-}
-int mainCRTStartup(void) {
- return main();
-}
-_ACEOF
-
-echo "$as_me:$LINENO: $CC conftest.$ac_ext $LDFLAGS -o conftest$ac_exeext" >&AS_MESSAGE_LOG_FD
-if $CC conftest.$ac_ext $LDFLAGS -o conftest$ac_exeext >&AS_MESSAGE_LOG_FD 2>&1; then
- AC_DEFINE([HAVE_CTOR_LIST],[1],[Whether the linker provides __CTOR_LIST__])
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
-fi
-LDFLAGS="$saved_LDFLAGS"
-
# Checks for libraries.
# Checks for header files.
diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c
index 8b0f4dd..51b8d35 100644
--- a/mingw-w64-crt/crt/crtdll.c
+++ b/mingw-w64-crt/crt/crtdll.c
@@ -10,10 +10,6 @@
#define _DLL
#endif
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <oscalls.h>
#include <internal.h>
#include <stdlib.h>
@@ -44,12 +40,6 @@
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
-#ifndef HAVE_CTOR_LIST
-__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.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. */
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
index 54bb204..6460543 100644
--- a/mingw-w64-crt/crt/crtexe.c
+++ b/mingw-w64-crt/crt/crtexe.c
@@ -9,10 +9,6 @@
#define _DLL
#endif
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#define SPECIAL_CRTEXE
#include <oscalls.h>
@@ -66,12 +62,6 @@
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
-#ifndef HAVE_CTOR_LIST
-__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.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. */
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
diff --git a/mingw-w64-crt/crt/gccmain.c b/mingw-w64-crt/crt/gccmain.c
index 030cdce..fc0e350 100644
--- a/mingw-w64-crt/crt/gccmain.c
+++ b/mingw-w64-crt/crt/gccmain.c
@@ -8,10 +8,6 @@
#include <stdlib.h>
#include <setjmp.h>
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
typedef void (*func_ptr) (void);
extern func_ptr __CTOR_LIST__[];
extern func_ptr __DTOR_LIST__[];
@@ -32,25 +28,6 @@
}
}
-#ifndef HAVE_CTOR_LIST
-// If the linker didn't provide __CTOR_LIST__, we provided it ourselves,
-// and then we also know we have __CTOR_END__ available.
-extern func_ptr __CTOR_END__[];
-extern func_ptr __DTOR_END__[];
-
-void __do_global_ctors (void)
-{
- static func_ptr *p = __CTOR_END__ - 1;
- while (*p != (func_ptr) -1) {
- (*(p))();
- p--;
- }
- atexit (__do_global_dtors);
-}
-
-#else
-// old method that iterates the list twice because old linker scripts do not have __CTOR_END__
-
void
__do_global_ctors (void)
{
@@ -70,8 +47,6 @@
atexit (__do_global_dtors);
}
-#endif
-
static int initialized = 0;
void