debianutils: bump to version 4.8.1
[buildroot-gz.git] / package / trousers / 0002-Check-if-the-compiler-understands-pie-and-relro-options.patch
blob3275b76a2c857eae0a68b909d64d6934ae792251
1 From 9abda1bb380bdbef1affaec381742ced394ca118 Mon Sep 17 00:00:00 2001
2 From: Lada Trimasova <ltrimas@synopsys.com>
3 Date: Mon, 18 Jan 2016 15:58:19 +0300
4 Subject: [PATCH] Check if the compiler understands pie and relro options
6 -pie and -fpie enable the building of position-independent
7 executables, and -Wl,-z,relro turns on read-only relocation support in gcc.
8 Add checks to ensure that the compiler and linker understand these options.
10 Signed-off-by: Lada Trimasova <ltrimas@synopsys.com>
11 ---
12 configure.in | 5 +++
13 m4/ax_check_compile_flag.m4 | 72 ++++++++++++++++++++++++++++++++++++
14 m4/ax_check_link_flag.m4 | 71 +++++++++++++++++++++++++++++++++++
15 src/tcsd/Makefile.am | 4 +-
16 4 files changed, 150 insertions(+), 2 deletions(-)
17 create mode 100644 m4/ax_check_compile_flag.m4
18 create mode 100644 m4/ax_check_link_flag.m4
20 diff --git a/configure.in b/configure.in
21 index add23dc..9603353 100644
22 --- a/configure.in
23 +++ b/configure.in
24 @@ -12,6 +12,7 @@ TSS_VER_MINOR=3
25 # compute $target
26 AC_CANONICAL_TARGET
27 AM_INIT_AUTOMAKE([foreign 1.6])
28 +AC_CONFIG_MACRO_DIR([m4])
30 # Debugging support
31 AC_ARG_ENABLE([debug],
32 @@ -383,6 +384,10 @@ elif test x"${prefix}" = x"NONE"; then
33 localstatedir="/usr/local/var"
36 +AX_CHECK_COMPILE_FLAG([-fPIE -DPIE], [PIE_CFLAGS="-fPIE -DPIE"])
37 +AX_CHECK_LINK_FLAG([-pie], [PIE_LDFLAGS="$PIE_LDFLAGS -pie"])
38 +AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
40 AC_OUTPUT(dist/tcsd.conf \
41 dist/fedora/trousers.spec \
42 dist/trousers.spec \
43 diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4
44 new file mode 100644
45 index 0000000..c3a8d69
46 --- /dev/null
47 +++ b/m4/ax_check_compile_flag.m4
48 @@ -0,0 +1,72 @@
49 +# ===========================================================================
50 +# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
51 +# ===========================================================================
53 +# SYNOPSIS
55 +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
57 +# DESCRIPTION
59 +# Check whether the given FLAG works with the current language's compiler
60 +# or gives an error. (Warnings, however, are ignored)
62 +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
63 +# success/failure.
65 +# If EXTRA-FLAGS is defined, it is added to the current language's default
66 +# flags (e.g. CFLAGS) when the check is done. The check is thus made with
67 +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
68 +# force the compiler to issue an error when a bad flag is given.
70 +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
71 +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
73 +# LICENSE
75 +# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
76 +# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
78 +# This program is free software: you can redistribute it and/or modify it
79 +# under the terms of the GNU General Public License as published by the
80 +# Free Software Foundation, either version 3 of the License, or (at your
81 +# option) any later version.
83 +# This program is distributed in the hope that it will be useful, but
84 +# WITHOUT ANY WARRANTY; without even the implied warranty of
85 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
86 +# Public License for more details.
88 +# You should have received a copy of the GNU General Public License along
89 +# with this program. If not, see <http://www.gnu.org/licenses/>.
91 +# As a special exception, the respective Autoconf Macro's copyright owner
92 +# gives unlimited permission to copy, distribute and modify the configure
93 +# scripts that are the output of Autoconf when processing the Macro. You
94 +# need not follow the terms of the GNU General Public License when using
95 +# or distributing such scripts, even though portions of the text of the
96 +# Macro appear in them. The GNU General Public License (GPL) does govern
97 +# all other use of the material that constitutes the Autoconf Macro.
99 +# This special exception to the GPL applies to versions of the Autoconf
100 +# Macro released by the Autoconf Archive. When you make and distribute a
101 +# modified version of the Autoconf Macro, you may extend this special
102 +# exception to the GPL to apply to your modified version as well.
104 +#serial 2
106 +AC_DEFUN([AX_CHECK_COMPILE_FLAG],
107 +[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
108 +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
109 +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
110 + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
111 + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
112 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
113 + [AS_VAR_SET(CACHEVAR,[yes])],
114 + [AS_VAR_SET(CACHEVAR,[no])])
115 + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
116 +AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
117 + [m4_default([$2], :)],
118 + [m4_default([$3], :)])
119 +AS_VAR_POPDEF([CACHEVAR])dnl
120 +])dnl AX_CHECK_COMPILE_FLAGS
121 diff --git a/m4/ax_check_link_flag.m4 b/m4/ax_check_link_flag.m4
122 new file mode 100644
123 index 0000000..e2d0d36
124 --- /dev/null
125 +++ b/m4/ax_check_link_flag.m4
126 @@ -0,0 +1,71 @@
127 +# ===========================================================================
128 +# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
129 +# ===========================================================================
131 +# SYNOPSIS
133 +# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
135 +# DESCRIPTION
137 +# Check whether the given FLAG works with the linker or gives an error.
138 +# (Warnings, however, are ignored)
140 +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
141 +# success/failure.
143 +# If EXTRA-FLAGS is defined, it is added to the linker's default flags
144 +# when the check is done. The check is thus made with the flags: "LDFLAGS
145 +# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
146 +# issue an error when a bad flag is given.
148 +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
149 +# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
151 +# LICENSE
153 +# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
154 +# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
156 +# This program is free software: you can redistribute it and/or modify it
157 +# under the terms of the GNU General Public License as published by the
158 +# Free Software Foundation, either version 3 of the License, or (at your
159 +# option) any later version.
161 +# This program is distributed in the hope that it will be useful, but
162 +# WITHOUT ANY WARRANTY; without even the implied warranty of
163 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
164 +# Public License for more details.
166 +# You should have received a copy of the GNU General Public License along
167 +# with this program. If not, see <http://www.gnu.org/licenses/>.
169 +# As a special exception, the respective Autoconf Macro's copyright owner
170 +# gives unlimited permission to copy, distribute and modify the configure
171 +# scripts that are the output of Autoconf when processing the Macro. You
172 +# need not follow the terms of the GNU General Public License when using
173 +# or distributing such scripts, even though portions of the text of the
174 +# Macro appear in them. The GNU General Public License (GPL) does govern
175 +# all other use of the material that constitutes the Autoconf Macro.
177 +# This special exception to the GPL applies to versions of the Autoconf
178 +# Macro released by the Autoconf Archive. When you make and distribute a
179 +# modified version of the Autoconf Macro, you may extend this special
180 +# exception to the GPL to apply to your modified version as well.
182 +#serial 2
184 +AC_DEFUN([AX_CHECK_LINK_FLAG],
185 +[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
186 +AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
187 + ax_check_save_flags=$LDFLAGS
188 + LDFLAGS="$LDFLAGS $4 $1"
189 + AC_LINK_IFELSE([AC_LANG_PROGRAM()],
190 + [AS_VAR_SET(CACHEVAR,[yes])],
191 + [AS_VAR_SET(CACHEVAR,[no])])
192 + LDFLAGS=$ax_check_save_flags])
193 +AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
194 + [m4_default([$2], :)],
195 + [m4_default([$3], :)])
196 +AS_VAR_POPDEF([CACHEVAR])dnl
197 +])dnl AX_CHECK_LINK_FLAGS
198 diff --git a/src/tcsd/Makefile.am b/src/tcsd/Makefile.am
199 index 2210734..6640ab2 100644
200 --- a/src/tcsd/Makefile.am
201 +++ b/src/tcsd/Makefile.am
202 @@ -1,8 +1,8 @@
203 sbin_PROGRAMS=tcsd
205 -tcsd_CFLAGS=-DAPPID=\"TCSD\" -DVAR_PREFIX=\"@localstatedir@\" -DETC_PREFIX=\"@sysconfdir@\" -I${top_srcdir}/src/include -fPIE -DPIE
206 +tcsd_CFLAGS=-DAPPID=\"TCSD\" -DVAR_PREFIX=\"@localstatedir@\" -DETC_PREFIX=\"@sysconfdir@\" -I${top_srcdir}/src/include $(PIE_CFLAGS)
207 tcsd_LDADD=${top_builddir}/src/tcs/libtcs.a ${top_builddir}/src/tddl/libtddl.a -lpthread @CRYPTOLIB@
208 -tcsd_LDFLAGS=-pie -Wl,-z,relro -Wl,-z,now
209 +tcsd_LDFLAGS=$(PIE_LDFLAGS) $(RELRO_LDFLAGS)
211 tcsd_SOURCES=svrside.c tcsd_conf.c tcsd_threads.c platform.c
214 2.5.0