PR gold/12525
[external/binutils.git] / gold / testsuite / Makefile.am
1 # Process this file with automake to generate Makefile.in
2
3 # As far as I can tell automake testing support assumes that the build
4 # system and the host system are the same.  So these tests will not
5 # work when building with a cross-compiler.
6
7 # Ignore warning about AM_PROG_CC_C_O due to large_CFLAGS
8 AUTOMAKE_OPTIONS = foreign -Wno-portability
9
10 # The two_file_test tests -fmerge-constants, so we simply always turn
11 # it on.  This may need to be controlled by a configure option
12 # eventually.
13 AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) -fmerge-constants
14 AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) -fmerge-constants
15
16 AM_CPPFLAGS = \
17         -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../include \
18         -I$(srcdir)/../../elfcpp -I.. \
19         -DLOCALEDIR="\"$(datadir)/locale\"" \
20         @INCINTL@
21
22 TEST_READELF = $(top_builddir)/../binutils/readelf
23 TEST_OBJDUMP = $(top_builddir)/../binutils/objdump
24 TEST_CXXFILT = $(top_builddir)/../binutils/cxxfilt
25 TEST_STRIP = $(top_builddir)/../binutils/strip-new
26 TEST_AR = $(top_builddir)/../binutils/ar
27 TEST_NM = $(top_builddir)/../binutils/nm-new
28 TEST_AS = $(top_builddir)/../gas/as-new
29
30 if PLUGINS
31 LIBDL = -ldl
32 endif
33
34 if THREADS
35 THREADSLIB = -lpthread
36 endif
37
38 if OMP_SUPPORT
39 TLS_TEST_C_CFLAGS = -fopenmp
40 endif
41
42 # 'make clean' is good about deleting some intermediate files (such as
43 # .o's), but not all of them (such as .so's and .err files).  We
44 # improve on that here.  automake-1.9 info docs say "mostlyclean" is
45 # the right choice for files 'make' builds that people rebuild.
46 MOSTLYCLEANFILES = *.so *.syms *.stdout
47
48
49 # We will add to these later, for each individual test.  Note
50 # that we add each test under check_SCRIPTS or check_PROGRAMS;
51 # the TESTS variable is automatically populated from these.
52 check_SCRIPTS =
53 check_DATA =
54 check_PROGRAMS =
55 BUILT_SOURCES =
56
57 TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
58
59 # ---------------------------------------------------------------------
60 # These tests test the internals of gold (unittests).
61
62 # Infrastucture needed for the unittests
63 check_LIBRARIES = libgoldtest.a
64 libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc
65
66 DEPENDENCIES = \
67         libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL_DEP)
68 LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \
69         $(THREADSLIB) $(LIBDL)
70
71
72 # The unittests themselves
73 if NATIVE_OR_CROSS_LINKER
74 if GCC
75
76 # Infrastucture needed for the unittests: a directory where the linker
77 # is named 'ld'.  This is because the -B flag appends 'ld' to its arg.
78 gcctestdir/ld: ../ld-new
79         test -d gcctestdir || mkdir -p gcctestdir
80         rm -f gcctestdir/ld
81         (cd gcctestdir && $(LN_S) ../../ld-new ld)
82
83 # Some tests require the latest features of an in-tree assembler.
84 gcctestdir/as: $(TEST_AS)
85         test -d gcctestdir || mkdir -p gcctestdir
86         rm -f gcctestdir/as
87         (cd gcctestdir && $(LN_S) $(abs_top_builddir)/../gas/as-new as)
88
89 endif GCC
90
91 check_PROGRAMS += object_unittest
92 object_unittest_SOURCES = object_unittest.cc
93
94 check_PROGRAMS += binary_unittest
95 binary_unittest_SOURCES = binary_unittest.cc
96
97 endif NATIVE_OR_CROSS_LINKER
98
99 # ---------------------------------------------------------------------
100 # These tests test the output of gold (end-to-end tests).  In
101 # particular, they make sure that gold can link "difficult" object
102 # files, and the resulting object files run correctly.  These can only
103 # run if we've built ld-new for the native architecture (that is,
104 # we're not cross-compiling it), since we run ld-new as part of these
105 # tests.  We use the gcc-specific flag '-B' to use our linker instead
106 # of the default linker, which is why we only run our tests under gcc.
107
108 if NATIVE_LINKER
109 if GCC
110
111 # Each of these .o's is a useful, small complete program.  They're
112 # particularly useful for making sure ld-new's flags do what they're
113 # supposed to (hence their names), but are used for many tests that
114 # don't actually involve analyzing input data.
115 flagstest_debug.o: constructor_test.cc
116         $(CXXCOMPILE) -O0 -g -c -o $@ $<
117 flagstest_ndebug.o: constructor_test.cc
118         $(CXXCOMPILE) -O0 -c -o $@ $<
119
120 check_SCRIPTS += incremental_test.sh
121 check_DATA += incremental_test.stdout
122 MOSTLYCLEANFILES += incremental_test
123 incremental_test_1.o: incremental_test_1.c
124         $(COMPILE) -O0 -c -ffunction-sections -g -o $@ $<
125 incremental_test_2.o: incremental_test_2.c
126         $(COMPILE) -O0 -c -ffunction-sections -g -o $@ $<
127 incremental_test: incremental_test_1.o incremental_test_2.o gcctestdir/ld
128         $(LINK) -Bgcctestdir/ -Wl,--incremental-full incremental_test_1.o incremental_test_2.o -Wl,-debug 2> incremental_test.cmdline
129 incremental_test.stdout: incremental_test ../incremental-dump
130         ../incremental-dump incremental_test > $@
131
132 check_SCRIPTS += gc_comdat_test.sh
133 check_DATA += gc_comdat_test.stdout
134 MOSTLYCLEANFILES += gc_comdat_test
135 gc_comdat_test_1.o: gc_comdat_test_1.cc 
136         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
137 gc_comdat_test_2.o: gc_comdat_test_2.cc 
138         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
139 gc_comdat_test: gc_comdat_test_1.o gc_comdat_test_2.o gcctestdir/ld
140         $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_comdat_test_1.o gc_comdat_test_2.o
141 gc_comdat_test.stdout: gc_comdat_test
142         $(TEST_NM) -C gc_comdat_test > gc_comdat_test.stdout
143
144 check_SCRIPTS += gc_tls_test.sh
145 check_DATA += gc_tls_test.stdout
146 MOSTLYCLEANFILES += gc_tls_test
147 gc_tls_test.o: gc_tls_test.cc
148         $(CXXCOMPILE) -O0 -c -g -o $@ $<
149 gc_tls_test:gc_tls_test.o gcctestdir/ld
150         $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_tls_test.o
151 gc_tls_test.stdout: gc_tls_test
152         $(TEST_NM) -C gc_tls_test > gc_tls_test.stdout
153
154 check_SCRIPTS += gc_orphan_section_test.sh
155 check_DATA += gc_orphan_section_test.stdout
156 MOSTLYCLEANFILES += gc_orphan_section_test
157 gc_orphan_section_test.o: gc_orphan_section_test.cc
158         $(CXXCOMPILE) -O0 -c -g -o $@ $<
159 gc_orphan_section_test:gc_orphan_section_test.o gcctestdir/ld
160         $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_orphan_section_test.o
161 gc_orphan_section_test.stdout: gc_orphan_section_test
162         $(TEST_NM) gc_orphan_section_test > gc_orphan_section_test.stdout
163
164 check_SCRIPTS += icf_test.sh
165 check_DATA += icf_test.stdout
166 MOSTLYCLEANFILES += icf_test
167 icf_test.o: icf_test.cc 
168         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
169 icf_test: icf_test.o gcctestdir/ld
170         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_test.o
171 icf_test.stdout: icf_test
172         $(TEST_NM) -C icf_test > icf_test.stdout
173
174 check_SCRIPTS += icf_keep_unique_test.sh
175 check_DATA += icf_keep_unique_test.stdout
176 MOSTLYCLEANFILES += icf_keep_unique_test
177 icf_keep_unique_test.o: icf_keep_unique_test.cc
178         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
179 icf_keep_unique_test: icf_keep_unique_test.o gcctestdir/ld
180         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all -Wl,--keep-unique,_Z11unique_funcv icf_keep_unique_test.o
181 icf_keep_unique_test.stdout: icf_keep_unique_test
182         $(TEST_NM) -C icf_keep_unique_test > icf_keep_unique_test.stdout
183
184 check_SCRIPTS += icf_safe_test.sh
185 check_DATA += icf_safe_test_1.stdout icf_safe_test_2.stdout
186 MOSTLYCLEANFILES += icf_safe_test
187 icf_safe_test.o: icf_safe_test.cc
188         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
189 icf_safe_test: icf_safe_test.o gcctestdir/ld
190         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=safe icf_safe_test.o
191 icf_safe_test_1.stdout: icf_safe_test
192         $(TEST_NM) icf_safe_test > icf_safe_test_1.stdout
193 icf_safe_test_2.stdout: icf_safe_test
194         $(TEST_READELF) -h icf_safe_test > icf_safe_test_2.stdout
195
196 check_SCRIPTS += icf_safe_so_test.sh
197 check_DATA += icf_safe_so_test_1.stdout icf_safe_so_test_2.stdout
198 MOSTLYCLEANFILES += icf_safe_so_test
199 icf_safe_so_test.o: icf_safe_so_test.cc
200         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
201 icf_safe_so_test: icf_safe_so_test.o gcctestdir/ld
202         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=safe icf_safe_so_test.o -fPIC -shared
203 icf_safe_so_test_1.stdout: icf_safe_so_test
204         $(TEST_NM) icf_safe_so_test > icf_safe_so_test_1.stdout
205 icf_safe_so_test_2.stdout: icf_safe_so_test
206         $(TEST_READELF) -h icf_safe_so_test > icf_safe_so_test_2.stdout
207
208 check_SCRIPTS += final_layout.sh
209 check_DATA += final_layout.stdout
210 MOSTLYCLEANFILES += final_layout
211 final_layout.o: final_layout.cc
212         $(CXXCOMPILE) -O0 -c -ffunction-sections  -fdata-sections -g -o $@ $<
213 final_layout_sequence.txt:
214         (echo "*_Z3barv*" && echo ".text._Z3bazv" && echo "*_Z3foov*" && echo "*global_varb*" && echo "*global_vara*" && echo "*global_varc*") > final_layout_sequence.txt
215 final_layout: final_layout.o final_layout_sequence.txt gcctestdir/ld
216         $(CXXLINK) -Bgcctestdir/ -Wl,--section-ordering-file,final_layout_sequence.txt final_layout.o
217 final_layout.stdout: final_layout
218         $(TEST_NM) -n final_layout > final_layout.stdout
219
220 check_PROGRAMS += icf_virtual_function_folding_test
221 MOSTLYCLEANFILES += icf_virtual_function_folding_test
222 icf_virtual_function_folding_test.o: icf_virtual_function_folding_test.cc
223         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIE -g -o $@ $<
224 icf_virtual_function_folding_test: icf_virtual_function_folding_test.o gcctestdir/ld
225         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_virtual_function_folding_test.o -pie
226
227 check_SCRIPTS += icf_preemptible_functions_test.sh
228 check_DATA += icf_preemptible_functions_test.stdout
229 MOSTLYCLEANFILES += icf_preemptible_functions_test
230 icf_preemptible_functions_test.o: icf_preemptible_functions_test.cc
231         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
232 icf_preemptible_functions_test: icf_preemptible_functions_test.o gcctestdir/ld
233         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_preemptible_functions_test.o -fPIC -shared
234 icf_preemptible_functions_test.stdout: icf_preemptible_functions_test
235         $(TEST_NM) icf_preemptible_functions_test > icf_preemptible_functions_test.stdout
236
237 check_SCRIPTS += icf_string_merge_test.sh
238 check_DATA += icf_string_merge_test.stdout
239 MOSTLYCLEANFILES += icf_string_merge_test
240 icf_string_merge_test.o: icf_string_merge_test.cc
241         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
242 icf_string_merge_test: icf_string_merge_test.o gcctestdir/ld
243         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_string_merge_test.o
244 icf_string_merge_test.stdout: icf_string_merge_test
245         $(TEST_NM) icf_string_merge_test > icf_string_merge_test.stdout
246
247 check_SCRIPTS += icf_sht_rel_addend_test.sh
248 check_DATA += icf_sht_rel_addend_test.stdout
249 MOSTLYCLEANFILES += icf_sht_rel_addend_test
250 icf_sht_rel_addend_test_1.o: icf_sht_rel_addend_test_1.cc
251         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
252 icf_sht_rel_addend_test_2.o: icf_sht_rel_addend_test_2.cc
253         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
254 icf_sht_rel_addend_test: icf_sht_rel_addend_test_1.o icf_sht_rel_addend_test_2.o gcctestdir/ld
255         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_sht_rel_addend_test_1.o icf_sht_rel_addend_test_2.o
256 icf_sht_rel_addend_test.stdout: icf_sht_rel_addend_test
257         $(TEST_NM) icf_sht_rel_addend_test > icf_sht_rel_addend_test.stdout
258
259 check_PROGRAMS += basic_test
260 check_PROGRAMS += basic_pic_test
261 basic_test.o: basic_test.cc
262         $(CXXCOMPILE) -O0 -c -o $@ $<
263 basic_test: basic_test.o gcctestdir/ld
264         $(CXXLINK) -Bgcctestdir/ basic_test.o
265
266 if HAVE_STATIC
267 check_PROGRAMS += basic_static_test
268 basic_static_test: basic_test.o gcctestdir/ld
269         $(CXXLINK) -Bgcctestdir/ -static basic_test.o
270 endif
271
272 basic_pic_test.o: basic_test.cc
273         $(CXXCOMPILE) -O0 -c -fpic -o $@ $<
274 basic_pic_test: basic_pic_test.o gcctestdir/ld
275         $(CXXLINK) -Bgcctestdir/ basic_pic_test.o
276
277 if HAVE_STATIC
278 check_PROGRAMS += basic_static_pic_test
279 basic_static_pic_test: basic_pic_test.o gcctestdir/ld
280         $(CXXLINK) -Bgcctestdir/ -static basic_pic_test.o
281 endif
282
283 check_PROGRAMS += basic_pie_test
284 basic_pie_test.o: basic_test.cc
285         $(CXXCOMPILE) -O0 -c -fpie -o $@ $<
286 basic_pie_test: basic_pie_test.o gcctestdir/ld
287         $(CXXLINK) -Bgcctestdir/ -pie basic_pie_test.o
288
289 check_PROGRAMS += constructor_test
290 constructor_test_SOURCES = constructor_test.cc
291 constructor_test_DEPENDENCIES = gcctestdir/ld
292 constructor_test_LDFLAGS = -Bgcctestdir/
293 constructor_test_LDADD =
294
295 if HAVE_STATIC
296 check_PROGRAMS += constructor_static_test
297 constructor_static_test_SOURCES = $(constructor_test_SOURCES)
298 constructor_static_test_DEPENDENCIES = $(constructor_test_DEPENDENCIES)
299 constructor_static_test_LDFLAGS = $(constructor_test_LDFLAGS) -static
300 constructor_static_test_LDADD = $(constructor_test_LDADD)
301 endif
302
303 check_PROGRAMS += two_file_test
304 check_PROGRAMS += two_file_pic_test
305 two_file_test_SOURCES = \
306         two_file_test_1.cc \
307         two_file_test_1b.cc \
308         two_file_test_2.cc \
309         two_file_test_main.cc \
310         two_file_test.h
311 two_file_test_DEPENDENCIES = gcctestdir/ld
312 two_file_test_LDFLAGS = -Bgcctestdir/
313 two_file_test_LDADD =
314
315 if HAVE_STATIC
316 check_PROGRAMS += two_file_static_test
317 two_file_static_test_SOURCES = $(two_file_test_SOURCES)
318 two_file_static_test_DEPENDENCIES = $(two_file_test_DEPENDENCIES)
319 two_file_static_test_LDFLAGS = $(two_file_test_LDFLAGS) -static
320 two_file_static_test_LDADD = $(two_file_test_LDADD)
321 endif
322
323 two_file_pic_test_SOURCES = two_file_test_main.cc
324 two_file_pic_test_DEPENDENCIES = \
325         gcctestdir/ld two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o
326 two_file_pic_test_LDFLAGS = -Bgcctestdir/
327 two_file_pic_test_LDADD = two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o
328
329
330 check_PROGRAMS += two_file_shared_1_test
331 check_PROGRAMS += two_file_shared_2_test
332 check_PROGRAMS += two_file_shared_1_pic_2_test
333 check_PROGRAMS += two_file_shared_2_pic_1_test
334 check_PROGRAMS += two_file_same_shared_test
335 check_PROGRAMS += two_file_separate_shared_12_test
336 check_PROGRAMS += two_file_separate_shared_21_test
337 two_file_test_1_pic.o: two_file_test_1.cc
338         $(CXXCOMPILE) -c -fpic -o $@ $<
339 two_file_test_1b_pic.o: two_file_test_1b.cc
340         $(CXXCOMPILE) -c -fpic -o $@ $<
341 two_file_test_2_pic.o: two_file_test_2.cc
342         $(CXXCOMPILE) -c -fpic -o $@ $<
343 two_file_shared_1.so: two_file_test_1_pic.o two_file_test_1b_pic.o gcctestdir/ld
344         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o
345 two_file_shared_2.so: two_file_test_2_pic.o gcctestdir/ld
346         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_2_pic.o
347 two_file_shared.so: two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o gcctestdir/ld
348         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o
349
350 two_file_shared_1_test_SOURCES = two_file_test_2.cc two_file_test_main.cc
351 two_file_shared_1_test_DEPENDENCIES = gcctestdir/ld two_file_shared_1.so
352 two_file_shared_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
353 two_file_shared_1_test_LDADD = two_file_shared_1.so
354
355 two_file_shared_2_test_SOURCES = two_file_test_1.cc two_file_test_1b.cc two_file_test_main.cc
356 two_file_shared_2_test_DEPENDENCIES = gcctestdir/ld two_file_shared_2.so
357 two_file_shared_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
358 two_file_shared_2_test_LDADD = two_file_shared_2.so
359
360 two_file_shared_1_pic_2_test_SOURCES = two_file_test_main.cc
361 two_file_shared_1_pic_2_test_DEPENDENCIES = \
362         gcctestdir/ld two_file_shared_2.so two_file_test_1_pic.o two_file_test_1b_pic.o
363 two_file_shared_1_pic_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
364 two_file_shared_1_pic_2_test_LDADD = two_file_test_1_pic.o two_file_test_1b_pic.o two_file_shared_2.so
365
366 two_file_shared_2_pic_1_test_SOURCES = two_file_test_main.cc
367 two_file_shared_2_pic_1_test_DEPENDENCIES = \
368         gcctestdir/ld two_file_shared_2.so two_file_test_2_pic.o
369 two_file_shared_2_pic_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
370 two_file_shared_2_pic_1_test_LDADD = two_file_test_2_pic.o two_file_shared_1.so
371
372 two_file_same_shared_test_SOURCES = two_file_test_main.cc
373 two_file_same_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared.so
374 two_file_same_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
375 two_file_same_shared_test_LDADD = two_file_shared.so
376
377 two_file_separate_shared_12_test_SOURCES = two_file_test_main.cc
378 two_file_separate_shared_12_test_DEPENDENCIES = \
379         gcctestdir/ld two_file_shared_1.so two_file_shared_2.so
380 two_file_separate_shared_12_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
381 two_file_separate_shared_12_test_LDADD = \
382         two_file_shared_1.so two_file_shared_2.so
383
384 two_file_separate_shared_21_test_SOURCES = two_file_test_main.cc
385 two_file_separate_shared_21_test_DEPENDENCIES = \
386         gcctestdir/ld two_file_shared_1.so two_file_shared_2.so
387 two_file_separate_shared_21_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
388 two_file_separate_shared_21_test_LDADD = \
389         two_file_shared_2.so two_file_shared_1.so
390
391 check_PROGRAMS += two_file_relocatable_test
392 two_file_relocatable_test_SOURCES = two_file_test_main.cc
393 two_file_relocatable_test_DEPENDENCIES = \
394         gcctestdir/ld two_file_relocatable.o
395 two_file_relocatable_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
396 two_file_relocatable_test_LDADD = two_file_relocatable.o
397 two_file_relocatable.o: gcctestdir/ld two_file_test_1.o two_file_test_1b.o two_file_test_2.o
398         gcctestdir/ld -r -o $@ two_file_test_1.o two_file_test_1b.o two_file_test_2.o
399
400 check_PROGRAMS += two_file_pie_test
401 two_file_test_1_pie.o: two_file_test_1.cc
402         $(CXXCOMPILE) -c -fpie -o $@ $<
403 two_file_test_1b_pie.o: two_file_test_1b.cc
404         $(CXXCOMPILE) -c -fpie -o $@ $<
405 two_file_test_2_pie.o: two_file_test_2.cc
406         $(CXXCOMPILE) -c -fpie -o $@ $<
407 two_file_test_main_pie.o: two_file_test_main.cc
408         $(CXXCOMPILE) -c -fpie -o $@ $<
409 two_file_pie_test: two_file_test_1_pie.o two_file_test_1b_pie.o \
410                 two_file_test_2_pie.o two_file_test_main_pie.o gcctestdir/ld
411         $(CXXLINK) -Bgcctestdir/ -pie two_file_test_1_pie.o two_file_test_1b_pie.o two_file_test_2_pie.o two_file_test_main_pie.o
412
413 check_SCRIPTS += two_file_shared.sh
414 check_DATA += two_file_shared.dbg
415 MOSTLYCLEANFILES += two_file_shared.dbg
416 two_file_shared.dbg: two_file_shared.so
417         $(TEST_READELF) -w $< >$@ 2>/dev/null
418
419 # The nonpic tests will fail on platforms which can not put non-PIC
420 # code into shared libraries, so we just don't run them in that case.
421 if FN_PTRS_IN_SO_WITHOUT_PIC
422
423 check_PROGRAMS += two_file_shared_1_nonpic_test
424 check_PROGRAMS += two_file_shared_2_nonpic_test
425 check_PROGRAMS += two_file_same_shared_nonpic_test
426 check_PROGRAMS += two_file_separate_shared_12_nonpic_test
427 check_PROGRAMS += two_file_separate_shared_21_nonpic_test
428 check_PROGRAMS += two_file_mixed_shared_test
429 check_PROGRAMS += two_file_mixed_2_shared_test
430 two_file_shared_1_nonpic.so: two_file_test_1.o gcctestdir/ld
431         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b.o -Wl,-z,notext
432 two_file_shared_2_nonpic.so: two_file_test_2.o gcctestdir/ld
433         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_2.o
434 two_file_shared_nonpic.so: two_file_test_1.o two_file_test_1b.o two_file_test_2.o gcctestdir/ld
435         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b.o two_file_test_2.o -Wl,-z,notext
436 two_file_shared_mixed.so: two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2.o gcctestdir/ld
437         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2.o -Wl,-z,notext
438 two_file_shared_mixed_1.so: two_file_test_1.o two_file_test_1b_pic.o two_file_shared_2.so gcctestdir/ld
439         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b_pic.o two_file_shared_2.so -Wl,-z,notext
440
441 two_file_shared_1_nonpic_test_SOURCES = \
442         two_file_test_2.cc two_file_test_main.cc
443 two_file_shared_1_nonpic_test_DEPENDENCIES = \
444         gcctestdir/ld two_file_shared_1_nonpic.so
445 two_file_shared_1_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
446 two_file_shared_1_nonpic_test_LDADD = two_file_shared_1_nonpic.so
447
448 two_file_shared_2_nonpic_test_SOURCES = \
449         two_file_test_1.cc two_file_test_1b.cc two_file_test_main.cc
450 two_file_shared_2_nonpic_test_DEPENDENCIES = \
451         gcctestdir/ld two_file_shared_2_nonpic.so
452 two_file_shared_2_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
453 two_file_shared_2_nonpic_test_LDADD = two_file_shared_2_nonpic.so
454
455 two_file_same_shared_nonpic_test_SOURCES = two_file_test_main.cc
456 two_file_same_shared_nonpic_test_DEPENDENCIES = \
457         gcctestdir/ld two_file_shared_nonpic.so
458 two_file_same_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
459 two_file_same_shared_nonpic_test_LDADD = two_file_shared_nonpic.so
460
461 two_file_separate_shared_12_nonpic_test_SOURCES = two_file_test_main.cc
462 two_file_separate_shared_12_nonpic_test_DEPENDENCIES = \
463         gcctestdir/ld two_file_shared_1_nonpic.so two_file_shared_2_nonpic.so
464 two_file_separate_shared_12_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
465 two_file_separate_shared_12_nonpic_test_LDADD = \
466         two_file_shared_1_nonpic.so two_file_shared_2_nonpic.so
467
468 two_file_separate_shared_21_nonpic_test_SOURCES = two_file_test_main.cc
469 two_file_separate_shared_21_nonpic_test_DEPENDENCIES = \
470         gcctestdir/ld two_file_shared_1_nonpic.so two_file_shared_2_nonpic.so
471 two_file_separate_shared_21_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
472 two_file_separate_shared_21_nonpic_test_LDADD = \
473         two_file_shared_2_nonpic.so two_file_shared_1_nonpic.so
474
475 two_file_mixed_shared_test_SOURCES = two_file_test_main.cc
476 two_file_mixed_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared_mixed.so
477 two_file_mixed_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
478 two_file_mixed_shared_test_LDADD = two_file_shared_mixed.so
479
480 two_file_mixed_2_shared_test_SOURCES = two_file_test_main.cc
481 two_file_mixed_2_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared_mixed_1.so two_file_shared_2.so
482 two_file_mixed_2_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
483 two_file_mixed_2_shared_test_LDADD = two_file_shared_mixed_1.so two_file_shared_2.so
484
485 check_PROGRAMS += two_file_mixed_pie_test
486 two_file_mixed_pie_test: two_file_test_1.o two_file_test_1b_pie.o \
487                 two_file_test_main_pie.o two_file_shared_2.so gcctestdir/ld
488         $(CXXLINK) -Bgcctestdir/ -Wl,-R,. -pie two_file_test_1.o two_file_test_1b_pie.o two_file_test_main_pie.o two_file_shared_2.so
489
490 endif FN_PTRS_IN_SO_WITHOUT_PIC
491
492 check_PROGRAMS += two_file_strip_test
493 two_file_strip_test: two_file_test
494         $(TEST_STRIP) -o two_file_strip_test two_file_test
495
496 check_PROGRAMS += two_file_same_shared_strip_test
497 two_file_same_shared_strip_test_SOURCES = two_file_test_main.cc
498 two_file_same_shared_strip_test_DEPENDENCIES = \
499         gcctestdir/ld two_file_shared_strip.so
500 two_file_same_shared_strip_test_LDFLAGS = -Bgcctestdir/ -Wl,-R.
501 two_file_same_shared_strip_test_LDADD = two_file_shared_strip.so
502 two_file_shared_strip.so: two_file_shared.so
503         $(TEST_STRIP) -S -o two_file_shared_strip.so two_file_shared.so
504
505 check_PROGRAMS += common_test_1
506 common_test_1_SOURCES = common_test_1.c
507 common_test_1_DEPENDENCIES = gcctestdir/ld
508 common_test_1_LDFLAGS = -Bgcctestdir/
509 common_test_1_LDADD =
510
511 check_PROGRAMS += common_test_2
512 common_test_2_SOURCES = common_test_1.c
513 common_test_2_DEPENDENCIES = common_test_2.so common_test_3.so gcctestdir/ld
514 common_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
515 common_test_2_LDADD = common_test_2.so common_test_3.so
516 common_test_2_pic.o: common_test_2.c
517         $(COMPILE) -c -fpic -o $@ $<
518 common_test_2.so: common_test_2_pic.o common_test_3.so gcctestdir/ld
519         $(LINK) -Bgcctestdir/ -shared common_test_2_pic.o common_test_3.so
520 common_test_3_pic.o: common_test_3.c
521         $(COMPILE) -c -fpic -o $@ $<
522 common_test_3.so: common_test_3_pic.o ver_test_2.script gcctestdir/ld
523         $(LINK) -Bgcctestdir/ -shared common_test_3_pic.o -Wl,--version-script,$(srcdir)/ver_test_2.script
524
525 check_PROGRAMS += exception_test
526 check_PROGRAMS += exception_shared_1_test
527 check_PROGRAMS += exception_shared_2_test
528 check_PROGRAMS += exception_same_shared_test
529 check_PROGRAMS += exception_separate_shared_12_test
530 check_PROGRAMS += exception_separate_shared_21_test
531 exception_test_1_pic.o: exception_test_1.cc
532         $(CXXCOMPILE) -c -fpic -o $@ $<
533 exception_test_2_pic.o: exception_test_2.cc
534         $(CXXCOMPILE) -c -fpic -o $@ $<
535 exception_shared_1.so: exception_test_1_pic.o gcctestdir/ld
536         $(CXXLINK) -Bgcctestdir/ -shared exception_test_1_pic.o
537 exception_shared_2.so: exception_test_2_pic.o gcctestdir/ld
538         $(CXXLINK) -Bgcctestdir/ -shared exception_test_2_pic.o
539 exception_shared.so: exception_test_1_pic.o exception_test_2_pic.o gcctestdir/ld
540         $(CXXLINK) -Bgcctestdir/ -shared exception_test_1_pic.o exception_test_2_pic.o
541
542 exception_test_SOURCES = \
543         exception_test_main.cc \
544         exception_test_1.cc \
545         exception_test_2.cc \
546         exception_test.h
547 exception_test_DEPENDENCIES = gcctestdir/ld
548 exception_test_LDFLAGS = -Bgcctestdir/
549 exception_test_LDADD =
550
551 if HAVE_STATIC
552 check_PROGRAMS += exception_static_test
553 exception_static_test_SOURCES = $(exception_test_SOURCES)
554 exception_static_test_DEPENDENCIES = $(exception_test_DEPENDENCIES)
555 exception_static_test_LDFLAGS = $(exception_test_LDFLAGS) -static
556 exception_static_test_LDADD = $(exception_test_LDADD)
557 endif
558
559 exception_shared_1_test_SOURCES = exception_test_2.cc exception_test_main.cc
560 exception_shared_1_test_DEPENDENCIES = gcctestdir/ld exception_shared_1.so
561 exception_shared_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
562 exception_shared_1_test_LDADD = exception_shared_1.so
563
564 exception_shared_2_test_SOURCES = exception_test_1.cc exception_test_main.cc
565 exception_shared_2_test_DEPENDENCIES = gcctestdir/ld exception_shared_2.so
566 exception_shared_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
567 exception_shared_2_test_LDADD = exception_shared_2.so
568
569 exception_same_shared_test_SOURCES = exception_test_main.cc
570 exception_same_shared_test_DEPENDENCIES = gcctestdir/ld exception_shared.so
571 exception_same_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
572 exception_same_shared_test_LDADD = exception_shared.so
573
574 exception_separate_shared_12_test_SOURCES = exception_test_main.cc
575 exception_separate_shared_12_test_DEPENDENCIES = \
576         gcctestdir/ld exception_shared_1.so exception_shared_2.so
577 exception_separate_shared_12_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
578 exception_separate_shared_12_test_LDADD = \
579         exception_shared_1.so exception_shared_2.so
580
581 exception_separate_shared_21_test_SOURCES = exception_test_main.cc
582 exception_separate_shared_21_test_DEPENDENCIES = \
583         gcctestdir/ld exception_shared_1.so exception_shared_2.so
584 exception_separate_shared_21_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
585 exception_separate_shared_21_test_LDADD = \
586         exception_shared_2.so exception_shared_1.so
587
588
589 check_PROGRAMS += weak_test
590 weak_test_SOURCES = weak_test.cc
591 weak_test_DEPENDENCIES = gcctestdir/ld
592 weak_test_LDFLAGS = -Bgcctestdir/
593 weak_test_LDADD =
594
595 check_PROGRAMS += weak_undef_test
596 MOSTLYCLEANFILES += alt/weak_undef_lib.so
597 weak_undef_test_SOURCES = weak_undef_test.cc
598 weak_undef_test_DEPENDENCIES = gcctestdir/ld weak_undef_lib.so alt/weak_undef_lib.so
599 weak_undef_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,alt
600 weak_undef_test_LDADD = -L . weak_undef_lib.so
601 weak_undef_file1.o: weak_undef_file1.cc
602         $(CXXCOMPILE) -c -fpic -o $@ $<
603 weak_undef_file2.o: weak_undef_file2.cc
604         $(CXXCOMPILE) -c -fpic -o $@ $<
605 weak_undef_lib.so: weak_undef_file1.o
606         $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file1.o
607 alt/weak_undef_lib.so: weak_undef_file2.o
608         test -d alt || mkdir -p alt
609         $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file2.o
610
611 if FN_PTRS_IN_SO_WITHOUT_PIC
612 check_PROGRAMS += weak_undef_nonpic_test
613 MOSTLYCLEANFILES += alt/weak_undef_lib_nonpic.so
614 weak_undef_nonpic_test_SOURCES = weak_undef_test.cc
615 weak_undef_nonpic_test_DEPENDENCIES = gcctestdir/ld weak_undef_lib_nonpic.so alt/weak_undef_lib_nonpic.so
616 weak_undef_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,alt
617 weak_undef_nonpic_test_LDADD = -L . weak_undef_lib_nonpic.so
618 weak_undef_file1_nonpic.o: weak_undef_file1.cc
619         $(CXXCOMPILE) -c -o $@ $<
620 weak_undef_file2_nonpic.o: weak_undef_file2.cc
621         $(CXXCOMPILE) -c -o $@ $<
622 weak_undef_lib_nonpic.so: weak_undef_file1_nonpic.o
623         $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file1_nonpic.o -Wl,-z,notext
624 alt/weak_undef_lib_nonpic.so: weak_undef_file2_nonpic.o
625         test -d alt || mkdir -p alt
626         $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file2_nonpic.o -Wl,-z,notext
627 endif FN_PTRS_IN_SO_WITHOUT_PIC
628
629
630 check_PROGRAMS += weak_alias_test
631 weak_alias_test_SOURCES = weak_alias_test_main.cc
632 weak_alias_test_DEPENDENCIES = \
633         gcctestdir/ld weak_alias_test_1.so weak_alias_test_2.so \
634         weak_alias_test_3.o weak_alias_test_4.so weak_alias_test_5.so
635 weak_alias_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
636 weak_alias_test_LDADD = \
637         weak_alias_test_1.so weak_alias_test_2.so weak_alias_test_3.o \
638         weak_alias_test_4.so weak_alias_test_5.so
639 weak_alias_test_1_pic.o: weak_alias_test_1.cc
640         $(CXXCOMPILE) -c -fpic -o $@ $<
641 weak_alias_test_1.so: weak_alias_test_1_pic.o gcctestdir/ld
642         $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_1_pic.o
643 weak_alias_test_2_pic.o: weak_alias_test_2.cc
644         $(CXXCOMPILE) -c -fpic -o $@ $<
645 weak_alias_test_2.so: weak_alias_test_2_pic.o gcctestdir/ld
646         $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_2_pic.o
647 weak_alias_test_3.o: weak_alias_test_3.cc
648         $(CXXCOMPILE) -c -o $@ $<
649 weak_alias_test_4_pic.o: weak_alias_test_4.cc
650         $(CXXCOMPILE) -c -fpic -o $@ $<
651 weak_alias_test_4.so: weak_alias_test_4_pic.o gcctestdir/ld
652         $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_4_pic.o
653 weak_alias_test_5_pic.o: weak_alias_test_5.cc
654         $(CXXCOMPILE) -c -fpic -o $@ $<
655 weak_alias_test_5.so: weak_alias_test_5_pic.o $(srcdir)/weak_alias_test.script gcctestdir/ld
656         $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_5_pic.o \
657                 -Wl,--version-script,$(srcdir)/weak_alias_test.script
658
659 check_SCRIPTS += weak_plt.sh
660 check_PROGRAMS += weak_plt
661 check_DATA += weak_plt_shared.so
662 weak_plt_main_pic.o: weak_plt_main.cc
663         $(CXXCOMPILE) -c -fpic -o $@ $<
664 weak_plt: weak_plt_main_pic.o gcctestdir/ld
665         $(CXXLINK) -Bgcctestdir/ weak_plt_main_pic.o
666 weak_plt_shared_pic.o: weak_plt_shared.cc
667         $(CXXCOMPILE) -c -fpic -o $@ $<
668 weak_plt_shared.so: weak_plt_shared_pic.o gcctestdir/ld
669         $(CXXLINK) -Bgcctestdir/ -shared weak_plt_shared_pic.o
670
671 check_PROGRAMS += copy_test
672 copy_test_SOURCES = copy_test.cc
673 copy_test_DEPENDENCIES = gcctestdir/ld copy_test_1.so copy_test_2.so
674 copy_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
675 copy_test_LDADD = copy_test_1.so copy_test_2.so
676 copy_test_1_pic.o: copy_test_1.cc
677         $(CXXCOMPILE) -c -fpic -o $@ $<
678 copy_test_1.so: gcctestdir/ld copy_test_1_pic.o
679         $(CXXLINK) -Bgcctestdir/ -shared copy_test_1_pic.o
680 copy_test_2_pic.o: copy_test_2.cc
681         $(CXXCOMPILE) -c -fpic -o $@ $<
682 copy_test_2.so: gcctestdir/ld copy_test_2_pic.o
683         $(CXXLINK) -Bgcctestdir/ -shared copy_test_2_pic.o
684
685 if TLS
686
687 check_PROGRAMS += tls_test
688 check_PROGRAMS += tls_pic_test
689 check_PROGRAMS += tls_pie_test
690 check_PROGRAMS += tls_pie_pic_test
691 check_PROGRAMS += tls_shared_test
692 check_PROGRAMS += tls_shared_ie_test
693 check_PROGRAMS += tls_shared_gd_to_ie_test
694 tls_test_pic.o: tls_test.cc
695         $(CXXCOMPILE) -c -fpic -o $@ $<
696 tls_test_file2_pic.o: tls_test_file2.cc
697         $(CXXCOMPILE) -c -fpic -o $@ $<
698 tls_test_c_pic.o: tls_test_c.c
699         $(COMPILE) -c -fpic $(TLS_TEST_C_CFLAGS) -o $@ $<
700 tls_test_shared.so: tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o gcctestdir/ld
701         $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -Wl,-z,defs
702 tls_test_shared2.so: tls_test_file2_pic.o gcctestdir/ld
703         $(CXXLINK) -Bgcctestdir/ -shared tls_test_file2_pic.o
704
705 tls_test_pic_ie.o: tls_test.cc
706         $(CXXCOMPILE) -c -fpic -ftls-model=initial-exec -o $@ $<
707 tls_test_file2_pic_ie.o: tls_test_file2.cc
708         $(CXXCOMPILE) -c -fpic -ftls-model=initial-exec -o $@ $<
709 tls_test_c_pic_ie.o: tls_test_c.c
710         $(COMPILE) -c -fpic -ftls-model=initial-exec $(TLS_TEST_C_CFLAGS) -o $@ $<
711 tls_test_ie_shared.so: tls_test_pic_ie.o tls_test_file2_pic_ie.o tls_test_c_pic_ie.o gcctestdir/ld
712         $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic_ie.o tls_test_file2_pic_ie.o tls_test_c_pic_ie.o
713
714 tls_test_SOURCES = tls_test.cc tls_test_file2.cc tls_test_main.cc tls_test.h
715 tls_test_DEPENDENCIES = gcctestdir/ld tls_test_c.o
716 tls_test_LDFLAGS = -Bgcctestdir/
717 tls_test_LDADD = tls_test_c.o -lpthread
718 tls_test_c.o: tls_test_c.c
719         $(COMPILE) -c $(TLS_TEST_C_CFLAGS) -o $@ $<
720
721 tls_pic_test_SOURCES = tls_test_main.cc
722 tls_pic_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o tls_test_file2_pic.o \
723         tls_test_c_pic.o
724 tls_pic_test_LDFLAGS = -Bgcctestdir/
725 tls_pic_test_LDADD = tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o \
726         -lpthread
727
728 tls_test_main_pie.o: tls_test_main.cc tls_test.h
729         $(CXXCOMPILE) -c -fpie -o $@ $<
730 tls_test_pie.o: tls_test.cc tls_test.h
731         $(CXXCOMPILE) -c -fpie -o $@ $<
732 tls_test_file2_pie.o: tls_test_file2.cc tls_test.h
733         $(CXXCOMPILE) -c -fpie -o $@ $<
734 tls_test_c_pie.o: tls_test_c.c
735         $(COMPILE) -c -fpic $(TLS_TEST_C_CFLAGS) -o $@ $<
736 tls_pie_test: tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o \
737                 tls_test_c_pie.o gcctestdir/ld
738         $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o tls_test_c_pie.o -lpthread
739
740 tls_pie_pic_test: tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o \
741                 tls_test_c_pic.o gcctestdir/ld
742         $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -lpthread
743
744 tls_shared_test_SOURCES = tls_test_main.cc
745 tls_shared_test_DEPENDENCIES = gcctestdir/ld tls_test_shared.so
746 tls_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
747 tls_shared_test_LDADD = tls_test_shared.so -lpthread
748
749 tls_shared_ie_test_SOURCES = tls_test_main.cc
750 tls_shared_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_ie_shared.so
751 tls_shared_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
752 tls_shared_ie_test_LDADD = tls_test_ie_shared.so -lpthread
753
754 tls_shared_gd_to_ie_test_SOURCES = tls_test_main.cc
755 tls_shared_gd_to_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o \
756         tls_test_c_pic.o tls_test_shared2.so
757 tls_shared_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
758 tls_shared_gd_to_ie_test_LDADD = tls_test_pic.o tls_test_c_pic.o \
759         tls_test_shared2.so -lpthread
760
761 if TLS_GNU2_DIALECT
762
763 check_PROGRAMS += tls_shared_gnu2_gd_to_ie_test
764
765 tls_test_gnu2.o: tls_test.cc
766         $(CXXCOMPILE) -c -fpic -mtls-dialect=gnu2 -o $@ $<
767 tls_test_file2_gnu2.o: tls_test_file2.cc
768         $(CXXCOMPILE) -c -fpic -mtls-dialect=gnu2 -o $@ $<
769 tls_test_c_gnu2.o: tls_test_c.c
770         $(COMPILE) -c -fpic -mtls-dialect=gnu2 $(TLS_TEST_C_CFLAGS) -o $@ $<
771 tls_test_gnu2_shared2.so: tls_test_file2_gnu2.o gcctestdir/ld
772         $(CXXLINK) -Bgcctestdir/ -shared tls_test_file2_gnu2.o
773
774 tls_shared_gnu2_gd_to_ie_test_SOURCES = tls_test_main.cc
775 tls_shared_gnu2_gd_to_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_gnu2.o \
776         tls_test_c_gnu2.o tls_test_gnu2_shared2.so
777 tls_shared_gnu2_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
778 tls_shared_gnu2_gd_to_ie_test_LDADD = tls_test_gnu2.o tls_test_c_gnu2.o \
779         tls_test_gnu2_shared2.so -lpthread
780
781 if TLS_DESCRIPTORS
782
783 check_PROGRAMS += tls_shared_gnu2_test
784
785 tls_test_gnu2_shared.so: tls_test_gnu2.o tls_test_file2_gnu2.o tls_test_c_gnu2.o gcctestdir/ld
786         $(CXXLINK) -Bgcctestdir/ -shared tls_test_gnu2.o tls_test_file2_gnu2.o tls_test_c_gnu2.o
787
788 tls_shared_gnu2_test_SOURCES = tls_test_main.cc
789 tls_shared_gnu2_test_DEPENDENCIES = gcctestdir/ld tls_test_gnu2_shared.so
790 tls_shared_gnu2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
791 tls_shared_gnu2_test_LDADD = tls_test_gnu2_shared.so -lpthread
792
793 endif TLS_DESCRIPTORS
794
795 endif TLS_GNU2_DIALECT
796
797 if HAVE_STATIC
798 if STATIC_TLS
799 check_PROGRAMS += tls_static_test
800 check_PROGRAMS += tls_static_pic_test
801
802 tls_static_test_SOURCES = $(tls_test_SOURCES)
803 tls_static_test_DEPENDENCIES = $(tls_test_DEPENDENCIES)
804 tls_static_test_LDFLAGS = $(tls_test_LDFLAGS) -static
805 tls_static_test_LDADD = $(tls_test_LDADD)
806
807 tls_static_pic_test_SOURCES = $(tls_pic_test_SOURCES)
808 tls_static_pic_test_DEPENDENCIES = $(tls_pic_test_DEPENDENCIES)
809 tls_static_pic_test_LDFLAGS = $(tls_pic_test_LDFLAGS) -static
810 tls_static_pic_test_LDADD = $(tls_pic_test_LDADD)
811 endif
812 endif
813
814 if FN_PTRS_IN_SO_WITHOUT_PIC
815 check_PROGRAMS += tls_shared_nonpic_test
816 tls_test_shared_nonpic.so: tls_test.o tls_test_file2.o tls_test_c.o gcctestdir/ld
817         $(CXXLINK) -Bgcctestdir/ -shared tls_test.o tls_test_file2.o tls_test_c.o -Wl,-z,notext
818
819 tls_shared_nonpic_test_SOURCES = tls_test_main.cc
820 tls_shared_nonpic_test_DEPENDENCIES = gcctestdir/ld tls_test_shared_nonpic.so
821 tls_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
822 tls_shared_nonpic_test_LDADD = tls_test_shared_nonpic.so -lpthread
823 endif FN_PTRS_IN_SO_WITHOUT_PIC
824
825 endif TLS
826
827 check_PROGRAMS += many_sections_test
828 many_sections_test_SOURCES = many_sections_test.cc
829 many_sections_test_DEPENDENCIES = gcctestdir/ld
830 many_sections_test_LDFLAGS = -Bgcctestdir/ -rdynamic
831 many_sections_test_LDADD =
832
833 BUILT_SOURCES += many_sections_define.h
834 MOSTLYCLEANFILES += many_sections_define.h
835 many_sections_define.h:
836         (for i in `seq 1 70000`; do \
837            echo "int var_$$i __attribute__((section(\"section_$$i\"))) = $$i;"; \
838          done) > $@.tmp
839         mv -f $@.tmp $@
840
841 BUILT_SOURCES += many_sections_check.h
842 MOSTLYCLEANFILES += many_sections_check.h
843 many_sections_check.h:
844         (for i in `seq 1 1000 70000`; do \
845            echo "assert(var_$$i == $$i);"; \
846          done) > $@.tmp
847         mv -f $@.tmp $@
848
849 check_PROGRAMS += many_sections_r_test
850 many_sections_r_test.o: many_sections_test.o gcctestdir/ld
851         gcctestdir/ld -r -o $@ many_sections_test.o
852 many_sections_r_test: many_sections_r_test.o gcctestdir/ld
853         $(CXXLINK) -Bgcctestdir/ many_sections_r_test.o $(LIBS)
854
855 check_PROGRAMS += initpri1
856 initpri1_SOURCES = initpri1.c
857 initpri1_DEPENDENCIES = gcctestdir/ld
858 initpri1_LDFLAGS = -Bgcctestdir/
859 initpri1_LDADD =
860
861 check_PROGRAMS += initpri2
862 initpri2_SOURCES = initpri2.c
863 initpri2_DEPENDENCIES = gcctestdir/ld
864 initpri2_LDFLAGS = -Bgcctestdir/
865 initpri2_LDADD =
866
867 check_PROGRAMS += initpri3a
868 initpri3a_SOURCES = initpri3.c
869 initpri3a_DEPENDENCIES = gcctestdir/ld
870 initpri3a_LDFLAGS = -Bgcctestdir/
871 initpri3a_LDADD =
872
873 check_PROGRAMS += initpri3b
874 initpri3b_SOURCES = initpri3.c
875 initpri3b_DEPENDENCIES = gcctestdir/ld
876 initpri3b_LDFLAGS = -Bgcctestdir/ -Wl,--no-ctors-in-init-array
877 initpri3b_LDADD =
878
879 # Test --detect-odr-violations
880 check_SCRIPTS += debug_msg.sh
881
882 # Create the data files that debug_msg.sh analyzes.
883 check_DATA += debug_msg.err
884 MOSTLYCLEANFILES += debug_msg.err
885 debug_msg.o: debug_msg.cc
886         $(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/debug_msg.cc
887 odr_violation1.o: odr_violation1.cc
888         $(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/odr_violation1.cc
889 # Compile with different optimization flags to check that rearranged
890 # instructions don't cause a false positive.
891 odr_violation2.o: odr_violation2.cc
892         $(CXXCOMPILE) -O2 -g -c -w -o $@ $(srcdir)/odr_violation2.cc
893 debug_msg.err: debug_msg.o odr_violation1.o odr_violation2.o gcctestdir/ld
894         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o "2>$@"
895         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o 2>$@; \
896         then \
897           echo 1>&2 "Link of debug_msg should have failed"; \
898           rm -f $@; \
899           exit 1; \
900         fi
901
902
903 if HAVE_ZLIB
904
905 # Check that --detect-odr-violations works with compressed debug sections.
906 check_DATA += debug_msg_cdebug.err
907 MOSTLYCLEANFILES += debug_msg_cdebug.err
908 debug_msg_cdebug.o: debug_msg.cc gcctestdir/as
909         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/debug_msg.cc
910 odr_violation1_cdebug.o: odr_violation1.cc gcctestdir/as
911         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/odr_violation1.cc
912 odr_violation2_cdebug.o: odr_violation2.cc gcctestdir/as
913         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/odr_violation2.cc
914 debug_msg_cdebug.err: debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o gcctestdir/ld
915         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o "2>$@"
916         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o 2>$@; \
917         then \
918           echo 1>&2 "Link of debug_msg_cdebug should have failed"; \
919           rm -f $@; \
920           exit 1; \
921         fi
922
923 endif HAVE_ZLIB
924
925 # See if we can also detect problems when we're linking .so's, not .o's.
926 check_DATA += debug_msg_so.err
927 MOSTLYCLEANFILES += debug_msg_so.err
928 debug_msg.so: debug_msg.cc gcctestdir/ld
929         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
930 odr_violation1.so: odr_violation1.cc gcctestdir/ld
931         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
932 odr_violation2.so: odr_violation2.cc gcctestdir/ld
933         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
934 debug_msg_so.err: debug_msg.so odr_violation1.so odr_violation2.so gcctestdir/ld
935         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so "2>$@"
936         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so 2>$@; \
937         then \
938           echo 1>&2 "Link of debug_msg_so should have failed"; \
939           rm -f $@; \
940           exit 1; \
941         fi
942
943 # We also want to make sure we do something reasonable when there's no
944 # debug info available.  For the best test, we use .so's.
945 check_DATA += debug_msg_ndebug.err
946 MOSTLYCLEANFILES += debug_msg_ndebug.err
947 debug_msg_ndebug.so: debug_msg.cc gcctestdir/ld
948         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
949 odr_violation1_ndebug.so: odr_violation1.cc gcctestdir/ld
950         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
951 odr_violation2_ndebug.so: odr_violation2.cc gcctestdir/ld
952         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
953 debug_msg_ndebug.err: debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so gcctestdir/ld
954         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so "2>$@"
955         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so 2>$@; \
956         then \
957           echo 1>&2 "Link of debug_msg_ndebug should have failed"; \
958           rm -f $@; \
959           exit 1; \
960         fi
961
962
963 # Similar to --detect-odr-violations: check for undefined symbols in .so's
964 check_SCRIPTS += undef_symbol.sh
965 check_DATA += undef_symbol.err
966 MOSTLYCLEANFILES += undef_symbol.err
967 undef_symbol.o: undef_symbol.cc
968         $(CXXCOMPILE) -O0 -g -c -fPIC $<
969 undef_symbol.so: undef_symbol.o gcctestdir/ld
970         $(CXXLINK) -Bgcctestdir/ -shared undef_symbol.o
971 undef_symbol.err: undef_symbol_main.o undef_symbol.so gcctestdir/ld
972         @echo $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so "2>$@"
973         @if $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so 2>$@; \
974         then \
975           echo 1>&2 "Link of undef_symbol_test should have failed"; \
976           rm -f $@; \
977           exit 1; \
978         fi
979
980
981 # Test -o when emitting to a special file (such as something in /dev).
982 check_PROGRAMS += flagstest_o_specialfile
983 flagstest_o_specialfile: flagstest_debug.o gcctestdir/ld
984         $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< 2>&1 | cat > $@
985         chmod a+x $@
986         test -s $@
987
988 if HAVE_ZLIB
989
990 # Test --compress-debug-sections.  FIXME: check we actually compress.
991 check_PROGRAMS += flagstest_compress_debug_sections
992 flagstest_compress_debug_sections: flagstest_debug.o gcctestdir/ld
993         $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib
994         test -s $@
995
996
997 # The specialfile output has a tricky case when we also compress debug
998 # sections, because it requires output-file resizing.
999 check_PROGRAMS += flagstest_o_specialfile_and_compress_debug_sections
1000 flagstest_o_specialfile_and_compress_debug_sections: flagstest_debug.o \
1001                 gcctestdir/ld
1002         $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< -Wl,--compress-debug-sections=zlib 2>&1 | cat > $@
1003         chmod a+x $@
1004         test -s $@
1005
1006 endif HAVE_ZLIB
1007
1008 # Test symbol versioning.
1009 check_PROGRAMS += ver_test
1010 ver_test_SOURCES = ver_test_main.cc
1011 ver_test_DEPENDENCIES = gcctestdir/ld ver_test_1.so ver_test_2.so ver_test_4.so
1012 ver_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1013 ver_test_LDADD = ver_test_1.so ver_test_2.so ver_test_4.so
1014 ver_test_1.so: ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so gcctestdir/ld
1015         $(CXXLINK) -Bgcctestdir/ -shared ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so
1016 ver_test_2.so: ver_test_2.o $(srcdir)/ver_test_2.script ver_test_4.so gcctestdir/ld
1017         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_2.script -Wl,-R,. ver_test_2.o ver_test_4.so
1018 ver_test_4.so: ver_test_4.o $(srcdir)/ver_test_4.script gcctestdir/ld
1019         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o
1020 ver_test_1.o: ver_test_1.cc
1021         $(CXXCOMPILE) -c -fpic -o $@ $<
1022 ver_test_2.o: ver_test_2.cc
1023         $(CXXCOMPILE) -c -fpic -o $@ $<
1024 ver_test_3.o: ver_test_3.cc
1025         $(CXXCOMPILE) -c -fpic -o $@ $<
1026 ver_test_4.o: ver_test_4.cc
1027         $(CXXCOMPILE) -c -fpic -o $@ $<
1028
1029 check_SCRIPTS += ver_test_1.sh
1030 check_DATA += ver_test_1.syms
1031 ver_test_1.syms: ver_test_1.so
1032         $(TEST_READELF) -s $< >$@ 2>/dev/null
1033
1034 check_PROGRAMS += ver_test_2
1035 ver_test_2_SOURCES = ver_test_main_2.cc
1036 ver_test_2_DEPENDENCIES = gcctestdir/ld ver_test_4.so ver_test_2.so
1037 ver_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1038 ver_test_2_LDADD = ver_test_4.so ver_test_2.so
1039
1040 check_SCRIPTS += ver_test_2.sh
1041 check_DATA += ver_test_2.syms
1042 ver_test_2.syms: ver_test_2
1043         $(TEST_READELF) -s $< >$@ 2>/dev/null
1044
1045 check_SCRIPTS += ver_test_4.sh
1046 check_DATA += ver_test_4.syms
1047 ver_test_4.syms: ver_test_4.so
1048         $(TEST_READELF) -s $< >$@ 2>/dev/null
1049
1050 ver_test_5.so: ver_test_5.o $(srcdir)/ver_test_5.script ver_test_4.so gcctestdir/ld
1051         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_5.script ver_test_5.o ver_test_4.so
1052 ver_test_5.o: ver_test_5.cc
1053         $(CXXCOMPILE) -c -fpic -o $@ $<
1054 check_SCRIPTS += ver_test_5.sh
1055 check_DATA += ver_test_5.syms
1056 ver_test_5.syms: ver_test_5.so
1057         $(TEST_READELF) -s $< >$@ 2>/dev/null
1058
1059 check_PROGRAMS += ver_test_6
1060 ver_test_6_SOURCES = ver_test_6.c
1061 ver_test_6_DEPENDENCIES = gcctestdir/ld ver_test_2.so
1062 ver_test_6_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1063 ver_test_6_LDADD = ver_test_2.so
1064
1065 ver_test_7.so: ver_test_4.o $(srcdir)/ver_test_4.script ver_test_7.o gcctestdir/ld
1066         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o ver_test_7.o
1067 ver_test_7.o: ver_test_7.cc
1068         $(CXXCOMPILE) -c -fpic -o $@ $<
1069 check_SCRIPTS += ver_test_7.sh
1070 check_DATA += ver_test_7.syms
1071 ver_test_7.syms: ver_test_7.so
1072         $(TEST_READELF) -s $< >$@ 2>/dev/null
1073
1074 check_PROGRAMS += ver_test_8
1075 ver_test_8_SOURCES = two_file_test_main.cc
1076 ver_test_8_DEPENDENCIES = gcctestdir/ld ver_test_8_1.so ver_test_8_2.so
1077 ver_test_8_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1078 ver_test_8_LDADD = ver_test_8_1.so ver_test_8_2.so
1079 ver_test_8_1.so: two_file_test_1_pic.o two_file_test_1b_pic.o ver_test_8_2.so gcctestdir/ld
1080         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o ver_test_8_2.so
1081 ver_test_8_2.so: two_file_test_2_pic.o $(srcdir)/ver_test_8.script gcctestdir/ld
1082         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_8.script two_file_test_2_pic.o
1083
1084 check_PROGRAMS += ver_test_9
1085 ver_test_9_SOURCES = ver_test_main.cc
1086 ver_test_9_DEPENDENCIES = gcctestdir/ld ver_test_9.so
1087 ver_test_9_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1088 ver_test_9_LDADD = ver_test_9.so
1089 ver_test_9.so: ver_test_9.o ver_test_4.so ver_test_5.so gcctestdir/ld
1090         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-R,. ver_test_9.o ver_test_5.so ver_test_4.so
1091 ver_test_9.o: ver_test_9.cc
1092         $(CXXCOMPILE) -c -fpic -o $@ $<
1093
1094 check_SCRIPTS += ver_test_10.sh
1095 check_DATA += ver_test_10.syms
1096 ver_test_10.syms: ver_test_10.so
1097         $(TEST_READELF) -s $< >$@ 2>/dev/null
1098 ver_test_10.so: gcctestdir/ld ver_test_2.o ver_test_10.script
1099         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_10.script ver_test_2.o
1100
1101 check_PROGRAMS += ver_test_11
1102 MOSTLYCLEANFILES += ver_test_11.a
1103 ver_test_11_SOURCES = ver_test_main_2.cc
1104 ver_test_11_DEPENDENCIES = gcctestdir/ld ver_test_11.a
1105 ver_test_11_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1106 ver_test_11_LDADD = ver_test_11.a
1107 ver_test_11.a: ver_test_1.o ver_test_2.o ver_test_4.o
1108         $(TEST_AR) rc $@ $^
1109
1110 check_PROGRAMS += ver_test_12
1111 ver_test_12_SOURCES = ver_test_main_2.cc
1112 ver_test_12_DEPENDENCIES = gcctestdir/ld ver_test_12.o
1113 ver_test_12_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1114 ver_test_12_LDADD = ver_test_12.o
1115 ver_test_12.o: gcctestdir/ld ver_test_1.o ver_test_2.o ver_test_4.o
1116         gcctestdir/ld -r -o $@ ver_test_1.o ver_test_2.o ver_test_4.o
1117
1118 check_PROGRAMS += protected_1
1119 protected_1_SOURCES = \
1120         protected_main_1.cc protected_main_2.cc protected_main_3.cc
1121 protected_1_DEPENDENCIES = gcctestdir/ld protected_1.so
1122 protected_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1123 protected_1_LDADD = protected_1.so
1124
1125 protected_1.so: gcctestdir/ld protected_1_pic.o protected_2_pic.o protected_3_pic.o
1126         $(CXXLINK) -Bgcctestdir/ -shared protected_1_pic.o protected_2_pic.o protected_3_pic.o
1127 protected_1_pic.o: protected_1.cc
1128         $(CXXCOMPILE) -c -fpic -o $@ $<
1129 protected_2_pic.o: protected_2.cc
1130         $(CXXCOMPILE) -c -fpic -o $@ $<
1131 protected_3_pic.o: protected_3.cc
1132         $(CXXCOMPILE) -c -fpic -o $@ $<
1133
1134 check_PROGRAMS += protected_2
1135 protected_2_SOURCES = protected_main_1.cc protected_3.cc
1136 protected_2_DEPENDENCIES = gcctestdir/ld protected_1.so
1137 protected_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1138 protected_2_LDADD = protected_1.so
1139
1140 check_DATA += protected_3.err
1141 MOSTLYCLEANFILES += protected_3.err
1142 protected_4_pic.o: protected_4.cc
1143         $(CXXCOMPILE) -c -fpic -o $@ $<
1144 protected_3.err: protected_4_pic.o gcctestdir/ld
1145         @echo $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o "2>$@"
1146         @if $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o 2>$@; then \
1147           echo 1>&2 "Link of protected_4.so should have failed"; \
1148           rm -f $@; \
1149           exit 1; \
1150         fi
1151
1152 check_PROGRAMS += relro_test
1153 check_SCRIPTS += relro_test.sh
1154 check_DATA += relro_test.stdout
1155 relro_test_SOURCES = relro_test_main.cc
1156 relro_test_DEPENDENCIES = gcctestdir/ld relro_test.so
1157 relro_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1158 relro_test_LDADD = relro_test.so
1159 relro_test.so: gcctestdir/ld relro_test_pic.o
1160         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro relro_test_pic.o
1161 relro_test_pic.o: relro_test.cc
1162         $(CXXCOMPILE) -c -fpic -o $@ $<
1163 relro_test.stdout: relro_test.so
1164         $(TEST_READELF) -SlW relro_test.so > relro_test.stdout
1165
1166 check_PROGRAMS += relro_strip_test
1167 relro_strip_test_SOURCES = relro_test_main.cc
1168 relro_strip_test_DEPENDENCIES = gcctestdir/ld relro_strip_test.so
1169 relro_strip_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1170 relro_strip_test_LDADD = relro_strip_test.so
1171 relro_strip_test.so: relro_test.so
1172         $(TEST_STRIP) -o $@ $<
1173
1174 check_PROGRAMS += relro_script_test
1175 relro_script_test_SOURCES = relro_test_main.cc
1176 relro_script_test_DEPENDENCIES = gcctestdir/ld relro_script_test.so
1177 relro_script_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1178 relro_script_test_LDADD = relro_script_test.so
1179 relro_script_test.so: gcctestdir/ld relro_script_test.t relro_test_pic.o
1180         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro -T $(srcdir)/relro_script_test.t relro_test_pic.o
1181
1182 check_PROGRAMS += script_test_1
1183 script_test_1_SOURCES = script_test_1.cc
1184 script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
1185 script_test_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_1.t
1186 script_test_1_LDADD =
1187
1188 check_PROGRAMS += script_test_2
1189 script_test_2_SOURCES = script_test_2.cc script_test_2a.cc script_test_2b.cc
1190 script_test_2_DEPENDENCIES = gcctestdir/ld script_test_2.t
1191 script_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_2.t
1192 script_test_2_LDADD =
1193
1194 check_PROGRAMS += justsyms
1195 justsyms_SOURCES = justsyms_1.cc
1196 justsyms_DEPENDENCIES = gcctestdir/ld justsyms_2r.o
1197 justsyms_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_2r.o
1198 justsyms_LDADD =
1199 justsyms_2.o: justsyms_2.cc
1200         $(CXXCOMPILE) -c -o $@ $<
1201 justsyms_2r.o: justsyms_2.o gcctestdir/ld $(srcdir)/justsyms.t
1202         gcctestdir/ld -o $@ -r -T $(srcdir)/justsyms.t justsyms_2.o
1203
1204 check_PROGRAMS += binary_test
1205 MOSTLYCLEANFILES += binary.txt
1206 binary_test_SOURCES = binary_test.cc
1207 binary_test_DEPENDENCIES = gcctestdir/ld binary.txt
1208 binary_test_LDFLAGS = -Bgcctestdir/ -Wl,--format,binary,binary.txt,--format,elf
1209 binary_test_LDADD =
1210 # Copy the file to the build directory to avoid worrying about the
1211 # full pathname in the generated symbols.
1212 binary.txt: $(srcdir)/binary.in
1213         rm -f $@
1214         $(LN_S) $< $@
1215
1216 check_SCRIPTS += ver_matching_test.sh
1217 check_DATA += ver_matching_test.stdout
1218 MOSTLYCLEANFILES += ver_matching_test.stdout
1219 ver_matching_def.so: ver_matching_def_pic.o $(srcdir)/version_script.map gcctestdir/ld
1220         $(CXXLINK) -O0 -Bgcctestdir/ -shared ver_matching_def_pic.o -Wl,--version-script=$(srcdir)/version_script.map
1221 ver_matching_def_pic.o: ver_matching_def.cc
1222         $(CXXCOMPILE) -O0 -c -fpic -o $@ $<
1223 ver_matching_test.stdout: ver_matching_def.so
1224         $(TEST_OBJDUMP) -T ver_matching_def.so | $(TEST_CXXFILT) > ver_matching_test.stdout
1225
1226 check_PROGRAMS += script_test_3
1227 check_SCRIPTS += script_test_3.sh
1228 check_DATA += script_test_3.stdout
1229 MOSTLYCLEANFILES += script_test_3.stdout
1230 script_test_3: basic_test.o gcctestdir/ld script_test_3.t
1231         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_3.t
1232 script_test_3.stdout: script_test_3
1233         $(TEST_READELF) -SlW script_test_3 > script_test_3.stdout
1234
1235 check_PROGRAMS += tls_phdrs_script_test
1236 tls_phdrs_script_test_SOURCES = $(tls_test_SOURCES)
1237 tls_phdrs_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_3.t
1238 tls_phdrs_script_test_LDFLAGS = $(tls_test_LDFLAGS) -T $(srcdir)/script_test_3.t
1239 tls_phdrs_script_test_LDADD = $(tls_test_LDADD)
1240
1241 check_SCRIPTS += script_test_4.sh
1242 check_DATA += script_test_4.stdout
1243 MOSTLYCLEANFILES += script_test_4
1244 script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
1245         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_4.t
1246 script_test_4.stdout: script_test_4
1247         $(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
1248
1249 check_PROGRAMS += tls_script_test
1250 tls_script_test_SOURCES = $(tls_test_SOURCES)
1251 tls_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_4.t
1252 tls_script_test_LDFLAGS = $(tls_test_LDFLAGS) -T $(srcdir)/script_test_4.t
1253 tls_script_test_LDADD = $(tls_test_LDADD)
1254
1255 check_SCRIPTS += script_test_5.sh
1256 check_DATA += script_test_5.stdout
1257 MOSTLYCLEANFILES += script_test_5
1258 script_test_5: script_test_5.o gcctestdir/ld $(srcdir)/script_test_5.t
1259         $(CXXLINK) -Bgcctestdir/ script_test_5.o -T $(srcdir)/script_test_5.t
1260 script_test_5.stdout: script_test_5
1261         $(TEST_READELF) -SW script_test_5 > script_test_5.stdout
1262
1263 check_SCRIPTS += script_test_6.sh
1264 check_DATA += script_test_6.stdout
1265 MOSTLYCLEANFILES += script_test_6
1266 script_test_6: basic_test.o gcctestdir/ld $(srcdir)/script_test_6.t
1267         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_6.t \
1268         -Wl,-Ttext=0x10001000 -Wl,-Tdata=0x10200000 -Wl,-Tbss=0x10400000
1269 script_test_6.stdout: script_test_6
1270         $(TEST_READELF) -SlW script_test_6 > script_test_6.stdout
1271
1272 check_SCRIPTS += script_test_7.sh
1273 check_DATA += script_test_7.stdout
1274 MOSTLYCLEANFILES += script_test_7
1275 script_test_7: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1276         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t
1277 script_test_7.stdout: script_test_7
1278         $(TEST_READELF) -SlW script_test_7 > script_test_7.stdout
1279
1280 check_SCRIPTS += script_test_8.sh
1281 check_DATA += script_test_8.stdout
1282 MOSTLYCLEANFILES += script_test_8
1283 script_test_8: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1284         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t \
1285         -Wl,-Ttext=0x20001000 -Wl,-Tdata=0x20200000 -Wl,-Tbss=0x20400000
1286 script_test_8.stdout: script_test_8
1287         $(TEST_READELF) -SlW script_test_8 > script_test_8.stdout
1288
1289
1290 check_SCRIPTS += script_test_9.sh
1291 check_DATA += script_test_9.stdout
1292 script_test_9.o: script_test_9.cc
1293         $(CXXCOMPILE) -O0 -c -o $@ $<
1294 script_test_9: gcctestdir/ld $(srcdir)/script_test_9.t script_test_9.o
1295         $(CXXLINK) -Bgcctestdir/ script_test_9.o -T $(srcdir)/script_test_9.t
1296 script_test_9.stdout: script_test_9
1297         $(TEST_READELF) -lW script_test_9 > script_test_9.stdout
1298
1299
1300 # Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new,
1301 # and --dynamic-list-cpp-typeinfo
1302
1303 check_SCRIPTS += dynamic_list.sh
1304 check_DATA += dynamic_list.stdout
1305 MOSTLYCLEANFILES += dynamic_list dynamic_list.stdout
1306 dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t
1307         $(CXXLINK) -Bgcctestdir/ basic_test.o \
1308           -Wl,--dynamic-list $(srcdir)/dynamic_list.t \
1309           -Wl,--dynamic-list-data \
1310           -Wl,--dynamic-list-cpp-new \
1311           -Wl,--dynamic-list-cpp-typeinfo
1312 dynamic_list.stdout: dynamic_list
1313         $(TEST_READELF) -W --dyn-syms dynamic_list > dynamic_list.stdout
1314
1315 check_PROGRAMS += thin_archive_test_1
1316 MOSTLYCLEANFILES += libthin1.a libthin3.a libthinall.a \
1317         alt/thin_archive_test_2.o alt/thin_archive_test_4.o \
1318         alt/libthin2.a alt/libthin4.a
1319 thin_archive_test_1_SOURCES = thin_archive_main.cc
1320 thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a
1321 thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt
1322 thin_archive_test_1_LDADD = libthin1.a -lthin2
1323
1324 check_PROGRAMS += thin_archive_test_2
1325 thin_archive_test_2_SOURCES = thin_archive_main.cc
1326 thin_archive_test_2_DEPENDENCIES = gcctestdir/ld libthinall.a
1327 thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L.
1328 thin_archive_test_2_LDADD = -lthinall
1329
1330 libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o
1331         rm -f $@
1332         $(TEST_AR) crT $@ $^
1333 alt/libthin2.a: thin_archive_test_3.o alt/thin_archive_test_4.o
1334         rm -f $@
1335         $(TEST_AR) crT $@ $^
1336 libthin3.a: thin_archive_test_1.o alt/thin_archive_test_4.o
1337         rm -f $@
1338         $(TEST_AR) crT $@ $^
1339 alt/libthin4.a: alt/thin_archive_test_2.o thin_archive_test_3.o
1340         rm -f $@
1341         $(TEST_AR) crT $@ $^
1342 libthinall.a: libthin3.a alt/libthin4.a
1343         rm -f $@
1344         $(TEST_AR) crT $@ $^
1345 alt/thin_archive_test_2.o: thin_archive_test_2.cc
1346         test -d alt || mkdir -p alt
1347         $(CXXCOMPILE) -c -o $@ $<
1348 alt/thin_archive_test_4.o: thin_archive_test_4.cc
1349         test -d alt || mkdir -p alt
1350         $(CXXCOMPILE) -c -o $@ $<
1351
1352 if PLUGINS
1353
1354 check_PROGRAMS += plugin_test_1
1355 check_SCRIPTS += plugin_test_1.sh
1356 check_DATA += plugin_test_1.err
1357 MOSTLYCLEANFILES += plugin_test_1.err
1358 plugin_test_1: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms empty.syms gcctestdir/ld plugin_test.so
1359         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms empty.syms 2>plugin_test_1.err
1360 plugin_test_1.err: plugin_test_1
1361         @touch plugin_test_1.err
1362
1363 check_PROGRAMS += plugin_test_2
1364 check_SCRIPTS += plugin_test_2.sh
1365 check_DATA += plugin_test_2.err
1366 MOSTLYCLEANFILES += plugin_test_2.err
1367 plugin_test_2: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so gcctestdir/ld plugin_test.so
1368         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,-R,.,--plugin,"./plugin_test.so" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so 2>plugin_test_2.err
1369 plugin_test_2.err: plugin_test_2
1370         @touch plugin_test_2.err
1371
1372 check_PROGRAMS += plugin_test_3
1373 check_SCRIPTS += plugin_test_3.sh
1374 check_DATA += plugin_test_3.err
1375 MOSTLYCLEANFILES += plugin_test_3.err
1376 plugin_test_3: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms empty.syms gcctestdir/ld plugin_test.so
1377         $(CXXLINK) -Bgcctestdir/ -Wl,--export-dynamic -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms empty.syms 2>plugin_test_3.err
1378 plugin_test_3.err: plugin_test_3
1379         @touch plugin_test_3.err
1380
1381 check_PROGRAMS += plugin_test_4
1382 check_SCRIPTS += plugin_test_4.sh
1383 check_DATA += plugin_test_4.err
1384 MOSTLYCLEANFILES += plugin_test_4.a plugin_test_4.err
1385 plugin_test_4: two_file_test_main.o plugin_test_4.a gcctestdir/ld plugin_test.so
1386         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o -Wl,--whole-archive,plugin_test_4.a,--no-whole-archive 2>plugin_test_4.err
1387 plugin_test_4.err: plugin_test_4
1388         @touch plugin_test_4.err
1389
1390 plugin_test_4.a: two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms
1391         $(TEST_AR) cr $@ $^
1392
1393 check_PROGRAMS += plugin_test_5
1394 plugin_test_5: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms unused.syms gcctestdir/ld plugin_test.so
1395         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv",--gc-sections two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms unused.syms
1396
1397 check_PROGRAMS += plugin_test_6
1398 check_SCRIPTS += plugin_test_6.sh
1399 check_DATA += plugin_test_6.err
1400 MOSTLYCLEANFILES += plugin_test_6.err
1401 plugin_test_6: plugin_common_test_1.syms plugin_common_test_2.syms gcctestdir/ld plugin_test.so
1402         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.syms plugin_common_test_2.syms 2>plugin_test_6.err
1403 plugin_test_6.err: plugin_test_6
1404         @touch plugin_test_6.err
1405
1406 check_PROGRAMS += plugin_test_7
1407 check_SCRIPTS += plugin_test_7.sh
1408 check_DATA += plugin_test_7.err plugin_test_7.syms
1409 MOSTLYCLEANFILES += plugin_test_7.err
1410 plugin_test_7: plugin_test_7_1.o plugin_test_7_1.syms plugin_test_7_2.o gcctestdir/ld plugin_test.so
1411         $(LINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--gc-sections,--print-gc-sections plugin_test_7_1.syms plugin_test_7_2.o 2>plugin_test_7.err
1412 plugin_test_7.syms: plugin_test_7
1413         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1414 plugin_test_7_1.o: plugin_test_7_1.c
1415         $(COMPILE) -DLTO -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1416 plugin_test_7_1_orig.o: plugin_test_7_1.c
1417         $(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1418 plugin_test_7_1.syms: plugin_test_7_1_orig.o
1419         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1420 plugin_test_7_2.o: plugin_test_7_2.c
1421         $(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1422 plugin_test_7.err: plugin_test_7
1423
1424 # Test plugins with -r.
1425 check_PROGRAMS += plugin_test_8
1426 plugin_test_8.o: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.o ../ld-new plugin_test.so
1427         ../ld-new -r -o $@ --no-demangle --plugin "./plugin_test.so" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.o
1428 plugin_test_8: plugin_test_8.o gcctestdir/ld
1429         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle plugin_test_8.o
1430
1431 # Test that symbols known in the IR file but not in the replacement file
1432 # produce an unresolved symbol error.
1433 check_DATA += plugin_test_9.err
1434 MOSTLYCLEANFILES += plugin_test_9.err
1435 plugin_test_9.err: two_file_test_main.o two_file_test_1c.syms two_file_test_2.syms gcctestdir/ld plugin_test.so
1436         @echo $(CXXLINK) -Bgcctestdir/ -o plugin_test_9 -Wl,--no-demangle,--plugin,"./plugin_test.so" two_file_test_main.o two_file_test_1c.syms two_file_test_2.syms "2>$@"
1437         @if $(CXXLINK) -Bgcctestdir/ -o plugin_test_9 -Wl,--no-demangle,--plugin,"./plugin_test.so" two_file_test_main.o two_file_test_1c.syms two_file_test_2.syms 2>$@; then \
1438           echo 1>&2 "Link of plugin_test_9 should have failed"; \
1439           rm -f $@; \
1440           exit 1; \
1441         fi
1442 # Make a .syms file that claims to define the symbol _Z4t16av.
1443 two_file_test_1c.syms: two_file_test_1.syms two_file_test_1c.o
1444         cp two_file_test_1.syms $@.tmp
1445         grep "_Z4t16av" two_file_test_1b.syms >> $@.tmp
1446         mv -f $@.tmp $@
1447 # Make a copy of two_file_test_1.o, which does not define the symbol _Z4t16av.
1448 MOSTLYCLEANFILES += two_file_test_1c.o
1449 two_file_test_1c.o: two_file_test_1.o
1450         cp two_file_test_1.o $@
1451
1452 plugin_test.so: plugin_test.o
1453         $(LINK) -Bgcctestdir/ -shared plugin_test.o
1454 plugin_test.o: plugin_test.c
1455         $(COMPILE) -O0 -c -fpic -o $@ $<
1456
1457 two_file_test_main.syms: two_file_test_main.o
1458         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1459 two_file_test_1.syms: two_file_test_1.o
1460         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1461 two_file_test_1b.syms: two_file_test_1b.o
1462         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1463 two_file_test_2.syms: two_file_test_2.o
1464         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1465 plugin_common_test_1.syms: plugin_common_test_1.o
1466         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1467 plugin_common_test_2.syms: plugin_common_test_2.o
1468         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1469
1470 empty.syms:
1471         @echo "" >$@
1472         @echo "Symbol table" >>$@
1473
1474 MOSTLYCLEANFILES += unused.c
1475 unused.syms: unused.o
1476         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1477         @echo "     1: 00000000     4 FUNC    GLOBAL DEFAULT    1 UNUSED" >>$@
1478 unused.o: unused.c
1479         $(COMPILE) -c -o $@ $<
1480 unused.c:
1481         @cp /dev/null $@
1482
1483 endif PLUGINS
1484
1485 check_PROGRAMS += exclude_libs_test
1486 check_SCRIPTS += exclude_libs_test.sh
1487 check_DATA += exclude_libs_test.syms
1488 MOSTLYCLEANFILES += exclude_libs_test.syms libexclude_libs_test_1.a \
1489         libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
1490 exclude_libs_test_SOURCES = exclude_libs_test.c
1491 exclude_libs_test_DEPENDENCIES = gcctestdir/ld libexclude_libs_test_1.a \
1492         libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
1493 exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. -Lalt \
1494         -Wl,--exclude-libs,dummy:libexclude_libs_test_1 \
1495         -Wl,--exclude-libs,libexclude_libs_test_3
1496 exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 \
1497         alt/libexclude_libs_test_3.a
1498 exclude_libs_test.syms: exclude_libs_test
1499         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1500 libexclude_libs_test_1.a: exclude_libs_test_1.o
1501         $(TEST_AR) rc $@ $^
1502 libexclude_libs_test_2.a: exclude_libs_test_2.o
1503         $(TEST_AR) rc $@ $^
1504 alt/libexclude_libs_test_3.a: exclude_libs_test_3.o
1505         test -d alt || mkdir -p alt
1506         $(TEST_AR) rc $@ $^
1507
1508 check_PROGRAMS += local_labels_test
1509 local_labels_test.o: ver_test_6.c
1510         $(COMPILE) -g -c -Wa,-L -o $@ $<
1511 local_labels_test: local_labels_test.o
1512         $(LINK) -Bgcctestdir/ local_labels_test.o
1513
1514 check_PROGRAMS += discard_locals_test
1515 check_SCRIPTS += discard_locals_test.sh
1516 check_DATA += discard_locals_test.syms \
1517         discard_locals_relocatable_test1.syms \
1518         discard_locals_relocatable_test2.syms
1519 MOSTLYCLEANFILES += discard_locals_test.syms \
1520         discard_locals_relocatable_test1.syms \
1521         discard_locals_relocatable_test2.syms \
1522         discard_locals_relocatable_test1.out \
1523         discard_locals_relocatable_test2.out
1524 discard_locals_test_SOURCES = discard_locals_test.c
1525 discard_locals_test_LDFLAGS = -Bgcctestdir/ -Wl,--discard-locals
1526 discard_locals_test.syms: discard_locals_test
1527         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1528 # '-Wa,-L' is required to preserve the local label used for testing.
1529 discard_locals_test.o: discard_locals_test.c
1530         $(COMPILE) -c -Wa,-L -o $@ $<
1531
1532 discard_locals_relocatable_test1.syms: discard_locals_relocatable_test1.out
1533         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1534 discard_locals_relocatable_test.o: discard_locals_relocatable_test.c
1535         $(COMPILE) -c -Wa,-L -fPIC -o $@ $<
1536 discard_locals_relocatable_test1.out: discard_locals_relocatable_test.o ../ld-new
1537         ../ld-new --discard-locals -relocatable -o $@ $<
1538
1539 discard_locals_relocatable_test2.syms: discard_locals_relocatable_test2.out
1540         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1541 discard_locals_relocatable_test2.out: discard_locals_relocatable_test.o ../ld-new
1542         ../ld-new --discard-all -relocatable -o $@ $<
1543
1544 if MCMODEL_MEDIUM
1545 check_PROGRAMS += large
1546 large_SOURCES = large.c
1547 large_CFLAGS = -mcmodel=medium
1548 large_DEPENDENCIES = gcctestdir/ld
1549 large_LDFLAGS = -Bgcctestdir/
1550 large_LDADD =
1551 endif MCMODEL_MEDIUM
1552
1553 # Test that hidden and internal symbols in the main program cannot be
1554 # referenced by a shared library.
1555 check_SCRIPTS += hidden_test.sh
1556 check_DATA += hidden_test.err
1557 MOSTLYCLEANFILES += hidden_test hidden_test.err
1558 libhidden.so: hidden_test_1.c gcctestdir/ld
1559         $(COMPILE) -Bgcctestdir/ -g -shared -fPIC -w -o $@ $(srcdir)/hidden_test_1.c
1560 hidden_test: hidden_test_main.o libhidden.so gcctestdir/ld
1561         $(LINK) -Bgcctestdir/ -Wl,-R,. hidden_test_main.o libhidden.so 2>hidden_test.err
1562 hidden_test.err: hidden_test
1563         @touch hidden_test.err
1564
1565 # Test -retain-symbols-file.
1566 check_SCRIPTS += retain_symbols_file_test.sh
1567 check_DATA += retain_symbols_file_test.stdout
1568 MOSTLYCLEANFILES += retain_symbols_file_test retain_symbols_file_test.in \
1569                     retain_symbols_file_test.stdout
1570 retain_symbols_file_test.so: basic_pic_test.o gcctestdir/ld
1571         echo 'main' > retain_symbols_file_test.in
1572         echo 't1' >> retain_symbols_file_test.in
1573         echo '_ZN4t16bC1Ev' >> retain_symbols_file_test.in
1574         echo '_ZNK4t20a3getEv' >> retain_symbols_file_test.in
1575         echo '_Z3t18v' >> retain_symbols_file_test.in
1576         echo '__tcf_0' >> retain_symbols_file_test.in   
1577         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-retain-symbols-file,retain_symbols_file_test.in basic_pic_test.o
1578 retain_symbols_file_test.stdout: retain_symbols_file_test.so
1579         $(TEST_NM) -C retain_symbols_file_test.so > $@
1580
1581
1582 # Test that if the output file already exists and is empty,
1583 # it will get execute permission.
1584 check_PROGRAMS += permission_test
1585 permission_test: basic_test.o gcctestdir/ld
1586         umask 022; \
1587         rm -f $@; \
1588         touch $@; \
1589         chmod 600 $@; \
1590         $(CXXLINK) -Bgcctestdir/ basic_test.o
1591
1592 # Check -l:foo.a
1593 check_PROGRAMS += searched_file_test
1594 MOSTLYCLEANFILES += searched_file_test searched_file_test_lib.o \
1595                     alt/searched_file_test_lib.a
1596 searched_file_test_SOURCES = searched_file_test.cc
1597 searched_file_test_DEPENDENCIES = alt/searched_file_test_lib.a
1598 searched_file_test_LDFLAGS = -Bgcctestdir/ -Lalt
1599 searched_file_test_LDADD = -l:searched_file_test_lib.a
1600 searched_file_test_lib.o: searched_file_test_lib.cc
1601         $(CXXCOMPILE) -c -o $@ $<
1602 alt/searched_file_test_lib.a: searched_file_test_lib.o
1603         test -d alt || mkdir -p alt
1604         $(TEST_AR) rc $@ $^
1605
1606 # Test that no .gnu.version sections are created when 
1607 # symbol versioning is not used.
1608 check_SCRIPTS += no_version_test.sh
1609 check_DATA += no_version_test.stdout
1610 MOSTLYCLEANFILES += libno_version_test.so no_version_test.stdout
1611 # We invoke the linker directly since gcc may include additional objects that
1612 # uses symbol versioning.
1613 libno_version_test.so: no_version_test.o gcctestdir/ld
1614         gcctestdir/ld -shared -o $@ no_version_test.o
1615 no_version_test.o: no_version_test.c
1616         $(COMPILE) -o $@ -c -fPIC $<
1617 no_version_test.stdout: libno_version_test.so
1618         $(TEST_OBJDUMP) -h $< > $@
1619
1620 # Test STT_GNU_IFUNC symbols.
1621 if IFUNC
1622
1623 ifuncmod1.o: ifuncmod1.c
1624         $(COMPILE) -c -fpic -o $@ $<
1625 ifuncmod1.so: ifuncmod1.o gcctestdir/ld
1626         $(LINK) -Bgcctestdir/ -shared ifuncmod1.o
1627
1628 ifuncdep1.o: ifuncmod1.c
1629         $(COMPILE) -c -o $@ $<
1630
1631 ifuncmain1pic.o: ifuncmain1.c
1632         $(COMPILE) -c -fpic -o $@ $<
1633 ifuncmain1pie.o: ifuncmain1.c
1634         $(COMPILE) -c -fpie -o $@ $<
1635
1636 if HAVE_STATIC
1637 check_PROGRAMS += ifuncmain1static
1638 ifuncmain1static_SOURCES = ifuncmain1.c
1639 ifuncmain1static_DEPENDENCIES = gcctestdir/ld ifuncdep1.o
1640 ifuncmain1static_LDFLAGS = -Bgcctestdir/ -static
1641 ifuncmain1static_LDADD = ifuncdep1.o
1642
1643 check_PROGRAMS += ifuncmain1picstatic
1644 ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
1645         $(LINK) -Bgcctestdir/ -static ifuncmain1pic.o ifuncmod1.o
1646 endif
1647
1648 check_PROGRAMS += ifuncmain1
1649 ifuncmain1_SOURCES = ifuncmain1.c
1650 ifuncmain1_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
1651 ifuncmain1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1652 ifuncmain1_LDADD = ifuncmod1.so
1653
1654 check_PROGRAMS += ifuncmain1pic
1655 ifuncmain1pic: ifuncmain1pic.o ifuncmod1.so gcctestdir/ld
1656         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
1657
1658 check_PROGRAMS += ifuncmain1vis
1659 ifuncmain1vis_SOURCES = ifuncmain1vis.c
1660 ifuncmain1vis_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
1661 ifuncmain1vis_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1662 ifuncmain1vis_LDADD = ifuncmod1.so
1663
1664 check_PROGRAMS += ifuncmain1vispic
1665 ifuncmain1vispic.o: ifuncmain1vis.c
1666         $(COMPILE) -c -fpic -o $@ $<
1667 ifuncmain1vispic: ifuncmain1vispic.o ifuncmod1.so gcctestdir/ld
1668         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
1669
1670 check_PROGRAMS += ifuncmain1staticpic
1671 ifuncmain1staticpic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
1672         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.o
1673
1674 check_PROGRAMS += ifuncmain1pie
1675 ifuncmain1pie: ifuncmain1pie.o ifuncmod1.so gcctestdir/ld
1676         $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.so -Wl,-R,.
1677
1678 check_PROGRAMS += ifuncmain1vispie
1679 ifuncmain1vispie.o: ifuncmain1vis.c
1680         $(COMPILE) -c -fpie -o $@ $<
1681 ifuncmain1vispie: ifuncmain1vispie.o ifuncmod1.so gcctestdir/ld
1682         $(LINK) -Bgcctestdir/ -pie ifuncmain1vispie.o ifuncmod1.so -Wl,-R,.
1683
1684 check_PROGRAMS += ifuncmain1staticpie
1685 ifuncmain1staticpie: ifuncmain1pie.o ifuncmod1.o gcctestdir/ld
1686         $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.o
1687
1688 ifuncmain2pic.o: ifuncmain2.c
1689         $(COMPILE) -c -fpic -o $@ $<
1690
1691 ifuncdep2pic.o: ifuncdep2.c
1692         $(COMPILE) -c -fpic -o $@ $<
1693
1694 if HAVE_STATIC
1695 check_PROGRAMS += ifuncmain2static
1696 ifuncmain2static_SOURCES = ifuncmain2.c ifuncdep2.c
1697 ifuncmain2static_DEPENDENCIES = gcctestdir/ld
1698 ifuncmain2static_LDFLAGS = -Bgcctestdir/ -static
1699 ifuncmain2static_LDADD =
1700
1701 check_PROGRAMS += ifuncmain2picstatic
1702 ifuncmain2picstatic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
1703         $(LINK) -Bgcctestdir/ -static ifuncmain2pic.o ifuncdep2pic.o
1704 endif
1705
1706 check_PROGRAMS += ifuncmain2
1707 ifuncmain2_SOURCES = ifuncmain2.c ifuncdep2.c
1708 ifuncmain2_DEPENDENCIES = gcctestdir/ld
1709 ifuncmain2_LDFLAGS = -Bgcctestdir/
1710 ifuncmain2_LDADD =
1711
1712 check_PROGRAMS += ifuncmain2pic
1713 ifuncmain2pic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
1714         $(LINK) -Bgcctestdir/ ifuncmain2pic.o ifuncdep2pic.o
1715
1716 ifuncmod3.o: ifuncmod3.c
1717         $(COMPILE) -c -fpic -o $@ $<
1718 ifuncmod3.so: ifuncmod3.o gcctestdir/ld
1719         $(LINK) -Bgcctestdir/ -shared ifuncmod3.o
1720
1721 check_PROGRAMS += ifuncmain3
1722 ifuncmain3_SOURCES = ifuncmain3.c
1723 ifuncmain3_DEPENDENCIES = gcctestdir/ld ifuncmod3.so
1724 ifuncmain3_LDFLAGS = -Bgcctestdir/ -Wl,--export-dynamic -Wl,-R,.
1725 ifuncmain3_LDADD = -ldl
1726
1727 ifuncmain4pic.o: ifuncmain4.c
1728         $(COMPILE) -c -fpic -o $@ $<
1729
1730 if HAVE_STATIC
1731 check_PROGRAMS += ifuncmain4static
1732 ifuncmain4static_SOURCES = ifuncmain4.c
1733 ifuncmain4static_DEPENDENCIES = gcctestdir/ld
1734 ifuncmain4static_LDFLAGS = -Bgcctestdir/ -static
1735 ifuncmain4static_LDADD =
1736
1737 check_PROGRAMS += ifuncmain4picstatic
1738 ifuncmain4picstatic: ifuncmain4pic.o gcctestdir/ld
1739         $(LINK) -Bgcctestdir/ -static ifuncmain4pic.o
1740 endif
1741
1742 check_PROGRAMS += ifuncmain4
1743 ifuncmain4_SOURCES = ifuncmain4.c
1744 ifuncmain4_DEPENDENCIES = gcctestdir/ld
1745 ifuncmain4_LDFLAGS = -Bgcctestdir/
1746 ifuncmain4_LDADD =
1747
1748 ifuncmain5pic.o: ifuncmain5.c
1749         $(COMPILE) -c -fpic -o $@ $<
1750
1751 ifuncmain5pie.o: ifuncmain5.c
1752         $(COMPILE) -c -fpie -o $@ $<
1753
1754 ifuncmod5.o: ifuncmod5.c
1755         $(COMPILE) -c -fpic -o $@ $<
1756 ifuncmod5.so: ifuncmod5.o gcctestdir/ld
1757         $(LINK) -Bgcctestdir/ -shared ifuncmod5.o
1758
1759 ifuncdep5.o: ifuncmod5.c
1760         $(COMPILE) -c -o $@ $<
1761
1762 if HAVE_STATIC
1763 check_PROGRAMS += ifuncmain5static
1764 ifuncmain5static_SOURCES = ifuncmain5.c
1765 ifuncmain5static_DEPENDENCIES = gcctestdir/ld ifuncdep5.o
1766 ifuncmain5static_LDFLAGS = -Bgcctestdir/ -static
1767 ifuncmain5static_LDADD = ifuncdep5.o
1768
1769 check_PROGRAMS += ifuncmain5picstatic
1770 ifuncmain5picstatic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
1771         $(LINK) -Bgcctestdir/ -static ifuncmain5pic.o ifuncmod5.o
1772 endif
1773
1774 check_PROGRAMS += ifuncmain5
1775 ifuncmain5_SOURCES = ifuncmain5.c
1776 ifuncmain5_DEPENDENCIES = gcctestdir/ld ifuncmod5.so
1777 ifuncmain5_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1778 ifuncmain5_LDADD = ifuncmod5.so
1779
1780 check_PROGRAMS += ifuncmain5pic
1781 ifuncmain5pic: ifuncmain5pic.o ifuncmod5.so gcctestdir/ld
1782         $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.so -Wl,-R,.
1783
1784 check_PROGRAMS += ifuncmain5staticpic
1785 ifuncmain5staticpic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
1786         $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.o
1787
1788 check_PROGRAMS += ifuncmain5pie
1789 ifuncmain5pie: ifuncmain5pie.o ifuncmod5.so gcctestdir/ld
1790         $(LINK) -Bgcctestdir/ -pie ifuncmain5pie.o ifuncmod5.so -Wl,-R,.
1791
1792 ifuncmain6pie.o: ifuncmain6pie.c
1793         $(COMPILE) -c -fpie -o $@ $<
1794
1795 ifuncmod6.o: ifuncmod6.c
1796         $(COMPILE) -c -fpic -o $@ $<
1797 ifuncmod6.so: ifuncmod6.o gcctestdir/ld
1798         $(LINK) -Bgcctestdir/ -shared ifuncmod6.o
1799
1800 check_PROGRAMS += ifuncmain6pie
1801 ifuncmain6pie: ifuncmain6pie.o ifuncmod6.so gcctestdir/ld
1802         $(LINK) -Bgcctestdir/ -pie ifuncmain6pie.o ifuncmod6.so -Wl,-R,.
1803
1804 ifuncmain7pic.o: ifuncmain7.c
1805         $(COMPILE) -c -fpic -o $@ $<
1806
1807 ifuncmain7pie.o: ifuncmain7.c
1808         $(COMPILE) -c -fpie -o $@ $<
1809
1810 if HAVE_STATIC
1811 check_PROGRAMS += ifuncmain7static
1812 ifuncmain7static_SOURCES = ifuncmain7.c
1813 ifuncmain7static_DEPENDENCIES = gcctestdir/ld
1814 ifuncmain7static_LDFLAGS = -Bgcctestdir/ -static
1815 ifuncmain7static_LDADD =
1816
1817 check_PROGRAMS += ifuncmain7picstatic
1818 ifuncmain7picstatic: ifuncmain7pic.o gcctestdir/ld
1819         $(LINK) -Bgcctestdir/ -static ifuncmain7pic.o
1820 endif
1821
1822 check_PROGRAMS += ifuncmain7
1823 ifuncmain7_SOURCES = ifuncmain7.c
1824 ifuncmain7_DEPENDENCIES = gcctestdir/ld
1825 ifuncmain7_LDFLAGS = -Bgcctestdir/
1826 ifuncmain7_LDADD =
1827
1828 check_PROGRAMS += ifuncmain7pic
1829 ifuncmain7pic: ifuncmain7pic.o gcctestdir/ld
1830         $(LINK) -Bgcctestdir/ ifuncmain7pic.o
1831
1832 check_PROGRAMS += ifuncmain7pie
1833 ifuncmain7pie: ifuncmain7pie.o gcctestdir/ld
1834         $(LINK) -Bgcctestdir/ -pie ifuncmain7pie.o
1835
1836 endif IFUNC
1837
1838 # Test that strong reference to a weak symbol in a DSO remains strong.
1839 check_SCRIPTS += strong_ref_weak_def.sh
1840 check_DATA += strong_ref_weak_def.stdout
1841 MOSTLYCLEANFILES += strong_ref_weak_def_1.so strong_ref_weak_def_2.so \
1842         strong_ref_weak_def.stdout
1843 strong_ref_weak_def_2.o: strong_ref_weak_def_2.c
1844         $(COMPILE) -o $@ -c -fPIC $<
1845 strong_ref_weak_def_2.so: strong_ref_weak_def_2.o gcctestdir/ld
1846         gcctestdir/ld -shared -o $@ strong_ref_weak_def_2.o
1847 strong_ref_weak_def_1.o: strong_ref_weak_def_1.c
1848         $(COMPILE) -o $@ -c -fPIC $<
1849 strong_ref_weak_def_1.so: strong_ref_weak_def_1.o strong_ref_weak_def_2.so \
1850         gcctestdir/ld
1851         gcctestdir/ld -shared -o $@ strong_ref_weak_def_1.o \
1852                 strong_ref_weak_def_2.so
1853 strong_ref_weak_def.stdout: strong_ref_weak_def_1.so
1854         $(TEST_READELF) -sWD $< > $@
1855
1856 # Test that a strong weak reference remains strong if there is another
1857 # weak reference in a DSO.
1858 check_SCRIPTS += dyn_weak_ref.sh
1859 check_DATA += dyn_weak_ref.stdout
1860 MOSTLYCLEANFILES += dyn_weak_ref_1.so dyn_weak_ref_2.so \
1861         dyn_weak_ref.stdout
1862 dyn_weak_ref_2.o: dyn_weak_ref_2.c
1863         $(COMPILE) -o $@ -c -fPIC $<
1864 dyn_weak_ref_2.so: dyn_weak_ref_2.o gcctestdir/ld
1865         gcctestdir/ld -shared -o $@ dyn_weak_ref_2.o
1866 dyn_weak_ref_1.o: dyn_weak_ref_1.c
1867         $(COMPILE) -o $@ -c -fPIC $<
1868 # We intentionally put dyn_weak_ref_2.so in front of dyn_weak_ref_1.o
1869 # so that the weak ref there goes to gold's symbol table first.
1870 dyn_weak_ref_1.so: dyn_weak_ref_1.o dyn_weak_ref_2.so gcctestdir/ld
1871         gcctestdir/ld -shared -o $@ dyn_weak_ref_2.so dyn_weak_ref_1.o
1872 dyn_weak_ref.stdout: dyn_weak_ref_1.so
1873         $(TEST_READELF) -sWD $< > $@
1874
1875
1876 # Test that --start-lib and --end-lib function correctly.
1877 check_PROGRAMS += start_lib_test
1878 start_lib_test: start_lib_test_main.o libstart_lib_test.a start_lib_test_2.o start_lib_test_3.o \
1879         gcctestdir/ld
1880         $(LINK) -Bgcctestdir/ -o $@ start_lib_test_main.o -L. -lstart_lib_test \
1881                 -Wl,--start-lib start_lib_test_2.o start_lib_test_3.o -Wl,--end-lib
1882 libstart_lib_test.a: start_lib_test_1.o
1883         $(TEST_AR) rc $@ $^
1884
1885 # Test that MEMORY region support works.
1886 check_SCRIPTS += memory_test.sh
1887 check_DATA += memory_test.stdout
1888 MOSTLYCLEANFILES += memory_test.stdout memory_test memory_test.o
1889 memory_test.o: memory_test.s
1890         $(COMPILE) -o $@ -c $<
1891 memory_test: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t
1892         $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -T $(srcdir)/memory_test.t -o $@ memory_test.o
1893 memory_test.stdout: memory_test
1894         $(TEST_READELF) -lWS  $< > $@
1895
1896 # End-to-end incremental linking tests.
1897 # Incremental linking is currently supported only on the x86_64 target.
1898
1899 if DEFAULT_TARGET_X86_64
1900
1901 check_PROGRAMS += incremental_test_2
1902 MOSTLYCLEANFILES += two_file_test_tmp_2.o
1903 incremental_test_2: two_file_test_1_v1.o two_file_test_1.o two_file_test_1b.o \
1904                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
1905         cp -f two_file_test_1_v1.o two_file_test_tmp_2.o
1906         $(CXXLINK) -Wl,--incremental-full -Bgcctestdir/ two_file_test_tmp_2.o two_file_test_1b.o two_file_test_2.o two_file_test_main.o
1907         @sleep 1
1908         cp -f two_file_test_1.o two_file_test_tmp_2.o
1909         $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ two_file_test_tmp_2.o two_file_test_1b.o two_file_test_2.o two_file_test_main.o
1910
1911 check_PROGRAMS += incremental_test_3
1912 MOSTLYCLEANFILES += two_file_test_tmp_3.o
1913 incremental_test_3: two_file_test_1.o two_file_test_1b_v1.o two_file_test_1b.o \
1914                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
1915         cp -f two_file_test_1b_v1.o two_file_test_tmp_3.o
1916         $(CXXLINK) -Wl,--incremental-full -Bgcctestdir/ two_file_test_1.o two_file_test_tmp_3.o two_file_test_2.o two_file_test_main.o
1917         @sleep 1
1918         cp -f two_file_test_1b.o two_file_test_tmp_3.o
1919         $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ two_file_test_1.o two_file_test_tmp_3.o two_file_test_2.o two_file_test_main.o
1920
1921 check_PROGRAMS += incremental_test_4
1922 MOSTLYCLEANFILES += incremental_test_4.base two_file_test_tmp_4.o
1923 incremental_test_4: two_file_test_1.o two_file_test_1b.o two_file_test_2_v1.o \
1924                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
1925         cp -f two_file_test_2_v1.o two_file_test_tmp_4.o
1926         $(CXXLINK) -Wl,--incremental-full -Bgcctestdir/ two_file_test_1.o two_file_test_1b.o two_file_test_tmp_4.o two_file_test_main.o
1927         mv -f incremental_test_4 incremental_test_4.base
1928         @sleep 1
1929         cp -f two_file_test_2.o two_file_test_tmp_4.o
1930         $(CXXLINK) -Wl,--incremental-update,--incremental-base=incremental_test_4.base -Bgcctestdir/ two_file_test_1.o two_file_test_1b.o two_file_test_tmp_4.o two_file_test_main.o
1931
1932 check_PROGRAMS += incremental_copy_test
1933 incremental_copy_test: copy_test_v1.o copy_test.o copy_test_1.so copy_test_2.so
1934         cp -f copy_test_v1.o copy_test_tmp.o
1935         $(CXXLINK) -Wl,--incremental-full -Bgcctestdir/ -Wl,-R,. copy_test_tmp.o copy_test_1.so copy_test_2.so
1936         @sleep 1
1937         cp -f copy_test.o copy_test_tmp.o
1938         $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ -Wl,-R,. copy_test_tmp.o copy_test_1.so copy_test_2.so
1939
1940 check_PROGRAMS += incremental_common_test_1
1941 incremental_common_test_1: common_test_1_v1.o common_test_1_v2.o gcctestdir/ld
1942         cp -f common_test_1_v1.o common_test_1_tmp.o
1943         $(CXXLINK) -Wl,--incremental-full -Bgcctestdir/ common_test_1_tmp.o
1944         @sleep 1
1945         cp -f common_test_1_v2.o common_test_1_tmp.o
1946         $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ common_test_1_tmp.o
1947
1948 endif DEFAULT_TARGET_X86_64
1949
1950 endif GCC
1951 endif NATIVE_LINKER
1952
1953 # These tests work with native and cross linkers.
1954
1955 if NATIVE_OR_CROSS_LINKER
1956
1957 # Test script section order.
1958 check_SCRIPTS += script_test_10.sh
1959 check_DATA += script_test_10.stdout
1960 script_test_10.o: script_test_10.s
1961         $(TEST_AS) -o $@ $<
1962 script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld
1963         gcctestdir/ld -o $@ script_test_10.o -T $(srcdir)/script_test_10.t
1964 script_test_10.stdout: script_test_10
1965         $(TEST_READELF) -SW script_test_10 > $@
1966
1967 # These tests work with cross linkers only.
1968
1969 if DEFAULT_TARGET_I386
1970
1971 check_SCRIPTS += split_i386.sh
1972 check_DATA += split_i386_1.stdout split_i386_2.stdout \
1973         split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout
1974 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
1975 split_i386_1.o: split_i386_1.s
1976         $(TEST_AS) -o $@ $<
1977 split_i386_2.o: split_i386_2.s
1978         $(TEST_AS) -o $@ $<
1979 split_i386_3.o: split_i386_3.s
1980         $(TEST_AS) -o $@ $<
1981 split_i386_4.o: split_i386_4.s
1982         $(TEST_AS) -o $@ $<
1983 split_i386_n.o: split_i386_n.s
1984         $(TEST_AS) -o $@ $<
1985 split_i386_1: split_i386_1.o split_i386_n.o ../ld-new
1986         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_1.o split_i386_n.o
1987 split_i386_1.stdout: split_i386_1
1988         $(TEST_OBJDUMP) -d $< > $@
1989 split_i386_2: split_i386_2.o split_i386_n.o ../ld-new
1990         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_2.o split_i386_n.o
1991 split_i386_2.stdout: split_i386_2
1992         $(TEST_OBJDUMP) -d $< > $@
1993 split_i386_3.stdout: split_i386_3.o split_i386_n.o ../ld-new
1994         ../ld-new $(SPLIT_DEFSYMS) -o split_i386_3 split_i386_3.o split_i386_n.o > $@ 2>&1 || exit 0
1995 split_i386_4: split_i386_4.o split_i386_n.o ../ld-new
1996         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_4.o split_i386_n.o
1997 split_i386_4.stdout: split_i386_4
1998         $(TEST_OBJDUMP) -d $< > $@
1999 split_i386_r.stdout: split_i386_1.o split_i386_n.o ../ld-new
2000         ../ld-new -r split_i386_1.o split_i386_n.o -o split_i386_r > $@ 2>&1 || exit 0
2001 MOSTLYCLEANFILES += split_i386_1 split_i386_2 split_i386_3 \
2002         split_i386_4 split_i386_r
2003
2004 endif DEFAULT_TARGET_I386
2005
2006 if DEFAULT_TARGET_X86_64
2007
2008 check_SCRIPTS += split_x86_64.sh
2009 check_DATA += split_x86_64_1.stdout split_x86_64_2.stdout \
2010         split_x86_64_3.stdout split_x86_64_4.stdout split_x86_64_r.stdout
2011 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
2012 split_x86_64_1.o: split_x86_64_1.s
2013         $(TEST_AS) -o $@ $<
2014 split_x86_64_2.o: split_x86_64_2.s
2015         $(TEST_AS) -o $@ $<
2016 split_x86_64_3.o: split_x86_64_3.s
2017         $(TEST_AS) -o $@ $<
2018 split_x86_64_4.o: split_x86_64_4.s
2019         $(TEST_AS) -o $@ $<
2020 split_x86_64_n.o: split_x86_64_n.s
2021         $(TEST_AS) -o $@ $<
2022 split_x86_64_1: split_x86_64_1.o split_x86_64_n.o ../ld-new
2023         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_1.o split_x86_64_n.o
2024 split_x86_64_1.stdout: split_x86_64_1
2025         $(TEST_OBJDUMP) -d $< > $@
2026 split_x86_64_2: split_x86_64_2.o split_x86_64_n.o ../ld-new
2027         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_2.o split_x86_64_n.o
2028 split_x86_64_2.stdout: split_x86_64_2
2029         $(TEST_OBJDUMP) -d $< > $@
2030 split_x86_64_3.stdout: split_x86_64_3.o split_x86_64_n.o ../ld-new
2031         ../ld-new $(SPLIT_DEFSYMS) -o split_x86_64_3 split_x86_64_3.o split_x86_64_n.o > $@ 2>&1 || exit 0
2032 split_x86_64_4: split_x86_64_4.o split_x86_64_n.o ../ld-new
2033         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_4.o split_x86_64_n.o
2034 split_x86_64_4.stdout: split_x86_64_4
2035         $(TEST_OBJDUMP) -d $< > $@
2036 split_x86_64_r.stdout: split_x86_64_1.o split_x86_64_n.o ../ld-new
2037         ../ld-new -r split_x86_64_1.o split_x86_64_n.o -o split_x86_64_r > $@ 2>&1 || exit 0
2038 MOSTLYCLEANFILES += split_x86_64_1 split_x86_64_2 split_x86_64_3 \
2039         split_x86_64_4 split_x86_64_r
2040
2041 endif DEFAULT_TARGET_X86_64
2042
2043 if DEFAULT_TARGET_ARM
2044
2045 check_SCRIPTS += arm_abs_global.sh
2046 check_DATA += arm_abs_global.stdout
2047 arm_abs_lib.o: arm_abs_lib.s
2048         $(TEST_AS) -march=armv7-a -o $@ $<
2049 libarm_abs.so: arm_abs_lib.o ../ld-new
2050         ../ld-new -shared -o $@ arm_abs_lib.o
2051 arm_abs_global.o: arm_abs_global.s
2052         $(TEST_AS) -march=armv7-a -o $@ $<
2053 arm_abs_global: arm_abs_global.o libarm_abs.so ../ld-new
2054         ../ld-new -o $@ arm_abs_global.o -L. -larm_abs
2055 arm_abs_global.stdout: arm_abs_global
2056         $(TEST_READELF) -r $< > $@
2057
2058 MOSTLYCLEANFILES += arm_abs_global
2059
2060 check_SCRIPTS += arm_branch_in_range.sh arm_branch_out_of_range.sh
2061 check_DATA += arm_bl_in_range.stdout arm_bl_out_of_range.stdout \
2062         thumb_bl_in_range.stdout thumb_bl_out_of_range.stdout \
2063         thumb2_bl_in_range.stdout thumb2_bl_out_of_range.stdout \
2064         thumb_blx_in_range.stdout thumb_blx_out_of_range.stdout \
2065         thumb2_blx_in_range.stdout thumb2_blx_out_of_range.stdout \
2066         thumb_bl_out_of_range_local.stdout arm_thm_jump11.stdout \
2067         arm_thm_jump8.stdout
2068
2069 arm_bl_in_range.stdout: arm_bl_in_range
2070         $(TEST_OBJDUMP) -D $< > $@
2071
2072 arm_bl_in_range: arm_bl_in_range.o ../ld-new
2073         ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2074
2075 arm_bl_in_range.o: arm_bl_in_range.s
2076         $(TEST_AS) -o $@ $<
2077
2078 arm_bl_out_of_range.stdout: arm_bl_out_of_range
2079         $(TEST_OBJDUMP) -S $< > $@
2080
2081 arm_bl_out_of_range: arm_bl_out_of_range.o ../ld-new
2082         ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2083
2084 arm_bl_out_of_range.o: arm_bl_out_of_range.s
2085         $(TEST_AS) -o $@ $<
2086
2087 thumb_bl_in_range.stdout: thumb_bl_in_range
2088         $(TEST_OBJDUMP) -D $< > $@
2089
2090 thumb_bl_in_range: thumb_bl_in_range.o ../ld-new
2091         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2092
2093 thumb_bl_in_range.o: thumb_bl_in_range.s
2094         $(TEST_AS) -o $@ -march=armv5te $<
2095
2096 thumb_bl_out_of_range.stdout: thumb_bl_out_of_range
2097         $(TEST_OBJDUMP) -D $< > $@
2098
2099 thumb_bl_out_of_range: thumb_bl_out_of_range.o ../ld-new
2100         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2101
2102 thumb_bl_out_of_range.o: thumb_bl_out_of_range.s
2103         $(TEST_AS) -o $@ -march=armv5te $<
2104
2105 thumb2_bl_in_range.stdout: thumb2_bl_in_range
2106         $(TEST_OBJDUMP) -D $< > $@
2107
2108 thumb2_bl_in_range: thumb2_bl_in_range.o ../ld-new
2109         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2110
2111 thumb2_bl_in_range.o: thumb_bl_in_range.s
2112         $(TEST_AS) -o $@ -march=armv7-a $<
2113
2114 thumb2_bl_out_of_range.stdout: thumb2_bl_out_of_range
2115         $(TEST_OBJDUMP) -D $< > $@
2116
2117 thumb2_bl_out_of_range: thumb2_bl_out_of_range.o ../ld-new
2118         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2119
2120 thumb2_bl_out_of_range.o: thumb_bl_out_of_range.s
2121         $(TEST_AS) -o $@ -march=armv7-a $<
2122
2123 thumb_blx_in_range.stdout: thumb_blx_in_range
2124         $(TEST_OBJDUMP) -D $< > $@
2125
2126 thumb_blx_in_range: thumb_blx_in_range.o ../ld-new
2127         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2128
2129 thumb_blx_in_range.o: thumb_blx_in_range.s
2130         $(TEST_AS) -o $@ -march=armv5te $<
2131
2132 thumb_blx_out_of_range.stdout: thumb_blx_out_of_range
2133         $(TEST_OBJDUMP) -D $< > $@
2134
2135 thumb_blx_out_of_range: thumb_blx_out_of_range.o ../ld-new
2136         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2137
2138 thumb_blx_out_of_range.o: thumb_blx_out_of_range.s
2139         $(TEST_AS) -o $@ -march=armv5te $<
2140
2141 thumb2_blx_in_range.stdout: thumb2_blx_in_range
2142         $(TEST_OBJDUMP) -D $< > $@
2143
2144 thumb2_blx_in_range: thumb2_blx_in_range.o ../ld-new
2145         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2146
2147 thumb2_blx_in_range.o: thumb_blx_in_range.s
2148         $(TEST_AS) -o $@ -march=armv7-a $<
2149
2150 thumb2_blx_out_of_range.stdout: thumb2_blx_out_of_range
2151         $(TEST_OBJDUMP) -D $< > $@
2152
2153 thumb2_blx_out_of_range: thumb2_blx_out_of_range.o ../ld-new
2154         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2155
2156 thumb2_blx_out_of_range.o: thumb_blx_out_of_range.s
2157         $(TEST_AS) -o $@ -march=armv7-a $<
2158
2159 thumb_bl_out_of_range_local.stdout: thumb_bl_out_of_range_local
2160         $(TEST_OBJDUMP) -D $< > $@
2161
2162 thumb_bl_out_of_range_local: thumb_bl_out_of_range_local.o ../ld-new
2163         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2164
2165 thumb_bl_out_of_range_local.o: thumb_bl_out_of_range_local.s
2166         $(TEST_AS) -o $@ -march=armv5te $<
2167
2168 arm_thm_jump11.stdout: arm_thm_jump11
2169         $(TEST_OBJDUMP) -D $< > $@
2170
2171 arm_thm_jump11: arm_thm_jump11.o ../ld-new
2172         ../ld-new -T $(srcdir)/arm_thm_jump11.t -o $@ $<
2173
2174 arm_thm_jump11.o: arm_thm_jump11.s
2175         $(TEST_AS) -o $@ $<
2176
2177 arm_thm_jump8.stdout: arm_thm_jump8
2178         $(TEST_OBJDUMP) -D $< > $@
2179
2180 arm_thm_jump8: arm_thm_jump8.o ../ld-new
2181         ../ld-new -T $(srcdir)/arm_thm_jump8.t -o $@ $<
2182
2183 arm_thm_jump8.o: arm_thm_jump8.s
2184         $(TEST_AS) -o $@ $<
2185
2186 MOSTLYCLEANFILES += arm_bl_in_range arm_bl_out_of_range thumb_bl_in_range \
2187         thumb_bl_out_of_range thumb2_bl_in_range thumb2_bl_out_of_range \
2188         thumb_blx_in_range thumb_blx_out_of_range thumb2_blx_in_range \
2189         thumb2_blx_out_of_range thumb_bl_out_of_range_local arm_thm_jump11 \
2190         arm_thm_jump8
2191
2192 check_SCRIPTS += arm_fix_v4bx.sh
2193 check_DATA += arm_fix_v4bx.stdout arm_fix_v4bx_interworking.stdout \
2194         arm_no_fix_v4bx.stdout
2195
2196 arm_fix_v4bx.stdout: arm_fix_v4bx
2197         $(TEST_OBJDUMP) -D -j.text $< > $@
2198
2199 arm_fix_v4bx: arm_fix_v4bx.o ../ld-new
2200         ../ld-new --fix-v4bx -o $@ $<
2201
2202 arm_fix_v4bx.o: arm_fix_v4bx.s
2203         $(TEST_AS) -o $@ $<
2204
2205 arm_fix_v4bx_interworking.stdout: arm_fix_v4bx_interworking
2206         $(TEST_OBJDUMP) -D -j.text $< > $@
2207
2208 arm_fix_v4bx_interworking: arm_fix_v4bx.o ../ld-new
2209         ../ld-new --fix-v4bx-interworking -o $@ $<
2210
2211 arm_no_fix_v4bx.stdout: arm_no_fix_v4bx
2212         $(TEST_OBJDUMP) -D -j.text $< > $@
2213
2214 arm_no_fix_v4bx: arm_fix_v4bx.o ../ld-new
2215         ../ld-new -o $@ $<
2216
2217 MOSTLYCLEANFILES += arm_fix_v4bx arm_fix_v4bx_interworking arm_no_fix_v4bx
2218
2219 check_SCRIPTS += arm_attr_merge.sh
2220 check_DATA += arm_attr_merge_6.stdout arm_attr_merge_6r.stdout \
2221         arm_attr_merge_7.stdout
2222
2223 arm_attr_merge_6.stdout: arm_attr_merge_6
2224         $(TEST_READELF) -A $< > $@
2225
2226 arm_attr_merge_6: arm_attr_merge_6a.o arm_attr_merge_6b.o
2227         ../ld-new -o $@ arm_attr_merge_6a.o arm_attr_merge_6b.o
2228
2229 arm_attr_merge_6a.o: arm_attr_merge_6a.s
2230         $(TEST_AS) -o $@ $<
2231
2232 arm_attr_merge_6b.o: arm_attr_merge_6b.s
2233         $(TEST_AS) -o $@ $<
2234
2235 arm_attr_merge_6r.stdout: arm_attr_merge_6r
2236         $(TEST_READELF) -A $< > $@
2237
2238 arm_attr_merge_6r: arm_attr_merge_6b.o arm_attr_merge_6a.o
2239         ../ld-new -o $@ arm_attr_merge_6b.o arm_attr_merge_6a.o
2240
2241 arm_attr_merge_7.stdout: arm_attr_merge_7
2242         $(TEST_READELF) -A $< > $@
2243
2244 arm_attr_merge_7: arm_attr_merge_7a.o arm_attr_merge_7b.o
2245         ../ld-new -o $@ arm_attr_merge_7a.o arm_attr_merge_7b.o
2246
2247 arm_attr_merge_7a.o: arm_attr_merge_7a.s
2248         $(TEST_AS) -o $@ $<
2249
2250 arm_attr_merge_7b.o: arm_attr_merge_7b.s
2251         $(TEST_AS) -o $@ $<
2252
2253 MOSTLYCLEANFILES += arm_attr_merge_6 arm_attr_merge_6r arm_attr_merge_7
2254
2255 # Cortex-A8 workaround test.
2256
2257 check_SCRIPTS += arm_cortex_a8.sh
2258 check_DATA += arm_cortex_a8_b_cond.stdout arm_cortex_a8_b.stdout \
2259         arm_cortex_a8_bl.stdout arm_cortex_a8_blx.stdout \
2260         arm_cortex_a8_local.stdout arm_cortex_a8_local_reloc.stdout
2261
2262 arm_cortex_a8_b_cond.stdout: arm_cortex_a8_b_cond
2263         $(TEST_OBJDUMP) -D -j.text $< > $@
2264
2265 arm_cortex_a8_b_cond: arm_cortex_a8_b_cond.o ../ld-new
2266         ../ld-new -o $@ $<
2267
2268 arm_cortex_a8_b_cond.o: arm_cortex_a8_b_cond.s
2269         $(TEST_AS) -o $@ $<
2270
2271 arm_cortex_a8_b.stdout: arm_cortex_a8_b
2272         $(TEST_OBJDUMP) -D -j.text $< > $@
2273
2274 arm_cortex_a8_b: arm_cortex_a8_b.o ../ld-new
2275         ../ld-new --fix-cortex-a8 -o $@ $<
2276
2277 arm_cortex_a8_b.o: arm_cortex_a8_b.s
2278         $(TEST_AS) -o $@ $<
2279
2280 arm_cortex_a8_bl.stdout: arm_cortex_a8_bl
2281         $(TEST_OBJDUMP) -D -j.text $< > $@
2282
2283 arm_cortex_a8_bl: arm_cortex_a8_bl.o ../ld-new
2284         ../ld-new -o $@ $<
2285
2286 arm_cortex_a8_bl.o: arm_cortex_a8_bl.s
2287         $(TEST_AS) -o $@ $<
2288
2289 arm_cortex_a8_blx.stdout: arm_cortex_a8_blx
2290         $(TEST_OBJDUMP) -D -j.text $< > $@
2291
2292 arm_cortex_a8_blx: arm_cortex_a8_blx.o ../ld-new
2293         ../ld-new -o $@ $<
2294
2295 arm_cortex_a8_blx.o: arm_cortex_a8_blx.s
2296         $(TEST_AS) -o $@ $<
2297
2298 arm_cortex_a8_local.stdout: arm_cortex_a8_local
2299         $(TEST_OBJDUMP) -D -j.text $< > $@
2300
2301 arm_cortex_a8_local: arm_cortex_a8_local.o ../ld-new
2302         ../ld-new -o $@ $<
2303
2304 arm_cortex_a8_local.o: arm_cortex_a8_local.s
2305         $(TEST_AS) -o $@ $<
2306
2307 arm_cortex_a8_local_reloc.stdout: arm_cortex_a8_local_reloc
2308         $(TEST_OBJDUMP) -D -j.text $< > $@
2309
2310 arm_cortex_a8_local_reloc: arm_cortex_a8_local_reloc.o ../ld-new
2311         ../ld-new -o $@ $<
2312
2313 arm_cortex_a8_local_reloc.o: arm_cortex_a8_local_reloc.s
2314         $(TEST_AS) -o $@ $<
2315
2316 MOSTLYCLEANFILES += arm_cortex_a8_b_cond arm_cortex_a8_b arm_cortex_a8_bl \
2317         arm_cortex_a8_blx arm_cortex_a8_local arm_cortex_a8_local_reloc
2318
2319 check_SCRIPTS += arm_exidx_test.sh
2320 check_DATA += arm_exidx_test.stdout
2321
2322 arm_exidx_test.stdout: arm_exidx_test.so
2323         $(TEST_READELF) -S $< > $@
2324
2325 arm_exidx_test.so: arm_exidx_test.o ../ld-new
2326         ../ld-new -shared -o $@ $<
2327
2328 arm_exidx_test.o: arm_exidx_test.s
2329         $(TEST_AS) -o $@ $<
2330
2331 check_SCRIPTS += pr12826.sh
2332 check_DATA += pr12826.stdout
2333
2334 pr12826.stdout: pr12826.so
2335         $(TEST_READELF) -A $< > $@
2336
2337 pr12826.so: pr12826_1.o pr12826_2.o ../ld-new
2338         ../ld-new -shared -o $@ $<
2339
2340 pr12826_1.o: pr12826_1.s
2341         $(TEST_AS) -o $@ $<
2342
2343 pr12826_2.o: pr12826_2.s
2344         $(TEST_AS) -o $@ $<
2345
2346 endif DEFAULT_TARGET_ARM
2347
2348 endif NATIVE_OR_CROSS_LINKER
2349