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