diff options
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/configure.in b/configure.in index e9464d89e6..e18b343416 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 |