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
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
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
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
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
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
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
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
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
654 check_SCRIPTS += weak_plt.sh
655 check_PROGRAMS += weak_plt
656 check_DATA += weak_plt_shared.so
657 weak_plt_main_pic.o: weak_plt_main.cc
658         $(CXXCOMPILE) -c -fpic -o $@ $<
659 weak_plt: weak_plt_main_pic.o gcctestdir/ld
660         $(CXXLINK) -Bgcctestdir/ weak_plt_main_pic.o
661 weak_plt_shared_pic.o: weak_plt_shared.cc
662         $(CXXCOMPILE) -c -fpic -o $@ $<
663 weak_plt_shared.so: weak_plt_shared_pic.o gcctestdir/ld
664         $(CXXLINK) -Bgcctestdir/ -shared weak_plt_shared_pic.o
665
666 check_PROGRAMS += copy_test
667 copy_test_SOURCES = copy_test.cc
668 copy_test_DEPENDENCIES = gcctestdir/ld copy_test_1.so copy_test_2.so
669 copy_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
670 copy_test_LDADD = copy_test_1.so copy_test_2.so
671 copy_test_1_pic.o: copy_test_1.cc
672         $(CXXCOMPILE) -c -fpic -o $@ $<
673 copy_test_1.so: gcctestdir/ld copy_test_1_pic.o
674         $(CXXLINK) -Bgcctestdir/ -shared copy_test_1_pic.o
675 copy_test_2_pic.o: copy_test_2.cc
676         $(CXXCOMPILE) -c -fpic -o $@ $<
677 copy_test_2.so: gcctestdir/ld copy_test_2_pic.o
678         $(CXXLINK) -Bgcctestdir/ -shared copy_test_2_pic.o
679
680 if TLS
681
682 check_PROGRAMS += tls_test
683 check_PROGRAMS += tls_pic_test
684 check_PROGRAMS += tls_pie_test
685 check_PROGRAMS += tls_pie_pic_test
686 check_PROGRAMS += tls_shared_test
687 check_PROGRAMS += tls_shared_ie_test
688 check_PROGRAMS += tls_shared_gd_to_ie_test
689 tls_test_pic.o: tls_test.cc
690         $(CXXCOMPILE) -c -fpic -o $@ $<
691 tls_test_file2_pic.o: tls_test_file2.cc
692         $(CXXCOMPILE) -c -fpic -o $@ $<
693 tls_test_c_pic.o: tls_test_c.c
694         $(COMPILE) -c -fpic $(TLS_TEST_C_CFLAGS) -o $@ $<
695 tls_test_shared.so: tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o gcctestdir/ld
696         $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -Wl,-z,defs
697 tls_test_shared2.so: tls_test_file2_pic.o gcctestdir/ld
698         $(CXXLINK) -Bgcctestdir/ -shared tls_test_file2_pic.o
699
700 tls_test_pic_ie.o: tls_test.cc
701         $(CXXCOMPILE) -c -fpic -ftls-model=initial-exec -o $@ $<
702 tls_test_file2_pic_ie.o: tls_test_file2.cc
703         $(CXXCOMPILE) -c -fpic -ftls-model=initial-exec -o $@ $<
704 tls_test_c_pic_ie.o: tls_test_c.c
705         $(COMPILE) -c -fpic -ftls-model=initial-exec $(TLS_TEST_C_CFLAGS) -o $@ $<
706 tls_test_ie_shared.so: tls_test_pic_ie.o tls_test_file2_pic_ie.o tls_test_c_pic_ie.o gcctestdir/ld
707         $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic_ie.o tls_test_file2_pic_ie.o tls_test_c_pic_ie.o
708
709 tls_test_SOURCES = tls_test.cc tls_test_file2.cc tls_test_main.cc tls_test.h
710 tls_test_DEPENDENCIES = gcctestdir/ld tls_test_c.o
711 tls_test_LDFLAGS = -Bgcctestdir/
712 tls_test_LDADD = tls_test_c.o -lpthread
713 tls_test_c.o: tls_test_c.c
714         $(COMPILE) -c $(TLS_TEST_C_CFLAGS) -o $@ $<
715
716 tls_pic_test_SOURCES = tls_test_main.cc
717 tls_pic_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o tls_test_file2_pic.o \
718         tls_test_c_pic.o
719 tls_pic_test_LDFLAGS = -Bgcctestdir/
720 tls_pic_test_LDADD = tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o \
721         -lpthread
722
723 tls_test_main_pie.o: tls_test_main.cc tls_test.h
724         $(CXXCOMPILE) -c -fpie -o $@ $<
725 tls_test_pie.o: tls_test.cc tls_test.h
726         $(CXXCOMPILE) -c -fpie -o $@ $<
727 tls_test_file2_pie.o: tls_test_file2.cc tls_test.h
728         $(CXXCOMPILE) -c -fpie -o $@ $<
729 tls_test_c_pie.o: tls_test_c.c
730         $(COMPILE) -c -fpic $(TLS_TEST_C_CFLAGS) -o $@ $<
731 tls_pie_test: tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o \
732                 tls_test_c_pie.o gcctestdir/ld
733         $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o tls_test_c_pie.o -lpthread
734
735 tls_pie_pic_test: tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o \
736                 tls_test_c_pic.o gcctestdir/ld
737         $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -lpthread
738
739 tls_shared_test_SOURCES = tls_test_main.cc
740 tls_shared_test_DEPENDENCIES = gcctestdir/ld tls_test_shared.so
741 tls_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
742 tls_shared_test_LDADD = tls_test_shared.so -lpthread
743
744 tls_shared_ie_test_SOURCES = tls_test_main.cc
745 tls_shared_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_ie_shared.so
746 tls_shared_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
747 tls_shared_ie_test_LDADD = tls_test_ie_shared.so -lpthread
748
749 tls_shared_gd_to_ie_test_SOURCES = tls_test_main.cc
750 tls_shared_gd_to_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o \
751         tls_test_c_pic.o tls_test_shared2.so
752 tls_shared_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
753 tls_shared_gd_to_ie_test_LDADD = tls_test_pic.o tls_test_c_pic.o \
754         tls_test_shared2.so -lpthread
755
756 if TLS_GNU2_DIALECT
757
758 check_PROGRAMS += tls_shared_gnu2_gd_to_ie_test
759
760 tls_test_gnu2.o: tls_test.cc
761         $(CXXCOMPILE) -c -fpic -mtls-dialect=gnu2 -o $@ $<
762 tls_test_file2_gnu2.o: tls_test_file2.cc
763         $(CXXCOMPILE) -c -fpic -mtls-dialect=gnu2 -o $@ $<
764 tls_test_c_gnu2.o: tls_test_c.c
765         $(COMPILE) -c -fpic -mtls-dialect=gnu2 $(TLS_TEST_C_CFLAGS) -o $@ $<
766 tls_test_gnu2_shared2.so: tls_test_file2_gnu2.o gcctestdir/ld
767         $(CXXLINK) -Bgcctestdir/ -shared tls_test_file2_gnu2.o
768
769 tls_shared_gnu2_gd_to_ie_test_SOURCES = tls_test_main.cc
770 tls_shared_gnu2_gd_to_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_gnu2.o \
771         tls_test_c_gnu2.o tls_test_gnu2_shared2.so
772 tls_shared_gnu2_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
773 tls_shared_gnu2_gd_to_ie_test_LDADD = tls_test_gnu2.o tls_test_c_gnu2.o \
774         tls_test_gnu2_shared2.so -lpthread
775
776 if TLS_DESCRIPTORS
777
778 check_PROGRAMS += tls_shared_gnu2_test
779
780 tls_test_gnu2_shared.so: tls_test_gnu2.o tls_test_file2_gnu2.o tls_test_c_gnu2.o gcctestdir/ld
781         $(CXXLINK) -Bgcctestdir/ -shared tls_test_gnu2.o tls_test_file2_gnu2.o tls_test_c_gnu2.o
782
783 tls_shared_gnu2_test_SOURCES = tls_test_main.cc
784 tls_shared_gnu2_test_DEPENDENCIES = gcctestdir/ld tls_test_gnu2_shared.so
785 tls_shared_gnu2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
786 tls_shared_gnu2_test_LDADD = tls_test_gnu2_shared.so -lpthread
787
788 endif TLS_DESCRIPTORS
789
790 endif TLS_GNU2_DIALECT
791
792 if HAVE_STATIC
793 if STATIC_TLS
794 check_PROGRAMS += tls_static_test
795 check_PROGRAMS += tls_static_pic_test
796
797 tls_static_test_SOURCES = $(tls_test_SOURCES)
798 tls_static_test_DEPENDENCIES = $(tls_test_DEPENDENCIES)
799 tls_static_test_LDFLAGS = $(tls_test_LDFLAGS) -static
800 tls_static_test_LDADD = $(tls_test_LDADD)
801
802 tls_static_pic_test_SOURCES = $(tls_pic_test_SOURCES)
803 tls_static_pic_test_DEPENDENCIES = $(tls_pic_test_DEPENDENCIES)
804 tls_static_pic_test_LDFLAGS = $(tls_pic_test_LDFLAGS) -static
805 tls_static_pic_test_LDADD = $(tls_pic_test_LDADD)
806 endif
807 endif
808
809 if FN_PTRS_IN_SO_WITHOUT_PIC
810 check_PROGRAMS += tls_shared_nonpic_test
811 tls_test_shared_nonpic.so: tls_test.o tls_test_file2.o tls_test_c.o gcctestdir/ld
812         $(CXXLINK) -Bgcctestdir/ -shared tls_test.o tls_test_file2.o tls_test_c.o
813
814 tls_shared_nonpic_test_SOURCES = tls_test_main.cc
815 tls_shared_nonpic_test_DEPENDENCIES = gcctestdir/ld tls_test_shared_nonpic.so
816 tls_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
817 tls_shared_nonpic_test_LDADD = tls_test_shared_nonpic.so -lpthread
818 endif FN_PTRS_IN_SO_WITHOUT_PIC
819
820 endif TLS
821
822 check_PROGRAMS += many_sections_test
823 many_sections_test_SOURCES = many_sections_test.cc
824 many_sections_test_DEPENDENCIES = gcctestdir/ld
825 many_sections_test_LDFLAGS = -Bgcctestdir/ -rdynamic
826 many_sections_test_LDADD =
827
828 BUILT_SOURCES += many_sections_define.h
829 MOSTLYCLEANFILES += many_sections_define.h
830 many_sections_define.h:
831         (for i in `seq 1 70000`; do \
832            echo "int var_$$i __attribute__((section(\"section_$$i\"))) = $$i;"; \
833          done) > $@.tmp
834         mv -f $@.tmp $@
835
836 BUILT_SOURCES += many_sections_check.h
837 MOSTLYCLEANFILES += many_sections_check.h
838 many_sections_check.h:
839         (for i in `seq 1 1000 70000`; do \
840            echo "assert(var_$$i == $$i);"; \
841          done) > $@.tmp
842         mv -f $@.tmp $@
843
844 check_PROGRAMS += many_sections_r_test
845 many_sections_r_test.o: many_sections_test.o gcctestdir/ld
846         gcctestdir/ld -r -o $@ many_sections_test.o
847 many_sections_r_test: many_sections_r_test.o gcctestdir/ld
848         $(CXXLINK) -Bgcctestdir/ many_sections_r_test.o $(LIBS)
849
850 check_PROGRAMS += initpri1
851 initpri1_SOURCES = initpri1.c
852 initpri1_DEPENDENCIES = gcctestdir/ld
853 initpri1_LDFLAGS = -Bgcctestdir/
854 initpri1_LDADD =
855
856 check_PROGRAMS += initpri2
857 initpri2_SOURCES = initpri2.c
858 initpri2_DEPENDENCIES = gcctestdir/ld
859 initpri2_LDFLAGS = -Bgcctestdir/
860 initpri2_LDADD =
861
862 check_PROGRAMS += initpri3a
863 initpri3a_SOURCES = initpri3.c
864 initpri3a_DEPENDENCIES = gcctestdir/ld
865 initpri3a_LDFLAGS = -Bgcctestdir/
866 initpri3a_LDADD =
867
868 check_PROGRAMS += initpri3b
869 initpri3b_SOURCES = initpri3.c
870 initpri3b_DEPENDENCIES = gcctestdir/ld
871 initpri3b_LDFLAGS = -Bgcctestdir/ -Wl,--no-ctors-in-init-array
872 initpri3b_LDADD =
873
874 # Test --detect-odr-violations
875 check_SCRIPTS += debug_msg.sh
876
877 # Create the data files that debug_msg.sh analyzes.
878 check_DATA += debug_msg.err
879 MOSTLYCLEANFILES += debug_msg.err
880 debug_msg.o: debug_msg.cc
881         $(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/debug_msg.cc
882 odr_violation1.o: odr_violation1.cc
883         $(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/odr_violation1.cc
884 # Compile with different optimization flags to check that rearranged
885 # instructions don't cause a false positive.
886 odr_violation2.o: odr_violation2.cc
887         $(CXXCOMPILE) -O2 -g -c -w -o $@ $(srcdir)/odr_violation2.cc
888 debug_msg.err: debug_msg.o odr_violation1.o odr_violation2.o gcctestdir/ld
889         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o "2>$@"
890         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o 2>$@; \
891         then \
892           echo 1>&2 "Link of debug_msg should have failed"; \
893           rm -f $@; \
894           exit 1; \
895         fi
896
897
898 if HAVE_ZLIB
899
900 # Check that --detect-odr-violations works with compressed debug sections.
901 check_DATA += debug_msg_cdebug.err
902 MOSTLYCLEANFILES += debug_msg_cdebug.err
903 debug_msg_cdebug.o: debug_msg.cc gcctestdir/as
904         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/debug_msg.cc
905 odr_violation1_cdebug.o: odr_violation1.cc gcctestdir/as
906         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/odr_violation1.cc
907 odr_violation2_cdebug.o: odr_violation2.cc gcctestdir/as
908         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/odr_violation2.cc
909 debug_msg_cdebug.err: debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o gcctestdir/ld
910         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o "2>$@"
911         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o 2>$@; \
912         then \
913           echo 1>&2 "Link of debug_msg_cdebug should have failed"; \
914           rm -f $@; \
915           exit 1; \
916         fi
917
918 endif HAVE_ZLIB
919
920 # See if we can also detect problems when we're linking .so's, not .o's.
921 check_DATA += debug_msg_so.err
922 MOSTLYCLEANFILES += debug_msg_so.err
923 debug_msg.so: debug_msg.cc gcctestdir/ld
924         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
925 odr_violation1.so: odr_violation1.cc gcctestdir/ld
926         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
927 odr_violation2.so: odr_violation2.cc gcctestdir/ld
928         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
929 debug_msg_so.err: debug_msg.so odr_violation1.so odr_violation2.so gcctestdir/ld
930         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so "2>$@"
931         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so 2>$@; \
932         then \
933           echo 1>&2 "Link of debug_msg_so should have failed"; \
934           rm -f $@; \
935           exit 1; \
936         fi
937
938 # We also want to make sure we do something reasonable when there's no
939 # debug info available.  For the best test, we use .so's.
940 check_DATA += debug_msg_ndebug.err
941 MOSTLYCLEANFILES += debug_msg_ndebug.err
942 debug_msg_ndebug.so: debug_msg.cc gcctestdir/ld
943         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
944 odr_violation1_ndebug.so: odr_violation1.cc gcctestdir/ld
945         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
946 odr_violation2_ndebug.so: odr_violation2.cc gcctestdir/ld
947         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
948 debug_msg_ndebug.err: debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so gcctestdir/ld
949         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so "2>$@"
950         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so 2>$@; \
951         then \
952           echo 1>&2 "Link of debug_msg_ndebug should have failed"; \
953           rm -f $@; \
954           exit 1; \
955         fi
956
957
958 # Similar to --detect-odr-violations: check for undefined symbols in .so's
959 check_SCRIPTS += undef_symbol.sh
960 check_DATA += undef_symbol.err
961 MOSTLYCLEANFILES += undef_symbol.err
962 undef_symbol.o: undef_symbol.cc
963         $(CXXCOMPILE) -O0 -g -c -fPIC $<
964 undef_symbol.so: undef_symbol.o gcctestdir/ld
965         $(CXXLINK) -Bgcctestdir/ -shared undef_symbol.o
966 undef_symbol.err: undef_symbol_main.o undef_symbol.so gcctestdir/ld
967         @echo $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so "2>$@"
968         @if $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so 2>$@; \
969         then \
970           echo 1>&2 "Link of undef_symbol_test should have failed"; \
971           rm -f $@; \
972           exit 1; \
973         fi
974
975
976 # Test -o when emitting to a special file (such as something in /dev).
977 check_PROGRAMS += flagstest_o_specialfile
978 flagstest_o_specialfile: flagstest_debug.o gcctestdir/ld
979         $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< 2>&1 | cat > $@
980         chmod a+x $@
981         test -s $@
982
983 if HAVE_ZLIB
984
985 # Test --compress-debug-sections.  FIXME: check we actually compress.
986 check_PROGRAMS += flagstest_compress_debug_sections
987 flagstest_compress_debug_sections: flagstest_debug.o gcctestdir/ld
988         $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib
989         test -s $@
990
991
992 # The specialfile output has a tricky case when we also compress debug
993 # sections, because it requires output-file resizing.
994 check_PROGRAMS += flagstest_o_specialfile_and_compress_debug_sections
995 flagstest_o_specialfile_and_compress_debug_sections: flagstest_debug.o \
996                 gcctestdir/ld
997         $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< -Wl,--compress-debug-sections=zlib 2>&1 | cat > $@
998         chmod a+x $@
999         test -s $@
1000
1001 endif HAVE_ZLIB
1002
1003 # Test symbol versioning.
1004 check_PROGRAMS += ver_test
1005 ver_test_SOURCES = ver_test_main.cc
1006 ver_test_DEPENDENCIES = gcctestdir/ld ver_test_1.so ver_test_2.so ver_test_4.so
1007 ver_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1008 ver_test_LDADD = ver_test_1.so ver_test_2.so ver_test_4.so
1009 ver_test_1.so: ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so gcctestdir/ld
1010         $(CXXLINK) -Bgcctestdir/ -shared ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so
1011 ver_test_2.so: ver_test_2.o $(srcdir)/ver_test_2.script ver_test_4.so gcctestdir/ld
1012         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_2.script -Wl,-R,. ver_test_2.o ver_test_4.so
1013 ver_test_4.so: ver_test_4.o $(srcdir)/ver_test_4.script gcctestdir/ld
1014         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o
1015 ver_test_1.o: ver_test_1.cc
1016         $(CXXCOMPILE) -c -fpic -o $@ $<
1017 ver_test_2.o: ver_test_2.cc
1018         $(CXXCOMPILE) -c -fpic -o $@ $<
1019 ver_test_3.o: ver_test_3.cc
1020         $(CXXCOMPILE) -c -fpic -o $@ $<
1021 ver_test_4.o: ver_test_4.cc
1022         $(CXXCOMPILE) -c -fpic -o $@ $<
1023
1024 check_SCRIPTS += ver_test_1.sh
1025 check_DATA += ver_test_1.syms
1026 ver_test_1.syms: ver_test_1.so
1027         $(TEST_READELF) -s $< >$@ 2>/dev/null
1028
1029 check_PROGRAMS += ver_test_2
1030 ver_test_2_SOURCES = ver_test_main_2.cc
1031 ver_test_2_DEPENDENCIES = gcctestdir/ld ver_test_4.so ver_test_2.so
1032 ver_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1033 ver_test_2_LDADD = ver_test_4.so ver_test_2.so
1034
1035 check_SCRIPTS += ver_test_2.sh
1036 check_DATA += ver_test_2.syms
1037 ver_test_2.syms: ver_test_2
1038         $(TEST_READELF) -s $< >$@ 2>/dev/null
1039
1040 check_SCRIPTS += ver_test_4.sh
1041 check_DATA += ver_test_4.syms
1042 ver_test_4.syms: ver_test_4.so
1043         $(TEST_READELF) -s $< >$@ 2>/dev/null
1044
1045 ver_test_5.so: ver_test_5.o $(srcdir)/ver_test_5.script ver_test_4.so gcctestdir/ld
1046         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_5.script ver_test_5.o ver_test_4.so
1047 ver_test_5.o: ver_test_5.cc
1048         $(CXXCOMPILE) -c -fpic -o $@ $<
1049 check_SCRIPTS += ver_test_5.sh
1050 check_DATA += ver_test_5.syms
1051 ver_test_5.syms: ver_test_5.so
1052         $(TEST_READELF) -s $< >$@ 2>/dev/null
1053
1054 check_PROGRAMS += ver_test_6
1055 ver_test_6_SOURCES = ver_test_6.c
1056 ver_test_6_DEPENDENCIES = gcctestdir/ld ver_test_2.so
1057 ver_test_6_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1058 ver_test_6_LDADD = ver_test_2.so
1059
1060 ver_test_7.so: ver_test_4.o $(srcdir)/ver_test_4.script ver_test_7.o gcctestdir/ld
1061         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o ver_test_7.o
1062 ver_test_7.o: ver_test_7.cc
1063         $(CXXCOMPILE) -c -fpic -o $@ $<
1064 check_SCRIPTS += ver_test_7.sh
1065 check_DATA += ver_test_7.syms
1066 ver_test_7.syms: ver_test_7.so
1067         $(TEST_READELF) -s $< >$@ 2>/dev/null
1068
1069 check_PROGRAMS += ver_test_8
1070 ver_test_8_SOURCES = two_file_test_main.cc
1071 ver_test_8_DEPENDENCIES = gcctestdir/ld ver_test_8_1.so ver_test_8_2.so
1072 ver_test_8_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1073 ver_test_8_LDADD = ver_test_8_1.so ver_test_8_2.so
1074 ver_test_8_1.so: two_file_test_1_pic.o two_file_test_1b_pic.o ver_test_8_2.so gcctestdir/ld
1075         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o ver_test_8_2.so
1076 ver_test_8_2.so: two_file_test_2_pic.o $(srcdir)/ver_test_8.script gcctestdir/ld
1077         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_8.script two_file_test_2_pic.o
1078
1079 check_PROGRAMS += ver_test_9
1080 ver_test_9_SOURCES = ver_test_main.cc
1081 ver_test_9_DEPENDENCIES = gcctestdir/ld ver_test_9.so
1082 ver_test_9_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1083 ver_test_9_LDADD = ver_test_9.so
1084 ver_test_9.so: ver_test_9.o ver_test_4.so ver_test_5.so gcctestdir/ld
1085         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-R,. ver_test_9.o ver_test_5.so ver_test_4.so
1086 ver_test_9.o: ver_test_9.cc
1087         $(CXXCOMPILE) -c -fpic -o $@ $<
1088
1089 check_SCRIPTS += ver_test_10.sh
1090 check_DATA += ver_test_10.syms
1091 ver_test_10.syms: ver_test_10.so
1092         $(TEST_READELF) -s $< >$@ 2>/dev/null
1093 ver_test_10.so: gcctestdir/ld ver_test_2.o ver_test_10.script
1094         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_10.script ver_test_2.o
1095
1096 check_PROGRAMS += ver_test_11
1097 MOSTLYCLEANFILES += ver_test_11.a
1098 ver_test_11_SOURCES = ver_test_main_2.cc
1099 ver_test_11_DEPENDENCIES = gcctestdir/ld ver_test_11.a
1100 ver_test_11_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1101 ver_test_11_LDADD = ver_test_11.a
1102 ver_test_11.a: ver_test_1.o ver_test_2.o ver_test_4.o
1103         $(TEST_AR) rc $@ $^
1104
1105 check_PROGRAMS += ver_test_12
1106 ver_test_12_SOURCES = ver_test_main_2.cc
1107 ver_test_12_DEPENDENCIES = gcctestdir/ld ver_test_12.o
1108 ver_test_12_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1109 ver_test_12_LDADD = ver_test_12.o
1110 ver_test_12.o: gcctestdir/ld ver_test_1.o ver_test_2.o ver_test_4.o
1111         gcctestdir/ld -r -o $@ ver_test_1.o ver_test_2.o ver_test_4.o
1112
1113 check_PROGRAMS += protected_1
1114 protected_1_SOURCES = \
1115         protected_main_1.cc protected_main_2.cc protected_main_3.cc
1116 protected_1_DEPENDENCIES = gcctestdir/ld protected_1.so
1117 protected_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1118 protected_1_LDADD = protected_1.so
1119
1120 protected_1.so: gcctestdir/ld protected_1_pic.o protected_2_pic.o protected_3_pic.o
1121         $(CXXLINK) -Bgcctestdir/ -shared protected_1_pic.o protected_2_pic.o protected_3_pic.o
1122 protected_1_pic.o: protected_1.cc
1123         $(CXXCOMPILE) -c -fpic -o $@ $<
1124 protected_2_pic.o: protected_2.cc
1125         $(CXXCOMPILE) -c -fpic -o $@ $<
1126 protected_3_pic.o: protected_3.cc
1127         $(CXXCOMPILE) -c -fpic -o $@ $<
1128
1129 check_PROGRAMS += protected_2
1130 protected_2_SOURCES = protected_main_1.cc protected_3.cc
1131 protected_2_DEPENDENCIES = gcctestdir/ld protected_1.so
1132 protected_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1133 protected_2_LDADD = protected_1.so
1134
1135 check_DATA += protected_3.err
1136 MOSTLYCLEANFILES += protected_3.err
1137 protected_4_pic.o: protected_4.cc
1138         $(CXXCOMPILE) -c -fpic -o $@ $<
1139 protected_3.err: protected_4_pic.o gcctestdir/ld
1140         @echo $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o "2>$@"
1141         @if $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o 2>$@; then \
1142           echo 1>&2 "Link of protected_4.so should have failed"; \
1143           rm -f $@; \
1144           exit 1; \
1145         fi
1146
1147 check_PROGRAMS += relro_test
1148 check_SCRIPTS += relro_test.sh
1149 check_DATA += relro_test.stdout
1150 relro_test_SOURCES = relro_test_main.cc
1151 relro_test_DEPENDENCIES = gcctestdir/ld relro_test.so
1152 relro_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1153 relro_test_LDADD = relro_test.so
1154 relro_test.so: gcctestdir/ld relro_test_pic.o
1155         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro relro_test_pic.o
1156 relro_test_pic.o: relro_test.cc
1157         $(CXXCOMPILE) -c -fpic -o $@ $<
1158 relro_test.stdout: relro_test.so
1159         $(TEST_READELF) -SlW relro_test.so > relro_test.stdout
1160
1161 check_PROGRAMS += relro_strip_test
1162 relro_strip_test_SOURCES = relro_test_main.cc
1163 relro_strip_test_DEPENDENCIES = gcctestdir/ld relro_strip_test.so
1164 relro_strip_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1165 relro_strip_test_LDADD = relro_strip_test.so
1166 relro_strip_test.so: relro_test.so
1167         $(TEST_STRIP) -o $@ $<
1168
1169 check_PROGRAMS += relro_script_test
1170 relro_script_test_SOURCES = relro_test_main.cc
1171 relro_script_test_DEPENDENCIES = gcctestdir/ld relro_script_test.so
1172 relro_script_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1173 relro_script_test_LDADD = relro_script_test.so
1174 relro_script_test.so: gcctestdir/ld relro_script_test.t relro_test_pic.o
1175         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro -T $(srcdir)/relro_script_test.t relro_test_pic.o
1176
1177 check_PROGRAMS += script_test_1
1178 script_test_1_SOURCES = script_test_1.cc
1179 script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
1180 script_test_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_1.t
1181 script_test_1_LDADD =
1182
1183 check_PROGRAMS += script_test_2
1184 script_test_2_SOURCES = script_test_2.cc script_test_2a.cc script_test_2b.cc
1185 script_test_2_DEPENDENCIES = gcctestdir/ld script_test_2.t
1186 script_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_2.t
1187 script_test_2_LDADD =
1188
1189 check_PROGRAMS += justsyms
1190 justsyms_SOURCES = justsyms_1.cc
1191 justsyms_DEPENDENCIES = gcctestdir/ld justsyms_2r.o
1192 justsyms_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_2r.o
1193 justsyms_LDADD =
1194 justsyms_2.o: justsyms_2.cc
1195         $(CXXCOMPILE) -c -o $@ $<
1196 justsyms_2r.o: justsyms_2.o gcctestdir/ld $(srcdir)/justsyms.t
1197         gcctestdir/ld -o $@ -r -T $(srcdir)/justsyms.t justsyms_2.o
1198
1199 check_PROGRAMS += binary_test
1200 MOSTLYCLEANFILES += binary.txt
1201 binary_test_SOURCES = binary_test.cc
1202 binary_test_DEPENDENCIES = gcctestdir/ld binary.txt
1203 binary_test_LDFLAGS = -Bgcctestdir/ -Wl,--format,binary,binary.txt,--format,elf
1204 binary_test_LDADD =
1205 # Copy the file to the build directory to avoid worrying about the
1206 # full pathname in the generated symbols.
1207 binary.txt: $(srcdir)/binary.in
1208         rm -f $@
1209         $(LN_S) $< $@
1210
1211 check_SCRIPTS += ver_matching_test.sh
1212 check_DATA += ver_matching_test.stdout
1213 MOSTLYCLEANFILES += ver_matching_test.stdout
1214 ver_matching_def.so: ver_matching_def_pic.o $(srcdir)/version_script.map gcctestdir/ld
1215         $(CXXLINK) -O0 -Bgcctestdir/ -shared ver_matching_def_pic.o -Wl,--version-script=$(srcdir)/version_script.map
1216 ver_matching_def_pic.o: ver_matching_def.cc
1217         $(CXXCOMPILE) -O0 -c -fpic -o $@ $<
1218 ver_matching_test.stdout: ver_matching_def.so
1219         $(TEST_OBJDUMP) -T ver_matching_def.so | $(TEST_CXXFILT) > ver_matching_test.stdout
1220
1221 check_PROGRAMS += script_test_3
1222 check_SCRIPTS += script_test_3.sh
1223 check_DATA += script_test_3.stdout
1224 MOSTLYCLEANFILES += script_test_3.stdout
1225 script_test_3: basic_test.o gcctestdir/ld script_test_3.t
1226         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_3.t
1227 script_test_3.stdout: script_test_3
1228         $(TEST_READELF) -SlW script_test_3 > script_test_3.stdout
1229
1230 check_PROGRAMS += tls_phdrs_script_test
1231 tls_phdrs_script_test_SOURCES = $(tls_test_SOURCES)
1232 tls_phdrs_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_3.t
1233 tls_phdrs_script_test_LDFLAGS = $(tls_test_LDFLAGS) -T $(srcdir)/script_test_3.t
1234 tls_phdrs_script_test_LDADD = $(tls_test_LDADD)
1235
1236 check_SCRIPTS += script_test_4.sh
1237 check_DATA += script_test_4.stdout
1238 MOSTLYCLEANFILES += script_test_4
1239 script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
1240         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_4.t
1241 script_test_4.stdout: script_test_4
1242         $(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
1243
1244 check_PROGRAMS += tls_script_test
1245 tls_script_test_SOURCES = $(tls_test_SOURCES)
1246 tls_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_4.t
1247 tls_script_test_LDFLAGS = $(tls_test_LDFLAGS) -T $(srcdir)/script_test_4.t
1248 tls_script_test_LDADD = $(tls_test_LDADD)
1249
1250 check_SCRIPTS += script_test_5.sh
1251 check_DATA += script_test_5.stdout
1252 MOSTLYCLEANFILES += script_test_5
1253 script_test_5: script_test_5.o gcctestdir/ld $(srcdir)/script_test_5.t
1254         $(CXXLINK) -Bgcctestdir/ script_test_5.o -T $(srcdir)/script_test_5.t
1255 script_test_5.stdout: script_test_5
1256         $(TEST_READELF) -SW script_test_5 > script_test_5.stdout
1257
1258 check_SCRIPTS += script_test_6.sh
1259 check_DATA += script_test_6.stdout
1260 MOSTLYCLEANFILES += script_test_6
1261 script_test_6: basic_test.o gcctestdir/ld $(srcdir)/script_test_6.t
1262         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_6.t \
1263         -Wl,-Ttext=0x10001000 -Wl,-Tdata=0x10200000 -Wl,-Tbss=0x10400000
1264 script_test_6.stdout: script_test_6
1265         $(TEST_READELF) -SlW script_test_6 > script_test_6.stdout
1266
1267 check_SCRIPTS += script_test_7.sh
1268 check_DATA += script_test_7.stdout
1269 MOSTLYCLEANFILES += script_test_7
1270 script_test_7: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1271         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t
1272 script_test_7.stdout: script_test_7
1273         $(TEST_READELF) -SlW script_test_7 > script_test_7.stdout
1274
1275 check_SCRIPTS += script_test_8.sh
1276 check_DATA += script_test_8.stdout
1277 MOSTLYCLEANFILES += script_test_8
1278 script_test_8: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1279         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t \
1280         -Wl,-Ttext=0x20001000 -Wl,-Tdata=0x20200000 -Wl,-Tbss=0x20400000
1281 script_test_8.stdout: script_test_8
1282         $(TEST_READELF) -SlW script_test_8 > script_test_8.stdout
1283
1284
1285 check_SCRIPTS += script_test_9.sh
1286 check_DATA += script_test_9.stdout
1287 script_test_9.o: script_test_9.cc
1288         $(CXXCOMPILE) -O0 -c -o $@ $<
1289 script_test_9: gcctestdir/ld $(srcdir)/script_test_9.t script_test_9.o
1290         $(CXXLINK) -Bgcctestdir/ script_test_9.o -T $(srcdir)/script_test_9.t
1291 script_test_9.stdout: script_test_9
1292         $(TEST_READELF) -lW script_test_9 > script_test_9.stdout
1293
1294
1295 # Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new,
1296 # and --dynamic-list-cpp-typeinfo
1297
1298 check_SCRIPTS += dynamic_list.sh
1299 check_DATA += dynamic_list.stdout
1300 MOSTLYCLEANFILES += dynamic_list dynamic_list.stdout
1301 dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t
1302         $(CXXLINK) -Bgcctestdir/ basic_test.o \
1303           -Wl,--dynamic-list $(srcdir)/dynamic_list.t \
1304           -Wl,--dynamic-list-data \
1305           -Wl,--dynamic-list-cpp-new \
1306           -Wl,--dynamic-list-cpp-typeinfo
1307 dynamic_list.stdout: dynamic_list
1308         $(TEST_READELF) -W --dyn-syms dynamic_list > dynamic_list.stdout
1309
1310 check_PROGRAMS += thin_archive_test_1
1311 MOSTLYCLEANFILES += libthin1.a libthin3.a libthinall.a \
1312         alt/thin_archive_test_2.o alt/thin_archive_test_4.o \
1313         alt/libthin2.a alt/libthin4.a
1314 thin_archive_test_1_SOURCES = thin_archive_main.cc
1315 thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a
1316 thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt
1317 thin_archive_test_1_LDADD = libthin1.a -lthin2
1318
1319 check_PROGRAMS += thin_archive_test_2
1320 thin_archive_test_2_SOURCES = thin_archive_main.cc
1321 thin_archive_test_2_DEPENDENCIES = gcctestdir/ld libthinall.a
1322 thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L.
1323 thin_archive_test_2_LDADD = -lthinall
1324
1325 libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o
1326         rm -f $@
1327         $(TEST_AR) crT $@ $^
1328 alt/libthin2.a: thin_archive_test_3.o alt/thin_archive_test_4.o
1329         rm -f $@
1330         $(TEST_AR) crT $@ $^
1331 libthin3.a: thin_archive_test_1.o alt/thin_archive_test_4.o
1332         rm -f $@
1333         $(TEST_AR) crT $@ $^
1334 alt/libthin4.a: alt/thin_archive_test_2.o thin_archive_test_3.o
1335         rm -f $@
1336         $(TEST_AR) crT $@ $^
1337 libthinall.a: libthin3.a alt/libthin4.a
1338         rm -f $@
1339         $(TEST_AR) crT $@ $^
1340 alt/thin_archive_test_2.o: thin_archive_test_2.cc
1341         test -d alt || mkdir -p alt
1342         $(CXXCOMPILE) -c -o $@ $<
1343 alt/thin_archive_test_4.o: thin_archive_test_4.cc
1344         test -d alt || mkdir -p alt
1345         $(CXXCOMPILE) -c -o $@ $<
1346
1347 if PLUGINS
1348
1349 check_PROGRAMS += plugin_test_1
1350 check_SCRIPTS += plugin_test_1.sh
1351 check_DATA += plugin_test_1.err
1352 MOSTLYCLEANFILES += plugin_test_1.err
1353 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
1354         $(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
1355 plugin_test_1.err: plugin_test_1
1356         @touch plugin_test_1.err
1357
1358 check_PROGRAMS += plugin_test_2
1359 check_SCRIPTS += plugin_test_2.sh
1360 check_DATA += plugin_test_2.err
1361 MOSTLYCLEANFILES += plugin_test_2.err
1362 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
1363         $(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
1364 plugin_test_2.err: plugin_test_2
1365         @touch plugin_test_2.err
1366
1367 check_PROGRAMS += plugin_test_3
1368 check_SCRIPTS += plugin_test_3.sh
1369 check_DATA += plugin_test_3.err
1370 MOSTLYCLEANFILES += plugin_test_3.err
1371 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
1372         $(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
1373 plugin_test_3.err: plugin_test_3
1374         @touch plugin_test_3.err
1375
1376 check_PROGRAMS += plugin_test_4
1377 check_SCRIPTS += plugin_test_4.sh
1378 check_DATA += plugin_test_4.err
1379 MOSTLYCLEANFILES += plugin_test_4.a plugin_test_4.err
1380 plugin_test_4: two_file_test_main.o plugin_test_4.a gcctestdir/ld plugin_test.so
1381         $(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
1382 plugin_test_4.err: plugin_test_4
1383         @touch plugin_test_4.err
1384
1385 plugin_test_4.a: two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms
1386         $(TEST_AR) cr $@ $^
1387
1388 check_PROGRAMS += plugin_test_5
1389 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
1390         $(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
1391
1392 check_PROGRAMS += plugin_test_6
1393 check_SCRIPTS += plugin_test_6.sh
1394 check_DATA += plugin_test_6.err
1395 MOSTLYCLEANFILES += plugin_test_6.err
1396 plugin_test_6: plugin_common_test_1.syms plugin_common_test_2.syms gcctestdir/ld plugin_test.so
1397         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.syms plugin_common_test_2.syms 2>plugin_test_6.err
1398 plugin_test_6.err: plugin_test_6
1399         @touch plugin_test_6.err
1400
1401 check_PROGRAMS += plugin_test_7
1402 check_SCRIPTS += plugin_test_7.sh
1403 check_DATA += plugin_test_7.err plugin_test_7.syms
1404 MOSTLYCLEANFILES += plugin_test_7.err
1405 plugin_test_7: plugin_test_7_1.o plugin_test_7_1.syms plugin_test_7_2.o gcctestdir/ld plugin_test.so
1406         $(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
1407 plugin_test_7.syms: plugin_test_7
1408         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1409 plugin_test_7_1.o: plugin_test_7_1.c
1410         $(COMPILE) -DLTO -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1411 plugin_test_7_1_orig.o: plugin_test_7_1.c
1412         $(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1413 plugin_test_7_1.syms: plugin_test_7_1_orig.o
1414         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1415 plugin_test_7_2.o: plugin_test_7_2.c
1416         $(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1417 plugin_test_7.err: plugin_test_7
1418
1419 # Test plugins with -r.
1420 check_PROGRAMS += plugin_test_8
1421 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
1422         ../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
1423 plugin_test_8: plugin_test_8.o gcctestdir/ld
1424         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle plugin_test_8.o
1425
1426 # Test that symbols known in the IR file but not in the replacement file
1427 # produce an unresolved symbol error.
1428 check_DATA += plugin_test_9.err
1429 MOSTLYCLEANFILES += plugin_test_9.err
1430 plugin_test_9.err: two_file_test_main.o two_file_test_1c.syms two_file_test_2.syms gcctestdir/ld plugin_test.so
1431         @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>$@"
1432         @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 \
1433           echo 1>&2 "Link of plugin_test_9 should have failed"; \
1434           rm -f $@; \
1435           exit 1; \
1436         fi
1437 # Make a .syms file that claims to define the symbol _Z4t16av.
1438 two_file_test_1c.syms: two_file_test_1.syms two_file_test_1c.o
1439         cp two_file_test_1.syms $@.tmp
1440         grep "_Z4t16av" two_file_test_1b.syms >> $@.tmp
1441         mv -f $@.tmp $@
1442 # Make a copy of two_file_test_1.o, which does not define the symbol _Z4t16av.
1443 MOSTLYCLEANFILES += two_file_test_1c.o
1444 two_file_test_1c.o: two_file_test_1.o
1445         cp two_file_test_1.o $@
1446
1447 plugin_test.so: plugin_test.o
1448         $(LINK) -Bgcctestdir/ -shared plugin_test.o
1449 plugin_test.o: plugin_test.c
1450         $(COMPILE) -O0 -c -fpic -o $@ $<
1451
1452 two_file_test_main.syms: two_file_test_main.o
1453         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1454 two_file_test_1.syms: two_file_test_1.o
1455         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1456 two_file_test_1b.syms: two_file_test_1b.o
1457         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1458 two_file_test_2.syms: two_file_test_2.o
1459         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1460 plugin_common_test_1.syms: plugin_common_test_1.o
1461         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1462 plugin_common_test_2.syms: plugin_common_test_2.o
1463         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1464
1465 empty.syms:
1466         @echo "" >$@
1467         @echo "Symbol table" >>$@
1468
1469 MOSTLYCLEANFILES += unused.c
1470 unused.syms: unused.o
1471         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1472         @echo "     1: 00000000     4 FUNC    GLOBAL DEFAULT    1 UNUSED" >>$@
1473 unused.o: unused.c
1474         $(COMPILE) -c -o $@ $<
1475 unused.c:
1476         @cp /dev/null $@
1477
1478 endif PLUGINS
1479
1480 check_PROGRAMS += exclude_libs_test
1481 check_SCRIPTS += exclude_libs_test.sh
1482 check_DATA += exclude_libs_test.syms
1483 MOSTLYCLEANFILES += exclude_libs_test.syms libexclude_libs_test_1.a \
1484         libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
1485 exclude_libs_test_SOURCES = exclude_libs_test.c
1486 exclude_libs_test_DEPENDENCIES = gcctestdir/ld libexclude_libs_test_1.a \
1487         libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
1488 exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. -Lalt \
1489         -Wl,--exclude-libs,dummy:libexclude_libs_test_1 \
1490         -Wl,--exclude-libs,libexclude_libs_test_3
1491 exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 \
1492         alt/libexclude_libs_test_3.a
1493 exclude_libs_test.syms: exclude_libs_test
1494         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1495 libexclude_libs_test_1.a: exclude_libs_test_1.o
1496         $(TEST_AR) rc $@ $^
1497 libexclude_libs_test_2.a: exclude_libs_test_2.o
1498         $(TEST_AR) rc $@ $^
1499 alt/libexclude_libs_test_3.a: exclude_libs_test_3.o
1500         test -d alt || mkdir -p alt
1501         $(TEST_AR) rc $@ $^
1502
1503 check_PROGRAMS += local_labels_test
1504 local_labels_test.o: ver_test_6.c
1505         $(COMPILE) -g -c -Wa,-L -o $@ $<
1506 local_labels_test: local_labels_test.o
1507         $(LINK) -Bgcctestdir/ local_labels_test.o
1508
1509 check_PROGRAMS += discard_locals_test
1510 check_SCRIPTS += discard_locals_test.sh
1511 check_DATA += discard_locals_test.syms \
1512         discard_locals_relocatable_test1.syms \
1513         discard_locals_relocatable_test2.syms
1514 MOSTLYCLEANFILES += discard_locals_test.syms \
1515         discard_locals_relocatable_test1.syms \
1516         discard_locals_relocatable_test2.syms \
1517         discard_locals_relocatable_test1.out \
1518         discard_locals_relocatable_test2.out
1519 discard_locals_test_SOURCES = discard_locals_test.c
1520 discard_locals_test_LDFLAGS = -Bgcctestdir/ -Wl,--discard-locals
1521 discard_locals_test.syms: discard_locals_test
1522         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1523 # '-Wa,-L' is required to preserve the local label used for testing.
1524 discard_locals_test.o: discard_locals_test.c
1525         $(COMPILE) -c -Wa,-L -o $@ $<
1526
1527 discard_locals_relocatable_test1.syms: discard_locals_relocatable_test1.out
1528         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1529 discard_locals_relocatable_test.o: discard_locals_relocatable_test.c
1530         $(COMPILE) -c -Wa,-L -fPIC -o $@ $<
1531 discard_locals_relocatable_test1.out: discard_locals_relocatable_test.o ../ld-new
1532         ../ld-new --discard-locals -relocatable -o $@ $<
1533
1534 discard_locals_relocatable_test2.syms: discard_locals_relocatable_test2.out
1535         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1536 discard_locals_relocatable_test2.out: discard_locals_relocatable_test.o ../ld-new
1537         ../ld-new --discard-all -relocatable -o $@ $<
1538
1539 if MCMODEL_MEDIUM
1540 check_PROGRAMS += large
1541 large_SOURCES = large.c
1542 large_CFLAGS = -mcmodel=medium
1543 large_DEPENDENCIES = gcctestdir/ld
1544 large_LDFLAGS = -Bgcctestdir/
1545 large_LDADD =
1546 endif MCMODEL_MEDIUM
1547
1548 # Test that hidden and internal symbols in the main program cannot be
1549 # referenced by a shared library.
1550 check_SCRIPTS += hidden_test.sh
1551 check_DATA += hidden_test.err
1552 MOSTLYCLEANFILES += hidden_test hidden_test.err
1553 libhidden.so: hidden_test_1.c gcctestdir/ld
1554         $(COMPILE) -Bgcctestdir/ -g -shared -fPIC -w -o $@ $(srcdir)/hidden_test_1.c
1555 hidden_test: hidden_test_main.o libhidden.so gcctestdir/ld
1556         $(LINK) -Bgcctestdir/ -Wl,-R,. hidden_test_main.o libhidden.so 2>hidden_test.err
1557 hidden_test.err: hidden_test
1558         @touch hidden_test.err
1559
1560 # Test -retain-symbols-file.
1561 check_SCRIPTS += retain_symbols_file_test.sh
1562 check_DATA += retain_symbols_file_test.stdout
1563 MOSTLYCLEANFILES += retain_symbols_file_test retain_symbols_file_test.in \
1564                     retain_symbols_file_test.stdout
1565 retain_symbols_file_test.so: basic_pic_test.o gcctestdir/ld
1566         echo 'main' > retain_symbols_file_test.in
1567         echo 't1' >> retain_symbols_file_test.in
1568         echo '_ZN4t16bC1Ev' >> retain_symbols_file_test.in
1569         echo '_ZNK4t20a3getEv' >> retain_symbols_file_test.in
1570         echo '_Z3t18v' >> retain_symbols_file_test.in
1571         echo '__tcf_0' >> retain_symbols_file_test.in   
1572         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-retain-symbols-file,retain_symbols_file_test.in basic_pic_test.o
1573 retain_symbols_file_test.stdout: retain_symbols_file_test.so
1574         $(TEST_NM) -C retain_symbols_file_test.so > $@
1575
1576
1577 # Test that if the output file already exists and is empty,
1578 # it will get execute permission.
1579 check_PROGRAMS += permission_test
1580 permission_test: basic_test.o gcctestdir/ld
1581         umask 022; \
1582         rm -f $@; \
1583         touch $@; \
1584         chmod 600 $@; \
1585         $(CXXLINK) -Bgcctestdir/ basic_test.o
1586
1587 # Check -l:foo.a
1588 check_PROGRAMS += searched_file_test
1589 MOSTLYCLEANFILES += searched_file_test searched_file_test_lib.o \
1590                     alt/searched_file_test_lib.a
1591 searched_file_test_SOURCES = searched_file_test.cc
1592 searched_file_test_DEPENDENCIES = alt/searched_file_test_lib.a
1593 searched_file_test_LDFLAGS = -Bgcctestdir/ -Lalt
1594 searched_file_test_LDADD = -l:searched_file_test_lib.a
1595 searched_file_test_lib.o: searched_file_test_lib.cc
1596         $(CXXCOMPILE) -c -o $@ $<
1597 alt/searched_file_test_lib.a: searched_file_test_lib.o
1598         test -d alt || mkdir -p alt
1599         $(TEST_AR) rc $@ $^
1600
1601 # Test that no .gnu.version sections are created when 
1602 # symbol versioning is not used.
1603 check_SCRIPTS += no_version_test.sh
1604 check_DATA += no_version_test.stdout
1605 MOSTLYCLEANFILES += libno_version_test.so no_version_test.stdout
1606 # We invoke the linker directly since gcc may include additional objects that
1607 # uses symbol versioning.
1608 libno_version_test.so: no_version_test.o gcctestdir/ld
1609         gcctestdir/ld -shared -o $@ no_version_test.o
1610 no_version_test.o: no_version_test.c
1611         $(COMPILE) -o $@ -c -fPIC $<
1612 no_version_test.stdout: libno_version_test.so
1613         $(TEST_OBJDUMP) -h $< > $@
1614
1615 # Test STT_GNU_IFUNC symbols.
1616 if IFUNC
1617
1618 ifuncmod1.o: ifuncmod1.c
1619         $(COMPILE) -c -fpic -o $@ $<
1620 ifuncmod1.so: ifuncmod1.o gcctestdir/ld
1621         $(LINK) -Bgcctestdir/ -shared ifuncmod1.o
1622
1623 ifuncdep1.o: ifuncmod1.c
1624         $(COMPILE) -c -o $@ $<
1625
1626 ifuncmain1pic.o: ifuncmain1.c
1627         $(COMPILE) -c -fpic -o $@ $<
1628 ifuncmain1pie.o: ifuncmain1.c
1629         $(COMPILE) -c -fpie -o $@ $<
1630
1631 if HAVE_STATIC
1632 check_PROGRAMS += ifuncmain1static
1633 ifuncmain1static_SOURCES = ifuncmain1.c
1634 ifuncmain1static_DEPENDENCIES = gcctestdir/ld ifuncdep1.o
1635 ifuncmain1static_LDFLAGS = -Bgcctestdir/ -static
1636 ifuncmain1static_LDADD = ifuncdep1.o
1637
1638 check_PROGRAMS += ifuncmain1picstatic
1639 ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
1640         $(LINK) -Bgcctestdir/ -static ifuncmain1pic.o ifuncmod1.o
1641 endif
1642
1643 check_PROGRAMS += ifuncmain1
1644 ifuncmain1_SOURCES = ifuncmain1.c
1645 ifuncmain1_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
1646 ifuncmain1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1647 ifuncmain1_LDADD = ifuncmod1.so
1648
1649 check_PROGRAMS += ifuncmain1pic
1650 ifuncmain1pic: ifuncmain1pic.o ifuncmod1.so gcctestdir/ld
1651         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
1652
1653 check_PROGRAMS += ifuncmain1vis
1654 ifuncmain1vis_SOURCES = ifuncmain1vis.c
1655 ifuncmain1vis_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
1656 ifuncmain1vis_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1657 ifuncmain1vis_LDADD = ifuncmod1.so
1658
1659 check_PROGRAMS += ifuncmain1vispic
1660 ifuncmain1vispic.o: ifuncmain1vis.c
1661         $(COMPILE) -c -fpic -o $@ $<
1662 ifuncmain1vispic: ifuncmain1vispic.o ifuncmod1.so gcctestdir/ld
1663         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
1664
1665 check_PROGRAMS += ifuncmain1staticpic
1666 ifuncmain1staticpic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
1667         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.o
1668
1669 check_PROGRAMS += ifuncmain1pie
1670 ifuncmain1pie: ifuncmain1pie.o ifuncmod1.so gcctestdir/ld
1671         $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.so -Wl,-R,.
1672
1673 check_PROGRAMS += ifuncmain1vispie
1674 ifuncmain1vispie.o: ifuncmain1vis.c
1675         $(COMPILE) -c -fpie -o $@ $<
1676 ifuncmain1vispie: ifuncmain1vispie.o ifuncmod1.so gcctestdir/ld
1677         $(LINK) -Bgcctestdir/ -pie ifuncmain1vispie.o ifuncmod1.so -Wl,-R,.
1678
1679 check_PROGRAMS += ifuncmain1staticpie
1680 ifuncmain1staticpie: ifuncmain1pie.o ifuncmod1.o gcctestdir/ld
1681         $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.o
1682
1683 ifuncmain2pic.o: ifuncmain2.c
1684         $(COMPILE) -c -fpic -o $@ $<
1685
1686 ifuncdep2pic.o: ifuncdep2.c
1687         $(COMPILE) -c -fpic -o $@ $<
1688
1689 if HAVE_STATIC
1690 check_PROGRAMS += ifuncmain2static
1691 ifuncmain2static_SOURCES = ifuncmain2.c ifuncdep2.c
1692 ifuncmain2static_DEPENDENCIES = gcctestdir/ld
1693 ifuncmain2static_LDFLAGS = -Bgcctestdir/ -static
1694 ifuncmain2static_LDADD =
1695
1696 check_PROGRAMS += ifuncmain2picstatic
1697 ifuncmain2picstatic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
1698         $(LINK) -Bgcctestdir/ -static ifuncmain2pic.o ifuncdep2pic.o
1699 endif
1700
1701 check_PROGRAMS += ifuncmain2
1702 ifuncmain2_SOURCES = ifuncmain2.c ifuncdep2.c
1703 ifuncmain2_DEPENDENCIES = gcctestdir/ld
1704 ifuncmain2_LDFLAGS = -Bgcctestdir/
1705 ifuncmain2_LDADD =
1706
1707 check_PROGRAMS += ifuncmain2pic
1708 ifuncmain2pic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
1709         $(LINK) -Bgcctestdir/ ifuncmain2pic.o ifuncdep2pic.o
1710
1711 ifuncmod3.o: ifuncmod3.c
1712         $(COMPILE) -c -fpic -o $@ $<
1713 ifuncmod3.so: ifuncmod3.o gcctestdir/ld
1714         $(LINK) -Bgcctestdir/ -shared ifuncmod3.o
1715
1716 check_PROGRAMS += ifuncmain3
1717 ifuncmain3_SOURCES = ifuncmain3.c
1718 ifuncmain3_DEPENDENCIES = gcctestdir/ld ifuncmod3.so
1719 ifuncmain3_LDFLAGS = -Bgcctestdir/ -Wl,--export-dynamic -Wl,-R,.
1720 ifuncmain3_LDADD = -ldl
1721
1722 ifuncmain4pic.o: ifuncmain4.c
1723         $(COMPILE) -c -fpic -o $@ $<
1724
1725 if HAVE_STATIC
1726 check_PROGRAMS += ifuncmain4static
1727 ifuncmain4static_SOURCES = ifuncmain4.c
1728 ifuncmain4static_DEPENDENCIES = gcctestdir/ld
1729 ifuncmain4static_LDFLAGS = -Bgcctestdir/ -static
1730 ifuncmain4static_LDADD =
1731
1732 check_PROGRAMS += ifuncmain4picstatic
1733 ifuncmain4picstatic: ifuncmain4pic.o gcctestdir/ld
1734         $(LINK) -Bgcctestdir/ -static ifuncmain4pic.o
1735 endif
1736
1737 check_PROGRAMS += ifuncmain4
1738 ifuncmain4_SOURCES = ifuncmain4.c
1739 ifuncmain4_DEPENDENCIES = gcctestdir/ld
1740 ifuncmain4_LDFLAGS = -Bgcctestdir/
1741 ifuncmain4_LDADD =
1742
1743 ifuncmain5pic.o: ifuncmain5.c
1744         $(COMPILE) -c -fpic -o $@ $<
1745
1746 ifuncmain5pie.o: ifuncmain5.c
1747         $(COMPILE) -c -fpie -o $@ $<
1748
1749 ifuncmod5.o: ifuncmod5.c
1750         $(COMPILE) -c -fpic -o $@ $<
1751 ifuncmod5.so: ifuncmod5.o gcctestdir/ld
1752         $(LINK) -Bgcctestdir/ -shared ifuncmod5.o
1753
1754 ifuncdep5.o: ifuncmod5.c
1755         $(COMPILE) -c -o $@ $<
1756
1757 if HAVE_STATIC
1758 check_PROGRAMS += ifuncmain5static
1759 ifuncmain5static_SOURCES = ifuncmain5.c
1760 ifuncmain5static_DEPENDENCIES = gcctestdir/ld ifuncdep5.o
1761 ifuncmain5static_LDFLAGS = -Bgcctestdir/ -static
1762 ifuncmain5static_LDADD = ifuncdep5.o
1763
1764 check_PROGRAMS += ifuncmain5picstatic
1765 ifuncmain5picstatic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
1766         $(LINK) -Bgcctestdir/ -static ifuncmain5pic.o ifuncmod5.o
1767 endif
1768
1769 check_PROGRAMS += ifuncmain5
1770 ifuncmain5_SOURCES = ifuncmain5.c
1771 ifuncmain5_DEPENDENCIES = gcctestdir/ld ifuncmod5.so
1772 ifuncmain5_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1773 ifuncmain5_LDADD = ifuncmod5.so
1774
1775 check_PROGRAMS += ifuncmain5pic
1776 ifuncmain5pic: ifuncmain5pic.o ifuncmod5.so gcctestdir/ld
1777         $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.so -Wl,-R,.
1778
1779 check_PROGRAMS += ifuncmain5staticpic
1780 ifuncmain5staticpic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
1781         $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.o
1782
1783 check_PROGRAMS += ifuncmain5pie
1784 ifuncmain5pie: ifuncmain5pie.o ifuncmod5.so gcctestdir/ld
1785         $(LINK) -Bgcctestdir/ -pie ifuncmain5pie.o ifuncmod5.so -Wl,-R,.
1786
1787 ifuncmain6pie.o: ifuncmain6pie.c
1788         $(COMPILE) -c -fpie -o $@ $<
1789
1790 ifuncmod6.o: ifuncmod6.c
1791         $(COMPILE) -c -fpic -o $@ $<
1792 ifuncmod6.so: ifuncmod6.o gcctestdir/ld
1793         $(LINK) -Bgcctestdir/ -shared ifuncmod6.o
1794
1795 check_PROGRAMS += ifuncmain6pie
1796 ifuncmain6pie: ifuncmain6pie.o ifuncmod6.so gcctestdir/ld
1797         $(LINK) -Bgcctestdir/ -pie ifuncmain6pie.o ifuncmod6.so -Wl,-R,.
1798
1799 ifuncmain7pic.o: ifuncmain7.c
1800         $(COMPILE) -c -fpic -o $@ $<
1801
1802 ifuncmain7pie.o: ifuncmain7.c
1803         $(COMPILE) -c -fpie -o $@ $<
1804
1805 if HAVE_STATIC
1806 check_PROGRAMS += ifuncmain7static
1807 ifuncmain7static_SOURCES = ifuncmain7.c
1808 ifuncmain7static_DEPENDENCIES = gcctestdir/ld
1809 ifuncmain7static_LDFLAGS = -Bgcctestdir/ -static
1810 ifuncmain7static_LDADD =
1811
1812 check_PROGRAMS += ifuncmain7picstatic
1813 ifuncmain7picstatic: ifuncmain7pic.o gcctestdir/ld
1814         $(LINK) -Bgcctestdir/ -static ifuncmain7pic.o
1815 endif
1816
1817 check_PROGRAMS += ifuncmain7
1818 ifuncmain7_SOURCES = ifuncmain7.c
1819 ifuncmain7_DEPENDENCIES = gcctestdir/ld
1820 ifuncmain7_LDFLAGS = -Bgcctestdir/
1821 ifuncmain7_LDADD =
1822
1823 check_PROGRAMS += ifuncmain7pic
1824 ifuncmain7pic: ifuncmain7pic.o gcctestdir/ld
1825         $(LINK) -Bgcctestdir/ ifuncmain7pic.o
1826
1827 check_PROGRAMS += ifuncmain7pie
1828 ifuncmain7pie: ifuncmain7pie.o gcctestdir/ld
1829         $(LINK) -Bgcctestdir/ -pie ifuncmain7pie.o
1830
1831 endif IFUNC
1832
1833 # Test that strong reference to a weak symbol in a DSO remains strong.
1834 check_SCRIPTS += strong_ref_weak_def.sh
1835 check_DATA += strong_ref_weak_def.stdout
1836 MOSTLYCLEANFILES += strong_ref_weak_def_1.so strong_ref_weak_def_2.so \
1837         strong_ref_weak_def.stdout
1838 strong_ref_weak_def_2.o: strong_ref_weak_def_2.c
1839         $(COMPILE) -o $@ -c -fPIC $<
1840 strong_ref_weak_def_2.so: strong_ref_weak_def_2.o gcctestdir/ld
1841         gcctestdir/ld -shared -o $@ strong_ref_weak_def_2.o
1842 strong_ref_weak_def_1.o: strong_ref_weak_def_1.c
1843         $(COMPILE) -o $@ -c -fPIC $<
1844 strong_ref_weak_def_1.so: strong_ref_weak_def_1.o strong_ref_weak_def_2.so \
1845         gcctestdir/ld
1846         gcctestdir/ld -shared -o $@ strong_ref_weak_def_1.o \
1847                 strong_ref_weak_def_2.so
1848 strong_ref_weak_def.stdout: strong_ref_weak_def_1.so
1849         $(TEST_READELF) -sWD $< > $@
1850
1851 # Test that a strong weak reference remains strong if there is another
1852 # weak reference in a DSO.
1853 check_SCRIPTS += dyn_weak_ref.sh
1854 check_DATA += dyn_weak_ref.stdout
1855 MOSTLYCLEANFILES += dyn_weak_ref_1.so dyn_weak_ref_2.so \
1856         dyn_weak_ref.stdout
1857 dyn_weak_ref_2.o: dyn_weak_ref_2.c
1858         $(COMPILE) -o $@ -c -fPIC $<
1859 dyn_weak_ref_2.so: dyn_weak_ref_2.o gcctestdir/ld
1860         gcctestdir/ld -shared -o $@ dyn_weak_ref_2.o
1861 dyn_weak_ref_1.o: dyn_weak_ref_1.c
1862         $(COMPILE) -o $@ -c -fPIC $<
1863 # We intentionally put dyn_weak_ref_2.so in front of dyn_weak_ref_1.o
1864 # so that the weak ref there goes to gold's symbol table first.
1865 dyn_weak_ref_1.so: dyn_weak_ref_1.o dyn_weak_ref_2.so gcctestdir/ld
1866         gcctestdir/ld -shared -o $@ dyn_weak_ref_2.so dyn_weak_ref_1.o
1867 dyn_weak_ref.stdout: dyn_weak_ref_1.so
1868         $(TEST_READELF) -sWD $< > $@
1869
1870
1871 # Test that --start-lib and --end-lib function correctly.
1872 check_PROGRAMS += start_lib_test
1873 start_lib_test: start_lib_test_main.o libstart_lib_test.a start_lib_test_2.o start_lib_test_3.o \
1874         gcctestdir/ld
1875         $(LINK) -Bgcctestdir/ -o $@ start_lib_test_main.o -L. -lstart_lib_test \
1876                 -Wl,--start-lib start_lib_test_2.o start_lib_test_3.o -Wl,--end-lib
1877 libstart_lib_test.a: start_lib_test_1.o
1878         $(TEST_AR) rc $@ $^
1879
1880 # Test that MEMORY region support works.
1881 check_SCRIPTS += memory_test.sh
1882 check_DATA += memory_test.stdout
1883 MOSTLYCLEANFILES += memory_test.stdout memory_test memory_test.o
1884 memory_test.o: memory_test.s
1885         $(COMPILE) -o $@ -c $<
1886 memory_test: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t
1887         $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -T $(srcdir)/memory_test.t -o $@ memory_test.o
1888 memory_test.stdout: memory_test
1889         $(TEST_READELF) -lWS  $< > $@
1890
1891 # End-to-end incremental linking tests.
1892 # Incremental linking is currently supported only on the x86_64 target.
1893
1894 if DEFAULT_TARGET_X86_64
1895
1896 check_PROGRAMS += incremental_test_2
1897 MOSTLYCLEANFILES += two_file_test_tmp_2.o
1898 incremental_test_2: two_file_test_1_v1.o two_file_test_1.o two_file_test_1b.o \
1899                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
1900         cp -f two_file_test_1_v1.o two_file_test_tmp_2.o
1901         $(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
1902         @sleep 1
1903         cp -f two_file_test_1.o two_file_test_tmp_2.o
1904         $(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
1905
1906 check_PROGRAMS += incremental_test_3
1907 MOSTLYCLEANFILES += two_file_test_tmp_3.o
1908 incremental_test_3: two_file_test_1.o two_file_test_1b_v1.o two_file_test_1b.o \
1909                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
1910         cp -f two_file_test_1b_v1.o two_file_test_tmp_3.o
1911         $(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
1912         @sleep 1
1913         cp -f two_file_test_1b.o two_file_test_tmp_3.o
1914         $(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
1915
1916 check_PROGRAMS += incremental_test_4
1917 MOSTLYCLEANFILES += incremental_test_4.base two_file_test_tmp_4.o
1918 incremental_test_4: two_file_test_1.o two_file_test_1b.o two_file_test_2_v1.o \
1919                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
1920         cp -f two_file_test_2_v1.o two_file_test_tmp_4.o
1921         $(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
1922         mv -f incremental_test_4 incremental_test_4.base
1923         @sleep 1
1924         cp -f two_file_test_2.o two_file_test_tmp_4.o
1925         $(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
1926
1927 check_PROGRAMS += incremental_copy_test
1928 incremental_copy_test: copy_test_v1.o copy_test.o copy_test_1.so copy_test_2.so
1929         cp -f copy_test_v1.o copy_test_tmp.o
1930         $(CXXLINK) -Wl,--incremental-full -Bgcctestdir/ -Wl,-R,. copy_test_tmp.o copy_test_1.so copy_test_2.so
1931         @sleep 1
1932         cp -f copy_test.o copy_test_tmp.o
1933         $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ -Wl,-R,. copy_test_tmp.o copy_test_1.so copy_test_2.so
1934
1935 check_PROGRAMS += incremental_common_test_1
1936 incremental_common_test_1: common_test_1_v1.o common_test_1_v2.o gcctestdir/ld
1937         cp -f common_test_1_v1.o common_test_1_tmp.o
1938         $(CXXLINK) -Wl,--incremental-full -Bgcctestdir/ common_test_1_tmp.o
1939         @sleep 1
1940         cp -f common_test_1_v2.o common_test_1_tmp.o
1941         $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ common_test_1_tmp.o
1942
1943 endif DEFAULT_TARGET_X86_64
1944
1945 endif GCC
1946 endif NATIVE_LINKER
1947
1948 # These tests work with native and cross linkers.
1949
1950 if NATIVE_OR_CROSS_LINKER
1951
1952 # Test script section order.
1953 check_SCRIPTS += script_test_10.sh
1954 check_DATA += script_test_10.stdout
1955 script_test_10.o: script_test_10.s
1956         $(TEST_AS) -o $@ $<
1957 script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld
1958         gcctestdir/ld -o $@ script_test_10.o -T $(srcdir)/script_test_10.t
1959 script_test_10.stdout: script_test_10
1960         $(TEST_READELF) -SW script_test_10 > $@
1961
1962 # These tests work with cross linkers only.
1963
1964 if DEFAULT_TARGET_I386
1965
1966 check_SCRIPTS += split_i386.sh
1967 check_DATA += split_i386_1.stdout split_i386_2.stdout \
1968         split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout
1969 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
1970 split_i386_1.o: split_i386_1.s
1971         $(TEST_AS) -o $@ $<
1972 split_i386_2.o: split_i386_2.s
1973         $(TEST_AS) -o $@ $<
1974 split_i386_3.o: split_i386_3.s
1975         $(TEST_AS) -o $@ $<
1976 split_i386_4.o: split_i386_4.s
1977         $(TEST_AS) -o $@ $<
1978 split_i386_n.o: split_i386_n.s
1979         $(TEST_AS) -o $@ $<
1980 split_i386_1: split_i386_1.o split_i386_n.o ../ld-new
1981         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_1.o split_i386_n.o
1982 split_i386_1.stdout: split_i386_1
1983         $(TEST_OBJDUMP) -d $< > $@
1984 split_i386_2: split_i386_2.o split_i386_n.o ../ld-new
1985         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_2.o split_i386_n.o
1986 split_i386_2.stdout: split_i386_2
1987         $(TEST_OBJDUMP) -d $< > $@
1988 split_i386_3.stdout: split_i386_3.o split_i386_n.o ../ld-new
1989         ../ld-new $(SPLIT_DEFSYMS) -o split_i386_3 split_i386_3.o split_i386_n.o > $@ 2>&1 || exit 0
1990 split_i386_4: split_i386_4.o split_i386_n.o ../ld-new
1991         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_4.o split_i386_n.o
1992 split_i386_4.stdout: split_i386_4
1993         $(TEST_OBJDUMP) -d $< > $@
1994 split_i386_r.stdout: split_i386_1.o split_i386_n.o ../ld-new
1995         ../ld-new -r split_i386_1.o split_i386_n.o -o split_i386_r > $@ 2>&1 || exit 0
1996 MOSTLYCLEANFILES += split_i386_1 split_i386_2 split_i386_3 \
1997         split_i386_4 split_i386_r
1998
1999 endif DEFAULT_TARGET_I386
2000
2001 if DEFAULT_TARGET_X86_64
2002
2003 check_SCRIPTS += split_x86_64.sh
2004 check_DATA += split_x86_64_1.stdout split_x86_64_2.stdout \
2005         split_x86_64_3.stdout split_x86_64_4.stdout split_x86_64_r.stdout
2006 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
2007 split_x86_64_1.o: split_x86_64_1.s
2008         $(TEST_AS) -o $@ $<
2009 split_x86_64_2.o: split_x86_64_2.s
2010         $(TEST_AS) -o $@ $<
2011 split_x86_64_3.o: split_x86_64_3.s
2012         $(TEST_AS) -o $@ $<
2013 split_x86_64_4.o: split_x86_64_4.s
2014         $(TEST_AS) -o $@ $<
2015 split_x86_64_n.o: split_x86_64_n.s
2016         $(TEST_AS) -o $@ $<
2017 split_x86_64_1: split_x86_64_1.o split_x86_64_n.o ../ld-new
2018         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_1.o split_x86_64_n.o
2019 split_x86_64_1.stdout: split_x86_64_1
2020         $(TEST_OBJDUMP) -d $< > $@
2021 split_x86_64_2: split_x86_64_2.o split_x86_64_n.o ../ld-new
2022         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_2.o split_x86_64_n.o
2023 split_x86_64_2.stdout: split_x86_64_2
2024         $(TEST_OBJDUMP) -d $< > $@
2025 split_x86_64_3.stdout: split_x86_64_3.o split_x86_64_n.o ../ld-new
2026         ../ld-new $(SPLIT_DEFSYMS) -o split_x86_64_3 split_x86_64_3.o split_x86_64_n.o > $@ 2>&1 || exit 0
2027 split_x86_64_4: split_x86_64_4.o split_x86_64_n.o ../ld-new
2028         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_4.o split_x86_64_n.o
2029 split_x86_64_4.stdout: split_x86_64_4
2030         $(TEST_OBJDUMP) -d $< > $@
2031 split_x86_64_r.stdout: split_x86_64_1.o split_x86_64_n.o ../ld-new
2032         ../ld-new -r split_x86_64_1.o split_x86_64_n.o -o split_x86_64_r > $@ 2>&1 || exit 0
2033 MOSTLYCLEANFILES += split_x86_64_1 split_x86_64_2 split_x86_64_3 \
2034         split_x86_64_4 split_x86_64_r
2035
2036 endif DEFAULT_TARGET_X86_64
2037
2038 if DEFAULT_TARGET_ARM
2039
2040 check_SCRIPTS += arm_abs_global.sh
2041 check_DATA += arm_abs_global.stdout
2042 arm_abs_lib.o: arm_abs_lib.s
2043         $(TEST_AS) -march=armv7-a -o $@ $<
2044 libarm_abs.so: arm_abs_lib.o ../ld-new
2045         ../ld-new -shared -o $@ arm_abs_lib.o
2046 arm_abs_global.o: arm_abs_global.s
2047         $(TEST_AS) -march=armv7-a -o $@ $<
2048 arm_abs_global: arm_abs_global.o libarm_abs.so ../ld-new
2049         ../ld-new -o $@ arm_abs_global.o -L. -larm_abs
2050 arm_abs_global.stdout: arm_abs_global
2051         $(TEST_READELF) -r $< > $@
2052
2053 MOSTLYCLEANFILES += arm_abs_global
2054
2055 check_SCRIPTS += arm_branch_in_range.sh arm_branch_out_of_range.sh
2056 check_DATA += arm_bl_in_range.stdout arm_bl_out_of_range.stdout \
2057         thumb_bl_in_range.stdout thumb_bl_out_of_range.stdout \
2058         thumb2_bl_in_range.stdout thumb2_bl_out_of_range.stdout \
2059         thumb_blx_in_range.stdout thumb_blx_out_of_range.stdout \
2060         thumb2_blx_in_range.stdout thumb2_blx_out_of_range.stdout \
2061         thumb_bl_out_of_range_local.stdout arm_thm_jump11.stdout \
2062         arm_thm_jump8.stdout
2063
2064 arm_bl_in_range.stdout: arm_bl_in_range
2065         $(TEST_OBJDUMP) -D $< > $@
2066
2067 arm_bl_in_range: arm_bl_in_range.o ../ld-new
2068         ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2069
2070 arm_bl_in_range.o: arm_bl_in_range.s
2071         $(TEST_AS) -o $@ $<
2072
2073 arm_bl_out_of_range.stdout: arm_bl_out_of_range
2074         $(TEST_OBJDUMP) -S $< > $@
2075
2076 arm_bl_out_of_range: arm_bl_out_of_range.o ../ld-new
2077         ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2078
2079 arm_bl_out_of_range.o: arm_bl_out_of_range.s
2080         $(TEST_AS) -o $@ $<
2081
2082 thumb_bl_in_range.stdout: thumb_bl_in_range
2083         $(TEST_OBJDUMP) -D $< > $@
2084
2085 thumb_bl_in_range: thumb_bl_in_range.o ../ld-new
2086         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2087
2088 thumb_bl_in_range.o: thumb_bl_in_range.s
2089         $(TEST_AS) -o $@ -march=armv5te $<
2090
2091 thumb_bl_out_of_range.stdout: thumb_bl_out_of_range
2092         $(TEST_OBJDUMP) -D $< > $@
2093
2094 thumb_bl_out_of_range: thumb_bl_out_of_range.o ../ld-new
2095         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2096
2097 thumb_bl_out_of_range.o: thumb_bl_out_of_range.s
2098         $(TEST_AS) -o $@ -march=armv5te $<
2099
2100 thumb2_bl_in_range.stdout: thumb2_bl_in_range
2101         $(TEST_OBJDUMP) -D $< > $@
2102
2103 thumb2_bl_in_range: thumb2_bl_in_range.o ../ld-new
2104         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2105
2106 thumb2_bl_in_range.o: thumb_bl_in_range.s
2107         $(TEST_AS) -o $@ -march=armv7-a $<
2108
2109 thumb2_bl_out_of_range.stdout: thumb2_bl_out_of_range
2110         $(TEST_OBJDUMP) -D $< > $@
2111
2112 thumb2_bl_out_of_range: thumb2_bl_out_of_range.o ../ld-new
2113         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2114
2115 thumb2_bl_out_of_range.o: thumb_bl_out_of_range.s
2116         $(TEST_AS) -o $@ -march=armv7-a $<
2117
2118 thumb_blx_in_range.stdout: thumb_blx_in_range
2119         $(TEST_OBJDUMP) -D $< > $@
2120
2121 thumb_blx_in_range: thumb_blx_in_range.o ../ld-new
2122         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2123
2124 thumb_blx_in_range.o: thumb_blx_in_range.s
2125         $(TEST_AS) -o $@ -march=armv5te $<
2126
2127 thumb_blx_out_of_range.stdout: thumb_blx_out_of_range
2128         $(TEST_OBJDUMP) -D $< > $@
2129
2130 thumb_blx_out_of_range: thumb_blx_out_of_range.o ../ld-new
2131         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2132
2133 thumb_blx_out_of_range.o: thumb_blx_out_of_range.s
2134         $(TEST_AS) -o $@ -march=armv5te $<
2135
2136 thumb2_blx_in_range.stdout: thumb2_blx_in_range
2137         $(TEST_OBJDUMP) -D $< > $@
2138
2139 thumb2_blx_in_range: thumb2_blx_in_range.o ../ld-new
2140         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2141
2142 thumb2_blx_in_range.o: thumb_blx_in_range.s
2143         $(TEST_AS) -o $@ -march=armv7-a $<
2144
2145 thumb2_blx_out_of_range.stdout: thumb2_blx_out_of_range
2146         $(TEST_OBJDUMP) -D $< > $@
2147
2148 thumb2_blx_out_of_range: thumb2_blx_out_of_range.o ../ld-new
2149         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2150
2151 thumb2_blx_out_of_range.o: thumb_blx_out_of_range.s
2152         $(TEST_AS) -o $@ -march=armv7-a $<
2153
2154 thumb_bl_out_of_range_local.stdout: thumb_bl_out_of_range_local
2155         $(TEST_OBJDUMP) -D $< > $@
2156
2157 thumb_bl_out_of_range_local: thumb_bl_out_of_range_local.o ../ld-new
2158         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2159
2160 thumb_bl_out_of_range_local.o: thumb_bl_out_of_range_local.s
2161         $(TEST_AS) -o $@ -march=armv5te $<
2162
2163 arm_thm_jump11.stdout: arm_thm_jump11
2164         $(TEST_OBJDUMP) -D $< > $@
2165
2166 arm_thm_jump11: arm_thm_jump11.o ../ld-new
2167         ../ld-new -T $(srcdir)/arm_thm_jump11.t -o $@ $<
2168
2169 arm_thm_jump11.o: arm_thm_jump11.s
2170         $(TEST_AS) -o $@ $<
2171
2172 arm_thm_jump8.stdout: arm_thm_jump8
2173         $(TEST_OBJDUMP) -D $< > $@
2174
2175 arm_thm_jump8: arm_thm_jump8.o ../ld-new
2176         ../ld-new -T $(srcdir)/arm_thm_jump8.t -o $@ $<
2177
2178 arm_thm_jump8.o: arm_thm_jump8.s
2179         $(TEST_AS) -o $@ $<
2180
2181 MOSTLYCLEANFILES += arm_bl_in_range arm_bl_out_of_range thumb_bl_in_range \
2182         thumb_bl_out_of_range thumb2_bl_in_range thumb2_bl_out_of_range \
2183         thumb_blx_in_range thumb_blx_out_of_range thumb2_blx_in_range \
2184         thumb2_blx_out_of_range thumb_bl_out_of_range_local arm_thm_jump11 \
2185         arm_thm_jump8
2186
2187 check_SCRIPTS += arm_fix_v4bx.sh
2188 check_DATA += arm_fix_v4bx.stdout arm_fix_v4bx_interworking.stdout \
2189         arm_no_fix_v4bx.stdout
2190
2191 arm_fix_v4bx.stdout: arm_fix_v4bx
2192         $(TEST_OBJDUMP) -D -j.text $< > $@
2193
2194 arm_fix_v4bx: arm_fix_v4bx.o ../ld-new
2195         ../ld-new --fix-v4bx -o $@ $<
2196
2197 arm_fix_v4bx.o: arm_fix_v4bx.s
2198         $(TEST_AS) -o $@ $<
2199
2200 arm_fix_v4bx_interworking.stdout: arm_fix_v4bx_interworking
2201         $(TEST_OBJDUMP) -D -j.text $< > $@
2202
2203 arm_fix_v4bx_interworking: arm_fix_v4bx.o ../ld-new
2204         ../ld-new --fix-v4bx-interworking -o $@ $<
2205
2206 arm_no_fix_v4bx.stdout: arm_no_fix_v4bx
2207         $(TEST_OBJDUMP) -D -j.text $< > $@
2208
2209 arm_no_fix_v4bx: arm_fix_v4bx.o ../ld-new
2210         ../ld-new -o $@ $<
2211
2212 MOSTLYCLEANFILES += arm_fix_v4bx arm_fix_v4bx_interworking arm_no_fix_v4bx
2213
2214 check_SCRIPTS += arm_attr_merge.sh
2215 check_DATA += arm_attr_merge_6.stdout arm_attr_merge_6r.stdout \
2216         arm_attr_merge_7.stdout
2217
2218 arm_attr_merge_6.stdout: arm_attr_merge_6
2219         $(TEST_READELF) -A $< > $@
2220
2221 arm_attr_merge_6: arm_attr_merge_6a.o arm_attr_merge_6b.o
2222         ../ld-new -o $@ arm_attr_merge_6a.o arm_attr_merge_6b.o
2223
2224 arm_attr_merge_6a.o: arm_attr_merge_6a.s
2225         $(TEST_AS) -o $@ $<
2226
2227 arm_attr_merge_6b.o: arm_attr_merge_6b.s
2228         $(TEST_AS) -o $@ $<
2229
2230 arm_attr_merge_6r.stdout: arm_attr_merge_6r
2231         $(TEST_READELF) -A $< > $@
2232
2233 arm_attr_merge_6r: arm_attr_merge_6b.o arm_attr_merge_6a.o
2234         ../ld-new -o $@ arm_attr_merge_6b.o arm_attr_merge_6a.o
2235
2236 arm_attr_merge_7.stdout: arm_attr_merge_7
2237         $(TEST_READELF) -A $< > $@
2238
2239 arm_attr_merge_7: arm_attr_merge_7a.o arm_attr_merge_7b.o
2240         ../ld-new -o $@ arm_attr_merge_7a.o arm_attr_merge_7b.o
2241
2242 arm_attr_merge_7a.o: arm_attr_merge_7a.s
2243         $(TEST_AS) -o $@ $<
2244
2245 arm_attr_merge_7b.o: arm_attr_merge_7b.s
2246         $(TEST_AS) -o $@ $<
2247
2248 MOSTLYCLEANFILES += arm_attr_merge_6 arm_attr_merge_6r arm_attr_merge_7
2249
2250 # Cortex-A8 workaround test.
2251
2252 check_SCRIPTS += arm_cortex_a8.sh
2253 check_DATA += arm_cortex_a8_b_cond.stdout arm_cortex_a8_b.stdout \
2254         arm_cortex_a8_bl.stdout arm_cortex_a8_blx.stdout \
2255         arm_cortex_a8_local.stdout arm_cortex_a8_local_reloc.stdout
2256
2257 arm_cortex_a8_b_cond.stdout: arm_cortex_a8_b_cond
2258         $(TEST_OBJDUMP) -D -j.text $< > $@
2259
2260 arm_cortex_a8_b_cond: arm_cortex_a8_b_cond.o ../ld-new
2261         ../ld-new -o $@ $<
2262
2263 arm_cortex_a8_b_cond.o: arm_cortex_a8_b_cond.s
2264         $(TEST_AS) -o $@ $<
2265
2266 arm_cortex_a8_b.stdout: arm_cortex_a8_b
2267         $(TEST_OBJDUMP) -D -j.text $< > $@
2268
2269 arm_cortex_a8_b: arm_cortex_a8_b.o ../ld-new
2270         ../ld-new --fix-cortex-a8 -o $@ $<
2271
2272 arm_cortex_a8_b.o: arm_cortex_a8_b.s
2273         $(TEST_AS) -o $@ $<
2274
2275 arm_cortex_a8_bl.stdout: arm_cortex_a8_bl
2276         $(TEST_OBJDUMP) -D -j.text $< > $@
2277
2278 arm_cortex_a8_bl: arm_cortex_a8_bl.o ../ld-new
2279         ../ld-new -o $@ $<
2280
2281 arm_cortex_a8_bl.o: arm_cortex_a8_bl.s
2282         $(TEST_AS) -o $@ $<
2283
2284 arm_cortex_a8_blx.stdout: arm_cortex_a8_blx
2285         $(TEST_OBJDUMP) -D -j.text $< > $@
2286
2287 arm_cortex_a8_blx: arm_cortex_a8_blx.o ../ld-new
2288         ../ld-new -o $@ $<
2289
2290 arm_cortex_a8_blx.o: arm_cortex_a8_blx.s
2291         $(TEST_AS) -o $@ $<
2292
2293 arm_cortex_a8_local.stdout: arm_cortex_a8_local
2294         $(TEST_OBJDUMP) -D -j.text $< > $@
2295
2296 arm_cortex_a8_local: arm_cortex_a8_local.o ../ld-new
2297         ../ld-new -o $@ $<
2298
2299 arm_cortex_a8_local.o: arm_cortex_a8_local.s
2300         $(TEST_AS) -o $@ $<
2301
2302 arm_cortex_a8_local_reloc.stdout: arm_cortex_a8_local_reloc
2303         $(TEST_OBJDUMP) -D -j.text $< > $@
2304
2305 arm_cortex_a8_local_reloc: arm_cortex_a8_local_reloc.o ../ld-new
2306         ../ld-new -o $@ $<
2307
2308 arm_cortex_a8_local_reloc.o: arm_cortex_a8_local_reloc.s
2309         $(TEST_AS) -o $@ $<
2310
2311 MOSTLYCLEANFILES += arm_cortex_a8_b_cond arm_cortex_a8_b arm_cortex_a8_bl \
2312         arm_cortex_a8_blx arm_cortex_a8_local arm_cortex_a8_local_reloc
2313
2314 check_SCRIPTS += arm_exidx_test.sh
2315 check_DATA += arm_exidx_test.stdout
2316
2317 arm_exidx_test.stdout: arm_exidx_test.so
2318         $(TEST_READELF) -S $< > $@
2319
2320 arm_exidx_test.so: arm_exidx_test.o ../ld-new
2321         ../ld-new -shared -o $@ $<
2322
2323 arm_exidx_test.o: arm_exidx_test.s
2324         $(TEST_AS) -o $@ $<
2325
2326 check_SCRIPTS += pr12826.sh
2327 check_DATA += pr12826.stdout
2328
2329 pr12826.stdout: pr12826.so
2330         $(TEST_READELF) -A $< > $@
2331
2332 pr12826.so: pr12826_1.o pr12826_2.o ../ld-new
2333         ../ld-new -shared -o $@ $<
2334
2335 pr12826_1.o: pr12826_1.s
2336         $(TEST_AS) -o $@ $<
2337
2338 pr12826_2.o: pr12826_2.s
2339         $(TEST_AS) -o $@ $<
2340
2341 endif DEFAULT_TARGET_ARM
2342
2343 endif NATIVE_OR_CROSS_LINKER
2344