about summary refs log tree commit diff
path: root/configure
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2011-07-09 14:41:39 -0700
committerRoland McGrath <roland@hack.frob.com>2011-07-09 14:41:39 -0700
commit113ddea44742d006d7a910a0707106c7defcfd9b (patch)
treed27e74deae49fc9dc8eb8f51af35363f958925b6 /configure
parent574920b446870648623a85e00dd8f3ca9f482c0e (diff)
downloadglibc-113ddea44742d006d7a910a0707106c7defcfd9b.tar.gz
glibc-113ddea44742d006d7a910a0707106c7defcfd9b.tar.xz
glibc-113ddea44742d006d7a910a0707106c7defcfd9b.zip
Use an empirical check for .ctors/.dtors -> .init_array/.fini_array magic.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure51
1 files changed, 40 insertions, 11 deletions
diff --git a/configure b/configure
index 252f637466..ffeb89057f 100755
--- a/configure
+++ b/configure
@@ -6217,20 +6217,49 @@ $as_echo_n "checking whether to use .ctors/.dtors header and trailer... " >&6; }
 if ${libc_cv_ctors_header+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-    if { ac_try='${CC-cc} -Wl,--verbose 2>&1|grep SORT_BY_INIT_PRIORITY 1>&5'
-  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-    libc_cv_ctors_header=no
-  else
-    libc_cv_ctors_header=yes
-  fi
+      libc_cv_ctors_header=yes
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+__attribute__ ((constructor)) void ctor (void) { puts("ctor"); }
+__attribute__ ((destructor))  void dtor (void) { puts("dtor"); }
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+        if $READELF -WS conftest$ac_exeext | $AWK '
+        { gsub(/\[ */, "[") }
+	$2 == ".ctors" || $2 == ".dtors" {
+	  size = strtonum("0x" $6)
+	  align = strtonum("0x" $NF)
+	  seen[$2] = 1
+	  stub[$2] = size == align * 2
+        }
+	END {
+	  ctors_ok = !seen[".ctors"] || stub[".ctors"]
+	  dtors_ok = !seen[".dtors"] || stub[".dtors"]
+	  exit ((ctors_ok && dtors_ok) ? 0 : 1)
+	}
+      '; then :
+  libc_cv_ctors_header=no
+fi
+
+else
+        as_fn_error $? "missing __attribute__ ((constructor)) support??" "$LINENO" 5
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ctors_header" >&5
 $as_echo "$libc_cv_ctors_header" >&6; }
-
   if test $libc_cv_ctors_header = no; then
     $as_echo "#define NO_CTORS_DTORS_SECTIONS 1" >>confdefs.h