aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rwxr-xr-xconfigure51
-rw-r--r--configure.in28
3 files changed, 67 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 78ab917..b2d282f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2011-07-09 Roland McGrath <roland@hack.frob.com>
+ * configure.in (.ctors/.dtors header and trailer check):
+ Use an empirical test on a built program.
+ * configure: Regenerated.
+
* configure.in (-z relro check): Use an empirical test on a built DSO.
Detect, but do not require, on ia64.
* configure: Regenerated.
diff --git a/configure b/configure
index 252f637..ffeb890 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
diff --git a/configure.in b/configure.in
index e9464d8..e18b343 100644
--- a/configure.in
+++ b/configure.in
@@ -1486,12 +1486,30 @@ EOF
AC_CACHE_CHECK(whether to use .ctors/.dtors header and trailer,
libc_cv_ctors_header, [dnl
- if AC_TRY_COMMAND([${CC-cc} -Wl,--verbose 2>&1|grep SORT_BY_INIT_PRIORITY 1>&AS_MESSAGE_LOG_FD]); then
- libc_cv_ctors_header=no
- else
libc_cv_ctors_header=yes
- fi])
-
+ AC_TRY_LINK([], [
+__attribute__ ((constructor)) void ctor (void) { puts("ctor"); }
+__attribute__ ((destructor)) void dtor (void) { puts("dtor"); }
+],
+ [dnl
+ AS_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)
+ }
+ '], [libc_cv_ctors_header=no])
+ ], [dnl
+ AC_MSG_ERROR([missing __attribute__ ((constructor)) support??])
+ ])
+ ])
if test $libc_cv_ctors_header = no; then
AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
fi