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