| From c810a0aca3f1148d2072d44b91b8cc9caeb4cf19 Mon Sep 17 00:00:00 2001 |
| From: James Knight <james.knight@rockwellcollins.com> |
| Date: Wed, 16 Nov 2016 15:54:46 -0500 |
| Subject: [PATCH] configure.ac: correct stack protector check |
| |
| If a used toolchain accepts the `-fstack-protector` option but does not |
| provide a stack smashing protector implementation (ex. libssp), linking |
| will fail: |
| |
| .libs/rpmio.o: In function `Fdescr': |
| rpmio.c:(.text+0x672): undefined reference to `__stack_chk_fail_local' |
| .libs/rpmio.o: In function `Fdopen': |
| rpmio.c:(.text+0xce9): undefined reference to `__stack_chk_fail_local' |
| .libs/rpmio.o: In function `ufdCopy': |
| rpmio.c:(.text+0x10f7): undefined reference to `__stack_chk_fail_local' |
| ... |
| |
| This is a result of testing for `-fstack-protector` support using a main |
| that GCC does not inject guards. GCC's manual notes that stack protector |
| code is only added when "[functions] that call alloca, and functions |
| with buffers larger than 8 bytes" [1]. This commit adjusts the stack |
| protector check to allocate memory on the stack (via `alloca`). |
| |
| [1]: https://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Optimize-Options.html |
| |
| Signed-off-by: James Knight <james.knight@rockwellcollins.com> |
| [Upstream commit: https://github.com/rpm-software-management/rpm/commit/c810a0aca3f1148d2072d44b91b8cc9caeb4cf19] |
| Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
| --- |
| configure.ac | 2 +- |
| 1 file changed, 1 insertion(+), 1 deletion(-) |
| |
| diff --git a/configure.ac b/configure.ac |
| index a9730d3bc..b4b3fe8fb 100644 |
| --- a/configure.ac |
| +++ b/configure.ac |
| @@ -43,7 +43,7 @@ if test "$GCC" = yes; then |
| echo |
| for flag in $cflags_to_try; do |
| CFLAGS="$CFLAGS $flag -Werror" |
| - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[ |
| + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])],[ |
| echo " $flag" |
| RPMCFLAGS="$RPMCFLAGS $flag" |
| ],[]) |