summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2010-12-24 20:14:37 -0500
committerH.J. Lu <hjl.tools@gmail.com>2013-01-28 09:09:57 -0800
commitd98bc91f30f657da1489e92983d72ef3a44a292f (patch)
tree323ef8439558fe3dcea3a041045008d25ce1f543
parent3a33e487eeb65e2f1f633581c56bee2c60d0ca43 (diff)
downloadglibc-hjl/ctor/release/2.12.tar.gz
Remove `.ctors' and `.dtors' output sectionshjl/ctor/release/2.12
Conflicts: ChangeLog configure
-rw-r--r--ChangeLog.ctor14
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure10
-rw-r--r--configure.in2
-rw-r--r--elf/sofini.c2
-rw-r--r--elf/soinit.c2
-rw-r--r--sysdeps/i386/init-first.c2
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c2
-rw-r--r--sysdeps/mach/hurd/powerpc/init-first.c2
-rw-r--r--sysdeps/sh/init-first.c2
-rw-r--r--sysdeps/unix/sysv/linux/init-first.c2
11 files changed, 40 insertions, 3 deletions
diff --git a/ChangeLog.ctor b/ChangeLog.ctor
new file mode 100644
index 0000000000..f65681870c
--- /dev/null
+++ b/ChangeLog.ctor
@@ -0,0 +1,14 @@
+2010-12-15 H.J. Lu <hongjiu.lu@intel.com>
+
+ * config.h.in (NO_CTORS_DTORS_SECTIONS): Define.
+ * configure.in: Define NO_CTORS_DTORS_SECTIONS if linker
+ script has SORT_BY_INIT_PRIORITY.
+ * elf/sofini.c: Remove `.ctors' and `.dtors' sections if
+ NO_CTORS_DTORS_SECTIONS is defined.
+ * elf/soinit.c: Likewise.
+ * sysdeps/i386/init-first.c: Don't call __libc_global_ctors if
+ NO_CTORS_DTORS_SECTIONS is defined.
+ * sysdeps/mach/hurd/i386/init-first.c: Likewise.
+ * sysdeps/mach/hurd/powerpc/init-first.c: Likewise.
+ * sysdeps/sh/init-first.c: Likewise.
+ * sysdeps/unix/sysv/linux/init-first.c: Likewise.
diff --git a/config.h.in b/config.h.in
index 18bf01a38c..9e797eb5b7 100644
--- a/config.h.in
+++ b/config.h.in
@@ -201,6 +201,9 @@
/* Define if multi-arch DSOs should be generated. */
#undef USE_MULTIARCH
+/* Define if `.ctors' and `.dtors' sections shouldn't be used. */
+#undef NO_CTORS_DTORS_SECTIONS
+
/*
*/
diff --git a/configure b/configure
index 8c9413b14c..fcaf74cfb0 100755
--- a/configure
+++ b/configure
@@ -6426,6 +6426,16 @@ $as_echo "$libc_cv_initfini_array" >&6; }
{ { $as_echo "$as_me:$LINENO: error: Need linker with .init_array/.fini_array support." >&5
$as_echo "$as_me: error: Need linker with .init_array/.fini_array support." >&2;}
{ (exit 1); exit 1; }; }
+ elif { ac_try='${CC-cc} -Wl,--verbose 2>&1|grep SORT_BY_INIT_PRIORITY 1>&5'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cat >>confdefs.h <<\_ACEOF
+#define NO_CTORS_DTORS_SECTIONS 1
+_ACEOF
+
fi
{ $as_echo "$as_me:$LINENO: checking for libunwind-support in compiler" >&5
diff --git a/configure.in b/configure.in
index 098adf4d35..47780086ac 100644
--- a/configure.in
+++ b/configure.in
@@ -1497,6 +1497,8 @@ EOF
rm -f conftest*])
if test $libc_cv_initfini_array != yes; then
AC_MSG_ERROR([Need linker with .init_array/.fini_array support.])
+ elif AC_TRY_COMMAND([${CC-cc} -Wl,--verbose 2>&1|grep SORT_BY_INIT_PRIORITY 1>&AS_MESSAGE_LOG_FD]); then
+ AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
fi
AC_CACHE_CHECK(for libunwind-support in compiler,
diff --git a/elf/sofini.c b/elf/sofini.c
index 5e06f0ca92..13e74b7903 100644
--- a/elf/sofini.c
+++ b/elf/sofini.c
@@ -1,12 +1,14 @@
/* Finalizer module for ELF shared C library. This provides terminating
null pointer words in the `.ctors' and `.dtors' sections. */
+#ifndef NO_CTORS_DTORS_SECTIONS
static void (*const __CTOR_END__[1]) (void)
__attribute__ ((used, section (".ctors")))
= { 0 };
static void (*const __DTOR_END__[1]) (void)
__attribute__ ((used, section (".dtors")))
= { 0 };
+#endif
/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
this would be the 'length' field in a real FDE. */
diff --git a/elf/soinit.c b/elf/soinit.c
index 6fecbb5674..1db676af01 100644
--- a/elf/soinit.c
+++ b/elf/soinit.c
@@ -3,6 +3,7 @@
the `.ctors' and `.dtors' sections so the lists are terminated, and
calling those lists of functions. */
+#ifndef NO_CTORS_DTORS_SECTIONS
#include <libc-internal.h>
#include <stdlib.h>
@@ -40,3 +41,4 @@ __libc_fini (void)
void (*_fini_ptr) (void) __attribute__ ((section (".fini_array")))
= &__libc_fini;
+#endif
diff --git a/sysdeps/i386/init-first.c b/sysdeps/i386/init-first.c
index c6355a8b7b..2af042fe4b 100644
--- a/sysdeps/i386/init-first.c
+++ b/sysdeps/i386/init-first.c
@@ -59,7 +59,9 @@ _init (int argc, ...)
{
init (&argc);
+#ifndef NO_CTORS_DTORS_SECTIONS
__libc_global_ctors ();
+#endif
}
#endif
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index f9a7a58deb..60823bd789 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -92,7 +92,7 @@ posixland_init (int argc, char **argv, char **envp)
__getopt_clean_environment (envp);
#endif
-#ifdef SHARED
+#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
__libc_global_ctors ();
#endif
}
diff --git a/sysdeps/mach/hurd/powerpc/init-first.c b/sysdeps/mach/hurd/powerpc/init-first.c
index 20fa1d4f12..21b5054b0a 100644
--- a/sysdeps/mach/hurd/powerpc/init-first.c
+++ b/sysdeps/mach/hurd/powerpc/init-first.c
@@ -82,7 +82,7 @@ posixland_init (int argc, char **argv, char **envp)
__getopt_clean_environment (__environ);
#endif
-#ifdef SHARED
+#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
__libc_global_ctors ();
#endif
}
diff --git a/sysdeps/sh/init-first.c b/sysdeps/sh/init-first.c
index d816625ef4..1f3a821fea 100644
--- a/sysdeps/sh/init-first.c
+++ b/sysdeps/sh/init-first.c
@@ -59,7 +59,9 @@ _init (int argc, ...)
{
init (&argc);
+#ifndef NO_CTORS_DTORS_SECTIONS
__libc_global_ctors ();
+#endif
}
#endif
diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
index 7b2333d4bf..a60212f4ed 100644
--- a/sysdeps/unix/sysv/linux/init-first.c
+++ b/sysdeps/unix/sysv/linux/init-first.c
@@ -93,7 +93,7 @@ _init (int argc, char **argv, char **envp)
__getopt_clean_environment (envp);
#endif
-#ifdef SHARED
+#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
__libc_global_ctors ();
#endif
}