* symtab.cc (Symbol::versioned_name): New function.
[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 += ver_test_12
1093 ver_test_12_SOURCES = ver_test_main_2.cc
1094 ver_test_12_DEPENDENCIES = gcctestdir/ld ver_test_12.o
1095 ver_test_12_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1096 ver_test_12_LDADD = ver_test_12.o
1097 ver_test_12.o: gcctestdir/ld ver_test_1.o ver_test_2.o ver_test_4.o
1098         gcctestdir/ld -r -o $@ ver_test_1.o ver_test_2.o ver_test_4.o
1099
1100 check_PROGRAMS += protected_1
1101 protected_1_SOURCES = \
1102         protected_main_1.cc protected_main_2.cc protected_main_3.cc
1103 protected_1_DEPENDENCIES = gcctestdir/ld protected_1.so
1104 protected_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1105 protected_1_LDADD = protected_1.so
1106
1107 protected_1.so: gcctestdir/ld protected_1_pic.o protected_2_pic.o protected_3_pic.o
1108         $(CXXLINK) -Bgcctestdir/ -shared protected_1_pic.o protected_2_pic.o protected_3_pic.o
1109 protected_1_pic.o: protected_1.cc
1110         $(CXXCOMPILE) -c -fpic -o $@ $<
1111 protected_2_pic.o: protected_2.cc
1112         $(CXXCOMPILE) -c -fpic -o $@ $<
1113 protected_3_pic.o: protected_3.cc
1114         $(CXXCOMPILE) -c -fpic -o $@ $<
1115
1116 check_PROGRAMS += protected_2
1117 protected_2_SOURCES = protected_main_1.cc protected_3.cc
1118 protected_2_DEPENDENCIES = gcctestdir/ld protected_1.so
1119 protected_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1120 protected_2_LDADD = protected_1.so
1121
1122 check_DATA += protected_3.err
1123 MOSTLYCLEANFILES += protected_3.err
1124 protected_4_pic.o: protected_4.cc
1125         $(CXXCOMPILE) -c -fpic -o $@ $<
1126 protected_3.err: protected_4_pic.o gcctestdir/ld
1127         @echo $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o "2>$@"
1128         @if $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o 2>$@; then \
1129           echo 1>&2 "Link of protected_4.so should have failed"; \
1130           rm -f $@; \
1131           exit 1; \
1132         fi
1133
1134 check_PROGRAMS += relro_test
1135 check_SCRIPTS += relro_test.sh
1136 check_DATA += relro_test.stdout
1137 relro_test_SOURCES = relro_test_main.cc
1138 relro_test_DEPENDENCIES = gcctestdir/ld relro_test.so
1139 relro_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1140 relro_test_LDADD = relro_test.so
1141 relro_test.so: gcctestdir/ld relro_test_pic.o
1142         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro relro_test_pic.o
1143 relro_test_pic.o: relro_test.cc
1144         $(CXXCOMPILE) -c -fpic -o $@ $<
1145 relro_test.stdout: relro_test.so
1146         $(TEST_READELF) -SlW relro_test.so > relro_test.stdout
1147
1148 check_PROGRAMS += relro_strip_test
1149 relro_strip_test_SOURCES = relro_test_main.cc
1150 relro_strip_test_DEPENDENCIES = gcctestdir/ld relro_strip_test.so
1151 relro_strip_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1152 relro_strip_test_LDADD = relro_strip_test.so
1153 relro_strip_test.so: relro_test.so
1154         $(TEST_STRIP) -o $@ $<
1155
1156 check_PROGRAMS += relro_script_test
1157 relro_script_test_SOURCES = relro_test_main.cc
1158 relro_script_test_DEPENDENCIES = gcctestdir/ld relro_script_test.so
1159 relro_script_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1160 relro_script_test_LDADD = relro_script_test.so
1161 relro_script_test.so: gcctestdir/ld relro_script_test.t relro_test_pic.o
1162         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro -T $(srcdir)/relro_script_test.t relro_test_pic.o
1163
1164 check_PROGRAMS += script_test_1
1165 script_test_1_SOURCES = script_test_1.cc
1166 script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
1167 script_test_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_1.t
1168 script_test_1_LDADD =
1169
1170 check_PROGRAMS += script_test_2
1171 script_test_2_SOURCES = script_test_2.cc script_test_2a.cc script_test_2b.cc
1172 script_test_2_DEPENDENCIES = gcctestdir/ld script_test_2.t
1173 script_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_2.t
1174 script_test_2_LDADD =
1175
1176 check_PROGRAMS += justsyms
1177 justsyms_SOURCES = justsyms_1.cc
1178 justsyms_DEPENDENCIES = gcctestdir/ld justsyms_2r.o
1179 justsyms_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_2r.o
1180 justsyms_LDADD =
1181 justsyms_2.o: justsyms_2.cc
1182         $(CXXCOMPILE) -c -o $@ $<
1183 justsyms_2r.o: justsyms_2.o gcctestdir/ld $(srcdir)/justsyms.t
1184         gcctestdir/ld -o $@ -r -T $(srcdir)/justsyms.t justsyms_2.o
1185
1186 check_PROGRAMS += binary_test
1187 MOSTLYCLEANFILES += binary.txt
1188 binary_test_SOURCES = binary_test.cc
1189 binary_test_DEPENDENCIES = gcctestdir/ld binary.txt
1190 binary_test_LDFLAGS = -Bgcctestdir/ -Wl,--format,binary,binary.txt,--format,elf
1191 binary_test_LDADD =
1192 # Copy the file to the build directory to avoid worrying about the
1193 # full pathname in the generated symbols.
1194 binary.txt: $(srcdir)/binary.in
1195         rm -f $@
1196         $(LN_S) $< $@
1197
1198 check_SCRIPTS += ver_matching_test.sh
1199 check_DATA += ver_matching_test.stdout
1200 MOSTLYCLEANFILES += ver_matching_test.stdout
1201 ver_matching_def.so: ver_matching_def_pic.o $(srcdir)/version_script.map gcctestdir/ld
1202         $(CXXLINK) -O0 -Bgcctestdir/ -shared ver_matching_def_pic.o -Wl,--version-script=$(srcdir)/version_script.map
1203 ver_matching_def_pic.o: ver_matching_def.cc
1204         $(CXXCOMPILE) -O0 -c -fpic -o $@ $<
1205 ver_matching_test.stdout: ver_matching_def.so
1206         $(TEST_OBJDUMP) -T ver_matching_def.so | $(TEST_CXXFILT) > ver_matching_test.stdout
1207
1208 check_PROGRAMS += script_test_3
1209 check_SCRIPTS += script_test_3.sh
1210 check_DATA += script_test_3.stdout
1211 MOSTLYCLEANFILES += script_test_3.stdout
1212 script_test_3: basic_test.o gcctestdir/ld script_test_3.t
1213         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_3.t
1214 script_test_3.stdout: script_test_3
1215         $(TEST_READELF) -SlW script_test_3 > script_test_3.stdout
1216
1217 check_PROGRAMS += tls_phdrs_script_test
1218 tls_phdrs_script_test_SOURCES = $(tls_test_SOURCES)
1219 tls_phdrs_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_3.t
1220 tls_phdrs_script_test_LDFLAGS = $(tls_test_LDFLAGS) -T $(srcdir)/script_test_3.t
1221 tls_phdrs_script_test_LDADD = $(tls_test_LDADD)
1222
1223 check_SCRIPTS += script_test_4.sh
1224 check_DATA += script_test_4.stdout
1225 MOSTLYCLEANFILES += script_test_4
1226 script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
1227         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_4.t
1228 script_test_4.stdout: script_test_4
1229         $(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
1230
1231 check_PROGRAMS += tls_script_test
1232 tls_script_test_SOURCES = $(tls_test_SOURCES)
1233 tls_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_4.t
1234 tls_script_test_LDFLAGS = $(tls_test_LDFLAGS) -T $(srcdir)/script_test_4.t
1235 tls_script_test_LDADD = $(tls_test_LDADD)
1236
1237 check_SCRIPTS += script_test_5.sh
1238 check_DATA += script_test_5.stdout
1239 MOSTLYCLEANFILES += script_test_5
1240 script_test_5: script_test_5.o gcctestdir/ld $(srcdir)/script_test_5.t
1241         $(CXXLINK) -Bgcctestdir/ script_test_5.o -T $(srcdir)/script_test_5.t
1242 script_test_5.stdout: script_test_5
1243         $(TEST_READELF) -SW script_test_5 > script_test_5.stdout
1244
1245 check_SCRIPTS += script_test_6.sh
1246 check_DATA += script_test_6.stdout
1247 MOSTLYCLEANFILES += script_test_6
1248 script_test_6: basic_test.o gcctestdir/ld $(srcdir)/script_test_6.t
1249         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_6.t \
1250         -Wl,-Ttext=0x10001000 -Wl,-Tdata=0x10200000 -Wl,-Tbss=0x10400000
1251 script_test_6.stdout: script_test_6
1252         $(TEST_READELF) -SlW script_test_6 > script_test_6.stdout
1253
1254 check_SCRIPTS += script_test_7.sh
1255 check_DATA += script_test_7.stdout
1256 MOSTLYCLEANFILES += script_test_7
1257 script_test_7: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1258         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t
1259 script_test_7.stdout: script_test_7
1260         $(TEST_READELF) -SlW script_test_7 > script_test_7.stdout
1261
1262 check_SCRIPTS += script_test_8.sh
1263 check_DATA += script_test_8.stdout
1264 MOSTLYCLEANFILES += script_test_8
1265 script_test_8: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1266         $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_7.t \
1267         -Wl,-Ttext=0x20001000 -Wl,-Tdata=0x20200000 -Wl,-Tbss=0x20400000
1268 script_test_8.stdout: script_test_8
1269         $(TEST_READELF) -SlW script_test_8 > script_test_8.stdout
1270
1271
1272 check_SCRIPTS += script_test_9.sh
1273 check_DATA += script_test_9.stdout
1274 script_test_9.o: script_test_9.cc
1275         $(CXXCOMPILE) -O0 -c -o $@ $<
1276 script_test_9: gcctestdir/ld $(srcdir)/script_test_9.t script_test_9.o
1277         $(CXXLINK) -Bgcctestdir/ script_test_9.o -T $(srcdir)/script_test_9.t
1278 script_test_9.stdout: script_test_9
1279         $(TEST_READELF) -lW script_test_9 > script_test_9.stdout
1280
1281
1282 # Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new,
1283 # and --dynamic-list-cpp-typeinfo
1284
1285 check_SCRIPTS += dynamic_list.sh
1286 check_DATA += dynamic_list.stdout
1287 MOSTLYCLEANFILES += dynamic_list dynamic_list.stdout
1288 dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t
1289         $(CXXLINK) -Bgcctestdir/ basic_test.o \
1290           -Wl,--dynamic-list $(srcdir)/dynamic_list.t \
1291           -Wl,--dynamic-list-data \
1292           -Wl,--dynamic-list-cpp-new \
1293           -Wl,--dynamic-list-cpp-typeinfo
1294 dynamic_list.stdout: dynamic_list
1295         $(TEST_READELF) -W --dyn-syms dynamic_list > dynamic_list.stdout
1296
1297 check_PROGRAMS += thin_archive_test_1
1298 MOSTLYCLEANFILES += libthin1.a libthin3.a libthinall.a \
1299         alt/thin_archive_test_2.o alt/thin_archive_test_4.o \
1300         alt/libthin2.a alt/libthin4.a
1301 thin_archive_test_1_SOURCES = thin_archive_main.cc
1302 thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a
1303 thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt
1304 thin_archive_test_1_LDADD = libthin1.a -lthin2
1305
1306 check_PROGRAMS += thin_archive_test_2
1307 thin_archive_test_2_SOURCES = thin_archive_main.cc
1308 thin_archive_test_2_DEPENDENCIES = gcctestdir/ld libthinall.a
1309 thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L.
1310 thin_archive_test_2_LDADD = -lthinall
1311
1312 libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o
1313         rm -f $@
1314         $(TEST_AR) crT $@ $^
1315 alt/libthin2.a: thin_archive_test_3.o alt/thin_archive_test_4.o
1316         rm -f $@
1317         $(TEST_AR) crT $@ $^
1318 libthin3.a: thin_archive_test_1.o alt/thin_archive_test_4.o
1319         rm -f $@
1320         $(TEST_AR) crT $@ $^
1321 alt/libthin4.a: alt/thin_archive_test_2.o thin_archive_test_3.o
1322         rm -f $@
1323         $(TEST_AR) crT $@ $^
1324 libthinall.a: libthin3.a alt/libthin4.a
1325         rm -f $@
1326         $(TEST_AR) crT $@ $^
1327 alt/thin_archive_test_2.o: thin_archive_test_2.cc
1328         test -d alt || mkdir -p alt
1329         $(CXXCOMPILE) -c -o $@ $<
1330 alt/thin_archive_test_4.o: thin_archive_test_4.cc
1331         test -d alt || mkdir -p alt
1332         $(CXXCOMPILE) -c -o $@ $<
1333
1334 if PLUGINS
1335
1336 check_PROGRAMS += plugin_test_1
1337 check_SCRIPTS += plugin_test_1.sh
1338 check_DATA += plugin_test_1.err
1339 MOSTLYCLEANFILES += plugin_test_1.err
1340 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
1341         $(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
1342 plugin_test_1.err: plugin_test_1
1343         @touch plugin_test_1.err
1344
1345 check_PROGRAMS += plugin_test_2
1346 check_SCRIPTS += plugin_test_2.sh
1347 check_DATA += plugin_test_2.err
1348 MOSTLYCLEANFILES += plugin_test_2.err
1349 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
1350         $(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
1351 plugin_test_2.err: plugin_test_2
1352         @touch plugin_test_2.err
1353
1354 check_PROGRAMS += plugin_test_3
1355 check_SCRIPTS += plugin_test_3.sh
1356 check_DATA += plugin_test_3.err
1357 MOSTLYCLEANFILES += plugin_test_3.err
1358 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
1359         $(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
1360 plugin_test_3.err: plugin_test_3
1361         @touch plugin_test_3.err
1362
1363 check_PROGRAMS += plugin_test_4
1364 check_SCRIPTS += plugin_test_4.sh
1365 check_DATA += plugin_test_4.err
1366 MOSTLYCLEANFILES += plugin_test_4.a plugin_test_4.err
1367 plugin_test_4: two_file_test_main.o plugin_test_4.a gcctestdir/ld plugin_test.so
1368         $(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
1369 plugin_test_4.err: plugin_test_4
1370         @touch plugin_test_4.err
1371
1372 plugin_test_4.a: two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms
1373         $(TEST_AR) cr $@ $^
1374
1375 check_PROGRAMS += plugin_test_5
1376 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
1377         $(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
1378
1379 check_PROGRAMS += plugin_test_6
1380 check_SCRIPTS += plugin_test_6.sh
1381 check_DATA += plugin_test_6.err
1382 MOSTLYCLEANFILES += plugin_test_6.err
1383 plugin_test_6: plugin_common_test_1.syms plugin_common_test_2.syms gcctestdir/ld plugin_test.so
1384         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.syms plugin_common_test_2.syms 2>plugin_test_6.err
1385 plugin_test_6.err: plugin_test_6
1386         @touch plugin_test_6.err
1387
1388 check_PROGRAMS += plugin_test_7
1389 check_SCRIPTS += plugin_test_7.sh
1390 check_DATA += plugin_test_7.err plugin_test_7.syms
1391 MOSTLYCLEANFILES += plugin_test_7.err
1392 plugin_test_7: plugin_test_7_1.o plugin_test_7_1.syms plugin_test_7_2.o gcctestdir/ld plugin_test.so
1393         $(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
1394 plugin_test_7.syms: plugin_test_7
1395         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1396 plugin_test_7_1.o: plugin_test_7_1.c
1397         $(COMPILE) -DLTO -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1398 plugin_test_7_1_orig.o: plugin_test_7_1.c
1399         $(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1400 plugin_test_7_1.syms: plugin_test_7_1_orig.o
1401         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1402 plugin_test_7_2.o: plugin_test_7_2.c
1403         $(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1404 plugin_test_7.err: plugin_test_7
1405
1406 # Test plugins with -r.
1407 check_PROGRAMS += plugin_test_8
1408 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
1409         ../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
1410 plugin_test_8: plugin_test_8.o gcctestdir/ld
1411         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle plugin_test_8.o
1412
1413 # Test that symbols known in the IR file but not in the replacement file
1414 # produce an unresolved symbol error.
1415 check_DATA += plugin_test_9.err
1416 MOSTLYCLEANFILES += plugin_test_9.err
1417 plugin_test_9.err: two_file_test_main.o two_file_test_1c.syms two_file_test_2.syms gcctestdir/ld plugin_test.so
1418         @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>$@"
1419         @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 \
1420           echo 1>&2 "Link of plugin_test_9 should have failed"; \
1421           rm -f $@; \
1422           exit 1; \
1423         fi
1424 # Make a .syms file that claims to define the symbol _Z4t16av.
1425 two_file_test_1c.syms: two_file_test_1.syms two_file_test_1c.o
1426         cp two_file_test_1.syms $@.tmp
1427         grep "_Z4t16av" two_file_test_1b.syms >> $@.tmp
1428         mv -f $@.tmp $@
1429 # Make a copy of two_file_test_1.o, which does not define the symbol _Z4t16av.
1430 MOSTLYCLEANFILES += two_file_test_1c.o
1431 two_file_test_1c.o: two_file_test_1.o
1432         cp two_file_test_1.o $@
1433
1434 plugin_test.so: plugin_test.o
1435         $(LINK) -Bgcctestdir/ -shared plugin_test.o
1436 plugin_test.o: plugin_test.c
1437         $(COMPILE) -O0 -c -fpic -o $@ $<
1438
1439 two_file_test_main.syms: two_file_test_main.o
1440         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1441 two_file_test_1.syms: two_file_test_1.o
1442         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1443 two_file_test_1b.syms: two_file_test_1b.o
1444         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1445 two_file_test_2.syms: two_file_test_2.o
1446         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1447 plugin_common_test_1.syms: plugin_common_test_1.o
1448         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1449 plugin_common_test_2.syms: plugin_common_test_2.o
1450         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1451
1452 empty.syms:
1453         @echo "" >$@
1454         @echo "Symbol table" >>$@
1455
1456 MOSTLYCLEANFILES += unused.c
1457 unused.syms: unused.o
1458         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1459         @echo "     1: 00000000     4 FUNC    GLOBAL DEFAULT    1 UNUSED" >>$@
1460 unused.o: unused.c
1461         $(COMPILE) -c -o $@ $<
1462 unused.c:
1463         @cp /dev/null $@
1464
1465 endif PLUGINS
1466
1467 check_PROGRAMS += exclude_libs_test
1468 check_SCRIPTS += exclude_libs_test.sh
1469 check_DATA += exclude_libs_test.syms
1470 MOSTLYCLEANFILES += exclude_libs_test.syms libexclude_libs_test_1.a \
1471         libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
1472 exclude_libs_test_SOURCES = exclude_libs_test.c
1473 exclude_libs_test_DEPENDENCIES = gcctestdir/ld libexclude_libs_test_1.a \
1474         libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
1475 exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. -Lalt \
1476         -Wl,--exclude-libs,dummy:libexclude_libs_test_1 \
1477         -Wl,--exclude-libs,libexclude_libs_test_3
1478 exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 \
1479         alt/libexclude_libs_test_3.a
1480 exclude_libs_test.syms: exclude_libs_test
1481         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1482 libexclude_libs_test_1.a: exclude_libs_test_1.o
1483         $(TEST_AR) rc $@ $^
1484 libexclude_libs_test_2.a: exclude_libs_test_2.o
1485         $(TEST_AR) rc $@ $^
1486 alt/libexclude_libs_test_3.a: exclude_libs_test_3.o
1487         test -d alt || mkdir -p alt
1488         $(TEST_AR) rc $@ $^
1489
1490 check_PROGRAMS += local_labels_test
1491 local_labels_test.o: ver_test_6.c
1492         $(COMPILE) -g -c -Wa,-L -o $@ $<
1493 local_labels_test: local_labels_test.o
1494         $(LINK) -Bgcctestdir/ local_labels_test.o
1495
1496 check_PROGRAMS += discard_locals_test
1497 check_SCRIPTS += discard_locals_test.sh
1498 check_DATA += discard_locals_test.syms \
1499         discard_locals_relocatable_test1.syms \
1500         discard_locals_relocatable_test2.syms
1501 MOSTLYCLEANFILES += discard_locals_test.syms \
1502         discard_locals_relocatable_test1.syms \
1503         discard_locals_relocatable_test2.syms \
1504         discard_locals_relocatable_test1.out \
1505         discard_locals_relocatable_test2.out
1506 discard_locals_test_SOURCES = discard_locals_test.c
1507 discard_locals_test_LDFLAGS = -Bgcctestdir/ -Wl,--discard-locals
1508 discard_locals_test.syms: discard_locals_test
1509         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1510 # '-Wa,-L' is required to preserve the local label used for testing.
1511 discard_locals_test.o: discard_locals_test.c
1512         $(COMPILE) -c -Wa,-L -o $@ $<
1513
1514 discard_locals_relocatable_test1.syms: discard_locals_relocatable_test1.out
1515         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1516 discard_locals_relocatable_test.o: discard_locals_relocatable_test.c
1517         $(COMPILE) -c -Wa,-L -fPIC -o $@ $<
1518 discard_locals_relocatable_test1.out: discard_locals_relocatable_test.o ../ld-new
1519         ../ld-new --discard-locals -relocatable -o $@ $<
1520
1521 discard_locals_relocatable_test2.syms: discard_locals_relocatable_test2.out
1522         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1523 discard_locals_relocatable_test2.out: discard_locals_relocatable_test.o ../ld-new
1524         ../ld-new --discard-all -relocatable -o $@ $<
1525
1526 if MCMODEL_MEDIUM
1527 check_PROGRAMS += large
1528 large_SOURCES = large.c
1529 large_CFLAGS = -mcmodel=medium
1530 large_DEPENDENCIES = gcctestdir/ld
1531 large_LDFLAGS = -Bgcctestdir/
1532 large_LDADD =
1533 endif MCMODEL_MEDIUM
1534
1535 # Test that hidden and internal symbols in the main program cannot be
1536 # referenced by a shared library.
1537 check_SCRIPTS += hidden_test.sh
1538 check_DATA += hidden_test.err
1539 MOSTLYCLEANFILES += hidden_test hidden_test.err
1540 libhidden.so: hidden_test_1.c gcctestdir/ld
1541         $(COMPILE) -Bgcctestdir/ -g -shared -fPIC -w -o $@ $(srcdir)/hidden_test_1.c
1542 hidden_test: hidden_test_main.o libhidden.so gcctestdir/ld
1543         $(LINK) -Bgcctestdir/ -Wl,-R,. hidden_test_main.o libhidden.so 2>hidden_test.err
1544 hidden_test.err: hidden_test
1545         @touch hidden_test.err
1546
1547 # Test -retain-symbols-file.
1548 check_SCRIPTS += retain_symbols_file_test.sh
1549 check_DATA += retain_symbols_file_test.stdout
1550 MOSTLYCLEANFILES += retain_symbols_file_test retain_symbols_file_test.in \
1551                     retain_symbols_file_test.stdout
1552 retain_symbols_file_test.so: basic_pic_test.o gcctestdir/ld
1553         echo 'main' > retain_symbols_file_test.in
1554         echo 't1' >> retain_symbols_file_test.in
1555         echo '_ZN4t16bC1Ev' >> retain_symbols_file_test.in
1556         echo '_ZNK4t20a3getEv' >> retain_symbols_file_test.in
1557         echo '_Z3t18v' >> retain_symbols_file_test.in
1558         echo '__tcf_0' >> retain_symbols_file_test.in   
1559         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-retain-symbols-file,retain_symbols_file_test.in basic_pic_test.o
1560 retain_symbols_file_test.stdout: retain_symbols_file_test.so
1561         $(TEST_NM) -C retain_symbols_file_test.so > $@
1562
1563
1564 # Test that if the output file already exists and is empty,
1565 # it will get execute permission.
1566 check_PROGRAMS += permission_test
1567 permission_test: basic_test.o gcctestdir/ld
1568         umask 022; \
1569         rm -f $@; \
1570         touch $@; \
1571         chmod 600 $@; \
1572         $(CXXLINK) -Bgcctestdir/ basic_test.o
1573
1574 # Check -l:foo.a
1575 check_PROGRAMS += searched_file_test
1576 MOSTLYCLEANFILES += searched_file_test searched_file_test_lib.o \
1577                     alt/searched_file_test_lib.a
1578 searched_file_test_SOURCES = searched_file_test.cc
1579 searched_file_test_DEPENDENCIES = alt/searched_file_test_lib.a
1580 searched_file_test_LDFLAGS = -Bgcctestdir/ -Lalt
1581 searched_file_test_LDADD = -l:searched_file_test_lib.a
1582 searched_file_test_lib.o: searched_file_test_lib.cc
1583         $(CXXCOMPILE) -c -o $@ $<
1584 alt/searched_file_test_lib.a: searched_file_test_lib.o
1585         test -d alt || mkdir -p alt
1586         $(TEST_AR) rc $@ $^
1587
1588 # Test that no .gnu.version sections are created when 
1589 # symbol versioning is not used.
1590 check_SCRIPTS += no_version_test.sh
1591 check_DATA += no_version_test.stdout
1592 MOSTLYCLEANFILES += libno_version_test.so no_version_test.stdout
1593 # We invoke the linker directly since gcc may include additional objects that
1594 # uses symbol versioning.
1595 libno_version_test.so: no_version_test.o gcctestdir/ld
1596         gcctestdir/ld -shared -o $@ no_version_test.o
1597 no_version_test.o: no_version_test.c
1598         $(COMPILE) -o $@ -c -fPIC $<
1599 no_version_test.stdout: libno_version_test.so
1600         $(TEST_OBJDUMP) -h $< > $@
1601
1602 # Test STT_GNU_IFUNC symbols.
1603 if IFUNC
1604
1605 ifuncmod1.o: ifuncmod1.c
1606         $(COMPILE) -c -fpic -o $@ $<
1607 ifuncmod1.so: ifuncmod1.o gcctestdir/ld
1608         $(LINK) -Bgcctestdir/ -shared ifuncmod1.o
1609
1610 ifuncdep1.o: ifuncmod1.c
1611         $(COMPILE) -c -o $@ $<
1612
1613 ifuncmain1pic.o: ifuncmain1.c
1614         $(COMPILE) -c -fpic -o $@ $<
1615 ifuncmain1pie.o: ifuncmain1.c
1616         $(COMPILE) -c -fpie -o $@ $<
1617
1618 check_PROGRAMS += ifuncmain1static
1619 ifuncmain1static_SOURCES = ifuncmain1.c
1620 ifuncmain1static_DEPENDENCIES = gcctestdir/ld ifuncdep1.o
1621 ifuncmain1static_LDFLAGS = -Bgcctestdir/ -static
1622 ifuncmain1static_LDADD = ifuncdep1.o
1623
1624 check_PROGRAMS += ifuncmain1picstatic
1625 ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
1626         $(LINK) -Bgcctestdir/ -static ifuncmain1pic.o ifuncmod1.o
1627
1628 check_PROGRAMS += ifuncmain1
1629 ifuncmain1_SOURCES = ifuncmain1.c
1630 ifuncmain1_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
1631 ifuncmain1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1632 ifuncmain1_LDADD = ifuncmod1.so
1633
1634 check_PROGRAMS += ifuncmain1pic
1635 ifuncmain1pic: ifuncmain1pic.o ifuncmod1.so gcctestdir/ld
1636         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
1637
1638 check_PROGRAMS += ifuncmain1vis
1639 ifuncmain1vis_SOURCES = ifuncmain1vis.c
1640 ifuncmain1vis_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
1641 ifuncmain1vis_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1642 ifuncmain1vis_LDADD = ifuncmod1.so
1643
1644 check_PROGRAMS += ifuncmain1vispic
1645 ifuncmain1vispic.o: ifuncmain1vis.c
1646         $(COMPILE) -c -fpic -o $@ $<
1647 ifuncmain1vispic: ifuncmain1vispic.o ifuncmod1.so gcctestdir/ld
1648         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
1649
1650 check_PROGRAMS += ifuncmain1staticpic
1651 ifuncmain1staticpic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
1652         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.o
1653
1654 check_PROGRAMS += ifuncmain1pie
1655 ifuncmain1pie: ifuncmain1pie.o ifuncmod1.so gcctestdir/ld
1656         $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.so -Wl,-R,.
1657
1658 check_PROGRAMS += ifuncmain1vispie
1659 ifuncmain1vispie.o: ifuncmain1vis.c
1660         $(COMPILE) -c -fpie -o $@ $<
1661 ifuncmain1vispie: ifuncmain1vispie.o ifuncmod1.so gcctestdir/ld
1662         $(LINK) -Bgcctestdir/ -pie ifuncmain1vispie.o ifuncmod1.so -Wl,-R,.
1663
1664 check_PROGRAMS += ifuncmain1staticpie
1665 ifuncmain1staticpie: ifuncmain1pie.o ifuncmod1.o gcctestdir/ld
1666         $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.o
1667
1668 ifuncmain2pic.o: ifuncmain2.c
1669         $(COMPILE) -c -fpic -o $@ $<
1670
1671 ifuncdep2pic.o: ifuncdep2.c
1672         $(COMPILE) -c -fpic -o $@ $<
1673
1674 check_PROGRAMS += ifuncmain2static
1675 ifuncmain2static_SOURCES = ifuncmain2.c ifuncdep2.c
1676 ifuncmain2static_DEPENDENCIES = gcctestdir/ld
1677 ifuncmain2static_LDFLAGS = -Bgcctestdir/ -static
1678 ifuncmain2static_LDADD =
1679
1680 check_PROGRAMS += ifuncmain2picstatic
1681 ifuncmain2picstatic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
1682         $(LINK) -Bgcctestdir/ -static ifuncmain2pic.o ifuncdep2pic.o
1683
1684 check_PROGRAMS += ifuncmain2
1685 ifuncmain2_SOURCES = ifuncmain2.c ifuncdep2.c
1686 ifuncmain2_DEPENDENCIES = gcctestdir/ld
1687 ifuncmain2_LDFLAGS = -Bgcctestdir/
1688 ifuncmain2_LDADD =
1689
1690 check_PROGRAMS += ifuncmain2pic
1691 ifuncmain2pic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
1692         $(LINK) -Bgcctestdir/ ifuncmain2pic.o ifuncdep2pic.o
1693
1694 ifuncmod3.o: ifuncmod3.c
1695         $(COMPILE) -c -fpic -o $@ $<
1696 ifuncmod3.so: ifuncmod3.o gcctestdir/ld
1697         $(LINK) -Bgcctestdir/ -shared ifuncmod3.o
1698
1699 check_PROGRAMS += ifuncmain3
1700 ifuncmain3_SOURCES = ifuncmain3.c
1701 ifuncmain3_DEPENDENCIES = gcctestdir/ld ifuncmod3.so
1702 ifuncmain3_LDFLAGS = -Bgcctestdir/ -Wl,--export-dynamic -Wl,-R,.
1703 ifuncmain3_LDADD = -ldl
1704
1705 ifuncmain4pic.o: ifuncmain4.c
1706         $(COMPILE) -c -fpic -o $@ $<
1707
1708 check_PROGRAMS += ifuncmain4static
1709 ifuncmain4static_SOURCES = ifuncmain4.c
1710 ifuncmain4static_DEPENDENCIES = gcctestdir/ld
1711 ifuncmain4static_LDFLAGS = -Bgcctestdir/ -static
1712 ifuncmain4static_LDADD =
1713
1714 check_PROGRAMS += ifuncmain4picstatic
1715 ifuncmain4picstatic: ifuncmain4pic.o gcctestdir/ld
1716         $(LINK) -Bgcctestdir/ -static ifuncmain4pic.o
1717
1718 check_PROGRAMS += ifuncmain4
1719 ifuncmain4_SOURCES = ifuncmain4.c
1720 ifuncmain4_DEPENDENCIES = gcctestdir/ld
1721 ifuncmain4_LDFLAGS = -Bgcctestdir/
1722 ifuncmain4_LDADD =
1723
1724 ifuncmain5pic.o: ifuncmain5.c
1725         $(COMPILE) -c -fpic -o $@ $<
1726
1727 ifuncmain5pie.o: ifuncmain5.c
1728         $(COMPILE) -c -fpie -o $@ $<
1729
1730 ifuncmod5.o: ifuncmod5.c
1731         $(COMPILE) -c -fpic -o $@ $<
1732 ifuncmod5.so: ifuncmod5.o gcctestdir/ld
1733         $(LINK) -Bgcctestdir/ -shared ifuncmod5.o
1734
1735 ifuncdep5.o: ifuncmod5.c
1736         $(COMPILE) -c -o $@ $<
1737
1738 check_PROGRAMS += ifuncmain5static
1739 ifuncmain5static_SOURCES = ifuncmain5.c
1740 ifuncmain5static_DEPENDENCIES = gcctestdir/ld ifuncdep5.o
1741 ifuncmain5static_LDFLAGS = -Bgcctestdir/ -static
1742 ifuncmain5static_LDADD = ifuncdep5.o
1743
1744 check_PROGRAMS += ifuncmain5picstatic
1745 ifuncmain5picstatic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
1746         $(LINK) -Bgcctestdir/ -static ifuncmain5pic.o ifuncmod5.o
1747
1748 check_PROGRAMS += ifuncmain5
1749 ifuncmain5_SOURCES = ifuncmain5.c
1750 ifuncmain5_DEPENDENCIES = gcctestdir/ld ifuncmod5.so
1751 ifuncmain5_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1752 ifuncmain5_LDADD = ifuncmod5.so
1753
1754 check_PROGRAMS += ifuncmain5pic
1755 ifuncmain5pic: ifuncmain5pic.o ifuncmod5.so gcctestdir/ld
1756         $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.so -Wl,-R,.
1757
1758 check_PROGRAMS += ifuncmain5staticpic
1759 ifuncmain5staticpic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
1760         $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.o
1761
1762 check_PROGRAMS += ifuncmain5pie
1763 ifuncmain5pie: ifuncmain5pie.o ifuncmod5.so gcctestdir/ld
1764         $(LINK) -Bgcctestdir/ -pie ifuncmain5pie.o ifuncmod5.so -Wl,-R,.
1765
1766 ifuncmain6pie.o: ifuncmain6pie.c
1767         $(COMPILE) -c -fpie -o $@ $<
1768
1769 ifuncmod6.o: ifuncmod6.c
1770         $(COMPILE) -c -fpic -o $@ $<
1771 ifuncmod6.so: ifuncmod6.o gcctestdir/ld
1772         $(LINK) -Bgcctestdir/ -shared ifuncmod6.o
1773
1774 check_PROGRAMS += ifuncmain6pie
1775 ifuncmain6pie: ifuncmain6pie.o ifuncmod6.so gcctestdir/ld
1776         $(LINK) -Bgcctestdir/ -pie ifuncmain6pie.o ifuncmod6.so -Wl,-R,.
1777
1778 ifuncmain7pic.o: ifuncmain7.c
1779         $(COMPILE) -c -fpic -o $@ $<
1780
1781 ifuncmain7pie.o: ifuncmain7.c
1782         $(COMPILE) -c -fpie -o $@ $<
1783
1784 check_PROGRAMS += ifuncmain7static
1785 ifuncmain7static_SOURCES = ifuncmain7.c
1786 ifuncmain7static_DEPENDENCIES = gcctestdir/ld
1787 ifuncmain7static_LDFLAGS = -Bgcctestdir/ -static
1788 ifuncmain7static_LDADD =
1789
1790 check_PROGRAMS += ifuncmain7picstatic
1791 ifuncmain7picstatic: ifuncmain7pic.o gcctestdir/ld
1792         $(LINK) -Bgcctestdir/ -static ifuncmain7pic.o
1793
1794 check_PROGRAMS += ifuncmain7
1795 ifuncmain7_SOURCES = ifuncmain7.c
1796 ifuncmain7_DEPENDENCIES = gcctestdir/ld
1797 ifuncmain7_LDFLAGS = -Bgcctestdir/
1798 ifuncmain7_LDADD =
1799
1800 check_PROGRAMS += ifuncmain7pic
1801 ifuncmain7pic: ifuncmain7pic.o gcctestdir/ld
1802         $(LINK) -Bgcctestdir/ ifuncmain7pic.o
1803
1804 check_PROGRAMS += ifuncmain7pie
1805 ifuncmain7pie: ifuncmain7pie.o gcctestdir/ld
1806         $(LINK) -Bgcctestdir/ -pie ifuncmain7pie.o
1807
1808 endif IFUNC
1809
1810 # Test that strong reference to a weak symbol in a DSO remains strong.
1811 check_SCRIPTS += strong_ref_weak_def.sh
1812 check_DATA += strong_ref_weak_def.stdout
1813 MOSTLYCLEANFILES += strong_ref_weak_def_1.so strong_ref_weak_def_2.so \
1814         strong_ref_weak_def.stdout
1815 strong_ref_weak_def_2.o: strong_ref_weak_def_2.c
1816         $(COMPILE) -o $@ -c -fPIC $<
1817 strong_ref_weak_def_2.so: strong_ref_weak_def_2.o gcctestdir/ld
1818         gcctestdir/ld -shared -o $@ strong_ref_weak_def_2.o
1819 strong_ref_weak_def_1.o: strong_ref_weak_def_1.c
1820         $(COMPILE) -o $@ -c -fPIC $<
1821 strong_ref_weak_def_1.so: strong_ref_weak_def_1.o strong_ref_weak_def_2.so \
1822         gcctestdir/ld
1823         gcctestdir/ld -shared -o $@ strong_ref_weak_def_1.o \
1824                 strong_ref_weak_def_2.so
1825 strong_ref_weak_def.stdout: strong_ref_weak_def_1.so
1826         $(TEST_READELF) -sWD $< > $@
1827
1828 # Test that a strong weak reference remains strong if there is another
1829 # weak reference in a DSO.
1830 check_SCRIPTS += dyn_weak_ref.sh
1831 check_DATA += dyn_weak_ref.stdout
1832 MOSTLYCLEANFILES += dyn_weak_ref_1.so dyn_weak_ref_2.so \
1833         dyn_weak_ref.stdout
1834 dyn_weak_ref_2.o: dyn_weak_ref_2.c
1835         $(COMPILE) -o $@ -c -fPIC $<
1836 dyn_weak_ref_2.so: dyn_weak_ref_2.o gcctestdir/ld
1837         gcctestdir/ld -shared -o $@ dyn_weak_ref_2.o
1838 dyn_weak_ref_1.o: dyn_weak_ref_1.c
1839         $(COMPILE) -o $@ -c -fPIC $<
1840 # We intentionally put dyn_weak_ref_2.so in front of dyn_weak_ref_1.o
1841 # so that the weak ref there goes to gold's symbol table first.
1842 dyn_weak_ref_1.so: dyn_weak_ref_1.o dyn_weak_ref_2.so gcctestdir/ld
1843         gcctestdir/ld -shared -o $@ dyn_weak_ref_2.so dyn_weak_ref_1.o
1844 dyn_weak_ref.stdout: dyn_weak_ref_1.so
1845         $(TEST_READELF) -sWD $< > $@
1846
1847
1848 # Test that --start-lib and --end-lib function correctly.
1849 check_PROGRAMS += start_lib_test
1850 start_lib_test: start_lib_test_main.o libstart_lib_test.a start_lib_test_2.o start_lib_test_3.o \
1851         gcctestdir/ld
1852         $(LINK) -Bgcctestdir/ -o $@ start_lib_test_main.o -L. -lstart_lib_test \
1853                 -Wl,--start-lib start_lib_test_2.o start_lib_test_3.o -Wl,--end-lib
1854 libstart_lib_test.a: start_lib_test_1.o
1855         $(TEST_AR) rc $@ $^
1856
1857 # Test that MEMORY region support works.
1858 check_SCRIPTS += memory_test.sh
1859 check_DATA += memory_test.stdout
1860 MOSTLYCLEANFILES += memory_test.stdout memory_test memory_test.o
1861 memory_test.o: memory_test.s
1862         $(COMPILE) -o $@ -c $<
1863 memory_test: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t
1864         $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -T $(srcdir)/memory_test.t -o $@ memory_test.o
1865 memory_test.stdout: memory_test
1866         $(TEST_READELF) -lWS  $< > $@
1867
1868 # End-to-end incremental linking tests.
1869 # Incremental linking is currently supported only on the x86_64 target.
1870
1871 if DEFAULT_TARGET_X86_64
1872
1873 check_PROGRAMS += incremental_test_2
1874 MOSTLYCLEANFILES += two_file_test_tmp_2.o
1875 incremental_test_2: two_file_test_1_v1.o two_file_test_1.o two_file_test_1b.o \
1876                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
1877         cp -f two_file_test_1_v1.o two_file_test_tmp_2.o
1878         $(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
1879         @sleep 1
1880         cp -f two_file_test_1.o two_file_test_tmp_2.o
1881         $(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
1882
1883 check_PROGRAMS += incremental_test_3
1884 MOSTLYCLEANFILES += two_file_test_tmp_3.o
1885 incremental_test_3: two_file_test_1.o two_file_test_1b_v1.o two_file_test_1b.o \
1886                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
1887         cp -f two_file_test_1b_v1.o two_file_test_tmp_3.o
1888         $(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
1889         @sleep 1
1890         cp -f two_file_test_1b.o two_file_test_tmp_3.o
1891         $(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
1892
1893 check_PROGRAMS += incremental_test_4
1894 MOSTLYCLEANFILES += incremental_test_4.base two_file_test_tmp_4.o
1895 incremental_test_4: two_file_test_1.o two_file_test_1b.o two_file_test_2_v1.o \
1896                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
1897         cp -f two_file_test_2_v1.o two_file_test_tmp_4.o
1898         $(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
1899         mv -f incremental_test_4 incremental_test_4.base
1900         @sleep 1
1901         cp -f two_file_test_2.o two_file_test_tmp_4.o
1902         $(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
1903
1904 check_PROGRAMS += incremental_copy_test
1905 incremental_copy_test: copy_test_v1.o copy_test.o copy_test_1.so copy_test_2.so
1906         cp -f copy_test_v1.o copy_test_tmp.o
1907         $(CXXLINK) -Wl,--incremental-full -Bgcctestdir/ -Wl,-R,. copy_test_tmp.o copy_test_1.so copy_test_2.so
1908         @sleep 1
1909         cp -f copy_test.o copy_test_tmp.o
1910         $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ -Wl,-R,. copy_test_tmp.o copy_test_1.so copy_test_2.so
1911
1912 check_PROGRAMS += incremental_common_test_1
1913 incremental_common_test_1: common_test_1_v1.o common_test_1_v2.o gcctestdir/ld
1914         cp -f common_test_1_v1.o common_test_1_tmp.o
1915         $(CXXLINK) -Wl,--incremental-full -Bgcctestdir/ common_test_1_tmp.o
1916         @sleep 1
1917         cp -f common_test_1_v2.o common_test_1_tmp.o
1918         $(CXXLINK) -Wl,--incremental-update -Bgcctestdir/ common_test_1_tmp.o
1919
1920 endif DEFAULT_TARGET_X86_64
1921
1922 endif GCC
1923 endif NATIVE_LINKER
1924
1925 # These tests work with native and cross linkers.
1926
1927 if NATIVE_OR_CROSS_LINKER
1928
1929 # Test script section order.
1930 check_SCRIPTS += script_test_10.sh
1931 check_DATA += script_test_10.stdout
1932 script_test_10.o: script_test_10.s
1933         $(TEST_AS) -o $@ $<
1934 script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld
1935         gcctestdir/ld -o $@ script_test_10.o -T $(srcdir)/script_test_10.t
1936 script_test_10.stdout: script_test_10
1937         $(TEST_READELF) -SW script_test_10 > $@
1938
1939 # These tests work with cross linkers only.
1940
1941 if DEFAULT_TARGET_I386
1942
1943 check_SCRIPTS += split_i386.sh
1944 check_DATA += split_i386_1.stdout split_i386_2.stdout \
1945         split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout
1946 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
1947 split_i386_1.o: split_i386_1.s
1948         $(TEST_AS) -o $@ $<
1949 split_i386_2.o: split_i386_2.s
1950         $(TEST_AS) -o $@ $<
1951 split_i386_3.o: split_i386_3.s
1952         $(TEST_AS) -o $@ $<
1953 split_i386_4.o: split_i386_4.s
1954         $(TEST_AS) -o $@ $<
1955 split_i386_n.o: split_i386_n.s
1956         $(TEST_AS) -o $@ $<
1957 split_i386_1: split_i386_1.o split_i386_n.o ../ld-new
1958         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_1.o split_i386_n.o
1959 split_i386_1.stdout: split_i386_1
1960         $(TEST_OBJDUMP) -d $< > $@
1961 split_i386_2: split_i386_2.o split_i386_n.o ../ld-new
1962         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_2.o split_i386_n.o
1963 split_i386_2.stdout: split_i386_2
1964         $(TEST_OBJDUMP) -d $< > $@
1965 split_i386_3.stdout: split_i386_3.o split_i386_n.o ../ld-new
1966         ../ld-new $(SPLIT_DEFSYMS) -o split_i386_3 split_i386_3.o split_i386_n.o > $@ 2>&1 || exit 0
1967 split_i386_4: split_i386_4.o split_i386_n.o ../ld-new
1968         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_4.o split_i386_n.o
1969 split_i386_4.stdout: split_i386_4
1970         $(TEST_OBJDUMP) -d $< > $@
1971 split_i386_r.stdout: split_i386_1.o split_i386_n.o ../ld-new
1972         ../ld-new -r split_i386_1.o split_i386_n.o -o split_i386_r > $@ 2>&1 || exit 0
1973 MOSTLYCLEANFILES += split_i386_1 split_i386_2 split_i386_3 \
1974         split_i386_4 split_i386_r
1975
1976 endif DEFAULT_TARGET_I386
1977
1978 if DEFAULT_TARGET_X86_64
1979
1980 check_SCRIPTS += split_x86_64.sh
1981 check_DATA += split_x86_64_1.stdout split_x86_64_2.stdout \
1982         split_x86_64_3.stdout split_x86_64_4.stdout split_x86_64_r.stdout
1983 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
1984 split_x86_64_1.o: split_x86_64_1.s
1985         $(TEST_AS) -o $@ $<
1986 split_x86_64_2.o: split_x86_64_2.s
1987         $(TEST_AS) -o $@ $<
1988 split_x86_64_3.o: split_x86_64_3.s
1989         $(TEST_AS) -o $@ $<
1990 split_x86_64_4.o: split_x86_64_4.s
1991         $(TEST_AS) -o $@ $<
1992 split_x86_64_n.o: split_x86_64_n.s
1993         $(TEST_AS) -o $@ $<
1994 split_x86_64_1: split_x86_64_1.o split_x86_64_n.o ../ld-new
1995         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_1.o split_x86_64_n.o
1996 split_x86_64_1.stdout: split_x86_64_1
1997         $(TEST_OBJDUMP) -d $< > $@
1998 split_x86_64_2: split_x86_64_2.o split_x86_64_n.o ../ld-new
1999         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_2.o split_x86_64_n.o
2000 split_x86_64_2.stdout: split_x86_64_2
2001         $(TEST_OBJDUMP) -d $< > $@
2002 split_x86_64_3.stdout: split_x86_64_3.o split_x86_64_n.o ../ld-new
2003         ../ld-new $(SPLIT_DEFSYMS) -o split_x86_64_3 split_x86_64_3.o split_x86_64_n.o > $@ 2>&1 || exit 0
2004 split_x86_64_4: split_x86_64_4.o split_x86_64_n.o ../ld-new
2005         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_4.o split_x86_64_n.o
2006 split_x86_64_4.stdout: split_x86_64_4
2007         $(TEST_OBJDUMP) -d $< > $@
2008 split_x86_64_r.stdout: split_x86_64_1.o split_x86_64_n.o ../ld-new
2009         ../ld-new -r split_x86_64_1.o split_x86_64_n.o -o split_x86_64_r > $@ 2>&1 || exit 0
2010 MOSTLYCLEANFILES += split_x86_64_1 split_x86_64_2 split_x86_64_3 \
2011         split_x86_64_4 split_x86_64_r
2012
2013 endif DEFAULT_TARGET_X86_64
2014
2015 if DEFAULT_TARGET_ARM
2016
2017 check_SCRIPTS += arm_abs_global.sh
2018 check_DATA += arm_abs_global.stdout
2019 arm_abs_lib.o: arm_abs_lib.s
2020         $(TEST_AS) -march=armv7-a -o $@ $<
2021 libarm_abs.so: arm_abs_lib.o ../ld-new
2022         ../ld-new -shared -o $@ arm_abs_lib.o
2023 arm_abs_global.o: arm_abs_global.s
2024         $(TEST_AS) -march=armv7-a -o $@ $<
2025 arm_abs_global: arm_abs_global.o libarm_abs.so ../ld-new
2026         ../ld-new -o $@ arm_abs_global.o -L. -larm_abs
2027 arm_abs_global.stdout: arm_abs_global
2028         $(TEST_READELF) -r $< > $@
2029
2030 MOSTLYCLEANFILES += arm_abs_global
2031
2032 check_SCRIPTS += arm_branch_in_range.sh arm_branch_out_of_range.sh
2033 check_DATA += arm_bl_in_range.stdout arm_bl_out_of_range.stdout \
2034         thumb_bl_in_range.stdout thumb_bl_out_of_range.stdout \
2035         thumb2_bl_in_range.stdout thumb2_bl_out_of_range.stdout \
2036         thumb_blx_in_range.stdout thumb_blx_out_of_range.stdout \
2037         thumb2_blx_in_range.stdout thumb2_blx_out_of_range.stdout \
2038         thumb_bl_out_of_range_local.stdout arm_thm_jump11.stdout \
2039         arm_thm_jump8.stdout
2040
2041 arm_bl_in_range.stdout: arm_bl_in_range
2042         $(TEST_OBJDUMP) -D $< > $@
2043
2044 arm_bl_in_range: arm_bl_in_range.o ../ld-new
2045         ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2046
2047 arm_bl_in_range.o: arm_bl_in_range.s
2048         $(TEST_AS) -o $@ $<
2049
2050 arm_bl_out_of_range.stdout: arm_bl_out_of_range
2051         $(TEST_OBJDUMP) -S $< > $@
2052
2053 arm_bl_out_of_range: arm_bl_out_of_range.o ../ld-new
2054         ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2055
2056 arm_bl_out_of_range.o: arm_bl_out_of_range.s
2057         $(TEST_AS) -o $@ $<
2058
2059 thumb_bl_in_range.stdout: thumb_bl_in_range
2060         $(TEST_OBJDUMP) -D $< > $@
2061
2062 thumb_bl_in_range: thumb_bl_in_range.o ../ld-new
2063         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2064
2065 thumb_bl_in_range.o: thumb_bl_in_range.s
2066         $(TEST_AS) -o $@ -march=armv5te $<
2067
2068 thumb_bl_out_of_range.stdout: thumb_bl_out_of_range
2069         $(TEST_OBJDUMP) -D $< > $@
2070
2071 thumb_bl_out_of_range: thumb_bl_out_of_range.o ../ld-new
2072         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2073
2074 thumb_bl_out_of_range.o: thumb_bl_out_of_range.s
2075         $(TEST_AS) -o $@ -march=armv5te $<
2076
2077 thumb2_bl_in_range.stdout: thumb2_bl_in_range
2078         $(TEST_OBJDUMP) -D $< > $@
2079
2080 thumb2_bl_in_range: thumb2_bl_in_range.o ../ld-new
2081         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2082
2083 thumb2_bl_in_range.o: thumb_bl_in_range.s
2084         $(TEST_AS) -o $@ -march=armv7-a $<
2085
2086 thumb2_bl_out_of_range.stdout: thumb2_bl_out_of_range
2087         $(TEST_OBJDUMP) -D $< > $@
2088
2089 thumb2_bl_out_of_range: thumb2_bl_out_of_range.o ../ld-new
2090         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2091
2092 thumb2_bl_out_of_range.o: thumb_bl_out_of_range.s
2093         $(TEST_AS) -o $@ -march=armv7-a $<
2094
2095 thumb_blx_in_range.stdout: thumb_blx_in_range
2096         $(TEST_OBJDUMP) -D $< > $@
2097
2098 thumb_blx_in_range: thumb_blx_in_range.o ../ld-new
2099         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2100
2101 thumb_blx_in_range.o: thumb_blx_in_range.s
2102         $(TEST_AS) -o $@ -march=armv5te $<
2103
2104 thumb_blx_out_of_range.stdout: thumb_blx_out_of_range
2105         $(TEST_OBJDUMP) -D $< > $@
2106
2107 thumb_blx_out_of_range: thumb_blx_out_of_range.o ../ld-new
2108         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2109
2110 thumb_blx_out_of_range.o: thumb_blx_out_of_range.s
2111         $(TEST_AS) -o $@ -march=armv5te $<
2112
2113 thumb2_blx_in_range.stdout: thumb2_blx_in_range
2114         $(TEST_OBJDUMP) -D $< > $@
2115
2116 thumb2_blx_in_range: thumb2_blx_in_range.o ../ld-new
2117         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2118
2119 thumb2_blx_in_range.o: thumb_blx_in_range.s
2120         $(TEST_AS) -o $@ -march=armv7-a $<
2121
2122 thumb2_blx_out_of_range.stdout: thumb2_blx_out_of_range
2123         $(TEST_OBJDUMP) -D $< > $@
2124
2125 thumb2_blx_out_of_range: thumb2_blx_out_of_range.o ../ld-new
2126         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2127
2128 thumb2_blx_out_of_range.o: thumb_blx_out_of_range.s
2129         $(TEST_AS) -o $@ -march=armv7-a $<
2130
2131 thumb_bl_out_of_range_local.stdout: thumb_bl_out_of_range_local
2132         $(TEST_OBJDUMP) -D $< > $@
2133
2134 thumb_bl_out_of_range_local: thumb_bl_out_of_range_local.o ../ld-new
2135         ../ld-new -T $(srcdir)/thumb_branch_range.t -o $@ $<
2136
2137 thumb_bl_out_of_range_local.o: thumb_bl_out_of_range_local.s
2138         $(TEST_AS) -o $@ -march=armv5te $<
2139
2140 arm_thm_jump11.stdout: arm_thm_jump11
2141         $(TEST_OBJDUMP) -D $< > $@
2142
2143 arm_thm_jump11: arm_thm_jump11.o ../ld-new
2144         ../ld-new -T $(srcdir)/arm_thm_jump11.t -o $@ $<
2145
2146 arm_thm_jump11.o: arm_thm_jump11.s
2147         $(TEST_AS) -o $@ $<
2148
2149 arm_thm_jump8.stdout: arm_thm_jump8
2150         $(TEST_OBJDUMP) -D $< > $@
2151
2152 arm_thm_jump8: arm_thm_jump8.o ../ld-new
2153         ../ld-new -T $(srcdir)/arm_thm_jump8.t -o $@ $<
2154
2155 arm_thm_jump8.o: arm_thm_jump8.s
2156         $(TEST_AS) -o $@ $<
2157
2158 MOSTLYCLEANFILES += arm_bl_in_range arm_bl_out_of_range thumb_bl_in_range \
2159         thumb_bl_out_of_range thumb2_bl_in_range thumb2_bl_out_of_range \
2160         thumb_blx_in_range thumb_blx_out_of_range thumb2_blx_in_range \
2161         thumb2_blx_out_of_range thumb_bl_out_of_range_local arm_thm_jump11 \
2162         arm_thm_jump8
2163
2164 check_SCRIPTS += arm_fix_v4bx.sh
2165 check_DATA += arm_fix_v4bx.stdout arm_fix_v4bx_interworking.stdout \
2166         arm_no_fix_v4bx.stdout
2167
2168 arm_fix_v4bx.stdout: arm_fix_v4bx
2169         $(TEST_OBJDUMP) -D -j.text $< > $@
2170
2171 arm_fix_v4bx: arm_fix_v4bx.o ../ld-new
2172         ../ld-new --fix-v4bx -o $@ $<
2173
2174 arm_fix_v4bx.o: arm_fix_v4bx.s
2175         $(TEST_AS) -o $@ $<
2176
2177 arm_fix_v4bx_interworking.stdout: arm_fix_v4bx_interworking
2178         $(TEST_OBJDUMP) -D -j.text $< > $@
2179
2180 arm_fix_v4bx_interworking: arm_fix_v4bx.o ../ld-new
2181         ../ld-new --fix-v4bx-interworking -o $@ $<
2182
2183 arm_no_fix_v4bx.stdout: arm_no_fix_v4bx
2184         $(TEST_OBJDUMP) -D -j.text $< > $@
2185
2186 arm_no_fix_v4bx: arm_fix_v4bx.o ../ld-new
2187         ../ld-new -o $@ $<
2188
2189 MOSTLYCLEANFILES += arm_fix_v4bx arm_fix_v4bx_interworking arm_no_fix_v4bx
2190
2191 check_SCRIPTS += arm_attr_merge.sh
2192 check_DATA += arm_attr_merge_6.stdout arm_attr_merge_6r.stdout \
2193         arm_attr_merge_7.stdout
2194
2195 arm_attr_merge_6.stdout: arm_attr_merge_6
2196         $(TEST_READELF) -A $< > $@
2197
2198 arm_attr_merge_6: arm_attr_merge_6a.o arm_attr_merge_6b.o
2199         ../ld-new -o $@ arm_attr_merge_6a.o arm_attr_merge_6b.o
2200
2201 arm_attr_merge_6a.o: arm_attr_merge_6a.s
2202         $(TEST_AS) -o $@ $<
2203
2204 arm_attr_merge_6b.o: arm_attr_merge_6b.s
2205         $(TEST_AS) -o $@ $<
2206
2207 arm_attr_merge_6r.stdout: arm_attr_merge_6r
2208         $(TEST_READELF) -A $< > $@
2209
2210 arm_attr_merge_6r: arm_attr_merge_6b.o arm_attr_merge_6a.o
2211         ../ld-new -o $@ arm_attr_merge_6b.o arm_attr_merge_6a.o
2212
2213 arm_attr_merge_7.stdout: arm_attr_merge_7
2214         $(TEST_READELF) -A $< > $@
2215
2216 arm_attr_merge_7: arm_attr_merge_7a.o arm_attr_merge_7b.o
2217         ../ld-new -o $@ arm_attr_merge_7a.o arm_attr_merge_7b.o
2218
2219 arm_attr_merge_7a.o: arm_attr_merge_7a.s
2220         $(TEST_AS) -o $@ $<
2221
2222 arm_attr_merge_7b.o: arm_attr_merge_7b.s
2223         $(TEST_AS) -o $@ $<
2224
2225 MOSTLYCLEANFILES += arm_attr_merge_6 arm_attr_merge_6r arm_attr_merge_7
2226
2227 # Cortex-A8 workaround test.
2228
2229 check_SCRIPTS += arm_cortex_a8.sh
2230 check_DATA += arm_cortex_a8_b_cond.stdout arm_cortex_a8_b.stdout \
2231         arm_cortex_a8_bl.stdout arm_cortex_a8_blx.stdout \
2232         arm_cortex_a8_local.stdout arm_cortex_a8_local_reloc.stdout
2233
2234 arm_cortex_a8_b_cond.stdout: arm_cortex_a8_b_cond
2235         $(TEST_OBJDUMP) -D -j.text $< > $@
2236
2237 arm_cortex_a8_b_cond: arm_cortex_a8_b_cond.o ../ld-new
2238         ../ld-new -o $@ $<
2239
2240 arm_cortex_a8_b_cond.o: arm_cortex_a8_b_cond.s
2241         $(TEST_AS) -o $@ $<
2242
2243 arm_cortex_a8_b.stdout: arm_cortex_a8_b
2244         $(TEST_OBJDUMP) -D -j.text $< > $@
2245
2246 arm_cortex_a8_b: arm_cortex_a8_b.o ../ld-new
2247         ../ld-new --fix-cortex-a8 -o $@ $<
2248
2249 arm_cortex_a8_b.o: arm_cortex_a8_b.s
2250         $(TEST_AS) -o $@ $<
2251
2252 arm_cortex_a8_bl.stdout: arm_cortex_a8_bl
2253         $(TEST_OBJDUMP) -D -j.text $< > $@
2254
2255 arm_cortex_a8_bl: arm_cortex_a8_bl.o ../ld-new
2256         ../ld-new -o $@ $<
2257
2258 arm_cortex_a8_bl.o: arm_cortex_a8_bl.s
2259         $(TEST_AS) -o $@ $<
2260
2261 arm_cortex_a8_blx.stdout: arm_cortex_a8_blx
2262         $(TEST_OBJDUMP) -D -j.text $< > $@
2263
2264 arm_cortex_a8_blx: arm_cortex_a8_blx.o ../ld-new
2265         ../ld-new -o $@ $<
2266
2267 arm_cortex_a8_blx.o: arm_cortex_a8_blx.s
2268         $(TEST_AS) -o $@ $<
2269
2270 arm_cortex_a8_local.stdout: arm_cortex_a8_local
2271         $(TEST_OBJDUMP) -D -j.text $< > $@
2272
2273 arm_cortex_a8_local: arm_cortex_a8_local.o ../ld-new
2274         ../ld-new -o $@ $<
2275
2276 arm_cortex_a8_local.o: arm_cortex_a8_local.s
2277         $(TEST_AS) -o $@ $<
2278
2279 arm_cortex_a8_local_reloc.stdout: arm_cortex_a8_local_reloc
2280         $(TEST_OBJDUMP) -D -j.text $< > $@
2281
2282 arm_cortex_a8_local_reloc: arm_cortex_a8_local_reloc.o ../ld-new
2283         ../ld-new -o $@ $<
2284
2285 arm_cortex_a8_local_reloc.o: arm_cortex_a8_local_reloc.s
2286         $(TEST_AS) -o $@ $<
2287
2288 MOSTLYCLEANFILES += arm_cortex_a8_b_cond arm_cortex_a8_b arm_cortex_a8_bl \
2289         arm_cortex_a8_blx arm_cortex_a8_local arm_cortex_a8_local_reloc
2290
2291 check_SCRIPTS += arm_exidx_test.sh
2292 check_DATA += arm_exidx_test.stdout
2293
2294 arm_exidx_test.stdout: arm_exidx_test.so
2295         $(TEST_READELF) -S $< > $@
2296
2297 arm_exidx_test.so: arm_exidx_test.o ../ld-new
2298         ../ld-new -shared -o $@ $<
2299
2300 arm_exidx_test.o: arm_exidx_test.s
2301         $(TEST_AS) -o $@ $<
2302
2303 check_SCRIPTS += pr12826.sh
2304 check_DATA += pr12826.stdout
2305
2306 pr12826.stdout: pr12826.so
2307         $(TEST_READELF) -A $< > $@
2308
2309 pr12826.so: pr12826_1.o pr12826_2.o ../ld-new
2310         ../ld-new -shared -o $@ $<
2311
2312 pr12826_1.o: pr12826_1.s
2313         $(TEST_AS) -o $@ $<
2314
2315 pr12826_2.o: pr12826_2.s
2316         $(TEST_AS) -o $@ $<
2317
2318 endif DEFAULT_TARGET_ARM
2319
2320 endif NATIVE_OR_CROSS_LINKER
2321