diff options
author | Reini Urban <rurban@cpan.org> | 2018-01-15 10:53:15 +0100 |
---|---|---|
committer | Reini Urban <rurban@cpan.org> | 2018-01-15 11:02:13 +0100 |
commit | 4789b434e3286dbe112deed35f05bc7edfa44c6a (patch) | |
tree | 1c01df53e694bbc5c3e0e2757ecdc6a1c4035626 /m4/ax_compiler_flags_ldflags.m4 | |
parent | 3546625f64904062a5c413ac9f08f0a9901427fd (diff) | |
download | autoconf-archive-4789b434e3286dbe112deed35f05bc7edfa44c6a.tar.gz |
ax_compiler_flags_ldflags: harden
Add -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack
but not yet the brand-new textonly, retpolineplt linker flags. Let's wait
what gcc decides on the flags for Spectre, clang went with retpolineplt.
Diffstat (limited to 'm4/ax_compiler_flags_ldflags.m4')
-rw-r--r-- | m4/ax_compiler_flags_ldflags.m4 | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/m4/ax_compiler_flags_ldflags.m4 b/m4/ax_compiler_flags_ldflags.m4 index 842e329..976d119 100644 --- a/m4/ax_compiler_flags_ldflags.m4 +++ b/m4/ax_compiler_flags_ldflags.m4 @@ -19,13 +19,14 @@ # LICENSE # # Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk> +# Copyright (c) 2017, 2018 Reini Urban <rurban@cpan.org> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 8 +#serial 9 AC_DEFUN([AX_COMPILER_FLAGS_LDFLAGS],[ AX_REQUIRE_DEFINED([AX_APPEND_LINK_FLAGS]) @@ -48,7 +49,25 @@ AC_DEFUN([AX_COMPILER_FLAGS_LDFLAGS],[ ax_compiler_flags_test="" ]) - # macOS linker does not have --as-needed + AX_CHECK_LINK_FLAG([-Wl,--as-needed], [ + AX_APPEND_LINK_FLAGS([-Wl,--as-needed], + [AM_LDFLAGS],[$ax_compiler_flags_test]) + ]) + AX_CHECK_LINK_FLAG([-Wl,-z,relro], [ + AX_APPEND_LINK_FLAGS([-Wl,-z,relro], + [AM_LDFLAGS],[$ax_compiler_flags_test]) + ]) + AX_CHECK_LINK_FLAG([-Wl,-z,now], [ + AX_APPEND_LINK_FLAGS([-Wl,-z,now], + [AM_LDFLAGS],[$ax_compiler_flags_test]) + ]) + AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [ + AX_APPEND_LINK_FLAGS([-Wl,-z,noexecstack], + [AM_LDFLAGS],[$ax_compiler_flags_test]) + ]) + # textonly, retpolineplt not yet + + # macOS and cygwin linker do not have --as-needed AX_CHECK_LINK_FLAG([-Wl,--no-as-needed], [ ax_compiler_flags_as_needed_option="-Wl,--no-as-needed" ], [ |