2
1

0001-configure.ac-add-disable-hardening-option.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 94c612016834d7bdc2b721ff5f4f5e158bda6fdd Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Sat, 8 Jan 2022 21:49:22 +0100
  4. Subject: [PATCH] configure.ac: add --disable-hardening option
  5. Allow the user to disable hardening which is enabled by default since
  6. version 02092020 and
  7. https://github.com/rurban/safeclib/commit/caa4408eb4a5c767f0474258af3b6ccf444e10aa
  8. to avoid the following build failure when the toolchain doesn't support
  9. stack-protector:
  10. /home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/m68k-buildroot-uclinux-uclibc/bin/ld.real: ../src/.libs/libsafec-3.6.0.a(safe_mem_constraint.o): in function `handle_mem_bos_chk_warn':
  11. safe_mem_constraint.c:(.text+0x40): undefined reference to `__stack_chk_guard'
  12. Fixes:
  13. - http://autobuild.buildroot.org/results/a481ee2d26a094358b0298617cce691be3077f22
  14. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  15. [Upstream status: https://github.com/rurban/safeclib/pull/107]
  16. ---
  17. configure.ac | 27 +++++++++++++++++++--------
  18. 1 file changed, 19 insertions(+), 8 deletions(-)
  19. diff --git a/configure.ac b/configure.ac
  20. index 55756b06..f852ed44 100644
  21. --- a/configure.ac
  22. +++ b/configure.ac
  23. @@ -383,6 +383,21 @@ AC_ARG_ENABLE(debug-build,
  24. esac], [enable_debug_build=false ])
  25. AM_CONDITIONAL(ENABLE_DEBUG_BUILD, test "x$enable_debug_build" = "xtrue")
  26. +AC_ARG_ENABLE(hardening,
  27. + AS_HELP_STRING([--disable-hardening],
  28. + [disable hardening @<:@default=no@:>@]),
  29. + [case "${enableval}" in
  30. + yes) enable_hardening=true ;;
  31. + no) enable_hardening=false ;;
  32. + *) AC_MSG_ERROR([bad value ${enableval} for --enable-hardening]) ;;
  33. + esac], [enable_hardening=true])
  34. +
  35. +if test "x$enable_hardening" = "xtrue" ; then
  36. + AX_APPEND_COMPILE_FLAGS([-fstack-protector-strong -fstack-clash-protection -fcf-protection],
  37. + [WARN_CFLAGS],[$ax_ccf_err])
  38. + AX_APPEND_LINK_FLAGS([-fstack-protector-strong -fstack-clash-protection -fcf-protection],
  39. + [WARN_LDFLAGS],[$ax_ccf_err])
  40. +fi
  41. AC_MSG_NOTICE([Check programs])
  42. # ===============================================
  43. @@ -543,10 +562,6 @@ case $host_os in
  44. [],[$ax_ccf_err])
  45. ;;
  46. esac
  47. -AX_APPEND_COMPILE_FLAGS([-fstack-protector-strong -fstack-clash-protection -fcf-protection],
  48. - [WARN_CFLAGS],[$ax_ccf_err])
  49. -AX_APPEND_LINK_FLAGS([-fstack-protector-strong -fstack-clash-protection -fcf-protection],
  50. - [WARN_LDFLAGS],[$ax_ccf_err])
  51. if test x$ax_cv_check_cflags__Wrestrict = xyes; then
  52. AC_DEFINE([HAVE_WARNING_RESTRICT], 1, [Have -Wrestrict])
  53. --
  54. 2.34.1