Blame SOURCES/glibc-gcc47-ctordtor.patch

b40826
diff -Nrup a/config.h.in b/config.h.in
b40826
--- a/config.h.in	2012-06-07 10:17:05.004639296 -0600
b40826
+++ b/config.h.in	2012-06-07 10:17:45.289449200 -0600
b40826
@@ -204,6 +204,9 @@
b40826
 /* Define if Systemtap <sys/sdt.h> probes should be defined.  */
b40826
 #undef USE_STAP_PROBE
b40826
 
b40826
+/* Define if `.ctors' and `.dtors' sections shouldn't be used.  */
b40826
+#undef	NO_CTORS_DTORS_SECTIONS
b40826
+
b40826
 /*
b40826
  */
b40826
 
b40826
diff -Nrup a/configure b/configure
b40826
--- a/configure	2012-06-07 10:17:05.427637302 -0600
b40826
+++ b/configure	2012-06-07 10:18:20.452282885 -0600
b40826
@@ -577,7 +577,7 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr
b40826
 exec 7<&0 </dev/null 6>&1
b40826
 
b40826
 # Name of the host.
b40826
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
b40826
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
b40826
 # so uname gets run too.
b40826
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
b40826
 
b40826
@@ -1307,8 +1307,8 @@ target=$target_alias
b40826
 if test "x$host_alias" != x; then
b40826
   if test "x$build_alias" = x; then
b40826
     cross_compiling=maybe
b40826
-    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
b40826
-    If a cross compiler is detected then cross compile mode will be used." >&2
b40826
+    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
b40826
+    If a cross compiler is detected then cross compile mode will be used" >&2
b40826
   elif test "x$build_alias" != "x$host_alias"; then
b40826
     cross_compiling=yes
b40826
   fi
b40826
@@ -1412,7 +1412,7 @@ Configuration:
b40826
       --help=short        display options specific to this package
b40826
       --help=recursive    display the short help of all the included packages
b40826
   -V, --version           display version information and exit
b40826
-  -q, --quiet, --silent   do not print \`checking...' messages
b40826
+  -q, --quiet, --silent   do not print \`checking ...' messages
b40826
       --cache-file=FILE   cache test results in FILE [disabled]
b40826
   -C, --config-cache      alias for \`--cache-file=config.cache'
b40826
   -n, --no-create         do not create output files
b40826
@@ -1725,11 +1725,9 @@ trap 'exit_status=$?
b40826
   {
b40826
     echo
b40826
 
b40826
-    cat <<\_ASBOX
b40826
-## ---------------- ##
b40826
+    $as_echo "## ---------------- ##
b40826
 ## Cache variables. ##
b40826
-## ---------------- ##
b40826
-_ASBOX
b40826
+## ---------------- ##"
b40826
     echo
b40826
     # The following way of writing the cache mishandles newlines in values,
b40826
 (
b40826
@@ -1763,11 +1761,9 @@ $as_echo "$as_me: WARNING: cache variabl
b40826
 )
b40826
     echo
b40826
 
b40826
-    cat <<\_ASBOX
b40826
-## ----------------- ##
b40826
+    $as_echo "## ----------------- ##
b40826
 ## Output variables. ##
b40826
-## ----------------- ##
b40826
-_ASBOX
b40826
+## ----------------- ##"
b40826
     echo
b40826
     for ac_var in $ac_subst_vars
b40826
     do
b40826
@@ -1780,11 +1776,9 @@ _ASBOX
b40826
     echo
b40826
 
b40826
     if test -n "$ac_subst_files"; then
b40826
-      cat <<\_ASBOX
b40826
-## ------------------- ##
b40826
+      $as_echo "## ------------------- ##
b40826
 ## File substitutions. ##
b40826
-## ------------------- ##
b40826
-_ASBOX
b40826
+## ------------------- ##"
b40826
       echo
b40826
       for ac_var in $ac_subst_files
b40826
       do
b40826
@@ -1798,11 +1792,9 @@ _ASBOX
b40826
     fi
b40826
 
b40826
     if test -s confdefs.h; then
b40826
-      cat <<\_ASBOX
b40826
-## ----------- ##
b40826
+      $as_echo "## ----------- ##
b40826
 ## confdefs.h. ##
b40826
-## ----------- ##
b40826
-_ASBOX
b40826
+## ----------- ##"
b40826
       echo
b40826
       cat confdefs.h
b40826
       echo
b40826
@@ -1855,7 +1847,12 @@ _ACEOF
b40826
 ac_site_file1=NONE
b40826
 ac_site_file2=NONE
b40826
 if test -n "$CONFIG_SITE"; then
b40826
-  ac_site_file1=$CONFIG_SITE
b40826
+  # We do not want a PATH search for config.site.
b40826
+  case $CONFIG_SITE in #((
b40826
+    -*)  ac_site_file1=./$CONFIG_SITE;;
b40826
+    */*) ac_site_file1=$CONFIG_SITE;;
b40826
+    *)   ac_site_file1=./$CONFIG_SITE;;
b40826
+  esac
b40826
 elif test "x$prefix" != xNONE; then
b40826
   ac_site_file1=$prefix/share/config.site
b40826
   ac_site_file2=$prefix/etc/config.site
b40826
@@ -1870,7 +1867,11 @@ do
b40826
     { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
b40826
 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
b40826
     sed 's/^/| /' "$ac_site_file" >&5
b40826
-    . "$ac_site_file"
b40826
+    . "$ac_site_file" \
b40826
+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
b40826
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
b40826
+as_fn_error $? "failed to load site script $ac_site_file
b40826
+See \`config.log' for more details" "$LINENO" 5; }
b40826
   fi
b40826
 done
b40826
 
b40826
@@ -6520,9 +6521,15 @@ fi
b40826
 { $as_echo "$as_me:$LINENO: result: $libc_cv_initfini_array" >&5
b40826
 $as_echo "$libc_cv_initfini_array" >&6; }
b40826
   if test $libc_cv_initfini_array != yes; then
b40826
-    { { $as_echo "$as_me:$LINENO: error: Need linker with .init_array/.fini_array support." >&5
b40826
-$as_echo "$as_me: error: Need linker with .init_array/.fini_array support." >&2;}
b40826
-   { (exit 1); exit 1; }; }
b40826
+    as_fn_error $? "Need linker with .init_array/.fini_array support." "$LINENO" 5
b40826
+  elif { ac_try='${CC-cc} -Wl,--verbose 2>&1|grep SORT_BY_INIT_PRIORITY 1>&5'
b40826
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
b40826
+  (eval $ac_try) 2>&5
b40826
+  ac_status=$?
b40826
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
b40826
+  test $ac_status = 0; }; }; then
b40826
+    $as_echo "#define NO_CTORS_DTORS_SECTIONS 1" >>confdefs.h
b40826
+
b40826
   fi
b40826
 
b40826
   { $as_echo "$as_me:$LINENO: checking for libunwind-support in compiler" >&5
b40826
@@ -9054,6 +9061,7 @@ DEFS=-DHAVE_CONFIG_H
b40826
 
b40826
 ac_libobjs=
b40826
 ac_ltlibobjs=
b40826
+U=
b40826
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
b40826
   # 1. Remove the extension, and $U if already installed.
b40826
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
b40826
diff -Nrup a/configure.in b/configure.in
b40826
--- a/configure.in	2012-06-07 10:17:05.009639273 -0600
b40826
+++ b/configure.in	2012-06-07 10:17:45.349448917 -0600
b40826
@@ -1536,6 +1536,8 @@ EOF
b40826
   rm -f conftest*])
b40826
   if test $libc_cv_initfini_array != yes; then
b40826
     AC_MSG_ERROR([Need linker with .init_array/.fini_array support.])
b40826
+  elif AC_TRY_COMMAND([${CC-cc} -Wl,--verbose 2>&1|grep SORT_BY_INIT_PRIORITY 1>&AS_MESSAGE_LOG_FD]); then
b40826
+    AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
b40826
   fi
b40826
 
b40826
   AC_CACHE_CHECK(for libunwind-support in compiler,
b40826
diff -Nrup a/elf/sofini.c b/elf/sofini.c
b40826
--- a/elf/sofini.c	2010-05-04 05:27:23.000000000 -0600
b40826
+++ b/elf/sofini.c	2012-06-07 10:17:45.350448913 -0600
b40826
@@ -1,12 +1,14 @@
b40826
 /* Finalizer module for ELF shared C library.  This provides terminating
b40826
    null pointer words in the `.ctors' and `.dtors' sections.  */
b40826
 
b40826
+#ifndef NO_CTORS_DTORS_SECTIONS
b40826
 static void (*const __CTOR_END__[1]) (void)
b40826
      __attribute__ ((used, section (".ctors")))
b40826
      = { 0 };
b40826
 static void (*const __DTOR_END__[1]) (void)
b40826
      __attribute__ ((used, section (".dtors")))
b40826
      = { 0 };
b40826
+#endif
b40826
 
b40826
 /* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
b40826
    this would be the 'length' field in a real FDE.  */
b40826
diff -Nrup a/elf/soinit.c b/elf/soinit.c
b40826
--- a/elf/soinit.c	2010-05-04 05:27:23.000000000 -0600
b40826
+++ b/elf/soinit.c	2012-06-07 10:17:45.351448908 -0600
b40826
@@ -3,6 +3,7 @@
b40826
    the `.ctors' and `.dtors' sections so the lists are terminated, and
b40826
    calling those lists of functions.  */
b40826
 
b40826
+#ifndef NO_CTORS_DTORS_SECTIONS
b40826
 #include <libc-internal.h>
b40826
 #include <stdlib.h>
b40826
 
b40826
@@ -40,3 +41,4 @@ __libc_fini (void)
b40826
 
b40826
 void (*_fini_ptr) (void) __attribute__ ((section (".fini_array")))
b40826
      = &__libc_fini;
b40826
+#endif
b40826
diff -Nrup a/sysdeps/i386/init-first.c b/sysdeps/i386/init-first.c
b40826
--- a/sysdeps/i386/init-first.c	2010-05-04 05:27:23.000000000 -0600
b40826
+++ b/sysdeps/i386/init-first.c	2012-06-07 10:17:45.353448898 -0600
b40826
@@ -59,7 +59,9 @@ _init (int argc, ...)
b40826
 {
b40826
   init (&argc);
b40826
 
b40826
+#ifndef NO_CTORS_DTORS_SECTIONS
b40826
   __libc_global_ctors ();
b40826
+#endif
b40826
 }
b40826
 #endif
b40826
 
b40826
diff -Nrup a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
b40826
--- a/sysdeps/mach/hurd/i386/init-first.c	2010-05-04 05:27:23.000000000 -0600
b40826
+++ b/sysdeps/mach/hurd/i386/init-first.c	2012-06-07 10:17:45.354448893 -0600
b40826
@@ -92,7 +92,7 @@ posixland_init (int argc, char **argv, c
b40826
   __getopt_clean_environment (envp);
b40826
 #endif
b40826
 
b40826
-#ifdef SHARED
b40826
+#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
b40826
   __libc_global_ctors ();
b40826
 #endif
b40826
 }
b40826
diff -Nrup a/sysdeps/mach/hurd/powerpc/init-first.c b/sysdeps/mach/hurd/powerpc/init-first.c
b40826
--- a/sysdeps/mach/hurd/powerpc/init-first.c	2010-05-04 05:27:23.000000000 -0600
b40826
+++ b/sysdeps/mach/hurd/powerpc/init-first.c	2012-06-07 10:17:45.354448893 -0600
b40826
@@ -82,7 +82,7 @@ posixland_init (int argc, char **argv, c
b40826
   __getopt_clean_environment (__environ);
b40826
 #endif
b40826
 
b40826
-#ifdef SHARED
b40826
+#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
b40826
   __libc_global_ctors ();
b40826
 #endif
b40826
 }
b40826
diff -Nrup a/sysdeps/sh/init-first.c b/sysdeps/sh/init-first.c
b40826
--- a/sysdeps/sh/init-first.c	2010-05-04 05:27:23.000000000 -0600
b40826
+++ b/sysdeps/sh/init-first.c	2012-06-07 10:17:45.355448888 -0600
b40826
@@ -59,7 +59,9 @@ _init (int argc, ...)
b40826
 {
b40826
   init (&argc);
b40826
 
b40826
+#ifndef NO_CTORS_DTORS_SECTIONS
b40826
   __libc_global_ctors ();
b40826
+#endif
b40826
 }
b40826
 #endif
b40826
 
b40826
diff -Nrup a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
b40826
--- a/sysdeps/unix/sysv/linux/init-first.c	2010-05-04 05:27:23.000000000 -0600
b40826
+++ b/sysdeps/unix/sysv/linux/init-first.c	2012-06-07 10:17:45.356448884 -0600
b40826
@@ -93,7 +93,7 @@ _init (int argc, char **argv, char **env
b40826
   __getopt_clean_environment (envp);
b40826
 #endif
b40826
 
b40826
-#ifdef SHARED
b40826
+#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
b40826
   __libc_global_ctors ();
b40826
 #endif
b40826
 }