summaryrefslogtreecommitdiffstats
path: root/package/rpm/0002-configure-ac-correct-stack-protector-check.patch
blob: 9d2942b4fabfbbc6cb87b3d1c9d3631702b2a75a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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"
         ],[])
OpenPOWER on IntegriCloud