more compiler safety flags

Corinna Vinschen vinschen at redhat.com
Fri Dec 21 20:42:41 EST 2012


On Dec 21 11:43, Darren Tucker wrote:
> Anyone see any reason not to add these extra compiler/linker flags if
> they're supported?
> 
> Index: aclocal.m4
> ===================================================================
> RCS file: /home/dtucker/openssh/cvs/openssh/aclocal.m4,v
> retrieving revision 1.8
> diff -u -p -r1.8 aclocal.m4
> --- aclocal.m4	20 May 2011 01:45:25 -0000	1.8
> +++ aclocal.m4	17 Dec 2012 03:56:32 -0000
> @@ -21,6 +21,23 @@ AC_DEFUN([OSSH_CHECK_CFLAG_COMPILE], [{
>  	)
>  }])
>  
> +dnl OSSH_CHECK_CFLAG_LINK(check_flag[, define_flag])
> +dnl Check that $LD accepts a flag 'check_flag'. If it is supported append
> +dnl 'define_flag' to $LDFLAGS. If 'define_flag' is not specified, then append
> +dnl 'check_flag'.
> +AC_DEFUN([OSSH_CHECK_LDFLAG_LINK], [{
> +	AC_MSG_CHECKING([if $LD supports $1])
> +	saved_LDFLAGS="$LDFLAGS"
> +	LDFLAGS="$LDFLAGS $1"
> +	_define_flag="$2"
> +	test "x$_define_flag" = "x" && _define_flag="$1"
> +	AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
> +		[ AC_MSG_RESULT([yes])
> +		  LDFLAGS="$saved_LDFLAGS $_define_flag"],
> +		[ AC_MSG_RESULT([no])
> +		  LDFLAGS="$saved_LDFLAGS" ]
> +	)
> +}])
>  
>  dnl OSSH_CHECK_HEADER_FOR_FIELD(field, header, symbol)
>  dnl Does AC_EGREP_HEADER on 'header' for the string 'field'
> Index: configure.ac
> ===================================================================
> RCS file: /home/dtucker/openssh/cvs/openssh/configure.ac,v
> retrieving revision 1.499
> diff -u -p -r1.499 configure.ac
> --- configure.ac	12 Dec 2012 21:18:56 -0000	1.499
> +++ configure.ac	17 Dec 2012 03:57:01 -0000
> @@ -164,6 +164,11 @@ if test "$GCC" = "yes" || test "$GCC" = 
>  	OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
>  	OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
>  	OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
> +	OSSH_CHECK_CFLAG_COMPILE([-fPIC])
> +	OSSH_CHECK_LDFLAG_LINK([-pie])
> +	OSSH_CHECK_LDFLAG_LINK([-Wa,--noexecstack])

Shouldn't that be

	OSSH_CHECK_CFLAG_COMPILE([-Wa,--noexecstack])

?


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


More information about the openssh-unix-dev mailing list