elf: Add ELF_DYNAMIC_AFTER_RELOC to rewrite PLT
[platform/upstream/glibc.git] / sysdeps / x86_64 / Makefile
1 # The i387 `long double' is a distinct type we support.
2 long-double-fcts = yes
3
4 ifeq (yes,$(have-z-mark-plt))
5 # Always generate DT_X86_64_PLT* tags.
6 sysdep-LDFLAGS += -Wl,-z,mark-plt
7 # Never generate DT_X86_64_PLT* tags on ld.so to avoid changing its own
8 # PLT.
9 LDFLAGS-rtld += -Wl,-z,nomark-plt
10 endif
11
12 ifeq ($(subdir),csu)
13 gen-as-const-headers += link-defines.sym
14 endif
15
16 ifeq ($(subdir),gmon)
17 sysdep_routines += _mcount
18 # We cannot compile _mcount.S with -pg because that would create
19 # recursive calls when ENTRY is used.  Just copy the normal static
20 # object.
21 sysdep_noprof += _mcount
22 endif
23
24 ifeq ($(subdir),string)
25 sysdep_routines += \
26   strcasecmp_l-nonascii \
27   strcspn-generic \
28   strncase_l-nonascii \
29   strpbrk-generic \
30   strspn-generic \
31   varshift \
32 # sysdep_routines
33 gen-as-const-headers += locale-defines.sym
34 tests += \
35   tst-rsi-strlen
36 endif
37
38 ifeq ($(subdir),elf)
39 # There is no good reason to use MMX in x86-64 ld.so with GCC.
40 CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
41                    -mno-mmx)
42
43 sysdep-dl-routines += tlsdesc dl-tlsdesc tls_get_addr
44
45 tests += ifuncmain8
46 modules-names += ifuncmod8
47
48 $(objpfx)ifuncmain8: $(objpfx)ifuncmod8.so
49
50 tests += tst-quad1 tst-quad2
51 modules-names += tst-quadmod1 tst-quadmod2
52
53 $(objpfx)tst-quad1: $(objpfx)tst-quadmod1.so
54 $(objpfx)tst-quad2: $(objpfx)tst-quadmod2.so
55
56 quad-pie-test += tst-quad1pie tst-quad2pie
57 tests += $(quad-pie-test)
58 tests-pie += $(quad-pie-test)
59 test-extras += tst-quadmod1pie tst-quadmod2pie
60 extra-test-objs += tst-quadmod1pie.o tst-quadmod2pie.o
61
62 $(objpfx)tst-quad1pie: $(objpfx)tst-quadmod1pie.o
63 $(objpfx)tst-quad2pie: $(objpfx)tst-quadmod2pie.o
64
65 CFLAGS-tst-quad1pie.c = $(PIE-ccflag)
66 CFLAGS-tst-quad2pie.c = $(PIE-ccflag)
67
68 tests += tst-platform-1
69 modules-names += tst-platformmod-1 x86_64/tst-platformmod-2
70 extra-test-objs += tst-platformmod-2.o
71 CFLAGS-tst-platform-1.c = -mno-avx
72 CFLAGS-tst-platformmod-1.c = -mno-avx
73 CFLAGS-tst-platformmod-2.c = -mno-avx
74 LDFLAGS-tst-platformmod-2.so = -Wl,-soname,tst-platformmod-2.so
75 $(objpfx)tst-platform-1: $(objpfx)tst-platformmod-1.so
76 $(objpfx)tst-platform-1.out: $(objpfx)x86_64/tst-platformmod-2.so
77 # Turn off AVX512F and AVX2 so that GLRO(dl_platform) is
78 # always set to x86_64.
79 tst-platform-1-ENV = LD_PRELOAD=$(objpfx)\$$PLATFORM/tst-platformmod-2.so \
80         GLIBC_TUNABLES=glibc.cpu.hwcaps=-AVX512F,-AVX2
81
82 tests += tst-audit3 tst-audit4 tst-audit5 tst-audit6 tst-audit7 \
83          tst-audit10 tst-sse tst-avx tst-avx512
84 test-extras += tst-audit4-aux tst-audit10-aux \
85                tst-avx-aux tst-avx512-aux
86 extra-test-objs += tst-audit4-aux.o tst-audit10-aux.o \
87                    tst-avx-aux.o tst-avx512-aux.o
88
89 ifeq ($(have-insert),yes)
90 tests += tst-split-dynreloc
91 LDFLAGS-tst-split-dynreloc = -Wl,-T,$(..)sysdeps/x86_64/tst-split-dynreloc.lds
92 tst-split-dynreloc-ENV = LD_BIND_NOW=1
93 endif
94
95 modules-names += tst-auditmod3a tst-auditmod3b \
96                 tst-auditmod4a tst-auditmod4b \
97                 tst-auditmod5a tst-auditmod5b \
98                 tst-auditmod6a tst-auditmod6b tst-auditmod6c \
99                 tst-auditmod7a tst-auditmod7b \
100                 tst-auditmod10a tst-auditmod10b \
101                 tst-ssemod tst-avxmod tst-avx512mod
102
103 $(objpfx)tst-audit3: $(objpfx)tst-auditmod3a.so
104 $(objpfx)tst-audit3.out: $(objpfx)tst-auditmod3b.so
105 tst-audit3-ENV = LD_AUDIT=$(objpfx)tst-auditmod3b.so
106
107 $(objpfx)tst-audit4: $(objpfx)tst-audit4-aux.o $(objpfx)tst-auditmod4a.so
108 $(objpfx)tst-audit4.out: $(objpfx)tst-auditmod4b.so
109 tst-audit4-ENV = LD_AUDIT=$(objpfx)tst-auditmod4b.so
110
111 $(objpfx)tst-audit5: $(objpfx)tst-auditmod5a.so
112 $(objpfx)tst-audit5.out: $(objpfx)tst-auditmod5b.so
113 tst-audit5-ENV = LD_AUDIT=$(objpfx)tst-auditmod5b.so
114
115 $(objpfx)tst-audit6: $(objpfx)tst-auditmod6a.so
116 $(objpfx)tst-audit6.out: $(objpfx)tst-auditmod6b.so \
117                          $(objpfx)tst-auditmod6c.so
118 tst-audit6-ENV = LD_AUDIT=$(objpfx)tst-auditmod6b.so:$(objpfx)tst-auditmod6c.so
119
120 $(objpfx)tst-audit7: $(objpfx)tst-auditmod7a.so
121 $(objpfx)tst-audit7.out: $(objpfx)tst-auditmod7b.so
122 tst-audit7-ENV = LD_AUDIT=$(objpfx)tst-auditmod7b.so
123
124 $(objpfx)tst-audit10: $(objpfx)tst-audit10-aux.o $(objpfx)tst-auditmod10a.so
125 $(objpfx)tst-audit10.out: $(objpfx)tst-auditmod10b.so
126 tst-audit10-ENV = LD_AUDIT=$(objpfx)tst-auditmod10b.so
127
128 $(objpfx)tst-sse: $(objpfx)tst-ssemod.so
129 $(objpfx)tst-avx: $(objpfx)tst-avx-aux.o $(objpfx)tst-avxmod.so
130 $(objpfx)tst-avx512: $(objpfx)tst-avx512-aux.o $(objpfx)tst-avx512mod.so
131
132 AVX-CFLAGS=-mavx -mno-vzeroupper
133 CFLAGS-tst-audit4-aux.c += $(AVX-CFLAGS)
134 CFLAGS-tst-auditmod4a.c += $(AVX-CFLAGS)
135 CFLAGS-tst-auditmod4b.c += $(AVX-CFLAGS)
136 CFLAGS-tst-auditmod6b.c += $(AVX-CFLAGS)
137 CFLAGS-tst-auditmod6c.c += $(AVX-CFLAGS)
138 CFLAGS-tst-auditmod7b.c += $(AVX-CFLAGS)
139 CFLAGS-tst-avx-aux.c += $(AVX-CFLAGS)
140 CFLAGS-tst-avxmod.c += $(AVX-CFLAGS)
141 AVX512-CFLAGS = -mavx512f
142 CFLAGS-tst-audit10-aux.c += $(AVX512-CFLAGS)
143 CFLAGS-tst-auditmod10a.c += $(AVX512-CFLAGS)
144 CFLAGS-tst-auditmod10b.c += $(AVX512-CFLAGS)
145 CFLAGS-tst-avx512-aux.c += $(AVX512-CFLAGS)
146 CFLAGS-tst-avx512mod.c += $(AVX512-CFLAGS)
147
148 $(objpfx)tst-glibc-hwcaps: $(objpfx)libmarkermod2-1.so \
149   $(objpfx)libmarkermod3-1.so $(objpfx)libmarkermod4-1.so
150 $(objpfx)tst-glibc-hwcaps.out: \
151   $(objpfx)libmarkermod2.so \
152     $(objpfx)glibc-hwcaps/x86-64-v2/libmarkermod2.so \
153   $(objpfx)libmarkermod3.so \
154     $(objpfx)glibc-hwcaps/x86-64-v2/libmarkermod3.so \
155     $(objpfx)glibc-hwcaps/x86-64-v3/libmarkermod3.so \
156   $(objpfx)libmarkermod4.so \
157     $(objpfx)glibc-hwcaps/x86-64-v2/libmarkermod4.so \
158     $(objpfx)glibc-hwcaps/x86-64-v3/libmarkermod4.so \
159     $(objpfx)glibc-hwcaps/x86-64-v4/libmarkermod4.so \
160
161 $(objpfx)glibc-hwcaps/x86-64-v2/libmarkermod2.so: $(objpfx)libmarkermod2-2.so
162         $(make-target-directory)
163         cp $< $@
164 $(objpfx)glibc-hwcaps/x86-64-v2/libmarkermod3.so: $(objpfx)libmarkermod3-2.so
165         $(make-target-directory)
166         cp $< $@
167 $(objpfx)glibc-hwcaps/x86-64-v3/libmarkermod3.so: $(objpfx)libmarkermod3-3.so
168         $(make-target-directory)
169         cp $< $@
170 $(objpfx)glibc-hwcaps/x86-64-v2/libmarkermod4.so: $(objpfx)libmarkermod4-2.so
171         $(make-target-directory)
172         cp $< $@
173 $(objpfx)glibc-hwcaps/x86-64-v3/libmarkermod4.so: $(objpfx)libmarkermod4-3.so
174         $(make-target-directory)
175         cp $< $@
176 $(objpfx)glibc-hwcaps/x86-64-v4/libmarkermod4.so: $(objpfx)libmarkermod4-4.so
177         $(make-target-directory)
178         cp $< $@
179
180 ifeq (no,$(build-hardcoded-path-in-tests))
181 # This is an ld.so.cache test, and RPATH/RUNPATH in the executable
182 # interferes with its test objectives.
183 tests-container += tst-glibc-hwcaps-cache
184 endif
185
186 ifeq (yes,$(have-z-mark-plt))
187 tests += \
188   tst-plt-rewrite1 \
189 # tests
190 modules-names += \
191   tst-plt-rewritemod1 \
192 # modules-names
193
194 tst-plt-rewrite1-no-pie = yes
195 LDFLAGS-tst-plt-rewrite1 = -Wl,-z,now
196 LDFLAGS-tst-plt-rewritemod1.so = -Wl,-z,now
197 tst-plt-rewrite1-ENV = GLIBC_TUNABLES=glibc.cpu.plt_rewrite=1 LD_DEBUG=files:bindings
198 $(objpfx)tst-plt-rewrite1: $(objpfx)tst-plt-rewritemod1.so
199 $(objpfx)tst-plt-rewrite1.out: /dev/null $(objpfx)tst-plt-rewrite1
200         $(tst-plt-rewrite1-ENV) $(make-test-out) > $@ 2>&1; \
201         grep -q -E "changing 'bar' PLT entry in .*/elf/tst-plt-rewritemod1.so' to direct branch" $@; \
202         $(evaluate-test)
203 endif
204
205 endif # $(subdir) == elf
206
207 ifeq ($(subdir),csu)
208 gen-as-const-headers += tlsdesc.sym rtld-offsets.sym
209 endif
210
211 ifeq ($(subdir),wcsmbs)
212
213 sysdep_routines += \
214   wcpcpy-generic \
215   wcpncpy-generic \
216   wcscat-generic \
217   wcscpy-generic \
218   wcsncat-generic \
219   wcsncmp-generic \
220   wcsncpy-generic \
221   wcsnlen-generic \
222 # sysdep_routines
223
224 tests += \
225   tst-rsi-wcslen
226 endif
227
228 do-tests-clean common-mostlyclean: tst-x86_64-1-clean
229
230 .PHONY: tst-x86_64-1-clean
231 tst-x86_64-1-clean:
232         -rm -rf $(objpfx)x86_64
233
234 $(objpfx)x86_64/tst-platformmod-2.os: $(objpfx)tst-platformmod-2.os
235         $(make-target-directory)
236         rm -f $@
237         ln $< $@