mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
configure: check compiler/linker support for RELRO and PIE options
Also, add AC_TRY_LDFLAGS m4 macro to help with checking ld flags.
This commit is contained in:
parent
163666e513
commit
6c6bcc00e4
@ -1,5 +1,6 @@
|
||||
Version 2.02.105 -
|
||||
=====================================
|
||||
Automatically detect support for compiler/linker options to use RELRO and PIE.
|
||||
Add --splitsnapshot to lvconvert to separate out cow LV.
|
||||
Reinstate origin reload to complete lvconvert -s with active LVs. (2.02.98)
|
||||
Select only active volume groups if vgdisplay -A is used.
|
||||
|
21
acinclude.m4
21
acinclude.m4
@ -36,3 +36,24 @@ AC_DEFUN([AC_TRY_CCFLAG],
|
||||
ifelse([$4], [], [:], [$4])
|
||||
fi
|
||||
])
|
||||
|
||||
dnl AC_TRY_LDFLAGS([LDFLAGS], [VAR], [ACTION-IF-WORKS], [ACTION-IF-FAILS])
|
||||
dnl check if $CC supports given ld flags
|
||||
|
||||
AC_DEFUN([AC_TRY_LDFLAGS],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
ac_save_LDFLAGS=$LDFLAGS
|
||||
LDFLAGS=$1
|
||||
AC_CACHE_CHECK([whether $CC accepts $1 ld flags], [ac_cv_flag_$2],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM()],
|
||||
[AS_VAR_SET([ac_cv_flag_$2], [yes])],
|
||||
[AS_VAR_SET([ac_cv_flag_$2], [no])])])
|
||||
LDLAGS=$ac_save_LDFLAGS
|
||||
$2=AS_VAR_GET([ac_cv_flag_$2])
|
||||
if test "$2" = yes; then
|
||||
ifelse([$3], [], [:], [$3])
|
||||
else
|
||||
ifelse([$4], [], [:], [$4])
|
||||
fi
|
||||
])
|
||||
|
81
configure
vendored
81
configure
vendored
@ -740,6 +740,8 @@ PKG_CONFIG
|
||||
THIN_REPAIR_CMD
|
||||
THIN_DUMP_CMD
|
||||
THIN_CHECK_CMD
|
||||
HAVE_FULL_RELRO
|
||||
HAVE_PIE
|
||||
POW_LIB
|
||||
LIBOBJS
|
||||
ALLOCA
|
||||
@ -6741,6 +6743,85 @@ fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $STATIC_LINK" >&5
|
||||
$as_echo "$STATIC_LINK" >&6; }
|
||||
|
||||
################################################################################
|
||||
|
||||
|
||||
ac_save_CFLAGS=$CFLAGS
|
||||
CFLAGS=-pie
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -pie flag" >&5
|
||||
$as_echo_n "checking whether $CC accepts -pie flag... " >&6; }
|
||||
if test "${ac_cv_flag_HAVE_PIE+set}" = set; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ac_cv_flag_HAVE_PIE=yes
|
||||
else
|
||||
ac_cv_flag_HAVE_PIE=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_flag_HAVE_PIE" >&5
|
||||
$as_echo "$ac_cv_flag_HAVE_PIE" >&6; }
|
||||
CFLAGS=$ac_save_CFLAGS
|
||||
HAVE_PIE=$ac_cv_flag_HAVE_PIE
|
||||
if test "HAVE_PIE" = yes; then
|
||||
:
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
ac_save_LDFLAGS=$LDFLAGS
|
||||
LDFLAGS=-Wl,-z,relro,-z,now
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -Wl,-z,relro,-z,now ld flags" >&5
|
||||
$as_echo_n "checking whether $CC accepts -Wl,-z,relro,-z,now ld flags... " >&6; }
|
||||
if test "${ac_cv_flag_HAVE_FULL_RELRO+set}" = set; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
ac_cv_flag_HAVE_FULL_RELRO=yes
|
||||
else
|
||||
ac_cv_flag_HAVE_FULL_RELRO=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_flag_HAVE_FULL_RELRO" >&5
|
||||
$as_echo "$ac_cv_flag_HAVE_FULL_RELRO" >&6; }
|
||||
LDLAGS=$ac_save_LDFLAGS
|
||||
HAVE_FULL_RELRO=$ac_cv_flag_HAVE_FULL_RELRO
|
||||
if test "HAVE_FULL_RELRO" = yes; then
|
||||
:
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
|
||||
|
@ -158,6 +158,13 @@ AC_ARG_ENABLE(static_link,
|
||||
STATIC_LINK=$enableval, STATIC_LINK=no)
|
||||
AC_MSG_RESULT($STATIC_LINK)
|
||||
|
||||
################################################################################
|
||||
dnl -- Check if compiler/linker supports PIE and RELRO
|
||||
AC_TRY_CCFLAG([-pie], [HAVE_PIE], [], [])
|
||||
AC_SUBST(HAVE_PIE)
|
||||
AC_TRY_LDFLAGS([-Wl,-z,relro,-z,now], [HAVE_FULL_RELRO], [], [])
|
||||
AC_SUBST(HAVE_FULL_RELRO)
|
||||
|
||||
################################################################################
|
||||
dnl -- Prefix is /usr by default, the exec_prefix default is setup later
|
||||
AC_PREFIX_DEFAULT(/usr)
|
||||
|
Loading…
Reference in New Issue
Block a user