libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 03c29b63e0e4c4036dafaa382cd0db1fe400a7a2
parent 7570030f7125f2fbc4e0c931ba09ca93c9218a71
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 17 Apr 2022 18:34:17 +0300

configure: improved usage of 'pie' mode for hardening

Diffstat:
Mconfigure.ac | 35++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -313,33 +313,30 @@ AS_VAR_IF([enable_compiler_hardening],["yes"], MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac],[-fstack-protector-strong],[-fstack-protector-all],[-fstack-protector]) MHD_CHECK_ADD_CC_CFLAGS([-fstack-clash-protection -ftrivial-auto-var-init=pattern],[CFLAGS_ac]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" - AS_VAR_IF([pic_mode],["no"],[], + AS_IF([test "x${enable_static}" = "xyes" && test "x${pic_mode}" != "xyes"], [ - AS_VAR_IF([enable_shared],["yes"],[], + # PIE static lib can be used within non-PIE application, but + # PIE static lib cannot be used in non-PIE shared lib. Let's assume + # that static lib will not be used in shared lib + # All "pie" flags will be used automatically by libtool only + # for static library objects. + CFLAGS="${user_CFLAGS}" + # Perform tests here with "-pie" enabled + LDFLAGS="${LDFLAGS_ac} -pie ${user_LDFLAGS}" + MHD_CHECK_ADD_CC_CFLAG([-fPIE],[CFLAGS_ac], [ - # PIE cannot be used for shared lib - # PIE static lib can be used within non-PIE application, but - # PIE static lib cannot be used in non-PIE shared lib. Let's assume - # that static lib will not be used in shared lib - CFLAGS="${user_CFLAGS}" - # Perform tests with "-pie" enabled - LDFLAGS="${LDFLAGS_ac} -pie ${user_LDFLAGS}" - MHD_CHECK_ADD_CC_CFLAG([-fPIE],[CFLAGS_ac], + MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie]) + ], + [ + MHD_CHECK_ADD_CC_CFLAG([-fpie],[CFLAGS_ac], [ MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie]) - ], - [ - MHD_CHECK_CC_CFLAG([-fpie],[CFLAGS_ac], - [ - MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie]) - ] - ) ] ) - CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" - LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) + CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" + LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"