aboutsummaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2011-07-09 13:55:24 -0700
committerRoland McGrath <roland@hack.frob.com>2011-07-09 13:55:24 -0700
commit574920b446870648623a85e00dd8f3ca9f482c0e (patch)
treeb4fe7f1fcb36ff56af9cd2e636ab5d194829e1a6 /configure.in
parentd30cf5bb00bfb286ff14d931fb69f5b53724bcdc (diff)
downloadglibc-574920b446870648623a85e00dd8f3ca9f482c0e.zip
glibc-574920b446870648623a85e00dd8f3ca9f482c0e.tar.gz
glibc-574920b446870648623a85e00dd8f3ca9f482c0e.tar.bz2
Rewrite -z relro configure check to be empirical.
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in80
1 files changed, 63 insertions, 17 deletions
diff --git a/configure.in b/configure.in
index 95450ba..e9464d8 100644
--- a/configure.in
+++ b/configure.in
@@ -1561,26 +1561,72 @@ EOF
fi
rm -f conftest*])
+ # Add-on fragments can set these for other machines.
+ libc_commonpagesize=${libc_commonpagesize:-no}
+ libc_relro_required=${libc_relro_required:-no}
case "$base_machine" in
-changequote(,)dnl
- i[34567]86 | x86_64 | powerpc* | s390* | sparc* | alpha*)
-changequote([,])dnl
- AC_CACHE_CHECK(for -z relro option,
- libc_cv_z_relro, [dnl
- libc_cv_z_relro=no
- if AC_TRY_COMMAND([${CC-cc} -v --help 2>&1|grep "z relro" 1>&AS_MESSAGE_LOG_FD])
- then
- if AC_TRY_COMMAND([${CC-cc} -Wl,--verbose 2>&1|grep DATA_SEGMENT_RELRO_END 1>&AS_MESSAGE_LOG_FD])
+ i[[34567]]86 | x86_64 | powerpc* | s390*)
+ libc_commonpagesize=0x1000
+ libc_relro_required=yes
+ ;;
+ sparc*)
+ libc_commonpagesize=0x2000
+ libc_relro_required=yes
+ ;;
+ ia64*)
+ libc_commonpagesize=0x4000
+ ;;
+ alpha*)
+ libc_commonpagesize=0x10000
+ libc_relro_required=yes
+ ;;
+ esac
+
+ if test $libc_commonpagesize != no; then
+ AC_CACHE_CHECK(for -z relro option,
+ libc_cv_z_relro, [dnl
+ libc_cv_z_relro=no
+ AC_LANG_CONFTEST([AC_LANG_SOURCE([[
+int _start (void) { return 42; }
+extern void _exit (int);
+const void *relro[] = { &_start, &_exit, 0 };
+]])])
+ cat > conftest.awk <<\EOF
+BEGIN {
+ result = "no"
+ commonpagesize = strtonum(commonpagesize)
+}
+{ print "LINE:", $0 > "/dev/stderr" }
+$1 == "GNU_RELRO" {
+ vaddr = strtonum($3)
+ memsz = strtonum($6)
+ end = vaddr + memsz
+ printf "vaddr %#x memsz %#x end %#x commonpagesize %#x\n", \
+ vaddr, memsz, end, commonpagesize > "/dev/stderr"
+ result = (end % commonpagesize == 0) ? "yes" : "broken"
+}
+END { print result }
+EOF
+ AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
+ -fPIC -shared -o conftest.so conftest.c
+ -nostartfiles -nostdlib
+ -Wl,-z,relro 1>&AS_MESSAGE_LOG_FD]) &&
+ AC_TRY_COMMAND([$READELF -Wl conftest.so > conftest.ph]) &&
+ AC_TRY_COMMAND([
+ $AWK -v commonpagesize=$libc_commonpagesize -f conftest.awk
+ conftest.ph > conftest.cps
+ ]) &&
+ libc_cv_z_relro=`cat conftest.cps 2>&AS_MESSAGE_LOG_FD`
+ rm -f conftest*])
+ if { test "x$libc_relro_required" = xyes &&
+ test "x$libc_cv_z_relro" != xyes
+ }
then
- libc_cv_z_relro=yes
+ AC_MSG_ERROR(linker with -z relro support required)
fi
- fi])
- if test "$libc_cv_z_relro" = no; then
- AC_MSG_ERROR(linker with -z relro support required)
- fi
- ;;
- *) ;;
- esac
+ else
+ AC_MSG_WARN([missing architecture parameter to check for working -z relro])
+ fi
AC_CACHE_CHECK(for -Bgroup option,
libc_cv_Bgroup, [dnl