1ifeq ($(subdir),csu)
2gen-as-const-headers += cpu-features-offsets.sym
3endif
4
5ifeq ($(subdir),elf)
6sysdep_routines += get-cpuid-feature-leaf
7sysdep-dl-routines += dl-get-cpu-features
8sysdep_headers += sys/platform/x86.h bits/platform/x86.h
9
10CFLAGS-get-cpuid-feature-leaf.o += $(no-stack-protector)
11
12tests += tst-get-cpu-features tst-get-cpu-features-static \
13	 tst-cpu-features-cpuinfo tst-cpu-features-cpuinfo-static \
14	 tst-cpu-features-supports tst-cpu-features-supports-static
15tests-static += tst-get-cpu-features-static \
16		tst-cpu-features-cpuinfo-static \
17		tst-cpu-features-supports-static
18ifeq (yes,$(have-ifunc))
19ifeq (yes,$(have-gcc-ifunc))
20tests += \
21  tst-ifunc-isa-1 \
22  tst-ifunc-isa-1-static
23tests-static += \
24  tst-ifunc-isa-1-static
25test-xfail-tst-ifunc-isa-1 = $(with-lld)
26test-xfail-tst-ifunc-isa-1-static = $(with-lld)
27ifneq ($(have-tunables),no)
28tests += \
29  tst-ifunc-isa-2 \
30  tst-ifunc-isa-2-static
31tests-static += \
32  tst-ifunc-isa-2-static
33test-xfail-tst-ifunc-isa-2 = $(with-lld)
34test-xfail-tst-ifunc-isa-2-static = $(with-lld)
35endif
36endif
37endif
38ifeq (yes,$(enable-x86-isa-level))
39tests += tst-isa-level-1
40modules-names += tst-isa-level-mod-1-baseline \
41		 tst-isa-level-mod-1-v2 \
42		 tst-isa-level-mod-1-v3 \
43		 tst-isa-level-mod-1-v4 \
44
45# X86 ISA level baseline
46CFLAGS-tst-isa-level-mod-1-baseline.c += -DINCLUDE_X86_ISA_LEVEL \
47					 -DISA_LEVEL=0x1 \
48					 -march=x86-64
49# X86 ISA level v2
50CFLAGS-tst-isa-level-mod-1-v2.c += -DINCLUDE_X86_ISA_LEVEL \
51				   -DISA_LEVEL=0x3 \
52				   -march=x86-64
53# X86 ISA level v3
54CFLAGS-tst-isa-level-mod-1-v3.c += -DINCLUDE_X86_ISA_LEVEL \
55				   -DISA_LEVEL=0x7 \
56				   -march=x86-64
57# X86 ISA level v4
58CFLAGS-tst-isa-level-mod-1-v4.c += -DINCLUDE_X86_ISA_LEVEL \
59				   -DISA_LEVEL=0xf \
60				   -march=x86-64
61
62$(objpfx)tst-isa-level-1.out: $(objpfx)tst-isa-level-mod-1-baseline.so \
63			      $(objpfx)tst-isa-level-mod-1-v2.so \
64			      $(objpfx)tst-isa-level-mod-1-v3.so \
65			      $(objpfx)tst-isa-level-mod-1-v4.so
66endif
67ifneq ($(have-tunables),no)
68tst-ifunc-isa-2-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-SSE4_2,-AVX,-AVX2,-AVX512F
69tst-ifunc-isa-2-static-ENV = $(tst-ifunc-isa-2-ENV)
70endif
71endif
72
73ifeq ($(subdir),math)
74tests += tst-ldbl-nonnormal-printf
75endif # $(subdir) == math
76
77ifeq ($(subdir),setjmp)
78gen-as-const-headers += jmp_buf-ssp.sym
79sysdep_routines += __longjmp_cancel
80ifneq ($(enable-cet),no)
81ifneq ($(have-tunables),no)
82tests += tst-setjmp-cet
83tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on
84endif
85endif
86endif
87
88ifeq ($(subdir),string)
89sysdep_routines += cacheinfo
90
91tests += \
92  tst-memchr-rtm \
93  tst-memcmp-rtm \
94  tst-memmove-rtm \
95  tst-memrchr-rtm \
96  tst-memset-rtm \
97  tst-strchr-rtm \
98  tst-strcpy-rtm \
99  tst-strlen-rtm \
100  tst-strncmp-rtm \
101  tst-strrchr-rtm
102
103CFLAGS-tst-memchr-rtm.c += -mrtm
104CFLAGS-tst-memcmp-rtm.c += -mrtm
105CFLAGS-tst-memmove-rtm.c += -mrtm
106CFLAGS-tst-memrchr-rtm.c += -mrtm
107CFLAGS-tst-memset-rtm.c += -mrtm
108CFLAGS-tst-strchr-rtm.c += -mrtm
109CFLAGS-tst-strcpy-rtm.c += -mrtm
110CFLAGS-tst-strlen-rtm.c += -mrtm
111CFLAGS-tst-strncmp-rtm.c += -mrtm
112CFLAGS-tst-strrchr-rtm.c += -mrtm
113endif
114
115ifneq ($(enable-cet),no)
116ifeq ($(subdir),elf)
117sysdep-dl-routines += dl-cet
118
119tests += tst-cet-legacy-1 tst-cet-legacy-1a tst-cet-legacy-2 \
120	 tst-cet-legacy-2a tst-cet-legacy-3 tst-cet-legacy-4 \
121	 tst-cet-legacy-5a tst-cet-legacy-6a tst-cet-legacy-7 \
122	 tst-cet-legacy-8 tst-cet-legacy-9 tst-cet-legacy-9-static \
123	 tst-cet-legacy-10 tst-cet-legacy-10-static
124tests-static += tst-cet-legacy-9-static tst-cet-legacy-10-static
125tst-cet-legacy-1a-ARGS = -- $(host-test-program-cmd)
126ifneq (no,$(have-tunables))
127tests += tst-cet-legacy-4a tst-cet-legacy-4b tst-cet-legacy-4c \
128	 tst-cet-legacy-5b tst-cet-legacy-6b
129endif
130modules-names += tst-cet-legacy-mod-1 tst-cet-legacy-mod-2 \
131		 tst-cet-legacy-mod-4 tst-cet-legacy-mod-5a \
132		 tst-cet-legacy-mod-5b tst-cet-legacy-mod-5c \
133		 tst-cet-legacy-mod-6a tst-cet-legacy-mod-6b \
134		 tst-cet-legacy-mod-6c
135
136CFLAGS-tst-cet-legacy-2.c += -fcf-protection=branch
137CFLAGS-tst-cet-legacy-2a.c += -fcf-protection
138CFLAGS-tst-cet-legacy-mod-1.c += -fcf-protection=none
139CFLAGS-tst-cet-legacy-mod-2.c += -fcf-protection=none
140CFLAGS-tst-cet-legacy-3.c += -fcf-protection=none
141CFLAGS-tst-cet-legacy-4.c += -fcf-protection=branch
142CFLAGS-tst-cet-legacy-4a.c += -fcf-protection
143CFLAGS-tst-cet-legacy-4b.c += -fcf-protection
144CFLAGS-tst-cet-legacy-mod-4.c += -fcf-protection=none
145CFLAGS-tst-cet-legacy-5a.c += -fcf-protection -mshstk
146ifeq ($(enable-cet),permissive)
147CPPFLAGS-tst-cet-legacy-5a.c += -DCET_IS_PERMISSIVE=1
148endif
149CFLAGS-tst-cet-legacy-5b.c += -fcf-protection -mshstk
150CPPFLAGS-tst-cet-legacy-5b.c += -DCET_DISABLED_BY_ENV=1
151CFLAGS-tst-cet-legacy-mod-5a.c += -fcf-protection=branch
152CFLAGS-tst-cet-legacy-mod-5b.c += -fcf-protection
153CFLAGS-tst-cet-legacy-mod-5c.c += -fcf-protection
154CFLAGS-tst-cet-legacy-6a.c += -fcf-protection -mshstk
155ifeq ($(enable-cet),permissive)
156CPPFLAGS-tst-cet-legacy-6a.c += -DCET_IS_PERMISSIVE=1
157endif
158CFLAGS-tst-cet-legacy-6b.c += -fcf-protection -mshstk
159CPPFLAGS-tst-cet-legacy-6b.c += -DCET_DISABLED_BY_ENV=1
160CFLAGS-tst-cet-legacy-mod-6a.c += -fcf-protection=branch
161CFLAGS-tst-cet-legacy-mod-6b.c += -fcf-protection
162CFLAGS-tst-cet-legacy-mod-6c.c += -fcf-protection
163CFLAGS-tst-cet-legacy-7.c += -fcf-protection=none
164CFLAGS-tst-cet-legacy-8.c += -mshstk
165CFLAGS-tst-cet-legacy-10.c += -mshstk
166CFLAGS-tst-cet-legacy-10-static.c += -mshstk
167
168$(objpfx)tst-cet-legacy-1: $(objpfx)tst-cet-legacy-mod-1.so \
169		       $(objpfx)tst-cet-legacy-mod-2.so
170$(objpfx)tst-cet-legacy-1a: $(objpfx)tst-cet-legacy-mod-1.so \
171		       $(objpfx)tst-cet-legacy-mod-2.so
172$(objpfx)tst-cet-legacy-2: $(objpfx)tst-cet-legacy-mod-2.so
173$(objpfx)tst-cet-legacy-2.out: $(objpfx)tst-cet-legacy-mod-1.so
174$(objpfx)tst-cet-legacy-2a: $(objpfx)tst-cet-legacy-mod-2.so
175$(objpfx)tst-cet-legacy-2a.out: $(objpfx)tst-cet-legacy-mod-1.so
176$(objpfx)tst-cet-legacy-4.out: $(objpfx)tst-cet-legacy-mod-4.so
177$(objpfx)tst-cet-legacy-5a.out: $(objpfx)tst-cet-legacy-mod-5a.so \
178				$(objpfx)tst-cet-legacy-mod-5b.so
179$(objpfx)tst-cet-legacy-mod-5a.so: $(objpfx)tst-cet-legacy-mod-5c.so
180$(objpfx)tst-cet-legacy-mod-5b.so: $(objpfx)tst-cet-legacy-mod-5c.so
181$(objpfx)tst-cet-legacy-6a.out: $(objpfx)tst-cet-legacy-mod-6a.so \
182				$(objpfx)tst-cet-legacy-mod-6b.so
183$(objpfx)tst-cet-legacy-mod-6a.so: $(objpfx)tst-cet-legacy-mod-6c.so
184$(objpfx)tst-cet-legacy-mod-6b.so: $(objpfx)tst-cet-legacy-mod-6c.so
185LDFLAGS-tst-cet-legacy-mod-6c.so = -Wl,--enable-new-dtags,-z,nodelete
186ifneq (no,$(have-tunables))
187$(objpfx)tst-cet-legacy-4a.out: $(objpfx)tst-cet-legacy-mod-4.so
188tst-cet-legacy-4a-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=permissive
189$(objpfx)tst-cet-legacy-4b.out: $(objpfx)tst-cet-legacy-mod-4.so
190tst-cet-legacy-4b-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=on
191$(objpfx)tst-cet-legacy-4c.out: $(objpfx)tst-cet-legacy-mod-4.so
192tst-cet-legacy-4c-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=off
193$(objpfx)tst-cet-legacy-5b.out: $(objpfx)tst-cet-legacy-mod-5a.so \
194				$(objpfx)tst-cet-legacy-mod-5b.so
195tst-cet-legacy-5b-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
196$(objpfx)tst-cet-legacy-6b.out: $(objpfx)tst-cet-legacy-mod-6a.so \
197				$(objpfx)tst-cet-legacy-mod-6b.so
198tst-cet-legacy-6b-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
199tst-cet-legacy-9-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
200tst-cet-legacy-9-static-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
201endif
202endif
203
204# Add -fcf-protection to CFLAGS when CET is enabled.
205CFLAGS-.o += -fcf-protection
206CFLAGS-.os += -fcf-protection
207CFLAGS-.op += -fcf-protection
208CFLAGS-.oS += -fcf-protection
209
210# Compile assembly codes with <cet.h> when CET is enabled.
211asm-CPPFLAGS += -fcf-protection -include cet.h
212
213ifeq ($(subdir),elf)
214ifeq (yes,$(build-shared))
215tests-special += $(objpfx)check-cet.out
216endif
217
218# FIXME: Can't use all-built-dso in elf/Makefile since this file is
219# processed before elf/Makefile.  Duplicate it here.
220cet-built-dso := $(common-objpfx)elf/ld.so $(common-objpfx)libc.so \
221		 $(filter-out $(common-objpfx)linkobj/libc.so, \
222			      $(sort $(wildcard $(addprefix $(common-objpfx), \
223							    */lib*.so \
224							    iconvdata/*.so))))
225
226$(cet-built-dso:=.note): %.note: %
227	@rm -f $@T
228	LC_ALL=C $(READELF) -n $< > $@T
229	test -s $@T
230	mv -f $@T $@
231common-generated += $(cet-built-dso:$(common-objpfx)%=%.note)
232
233$(objpfx)check-cet.out: $(..)sysdeps/x86/check-cet.awk \
234			$(cet-built-dso:=.note)
235	LC_ALL=C $(AWK) -f $^ > $@; \
236	$(evaluate-test)
237generated += check-cet.out
238endif
239endif
240
241ifeq ($(subdir),posix)
242tests += \
243  tst-sysconf-cache-linesize \
244  tst-sysconf-cache-linesize-static
245tests-static += \
246  tst-sysconf-cache-linesize-static
247endif
248