]> git.ipfire.org Git - thirdparty/glibc.git/blob - debug/Makefile
Avoid backtrace from __stack_chk_fail [BZ #12189]
[thirdparty/glibc.git] / debug / Makefile
1 # Copyright (C) 1998-2017 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
13
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <http://www.gnu.org/licenses/>.
17
18 #
19 # Sub-makefile for debug portion of the library.
20 #
21 subdir := debug
22
23 include ../Makeconfig
24
25 headers := execinfo.h
26
27 # Note that ptsname_r_chk and getlogin_r are not here, but in
28 # login/Makefile instead. If that subdir is omitted from the
29 # build, its _FORTIFY_SOURCE support will be too.
30 routines = backtrace backtracesyms backtracesymsfd noophooks \
31 memcpy_chk memmove_chk mempcpy_chk memset_chk stpcpy_chk \
32 strcat_chk strcpy_chk strncat_chk strncpy_chk stpncpy_chk \
33 sprintf_chk vsprintf_chk snprintf_chk vsnprintf_chk \
34 printf_chk fprintf_chk vprintf_chk vfprintf_chk \
35 gets_chk chk_fail readonly-area fgets_chk fgets_u_chk \
36 read_chk pread_chk pread64_chk recv_chk recvfrom_chk \
37 readlink_chk readlinkat_chk getwd_chk getcwd_chk \
38 realpath_chk fread_chk fread_u_chk \
39 wctomb_chk wcscpy_chk wmemcpy_chk wmemmove_chk wmempcpy_chk \
40 wcpcpy_chk wcsncpy_chk wcscat_chk wcsncat_chk wmemset_chk \
41 wcpncpy_chk \
42 swprintf_chk vswprintf_chk wprintf_chk fwprintf_chk \
43 vwprintf_chk vfwprintf_chk fgetws_chk fgetws_u_chk \
44 confstr_chk getgroups_chk ttyname_r_chk \
45 gethostname_chk getdomainname_chk wcrtomb_chk mbsnrtowcs_chk \
46 wcsnrtombs_chk mbsrtowcs_chk wcsrtombs_chk mbstowcs_chk \
47 wcstombs_chk asprintf_chk vasprintf_chk dprintf_chk \
48 vdprintf_chk obprintf_chk \
49 longjmp_chk ____longjmp_chk \
50 fdelt_chk poll_chk ppoll_chk \
51 explicit_bzero_chk \
52 stack_chk_fail fortify_fail \
53 $(static-only-routines)
54 static-only-routines := warning-nop stack_chk_fail_local
55
56 # Building the stack-protector failure routines with stack protection
57 # makes no sense.
58
59 CFLAGS-stack_chk_fail.c = $(no-stack-protector)
60 CFLAGS-stack_chk_fail_local.c = $(no-stack-protector)
61
62 CFLAGS-backtrace.c = -fno-omit-frame-pointer
63 CFLAGS-sprintf_chk.c = $(libio-mtsafe)
64 CFLAGS-snprintf_chk.c = $(libio-mtsafe)
65 CFLAGS-vsprintf_chk.c = $(libio-mtsafe)
66 CFLAGS-vsnprintf_chk.c = $(libio-mtsafe)
67 CFLAGS-asprintf_chk.c = $(libio-mtsafe)
68 CFLAGS-vasprintf_chk.c = $(libio-mtsafe)
69 CFLAGS-obprintf_chk.c = $(libio-mtsafe)
70 CFLAGS-dprintf_chk.c = $(libio-mtsafe) -fexceptions
71 CFLAGS-vdprintf_chk.c = $(libio-mtsafe) -fexceptions
72 CFLAGS-printf_chk.c = $(libio-mtsafe) -fexceptions
73 CFLAGS-fprintf_chk.c = $(libio-mtsafe) -fexceptions
74 CFLAGS-vprintf_chk.c = $(libio-mtsafe) -fexceptions
75 CFLAGS-vfprintf_chk.c = $(libio-mtsafe) -fexceptions
76 CFLAGS-gets_chk.c = $(libio-mtsafe) -fexceptions
77 CFLAGS-fgets_chk.c = $(libio-mtsafe) -fexceptions
78 CFLAGS-fgets_u_chk.c = $(libio-mtsafe) -fexceptions
79 CFLAGS-fread_chk.c = $(libio-mtsafe) -fexceptions
80 CFLAGS-fread_u_chk.c = $(libio-mtsafe) -fexceptions
81 CFLAGS-swprintf_chk.c = $(libio-mtsafe)
82 CFLAGS-vswprintf_chk.c = $(libio-mtsafe)
83 CFLAGS-wprintf_chk.c = $(libio-mtsafe) -fexceptions
84 CFLAGS-fwprintf_chk.c = $(libio-mtsafe) -fexceptions
85 CFLAGS-vwprintf_chk.c = $(libio-mtsafe) -fexceptions
86 CFLAGS-vfwprintf_chk.c = $(libio-mtsafe) -fexceptions
87 CFLAGS-fgetws_chk.c = $(libio-mtsafe) -fexceptions
88 CFLAGS-fgetws_u_chk.c = $(libio-mtsafe) -fexceptions
89 CFLAGS-read_chk.c = -fexceptions -fasynchronous-unwind-tables
90 CFLAGS-pread_chk.c = -fexceptions -fasynchronous-unwind-tables
91 CFLAGS-pread64_chk.c = -fexceptions -fasynchronous-unwind-tables
92 CFLAGS-recv_chk.c = -fexceptions -fasynchronous-unwind-tables
93 CFLAGS-recvfrom_chk.c = -fexceptions -fasynchronous-unwind-tables
94
95 # Need to make sure the settings here override what configure might have
96 # set up for us, so keep the CFLAGS/CPPFLAGS split logical as the order is:
97 # <user CFLAGS> <test CFLAGS> <user CPPFLAGS> <test CPPFLAGS>
98 CFLAGS-tst-longjmp_chk.c = -fexceptions -fasynchronous-unwind-tables
99 CPPFLAGS-tst-longjmp_chk.c = -D_FORTIFY_SOURCE=1
100 CFLAGS-tst-longjmp_chk2.c = -fexceptions -fasynchronous-unwind-tables
101 CPPFLAGS-tst-longjmp_chk2.c = -D_FORTIFY_SOURCE=1
102 CFLAGS-tst-longjmp_chk3.c = -fexceptions -fasynchronous-unwind-tables
103 CPPFLAGS-tst-longjmp_chk3.c = -D_FORTIFY_SOURCE=1
104
105 # We know these tests have problems with format strings, this is what
106 # we are testing. Disable that warning. They are also testing
107 # deprecated functions (notably gets) so disable that warning as well.
108 # And they also generate warnings from warning attributes, which
109 # cannot be disabled via pragmas, so require -Wno-error to be used.
110 CFLAGS-tst-chk1.c = -Wno-format -Wno-deprecated-declarations -Wno-error
111 CFLAGS-tst-chk2.c = -Wno-format -Wno-deprecated-declarations -Wno-error
112 CFLAGS-tst-chk3.c = -Wno-format -Wno-deprecated-declarations -Wno-error
113 CFLAGS-tst-chk4.cc = -Wno-format -Wno-deprecated-declarations -Wno-error
114 CFLAGS-tst-chk5.cc = -Wno-format -Wno-deprecated-declarations -Wno-error
115 CFLAGS-tst-chk6.cc = -Wno-format -Wno-deprecated-declarations -Wno-error
116 CFLAGS-tst-lfschk1.c = -Wno-format -Wno-deprecated-declarations -Wno-error
117 CFLAGS-tst-lfschk2.c = -Wno-format -Wno-deprecated-declarations -Wno-error
118 CFLAGS-tst-lfschk3.c = -Wno-format -Wno-deprecated-declarations -Wno-error
119 CFLAGS-tst-lfschk4.cc = -Wno-format -Wno-deprecated-declarations -Wno-error
120 CFLAGS-tst-lfschk5.cc = -Wno-format -Wno-deprecated-declarations -Wno-error
121 CFLAGS-tst-lfschk6.cc = -Wno-format -Wno-deprecated-declarations -Wno-error
122 LDLIBS-tst-chk4 = -lstdc++
123 LDLIBS-tst-chk5 = -lstdc++
124 LDLIBS-tst-chk6 = -lstdc++
125 LDLIBS-tst-lfschk4 = -lstdc++
126 LDLIBS-tst-lfschk5 = -lstdc++
127 LDLIBS-tst-lfschk6 = -lstdc++
128
129 # backtrace_symbols only works if we link with -rdynamic. backtrace
130 # requires unwind tables on most architectures.
131 CFLAGS-tst-backtrace2.c += -funwind-tables
132 CFLAGS-tst-backtrace3.c += -funwind-tables
133 CFLAGS-tst-backtrace4.c += -funwind-tables
134 CFLAGS-tst-backtrace5.c += -funwind-tables
135 CFLAGS-tst-backtrace6.c += -funwind-tables
136 LDFLAGS-tst-backtrace2 = -rdynamic
137 LDFLAGS-tst-backtrace3 = -rdynamic
138 LDFLAGS-tst-backtrace4 = -rdynamic
139 LDFLAGS-tst-backtrace5 = -rdynamic
140 LDFLAGS-tst-backtrace6 = -rdynamic
141
142 CFLAGS-tst-ssp-1.c = -fstack-protector
143
144 tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
145 tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
146 tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6 \
147 tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 tst-backtrace4 \
148 tst-backtrace5 tst-backtrace6
149
150 ifeq ($(have-ssp),yes)
151 tests += tst-ssp-1
152 endif
153
154 ifeq (,$(CXX))
155 tests-unsupported = tst-chk4 tst-chk5 tst-chk6 \
156 tst-lfschk4 tst-lfschk5 tst-lfschk6
157 endif
158
159 extra-libs = libSegFault libpcprofile
160 extra-libs-others = $(extra-libs)
161
162 libSegFault-routines = segfault
163 libSegFault-inhibit-o = $(filter-out .os,$(object-suffixes))
164
165 libpcprofile-routines = pcprofile
166 libpcprofile-inhibit-o = $(filter-out .os,$(object-suffixes))
167
168 others = pcprofiledump
169 install-bin = pcprofiledump
170 install-bin-script = xtrace
171
172 ifeq ($(build-shared),yes)
173 install-bin-script += catchsegv
174 endif
175 generated += catchsegv xtrace
176
177 include ../Rules
178
179 ifeq ($(run-built-tests),yes)
180 LOCALES := de_DE.UTF-8
181 include ../gen-locales.mk
182
183 $(objpfx)tst-chk1.out: $(gen-locales)
184 endif
185
186 sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
187
188 $(objpfx)catchsegv: catchsegv.sh $(common-objpfx)soversions.mk \
189 $(common-objpfx)config.make
190 slibpfx=`echo $(slibdir)|sed 's/lib\(64\|\)$$/\\\\\\\\$$LIB/'`; \
191 sed -e 's|@VERSION@|$(version)|' -e "s|@SLIB@|$$slibpfx|" \
192 -e 's|@PKGVERSION@|$(PKGVERSION)|' \
193 -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $< > $@.new
194 chmod 555 $@.new
195 mv -f $@.new $@
196
197 $(objpfx)pcprofiledump: $(objpfx)pcprofiledump.o
198
199 $(objpfx)xtrace: xtrace.sh
200 rm -f $@.new
201 sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
202 -e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' \
203 -e 's|@PKGVERSION@|$(PKGVERSION)|' \
204 -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
205 && rm -f $@ && mv $@.new $@ && chmod +x $@