]>
Commit | Line | Data |
---|---|---|
688903eb | 1 | # Copyright (C) 1998-2018 Free Software Foundation, Inc. |
2de7874e UD |
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 | |
41bdb6e2 AJ |
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. | |
2de7874e UD |
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 | |
41bdb6e2 | 12 | # Lesser General Public License for more details. |
2de7874e | 13 | |
41bdb6e2 | 14 | # You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
15 | # License along with the GNU C Library; if not, see |
16 | # <http://www.gnu.org/licenses/>. | |
2de7874e UD |
17 | |
18 | # | |
19 | # Sub-makefile for debug portion of the library. | |
20 | # | |
21 | subdir := debug | |
22 | ||
a5f891ac JM |
23 | include ../Makeconfig |
24 | ||
2de7874e UD |
25 | headers := execinfo.h |
26 | ||
ee586a6d RM |
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. | |
61062f56 | 30 | routines = backtrace backtracesyms backtracesymsfd noophooks \ |
b5cc329c | 31 | memcpy_chk memmove_chk mempcpy_chk memset_chk stpcpy_chk \ |
8215c9ec | 32 | strcat_chk strcpy_chk strncat_chk strncpy_chk stpncpy_chk \ |
b5cc329c UD |
33 | sprintf_chk vsprintf_chk snprintf_chk vsnprintf_chk \ |
34 | printf_chk fprintf_chk vprintf_chk vfprintf_chk \ | |
553cc5f9 UD |
35 | gets_chk chk_fail readonly-area fgets_chk fgets_u_chk \ |
36 | read_chk pread_chk pread64_chk recv_chk recvfrom_chk \ | |
a346370d | 37 | readlink_chk readlinkat_chk getwd_chk getcwd_chk \ |
bd9ffde6 | 38 | realpath_chk fread_chk fread_u_chk \ |
8215c9ec UD |
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 \ | |
ee586a6d | 44 | confstr_chk getgroups_chk ttyname_r_chk \ |
df6f8969 | 45 | gethostname_chk getdomainname_chk wcrtomb_chk mbsnrtowcs_chk \ |
02ca3541 | 46 | wcsnrtombs_chk mbsrtowcs_chk wcsrtombs_chk mbstowcs_chk \ |
dff37515 | 47 | wcstombs_chk asprintf_chk vasprintf_chk dprintf_chk \ |
4e2f43f8 | 48 | vdprintf_chk obprintf_chk vobprintf_chk \ |
b50f8e42 | 49 | longjmp_chk ____longjmp_chk \ |
d9a216c0 | 50 | fdelt_chk poll_chk ppoll_chk \ |
ea1bd74d | 51 | explicit_bzero_chk \ |
ddfd0535 | 52 | stack_chk_fail fortify_fail \ |
61062f56 | 53 | $(static-only-routines) |
35f1e827 | 54 | static-only-routines := warning-nop stack_chk_fail_local |
2de7874e | 55 | |
2b4fca86 L |
56 | # Don't add stack_chk_fail_local.o to libc.a since __stack_chk_fail_local |
57 | # is an alias of __stack_chk_fail in stack_chk_fail.o. | |
58 | elide-routines.o := stack_chk_fail_local | |
59 | ||
524a8ef2 | 60 | # Building the stack-protector failure routines with stack protection |
38cade0c FW |
61 | # is not required since we have already failed a stack check and are |
62 | # exiting the process. However, the local aliases which jump to the | |
63 | # real routines should still be compiled with stack protection | |
64 | # (stack_chk_fail_local.c), so that the statically linked parts of the | |
65 | # library have the expected flags. | |
524a8ef2 | 66 | |
36975e8e | 67 | CFLAGS-stack_chk_fail.c += $(no-stack-protector) |
36975e8e L |
68 | |
69 | CFLAGS-backtrace.c += -fno-omit-frame-pointer -funwind-tables | |
70 | CFLAGS-sprintf_chk.c += $(libio-mtsafe) | |
71 | CFLAGS-snprintf_chk.c += $(libio-mtsafe) | |
72 | CFLAGS-vsprintf_chk.c += $(libio-mtsafe) | |
73 | CFLAGS-vsnprintf_chk.c += $(libio-mtsafe) | |
74 | CFLAGS-asprintf_chk.c += $(libio-mtsafe) | |
75 | CFLAGS-vasprintf_chk.c += $(libio-mtsafe) | |
76 | CFLAGS-obprintf_chk.c += $(libio-mtsafe) | |
77 | CFLAGS-dprintf_chk.c += $(libio-mtsafe) -fexceptions | |
78 | CFLAGS-vdprintf_chk.c += $(libio-mtsafe) -fexceptions | |
79 | CFLAGS-printf_chk.c += $(libio-mtsafe) -fexceptions | |
80 | CFLAGS-fprintf_chk.c += $(libio-mtsafe) -fexceptions | |
81 | CFLAGS-vprintf_chk.c += $(libio-mtsafe) -fexceptions | |
82 | CFLAGS-vfprintf_chk.c += $(libio-mtsafe) -fexceptions | |
83 | CFLAGS-gets_chk.c += $(libio-mtsafe) -fexceptions | |
84 | CFLAGS-fgets_chk.c += $(libio-mtsafe) -fexceptions | |
85 | CFLAGS-fgets_u_chk.c += $(libio-mtsafe) -fexceptions | |
86 | CFLAGS-fread_chk.c += $(libio-mtsafe) -fexceptions | |
87 | CFLAGS-fread_u_chk.c += $(libio-mtsafe) -fexceptions | |
88 | CFLAGS-swprintf_chk.c += $(libio-mtsafe) | |
89 | CFLAGS-vswprintf_chk.c += $(libio-mtsafe) | |
90 | CFLAGS-wprintf_chk.c += $(libio-mtsafe) -fexceptions | |
91 | CFLAGS-fwprintf_chk.c += $(libio-mtsafe) -fexceptions | |
92 | CFLAGS-vwprintf_chk.c += $(libio-mtsafe) -fexceptions | |
93 | CFLAGS-vfwprintf_chk.c += $(libio-mtsafe) -fexceptions | |
94 | CFLAGS-fgetws_chk.c += $(libio-mtsafe) -fexceptions | |
95 | CFLAGS-fgetws_u_chk.c += $(libio-mtsafe) -fexceptions | |
96 | CFLAGS-read_chk.c += -fexceptions -fasynchronous-unwind-tables | |
97 | CFLAGS-pread_chk.c += -fexceptions -fasynchronous-unwind-tables | |
98 | CFLAGS-pread64_chk.c += -fexceptions -fasynchronous-unwind-tables | |
99 | CFLAGS-recv_chk.c += -fexceptions -fasynchronous-unwind-tables | |
100 | CFLAGS-recvfrom_chk.c += -fexceptions -fasynchronous-unwind-tables | |
fed806c3 MF |
101 | |
102 | # Need to make sure the settings here override what configure might have | |
103 | # set up for us, so keep the CFLAGS/CPPFLAGS split logical as the order is: | |
104 | # <user CFLAGS> <test CFLAGS> <user CPPFLAGS> <test CPPFLAGS> | |
36975e8e L |
105 | CFLAGS-tst-longjmp_chk.c += -fexceptions -fasynchronous-unwind-tables |
106 | CPPFLAGS-tst-longjmp_chk.c += -D_FORTIFY_SOURCE=1 | |
107 | CFLAGS-tst-longjmp_chk2.c += -fexceptions -fasynchronous-unwind-tables | |
108 | CPPFLAGS-tst-longjmp_chk2.c += -D_FORTIFY_SOURCE=1 | |
109 | CFLAGS-tst-longjmp_chk3.c += -fexceptions -fasynchronous-unwind-tables | |
110 | CPPFLAGS-tst-longjmp_chk3.c += -D_FORTIFY_SOURCE=1 | |
2de7874e | 111 | |
7a344d1d | 112 | # We know these tests have problems with format strings, this is what |
7caa5054 ZW |
113 | # we are testing. Disable that warning. They are also testing |
114 | # deprecated functions (notably gets) so disable that warning as well. | |
115 | # And they also generate warnings from warning attributes, which | |
116 | # cannot be disabled via pragmas, so require -Wno-error to be used. | |
36975e8e L |
117 | CFLAGS-tst-chk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error |
118 | CFLAGS-tst-chk2.c += -Wno-format -Wno-deprecated-declarations -Wno-error | |
119 | CFLAGS-tst-chk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error | |
120 | CFLAGS-tst-chk4.cc += -Wno-format -Wno-deprecated-declarations -Wno-error | |
121 | CFLAGS-tst-chk5.cc += -Wno-format -Wno-deprecated-declarations -Wno-error | |
122 | CFLAGS-tst-chk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error | |
123 | CFLAGS-tst-lfschk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error | |
124 | CFLAGS-tst-lfschk2.c += -Wno-format -Wno-deprecated-declarations -Wno-error | |
125 | CFLAGS-tst-lfschk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error | |
126 | CFLAGS-tst-lfschk4.cc += -Wno-format -Wno-deprecated-declarations -Wno-error | |
127 | CFLAGS-tst-lfschk5.cc += -Wno-format -Wno-deprecated-declarations -Wno-error | |
128 | CFLAGS-tst-lfschk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error | |
5ca78dd0 L |
129 | LDLIBS-tst-chk4 = -lstdc++ |
130 | LDLIBS-tst-chk5 = -lstdc++ | |
131 | LDLIBS-tst-chk6 = -lstdc++ | |
132 | LDLIBS-tst-lfschk4 = -lstdc++ | |
133 | LDLIBS-tst-lfschk5 = -lstdc++ | |
134 | LDLIBS-tst-lfschk6 = -lstdc++ | |
5852d1e5 | 135 | |
31d470ac JM |
136 | # backtrace_symbols only works if we link with -rdynamic. backtrace |
137 | # requires unwind tables on most architectures. | |
138 | CFLAGS-tst-backtrace2.c += -funwind-tables | |
139 | CFLAGS-tst-backtrace3.c += -funwind-tables | |
140 | CFLAGS-tst-backtrace4.c += -funwind-tables | |
141 | CFLAGS-tst-backtrace5.c += -funwind-tables | |
d400dcac | 142 | CFLAGS-tst-backtrace6.c += -funwind-tables |
31d470ac JM |
143 | LDFLAGS-tst-backtrace2 = -rdynamic |
144 | LDFLAGS-tst-backtrace3 = -rdynamic | |
145 | LDFLAGS-tst-backtrace4 = -rdynamic | |
146 | LDFLAGS-tst-backtrace5 = -rdynamic | |
d400dcac | 147 | LDFLAGS-tst-backtrace6 = -rdynamic |
31d470ac | 148 | |
36975e8e | 149 | CFLAGS-tst-ssp-1.c += -fstack-protector-all |
ed421fca | 150 | |
b50f8e42 | 151 | tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \ |
de1c3ebb | 152 | tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \ |
44a6213c | 153 | tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6 \ |
31d470ac | 154 | tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 tst-backtrace4 \ |
d400dcac | 155 | tst-backtrace5 tst-backtrace6 |
2de7874e | 156 | |
ed421fca L |
157 | ifeq ($(have-ssp),yes) |
158 | tests += tst-ssp-1 | |
159 | endif | |
160 | ||
44a6213c RM |
161 | ifeq (,$(CXX)) |
162 | tests-unsupported = tst-chk4 tst-chk5 tst-chk6 \ | |
163 | tst-lfschk4 tst-lfschk5 tst-lfschk6 | |
e4693aa7 RM |
164 | endif |
165 | ||
87843f15 | 166 | extra-libs = libSegFault libpcprofile |
107f8131 UD |
167 | extra-libs-others = $(extra-libs) |
168 | ||
169 | libSegFault-routines = segfault | |
170 | libSegFault-inhibit-o = $(filter-out .os,$(object-suffixes)) | |
171 | ||
87843f15 UD |
172 | libpcprofile-routines = pcprofile |
173 | libpcprofile-inhibit-o = $(filter-out .os,$(object-suffixes)) | |
174 | ||
08920a50 | 175 | others = pcprofiledump |
6c3ebebd UD |
176 | install-bin = pcprofiledump |
177 | install-bin-script = xtrace | |
cab30d75 | 178 | |
bfe1b528 | 179 | ifeq ($(build-shared),yes) |
6c3ebebd | 180 | install-bin-script += catchsegv |
ce85d65b | 181 | endif |
f08e9a26 | 182 | generated += catchsegv xtrace |
6ce7ab19 | 183 | |
2de7874e | 184 | include ../Rules |
107f8131 | 185 | |
f881f6ff AS |
186 | ifeq ($(run-built-tests),yes) |
187 | LOCALES := de_DE.UTF-8 | |
188 | include ../gen-locales.mk | |
189 | ||
190 | $(objpfx)tst-chk1.out: $(gen-locales) | |
191 | endif | |
192 | ||
f50fa10c UD |
193 | sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,') |
194 | ||
6ce7ab19 UD |
195 | $(objpfx)catchsegv: catchsegv.sh $(common-objpfx)soversions.mk \ |
196 | $(common-objpfx)config.make | |
0325dd20 | 197 | slibpfx=`echo $(slibdir)|sed 's/lib\(64\|\)$$/\\\\\\\\$$LIB/'`; \ |
8b748aed JM |
198 | sed -e 's|@VERSION@|$(version)|' -e "s|@SLIB@|$$slibpfx|" \ |
199 | -e 's|@PKGVERSION@|$(PKGVERSION)|' \ | |
200 | -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $< > $@.new | |
6ce7ab19 UD |
201 | chmod 555 $@.new |
202 | mv -f $@.new $@ | |
203 | ||
cab30d75 | 204 | $(objpfx)pcprofiledump: $(objpfx)pcprofiledump.o |
cab30d75 UD |
205 | |
206 | $(objpfx)xtrace: xtrace.sh | |
207 | rm -f $@.new | |
208 | sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \ | |
8b748aed JM |
209 | -e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' \ |
210 | -e 's|@PKGVERSION@|$(PKGVERSION)|' \ | |
211 | -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \ | |
cab30d75 | 212 | && rm -f $@ && mv $@.new $@ && chmod +x $@ |