Skip to content

Commit 0b1f35c

Browse files
committed
Add back the linker check for -fstack-clash-protection.
This is expected to fix GitHub issue #231. --HG-- branch : 1.9
1 parent e6c720a commit 0b1f35c

2 files changed

Lines changed: 46 additions & 5 deletions

File tree

configure

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31915,7 +31915,7 @@ else $as_nop
3191531915
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3191631916
/* end confdefs.h. */
3191731917

31918-
int main(int argc, char *argv[]) { char buf[16384], *src = argv[0], *dst = buf; while ((*dst++ = *src++) != '\0'); return buf[argc]; }
31918+
int main(int argc, char *argv[]) { char buf[16384], *src = argv[0], *dst = buf; while ((*dst++ = *src++) != '\0') { continue; } return buf[argc]; }
3191931919

3192031920
_ACEOF
3192131921
if ac_fn_c_try_compile "$LINENO"
@@ -31932,6 +31932,41 @@ fi
3193231932
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_check_cflags___fstack_clash_protection" >&5
3193331933
printf "%s\n" "$sudo_cv_check_cflags___fstack_clash_protection" >&6; }
3193431934
if test X"$sudo_cv_check_cflags___fstack_clash_protection" = X"yes"; then
31935+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -fstack-clash-protection" >&5
31936+
printf %s "checking whether the linker accepts -fstack-clash-protection... " >&6; }
31937+
if test ${ax_cv_check_ldflags___fstack_clash_protection+y}
31938+
then :
31939+
printf %s "(cached) " >&6
31940+
else $as_nop
31941+
31942+
ax_check_save_flags=$LDFLAGS
31943+
LDFLAGS="$LDFLAGS -fstack-clash-protection"
31944+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
31945+
/* end confdefs.h. */
31946+
31947+
int
31948+
main (void)
31949+
{
31950+
31951+
;
31952+
return 0;
31953+
}
31954+
_ACEOF
31955+
if ac_fn_c_try_link "$LINENO"
31956+
then :
31957+
ax_cv_check_ldflags___fstack_clash_protection=yes
31958+
else $as_nop
31959+
ax_cv_check_ldflags___fstack_clash_protection=no
31960+
fi
31961+
rm -f core conftest.err conftest.$ac_objext conftest.beam \
31962+
conftest$ac_exeext conftest.$ac_ext
31963+
LDFLAGS=$ax_check_save_flags
31964+
fi
31965+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___fstack_clash_protection" >&5
31966+
printf "%s\n" "$ax_cv_check_ldflags___fstack_clash_protection" >&6; }
31967+
if test x"$ax_cv_check_ldflags___fstack_clash_protection" = xyes
31968+
then :
31969+
3193531970

3193631971
if test ${HARDENING_CFLAGS+y}
3193731972
then :
@@ -31998,6 +32033,11 @@ else $as_nop
3199832033

3199932034
fi
3200032035

32036+
32037+
else $as_nop
32038+
:
32039+
fi
32040+
3200132041
fi
3200232042

3200332043
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fcf-protection" >&5
@@ -35127,6 +35167,5 @@ fi
3512735167

3512835168

3512935169

35130-
3513135170

3513235171

configure.ac

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4966,14 +4966,16 @@ if test "$enable_hardening" != "no"; then
49664966
_CFLAGS="$CFLAGS"
49674967
CFLAGS="$CFLAGS -fstack-clash-protection"
49684968
AC_COMPILE_IFELSE([
4969-
AC_LANG_SOURCE([[int main(int argc, char *argv[]) { char buf[16384], *src = argv[0], *dst = buf; while ((*dst++ = *src++) != '\0'); return buf[argc]; }]])
4969+
AC_LANG_SOURCE([[int main(int argc, char *argv[]) { char buf[16384], *src = argv[0], *dst = buf; while ((*dst++ = *src++) != '\0') { continue; } return buf[argc]; }]])
49704970
], [sudo_cv_check_cflags___fstack_clash_protection=yes], [sudo_cv_check_cflags___fstack_clash_protection=no])
49714971
CFLAGS="$_CFLAGS"
49724972
]
49734973
)
49744974
if test X"$sudo_cv_check_cflags___fstack_clash_protection" = X"yes"; then
4975-
AX_APPEND_FLAG([-fstack-clash-protection], [HARDENING_CFLAGS])
4976-
AX_APPEND_FLAG([-Wc,-fstack-clash-protection], [HARDENING_LDFLAGS])
4975+
AX_CHECK_LINK_FLAG([-fstack-clash-protection], [
4976+
AX_APPEND_FLAG([-fstack-clash-protection], [HARDENING_CFLAGS])
4977+
AX_APPEND_FLAG([-Wc,-fstack-clash-protection], [HARDENING_LDFLAGS])
4978+
])
49774979
fi
49784980

49794981
AX_CHECK_COMPILE_FLAG([-fcf-protection], [

0 commit comments

Comments
 (0)