Fix Makefile so make clean removes overlooked files.
[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 # This is where we get zlib from.  zlib is in ../../zlib unless we were
11 # configured with --with-system-zlib, in which case ../../zlib either
12 # doesn't exist or not configured.
13 ZLIB = -L../../zlib -lz
14
15 # The two_file_test tests -fmerge-constants, so we simply always turn
16 # it on.  For compilers that do not support the command-line option,
17 # we assume they just always emit SHF_MERGE sections unconditionally.
18 AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) $(MERGE_CONSTANTS_FLAG)
19 AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) $(MERGE_CONSTANTS_FLAG)
20
21 AM_CPPFLAGS = \
22         -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../include \
23         -I$(srcdir)/../../elfcpp -I.. \
24         -DLOCALEDIR="\"$(datadir)/locale\"" \
25         @INCINTL@
26
27 # Some versions of GCC now automatically enable linker plugins,
28 # but we want to run our tests without GCC's plugins.
29 if HAVE_NO_USE_LINKER_PLUGIN
30 OPT_NO_PLUGINS = -fno-use-linker-plugin
31 endif
32
33 # COMPILE1, LINK1, CXXCOMPILE1, CXXLINK1 are renamed from COMPILE, LINK,
34 # CXXCOMPILE and CXXLINK generated by automake 1.11.1.  FIXME: they should
35 # be updated if they are different from automake used by gold.
36 COMPILE1 = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
37         $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
38 LINK1 = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) \
39         $(AM_LDFLAGS) $(LDFLAGS) -o $@
40 CXXCOMPILE1 = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
41         $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
42 CXXLINK1 = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(OPT_NO_PLUGINS) \
43         $(AM_LDFLAGS) $(LDFLAGS) -o $@
44
45 # Strip out -Wp,-D_FORTIFY_SOURCE=, which is irrelevant for the gold
46 # testsuite and incompatible with -O0 used in gold tests, from
47 # COMPILE, LINK, CXXCOMPILE and CXXLINK.
48 COMPILE = `echo $(COMPILE1) | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[0-9[0-9]]*//'`
49 LINK = `echo $(LINK1) | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[0-9][0-9]*//'`
50 CXXCOMPILE = `echo $(CXXCOMPILE1) | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[0-9][0-9]*//'`
51 CXXLINK = `echo $(CXXLINK1) | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[0-9][0-9]*//'`
52
53 # Strip out -static-libgcc and -static-libstdc++ options, for tests
54 # that must have these libraries linked dynamically.  The -shared-libgcc
55 # option does not work correctly, and there is no -shared-libstdc++ option.
56 # (See GCC PR 55781 and PR 55782.)
57 CXXLINK_S = `echo $(CXXLINK1) | sed -e 's/-static-lib\\(gcc\\|stdc++\\)//g'`
58
59 TEST_READELF = $(top_builddir)/../binutils/readelf
60 TEST_OBJDUMP = $(top_builddir)/../binutils/objdump
61 TEST_OBJCOPY = $(top_builddir)/../binutils/objcopy
62 TEST_CXXFILT = $(top_builddir)/../binutils/cxxfilt
63 TEST_STRIP = $(top_builddir)/../binutils/strip-new
64 TEST_AR = $(top_builddir)/../binutils/ar
65 TEST_NM = $(top_builddir)/../binutils/nm-new
66 TEST_AS = $(top_builddir)/../gas/as-new
67
68 if PLUGINS
69 LIBDL = -ldl
70 endif
71
72 if THREADS
73 THREADSLIB = -lpthread
74 endif
75
76 if OMP_SUPPORT
77 TLS_TEST_C_CFLAGS = -fopenmp
78 endif
79
80 # 'make clean' is good about deleting some intermediate files (such as
81 # .o's), but not all of them (such as .so's and .err files).  We
82 # improve on that here.  automake-1.9 info docs say "mostlyclean" is
83 # the right choice for files 'make' builds that people rebuild.
84 MOSTLYCLEANFILES = *.so *.syms *.stdout
85
86 # Export make variables to the shell scripts so that they can see
87 # (for example) DEFAULT_TARGET.
88 .EXPORT_ALL_VARIABLES:
89
90 # We will add to these later, for each individual test.  Note
91 # that we add each test under check_SCRIPTS or check_PROGRAMS;
92 # the TESTS variable is automatically populated from these.
93 check_SCRIPTS =
94 check_DATA =
95 check_PROGRAMS =
96 BUILT_SOURCES =
97
98 TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
99
100 # ---------------------------------------------------------------------
101 # These tests test the internals of gold (unittests).
102
103 # Infrastucture needed for the unittests
104 check_LIBRARIES = libgoldtest.a
105 libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc
106
107 DEPENDENCIES = \
108         libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL_DEP)
109 LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \
110         $(THREADSLIB) $(LIBDL) $(ZLIB)
111
112
113 # The unittests themselves
114 if NATIVE_OR_CROSS_LINKER
115 if GCC
116
117 # Infrastucture needed for the unittests: a directory where the linker
118 # is named 'ld'.  This is because the -B flag appends 'ld' to its arg.
119 gcctestdir/ld: ../ld-new
120         test -d gcctestdir || mkdir -p gcctestdir
121         rm -f gcctestdir/ld
122         (cd gcctestdir && $(LN_S) ../../ld-new ld)
123
124 # Some tests require the latest features of an in-tree assembler.
125 gcctestdir/as: $(TEST_AS)
126         test -d gcctestdir || mkdir -p gcctestdir
127         rm -f gcctestdir/as
128         (cd gcctestdir && $(LN_S) $(abs_top_builddir)/../gas/as-new as)
129
130 endif GCC
131
132 check_PROGRAMS += object_unittest
133 object_unittest_SOURCES = object_unittest.cc
134
135 check_PROGRAMS += binary_unittest
136 binary_unittest_SOURCES = binary_unittest.cc
137
138 check_PROGRAMS += leb128_unittest
139 leb128_unittest_SOURCES = leb128_unittest.cc
140
141 check_PROGRAMS += overflow_unittest
142 overflow_unittest_SOURCES = overflow_unittest.cc
143 overflow_unittest.o: overflow_unittest.cc
144         $(CXXCOMPILE) -O3 -c -o $@ $<
145
146 endif NATIVE_OR_CROSS_LINKER
147
148 # ---------------------------------------------------------------------
149 # These tests test the output of gold (end-to-end tests).  In
150 # particular, they make sure that gold can link "difficult" object
151 # files, and the resulting object files run correctly.  These can only
152 # run if we've built ld-new for the native architecture (that is,
153 # we're not cross-compiling it), since we run ld-new as part of these
154 # tests.  We use the gcc-specific flag '-B' to use our linker instead
155 # of the default linker, which is why we only run our tests under gcc.
156
157 if NATIVE_LINKER
158 if GCC
159
160 # Each of these .o's is a useful, small complete program.  They're
161 # particularly useful for making sure ld-new's flags do what they're
162 # supposed to (hence their names), but are used for many tests that
163 # don't actually involve analyzing input data.
164 flagstest_debug.o: constructor_test.cc
165         $(CXXCOMPILE) -O0 -g -c -o $@ $<
166 flagstest_ndebug.o: constructor_test.cc
167         $(CXXCOMPILE) -O0 -c -o $@ $<
168
169 check_SCRIPTS += incremental_test.sh
170 check_DATA += incremental_test.stdout
171 MOSTLYCLEANFILES += incremental_test incremental_test.cmdline
172 incremental_test_1.o: incremental_test_1.c
173         $(COMPILE) -O0 -c -ffunction-sections -g -o $@ $<
174 incremental_test_2.o: incremental_test_2.c
175         $(COMPILE) -O0 -c -ffunction-sections -g -o $@ $<
176 incremental_test: incremental_test_1.o incremental_test_2.o gcctestdir/ld
177         $(LINK) -Bgcctestdir/ -Wl,--incremental-full -Wl,-z,norelro incremental_test_1.o incremental_test_2.o -Wl,-debug 2> incremental_test.cmdline
178 incremental_test.stdout: incremental_test ../incremental-dump
179         ../incremental-dump incremental_test > $@
180
181 check_SCRIPTS += gc_comdat_test.sh
182 check_DATA += gc_comdat_test.stdout
183 MOSTLYCLEANFILES += gc_comdat_test
184 gc_comdat_test_1.o: gc_comdat_test_1.cc
185         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
186 gc_comdat_test_2.o: gc_comdat_test_2.cc
187         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
188 gc_comdat_test: gc_comdat_test_1.o gc_comdat_test_2.o gcctestdir/ld
189         $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_comdat_test_1.o gc_comdat_test_2.o
190 gc_comdat_test.stdout: gc_comdat_test
191         $(TEST_NM) -C gc_comdat_test > gc_comdat_test.stdout
192
193 check_SCRIPTS += gc_tls_test.sh
194 check_DATA += gc_tls_test.stdout
195 MOSTLYCLEANFILES += gc_tls_test
196 gc_tls_test.o: gc_tls_test.cc
197         $(CXXCOMPILE) -O0 -c -g -o $@ $<
198 gc_tls_test:gc_tls_test.o gcctestdir/ld
199         $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_tls_test.o
200 gc_tls_test.stdout: gc_tls_test
201         $(TEST_NM) -C gc_tls_test > gc_tls_test.stdout
202
203 check_SCRIPTS += gc_orphan_section_test.sh
204 check_DATA += gc_orphan_section_test.stdout
205 MOSTLYCLEANFILES += gc_orphan_section_test
206 gc_orphan_section_test.o: gc_orphan_section_test.cc
207         $(CXXCOMPILE) -O0 -c -g -o $@ $<
208 gc_orphan_section_test:gc_orphan_section_test.o gcctestdir/ld
209         $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_orphan_section_test.o
210 gc_orphan_section_test.stdout: gc_orphan_section_test
211         $(TEST_NM) gc_orphan_section_test > gc_orphan_section_test.stdout
212
213 check_SCRIPTS += pr14265.sh
214 check_DATA += pr14265.stdout
215 MOSTLYCLEANFILES += pr14265
216 pr14265.o: pr14265.c
217         $(COMPILE) -O0 -c -o $@ $<
218 pr14265: pr14265.o
219         $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,-T,$(srcdir)/pr14265.t -o $@ $<
220 pr14265.stdout: pr14265
221         $(TEST_NM) --format=bsd --numeric-sort $< > $@
222
223 check_SCRIPTS += gc_dynamic_list_test.sh
224 check_DATA += gc_dynamic_list_test.stdout
225 MOSTLYCLEANFILES += gc_dynamic_list_test
226 gc_dynamic_list_test.o: gc_dynamic_list_test.c
227         $(COMPILE) -c -ffunction-sections -o $@ $<
228 gc_dynamic_list_test: gc_dynamic_list_test.o gcctestdir/ld $(srcdir)/gc_dynamic_list_test.t
229         $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,--dynamic-list,$(srcdir)/gc_dynamic_list_test.t gc_dynamic_list_test.o
230 gc_dynamic_list_test.stdout: gc_dynamic_list_test
231         $(TEST_NM) gc_dynamic_list_test > $@
232
233 check_SCRIPTS += icf_test.sh
234 check_DATA += icf_test.map
235 MOSTLYCLEANFILES += icf_test icf_test.map
236 icf_test.o: icf_test.cc
237         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
238 icf_test: icf_test.o gcctestdir/ld
239         $(CXXLINK) -o icf_test -Bgcctestdir/ -Wl,--icf=all,-Map,icf_test.map icf_test.o
240 icf_test.map: icf_test
241         @touch icf_test.map
242
243 check_SCRIPTS += icf_keep_unique_test.sh
244 check_DATA += icf_keep_unique_test.stdout
245 MOSTLYCLEANFILES += icf_keep_unique_test
246 icf_keep_unique_test.o: icf_keep_unique_test.cc
247         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
248 icf_keep_unique_test: icf_keep_unique_test.o gcctestdir/ld
249         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all -Wl,--keep-unique,_Z11unique_funcv icf_keep_unique_test.o
250 icf_keep_unique_test.stdout: icf_keep_unique_test
251         $(TEST_NM) -C $< > $@
252
253 check_SCRIPTS += icf_safe_test.sh
254 check_DATA += icf_safe_test_1.stdout icf_safe_test_2.stdout icf_safe_test.map
255 MOSTLYCLEANFILES += icf_safe_test icf_safe_test.map
256 icf_safe_test.o: icf_safe_test.cc
257         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
258 icf_safe_test: icf_safe_test.o gcctestdir/ld
259         $(CXXLINK) -o icf_safe_test -Bgcctestdir/ -Wl,--icf=safe,-Map,icf_safe_test.map icf_safe_test.o
260 icf_safe_test.map: icf_safe_test
261         @touch icf_safe_test.map
262 icf_safe_test_1.stdout: icf_safe_test
263         $(TEST_NM) $< > $@
264 icf_safe_test_2.stdout: icf_safe_test
265         $(TEST_READELF) -h $< > $@
266
267 check_SCRIPTS += icf_safe_so_test.sh
268 check_DATA += icf_safe_so_test_1.stdout icf_safe_so_test_2.stdout icf_safe_so_test.map
269 MOSTLYCLEANFILES += icf_safe_so_test icf_safe_so_test.map
270 icf_safe_so_test.o: icf_safe_so_test.cc
271         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
272 icf_safe_so_test: icf_safe_so_test.o gcctestdir/ld
273         $(CXXLINK) -o icf_safe_so_test -Bgcctestdir/ -Wl,--icf=safe,-Map,icf_safe_so_test.map icf_safe_so_test.o -fPIC -shared
274 icf_safe_so_test.map:
275         @touch icf_safe_so_test.map
276 icf_safe_so_test_1.stdout: icf_safe_so_test
277         $(TEST_NM) $< > $@
278 icf_safe_so_test_2.stdout: icf_safe_so_test
279         $(TEST_READELF) -h $< > $@
280
281 check_SCRIPTS += final_layout.sh
282 check_DATA += final_layout.stdout
283 MOSTLYCLEANFILES += final_layout final_layout_sequence.txt final_layout_script.lds
284 final_layout.o: final_layout.cc
285         $(CXXCOMPILE) -O0 -c -ffunction-sections  -fdata-sections -g -o $@ $<
286 final_layout_sequence.txt:
287         (echo "*_Z3barv*" && echo ".text._Z3bazv" && echo "*_Z3foov*" && echo "*global_varb*" && echo "*global_vara*" && echo "*global_varc*") > final_layout_sequence.txt
288 final_layout_script.lds:
289         (echo "SECTIONS { .text : { *(.text*) } .got : { *(.got .toc) } .sbss : { *(.sbss*) } .bss : { *(.bss*) } }") > final_layout_script.lds
290 final_layout: final_layout.o final_layout_sequence.txt final_layout_script.lds gcctestdir/ld
291         $(CXXLINK) -Bgcctestdir/ -Wl,--section-ordering-file,final_layout_sequence.txt -Wl,-T,final_layout_script.lds final_layout.o
292 final_layout.stdout: final_layout
293         $(TEST_NM) -n --synthetic final_layout > final_layout.stdout
294
295 check_SCRIPTS += text_section_grouping.sh
296 check_DATA += text_section_grouping.stdout text_section_no_grouping.stdout
297 MOSTLYCLEANFILES += text_section_grouping text_section_no_grouping
298 text_section_grouping.o: text_section_grouping.cc
299         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
300 text_section_grouping: text_section_grouping.o gcctestdir/ld
301         $(CXXLINK)  -Bgcctestdir/ text_section_grouping.o
302 text_section_no_grouping: text_section_grouping.o gcctestdir/ld
303         $(CXXLINK)  -Bgcctestdir/ -Wl,--no-text-reorder text_section_grouping.o
304 text_section_grouping.stdout: text_section_grouping
305         $(TEST_NM) -n --synthetic text_section_grouping > text_section_grouping.stdout
306 text_section_no_grouping.stdout: text_section_no_grouping
307         $(TEST_NM) -n --synthetic text_section_no_grouping > text_section_no_grouping.stdout
308
309 check_SCRIPTS += section_sorting_name.sh
310 check_DATA += section_sorting_name.stdout
311 MOSTLYCLEANFILES += section_sorting_name
312 section_sorting_name.o: section_sorting_name.cc
313         $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
314 section_sorting_name: section_sorting_name.o gcctestdir/ld
315         $(CXXLINK)  -Bgcctestdir/ -Wl,--sort-section=name section_sorting_name.o
316 section_sorting_name.stdout: section_sorting_name
317         $(TEST_NM) -n --synthetic section_sorting_name > section_sorting_name.stdout
318
319 check_PROGRAMS += icf_virtual_function_folding_test
320 MOSTLYCLEANFILES += icf_virtual_function_folding_test icf_virtual_function_folding_test.map
321 icf_virtual_function_folding_test.o: icf_virtual_function_folding_test.cc
322         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIE -g -o $@ $<
323 icf_virtual_function_folding_test: icf_virtual_function_folding_test.o gcctestdir/ld
324         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_virtual_function_folding_test.o -pie
325
326 check_SCRIPTS += icf_preemptible_functions_test.sh
327 check_DATA += icf_preemptible_functions_test.stdout
328 MOSTLYCLEANFILES += icf_preemptible_functions_test
329 icf_preemptible_functions_test.o: icf_preemptible_functions_test.cc
330         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
331 icf_preemptible_functions_test: icf_preemptible_functions_test.o gcctestdir/ld
332         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_preemptible_functions_test.o -fPIC -shared
333 icf_preemptible_functions_test.stdout: icf_preemptible_functions_test
334         $(TEST_NM) icf_preemptible_functions_test > icf_preemptible_functions_test.stdout
335
336 check_SCRIPTS += icf_string_merge_test.sh
337 check_DATA += icf_string_merge_test.stdout
338 MOSTLYCLEANFILES += icf_string_merge_test
339 icf_string_merge_test.o: icf_string_merge_test.cc
340         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
341 icf_string_merge_test: icf_string_merge_test.o gcctestdir/ld
342         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_string_merge_test.o
343 icf_string_merge_test.stdout: icf_string_merge_test
344         $(TEST_NM) icf_string_merge_test > icf_string_merge_test.stdout
345
346 check_SCRIPTS += icf_sht_rel_addend_test.sh
347 check_DATA += icf_sht_rel_addend_test.stdout
348 MOSTLYCLEANFILES += icf_sht_rel_addend_test
349 icf_sht_rel_addend_test_1.o: icf_sht_rel_addend_test_1.cc
350         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
351 icf_sht_rel_addend_test_2.o: icf_sht_rel_addend_test_2.cc
352         $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $<
353 icf_sht_rel_addend_test: icf_sht_rel_addend_test_1.o icf_sht_rel_addend_test_2.o gcctestdir/ld
354         $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_sht_rel_addend_test_1.o icf_sht_rel_addend_test_2.o
355 icf_sht_rel_addend_test.stdout: icf_sht_rel_addend_test
356         $(TEST_NM) icf_sht_rel_addend_test > icf_sht_rel_addend_test.stdout
357
358 check_PROGRAMS += large_symbol_alignment
359 large_symbol_alignment_SOURCES = large_symbol_alignment.cc
360 large_symbol_alignment_DEPENDENCIES = gcctestdir/ld
361 large_symbol_alignment_LDFLAGS = -Bgcctestdir/
362 large_symbol_alignment_LDADD =
363
364 check_SCRIPTS += merge_string_literals.sh
365 check_DATA += merge_string_literals.stdout
366 MOSTLYCLEANFILES += merge_string_literals
367 merge_string_literals_1.o: merge_string_literals_1.cc
368         $(CXXCOMPILE) -O2 -c -fPIC -g -o $@ $<
369 merge_string_literals_2.o: merge_string_literals_2.cc
370         $(CXXCOMPILE) -O2 -c -fPIC -g -o $@ $<
371 merge_string_literals: merge_string_literals_1.o merge_string_literals_2.o gcctestdir/ld
372         $(CXXLINK) -Bgcctestdir/ merge_string_literals_1.o merge_string_literals_2.o -O2 -shared -nostdlib
373 merge_string_literals.stdout: merge_string_literals
374         $(TEST_OBJDUMP) -s -j.rodata merge_string_literals > merge_string_literals.stdout
375
376 check_PROGRAMS += basic_test
377 check_PROGRAMS += basic_pic_test
378 basic_test.o: basic_test.cc
379         $(CXXCOMPILE) -O0 -c -o $@ $<
380 basic_test: basic_test.o gcctestdir/ld
381         $(CXXLINK) -Bgcctestdir/ basic_test.o
382
383 check_PROGRAMS += eh_test
384 eh_test_a.o: eh_test_a.cc
385         $(CXXCOMPILE) -O0 -c -o $@ $<
386 eh_test_b.o: eh_test_b.cc
387         $(CXXCOMPILE) -O0 -c -o $@ $<
388 eh_test: eh_test_a.o eh_test_b.o  gcctestdir/ld
389         $(CXXLINK_S) -Bgcctestdir/ eh_test_a.o eh_test_b.o
390
391 if HAVE_STATIC
392 check_PROGRAMS += basic_static_test
393 basic_static_test: basic_test.o gcctestdir/ld
394         $(CXXLINK) -Bgcctestdir/ -static basic_test.o
395 endif
396
397 basic_pic_test.o: basic_test.cc
398         $(CXXCOMPILE) -O0 -c -fpic -o $@ $<
399 basic_pic_test: basic_pic_test.o gcctestdir/ld
400         $(CXXLINK) -Bgcctestdir/ basic_pic_test.o
401
402 if HAVE_STATIC
403 check_PROGRAMS += basic_static_pic_test
404 basic_static_pic_test: basic_pic_test.o gcctestdir/ld
405         $(CXXLINK) -Bgcctestdir/ -static basic_pic_test.o
406 endif
407
408 check_PROGRAMS += basic_pie_test
409 basic_pie_test.o: basic_test.cc
410         $(CXXCOMPILE) -O0 -c -fpie -o $@ $<
411 basic_pie_test: basic_pie_test.o gcctestdir/ld
412         $(CXXLINK) -Bgcctestdir/ -pie basic_pie_test.o
413
414 check_PROGRAMS += constructor_test
415 constructor_test_SOURCES = constructor_test.cc
416 constructor_test_DEPENDENCIES = gcctestdir/ld
417 constructor_test_LDFLAGS = -Bgcctestdir/
418 constructor_test_LDADD =
419
420 if HAVE_STATIC
421 check_PROGRAMS += constructor_static_test
422 constructor_static_test_SOURCES = $(constructor_test_SOURCES)
423 constructor_static_test_DEPENDENCIES = $(constructor_test_DEPENDENCIES)
424 constructor_static_test_LDFLAGS = $(constructor_test_LDFLAGS) -static
425 constructor_static_test_LDADD = $(constructor_test_LDADD)
426 endif
427
428 check_PROGRAMS += two_file_test
429 check_PROGRAMS += two_file_pic_test
430 two_file_test_SOURCES = \
431         two_file_test_1.cc \
432         two_file_test_1b.cc \
433         two_file_test_2.cc \
434         two_file_test_main.cc \
435         two_file_test.h
436 two_file_test_DEPENDENCIES = gcctestdir/ld
437 two_file_test_LDFLAGS = -Bgcctestdir/
438 two_file_test_LDADD =
439
440 if HAVE_STATIC
441 check_PROGRAMS += two_file_static_test
442 two_file_static_test_SOURCES = $(two_file_test_SOURCES)
443 two_file_static_test_DEPENDENCIES = $(two_file_test_DEPENDENCIES)
444 two_file_static_test_LDFLAGS = $(two_file_test_LDFLAGS) -static
445 two_file_static_test_LDADD = $(two_file_test_LDADD)
446 endif
447
448 two_file_pic_test_SOURCES = two_file_test_main.cc
449 two_file_pic_test_DEPENDENCIES = \
450         gcctestdir/ld two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o
451 two_file_pic_test_LDFLAGS = -Bgcctestdir/
452 two_file_pic_test_LDADD = two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o
453
454
455 check_PROGRAMS += two_file_shared_1_test
456 check_PROGRAMS += two_file_shared_2_test
457 check_PROGRAMS += two_file_shared_1_pic_2_test
458 check_PROGRAMS += two_file_shared_2_pic_1_test
459 check_PROGRAMS += two_file_same_shared_test
460 check_PROGRAMS += two_file_separate_shared_12_test
461 check_PROGRAMS += two_file_separate_shared_21_test
462 two_file_test_1_pic.o: two_file_test_1.cc
463         $(CXXCOMPILE) -c -fpic -o $@ $<
464 two_file_test_1b_pic.o: two_file_test_1b.cc
465         $(CXXCOMPILE) -c -fpic -o $@ $<
466 two_file_test_2_pic.o: two_file_test_2.cc
467         $(CXXCOMPILE) -c -fpic -o $@ $<
468 two_file_shared_1.so: two_file_test_1_pic.o two_file_test_1b_pic.o gcctestdir/ld
469         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o
470 two_file_shared_2.so: two_file_test_2_pic.o gcctestdir/ld
471         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_2_pic.o
472 two_file_shared.so: two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o gcctestdir/ld
473         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o
474
475 two_file_shared_1_test_SOURCES = two_file_test_2.cc two_file_test_main.cc
476 two_file_shared_1_test_DEPENDENCIES = gcctestdir/ld two_file_shared_1.so
477 two_file_shared_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
478 two_file_shared_1_test_LDADD = two_file_shared_1.so
479
480 two_file_shared_2_test_SOURCES = two_file_test_1.cc two_file_test_1b.cc two_file_test_main.cc
481 two_file_shared_2_test_DEPENDENCIES = gcctestdir/ld two_file_shared_2.so
482 two_file_shared_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
483 two_file_shared_2_test_LDADD = two_file_shared_2.so
484
485 two_file_shared_1_pic_2_test_SOURCES = two_file_test_main.cc
486 two_file_shared_1_pic_2_test_DEPENDENCIES = \
487         gcctestdir/ld two_file_shared_2.so two_file_test_1_pic.o two_file_test_1b_pic.o
488 two_file_shared_1_pic_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
489 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
490
491 two_file_shared_2_pic_1_test_SOURCES = two_file_test_main.cc
492 two_file_shared_2_pic_1_test_DEPENDENCIES = \
493         gcctestdir/ld two_file_shared_1.so two_file_test_2_pic.o
494 two_file_shared_2_pic_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
495 two_file_shared_2_pic_1_test_LDADD = two_file_test_2_pic.o two_file_shared_1.so
496
497 two_file_same_shared_test_SOURCES = two_file_test_main.cc
498 two_file_same_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared.so
499 two_file_same_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
500 two_file_same_shared_test_LDADD = two_file_shared.so
501
502 two_file_separate_shared_12_test_SOURCES = two_file_test_main.cc
503 two_file_separate_shared_12_test_DEPENDENCIES = \
504         gcctestdir/ld two_file_shared_1.so two_file_shared_2.so
505 two_file_separate_shared_12_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
506 two_file_separate_shared_12_test_LDADD = \
507         two_file_shared_1.so two_file_shared_2.so
508
509 two_file_separate_shared_21_test_SOURCES = two_file_test_main.cc
510 two_file_separate_shared_21_test_DEPENDENCIES = \
511         gcctestdir/ld two_file_shared_1.so two_file_shared_2.so
512 two_file_separate_shared_21_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
513 two_file_separate_shared_21_test_LDADD = \
514         two_file_shared_2.so two_file_shared_1.so
515
516 check_PROGRAMS += two_file_relocatable_test
517 two_file_relocatable_test_SOURCES = two_file_test_main.cc
518 two_file_relocatable_test_DEPENDENCIES = \
519         gcctestdir/ld two_file_relocatable.o
520 two_file_relocatable_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
521 two_file_relocatable_test_LDADD = two_file_relocatable.o
522 two_file_relocatable.o: gcctestdir/ld two_file_test_1.o two_file_test_1b.o two_file_test_2.o
523         gcctestdir/ld -r -o $@ two_file_test_1.o two_file_test_1b.o two_file_test_2.o
524
525 check_PROGRAMS += two_file_pie_test
526 two_file_test_1_pie.o: two_file_test_1.cc
527         $(CXXCOMPILE) -c -fpie -o $@ $<
528 two_file_test_1b_pie.o: two_file_test_1b.cc
529         $(CXXCOMPILE) -c -fpie -o $@ $<
530 two_file_test_2_pie.o: two_file_test_2.cc
531         $(CXXCOMPILE) -c -fpie -o $@ $<
532 two_file_test_main_pie.o: two_file_test_main.cc
533         $(CXXCOMPILE) -c -fpie -o $@ $<
534 two_file_pie_test: two_file_test_1_pie.o two_file_test_1b_pie.o \
535                 two_file_test_2_pie.o two_file_test_main_pie.o gcctestdir/ld
536         $(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
537
538 check_PROGRAMS += pie_copyrelocs_test
539 pie_copyrelocs_test_SOURCES = pie_copyrelocs_test.cc
540 pie_copyrelocs_test_DEPENDENCIES = gcctestdir/ld pie_copyrelocs_shared_test.so
541 pie_copyrelocs_test_CXXFLAGS = -fno-exceptions -fno-asynchronous-unwind-tables
542 pie_copyrelocs_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -pie
543 pie_copyrelocs_test_LDADD = pie_copyrelocs_shared_test.so
544 pie_copyrelocs_shared_test.o: pie_copyrelocs_shared_test.cc
545         $(CXXCOMPILE) -O2 -fpic -c -o $@ $<
546 pie_copyrelocs_shared_test.so: pie_copyrelocs_shared_test.o gcctestdir/ld
547         $(CXXLINK) -Bgcctestdir/ -shared pie_copyrelocs_shared_test.o
548
549 check_PROGRAMS += weak_unresolved_symbols_test
550 weak_unresolved_symbols_test_SOURCES = weak_unresolved_symbols_test.cc
551 weak_unresolved_symbols_test_CXXFLAGS = -fPIE
552 weak_unresolved_symbols_test_LDFLAGS = -Bgcctestdir/ -pie -Wl,--weak-unresolved-symbols
553
554 check_SCRIPTS += two_file_shared.sh
555 check_DATA += two_file_shared.dbg
556 MOSTLYCLEANFILES += two_file_shared.dbg
557 two_file_shared.dbg: two_file_shared.so
558         $(TEST_READELF) -w $< >$@ 2>/dev/null
559
560 # The nonpic tests will fail on platforms which can not put non-PIC
561 # code into shared libraries, so we just don't run them in that case.
562 if FN_PTRS_IN_SO_WITHOUT_PIC
563
564 check_PROGRAMS += two_file_shared_1_nonpic_test
565 check_PROGRAMS += two_file_shared_2_nonpic_test
566 check_PROGRAMS += two_file_same_shared_nonpic_test
567 check_PROGRAMS += two_file_separate_shared_12_nonpic_test
568 check_PROGRAMS += two_file_separate_shared_21_nonpic_test
569 check_PROGRAMS += two_file_mixed_shared_test
570 check_PROGRAMS += two_file_mixed_2_shared_test
571 two_file_shared_1_nonpic.so: two_file_test_1.o gcctestdir/ld
572         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b.o -Wl,-z,notext
573 two_file_shared_2_nonpic.so: two_file_test_2.o gcctestdir/ld
574         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_2.o
575 two_file_shared_nonpic.so: two_file_test_1.o two_file_test_1b.o two_file_test_2.o gcctestdir/ld
576         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b.o two_file_test_2.o -Wl,-z,notext
577 two_file_shared_mixed.so: two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2.o gcctestdir/ld
578         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2.o -Wl,-z,notext
579 two_file_shared_mixed_1.so: two_file_test_1.o two_file_test_1b_pic.o two_file_shared_2.so gcctestdir/ld
580         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b_pic.o two_file_shared_2.so -Wl,-z,notext
581
582 two_file_shared_1_nonpic_test_SOURCES = \
583         two_file_test_2.cc two_file_test_main.cc
584 two_file_shared_1_nonpic_test_DEPENDENCIES = \
585         gcctestdir/ld two_file_shared_1_nonpic.so
586 two_file_shared_1_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
587 two_file_shared_1_nonpic_test_LDADD = two_file_shared_1_nonpic.so
588
589 two_file_shared_2_nonpic_test_SOURCES = \
590         two_file_test_1.cc two_file_test_1b.cc two_file_test_main.cc
591 two_file_shared_2_nonpic_test_DEPENDENCIES = \
592         gcctestdir/ld two_file_shared_2_nonpic.so
593 two_file_shared_2_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
594 two_file_shared_2_nonpic_test_LDADD = two_file_shared_2_nonpic.so
595
596 two_file_same_shared_nonpic_test_SOURCES = two_file_test_main.cc
597 two_file_same_shared_nonpic_test_DEPENDENCIES = \
598         gcctestdir/ld two_file_shared_nonpic.so
599 two_file_same_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
600 two_file_same_shared_nonpic_test_LDADD = two_file_shared_nonpic.so
601
602 two_file_separate_shared_12_nonpic_test_SOURCES = two_file_test_main.cc
603 two_file_separate_shared_12_nonpic_test_DEPENDENCIES = \
604         gcctestdir/ld two_file_shared_1_nonpic.so two_file_shared_2_nonpic.so
605 two_file_separate_shared_12_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
606 two_file_separate_shared_12_nonpic_test_LDADD = \
607         two_file_shared_1_nonpic.so two_file_shared_2_nonpic.so
608
609 two_file_separate_shared_21_nonpic_test_SOURCES = two_file_test_main.cc
610 two_file_separate_shared_21_nonpic_test_DEPENDENCIES = \
611         gcctestdir/ld two_file_shared_1_nonpic.so two_file_shared_2_nonpic.so
612 two_file_separate_shared_21_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
613 two_file_separate_shared_21_nonpic_test_LDADD = \
614         two_file_shared_2_nonpic.so two_file_shared_1_nonpic.so
615
616 two_file_mixed_shared_test_SOURCES = two_file_test_main.cc
617 two_file_mixed_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared_mixed.so
618 two_file_mixed_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
619 two_file_mixed_shared_test_LDADD = two_file_shared_mixed.so
620
621 two_file_mixed_2_shared_test_SOURCES = two_file_test_main.cc
622 two_file_mixed_2_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared_mixed_1.so two_file_shared_2.so
623 two_file_mixed_2_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
624 two_file_mixed_2_shared_test_LDADD = two_file_shared_mixed_1.so two_file_shared_2.so
625
626 check_PROGRAMS += two_file_mixed_pie_test
627 two_file_mixed_pie_test: two_file_test_1.o two_file_test_1b_pie.o \
628                 two_file_test_main_pie.o two_file_shared_2.so gcctestdir/ld
629         $(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
630
631 endif FN_PTRS_IN_SO_WITHOUT_PIC
632
633 check_PROGRAMS += two_file_strip_test
634 two_file_strip_test: two_file_test
635         $(TEST_STRIP) -o two_file_strip_test two_file_test
636
637 check_PROGRAMS += two_file_same_shared_strip_test
638 two_file_same_shared_strip_test_SOURCES = two_file_test_main.cc
639 two_file_same_shared_strip_test_DEPENDENCIES = \
640         gcctestdir/ld two_file_shared_strip.so
641 two_file_same_shared_strip_test_LDFLAGS = -Bgcctestdir/ -Wl,-R.
642 two_file_same_shared_strip_test_LDADD = two_file_shared_strip.so
643 two_file_shared_strip.so: two_file_shared.so
644         $(TEST_STRIP) -S -o two_file_shared_strip.so two_file_shared.so
645
646 check_PROGRAMS += common_test_1
647 common_test_1_SOURCES = common_test_1.c
648 common_test_1_DEPENDENCIES = gcctestdir/ld
649 common_test_1_LDFLAGS = -Bgcctestdir/
650 common_test_1_LDADD =
651
652 check_PROGRAMS += common_test_2
653 common_test_2_SOURCES = common_test_1.c
654 common_test_2_DEPENDENCIES = common_test_2.so common_test_3.so gcctestdir/ld
655 common_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
656 common_test_2_LDADD = common_test_2.so common_test_3.so
657 common_test_2_pic.o: common_test_2.c
658         $(COMPILE) -c -fpic -o $@ $<
659 common_test_2.so: common_test_2_pic.o common_test_3.so gcctestdir/ld
660         $(LINK) -Bgcctestdir/ -shared common_test_2_pic.o common_test_3.so
661 common_test_3_pic.o: common_test_3.c
662         $(COMPILE) -c -fpic -o $@ $<
663 common_test_3.so: common_test_3_pic.o ver_test_2.script gcctestdir/ld
664         $(LINK) -Bgcctestdir/ -shared common_test_3_pic.o -Wl,--version-script,$(srcdir)/ver_test_2.script
665
666 check_PROGRAMS += exception_test
667 check_PROGRAMS += exception_shared_1_test
668 check_PROGRAMS += exception_shared_2_test
669 check_PROGRAMS += exception_same_shared_test
670 check_PROGRAMS += exception_separate_shared_12_test
671 check_PROGRAMS += exception_separate_shared_21_test
672 exception_test_1_pic.o: exception_test_1.cc
673         $(CXXCOMPILE) -c -fpic -o $@ $<
674 exception_test_2_pic.o: exception_test_2.cc
675         $(CXXCOMPILE) -c -fpic -o $@ $<
676 exception_shared_1.so: exception_test_1_pic.o gcctestdir/ld
677         $(CXXLINK) -Bgcctestdir/ -shared exception_test_1_pic.o
678 exception_shared_2.so: exception_test_2_pic.o gcctestdir/ld
679         $(CXXLINK) -Bgcctestdir/ -shared exception_test_2_pic.o
680 exception_shared.so: exception_test_1_pic.o exception_test_2_pic.o gcctestdir/ld
681         $(CXXLINK) -Bgcctestdir/ -shared exception_test_1_pic.o exception_test_2_pic.o
682
683 exception_test_SOURCES = \
684         exception_test_main.cc \
685         exception_test_1.cc \
686         exception_test_2.cc \
687         exception_test.h
688 exception_test_DEPENDENCIES = gcctestdir/ld
689 exception_test_LDFLAGS = -Bgcctestdir/
690 exception_test_LDADD =
691
692 if HAVE_STATIC
693 check_PROGRAMS += exception_static_test
694 exception_static_test_SOURCES = $(exception_test_SOURCES)
695 exception_static_test_DEPENDENCIES = $(exception_test_DEPENDENCIES)
696 exception_static_test_LDFLAGS = $(exception_test_LDFLAGS) -static
697 exception_static_test_LDADD = $(exception_test_LDADD)
698 endif
699
700 exception_shared_1_test_SOURCES = exception_test_2.cc exception_test_main.cc
701 exception_shared_1_test_DEPENDENCIES = gcctestdir/ld exception_shared_1.so
702 exception_shared_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
703 exception_shared_1_test_LDADD = exception_shared_1.so
704
705 exception_shared_2_test_SOURCES = exception_test_1.cc exception_test_main.cc
706 exception_shared_2_test_DEPENDENCIES = gcctestdir/ld exception_shared_2.so
707 exception_shared_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
708 exception_shared_2_test_LDADD = exception_shared_2.so
709
710 exception_same_shared_test_SOURCES = exception_test_main.cc
711 exception_same_shared_test_DEPENDENCIES = gcctestdir/ld exception_shared.so
712 exception_same_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
713 exception_same_shared_test_LDADD = exception_shared.so
714
715 exception_separate_shared_12_test_SOURCES = exception_test_main.cc
716 exception_separate_shared_12_test_DEPENDENCIES = \
717         gcctestdir/ld exception_shared_1.so exception_shared_2.so
718 exception_separate_shared_12_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. \
719         -Wl,--no-as-needed
720 exception_separate_shared_12_test_LDADD = \
721         exception_shared_1.so exception_shared_2.so
722
723 exception_separate_shared_21_test_SOURCES = exception_test_main.cc
724 exception_separate_shared_21_test_DEPENDENCIES = \
725         gcctestdir/ld exception_shared_1.so exception_shared_2.so
726 exception_separate_shared_21_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. \
727         -Wl,--no-as-needed
728 exception_separate_shared_21_test_LDADD = \
729         exception_shared_2.so exception_shared_1.so
730
731
732 check_PROGRAMS += weak_test
733 weak_test_SOURCES = weak_test.cc
734 weak_test_DEPENDENCIES = gcctestdir/ld
735 weak_test_LDFLAGS = -Bgcctestdir/
736 weak_test_LDADD =
737
738 check_PROGRAMS += weak_undef_test
739 MOSTLYCLEANFILES += alt/weak_undef_lib.so
740 weak_undef_test_SOURCES = weak_undef_test.cc
741 weak_undef_test_DEPENDENCIES = gcctestdir/ld weak_undef_lib.so alt/weak_undef_lib.so
742 weak_undef_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,alt
743 weak_undef_test_LDADD = -L . weak_undef_lib.so
744 weak_undef_file1.o: weak_undef_file1.cc
745         $(CXXCOMPILE) -c -fpic -o $@ $<
746 weak_undef_file2.o: weak_undef_file2.cc
747         $(CXXCOMPILE) -c -fpic -o $@ $<
748 weak_undef_lib.so: weak_undef_file1.o
749         $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file1.o
750 alt/weak_undef_lib.so: weak_undef_file2.o
751         test -d alt || mkdir -p alt
752         $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file2.o
753
754 check_PROGRAMS += weak_undef_test_2
755 weak_undef_test_2_SOURCES = weak_undef_test_2.cc
756 weak_undef_test_2_DEPENDENCIES = gcctestdir/ld libweak_undef_2.a
757 weak_undef_test_2_LDFLAGS = -Bgcctestdir/ -u weak_undef_2
758 weak_undef_test_2_LDADD = -L . -lweak_undef_2
759 MOSTLYCLEANFILES += libweak_undef_2.a
760 libweak_undef_2.a: weak_undef_file3.o weak_undef_file4.o
761         $(TEST_AR) rc $@ $^
762 weak_undef_file3.o: weak_undef_file3.cc
763         $(CXXCOMPILE) -c -o $@ $<
764 weak_undef_file4.o: weak_undef_file4.cc
765         $(CXXCOMPILE) -c -o $@ $<
766
767 if FN_PTRS_IN_SO_WITHOUT_PIC
768 check_PROGRAMS += weak_undef_nonpic_test
769 MOSTLYCLEANFILES += alt/weak_undef_lib_nonpic.so
770 weak_undef_nonpic_test_SOURCES = weak_undef_test.cc
771 weak_undef_nonpic_test_DEPENDENCIES = gcctestdir/ld weak_undef_lib_nonpic.so alt/weak_undef_lib_nonpic.so
772 weak_undef_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,alt
773 weak_undef_nonpic_test_LDADD = -L . weak_undef_lib_nonpic.so
774 weak_undef_file1_nonpic.o: weak_undef_file1.cc
775         $(CXXCOMPILE) -c -o $@ $<
776 weak_undef_file2_nonpic.o: weak_undef_file2.cc
777         $(CXXCOMPILE) -c -o $@ $<
778 weak_undef_lib_nonpic.so: weak_undef_file1_nonpic.o
779         $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file1_nonpic.o -Wl,-z,notext
780 alt/weak_undef_lib_nonpic.so: weak_undef_file2_nonpic.o
781         test -d alt || mkdir -p alt
782         $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file2_nonpic.o -Wl,-z,notext
783 endif FN_PTRS_IN_SO_WITHOUT_PIC
784
785
786 check_PROGRAMS += weak_alias_test
787 weak_alias_test_SOURCES = weak_alias_test_main.cc
788 weak_alias_test_DEPENDENCIES = \
789         gcctestdir/ld weak_alias_test_1.so weak_alias_test_2.so \
790         weak_alias_test_3.o weak_alias_test_4.so weak_alias_test_5.so
791 weak_alias_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
792 weak_alias_test_LDADD = \
793         weak_alias_test_1.so weak_alias_test_2.so weak_alias_test_3.o \
794         weak_alias_test_4.so weak_alias_test_5.so
795 weak_alias_test_1_pic.o: weak_alias_test_1.cc
796         $(CXXCOMPILE) -c -fpic -o $@ $<
797 weak_alias_test_1.so: weak_alias_test_1_pic.o gcctestdir/ld
798         $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_1_pic.o
799 weak_alias_test_2_pic.o: weak_alias_test_2.cc
800         $(CXXCOMPILE) -c -fpic -o $@ $<
801 weak_alias_test_2.so: weak_alias_test_2_pic.o gcctestdir/ld
802         $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_2_pic.o
803 weak_alias_test_3.o: weak_alias_test_3.cc
804         $(CXXCOMPILE) -c -o $@ $<
805 weak_alias_test_4_pic.o: weak_alias_test_4.cc
806         $(CXXCOMPILE) -c -fpic -o $@ $<
807 weak_alias_test_4.so: weak_alias_test_4_pic.o gcctestdir/ld
808         $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_4_pic.o
809 weak_alias_test_5_pic.o: weak_alias_test_5.cc
810         $(CXXCOMPILE) -c -fpic -o $@ $<
811 weak_alias_test_5.so: weak_alias_test_5_pic.o $(srcdir)/weak_alias_test.script gcctestdir/ld
812         $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_5_pic.o \
813                 -Wl,--version-script,$(srcdir)/weak_alias_test.script
814
815 check_SCRIPTS += weak_plt.sh
816 check_PROGRAMS += weak_plt
817 check_DATA += weak_plt_shared.so
818 weak_plt_main_pic.o: weak_plt_main.cc
819         $(CXXCOMPILE) -c -fpic -o $@ $<
820 weak_plt: weak_plt_main_pic.o gcctestdir/ld
821         $(CXXLINK) -Bgcctestdir/ weak_plt_main_pic.o
822 weak_plt_shared_pic.o: weak_plt_shared.cc
823         $(CXXCOMPILE) -c -fpic -o $@ $<
824 weak_plt_shared.so: weak_plt_shared_pic.o gcctestdir/ld
825         $(CXXLINK) -Bgcctestdir/ -shared weak_plt_shared_pic.o
826
827 check_PROGRAMS += copy_test
828 copy_test_SOURCES = copy_test.cc
829 copy_test_DEPENDENCIES = gcctestdir/ld copy_test_1.so copy_test_2.so
830 copy_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
831 copy_test_LDADD = copy_test_1.so copy_test_2.so
832 copy_test_1_pic.o: copy_test_1.cc
833         $(CXXCOMPILE) -c -fpic -o $@ $<
834 copy_test_1.so: gcctestdir/ld copy_test_1_pic.o
835         $(CXXLINK) -Bgcctestdir/ -shared copy_test_1_pic.o
836 copy_test_2_pic.o: copy_test_2.cc
837         $(CXXCOMPILE) -c -fpic -o $@ $<
838 copy_test_2.so: gcctestdir/ld copy_test_2_pic.o
839         $(CXXLINK) -Bgcctestdir/ -shared copy_test_2_pic.o
840
841 if TLS
842
843 check_PROGRAMS += tls_test
844 check_PROGRAMS += tls_pic_test
845 check_PROGRAMS += tls_pie_test
846 check_PROGRAMS += tls_pie_pic_test
847 check_PROGRAMS += tls_shared_test
848 check_PROGRAMS += tls_shared_ie_test
849 check_PROGRAMS += tls_shared_gd_to_ie_test
850 tls_test_pic.o: tls_test.cc
851         $(CXXCOMPILE) -c -fpic -o $@ $<
852 tls_test_file2_pic.o: tls_test_file2.cc
853         $(CXXCOMPILE) -c -fpic -o $@ $<
854 tls_test_c_pic.o: tls_test_c.c
855         $(COMPILE) -c -fpic $(TLS_TEST_C_CFLAGS) -o $@ $<
856 tls_test_shared.so: tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o gcctestdir/ld
857         $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -Wl,-z,defs
858 tls_test_shared2.so: tls_test_file2_pic.o gcctestdir/ld
859         $(CXXLINK) -Bgcctestdir/ -shared tls_test_file2_pic.o
860
861 tls_test_pic_ie.o: tls_test.cc
862         $(CXXCOMPILE) -c -fpic -ftls-model=initial-exec -o $@ $<
863 tls_test_file2_pic_ie.o: tls_test_file2.cc
864         $(CXXCOMPILE) -c -fpic -ftls-model=initial-exec -o $@ $<
865 tls_test_c_pic_ie.o: tls_test_c.c
866         $(COMPILE) -c -fpic -ftls-model=initial-exec $(TLS_TEST_C_CFLAGS) -o $@ $<
867 tls_test_ie_shared.so: tls_test_pic_ie.o tls_test_file2_pic_ie.o tls_test_c_pic_ie.o gcctestdir/ld
868         $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic_ie.o tls_test_file2_pic_ie.o tls_test_c_pic_ie.o
869
870 tls_test_SOURCES = tls_test.cc tls_test_file2.cc tls_test_main.cc tls_test.h
871 tls_test_DEPENDENCIES = gcctestdir/ld tls_test_c.o
872 tls_test_LDFLAGS = -Bgcctestdir/
873 tls_test_LDADD = tls_test_c.o -lpthread
874 tls_test_c.o: tls_test_c.c
875         $(COMPILE) -c $(TLS_TEST_C_CFLAGS) -o $@ $<
876
877 tls_pic_test_SOURCES = tls_test_main.cc
878 tls_pic_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o tls_test_file2_pic.o \
879         tls_test_c_pic.o
880 tls_pic_test_LDFLAGS = -Bgcctestdir/
881 tls_pic_test_LDADD = tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o \
882         -lpthread
883
884 tls_test_main_pie.o: tls_test_main.cc tls_test.h
885         $(CXXCOMPILE) -c -fpie -o $@ $<
886 tls_test_pie.o: tls_test.cc tls_test.h
887         $(CXXCOMPILE) -c -fpie -o $@ $<
888 tls_test_file2_pie.o: tls_test_file2.cc tls_test.h
889         $(CXXCOMPILE) -c -fpie -o $@ $<
890 tls_test_c_pie.o: tls_test_c.c
891         $(COMPILE) -c -fpic $(TLS_TEST_C_CFLAGS) -o $@ $<
892 tls_pie_test: tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o \
893                 tls_test_c_pie.o gcctestdir/ld
894         $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o tls_test_c_pie.o -lpthread
895
896 check_SCRIPTS += tls_pie_test.sh
897 check_DATA += tls_pie_test.stdout
898 tls_pie_test.stdout: tls_pie_test
899         $(TEST_READELF) -rW $< > $@ 2>/dev/null
900
901 tls_pie_pic_test: tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o \
902                 tls_test_c_pic.o gcctestdir/ld
903         $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -lpthread
904
905 tls_shared_test_SOURCES = tls_test_main.cc
906 tls_shared_test_DEPENDENCIES = gcctestdir/ld tls_test_shared.so
907 tls_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
908 tls_shared_test_LDADD = tls_test_shared.so -lpthread
909
910 tls_shared_ie_test_SOURCES = tls_test_main.cc
911 tls_shared_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_ie_shared.so
912 tls_shared_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
913 tls_shared_ie_test_LDADD = tls_test_ie_shared.so -lpthread
914
915 tls_shared_gd_to_ie_test_SOURCES = tls_test_main.cc
916 tls_shared_gd_to_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o \
917         tls_test_c_pic.o tls_test_shared2.so
918 tls_shared_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
919 tls_shared_gd_to_ie_test_LDADD = tls_test_pic.o tls_test_c_pic.o \
920         tls_test_shared2.so -lpthread
921
922 if TLS_GNU2_DIALECT
923
924 check_PROGRAMS += tls_shared_gnu2_gd_to_ie_test
925
926 tls_test_gnu2.o: tls_test.cc
927         $(CXXCOMPILE) -c -fpic -mtls-dialect=gnu2 -o $@ $<
928 tls_test_file2_gnu2.o: tls_test_file2.cc
929         $(CXXCOMPILE) -c -fpic -mtls-dialect=gnu2 -o $@ $<
930 tls_test_c_gnu2.o: tls_test_c.c
931         $(COMPILE) -c -fpic -mtls-dialect=gnu2 $(TLS_TEST_C_CFLAGS) -o $@ $<
932 tls_test_gnu2_shared2.so: tls_test_file2_gnu2.o gcctestdir/ld
933         $(CXXLINK) -Bgcctestdir/ -shared tls_test_file2_gnu2.o
934
935 tls_shared_gnu2_gd_to_ie_test_SOURCES = tls_test_main.cc
936 tls_shared_gnu2_gd_to_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_gnu2.o \
937         tls_test_c_gnu2.o tls_test_gnu2_shared2.so
938 tls_shared_gnu2_gd_to_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
939 tls_shared_gnu2_gd_to_ie_test_LDADD = tls_test_gnu2.o tls_test_c_gnu2.o \
940         tls_test_gnu2_shared2.so -lpthread
941
942 if TLS_DESCRIPTORS
943
944 check_PROGRAMS += tls_shared_gnu2_test
945
946 tls_test_gnu2_shared.so: tls_test_gnu2.o tls_test_file2_gnu2.o tls_test_c_gnu2.o gcctestdir/ld
947         $(CXXLINK) -Bgcctestdir/ -shared tls_test_gnu2.o tls_test_file2_gnu2.o tls_test_c_gnu2.o
948
949 tls_shared_gnu2_test_SOURCES = tls_test_main.cc
950 tls_shared_gnu2_test_DEPENDENCIES = gcctestdir/ld tls_test_gnu2_shared.so
951 tls_shared_gnu2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
952 tls_shared_gnu2_test_LDADD = tls_test_gnu2_shared.so -lpthread
953
954 endif TLS_DESCRIPTORS
955
956 endif TLS_GNU2_DIALECT
957
958 if HAVE_STATIC
959 if STATIC_TLS
960 check_PROGRAMS += tls_static_test
961 check_PROGRAMS += tls_static_pic_test
962
963 tls_static_test_SOURCES = $(tls_test_SOURCES)
964 tls_static_test_DEPENDENCIES = $(tls_test_DEPENDENCIES)
965 tls_static_test_LDFLAGS = $(tls_test_LDFLAGS) -static
966 tls_static_test_LDADD = $(tls_test_LDADD)
967
968 tls_static_pic_test_SOURCES = $(tls_pic_test_SOURCES)
969 tls_static_pic_test_DEPENDENCIES = $(tls_pic_test_DEPENDENCIES)
970 tls_static_pic_test_LDFLAGS = $(tls_pic_test_LDFLAGS) -static
971 tls_static_pic_test_LDADD = $(tls_pic_test_LDADD)
972 endif
973 endif
974
975 if FN_PTRS_IN_SO_WITHOUT_PIC
976 check_PROGRAMS += tls_shared_nonpic_test
977 tls_test_shared_nonpic.so: tls_test.o tls_test_file2.o tls_test_c.o gcctestdir/ld
978         $(CXXLINK) -Bgcctestdir/ -shared tls_test.o tls_test_file2.o tls_test_c.o -Wl,-z,notext
979
980 tls_shared_nonpic_test_SOURCES = tls_test_main.cc
981 tls_shared_nonpic_test_DEPENDENCIES = gcctestdir/ld tls_test_shared_nonpic.so
982 tls_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
983 tls_shared_nonpic_test_LDADD = tls_test_shared_nonpic.so -lpthread
984 endif FN_PTRS_IN_SO_WITHOUT_PIC
985
986 endif TLS
987
988 if DEFAULT_TARGET_X86_64
989
990 check_SCRIPTS += x86_64_mov_to_lea.sh
991 check_DATA += x86_64_mov_to_lea1.stdout x86_64_mov_to_lea2.stdout \
992         x86_64_mov_to_lea3.stdout x86_64_mov_to_lea4.stdout \
993         x86_64_mov_to_lea5.stdout x86_64_mov_to_lea6.stdout \
994         x86_64_mov_to_lea7.stdout x86_64_mov_to_lea8.stdout \
995         x86_64_mov_to_lea9.stdout x86_64_mov_to_lea10.stdout \
996         x86_64_mov_to_lea11.stdout x86_64_mov_to_lea12.stdout \
997         x86_64_mov_to_lea13.stdout x86_64_mov_to_lea14.stdout
998 MOSTLYCLEANFILES += x86_64_mov_to_lea1 x86_64_mov_to_lea2 \
999         x86_64_mov_to_lea3 x86_64_mov_to_lea4 x86_64_mov_to_lea5 \
1000         x86_64_mov_to_lea6 x86_64_mov_to_lea7 x86_64_mov_to_lea8 \
1001         x86_64_mov_to_lea9 x86_64_mov_to_lea10 x86_64_mov_to_lea11 \
1002         x86_64_mov_to_lea12 x86_64_mov_to_lea13 x86_64_mov_to_lea14
1003
1004 x86_64_mov_to_lea1.o: x86_64_mov_to_lea1.s
1005         $(TEST_AS) --64 -o $@ $<
1006 x86_64_mov_to_lea2.o: x86_64_mov_to_lea1.s
1007         $(TEST_AS) --x32 -o $@ $<
1008 x86_64_mov_to_lea3.o: x86_64_mov_to_lea2.s
1009         $(TEST_AS) --x32 -o $@ $<
1010 x86_64_mov_to_lea4.o: x86_64_mov_to_lea2.s
1011         $(TEST_AS) --64 -o $@ $<
1012 x86_64_mov_to_lea5.o: x86_64_mov_to_lea3.s
1013         $(TEST_AS) --x32 -mrelax-relocations=yes -o $@ $<
1014 x86_64_mov_to_lea6.o: x86_64_mov_to_lea3.s
1015         $(TEST_AS) --64 -mrelax-relocations=yes -o $@ $<
1016 x86_64_mov_to_lea7.o: x86_64_mov_to_lea4.s
1017         $(TEST_AS) --x32 -o $@ $<
1018 x86_64_mov_to_lea8.o: x86_64_mov_to_lea4.s
1019         $(TEST_AS) --64 -o $@ $<
1020 x86_64_mov_to_lea1: x86_64_mov_to_lea1.o
1021         ../ld-new -Bsymbolic -shared  -melf_x86_64  -o $@ $<
1022 x86_64_mov_to_lea2: x86_64_mov_to_lea1.o
1023         ../ld-new -pie -melf_x86_64  -o $@ $<
1024 x86_64_mov_to_lea3: x86_64_mov_to_lea1.o
1025         ../ld-new -melf_x86_64  -o $@ $<
1026 x86_64_mov_to_lea4: x86_64_mov_to_lea2.o
1027         ../ld-new -Bsymbolic -shared  -melf32_x86_64  -o $@ $<
1028 x86_64_mov_to_lea5: x86_64_mov_to_lea2.o
1029         ../ld-new -pie -melf32_x86_64  -o $@ $<
1030 x86_64_mov_to_lea6: x86_64_mov_to_lea2.o
1031         ../ld-new -melf32_x86_64  -o $@ $<
1032 x86_64_mov_to_lea7: x86_64_mov_to_lea3.o
1033         ../ld-new -melf32_x86_64 -pie -o $@ $<
1034 x86_64_mov_to_lea8: x86_64_mov_to_lea4.o
1035         ../ld-new -melf_x86_64 -pie -o $@ $<
1036 x86_64_mov_to_lea9: x86_64_mov_to_lea5.o
1037         ../ld-new -melf32_x86_64  -o $@ $<
1038 x86_64_mov_to_lea10: x86_64_mov_to_lea6.o
1039         ../ld-new -melf_x86_64  -o $@ $<
1040 x86_64_mov_to_lea11: x86_64_mov_to_lea2.o
1041         ../ld-new -melf32_x86_64 -shared  -o $@ $<
1042 x86_64_mov_to_lea12: x86_64_mov_to_lea1.o
1043         ../ld-new -melf_x86_64 -shared  -o $@ $<
1044 x86_64_mov_to_lea13: x86_64_mov_to_lea7.o
1045         ../ld-new -melf32_x86_64 -shared  -o $@ $<
1046 x86_64_mov_to_lea14: x86_64_mov_to_lea8.o
1047         ../ld-new -melf_x86_64 -shared  -o $@ $<
1048 x86_64_mov_to_lea1.stdout: x86_64_mov_to_lea1
1049         $(TEST_OBJDUMP) -dw $< > $@
1050 x86_64_mov_to_lea2.stdout: x86_64_mov_to_lea2
1051         $(TEST_OBJDUMP) -dw $< > $@
1052 x86_64_mov_to_lea3.stdout: x86_64_mov_to_lea3
1053         $(TEST_OBJDUMP) -dw $< > $@
1054 x86_64_mov_to_lea4.stdout: x86_64_mov_to_lea4
1055         $(TEST_OBJDUMP) -dw $< > $@
1056 x86_64_mov_to_lea5.stdout: x86_64_mov_to_lea5
1057         $(TEST_OBJDUMP) -dw $< > $@
1058 x86_64_mov_to_lea6.stdout: x86_64_mov_to_lea6
1059         $(TEST_OBJDUMP) -dw $< > $@
1060 x86_64_mov_to_lea7.stdout: x86_64_mov_to_lea7
1061         $(TEST_OBJDUMP) -dw $< > $@
1062 x86_64_mov_to_lea8.stdout: x86_64_mov_to_lea8
1063         $(TEST_OBJDUMP) -dw $< > $@
1064 x86_64_mov_to_lea9.stdout: x86_64_mov_to_lea9
1065         $(TEST_OBJDUMP) -dw $< > $@
1066 x86_64_mov_to_lea10.stdout: x86_64_mov_to_lea10
1067         $(TEST_OBJDUMP) -dw $< > $@
1068 x86_64_mov_to_lea11.stdout: x86_64_mov_to_lea11
1069         $(TEST_OBJDUMP) -dw $< > $@
1070 x86_64_mov_to_lea12.stdout: x86_64_mov_to_lea12
1071         $(TEST_OBJDUMP) -dw $< > $@
1072 x86_64_mov_to_lea13.stdout: x86_64_mov_to_lea13
1073         $(TEST_OBJDUMP) -dw $< > $@
1074 x86_64_mov_to_lea14.stdout: x86_64_mov_to_lea14
1075         $(TEST_OBJDUMP) -dw $< > $@
1076
1077 check_SCRIPTS += x86_64_overflow_pc32.sh
1078 check_DATA += x86_64_overflow_pc32.err
1079 MOSTLYCLEANFILES += x86_64_overflow_pc32.err
1080 x86_64_overflow_pc32.o: x86_64_overflow_pc32.s
1081         $(TEST_AS) -o $@ $<
1082 x86_64_overflow_pc32.err: x86_64_overflow_pc32.o gcctestdir/ld
1083         @echo gcctestdir/ld -e bar -Tdata=0x81000000 -o x86_64_overflow_pc32 x86_64_overflow_pc32.o "2>$@"
1084         @if gcctestdir/ld -e bar -Tdata=0x81000000 -o x86_64_overflow_pc32 x86_64_overflow_pc32.o 2>$@; \
1085         then \
1086           echo 1>&2 "Link of x86_64_overflow_pc32 should have failed"; \
1087           rm -f $@; \
1088           exit 1; \
1089         fi
1090
1091 check_SCRIPTS += x32_overflow_pc32.sh
1092 check_DATA += x32_overflow_pc32.err
1093 MOSTLYCLEANFILES += x32_overflow_pc32.err
1094 x32_overflow_pc32.o: x86_64_overflow_pc32.s
1095         $(TEST_AS) --x32 -o $@ $<
1096 x32_overflow_pc32.err: x32_overflow_pc32.o gcctestdir/ld
1097         @echo gcctestdir/ld -e bar -Tdata=0x81000000 -o x32_overflow_pc32 x32_overflow_pc32.o "2>$@"
1098         @if gcctestdir/ld -e bar -Tdata=0x81000000 -o x32_overflow_pc32 x32_overflow_pc32.o 2>$@; \
1099         then \
1100           echo 1>&2 "Link of x32_overflow_pc32 should have failed"; \
1101           rm -f $@; \
1102           exit 1; \
1103         fi
1104
1105 endif DEFAULT_TARGET_X86_64
1106
1107 if DEFAULT_TARGET_I386
1108
1109 check_SCRIPTS += i386_mov_to_lea.sh
1110 check_DATA += i386_mov_to_lea1.stdout  i386_mov_to_lea2.stdout \
1111         i386_mov_to_lea3.stdout  i386_mov_to_lea4.stdout \
1112         i386_mov_to_lea5.stdout i386_mov_to_lea6.stdout \
1113         i386_mov_to_lea7.stdout i386_mov_to_lea8.stdout
1114 MOSTLYCLEANFILES += i386_mov_to_lea1 i386_mov_to_lea2 i386_mov_to_lea3 \
1115         i386_mov_to_lea4 i386_mov_to_lea5 i386_mov_to_lea6 \
1116         i386_mov_to_lea7 i386_mov_to_lea8
1117
1118 i386_mov_to_lea1.o: i386_mov_to_lea1.s
1119         $(TEST_AS) --32 -o $@ $<
1120 i386_mov_to_lea2.o: i386_mov_to_lea2.s
1121         $(TEST_AS) --32 -o $@ $<
1122 i386_mov_to_lea3.o: i386_mov_to_lea3.s
1123         $(TEST_AS) --32 -o $@ $<
1124 i386_mov_to_lea4.o: i386_mov_to_lea4.s
1125         $(TEST_AS) --32 -o $@ $<
1126 i386_mov_to_lea5.o: i386_mov_to_lea5.s
1127         $(TEST_AS) --32 -o $@ $<
1128 i386_mov_to_lea1: i386_mov_to_lea1.o
1129         ../ld-new -Bsymbolic -shared -melf_i386  -o $@ $<
1130 i386_mov_to_lea2: i386_mov_to_lea1.o
1131         ../ld-new  -pie -melf_i386  -o $@ $<
1132 i386_mov_to_lea3: i386_mov_to_lea1.o
1133         ../ld-new -melf_i386  -o $@ $<
1134 i386_mov_to_lea4: i386_mov_to_lea1.o
1135         ../ld-new -melf_i386 -shared  -o $@ $<
1136 i386_mov_to_lea5: i386_mov_to_lea2.o
1137         ../ld-new -melf_i386 -shared  -o $@ $<
1138 i386_mov_to_lea6: i386_mov_to_lea3.o
1139         ../ld-new -melf_i386 -shared  -o $@ $<
1140 i386_mov_to_lea7: i386_mov_to_lea4.o
1141         ../ld-new -melf_i386 -shared  -o $@ $<
1142 i386_mov_to_lea8: i386_mov_to_lea5.o
1143         ../ld-new -melf_i386 -shared  -o $@ $<
1144 i386_mov_to_lea1.stdout: i386_mov_to_lea1
1145         $(TEST_OBJDUMP) -dw $< > $@
1146 i386_mov_to_lea2.stdout: i386_mov_to_lea2
1147         $(TEST_OBJDUMP) -dw $< > $@
1148 i386_mov_to_lea3.stdout: i386_mov_to_lea3
1149         $(TEST_OBJDUMP) -dw $< > $@
1150 i386_mov_to_lea4.stdout: i386_mov_to_lea4
1151         $(TEST_OBJDUMP) -dw $< > $@
1152 i386_mov_to_lea5.stdout: i386_mov_to_lea5
1153         $(TEST_OBJDUMP) -dw $< > $@
1154 i386_mov_to_lea6.stdout: i386_mov_to_lea6
1155         $(TEST_OBJDUMP) -dw $< > $@
1156 i386_mov_to_lea7.stdout: i386_mov_to_lea7
1157         $(TEST_OBJDUMP) -dw $< > $@
1158 i386_mov_to_lea8.stdout: i386_mov_to_lea8
1159         $(TEST_OBJDUMP) -dw $< > $@
1160
1161 endif DEFAULT_TARGET_I386
1162
1163 check_PROGRAMS += many_sections_test
1164 many_sections_test_SOURCES = many_sections_test.cc
1165 many_sections_test_DEPENDENCIES = gcctestdir/ld
1166 many_sections_test_LDFLAGS = -Bgcctestdir/ -rdynamic
1167 many_sections_test_LDADD =
1168
1169 BUILT_SOURCES += many_sections_define.h
1170 MOSTLYCLEANFILES += many_sections_define.h
1171 many_sections_define.h:
1172         (for i in `seq 1 70000`; do \
1173            echo "int var_$$i __attribute__((section(\"section_$$i\"))) = $$i;"; \
1174          done) > $@.tmp
1175         mv -f $@.tmp $@
1176
1177 BUILT_SOURCES += many_sections_check.h
1178 MOSTLYCLEANFILES += many_sections_check.h
1179 many_sections_check.h:
1180         (for i in `seq 1 1000 70000`; do \
1181            echo "assert(var_$$i == $$i);"; \
1182          done) > $@.tmp
1183         mv -f $@.tmp $@
1184
1185 check_PROGRAMS += many_sections_r_test
1186 many_sections_r_test.o: many_sections_test.o gcctestdir/ld
1187         gcctestdir/ld -r -o $@ many_sections_test.o
1188 many_sections_r_test: many_sections_r_test.o gcctestdir/ld
1189         $(CXXLINK) -Bgcctestdir/ many_sections_r_test.o $(LIBS)
1190
1191 check_PROGRAMS += initpri1
1192 initpri1_SOURCES = initpri1.c
1193 initpri1_DEPENDENCIES = gcctestdir/ld
1194 initpri1_LDFLAGS = -Bgcctestdir/
1195 initpri1_LDADD =
1196
1197 check_PROGRAMS += initpri2
1198 initpri2_SOURCES = initpri2.c
1199 initpri2_DEPENDENCIES = gcctestdir/ld
1200 initpri2_LDFLAGS = -Bgcctestdir/ -Wl,--ctors-in-init-array
1201 initpri2_LDADD =
1202
1203 check_PROGRAMS += initpri3a
1204 initpri3a_SOURCES = initpri3.c
1205 initpri3a_DEPENDENCIES = gcctestdir/ld
1206 initpri3a_LDFLAGS = -Bgcctestdir/
1207 initpri3a_LDADD =
1208
1209 # This test fails on targets not using .ctors and .dtors sections (e.g. ARM
1210 # EABI). Given that gcc is moving towards using .init_array in all cases,
1211 # this test is commented out.  A better fix would be checking whether gcc
1212 # uses .ctors or .init_array sections in configure.
1213
1214 # check_PROGRAMS += initpri3b
1215 # initpri3b_SOURCES = initpri3.c
1216 # initpri3b_DEPENDENCIES = gcctestdir/ld
1217 # initpri3b_LDFLAGS = -Bgcctestdir/ -Wl,--no-ctors-in-init-array
1218 # initpri3b_LDADD =
1219
1220 # Test --detect-odr-violations
1221 check_SCRIPTS += debug_msg.sh
1222
1223 # Create the data files that debug_msg.sh analyzes.
1224 check_DATA += debug_msg.err
1225 MOSTLYCLEANFILES += debug_msg.err
1226 debug_msg.o: debug_msg.cc
1227         $(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/debug_msg.cc
1228 odr_violation1.o: odr_violation1.cc
1229         $(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/odr_violation1.cc
1230 # Compile with different optimization flags to check that rearranged
1231 # instructions don't cause a false positive.
1232 odr_violation2.o: odr_violation2.cc
1233         $(CXXCOMPILE) -O2 -g -c -w -o $@ $(srcdir)/odr_violation2.cc
1234 debug_msg.err: debug_msg.o odr_violation1.o odr_violation2.o gcctestdir/ld
1235         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o "2>$@"
1236         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o 2>$@; \
1237         then \
1238           echo 1>&2 "Link of debug_msg should have failed"; \
1239           rm -f $@; \
1240           exit 1; \
1241         fi
1242
1243 # Test error message when a vtable is undefined.
1244 check_SCRIPTS += missing_key_func.sh
1245 check_DATA += missing_key_func.err
1246 MOSTLYCLEANFILES += missing_key_func.err
1247 missing_key_func.o: missing_key_func.cc
1248         $(CXXCOMPILE) -O0 -g -c -o $@ $(srcdir)/missing_key_func.cc
1249 missing_key_func.err: missing_key_func.o gcctestdir/ld
1250         @echo $(CXXLINK) -Bgcctestdir/ -o missing_key_func missing_key_func.o "2>$@"
1251         @if $(CXXLINK) -Bgcctestdir/ -o missing_key_func missing_key_func.o 2>$@; \
1252         then \
1253           echo 1>&2 "Link of missing_key_func should have failed"; \
1254           rm -f $@; \
1255           exit 1; \
1256         fi
1257
1258 # Check that --detect-odr-violations works with compressed debug sections.
1259 check_DATA += debug_msg_cdebug.err
1260 MOSTLYCLEANFILES += debug_msg_cdebug.err
1261 debug_msg_cdebug.o: debug_msg.cc gcctestdir/as
1262         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/debug_msg.cc
1263 odr_violation1_cdebug.o: odr_violation1.cc gcctestdir/as
1264         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/odr_violation1.cc
1265 odr_violation2_cdebug.o: odr_violation2.cc gcctestdir/as
1266         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/odr_violation2.cc
1267 debug_msg_cdebug.err: debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o gcctestdir/ld
1268         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o "2>$@"
1269         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o 2>$@; \
1270         then \
1271           echo 1>&2 "Link of debug_msg_cdebug should have failed"; \
1272           rm -f $@; \
1273           exit 1; \
1274         fi
1275 check_DATA += debug_msg_cdebug_gabi.err
1276 MOSTLYCLEANFILES += debug_msg_cdebug_gabi.err
1277 debug_msg_cdebug_gabi.o: debug_msg.cc gcctestdir/as
1278         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections=zlib-gabi -c -w -o $@ $(srcdir)/debug_msg.cc
1279 odr_violation1_cdebug_gabi.o: odr_violation1.cc gcctestdir/as
1280         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections=zlib-gabi -c -w -o $@ $(srcdir)/odr_violation1.cc
1281 odr_violation2_cdebug_gabi.o: odr_violation2.cc gcctestdir/as
1282         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g -Wa,--compress-debug-sections=zlib-gabi -c -w -o $@ $(srcdir)/odr_violation2.cc
1283 debug_msg_cdebug_gabi.err: debug_msg_cdebug_gabi.o odr_violation1_cdebug_gabi.o odr_violation2_cdebug_gabi.o gcctestdir/ld
1284         @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug debug_msg_cdebug_gabi.o odr_violation1_cdebug_gabi.o odr_violation2_cdebug_gabi.o "2>$@"
1285         @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug_gabi debug_msg_cdebug_gabi.o odr_violation1_cdebug_gabi.o odr_violation2_cdebug_gabi.o 2>$@; \
1286         then \
1287           echo 1>&2 "Link of debug_msg_cdebug_gabi should have failed"; \
1288           rm -f $@; \
1289           exit 1; \
1290         fi
1291
1292 # See if we can also detect problems when we're linking .so's, not .o's.
1293 check_DATA += debug_msg_so.err
1294 MOSTLYCLEANFILES += debug_msg_so.err
1295 debug_msg.so: debug_msg.cc gcctestdir/ld
1296         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
1297 odr_violation1.so: odr_violation1.cc gcctestdir/ld
1298         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
1299 odr_violation2.so: odr_violation2.cc gcctestdir/ld
1300         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
1301 debug_msg_so.err: debug_msg.so odr_violation1.so odr_violation2.so gcctestdir/ld
1302         @echo $(CXXLINK_S) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so "2>$@"
1303         @if $(CXXLINK_S) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so 2>$@; \
1304         then \
1305           echo 1>&2 "Link of debug_msg_so should have failed"; \
1306           rm -f $@; \
1307           exit 1; \
1308         fi
1309
1310 # We also want to make sure we do something reasonable when there's no
1311 # debug info available.  For the best test, we use .so's.
1312 check_DATA += debug_msg_ndebug.err
1313 MOSTLYCLEANFILES += debug_msg_ndebug.err
1314 debug_msg_ndebug.so: debug_msg.cc gcctestdir/ld
1315         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
1316 odr_violation1_ndebug.so: odr_violation1.cc gcctestdir/ld
1317         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
1318 odr_violation2_ndebug.so: odr_violation2.cc gcctestdir/ld
1319         $(CXXCOMPILE) -Bgcctestdir/ -O2 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
1320 debug_msg_ndebug.err: debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so gcctestdir/ld
1321         @echo $(CXXLINK_S) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so -shared-libgcc -Bdynamic -lstdc++ "2>$@"
1322         @if $(CXXLINK_S) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so -shared-libgcc -Bdynamic -lstdc++ 2>$@; \
1323         then \
1324           echo 1>&2 "Link of debug_msg_ndebug should have failed"; \
1325           rm -f $@; \
1326           exit 1; \
1327         fi
1328
1329
1330 # Similar to --detect-odr-violations: check for undefined symbols in .so's
1331 check_SCRIPTS += undef_symbol.sh
1332 check_DATA += undef_symbol.err
1333 MOSTLYCLEANFILES += undef_symbol.err
1334 undef_symbol.o: undef_symbol.cc
1335         $(CXXCOMPILE) -O0 -g -c -fPIC $<
1336 undef_symbol.so: undef_symbol.o gcctestdir/ld
1337         $(CXXLINK) -Bgcctestdir/ -shared undef_symbol.o
1338 undef_symbol.err: undef_symbol_main.o undef_symbol.so gcctestdir/ld
1339         @echo $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so "2>$@"
1340         @if $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so 2>$@; \
1341         then \
1342           echo 1>&2 "Link of undef_symbol_test should have failed"; \
1343           rm -f $@; \
1344           exit 1; \
1345         fi
1346
1347
1348 # Test -o when emitting to a special file (such as something in /dev).
1349 check_PROGRAMS += flagstest_o_specialfile
1350 flagstest_o_specialfile: flagstest_debug.o gcctestdir/ld
1351         $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< 2>&1 | cat > $@
1352         chmod a+x $@
1353         test -s $@
1354
1355 # Test --compress-debug-sections.
1356 check_PROGRAMS += flagstest_compress_debug_sections_none
1357 check_DATA += flagstest_compress_debug_sections_none.stdout
1358 flagstest_compress_debug_sections_none: flagstest_debug.o gcctestdir/ld
1359         $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=none
1360         test -s $@
1361
1362 # Dump DWARF debug sections.
1363 flagstest_compress_debug_sections_none.stdout: flagstest_compress_debug_sections_none
1364         $(TEST_READELF) -w $< > $@.tmp
1365         mv -f $@.tmp $@
1366
1367 check_PROGRAMS += flagstest_compress_debug_sections
1368 check_DATA += flagstest_compress_debug_sections.stdout \
1369               flagstest_compress_debug_sections.cmp \
1370               flagstest_compress_debug_sections.check
1371 MOSTLYCLEANFILES += flagstest_compress_debug_sections.check \
1372                     flagstest_compress_debug_sections.cmp
1373 flagstest_compress_debug_sections: flagstest_debug.o gcctestdir/ld
1374         $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib
1375         test -s $@
1376
1377 # Test --compress-debug-sections with --build-id=tree.
1378 check_PROGRAMS += flagstest_compress_debug_sections_and_build_id_tree
1379 flagstest_compress_debug_sections_and_build_id_tree: flagstest_debug.o gcctestdir/ld
1380         $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib \
1381                 -Wl,--build-id=tree \
1382                 -Wl,--build-id-chunk-size-for-treehash=4096 \
1383                 -Wl,--build-id-min-file-size-for-treehash=0
1384         test -s $@
1385
1386 # Dump compressed DWARF debug sections.
1387 flagstest_compress_debug_sections.stdout: flagstest_compress_debug_sections
1388         $(TEST_READELF) -w $< | sed -e "s/.zdebug_/.debug_/" > $@.tmp
1389         mv -f $@.tmp $@
1390
1391 # Check there are compressed DWARF .debug_* sections.
1392 flagstest_compress_debug_sections.check: flagstest_compress_debug_sections
1393         $(TEST_READELF) -SW $< | egrep ".debug_.* C *" > $@.tmp
1394         mv -f $@.tmp $@
1395
1396 # Compare DWARF debug info.
1397 flagstest_compress_debug_sections.cmp: flagstest_compress_debug_sections.stdout \
1398         flagstest_compress_debug_sections_none.stdout
1399         cmp flagstest_compress_debug_sections.stdout \
1400                 flagstest_compress_debug_sections_none.stdout > $@.tmp
1401         mv -f $@.tmp $@
1402
1403 check_PROGRAMS += flagstest_compress_debug_sections_gnu
1404 check_DATA += flagstest_compress_debug_sections_gnu.stdout \
1405               flagstest_compress_debug_sections_gnu.cmp \
1406               flagstest_compress_debug_sections_gnu.check
1407 MOSTLYCLEANFILES += flagstest_compress_debug_sections_gnu.check \
1408                     flagstest_compress_debug_sections_gnu.cmp
1409 flagstest_compress_debug_sections_gnu: flagstest_debug.o gcctestdir/ld
1410         $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib-gnu
1411         test -s $@
1412
1413 # Dump compressed DWARF debug sections.
1414 flagstest_compress_debug_sections_gnu.stdout: flagstest_compress_debug_sections_gnu
1415         $(TEST_READELF) -w $< | sed -e "s/.zdebug_/.debug_/" > $@.tmp
1416         mv -f $@.tmp $@
1417
1418 # Check there are compressed DWARF .zdebug_* sections.
1419 flagstest_compress_debug_sections_gnu.check: flagstest_compress_debug_sections_gnu
1420         $(TEST_READELF) -SW $< | grep ".zdebug_" > $@.tmp
1421         mv -f $@.tmp $@
1422
1423 # Compare DWARF debug info.
1424 flagstest_compress_debug_sections_gnu.cmp: flagstest_compress_debug_sections_gnu.stdout \
1425         flagstest_compress_debug_sections_none.stdout
1426         cmp flagstest_compress_debug_sections_gnu.stdout \
1427                 flagstest_compress_debug_sections_none.stdout > $@.tmp
1428         mv -f $@.tmp $@
1429
1430 check_PROGRAMS += flagstest_compress_debug_sections_gabi
1431 check_DATA += flagstest_compress_debug_sections_gabi.stdout \
1432               flagstest_compress_debug_sections_gabi.cmp \
1433               flagstest_compress_debug_sections_gabi.check
1434 MOSTLYCLEANFILES += flagstest_compress_debug_sections_gabi.cmp \
1435                     flagstest_compress_debug_sections_gabi.check
1436 flagstest_compress_debug_sections_gabi: flagstest_debug.o gcctestdir/ld
1437         $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib-gabi
1438         test -s $@
1439
1440 # Dump compressed DWARF debug sections.
1441 flagstest_compress_debug_sections_gabi.stdout: flagstest_compress_debug_sections_gabi
1442         $(TEST_READELF) -w $< > $@.tmp
1443         mv -f $@.tmp $@
1444
1445 # Check there are compressed DWARF .debug_* sections.
1446 flagstest_compress_debug_sections_gabi.check: flagstest_compress_debug_sections_gabi
1447         $(TEST_READELF) -tW $< | grep "COMPRESSED" > $@.tmp
1448         mv -f $@.tmp $@
1449
1450 # Compare DWARF debug info.
1451 flagstest_compress_debug_sections_gabi.cmp: flagstest_compress_debug_sections_gabi.stdout \
1452         flagstest_compress_debug_sections_none.stdout
1453         cmp flagstest_compress_debug_sections_gabi.stdout \
1454                 flagstest_compress_debug_sections_none.stdout > $@.tmp
1455         mv -f $@.tmp $@
1456
1457 # The specialfile output has a tricky case when we also compress debug
1458 # sections, because it requires output-file resizing.
1459 check_PROGRAMS += flagstest_o_specialfile_and_compress_debug_sections
1460 flagstest_o_specialfile_and_compress_debug_sections: flagstest_debug.o \
1461                 gcctestdir/ld
1462         $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< -Wl,--compress-debug-sections=zlib 2>&1 | cat > $@
1463         chmod a+x $@
1464         test -s $@
1465
1466 check_SCRIPTS += pr18689.sh
1467 check_DATA += pr18689.stdout
1468 MOSTLYCLEANFILES += pr18689a.o pr18689b.o
1469
1470 pr18689.stdout: pr18689b.o
1471         $(TEST_READELF) -SW $< > $@
1472
1473 pr18689a.o: pr18689.o ../ld-new
1474         ../ld-new -r -o $@ $<
1475
1476 pr18689b.o: pr18689a.o ../ld-new
1477         ../ld-new -r -o $@ $<
1478
1479 pr18689.o: pr18689.c gcctestdir/as
1480         $(COMPILE) -Bgcctestdir/ -ggdb3 -g -Wa,--compress-debug-sections=zlib-gabi -c -w -o $@ $(srcdir)/pr18689.c
1481
1482 # Test -TText and -Tdata.
1483 check_PROGRAMS += flagstest_o_ttext_1
1484 flagstest_o_ttext_1: flagstest_debug.o gcctestdir/ld
1485         $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,-Ttext,0x400000 -Wl,-Tdata,0x800000
1486
1487 # This version won't be runnable, because there is no way to put the
1488 # PT_PHDR segment at file offset 0.  We just make sure that we can
1489 # build it without error.
1490 check_DATA += flagstest_o_ttext_2
1491 MOSTLYCLEANFILES += flagstest_o_ttext_2
1492 flagstest_o_ttext_2: flagstest_debug.o gcctestdir/ld
1493         $(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,-Ttext,0x400010 -Wl,-Tdata,0x800010
1494
1495 # Test symbol versioning.
1496 check_PROGRAMS += ver_test
1497 ver_test_SOURCES = ver_test_main.cc
1498 ver_test_DEPENDENCIES = gcctestdir/ld ver_test_1.so ver_test_2.so ver_test_4.so
1499 ver_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1500 ver_test_LDADD = ver_test_1.so ver_test_2.so ver_test_4.so
1501 ver_test_1.so: ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so gcctestdir/ld
1502         $(CXXLINK) -Bgcctestdir/ -shared ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so
1503 ver_test_2.so: ver_test_2.o $(srcdir)/ver_test_2.script ver_test_4.so gcctestdir/ld
1504         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_2.script -Wl,-R,. ver_test_2.o ver_test_4.so
1505 ver_test_4.so: ver_test_4.o $(srcdir)/ver_test_4.script gcctestdir/ld
1506         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o
1507 ver_test_1.o: ver_test_1.cc
1508         $(CXXCOMPILE) -c -fpic -o $@ $<
1509 ver_test_2.o: ver_test_2.cc
1510         $(CXXCOMPILE) -c -fpic -o $@ $<
1511 ver_test_3.o: ver_test_3.cc
1512         $(CXXCOMPILE) -c -fpic -o $@ $<
1513 ver_test_4.o: ver_test_4.cc
1514         $(CXXCOMPILE) -c -fpic -o $@ $<
1515
1516 check_SCRIPTS += ver_test_1.sh
1517 check_DATA += ver_test_1.syms
1518 ver_test_1.syms: ver_test_1.so
1519         $(TEST_READELF) -s $< >$@ 2>/dev/null
1520
1521 check_PROGRAMS += ver_test_2
1522 ver_test_2_SOURCES = ver_test_main_2.cc
1523 ver_test_2_DEPENDENCIES = gcctestdir/ld ver_test_4.so ver_test_2.so
1524 ver_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1525 ver_test_2_LDADD = ver_test_4.so ver_test_2.so
1526
1527 check_SCRIPTS += ver_test_2.sh
1528 check_DATA += ver_test_2.syms
1529 ver_test_2.syms: ver_test_2
1530         $(TEST_READELF) -s $< >$@ 2>/dev/null
1531
1532 check_SCRIPTS += ver_test_4.sh
1533 check_DATA += ver_test_4.syms
1534 ver_test_4.syms: ver_test_4.so
1535         $(TEST_READELF) -s $< >$@ 2>/dev/null
1536
1537 ver_test_5.so: ver_test_5.o $(srcdir)/ver_test_5.script ver_test_4.so gcctestdir/ld
1538         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_5.script ver_test_5.o ver_test_4.so
1539 ver_test_5.o: ver_test_5.cc
1540         $(CXXCOMPILE) -c -fpic -o $@ $<
1541 check_SCRIPTS += ver_test_5.sh
1542 check_DATA += ver_test_5.syms
1543 ver_test_5.syms: ver_test_5.so
1544         $(TEST_READELF) -s $< >$@ 2>/dev/null
1545
1546 check_PROGRAMS += ver_test_6
1547 ver_test_6_SOURCES = ver_test_6.c
1548 ver_test_6_DEPENDENCIES = gcctestdir/ld ver_test_2.so
1549 ver_test_6_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1550 ver_test_6_LDADD = ver_test_2.so
1551
1552 ver_test_7.so: ver_test_4.o $(srcdir)/ver_test_4.script ver_test_7.o gcctestdir/ld
1553         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o ver_test_7.o
1554 ver_test_7.o: ver_test_7.cc
1555         $(CXXCOMPILE) -c -fpic -o $@ $<
1556 check_SCRIPTS += ver_test_7.sh
1557 check_DATA += ver_test_7.syms
1558 ver_test_7.syms: ver_test_7.so
1559         $(TEST_READELF) -s $< >$@ 2>/dev/null
1560
1561 check_PROGRAMS += ver_test_8
1562 ver_test_8_SOURCES = two_file_test_main.cc
1563 ver_test_8_DEPENDENCIES = gcctestdir/ld ver_test_8_1.so ver_test_8_2.so
1564 ver_test_8_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1565 ver_test_8_LDADD = ver_test_8_1.so ver_test_8_2.so
1566 ver_test_8_1.so: two_file_test_1_pic.o two_file_test_1b_pic.o ver_test_8_2.so gcctestdir/ld
1567         $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o ver_test_8_2.so
1568 ver_test_8_2.so: two_file_test_2_pic.o $(srcdir)/ver_test_8.script gcctestdir/ld
1569         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_8.script two_file_test_2_pic.o
1570
1571 check_PROGRAMS += ver_test_9
1572 ver_test_9_SOURCES = ver_test_main.cc
1573 ver_test_9_DEPENDENCIES = gcctestdir/ld ver_test_9.so
1574 ver_test_9_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1575 ver_test_9_LDADD = ver_test_9.so
1576 ver_test_9.so: ver_test_9.o ver_test_4.so ver_test_5.so gcctestdir/ld
1577         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-R,. ver_test_9.o ver_test_5.so ver_test_4.so
1578 ver_test_9.o: ver_test_9.cc
1579         $(CXXCOMPILE) -c -fpic -o $@ $<
1580
1581 check_SCRIPTS += ver_test_10.sh
1582 check_DATA += ver_test_10.syms
1583 ver_test_10.syms: ver_test_10.so
1584         $(TEST_READELF) -s $< >$@ 2>/dev/null
1585 ver_test_10.so: gcctestdir/ld ver_test_2.o ver_test_10.script
1586         $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_10.script ver_test_2.o
1587
1588 check_PROGRAMS += ver_test_11
1589 MOSTLYCLEANFILES += ver_test_11.a
1590 ver_test_11_SOURCES = ver_test_main_2.cc
1591 ver_test_11_DEPENDENCIES = gcctestdir/ld ver_test_11.a
1592 ver_test_11_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1593 ver_test_11_LDADD = ver_test_11.a
1594 ver_test_11.a: ver_test_1.o ver_test_2.o ver_test_4.o
1595         $(TEST_AR) rc $@ $^
1596
1597 check_PROGRAMS += ver_test_12
1598 ver_test_12_SOURCES = ver_test_main_2.cc
1599 ver_test_12_DEPENDENCIES = gcctestdir/ld ver_test_12.o
1600 ver_test_12_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1601 ver_test_12_LDADD = ver_test_12.o
1602 ver_test_12.o: gcctestdir/ld ver_test_1.o ver_test_2.o ver_test_4.o
1603         gcctestdir/ld -r -o $@ ver_test_1.o ver_test_2.o ver_test_4.o
1604
1605 check_SCRIPTS += ver_test_13.sh
1606 check_DATA += ver_test_13.syms
1607 ver_test_13.syms: ver_test_13.so
1608         $(TEST_READELF) -s $< >$@ 2>/dev/null
1609 ver_test_13.so: gcctestdir/ld ver_test_13.o ver_test_13.script
1610         $(LINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_13.script ver_test_13.o
1611 ver_test_13.o: ver_test_13.c
1612         $(COMPILE) -c -fpic -o $@ $<
1613
1614 check_PROGRAMS += protected_1
1615 protected_1_SOURCES = \
1616         protected_main_1.cc protected_main_2.cc protected_main_3.cc
1617 protected_1_DEPENDENCIES = gcctestdir/ld protected_1.so
1618 protected_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1619 protected_1_LDADD = protected_1.so
1620
1621 protected_1.so: gcctestdir/ld protected_1_pic.o protected_2_pic.o protected_3_pic.o
1622         $(CXXLINK) -Bgcctestdir/ -shared protected_1_pic.o protected_2_pic.o protected_3_pic.o
1623 protected_1_pic.o: protected_1.cc
1624         $(CXXCOMPILE) -c -fpic -o $@ $<
1625 protected_2_pic.o: protected_2.cc
1626         $(CXXCOMPILE) -c -fpic -o $@ $<
1627 protected_3_pic.o: protected_3.cc
1628         $(CXXCOMPILE) -c -fpic -o $@ $<
1629
1630 check_PROGRAMS += protected_2
1631 protected_2_SOURCES = protected_main_1.cc protected_3.cc
1632 protected_2_DEPENDENCIES = gcctestdir/ld protected_1.so
1633 protected_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1634 protected_2_LDADD = protected_1.so
1635
1636 check_DATA += protected_3.err
1637 MOSTLYCLEANFILES += protected_3.err
1638 protected_4_pic.o: protected_4.cc
1639         $(CXXCOMPILE) -c -fpic -o $@ $<
1640 protected_3.err: protected_4_pic.o gcctestdir/ld
1641         @echo $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o "2>$@"
1642         @if $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o 2>$@; then \
1643           echo 1>&2 "Link of protected_4.so should have failed"; \
1644           rm -f $@; \
1645           exit 1; \
1646         fi
1647
1648 check_PROGRAMS += relro_test
1649 check_SCRIPTS += relro_test.sh
1650 check_DATA += relro_test.stdout
1651 relro_test_SOURCES = relro_test_main.cc
1652 relro_test_DEPENDENCIES = gcctestdir/ld relro_test.so
1653 relro_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1654 relro_test_LDADD = relro_test.so
1655 relro_test.so: gcctestdir/ld relro_test_pic.o
1656         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro relro_test_pic.o
1657 relro_test_pic.o: relro_test.cc
1658         $(CXXCOMPILE) -c -fpic -o $@ $<
1659 relro_test.stdout: relro_test.so
1660         $(TEST_READELF) -SlW relro_test.so > relro_test.stdout
1661
1662 check_PROGRAMS += relro_now_test
1663 relro_now_test_SOURCES = relro_test_main.cc
1664 relro_now_test_DEPENDENCIES = gcctestdir/ld relro_now_test.so
1665 relro_now_test_LDFLAGS = -Bgcctestdir -Wl,-R,. -Wl,-z,relro -Wl,-z,now
1666 relro_now_test_LDADD = relro_now_test.so
1667 relro_now_test.so: gcctestdir/ld relro_test_pic.o
1668         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro -Wl,-z,now relro_test_pic.o
1669
1670 check_PROGRAMS += relro_strip_test
1671 relro_strip_test_SOURCES = relro_test_main.cc
1672 relro_strip_test_DEPENDENCIES = gcctestdir/ld relro_strip_test.so
1673 relro_strip_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1674 relro_strip_test_LDADD = relro_strip_test.so
1675 relro_strip_test.so: relro_test.so
1676         $(TEST_STRIP) -o $@ $<
1677
1678 check_PROGRAMS += relro_script_test
1679 relro_script_test_SOURCES = relro_test_main.cc
1680 relro_script_test_DEPENDENCIES = gcctestdir/ld relro_script_test.so
1681 relro_script_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1682 relro_script_test_LDADD = relro_script_test.so
1683 relro_script_test.so: gcctestdir/ld relro_script_test.t relro_test_pic.o
1684         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro -Wl,-T,$(srcdir)/relro_script_test.t relro_test_pic.o
1685
1686 check_PROGRAMS += script_test_1
1687 script_test_1_SOURCES = script_test_1a.cc script_test_1b.cc
1688 script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
1689 script_test_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -Wl,-T,$(srcdir)/script_test_1.t
1690 script_test_1_LDADD =
1691
1692 check_PROGRAMS += script_test_2
1693 script_test_2_SOURCES = script_test_2.cc script_test_2a.cc script_test_2b.cc
1694 script_test_2_DEPENDENCIES = gcctestdir/ld script_test_2.t
1695 script_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -Wl,-T,$(srcdir)/script_test_2.t
1696 script_test_2_LDADD =
1697
1698 check_PROGRAMS += justsyms
1699 justsyms_SOURCES = justsyms_1.cc
1700 justsyms_DEPENDENCIES = gcctestdir/ld justsyms_2r.o
1701 justsyms_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_2r.o
1702 justsyms_LDADD =
1703 justsyms_2.o: justsyms_2.cc
1704         $(CXXCOMPILE) -c -o $@ $<
1705 justsyms_2r.o: justsyms_2.o gcctestdir/ld $(srcdir)/justsyms.t
1706         gcctestdir/ld -o $@ -r -T $(srcdir)/justsyms.t justsyms_2.o
1707
1708 check_PROGRAMS += justsyms_exec
1709 justsyms_exec_SOURCES = justsyms_exec.c
1710 justsyms_exec_DEPENDENCIES = gcctestdir/ld justsyms_lib
1711 justsyms_exec_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_lib
1712 justsyms_exec_LDADD =
1713 MOSTLYCLEANFILES += justsyms_lib
1714 justsyms_lib.o: justsyms_lib.c
1715         $(COMPILE) -c -o $@ $<
1716 justsyms_lib: justsyms_lib.o gcctestdir/ld
1717         gcctestdir/ld -o $@ -Ttext=0x1000200 -Tdata=0x2000000 -e exported_func justsyms_lib.o
1718
1719 check_PROGRAMS += binary_test
1720 MOSTLYCLEANFILES += binary.txt
1721 binary_test_SOURCES = binary_test.cc
1722 binary_test_DEPENDENCIES = gcctestdir/ld binary.txt
1723 binary_test_LDFLAGS = -Bgcctestdir/ -Wl,--format,binary,binary.txt,--format,elf
1724 binary_test_LDADD =
1725 # Copy the file to the build directory to avoid worrying about the
1726 # full pathname in the generated symbols.
1727 binary.txt: $(srcdir)/binary.in
1728         rm -f $@
1729         $(LN_S) $< $@
1730
1731 check_SCRIPTS += ver_matching_test.sh
1732 check_DATA += ver_matching_test.stdout
1733 MOSTLYCLEANFILES += ver_matching_test.stdout
1734 ver_matching_def.so: ver_matching_def_pic.o $(srcdir)/version_script.map gcctestdir/ld
1735         $(CXXLINK) -O0 -Bgcctestdir/ -shared ver_matching_def_pic.o -Wl,--version-script=$(srcdir)/version_script.map
1736 ver_matching_def_pic.o: ver_matching_def.cc
1737         $(CXXCOMPILE) -O0 -c -fpic -o $@ $<
1738 ver_matching_test.stdout: ver_matching_def.so
1739         $(TEST_OBJDUMP) -T ver_matching_def.so | $(TEST_CXXFILT) > ver_matching_test.stdout
1740
1741 check_PROGRAMS += script_test_3
1742 check_SCRIPTS += script_test_3.sh
1743 check_DATA += script_test_3.stdout
1744 MOSTLYCLEANFILES += script_test_3.stdout
1745 script_test_3: basic_test.o gcctestdir/ld script_test_3.t
1746         $(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_3.t
1747 script_test_3.stdout: script_test_3
1748         $(TEST_READELF) -SlW script_test_3 > script_test_3.stdout
1749
1750 check_PROGRAMS += tls_phdrs_script_test
1751 tls_phdrs_script_test_SOURCES = $(tls_test_SOURCES)
1752 tls_phdrs_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_3.t
1753 tls_phdrs_script_test_LDFLAGS = $(tls_test_LDFLAGS) -Wl,-T,$(srcdir)/script_test_3.t
1754 tls_phdrs_script_test_LDADD = $(tls_test_LDADD)
1755
1756 check_SCRIPTS += script_test_4.sh
1757 check_DATA += script_test_4.stdout
1758 MOSTLYCLEANFILES += script_test_4
1759 script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
1760         $(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_4.t
1761 script_test_4.stdout: script_test_4
1762         $(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
1763
1764 check_PROGRAMS += tls_script_test
1765 tls_script_test_SOURCES = $(tls_test_SOURCES)
1766 tls_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_4.t
1767 tls_script_test_LDFLAGS = $(tls_test_LDFLAGS) -Wl,-T,$(srcdir)/script_test_4.t
1768 tls_script_test_LDADD = $(tls_test_LDADD)
1769
1770 check_SCRIPTS += script_test_5.sh
1771 check_DATA += script_test_5.stdout
1772 MOSTLYCLEANFILES += script_test_5
1773 script_test_5: script_test_5.o gcctestdir/ld $(srcdir)/script_test_5.t
1774         $(CXXLINK) -Bgcctestdir/ script_test_5.o -Wl,-T,$(srcdir)/script_test_5.t
1775 script_test_5.stdout: script_test_5
1776         $(TEST_READELF) -SW script_test_5 > script_test_5.stdout
1777
1778 check_SCRIPTS += script_test_6.sh
1779 check_DATA += script_test_6.stdout
1780 MOSTLYCLEANFILES += script_test_6
1781 script_test_6: basic_test.o gcctestdir/ld $(srcdir)/script_test_6.t
1782         $(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_6.t \
1783         -Wl,-Ttext=0x10001000 -Wl,-Tdata=0x10200000 -Wl,-Tbss=0x10400000
1784 script_test_6.stdout: script_test_6
1785         $(TEST_READELF) -SlW script_test_6 > script_test_6.stdout
1786
1787 check_SCRIPTS += script_test_7.sh
1788 check_DATA += script_test_7.stdout
1789 MOSTLYCLEANFILES += script_test_7
1790 script_test_7: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1791         $(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_7.t
1792 script_test_7.stdout: script_test_7
1793         $(TEST_READELF) -SlW script_test_7 > script_test_7.stdout
1794
1795 check_SCRIPTS += script_test_8.sh
1796 check_DATA += script_test_8.stdout
1797 MOSTLYCLEANFILES += script_test_8
1798 script_test_8: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1799         $(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_7.t \
1800         -Wl,-Ttext=0x20001000 -Wl,-Tdata=0x20200000 -Wl,-Tbss=0x20400000
1801 script_test_8.stdout: script_test_8
1802         $(TEST_READELF) -SlW script_test_8 > script_test_8.stdout
1803
1804 check_SCRIPTS += script_test_9.sh
1805 check_DATA += script_test_9.stdout
1806 MOSTLYCLEANFILES += script_test_9
1807 script_test_9.o: script_test_9.cc
1808         $(CXXCOMPILE) -O0 -c -o $@ $<
1809 script_test_9: gcctestdir/ld $(srcdir)/script_test_9.t script_test_9.o
1810         $(CXXLINK) -Bgcctestdir/ script_test_9.o -Wl,-T,$(srcdir)/script_test_9.t
1811 script_test_9.stdout: script_test_9
1812         $(TEST_READELF) -lW script_test_9 > script_test_9.stdout
1813
1814 # Test scripts with a relocatable link.
1815 # The -g option is necessary to trigger a bug where a section
1816 # declared in a script file is assigned a non-zero starting address.
1817 check_PROGRAMS += script_test_11
1818 script_test_11: gcctestdir/ld script_test_11_r.o
1819         $(LINK) -Bgcctestdir/ script_test_11_r.o
1820 script_test_11_r.o: gcctestdir/ld $(srcdir)/script_test_11.t script_test_11a.o script_test_11b.o
1821         gcctestdir/ld -r -o $@ -T $(srcdir)/script_test_11.t script_test_11a.o script_test_11b.o
1822 script_test_11a.o: script_test_11a.c
1823         $(COMPILE) -c -g -o $@ $<
1824 script_test_11b.o: script_test_11b.c
1825         $(COMPILE) -c -g -o $@ $<
1826
1827 # Test difference between "*(a b)" and "*(a) *(b)" in input section spec.
1828 check_PROGRAMS += script_test_12
1829 script_test_12: gcctestdir/ld $(srcdir)/script_test_12.t script_test_12a.o script_test_12b.o
1830         $(LINK) -Bgcctestdir/ -Wl,-T,$(srcdir)/script_test_12.t script_test_12a.o script_test_12b.o
1831
1832 check_PROGRAMS += script_test_12i
1833 script_test_12i: gcctestdir/ld $(srcdir)/script_test_12i.t script_test_12a.o script_test_12b.o
1834         $(LINK) -Bgcctestdir/ -Wl,-T,$(srcdir)/script_test_12i.t script_test_12a.o script_test_12b.o
1835 script_test_12a.o: script_test_12a.c
1836         $(COMPILE) -O0 -c -o $@ $<
1837 script_test_12b.o: script_test_12b.c
1838         $(COMPILE) -O0 -c -o $@ $<
1839
1840 # Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new,
1841 # and --dynamic-list-cpp-typeinfo
1842
1843 check_SCRIPTS += dynamic_list.sh
1844 check_DATA += dynamic_list.stdout
1845 MOSTLYCLEANFILES += dynamic_list dynamic_list.stdout
1846 dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t
1847         $(CXXLINK) -Bgcctestdir/ basic_test.o \
1848           -Wl,--dynamic-list $(srcdir)/dynamic_list.t \
1849           -Wl,--dynamic-list-data \
1850           -Wl,--dynamic-list-cpp-new \
1851           -Wl,--dynamic-list-cpp-typeinfo
1852 dynamic_list.stdout: dynamic_list
1853         $(TEST_READELF) -W --dyn-syms dynamic_list > dynamic_list.stdout
1854
1855 check_PROGRAMS += dynamic_list_2
1856 dynamic_list_2_SOURCES = dynamic_list_2.cc
1857 dynamic_list_2_DEPENDENCIES = gcctestdir/ld dynamic_list_lib1.so dynamic_list_lib2.so
1858 dynamic_list_2_LDFLAGS = -Bgcctestdir/ -L. -Wl,-R,. -Wl,--no-as-needed
1859 dynamic_list_2_LDADD = dynamic_list_lib1.so dynamic_list_lib2.so
1860
1861 dynamic_list_lib1.so: gcctestdir/ld dynamic_list_lib1.o
1862         $(CXXLINK) -Bgcctestdir/ -shared dynamic_list_lib1.o
1863 dynamic_list_lib1.o: dynamic_list_lib1.cc
1864         $(CXXCOMPILE) -c -fpic -o $@ $<
1865
1866 dynamic_list_lib2.so: gcctestdir/ld dynamic_list_lib2.o $(srcdir)/dynamic_list_2.t
1867         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-Bsymbolic-functions -Wl,--dynamic-list,$(srcdir)/dynamic_list_2.t dynamic_list_lib2.o
1868 dynamic_list_lib2.o: dynamic_list_lib2.cc
1869         $(CXXCOMPILE) -c -fpic -o $@ $<
1870
1871 check_PROGRAMS += thin_archive_test_1
1872 MOSTLYCLEANFILES += libthin1.a libthin3.a libthinall.a \
1873         alt/thin_archive_test_2.o alt/thin_archive_test_4.o \
1874         alt/libthin2.a alt/libthin4.a
1875 thin_archive_test_1_SOURCES = thin_archive_main.cc
1876 thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a
1877 thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt
1878 thin_archive_test_1_LDADD = libthin1.a -lthin2
1879
1880 check_PROGRAMS += thin_archive_test_2
1881 thin_archive_test_2_SOURCES = thin_archive_main.cc
1882 thin_archive_test_2_DEPENDENCIES = gcctestdir/ld libthinall.a
1883 thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L.
1884 thin_archive_test_2_LDADD = -lthinall
1885
1886 libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o
1887         rm -f $@
1888         $(TEST_AR) crT $@ $^
1889 alt/libthin2.a: thin_archive_test_3.o alt/thin_archive_test_4.o
1890         rm -f $@
1891         $(TEST_AR) crT $@ $^
1892 libthin3.a: thin_archive_test_1.o alt/thin_archive_test_4.o
1893         rm -f $@
1894         $(TEST_AR) crT $@ $^
1895 alt/libthin4.a: alt/thin_archive_test_2.o thin_archive_test_3.o
1896         rm -f $@
1897         $(TEST_AR) crT $@ $^
1898 libthinall.a: libthin3.a alt/libthin4.a
1899         rm -f $@
1900         $(TEST_AR) crT $@ $^
1901 alt/thin_archive_test_2.o: thin_archive_test_2.cc
1902         test -d alt || mkdir -p alt
1903         $(CXXCOMPILE) -c -o $@ $<
1904 alt/thin_archive_test_4.o: thin_archive_test_4.cc
1905         test -d alt || mkdir -p alt
1906         $(CXXCOMPILE) -c -o $@ $<
1907
1908 if PLUGINS
1909
1910 check_PROGRAMS += plugin_test_1
1911 check_SCRIPTS += plugin_test_1.sh
1912 check_DATA += plugin_test_1.err
1913 MOSTLYCLEANFILES += plugin_test_1.err
1914 plugin_test_1: two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms gcctestdir/ld plugin_test.so
1915         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms 2>plugin_test_1.err
1916 plugin_test_1.err: plugin_test_1
1917         @touch plugin_test_1.err
1918
1919 check_PROGRAMS += plugin_test_2
1920 check_SCRIPTS += plugin_test_2.sh
1921 check_DATA += plugin_test_2.err
1922 MOSTLYCLEANFILES += plugin_test_2.err
1923 plugin_test_2: two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_shared_2.so gcctestdir/ld plugin_test.so
1924         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,-R,.,--plugin,"./plugin_test.so" two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_shared_2.so 2>plugin_test_2.err
1925 plugin_test_2.err: plugin_test_2
1926         @touch plugin_test_2.err
1927
1928 check_PROGRAMS += plugin_test_3
1929 check_SCRIPTS += plugin_test_3.sh
1930 check_DATA += plugin_test_3.err
1931 MOSTLYCLEANFILES += plugin_test_3.err
1932 plugin_test_3: two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms gcctestdir/ld plugin_test.so
1933         $(CXXLINK) -Bgcctestdir/ -Wl,--export-dynamic -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms 2>plugin_test_3.err
1934 plugin_test_3.err: plugin_test_3
1935         @touch plugin_test_3.err
1936
1937 check_PROGRAMS += plugin_test_4
1938 check_SCRIPTS += plugin_test_4.sh
1939 check_DATA += plugin_test_4.err
1940 MOSTLYCLEANFILES += plugin_test_4.a plugin_test_4.err
1941 plugin_test_4: two_file_test_main.o plugin_test_4.a gcctestdir/ld plugin_test.so
1942         $(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
1943 plugin_test_4.err: plugin_test_4
1944         @touch plugin_test_4.err
1945
1946 plugin_test_4.a: two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms
1947         $(TEST_AR) cr $@ $^
1948
1949 check_PROGRAMS += plugin_test_5
1950 plugin_test_5: two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms unused.o.syms gcctestdir/ld plugin_test.so
1951         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv",--gc-sections two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms unused.o.syms
1952
1953 check_PROGRAMS += plugin_test_6
1954 check_SCRIPTS += plugin_test_6.sh
1955 check_DATA += plugin_test_6.err
1956 MOSTLYCLEANFILES += plugin_test_6.err
1957 plugin_test_6: plugin_common_test_1.o.syms plugin_common_test_2.o.syms gcctestdir/ld plugin_test.so
1958         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.o.syms plugin_common_test_2.o.syms 2>plugin_test_6.err
1959 plugin_test_6.err: plugin_test_6
1960         @touch plugin_test_6.err
1961
1962 check_PROGRAMS += plugin_test_7
1963 check_SCRIPTS += plugin_test_7.sh
1964 check_DATA += plugin_test_7.err plugin_test_7.o.syms
1965 MOSTLYCLEANFILES += plugin_test_7.err
1966 plugin_test_7: plugin_test_7_1.o plugin_test_7_1.o.syms plugin_test_7_2.o gcctestdir/ld plugin_test.so
1967         $(LINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--gc-sections,--print-gc-sections plugin_test_7_1.o.syms plugin_test_7_2.o 2>plugin_test_7.err
1968 plugin_test_7.o.syms: plugin_test_7
1969         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1970 plugin_test_7_1.o: plugin_test_7_1.c
1971         $(COMPILE) -DLTO -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1972 plugin_test_7_1_orig.o: plugin_test_7_1.c
1973         $(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1974 plugin_test_7_1.o.syms: plugin_test_7_1_orig.o
1975         $(TEST_READELF) -sW $< >$@ 2>/dev/null
1976 plugin_test_7_2.o: plugin_test_7_2.c
1977         $(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1978 plugin_test_7.err: plugin_test_7
1979
1980 # Test plugins with -r.
1981 check_PROGRAMS += plugin_test_8
1982 plugin_test_8.o: two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o ../ld-new plugin_test.so
1983         ../ld-new -r -o $@ --no-demangle --plugin "./plugin_test.so" two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o
1984 plugin_test_8: plugin_test_8.o gcctestdir/ld
1985         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle plugin_test_8.o
1986
1987 # Test that symbols known in the IR file but not in the replacement file
1988 # produce an unresolved symbol error.
1989 check_DATA += plugin_test_9.err
1990 MOSTLYCLEANFILES += plugin_test_9.err
1991 plugin_test_9.err: two_file_test_main.o two_file_test_1c.o.syms two_file_test_2.o.syms gcctestdir/ld plugin_test.so
1992         @echo $(CXXLINK) -Bgcctestdir/ -o plugin_test_9 -Wl,--no-demangle,--plugin,"./plugin_test.so" two_file_test_main.o two_file_test_1c.o.syms two_file_test_2.o.syms "2>$@"
1993         @if $(CXXLINK) -Bgcctestdir/ -o plugin_test_9 -Wl,--no-demangle,--plugin,"./plugin_test.so" two_file_test_main.o two_file_test_1c.o.syms two_file_test_2.o.syms 2>$@; then \
1994           echo 1>&2 "Link of plugin_test_9 should have failed"; \
1995           rm -f $@; \
1996           exit 1; \
1997         fi
1998 # Make a .syms file that claims to define the symbol _Z4t16av.
1999 two_file_test_1c.o.syms: two_file_test_1.o.syms two_file_test_1c.o
2000         cp two_file_test_1.o.syms $@.tmp
2001         grep "_Z4t16av" two_file_test_1b.o.syms >> $@.tmp
2002         mv -f $@.tmp $@
2003 # Make a copy of two_file_test_1.o, which does not define the symbol _Z4t16av.
2004 MOSTLYCLEANFILES += two_file_test_1c.o
2005 two_file_test_1c.o: two_file_test_1.o
2006         cp two_file_test_1.o $@
2007
2008 check_PROGRAMS += plugin_test_10
2009 check_SCRIPTS += plugin_test_10.sh
2010 check_DATA += plugin_test_10.sections
2011 MOSTLYCLEANFILES += plugin_test_10.sections
2012 plugin_test_10: plugin_common_test_1.o.syms plugin_common_test_2.o  gcctestdir/ld plugin_test.so
2013         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.o.syms plugin_common_test_2.o
2014 plugin_test_10.sections: plugin_test_10
2015         $(TEST_READELF) -SW $< >$@ 2>/dev/null
2016
2017 check_PROGRAMS += plugin_test_11
2018 check_SCRIPTS += plugin_test_11.sh
2019 check_DATA += plugin_test_11.err
2020 MOSTLYCLEANFILES += plugin_test_11.err plugin_test_thin.a
2021 PLUGIN_TEST_11_SYMS = two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms
2022 plugin_test_11: two_file_test_main.o plugin_test_thin.a gcctestdir/ld plugin_test.so $(PLUGIN_TEST_11_SYMS)
2023         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o plugin_test_thin.a 2>plugin_test_11.err
2024 plugin_test_11.err: plugin_test_11
2025         @touch plugin_test_11.err
2026 plugin_test_thin.a: two_file_test_1.o two_file_test_1b.o two_file_test_2.o
2027         rm -f $@
2028         $(TEST_AR) crT $@ $^
2029
2030
2031 check_PROGRAMS += plugin_test_start_lib
2032 check_SCRIPTS += plugin_test_start_lib.sh
2033 check_DATA += plugin_test_start_lib.err
2034 MOSTLYCLEANFILES += plugin_test_start_lib.err
2035 plugin_test_start_lib: unused.o plugin_start_lib_test.o plugin_start_lib_test_2.syms gcctestdir/ld plugin_test.so
2036         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_start_lib_test.o \
2037                 -Wl,--start-lib plugin_start_lib_test_2.syms -Wl,--end-lib 2>plugin_test_start_lib.err
2038 plugin_test_start_lib.err: plugin_test_start_lib
2039         @touch plugin_test_start_lib.err
2040
2041
2042 plugin_start_lib_test_2.syms: plugin_start_lib_test_2.o
2043         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2044
2045
2046 plugin_test.so: plugin_test.o
2047         $(LINK) -Bgcctestdir/ -shared plugin_test.o
2048 plugin_test.o: plugin_test.c
2049         $(COMPILE) -O0 -c -fpic -o $@ $<
2050
2051 two_file_test_main.o.syms: two_file_test_main.o
2052         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2053 two_file_test_1.o.syms: two_file_test_1.o
2054         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2055 two_file_test_1b.o.syms: two_file_test_1b.o
2056         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2057 two_file_test_2.o.syms: two_file_test_2.o
2058         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2059 plugin_common_test_1.o.syms: plugin_common_test_1.o
2060         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2061 plugin_common_test_2.o.syms: plugin_common_test_2.o
2062         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2063
2064 empty.o.syms:
2065         @echo "" >$@
2066         @echo "Symbol table" >>$@
2067
2068 if TLS
2069
2070 check_PROGRAMS += plugin_test_tls
2071 check_SCRIPTS += plugin_test_tls.sh
2072 check_DATA += plugin_test_tls.err
2073 MOSTLYCLEANFILES += plugin_test_tls.err
2074 plugin_test_tls: two_file_test_tls.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2_tls.o.syms gcctestdir/ld plugin_test.so
2075         $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_tls.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2_tls.o.syms 2>plugin_test_tls.err
2076 plugin_test_tls.err: plugin_test_tls
2077         @touch plugin_test_tls.err
2078
2079 two_file_test_2_tls.o.syms: two_file_test_2_tls.o
2080         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2081
2082 endif TLS
2083
2084 MOSTLYCLEANFILES += unused.c
2085 unused.o.syms: unused.o
2086         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2087         @echo "     1: 00000000     4 FUNC    GLOBAL DEFAULT    1 UNUSED" >>$@
2088 unused.o: unused.c
2089         $(COMPILE) -c -o $@ $<
2090 unused.c:
2091         @cp /dev/null $@
2092
2093 check_SCRIPTS += plugin_final_layout.sh
2094 check_DATA += plugin_final_layout.stdout plugin_final_layout_readelf.stdout
2095 MOSTLYCLEANFILES += plugin_final_layout
2096 plugin_final_layout.o: plugin_final_layout.cc
2097         $(CXXCOMPILE) -O0 -c -ffunction-sections  -fdata-sections -g -o $@ $<
2098 plugin_final_layout: plugin_final_layout.o plugin_section_order.so gcctestdir/ld
2099         $(CXXLINK) -Bgcctestdir/ -Wl,--plugin,"./plugin_section_order.so" plugin_final_layout.o
2100 plugin_final_layout.stdout: plugin_final_layout
2101         $(TEST_NM) -n --synthetic plugin_final_layout > plugin_final_layout.stdout
2102 plugin_final_layout_readelf.stdout: plugin_final_layout
2103         $(TEST_READELF) -Wl plugin_final_layout > plugin_final_layout_readelf.stdout
2104
2105 plugin_section_order.so: plugin_section_order.o
2106         $(LINK) -Bgcctestdir/ -shared plugin_section_order.o
2107 plugin_section_order.o: plugin_section_order.c
2108         $(COMPILE) -O0 -c -fpic -o $@ $<
2109
2110 check_SCRIPTS += plugin_layout_with_alignment.sh
2111 check_DATA += plugin_layout_with_alignment.stdout
2112 MOSTLYCLEANFILES += plugin_layout_with_alignment
2113 plugin_layout_with_alignment.o: plugin_layout_with_alignment.cc
2114         $(CXXCOMPILE) -O0 -c -ffunction-sections  -fdata-sections -g -o $@ $<
2115 plugin_layout_with_alignment: plugin_layout_with_alignment.o plugin_section_alignment.so gcctestdir/ld
2116         $(CXXLINK) -Bgcctestdir/ -Wl,--plugin,"./plugin_section_alignment.so" plugin_layout_with_alignment.o
2117 plugin_layout_with_alignment.stdout: plugin_layout_with_alignment
2118         $(TEST_NM) -n --synthetic plugin_layout_with_alignment > plugin_layout_with_alignment.stdout
2119
2120 plugin_section_alignment.so: plugin_section_alignment.o
2121         $(CXXLINK) -Bgcctestdir/ -shared plugin_section_alignment.o
2122 plugin_section_alignment.o: plugin_section_alignment.cc
2123         $(CXXCOMPILE) -O0 -c -fpic -o $@ $<
2124
2125 endif PLUGINS
2126
2127 check_PROGRAMS += exclude_libs_test
2128 check_SCRIPTS += exclude_libs_test.sh
2129 check_DATA += exclude_libs_test.syms
2130 MOSTLYCLEANFILES += exclude_libs_test.syms libexclude_libs_test_1.a \
2131         libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
2132 exclude_libs_test_SOURCES = exclude_libs_test.c
2133 exclude_libs_test_DEPENDENCIES = gcctestdir/ld libexclude_libs_test_1.a \
2134         libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
2135 exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. -Lalt \
2136         -Wl,--exclude-libs,dummy:libexclude_libs_test_1 \
2137         -Wl,--exclude-libs,libexclude_libs_test_3
2138 exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 \
2139         alt/libexclude_libs_test_3.a
2140 exclude_libs_test.syms: exclude_libs_test
2141         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2142 libexclude_libs_test_1.a: exclude_libs_test_1.o
2143         $(TEST_AR) rc $@ $^
2144 libexclude_libs_test_2.a: exclude_libs_test_2.o
2145         $(TEST_AR) rc $@ $^
2146 alt/libexclude_libs_test_3.a: exclude_libs_test_3.o
2147         test -d alt || mkdir -p alt
2148         $(TEST_AR) rc $@ $^
2149
2150 check_PROGRAMS += local_labels_test
2151 local_labels_test.o: ver_test_6.c
2152         $(COMPILE) -g -c -Wa,-L -o $@ $<
2153 local_labels_test: local_labels_test.o
2154         $(LINK) -Bgcctestdir/ local_labels_test.o
2155
2156 check_PROGRAMS += discard_locals_test
2157 check_SCRIPTS += discard_locals_test.sh
2158 check_DATA += discard_locals_test.syms \
2159         discard_locals_relocatable_test1.syms \
2160         discard_locals_relocatable_test2.syms
2161 MOSTLYCLEANFILES += discard_locals_test.syms \
2162         discard_locals_relocatable_test1.syms \
2163         discard_locals_relocatable_test2.syms \
2164         discard_locals_relocatable_test1.out \
2165         discard_locals_relocatable_test2.out
2166 discard_locals_test_SOURCES = discard_locals_test.c
2167 discard_locals_test_LDFLAGS = -Bgcctestdir/ -Wl,--discard-locals
2168 discard_locals_test.syms: discard_locals_test
2169         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2170 # '-Wa,-L' is required to preserve the local label used for testing.
2171 discard_locals_test.o: discard_locals_test.c
2172         $(COMPILE) -c -Wa,-L -o $@ $<
2173
2174 discard_locals_relocatable_test1.syms: discard_locals_relocatable_test1.out
2175         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2176 discard_locals_relocatable_test.o: discard_locals_relocatable_test.c
2177         $(COMPILE) -c -Wa,-L -fPIC -o $@ $<
2178 discard_locals_relocatable_test1.out: discard_locals_relocatable_test.o ../ld-new
2179         ../ld-new --discard-locals -relocatable -o $@ $<
2180
2181 discard_locals_relocatable_test2.syms: discard_locals_relocatable_test2.out
2182         $(TEST_READELF) -sW $< >$@ 2>/dev/null
2183 discard_locals_relocatable_test2.out: discard_locals_relocatable_test.o ../ld-new
2184         ../ld-new --discard-all -relocatable -o $@ $<
2185
2186 if MCMODEL_MEDIUM
2187 check_PROGRAMS += large
2188 large_SOURCES = large.c
2189 large_CFLAGS = -mcmodel=medium
2190 large_DEPENDENCIES = gcctestdir/ld
2191 large_LDFLAGS = -Bgcctestdir/
2192 large_LDADD =
2193 endif MCMODEL_MEDIUM
2194
2195 # Test that hidden and internal symbols in the main program cannot be
2196 # referenced by a shared library.
2197 check_SCRIPTS += hidden_test.sh
2198 check_DATA += hidden_test.err
2199 MOSTLYCLEANFILES += hidden_test hidden_test.err hidden_test.syms
2200 libhidden.so: hidden_test_1.c gcctestdir/ld
2201         $(COMPILE) -Bgcctestdir/ -g -shared -fPIC -w -o $@ $(srcdir)/hidden_test_1.c
2202 hidden_test: hidden_test_main.o libhidden.so gcctestdir/ld
2203         $(LINK) -Bgcctestdir/ -Wl,-R,. hidden_test_main.o libhidden.so 2>hidden_test.err
2204 hidden_test.syms: hidden_test
2205         $(TEST_NM) -D hidden_test > $@
2206 hidden_test.err: hidden_test
2207         @touch hidden_test.err
2208
2209 # Test -retain-symbols-file.
2210 check_SCRIPTS += retain_symbols_file_test.sh
2211 check_DATA += retain_symbols_file_test.stdout
2212 MOSTLYCLEANFILES += retain_symbols_file_test retain_symbols_file_test.in \
2213                     retain_symbols_file_test.stdout
2214 retain_symbols_file_test.so: basic_pic_test.o gcctestdir/ld
2215         echo 'main' > retain_symbols_file_test.in
2216         echo 't1' >> retain_symbols_file_test.in
2217         echo '_ZN4t16bC1Ev' >> retain_symbols_file_test.in
2218         echo '_ZNK4t20a3getEv' >> retain_symbols_file_test.in
2219         echo '_Z3t18v' >> retain_symbols_file_test.in
2220         echo '__tcf_0' >> retain_symbols_file_test.in
2221         $(CXXLINK) -Bgcctestdir/ -shared -Wl,-retain-symbols-file,retain_symbols_file_test.in basic_pic_test.o
2222 retain_symbols_file_test.stdout: retain_symbols_file_test.so
2223         $(TEST_NM) -C retain_symbols_file_test.so > $@
2224
2225
2226 # Test that if the output file already exists and is empty,
2227 # it will get execute permission.
2228 check_PROGRAMS += permission_test
2229 permission_test: basic_test.o gcctestdir/ld
2230         umask 022; \
2231         rm -f $@; \
2232         touch $@; \
2233         chmod 600 $@; \
2234         $(CXXLINK) -Bgcctestdir/ basic_test.o
2235
2236 # Check -l:foo.a
2237 check_PROGRAMS += searched_file_test
2238 MOSTLYCLEANFILES += searched_file_test searched_file_test_lib.o \
2239                     alt/searched_file_test_lib.a
2240 searched_file_test_SOURCES = searched_file_test.cc
2241 searched_file_test_DEPENDENCIES = alt/searched_file_test_lib.a
2242 searched_file_test_LDFLAGS = -Bgcctestdir/ -Lalt
2243 searched_file_test_LDADD = -l:searched_file_test_lib.a
2244 searched_file_test_lib.o: searched_file_test_lib.cc
2245         $(CXXCOMPILE) -c -o $@ $<
2246 alt/searched_file_test_lib.a: searched_file_test_lib.o
2247         test -d alt || mkdir -p alt
2248         $(TEST_AR) rc $@ $^
2249
2250 # Test that no .gnu.version sections are created when
2251 # symbol versioning is not used.
2252 check_SCRIPTS += no_version_test.sh
2253 check_DATA += no_version_test.stdout
2254 MOSTLYCLEANFILES += libno_version_test.so no_version_test.stdout
2255 # We invoke the linker directly since gcc may include additional objects that
2256 # uses symbol versioning.
2257 libno_version_test.so: no_version_test.o gcctestdir/ld
2258         gcctestdir/ld -shared -o $@ no_version_test.o
2259 no_version_test.o: no_version_test.c
2260         $(COMPILE) -o $@ -c -fPIC $<
2261 no_version_test.stdout: libno_version_test.so
2262         $(TEST_OBJDUMP) -h $< > $@
2263
2264 # Test STT_GNU_IFUNC symbols.
2265 if IFUNC
2266
2267 ifuncmod1.o: ifuncmod1.c
2268         $(COMPILE) -c -fPIC -o $@ $<
2269 ifuncmod1.so: ifuncmod1.o gcctestdir/ld
2270         $(LINK) -Bgcctestdir/ -shared ifuncmod1.o
2271
2272 ifuncdep1.o: ifuncmod1.c
2273         $(COMPILE) -c -o $@ $<
2274
2275 ifuncmain1pic.o: ifuncmain1.c
2276         $(COMPILE) -c -fPIC -o $@ $<
2277 ifuncmain1pie.o: ifuncmain1.c
2278         $(COMPILE) -c -fPIE -o $@ $<
2279
2280 if HAVE_STATIC
2281 if IFUNC_STATIC
2282 check_PROGRAMS += ifuncmain1static
2283 ifuncmain1static_SOURCES = ifuncmain1.c
2284 ifuncmain1static_DEPENDENCIES = gcctestdir/ld ifuncdep1.o
2285 ifuncmain1static_LDFLAGS = -Bgcctestdir/ -static
2286 ifuncmain1static_LDADD = ifuncdep1.o
2287
2288 check_PROGRAMS += ifuncmain1picstatic
2289 ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
2290         $(LINK) -Bgcctestdir/ -static ifuncmain1pic.o ifuncmod1.o
2291 endif
2292 endif
2293
2294 check_PROGRAMS += ifuncmain1
2295 ifuncmain1_SOURCES = ifuncmain1.c
2296 ifuncmain1_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
2297 ifuncmain1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
2298 ifuncmain1_LDADD = ifuncmod1.so
2299
2300 check_PROGRAMS += ifuncmain1pic
2301 ifuncmain1pic: ifuncmain1pic.o ifuncmod1.so gcctestdir/ld
2302         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
2303
2304 check_PROGRAMS += ifuncmain1vis
2305 ifuncmain1vis_SOURCES = ifuncmain1vis.c
2306 ifuncmain1vis_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
2307 ifuncmain1vis_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
2308 ifuncmain1vis_LDADD = ifuncmod1.so
2309
2310 check_PROGRAMS += ifuncmain1vispic
2311 ifuncmain1vispic.o: ifuncmain1vis.c
2312         $(COMPILE) -c -fPIC -o $@ $<
2313 ifuncmain1vispic: ifuncmain1vispic.o ifuncmod1.so gcctestdir/ld
2314         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
2315
2316 check_PROGRAMS += ifuncmain1staticpic
2317 ifuncmain1staticpic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
2318         $(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.o
2319
2320 check_PROGRAMS += ifuncmain1pie
2321 ifuncmain1pie: ifuncmain1pie.o ifuncmod1.so gcctestdir/ld
2322         $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.so -Wl,-R,.
2323
2324 check_PROGRAMS += ifuncmain1vispie
2325 ifuncmain1vispie.o: ifuncmain1vis.c
2326         $(COMPILE) -c -fPIE -o $@ $<
2327 ifuncmain1vispie: ifuncmain1vispie.o ifuncmod1.so gcctestdir/ld
2328         $(LINK) -Bgcctestdir/ -pie ifuncmain1vispie.o ifuncmod1.so -Wl,-R,.
2329
2330 check_PROGRAMS += ifuncmain1staticpie
2331 ifuncmain1staticpie: ifuncmain1pie.o ifuncmod1.o gcctestdir/ld
2332         $(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.o
2333
2334 ifuncmain2pic.o: ifuncmain2.c
2335         $(COMPILE) -c -fPIC -o $@ $<
2336
2337 ifuncdep2pic.o: ifuncdep2.c
2338         $(COMPILE) -c -fPIC -o $@ $<
2339
2340 if HAVE_STATIC
2341 if IFUNC_STATIC
2342 check_PROGRAMS += ifuncmain2static
2343 ifuncmain2static_SOURCES = ifuncmain2.c ifuncdep2.c
2344 ifuncmain2static_DEPENDENCIES = gcctestdir/ld
2345 ifuncmain2static_LDFLAGS = -Bgcctestdir/ -static
2346 ifuncmain2static_LDADD =
2347
2348 check_PROGRAMS += ifuncmain2picstatic
2349 ifuncmain2picstatic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
2350         $(LINK) -Bgcctestdir/ -static ifuncmain2pic.o ifuncdep2pic.o
2351 endif
2352 endif
2353
2354 check_PROGRAMS += ifuncmain2
2355 ifuncmain2_SOURCES = ifuncmain2.c ifuncdep2.c
2356 ifuncmain2_DEPENDENCIES = gcctestdir/ld
2357 ifuncmain2_LDFLAGS = -Bgcctestdir/
2358 ifuncmain2_LDADD =
2359
2360 check_PROGRAMS += ifuncmain2pic
2361 ifuncmain2pic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
2362         $(LINK) -Bgcctestdir/ ifuncmain2pic.o ifuncdep2pic.o
2363
2364 ifuncmod3.o: ifuncmod3.c
2365         $(COMPILE) -c -fPIC -o $@ $<
2366 ifuncmod3.so: ifuncmod3.o gcctestdir/ld
2367         $(LINK) -Bgcctestdir/ -shared ifuncmod3.o
2368
2369 check_PROGRAMS += ifuncmain3
2370 ifuncmain3_SOURCES = ifuncmain3.c
2371 ifuncmain3_DEPENDENCIES = gcctestdir/ld ifuncmod3.so
2372 ifuncmain3_LDFLAGS = -Bgcctestdir/ -Wl,--export-dynamic -Wl,-R,.
2373 ifuncmain3_LDADD = -ldl
2374
2375 ifuncmain4pic.o: ifuncmain4.c
2376         $(COMPILE) -c -fPIC -o $@ $<
2377
2378 if HAVE_STATIC
2379 if IFUNC_STATIC
2380 check_PROGRAMS += ifuncmain4static
2381 ifuncmain4static_SOURCES = ifuncmain4.c
2382 ifuncmain4static_DEPENDENCIES = gcctestdir/ld
2383 ifuncmain4static_LDFLAGS = -Bgcctestdir/ -static
2384 ifuncmain4static_LDADD =
2385
2386 check_PROGRAMS += ifuncmain4picstatic
2387 ifuncmain4picstatic: ifuncmain4pic.o gcctestdir/ld
2388         $(LINK) -Bgcctestdir/ -static ifuncmain4pic.o
2389 endif
2390 endif
2391
2392 check_PROGRAMS += ifuncmain4
2393 ifuncmain4_SOURCES = ifuncmain4.c
2394 ifuncmain4_DEPENDENCIES = gcctestdir/ld
2395 ifuncmain4_LDFLAGS = -Bgcctestdir/
2396 ifuncmain4_LDADD =
2397
2398 ifuncmain5pic.o: ifuncmain5.c
2399         $(COMPILE) -c -fPIC -o $@ $<
2400
2401 ifuncmain5pie.o: ifuncmain5.c
2402         $(COMPILE) -c -fPIE -o $@ $<
2403
2404 ifuncmod5.o: ifuncmod5.c
2405         $(COMPILE) -c -fPIC -o $@ $<
2406 ifuncmod5.so: ifuncmod5.o gcctestdir/ld
2407         $(LINK) -Bgcctestdir/ -shared ifuncmod5.o
2408
2409 ifuncdep5.o: ifuncmod5.c
2410         $(COMPILE) -c -o $@ $<
2411
2412 if HAVE_STATIC
2413 if IFUNC_STATIC
2414 check_PROGRAMS += ifuncmain5static
2415 ifuncmain5static_SOURCES = ifuncmain5.c
2416 ifuncmain5static_DEPENDENCIES = gcctestdir/ld ifuncdep5.o
2417 ifuncmain5static_LDFLAGS = -Bgcctestdir/ -static
2418 ifuncmain5static_LDADD = ifuncdep5.o
2419
2420 check_PROGRAMS += ifuncmain5picstatic
2421 ifuncmain5picstatic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
2422         $(LINK) -Bgcctestdir/ -static ifuncmain5pic.o ifuncmod5.o
2423 endif
2424 endif
2425
2426 check_PROGRAMS += ifuncmain5
2427 ifuncmain5_SOURCES = ifuncmain5.c
2428 ifuncmain5_DEPENDENCIES = gcctestdir/ld ifuncmod5.so
2429 ifuncmain5_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
2430 ifuncmain5_LDADD = ifuncmod5.so
2431
2432 check_PROGRAMS += ifuncmain5pic
2433 ifuncmain5pic: ifuncmain5pic.o ifuncmod5.so gcctestdir/ld
2434         $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.so -Wl,-R,.
2435
2436 check_PROGRAMS += ifuncmain5staticpic
2437 ifuncmain5staticpic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
2438         $(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.o
2439
2440 check_PROGRAMS += ifuncmain5pie
2441 ifuncmain5pie: ifuncmain5pie.o ifuncmod5.so gcctestdir/ld
2442         $(LINK) -Bgcctestdir/ -pie ifuncmain5pie.o ifuncmod5.so -Wl,-R,.
2443
2444 ifuncmain6pie.o: ifuncmain6pie.c
2445         $(COMPILE) -c -fPIE -o $@ $<
2446
2447 ifuncmod6.o: ifuncmod6.c
2448         $(COMPILE) -c -fPIC -o $@ $<
2449 ifuncmod6.so: ifuncmod6.o gcctestdir/ld
2450         $(LINK) -Bgcctestdir/ -shared ifuncmod6.o
2451
2452 check_PROGRAMS += ifuncmain6pie
2453 ifuncmain6pie: ifuncmain6pie.o ifuncmod6.so gcctestdir/ld
2454         $(LINK) -Bgcctestdir/ -pie ifuncmain6pie.o ifuncmod6.so -Wl,-R,.
2455
2456 ifuncmain7pic.o: ifuncmain7.c
2457         $(COMPILE) -c -fPIC -o $@ $<
2458
2459 ifuncmain7pie.o: ifuncmain7.c
2460         $(COMPILE) -c -fPIE -o $@ $<
2461
2462 if HAVE_STATIC
2463 if IFUNC_STATIC
2464 check_PROGRAMS += ifuncmain7static
2465 ifuncmain7static_SOURCES = ifuncmain7.c
2466 ifuncmain7static_DEPENDENCIES = gcctestdir/ld
2467 ifuncmain7static_LDFLAGS = -Bgcctestdir/ -static
2468 ifuncmain7static_LDADD =
2469
2470 check_PROGRAMS += ifuncmain7picstatic
2471 ifuncmain7picstatic: ifuncmain7pic.o gcctestdir/ld
2472         $(LINK) -Bgcctestdir/ -static ifuncmain7pic.o
2473 endif
2474 endif
2475
2476 check_PROGRAMS += ifuncmain7
2477 ifuncmain7_SOURCES = ifuncmain7.c
2478 ifuncmain7_DEPENDENCIES = gcctestdir/ld
2479 ifuncmain7_LDFLAGS = -Bgcctestdir/
2480 ifuncmain7_LDADD =
2481
2482 check_PROGRAMS += ifuncmain7pic
2483 ifuncmain7pic: ifuncmain7pic.o gcctestdir/ld
2484         $(LINK) -Bgcctestdir/ ifuncmain7pic.o
2485
2486 check_PROGRAMS += ifuncmain7pie
2487 ifuncmain7pie: ifuncmain7pie.o gcctestdir/ld
2488         $(LINK) -Bgcctestdir/ -pie ifuncmain7pie.o
2489
2490 check_PROGRAMS += ifuncvar
2491 ifuncvar1_pic.o: ifuncvar1.c
2492         $(COMPILE) -c -fPIC -o $@ $<
2493 ifuncvar2_pic.o: ifuncvar2.c
2494         $(COMPILE) -c -fPIC -o $@ $<
2495 ifuncvar.so: ifuncvar1_pic.o ifuncvar2_pic.o gcctestdir/ld
2496         $(LINK) -Bgcctestdir/ -shared ifuncvar1_pic.o ifuncvar2_pic.o
2497 ifuncvar_SOURCES = ifuncvar3.c
2498 ifuncvar_DEPENDENCIES = gcctestdir/ld ifuncvar.so
2499 ifuncvar_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
2500 ifuncvar_LDADD = ifuncvar.so
2501
2502 endif IFUNC
2503
2504 # Test that strong reference to a weak symbol in a DSO remains strong.
2505 check_SCRIPTS += strong_ref_weak_def.sh
2506 check_DATA += strong_ref_weak_def.stdout
2507 MOSTLYCLEANFILES += strong_ref_weak_def_1.so strong_ref_weak_def_2.so \
2508         strong_ref_weak_def.stdout
2509 strong_ref_weak_def_2.o: strong_ref_weak_def_2.c
2510         $(COMPILE) -o $@ -c -fPIC $<
2511 strong_ref_weak_def_2.so: strong_ref_weak_def_2.o gcctestdir/ld
2512         gcctestdir/ld -shared -o $@ strong_ref_weak_def_2.o
2513 strong_ref_weak_def_1.o: strong_ref_weak_def_1.c
2514         $(COMPILE) -o $@ -c -fPIC $<
2515 strong_ref_weak_def_1.so: strong_ref_weak_def_1.o strong_ref_weak_def_2.so \
2516         gcctestdir/ld
2517         gcctestdir/ld -shared -o $@ strong_ref_weak_def_1.o \
2518                 strong_ref_weak_def_2.so
2519 strong_ref_weak_def.stdout: strong_ref_weak_def_1.so
2520         $(TEST_READELF) -sWD $< > $@
2521
2522 # Test that a strong weak reference remains strong if there is another
2523 # weak reference in a DSO.
2524 check_SCRIPTS += dyn_weak_ref.sh
2525 check_DATA += dyn_weak_ref.stdout
2526 MOSTLYCLEANFILES += dyn_weak_ref_1.so dyn_weak_ref_2.so \
2527         dyn_weak_ref.stdout
2528 dyn_weak_ref_2.o: dyn_weak_ref_2.c
2529         $(COMPILE) -o $@ -c -fPIC $<
2530 dyn_weak_ref_2.so: dyn_weak_ref_2.o gcctestdir/ld
2531         gcctestdir/ld -shared -o $@ dyn_weak_ref_2.o
2532 dyn_weak_ref_1.o: dyn_weak_ref_1.c
2533         $(COMPILE) -o $@ -c -fPIC $<
2534 # We intentionally put dyn_weak_ref_2.so in front of dyn_weak_ref_1.o
2535 # so that the weak ref there goes to gold's symbol table first.
2536 dyn_weak_ref_1.so: dyn_weak_ref_1.o dyn_weak_ref_2.so gcctestdir/ld
2537         gcctestdir/ld -shared -o $@ dyn_weak_ref_2.so dyn_weak_ref_1.o
2538 dyn_weak_ref.stdout: dyn_weak_ref_1.so
2539         $(TEST_READELF) -sWD $< > $@
2540
2541
2542 # Test that --start-lib and --end-lib function correctly.
2543 check_PROGRAMS += start_lib_test
2544 MOSTLYCLEANFILES += libstart_lib_test.a
2545 start_lib_test: start_lib_test_main.o libstart_lib_test.a start_lib_test_2.o start_lib_test_3.o \
2546         gcctestdir/ld
2547         $(LINK) -Bgcctestdir/ -o $@ start_lib_test_main.o -L. -lstart_lib_test \
2548                 -Wl,--start-lib start_lib_test_2.o start_lib_test_3.o -Wl,--end-lib
2549 libstart_lib_test.a: start_lib_test_1.o
2550         $(TEST_AR) rc $@ $^
2551
2552 # Test that MEMORY region support works.
2553 check_SCRIPTS += memory_test.sh
2554 check_DATA += memory_test.stdout
2555 MOSTLYCLEANFILES += memory_test.stdout memory_test memory_test.o
2556 memory_test.o: memory_test.s
2557         $(COMPILE) -o $@ -c $<
2558 memory_test: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t
2559         $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -z max-page-size=0x1000 -z common-page-size=0x1000 -Wl,-T,$(srcdir)/memory_test.t -o $@ memory_test.o
2560 memory_test.stdout: memory_test
2561         $(TEST_READELF) -lWS  $< > $@
2562
2563 # Test INCLUDE directives in linker scripts.
2564 # The binary isn't runnable, so we just check that we can build it without errors.
2565 check_DATA += memory_test_2
2566 MOSTLYCLEANFILES += memory_test_inc_1.t memory_test_inc_2.t memory_test_inc_3.t memory_test_2
2567 memory_test_inc_1.t: $(srcdir)/memory_test_inc_1.t.src
2568         cp $< $@
2569 memory_test_inc_2.t: $(srcdir)/memory_test_inc_2.t.src
2570         cp $< $@
2571 memory_test_inc_3.t: $(srcdir)/memory_test_inc_3.t.src
2572         cp $< $@
2573 memory_test_2: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t memory_test_inc_1.t memory_test_inc_2.t memory_test_inc_3.t
2574         $(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -z max-page-size=0x1000 -z common-page-size=0x1000 -Wl,-T,$(srcdir)/memory_test.t -o $@ memory_test.o
2575
2576 if HAVE_PUBNAMES
2577
2578 # Test that --gdb-index functions correctly without gcc-generated pubnames.
2579 check_SCRIPTS += gdb_index_test_1.sh
2580 check_DATA += gdb_index_test_1.stdout
2581 MOSTLYCLEANFILES += gdb_index_test_1.stdout gdb_index_test_1
2582 gdb_index_test.o: gdb_index_test.cc
2583         $(CXXCOMPILE) -O0 -g -gno-pubnames -c -o $@ $<
2584 gdb_index_test_1: gdb_index_test.o gcctestdir/ld
2585         $(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $<
2586 gdb_index_test_1.stdout: gdb_index_test_1
2587         $(TEST_READELF) --debug-dump=gdb_index $< > $@
2588
2589 # Test that --gdb-index functions correctly with compressed debug sections.
2590 check_SCRIPTS += gdb_index_test_2.sh
2591 check_DATA += gdb_index_test_2.stdout
2592 MOSTLYCLEANFILES += gdb_index_test_2.stdout gdb_index_test_2 gdb_index_test_2_gabi
2593 gdb_index_test_cdebug.o: gdb_index_test.cc
2594         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -o $@ $<
2595 gdb_index_test_2: gdb_index_test_cdebug.o gcctestdir/ld
2596         $(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $<
2597 gdb_index_test_2.stdout: gdb_index_test_2
2598         $(TEST_READELF) --debug-dump=gdb_index $< > $@
2599 check_SCRIPTS += gdb_index_test_2_gabi.sh
2600 check_DATA += gdb_index_test_2_gabi.stdout
2601 MOSTLYCLEANFILES += gdb_index_test_2.stdout gdb_index_test_2
2602 gdb_index_test_cdebug_gabi.o: gdb_index_test.cc
2603         $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections=zlib-gabi -c -o $@ $<
2604 gdb_index_test_2_gabi: gdb_index_test_cdebug_gabi.o gcctestdir/ld
2605         $(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $<
2606 gdb_index_test_2_gabi.stdout: gdb_index_test_2_gabi
2607         $(TEST_READELF) --debug-dump=gdb_index $< > $@
2608
2609 # Another simple C test (DW_AT_high_pc encoding) for --gdb-index.
2610 check_SCRIPTS += gdb_index_test_3.sh
2611 check_DATA += gdb_index_test_3.stdout
2612 MOSTLYCLEANFILES += gdb_index_test_3.stdout gdb_index_test_3
2613 gdb_index_test_3.o: gdb_index_test_3.c
2614         $(COMPILE) -O0 -g -c -o $@ $<
2615 gdb_index_test_3: gdb_index_test_3.o gcctestdir/ld
2616         $(LINK) -Bgcctestdir/ -Wl,--gdb-index,--fatal-warnings $<
2617 gdb_index_test_3.stdout: gdb_index_test_3
2618         $(TEST_READELF) --debug-dump=gdb_index $< > $@
2619
2620 # Test that --gdb-index functions correctly with gcc-generated pubnames.
2621 check_SCRIPTS += gdb_index_test_4.sh
2622 check_DATA += gdb_index_test_4.stdout
2623 MOSTLYCLEANFILES += gdb_index_test_4.stdout gdb_index_test_4
2624 gdb_index_test_pub.o: gdb_index_test.cc
2625         $(CXXCOMPILE) -O0 -g -gpubnames -c -o $@ $<
2626 gdb_index_test_4: gdb_index_test_pub.o gcctestdir/ld
2627         $(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $<
2628 gdb_index_test_4.stdout: gdb_index_test_4
2629         $(TEST_READELF) --debug-dump=gdb_index $< > $@
2630
2631 endif HAVE_PUBNAMES
2632
2633 # Test that __ehdr_start is defined correctly.
2634 check_PROGRAMS += ehdr_start_test_1
2635 ehdr_start_test_1_SOURCES = ehdr_start_test.cc
2636 ehdr_start_test_1_DEPENDENCIES = gcctestdir/ld
2637 ehdr_start_test_1_CXXFLAGS =
2638 ehdr_start_test_1_LDFLAGS = -Bgcctestdir/
2639 ehdr_start_test_1_LDADD =
2640
2641 # Test that __ehdr_start is defined correctly with a weak reference.
2642 check_PROGRAMS += ehdr_start_test_2
2643 ehdr_start_test_2_SOURCES = ehdr_start_test.cc
2644 ehdr_start_test_2_DEPENDENCIES = gcctestdir/ld
2645 ehdr_start_test_2_CXXFLAGS = -DEHDR_START_WEAK
2646 ehdr_start_test_2_LDFLAGS = -Bgcctestdir/
2647 ehdr_start_test_2_LDADD =
2648
2649 # Test that __ehdr_start is defined correctly when used with a linker script.
2650 check_PROGRAMS += ehdr_start_test_3
2651 ehdr_start_test_3_SOURCES = ehdr_start_test.cc
2652 ehdr_start_test_3_DEPENDENCIES = gcctestdir/ld $(srcdir)/ehdr_start_test.t
2653 ehdr_start_test_3_CXXFLAGS = -DEHDR_START_WEAK
2654 ehdr_start_test_3_LDFLAGS = -Bgcctestdir/ -Wl,-T,$(srcdir)/ehdr_start_test.t
2655 ehdr_start_test_3_LDADD =
2656
2657 # Test that __ehdr_start is left undefined when the text segment is not
2658 # appropriately aligned.
2659 check_SCRIPTS += ehdr_start_test_4.sh
2660 check_DATA += ehdr_start_test_4.syms
2661 MOSTLYCLEANFILES += ehdr_start_test_4
2662 ehdr_start_test_4.syms: ehdr_start_test_4
2663         $(TEST_NM) ehdr_start_test_4 > $@
2664 ehdr_start_test_4: ehdr_start_test_4.o gcctestdir/ld
2665         $(CXXLINK) -Bgcctestdir/ -Wl,-Ttext=0x100100 $<
2666 ehdr_start_test_4.o: ehdr_start_test.cc
2667         $(CXXCOMPILE) -c -DEHDR_START_WEAK -o $@ $<
2668
2669 # Test that __ehdr_start is not overridden when supplied by the user.
2670 check_PROGRAMS += ehdr_start_test_5
2671 ehdr_start_test_5_SOURCES = ehdr_start_test.cc ehdr_start_def.cc
2672 ehdr_start_test_5_DEPENDENCIES = gcctestdir/ld
2673 ehdr_start_test_5_CXXFLAGS = -DEHDR_START_USER_DEF
2674 ehdr_start_test_5_LDFLAGS = -Bgcctestdir/
2675 ehdr_start_test_5_LDADD =
2676
2677 # Test that the --defsym option copies the symbol type and visibility.
2678 check_SCRIPTS += defsym_test.sh
2679 check_DATA += defsym_test.syms
2680 MOSTLYCLEANFILES += defsym_test defsym_test.syms
2681 defsym_test.syms: defsym_test
2682         $(TEST_READELF) -sW $< > $@
2683 defsym_test: defsym_test.o gcctestdir/ld
2684         $(LINK) -Bgcctestdir/ -Wl,--defsym=bar=foo defsym_test.o
2685 defsym_test.o: defsym_test.c
2686         $(COMPILE) -c -o $@ $<
2687
2688 # End-to-end incremental linking tests.
2689 # Incremental linking is currently supported only on the x86_64 target.
2690
2691 if DEFAULT_TARGET_X86_64
2692
2693 two_file_test_1_v1_ndebug.o: two_file_test_1_v1.cc
2694         $(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2695 two_file_test_1_ndebug.o: two_file_test_1.cc
2696         $(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2697 two_file_test_1b_ndebug.o: two_file_test_1b.cc
2698         $(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2699 two_file_test_2_ndebug.o: two_file_test_2.cc
2700         $(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2701 two_file_test_main_ndebug.o: two_file_test_main.cc
2702         $(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2703
2704 check_PROGRAMS += incremental_test_2
2705 MOSTLYCLEANFILES += two_file_test_tmp_2.o
2706 incremental_test_2: two_file_test_1_v1_ndebug.o two_file_test_1_ndebug.o two_file_test_1b_ndebug.o \
2707                     two_file_test_2_ndebug.o two_file_test_main_ndebug.o gcctestdir/ld
2708         cp -f two_file_test_1_v1_ndebug.o two_file_test_tmp_2.o
2709         $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ two_file_test_tmp_2.o two_file_test_1b_ndebug.o two_file_test_2_ndebug.o two_file_test_main_ndebug.o
2710         @sleep 1
2711         cp -f two_file_test_1_ndebug.o two_file_test_tmp_2.o
2712         $(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ two_file_test_tmp_2.o two_file_test_1b_ndebug.o two_file_test_2_ndebug.o two_file_test_main_ndebug.o
2713
2714 check_PROGRAMS += incremental_test_3
2715 MOSTLYCLEANFILES += two_file_test_tmp_3.o
2716 incremental_test_3: two_file_test_1.o two_file_test_1b_v1.o two_file_test_1b.o \
2717                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
2718         cp -f two_file_test_1b_v1.o two_file_test_tmp_3.o
2719         $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ two_file_test_1.o two_file_test_tmp_3.o two_file_test_2.o two_file_test_main.o
2720         @sleep 1
2721         cp -f two_file_test_1b.o two_file_test_tmp_3.o
2722         $(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ two_file_test_1.o two_file_test_tmp_3.o two_file_test_2.o two_file_test_main.o
2723
2724 check_PROGRAMS += incremental_test_4
2725 MOSTLYCLEANFILES += incremental_test_4.base two_file_test_tmp_4.o
2726 incremental_test_4: two_file_test_1.o two_file_test_1b.o two_file_test_2_v1.o \
2727                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
2728         cp -f two_file_test_2_v1.o two_file_test_tmp_4.o
2729         $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ two_file_test_1.o two_file_test_1b.o two_file_test_tmp_4.o two_file_test_main.o
2730         mv -f incremental_test_4 incremental_test_4.base
2731         @sleep 1
2732         cp -f two_file_test_2.o two_file_test_tmp_4.o
2733         $(CXXLINK) -Wl,--incremental-update,--incremental-base=incremental_test_4.base -Wl,-z,norelro -Bgcctestdir/ two_file_test_1.o two_file_test_1b.o two_file_test_tmp_4.o two_file_test_main.o
2734
2735 check_PROGRAMS += incremental_test_5
2736 MOSTLYCLEANFILES += two_file_test_5.a
2737 incremental_test_5: two_file_test_1.o two_file_test_1b_v1.o two_file_test_1b.o \
2738                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
2739         cp -f two_file_test_1b_v1.o two_file_test_tmp_5.o
2740         $(TEST_AR) rc two_file_test_5.a two_file_test_1.o two_file_test_tmp_5.o two_file_test_2.o
2741         $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ two_file_test_main.o two_file_test_5.a
2742         @sleep 1
2743         cp -f two_file_test_1b.o two_file_test_tmp_5.o
2744         $(TEST_AR) rc two_file_test_5.a two_file_test_1.o two_file_test_tmp_5.o two_file_test_2.o
2745         $(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ two_file_test_main.o two_file_test_5.a
2746
2747 # Test the --incremental-unchanged flag with an archive library.
2748 # The second link should not update the library.
2749 check_PROGRAMS += incremental_test_6
2750 MOSTLYCLEANFILES += two_file_test_6.a
2751 incremental_test_6: two_file_test_1.o two_file_test_1b_v1.o two_file_test_1b.o \
2752                     two_file_test_2.o two_file_test_main.o gcctestdir/ld
2753         cp -f two_file_test_1b.o two_file_test_tmp_6.o
2754         $(TEST_AR) rc two_file_test_6.a two_file_test_1.o two_file_test_tmp_6.o two_file_test_2.o
2755         $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ two_file_test_main.o two_file_test_6.a
2756         @sleep 1
2757         cp -f two_file_test_1b_v1.o two_file_test_tmp_6.o
2758         $(TEST_AR) rc two_file_test_6.a two_file_test_1.o two_file_test_tmp_6.o two_file_test_2.o
2759         $(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ two_file_test_main.o -Wl,--incremental-unchanged two_file_test_6.a -Wl,--incremental-unknown
2760
2761 check_PROGRAMS += incremental_copy_test
2762 incremental_copy_test: copy_test_v1.o copy_test.o copy_test_1.so copy_test_2.so
2763         cp -f copy_test_v1.o copy_test_tmp.o
2764         $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ -Wl,-R,. -Wl,--no-as-needed copy_test_tmp.o copy_test_1.so copy_test_2.so
2765         @sleep 1
2766         cp -f copy_test.o copy_test_tmp.o
2767         $(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ -Wl,-R,. -Wl,--no-as-needed copy_test_tmp.o copy_test_1.so copy_test_2.so
2768
2769 check_PROGRAMS += incremental_common_test_1
2770 incremental_common_test_1: common_test_1_v1.o common_test_1_v2.o gcctestdir/ld
2771         cp -f common_test_1_v1.o common_test_1_tmp.o
2772         $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ common_test_1_tmp.o
2773         @sleep 1
2774         cp -f common_test_1_v2.o common_test_1_tmp.o
2775         $(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ common_test_1_tmp.o
2776
2777 check_PROGRAMS += incremental_comdat_test_1
2778 incremental_comdat_test_1: incr_comdat_test_1.o incr_comdat_test_2_v1.o incr_comdat_test_2_v2.o incr_comdat_test_2_v3.o gcctestdir/ld
2779         cp -f incr_comdat_test_2_v1.o incr_comdat_test_1_tmp.o
2780         $(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
2781         @sleep 1
2782         cp -f incr_comdat_test_2_v2.o incr_comdat_test_1_tmp.o
2783         $(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
2784         @sleep 1
2785         cp -f incr_comdat_test_2_v3.o incr_comdat_test_1_tmp.o
2786         $(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
2787
2788 endif DEFAULT_TARGET_X86_64
2789
2790 if DEFAULT_TARGET_X86_64
2791 check_PROGRAMS += exception_x86_64_bnd_test
2792 exception_x86_64_bnd_test_SOURCES = exception_test_main.cc
2793 exception_x86_64_bnd_test_DEPENDENCIES = gcctestdir/ld exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o
2794 exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS)
2795 exception_x86_64_bnd_test_LDADD = exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o
2796 exception_x86_64_bnd_1.o: exception_test_1.cc gcctestdir/as
2797         $(CXXCOMPILE) -c -fpic -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $<
2798 exception_x86_64_bnd_2.o: exception_test_2.cc gcctestdir/as
2799         $(CXXCOMPILE) -c -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $<
2800 endif DEFAULT_TARGET_X86_64
2801
2802 endif GCC
2803 endif NATIVE_LINKER
2804
2805 # These tests work with native and cross linkers.
2806
2807 if NATIVE_OR_CROSS_LINKER
2808
2809 # Test script section order.
2810 check_SCRIPTS += script_test_10.sh
2811 check_DATA += script_test_10.stdout
2812 MOSTLYCLEANFILES += script_test_10
2813 script_test_10.o: script_test_10.s
2814         $(TEST_AS) -o $@ $<
2815 script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld
2816         gcctestdir/ld -o $@ script_test_10.o -T $(srcdir)/script_test_10.t
2817 script_test_10.stdout: script_test_10
2818         $(TEST_READELF) -SW script_test_10 > $@
2819
2820 # These tests work with cross linkers only.
2821
2822 if DEFAULT_TARGET_I386
2823
2824 check_SCRIPTS += split_i386.sh
2825 check_DATA += split_i386_1.stdout split_i386_2.stdout \
2826         split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout
2827 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
2828 split_i386_1.o: split_i386_1.s
2829         $(TEST_AS) -o $@ $<
2830 split_i386_2.o: split_i386_2.s
2831         $(TEST_AS) -o $@ $<
2832 split_i386_3.o: split_i386_3.s
2833         $(TEST_AS) -o $@ $<
2834 split_i386_4.o: split_i386_4.s
2835         $(TEST_AS) -o $@ $<
2836 split_i386_n.o: split_i386_n.s
2837         $(TEST_AS) -o $@ $<
2838 split_i386_1: split_i386_1.o split_i386_n.o ../ld-new
2839         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_1.o split_i386_n.o
2840 split_i386_1.stdout: split_i386_1
2841         $(TEST_OBJDUMP) -d $< > $@
2842 split_i386_2: split_i386_2.o split_i386_n.o ../ld-new
2843         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_2.o split_i386_n.o
2844 split_i386_2.stdout: split_i386_2
2845         $(TEST_OBJDUMP) -d $< > $@
2846 split_i386_3.stdout: split_i386_3.o split_i386_n.o ../ld-new
2847         ../ld-new $(SPLIT_DEFSYMS) -o split_i386_3 split_i386_3.o split_i386_n.o > $@ 2>&1 || exit 0
2848 split_i386_4: split_i386_4.o split_i386_n.o ../ld-new
2849         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_4.o split_i386_n.o
2850 split_i386_4.stdout: split_i386_4
2851         $(TEST_OBJDUMP) -d $< > $@
2852 split_i386_r.stdout: split_i386_1.o split_i386_n.o ../ld-new
2853         ../ld-new -r split_i386_1.o split_i386_n.o -o split_i386_r > $@ 2>&1 || exit 0
2854 MOSTLYCLEANFILES += split_i386_1 split_i386_2 split_i386_3 \
2855         split_i386_4 split_i386_r
2856
2857 endif DEFAULT_TARGET_I386
2858
2859 if DEFAULT_TARGET_X86_64
2860
2861 check_SCRIPTS += split_x86_64.sh
2862 check_DATA += split_x86_64_1.stdout split_x86_64_2.stdout \
2863         split_x86_64_3.stdout split_x86_64_4.stdout split_x86_64_r.stdout
2864 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
2865 split_x86_64_1.o: split_x86_64_1.s
2866         $(TEST_AS) -o $@ $<
2867 split_x86_64_2.o: split_x86_64_2.s
2868         $(TEST_AS) -o $@ $<
2869 split_x86_64_3.o: split_x86_64_3.s
2870         $(TEST_AS) -o $@ $<
2871 split_x86_64_4.o: split_x86_64_4.s
2872         $(TEST_AS) -o $@ $<
2873 split_x86_64_n.o: split_x86_64_n.s
2874         $(TEST_AS) -o $@ $<
2875 split_x86_64_1: split_x86_64_1.o split_x86_64_n.o ../ld-new
2876         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_1.o split_x86_64_n.o
2877 split_x86_64_1.stdout: split_x86_64_1
2878         $(TEST_OBJDUMP) -d $< > $@
2879 split_x86_64_2: split_x86_64_2.o split_x86_64_n.o ../ld-new
2880         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_2.o split_x86_64_n.o
2881 split_x86_64_2.stdout: split_x86_64_2
2882         $(TEST_OBJDUMP) -d $< > $@
2883 split_x86_64_3.stdout: split_x86_64_3.o split_x86_64_n.o ../ld-new
2884         ../ld-new $(SPLIT_DEFSYMS) -o split_x86_64_3 split_x86_64_3.o split_x86_64_n.o > $@ 2>&1 || exit 0
2885 split_x86_64_4: split_x86_64_4.o split_x86_64_n.o ../ld-new
2886         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_4.o split_x86_64_n.o
2887 split_x86_64_4.stdout: split_x86_64_4
2888         $(TEST_OBJDUMP) -d $< > $@
2889 split_x86_64_r.stdout: split_x86_64_1.o split_x86_64_n.o ../ld-new
2890         ../ld-new -r split_x86_64_1.o split_x86_64_n.o -o split_x86_64_r > $@ 2>&1 || exit 0
2891 MOSTLYCLEANFILES += split_x86_64_1 split_x86_64_2 split_x86_64_3 \
2892         split_x86_64_4 split_x86_64_r
2893
2894 endif DEFAULT_TARGET_X86_64
2895
2896 if DEFAULT_TARGET_X32
2897
2898 check_SCRIPTS += split_x32.sh
2899 check_DATA += split_x32_1.stdout split_x32_2.stdout \
2900         split_x32_3.stdout split_x32_4.stdout split_x32_r.stdout
2901 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
2902 split_x32_1.o: split_x32_1.s
2903         $(TEST_AS) -o $@ $<
2904 split_x32_2.o: split_x32_2.s
2905         $(TEST_AS) -o $@ $<
2906 split_x32_3.o: split_x32_3.s
2907         $(TEST_AS) -o $@ $<
2908 split_x32_4.o: split_x32_4.s
2909         $(TEST_AS) -o $@ $<
2910 split_x32_n.o: split_x32_n.s
2911         $(TEST_AS) -o $@ $<
2912 split_x32_1: split_x32_1.o split_x32_n.o ../ld-new
2913         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x32_1.o split_x32_n.o
2914 split_x32_1.stdout: split_x32_1
2915         $(TEST_OBJDUMP) -d $< > $@
2916 split_x32_2: split_x32_2.o split_x32_n.o ../ld-new
2917         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x32_2.o split_x32_n.o
2918 split_x32_2.stdout: split_x32_2
2919         $(TEST_OBJDUMP) -d $< > $@
2920 split_x32_3.stdout: split_x32_3.o split_x32_n.o ../ld-new
2921         ../ld-new $(SPLIT_DEFSYMS) -o split_x32_3 split_x32_3.o split_x32_n.o > $@ 2>&1 || exit 0
2922 split_x32_4: split_x32_4.o split_x32_n.o ../ld-new
2923         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_x32_4.o split_x32_n.o
2924 split_x32_4.stdout: split_x32_4
2925         $(TEST_OBJDUMP) -d $< > $@
2926 split_x32_r.stdout: split_x32_1.o split_x32_n.o ../ld-new
2927         ../ld-new -r split_x32_1.o split_x32_n.o -o split_x32_r > $@ 2>&1 || exit 0
2928 MOSTLYCLEANFILES += split_x32_1 split_x32_2 split_x32_3 \
2929         split_x32_4 split_x32_r
2930
2931 endif DEFAULT_TARGET_X32
2932
2933 if DEFAULT_TARGET_ARM
2934
2935 check_SCRIPTS += arm_abs_global.sh
2936 check_DATA += arm_abs_global.stdout
2937 arm_abs_lib.o: arm_abs_lib.s
2938         $(TEST_AS) -march=armv7-a -o $@ $<
2939 libarm_abs.so: arm_abs_lib.o ../ld-new
2940         ../ld-new -shared -o $@ arm_abs_lib.o
2941 arm_abs_global.o: arm_abs_global.s
2942         $(TEST_AS) -march=armv7-a -o $@ $<
2943 arm_abs_global: arm_abs_global.o libarm_abs.so ../ld-new
2944         ../ld-new -o $@ arm_abs_global.o -L. -larm_abs
2945 arm_abs_global.stdout: arm_abs_global
2946         $(TEST_READELF) -r $< > $@
2947
2948 MOSTLYCLEANFILES += arm_abs_global
2949
2950 check_SCRIPTS += arm_branch_in_range.sh arm_branch_out_of_range.sh
2951 check_DATA += arm_bl_in_range.stdout arm_bl_out_of_range.stdout \
2952         thumb_bl_in_range.stdout thumb_bl_out_of_range.stdout \
2953         thumb2_bl_in_range.stdout thumb2_bl_out_of_range.stdout \
2954         thumb_blx_in_range.stdout thumb_blx_out_of_range.stdout \
2955         thumb2_blx_in_range.stdout thumb2_blx_out_of_range.stdout \
2956         thumb_bl_out_of_range_local.stdout arm_thm_jump11.stdout \
2957         arm_thm_jump8.stdout
2958
2959 arm_bl_in_range.stdout: arm_bl_in_range
2960         $(TEST_OBJDUMP) -D $< > $@
2961
2962 arm_bl_in_range: arm_bl_in_range.o ../ld-new
2963         ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2964
2965 arm_bl_in_range.o: arm_bl_in_range.s
2966         $(TEST_AS) -o $@ $<
2967
2968 arm_bl_out_of_range.stdout: arm_bl_out_of_range
2969         $(TEST_OBJDUMP) -S $< > $@
2970
2971 arm_bl_out_of_range: arm_bl_out_of_range.o ../ld-new
2972         ../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2973
2974 arm_bl_out_of_range.o: arm_bl_out_of_range.s
2975         $(TEST_AS) -o $@ $<
2976
2977 thumb_bl_in_range.stdout: thumb_bl_in_range
2978         $(TEST_OBJDUMP) -D $< > $@
2979
2980 thumb_bl_in_range: thumb_bl_in_range.o ../ld-new
2981         ../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
2982
2983 thumb_bl_in_range.o: thumb_bl_in_range.s
2984         $(TEST_AS) -o $@ -march=armv5te $<
2985
2986 thumb_bl_out_of_range.stdout: thumb_bl_out_of_range
2987         $(TEST_OBJDUMP) -D $< > $@
2988
2989 thumb_bl_out_of_range: thumb_bl_out_of_range.o ../ld-new
2990         ../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
2991
2992 thumb_bl_out_of_range.o: thumb_bl_out_of_range.s
2993         $(TEST_AS) -o $@ -march=armv5te $<
2994
2995 thumb2_bl_in_range.stdout: thumb2_bl_in_range
2996         $(TEST_OBJDUMP) -D $< > $@
2997
2998 thumb2_bl_in_range: thumb2_bl_in_range.o ../ld-new
2999         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
3000
3001 thumb2_bl_in_range.o: thumb_bl_in_range.s
3002         $(TEST_AS) -o $@ -march=armv7-a $<
3003
3004 thumb2_bl_out_of_range.stdout: thumb2_bl_out_of_range
3005         $(TEST_OBJDUMP) -D $< > $@
3006
3007 thumb2_bl_out_of_range: thumb2_bl_out_of_range.o ../ld-new
3008         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
3009
3010 thumb2_bl_out_of_range.o: thumb_bl_out_of_range.s
3011         $(TEST_AS) -o $@ -march=armv7-a $<
3012
3013 thumb_blx_in_range.stdout: thumb_blx_in_range
3014         $(TEST_OBJDUMP) -D $< > $@
3015
3016 thumb_blx_in_range: thumb_blx_in_range.o ../ld-new
3017         ../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
3018
3019 thumb_blx_in_range.o: thumb_blx_in_range.s
3020         $(TEST_AS) -o $@ -march=armv5te $<
3021
3022 thumb_blx_out_of_range.stdout: thumb_blx_out_of_range
3023         $(TEST_OBJDUMP) -D $< > $@
3024
3025 thumb_blx_out_of_range: thumb_blx_out_of_range.o ../ld-new
3026         ../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
3027
3028 thumb_blx_out_of_range.o: thumb_blx_out_of_range.s
3029         $(TEST_AS) -o $@ -march=armv5te $<
3030
3031 thumb2_blx_in_range.stdout: thumb2_blx_in_range
3032         $(TEST_OBJDUMP) -D $< > $@
3033
3034 thumb2_blx_in_range: thumb2_blx_in_range.o ../ld-new
3035         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
3036
3037 thumb2_blx_in_range.o: thumb_blx_in_range.s
3038         $(TEST_AS) -o $@ -march=armv7-a $<
3039
3040 thumb2_blx_out_of_range.stdout: thumb2_blx_out_of_range
3041         $(TEST_OBJDUMP) -D $< > $@
3042
3043 thumb2_blx_out_of_range: thumb2_blx_out_of_range.o ../ld-new
3044         ../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
3045
3046 thumb2_blx_out_of_range.o: thumb_blx_out_of_range.s
3047         $(TEST_AS) -o $@ -march=armv7-a $<
3048
3049 thumb_bl_out_of_range_local.stdout: thumb_bl_out_of_range_local
3050         $(TEST_OBJDUMP) -D $< > $@
3051
3052 thumb_bl_out_of_range_local: thumb_bl_out_of_range_local.o ../ld-new
3053         ../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
3054
3055 thumb_bl_out_of_range_local.o: thumb_bl_out_of_range_local.s
3056         $(TEST_AS) -o $@ -march=armv5te $<
3057
3058 arm_thm_jump11.stdout: arm_thm_jump11
3059         $(TEST_OBJDUMP) -D $< > $@
3060
3061 arm_thm_jump11: arm_thm_jump11.o ../ld-new
3062         ../ld-new -T $(srcdir)/arm_thm_jump11.t -o $@ $<
3063
3064 arm_thm_jump11.o: arm_thm_jump11.s
3065         $(TEST_AS) -o $@ $<
3066
3067 arm_thm_jump8.stdout: arm_thm_jump8
3068         $(TEST_OBJDUMP) -D $< > $@
3069
3070 arm_thm_jump8: arm_thm_jump8.o ../ld-new
3071         ../ld-new -T $(srcdir)/arm_thm_jump8.t -o $@ $<
3072
3073 arm_thm_jump8.o: arm_thm_jump8.s
3074         $(TEST_AS) -o $@ $<
3075
3076 MOSTLYCLEANFILES += arm_bl_in_range arm_bl_out_of_range thumb_bl_in_range \
3077         thumb_bl_out_of_range thumb2_bl_in_range thumb2_bl_out_of_range \
3078         thumb_blx_in_range thumb_blx_out_of_range thumb2_blx_in_range \
3079         thumb2_blx_out_of_range thumb_bl_out_of_range_local arm_thm_jump11 \
3080         arm_thm_jump8
3081
3082 check_SCRIPTS += arm_fix_v4bx.sh
3083 check_DATA += arm_fix_v4bx.stdout arm_fix_v4bx_interworking.stdout \
3084         arm_no_fix_v4bx.stdout
3085
3086 arm_fix_v4bx.stdout: arm_fix_v4bx
3087         $(TEST_OBJDUMP) -D -j.text $< > $@
3088
3089 arm_fix_v4bx: arm_fix_v4bx.o ../ld-new
3090         ../ld-new --no-fix-arm1176 --fix-v4bx -o $@ $<
3091
3092 arm_fix_v4bx.o: arm_fix_v4bx.s
3093         $(TEST_AS) -o $@ $<
3094
3095 arm_fix_v4bx_interworking.stdout: arm_fix_v4bx_interworking
3096         $(TEST_OBJDUMP) -D -j.text $< > $@
3097
3098 arm_fix_v4bx_interworking: arm_fix_v4bx.o ../ld-new
3099         ../ld-new --no-fix-arm1176 --fix-v4bx-interworking -o $@ $<
3100
3101 arm_no_fix_v4bx.stdout: arm_no_fix_v4bx
3102         $(TEST_OBJDUMP) -D -j.text $< > $@
3103
3104 arm_no_fix_v4bx: arm_fix_v4bx.o ../ld-new
3105         ../ld-new --no-fix-arm1176 -o $@ $<
3106
3107 MOSTLYCLEANFILES += arm_fix_v4bx arm_fix_v4bx_interworking arm_no_fix_v4bx
3108
3109 check_SCRIPTS += arm_attr_merge.sh
3110 check_DATA += arm_attr_merge_6.stdout arm_attr_merge_6r.stdout \
3111         arm_attr_merge_7.stdout
3112
3113 arm_attr_merge_6.stdout: arm_attr_merge_6
3114         $(TEST_READELF) -A $< > $@
3115
3116 arm_attr_merge_6: arm_attr_merge_6a.o arm_attr_merge_6b.o
3117         ../ld-new -o $@ arm_attr_merge_6a.o arm_attr_merge_6b.o
3118
3119 arm_attr_merge_6a.o: arm_attr_merge_6a.s
3120         $(TEST_AS) -o $@ $<
3121
3122 arm_attr_merge_6b.o: arm_attr_merge_6b.s
3123         $(TEST_AS) -o $@ $<
3124
3125 arm_attr_merge_6r.stdout: arm_attr_merge_6r
3126         $(TEST_READELF) -A $< > $@
3127
3128 arm_attr_merge_6r: arm_attr_merge_6b.o arm_attr_merge_6a.o
3129         ../ld-new -o $@ arm_attr_merge_6b.o arm_attr_merge_6a.o
3130
3131 arm_attr_merge_7.stdout: arm_attr_merge_7
3132         $(TEST_READELF) -A $< > $@
3133
3134 arm_attr_merge_7: arm_attr_merge_7a.o arm_attr_merge_7b.o
3135         ../ld-new -o $@ arm_attr_merge_7a.o arm_attr_merge_7b.o
3136
3137 arm_attr_merge_7a.o: arm_attr_merge_7a.s
3138         $(TEST_AS) -o $@ $<
3139
3140 arm_attr_merge_7b.o: arm_attr_merge_7b.s
3141         $(TEST_AS) -o $@ $<
3142
3143 MOSTLYCLEANFILES += arm_attr_merge_6 arm_attr_merge_6r arm_attr_merge_7
3144
3145 # ARM1176 workaround test.
3146 check_SCRIPTS += arm_fix_1176.sh
3147 check_DATA += arm_fix_1176_default_v6z.stdout arm_fix_1176_on_v6z.stdout \
3148         arm_fix_1176_off_v6z.stdout arm_fix_1176_default_v5te.stdout \
3149         arm_fix_1176_default_v7a.stdout arm_fix_1176_default_1156t2f_s.stdout
3150
3151 arm_fix_1176_default_v6z.stdout: arm_fix_1176_default_v6z
3152         $(TEST_OBJDUMP) -D -j.foo $< > $@
3153
3154 arm_fix_1176_default_v6z: arm_fix_1176_default_v6z.o ../ld-new
3155         ../ld-new --section-start=.foo=0x2001014 -o $@ $<
3156
3157 arm_fix_1176_default_v6z.o: arm_fix_1176.s
3158         $(TEST_AS) -march=armv6z -o $@ $<
3159
3160 arm_fix_1176_on_v6z.stdout: arm_fix_1176_on_v6z
3161         $(TEST_OBJDUMP) -D -j.foo $< > $@
3162
3163 arm_fix_1176_on_v6z: arm_fix_1176_on_v6z.o ../ld-new
3164         ../ld-new --section-start=.foo=0x2001014 --fix-arm1176 -o $@ $<
3165
3166 arm_fix_1176_on_v6z.o: arm_fix_1176.s
3167         $(TEST_AS) -march=armv6z -o $@ $<
3168
3169 arm_fix_1176_off_v6z.stdout: arm_fix_1176_off_v6z
3170         $(TEST_OBJDUMP) -D -j.foo $< > $@
3171
3172 arm_fix_1176_off_v6z: arm_fix_1176_off_v6z.o ../ld-new
3173         ../ld-new --section-start=.foo=0x2001014 --no-fix-arm1176 -o $@ $<
3174
3175 arm_fix_1176_off_v6z.o: arm_fix_1176.s
3176         $(TEST_AS) -march=armv6z -o $@ $<
3177
3178 arm_fix_1176_default_v5te.stdout: arm_fix_1176_default_v5te
3179         $(TEST_OBJDUMP) -D -j.foo $< > $@
3180
3181 arm_fix_1176_default_v5te: arm_fix_1176_default_v5te.o ../ld-new
3182         ../ld-new --section-start=.foo=0x2001014 -o $@ $<
3183
3184 arm_fix_1176_default_v5te.o: arm_fix_1176.s
3185         $(TEST_AS) -march=armv5te -o $@ $<
3186
3187 arm_fix_1176_default_v7a.stdout: arm_fix_1176_default_v7a
3188         $(TEST_OBJDUMP) -D -j.foo $< > $@
3189
3190 arm_fix_1176_default_v7a: arm_fix_1176_default_v7a.o ../ld-new
3191         ../ld-new --section-start=.foo=0x2001014 -o $@ $<
3192
3193 arm_fix_1176_default_v7a.o: arm_fix_1176.s
3194         $(TEST_AS) -march=armv7-a -o $@ $<
3195
3196 arm_fix_1176_default_1156t2f_s.stdout: arm_fix_1176_default_1156t2f_s
3197         $(TEST_OBJDUMP) -D -j.foo $< > $@
3198
3199 arm_fix_1176_default_1156t2f_s: arm_fix_1176_default_1156t2f_s.o ../ld-new
3200         ../ld-new --section-start=.foo=0x2001014 -o $@ $<
3201
3202 arm_fix_1176_default_1156t2f_s.o: arm_fix_1176.s
3203         $(TEST_AS) -mcpu=arm1156t2f-s -o $@ $<
3204
3205 MOSTLYCLEANFILES += arm_fix_1176_default_v6z arm_fix_1176_on_v6z arm_fix_1176_off_v6z \
3206         arm_fix_1176_default_v5te arm_fix_1176_default_v7a arm_fix_1176_default_1156t2f_s
3207
3208 # Cortex-A8 workaround test.
3209
3210 check_SCRIPTS += arm_cortex_a8.sh
3211 check_DATA += arm_cortex_a8_b_cond.stdout arm_cortex_a8_b.stdout \
3212         arm_cortex_a8_bl.stdout arm_cortex_a8_blx.stdout \
3213         arm_cortex_a8_local.stdout arm_cortex_a8_local_reloc.stdout
3214
3215 arm_cortex_a8_b_cond.stdout: arm_cortex_a8_b_cond
3216         $(TEST_OBJDUMP) -D -j.text $< > $@
3217
3218 arm_cortex_a8_b_cond: arm_cortex_a8_b_cond.o ../ld-new
3219         ../ld-new -o $@ $<
3220
3221 arm_cortex_a8_b_cond.o: arm_cortex_a8_b_cond.s
3222         $(TEST_AS) -o $@ $<
3223
3224 arm_cortex_a8_b.stdout: arm_cortex_a8_b
3225         $(TEST_OBJDUMP) -D -j.text $< > $@
3226
3227 arm_cortex_a8_b: arm_cortex_a8_b.o ../ld-new
3228         ../ld-new --fix-cortex-a8 -o $@ $<
3229
3230 arm_cortex_a8_b.o: arm_cortex_a8_b.s
3231         $(TEST_AS) -o $@ $<
3232
3233 arm_cortex_a8_bl.stdout: arm_cortex_a8_bl
3234         $(TEST_OBJDUMP) -D -j.text $< > $@
3235
3236 arm_cortex_a8_bl: arm_cortex_a8_bl.o ../ld-new
3237         ../ld-new -o $@ $<
3238
3239 arm_cortex_a8_bl.o: arm_cortex_a8_bl.s
3240         $(TEST_AS) -o $@ $<
3241
3242 arm_cortex_a8_blx.stdout: arm_cortex_a8_blx
3243         $(TEST_OBJDUMP) -D -j.text $< > $@
3244
3245 arm_cortex_a8_blx: arm_cortex_a8_blx.o ../ld-new
3246         ../ld-new -o $@ $<
3247
3248 arm_cortex_a8_blx.o: arm_cortex_a8_blx.s
3249         $(TEST_AS) -o $@ $<
3250
3251 arm_cortex_a8_local.stdout: arm_cortex_a8_local
3252         $(TEST_OBJDUMP) -D -j.text $< > $@
3253
3254 arm_cortex_a8_local: arm_cortex_a8_local.o ../ld-new
3255         ../ld-new -o $@ $<
3256
3257 arm_cortex_a8_local.o: arm_cortex_a8_local.s
3258         $(TEST_AS) -o $@ $<
3259
3260 arm_cortex_a8_local_reloc.stdout: arm_cortex_a8_local_reloc
3261         $(TEST_OBJDUMP) -D -j.text $< > $@
3262
3263 arm_cortex_a8_local_reloc: arm_cortex_a8_local_reloc.o ../ld-new
3264         ../ld-new -o $@ $<
3265
3266 arm_cortex_a8_local_reloc.o: arm_cortex_a8_local_reloc.s
3267         $(TEST_AS) -o $@ $<
3268
3269 MOSTLYCLEANFILES += arm_cortex_a8_b_cond arm_cortex_a8_b arm_cortex_a8_bl \
3270         arm_cortex_a8_blx arm_cortex_a8_local arm_cortex_a8_local_reloc
3271
3272 check_SCRIPTS += arm_exidx_test.sh
3273 check_DATA += arm_exidx_test.stdout
3274
3275 arm_exidx_test.stdout: arm_exidx_test.so
3276         $(TEST_READELF) -Sr $< > $@
3277
3278 arm_exidx_test.so: arm_exidx_test.o ../ld-new
3279         ../ld-new -shared -o $@ $<
3280
3281 arm_exidx_test.o: arm_exidx_test.s
3282         $(TEST_AS) -o $@ $<
3283
3284 check_SCRIPTS += pr12826.sh
3285 check_DATA += pr12826.stdout
3286
3287 pr12826.stdout: pr12826.so
3288         $(TEST_READELF) -A $< > $@
3289
3290 pr12826.so: pr12826_1.o pr12826_2.o ../ld-new
3291         ../ld-new -shared -o $@ $<
3292
3293 pr12826_1.o: pr12826_1.s
3294         $(TEST_AS) -o $@ $<
3295
3296 pr12826_2.o: pr12826_2.s
3297         $(TEST_AS) -o $@ $<
3298
3299 check_SCRIPTS += arm_unaligned_reloc.sh
3300 check_DATA += arm_unaligned_reloc.stdout arm_unaligned_reloc_r.stdout
3301
3302 arm_unaligned_reloc.stdout: arm_unaligned_reloc
3303         $(TEST_OBJDUMP) -D $< > $@
3304
3305 arm_unaligned_reloc_r.stdout: arm_unaligned_reloc_r
3306         $(TEST_OBJDUMP) -Dr $< > $@
3307
3308 arm_unaligned_reloc: arm_unaligned_reloc.o ../ld-new
3309         ../ld-new -o $@ $<
3310
3311 arm_unaligned_reloc_r: arm_unaligned_reloc.o ../ld-new
3312         ../ld-new -r -o $@ $<
3313
3314 arm_unaligned_reloc.o: arm_unaligned_reloc.s
3315         $(TEST_AS) -o $@ $<
3316
3317 MOSTLYCLEANFILES += arm_unaligned_reloc arm_unaligned_reloc_r
3318
3319 # Check ARM to ARM farcall veneers
3320
3321 check_SCRIPTS += arm_farcall_arm_arm.sh
3322 check_DATA += arm_farcall_arm_arm.stdout
3323
3324 arm_farcall_arm_arm.stdout: arm_farcall_arm_arm
3325         $(TEST_OBJDUMP) -d $< > $@
3326
3327 arm_farcall_arm_arm: arm_farcall_arm_arm.o ../ld-new
3328         ../ld-new --no-fix-arm1176 --section-start .text=0x1000 --section-start .foo=0x2001020 -o $@ $<
3329
3330 arm_farcall_arm_arm.o: arm_farcall_arm_arm.s
3331         $(TEST_AS) -o $@ $<
3332
3333 MOSTLYCLEANFILES += arm_farcall_arm_arm
3334
3335 # Check ARM to Thumb farcall veneers
3336
3337 check_SCRIPTS += arm_farcall_arm_thumb.sh
3338 check_DATA += arm_farcall_arm_thumb.stdout arm_farcall_arm_thumb_5t.stdout
3339
3340 arm_farcall_arm_thumb.stdout: arm_farcall_arm_thumb
3341         $(TEST_OBJDUMP) -D $< > $@
3342
3343 arm_farcall_arm_thumb: arm_farcall_arm_thumb.o ../ld-new
3344         ../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3345
3346 arm_farcall_arm_thumb.o: arm_farcall_arm_thumb.s
3347         $(TEST_AS) -o $@ $<
3348
3349 arm_farcall_arm_thumb_5t.stdout: arm_farcall_arm_thumb_5t
3350         $(TEST_OBJDUMP) -D $< > $@
3351
3352 arm_farcall_arm_thumb_5t: arm_farcall_arm_thumb_5t.o ../ld-new
3353         ../ld-new --no-fix-arm1176 --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3354
3355 arm_farcall_arm_thumb_5t.o: arm_farcall_arm_thumb.s
3356         $(TEST_AS) -march=armv5t -o $@ $<
3357
3358 MOSTLYCLEANFILES += arm_farcall_arm_thumb arm_farcall_arm_thumb_5t
3359
3360 # Check Thumb to Thumb farcall veneers
3361
3362 check_SCRIPTS += arm_farcall_thumb_thumb.sh
3363 check_DATA += arm_farcall_thumb_thumb.stdout \
3364               arm_farcall_thumb_thumb_5t.stdout \
3365               arm_farcall_thumb_thumb_7m.stdout \
3366               arm_farcall_thumb_thumb_6m.stdout
3367
3368 arm_farcall_thumb_thumb.stdout: arm_farcall_thumb_thumb
3369         $(TEST_OBJDUMP) -D $< > $@
3370
3371 arm_farcall_thumb_thumb: arm_farcall_thumb_thumb.o ../ld-new
3372         ../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3373
3374 arm_farcall_thumb_thumb.o: arm_farcall_thumb_thumb.s
3375         $(TEST_AS) -march=armv4t -o $@ $<
3376
3377 arm_farcall_thumb_thumb_5t.stdout: arm_farcall_thumb_thumb_5t
3378         $(TEST_OBJDUMP) -D $< > $@
3379
3380 arm_farcall_thumb_thumb_5t: arm_farcall_thumb_thumb_5t.o ../ld-new
3381         ../ld-new --no-fix-arm1176 --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3382
3383 arm_farcall_thumb_thumb_5t.o: arm_farcall_thumb_thumb.s
3384         $(TEST_AS) -march=armv5t -o $@ $<
3385
3386 arm_farcall_thumb_thumb_7m.stdout: arm_farcall_thumb_thumb_7m
3387         $(TEST_OBJDUMP) -D $< > $@
3388
3389 arm_farcall_thumb_thumb_7m: arm_farcall_thumb_thumb_7m.o ../ld-new
3390         ../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3391
3392 arm_farcall_thumb_thumb_7m.o: arm_farcall_thumb_thumb.s
3393         $(TEST_AS) -march=armv7-m -o $@ $<
3394
3395 arm_farcall_thumb_thumb_6m.stdout: arm_farcall_thumb_thumb_6m
3396         $(TEST_OBJDUMP) -D $< > $@
3397
3398 arm_farcall_thumb_thumb_6m: arm_farcall_thumb_thumb_6m.o ../ld-new
3399         ../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3400
3401 arm_farcall_thumb_thumb_6m.o: arm_farcall_thumb_thumb.s
3402         $(TEST_AS) -march=armv6-m -o $@ $<
3403
3404 MOSTLYCLEANFILES += arm_farcall_thumb_thumb arm_farcall_thumb_thumb_5t \
3405                     arm_farcall_thumb_thumb_7m arm_farcall_thumb_thumb_6m
3406
3407 # Check Thumb to ARM farcall veneers
3408
3409 check_SCRIPTS += arm_farcall_thumb_arm.sh
3410 check_DATA += arm_farcall_thumb_arm.stdout \
3411               arm_farcall_thumb_arm_5t.stdout
3412
3413 arm_farcall_thumb_arm.stdout: arm_farcall_thumb_arm
3414         $(TEST_OBJDUMP) -D $< > $@
3415
3416 arm_farcall_thumb_arm: arm_farcall_thumb_arm.o ../ld-new
3417         ../ld-new --section-start .text=0x1c01010 --section-start .foo=0x2001014 -o $@ $<
3418
3419 arm_farcall_thumb_arm.o: arm_farcall_thumb_arm.s
3420         $(TEST_AS) -o $@ $<
3421
3422 arm_farcall_thumb_arm_5t.stdout: arm_farcall_thumb_arm_5t
3423         $(TEST_OBJDUMP) -D $< > $@
3424
3425 arm_farcall_thumb_arm_5t: arm_farcall_thumb_arm_5t.o ../ld-new
3426         ../ld-new --no-fix-arm1176 --section-start .text=0x1c01010 --section-start .foo=0x2001014 -o $@ $<
3427
3428 arm_farcall_thumb_arm_5t.o: arm_farcall_thumb_arm.s
3429         $(TEST_AS) -march=armv5t -o $@ $<
3430
3431 MOSTLYCLEANFILES += arm_farcall_thumb_arm arm_farcall_thumb_arm_5t
3432
3433 endif DEFAULT_TARGET_ARM
3434
3435 if DEFAULT_TARGET_S390
3436
3437 check_SCRIPTS += split_s390.sh
3438 check_DATA += split_s390_z1.stdout split_s390_z2.stdout split_s390_z3.stdout \
3439         split_s390_z4.stdout split_s390_n1.stdout split_s390_n2.stdout \
3440         split_s390_a1.stdout split_s390_a2.stdout split_s390_z1_ns.stdout \
3441         split_s390_z2_ns.stdout split_s390_z3_ns.stdout split_s390_z4_ns.stdout \
3442         split_s390_n1_ns.stdout split_s390_n2_ns.stdout split_s390_r.stdout \
3443         split_s390x_z1.stdout split_s390x_z2.stdout split_s390x_z3.stdout \
3444         split_s390x_z4.stdout split_s390x_n1.stdout split_s390x_n2.stdout \
3445         split_s390x_a1.stdout split_s390x_a2.stdout split_s390x_z1_ns.stdout \
3446         split_s390x_z2_ns.stdout split_s390x_z3_ns.stdout \
3447         split_s390x_z4_ns.stdout split_s390x_n1_ns.stdout \
3448         split_s390x_n2_ns.stdout split_s390x_r.stdout
3449 SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
3450 split_s390_1_z1.o: split_s390_1_z1.s
3451         $(TEST_AS) -m31 -o $@ $<
3452 split_s390_1_z2.o: split_s390_1_z2.s
3453         $(TEST_AS) -m31 -o $@ $<
3454 split_s390_1_z3.o: split_s390_1_z3.s
3455         $(TEST_AS) -m31 -o $@ $<
3456 split_s390_1_z4.o: split_s390_1_z4.s
3457         $(TEST_AS) -m31 -o $@ $<
3458 split_s390_1_n1.o: split_s390_1_n1.s
3459         $(TEST_AS) -m31 -o $@ $<
3460 split_s390_1_n2.o: split_s390_1_n2.s
3461         $(TEST_AS) -m31 -o $@ $<
3462 split_s390_1_a1.o: split_s390_1_a1.s
3463         $(TEST_AS) -m31 -o $@ $<
3464 split_s390_1_a2.o: split_s390_1_a2.s
3465         $(TEST_AS) -m31 -o $@ $<
3466 split_s390_2_s.o: split_s390_2_s.s
3467         $(TEST_AS) -m31 -o $@ $<
3468 split_s390_2_ns.o: split_s390_2_ns.s
3469         $(TEST_AS) -m31 -o $@ $<
3470 split_s390_z1: split_s390_1_z1.o split_s390_2_s.o ../ld-new
3471         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_z1.o split_s390_2_s.o
3472 split_s390_z1.stdout: split_s390_z1
3473         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3474 split_s390_z2: split_s390_1_z2.o split_s390_2_s.o ../ld-new
3475         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_z2.o split_s390_2_s.o
3476 split_s390_z2.stdout: split_s390_z2
3477         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3478 split_s390_z3: split_s390_1_z3.o split_s390_2_s.o ../ld-new
3479         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_z3.o split_s390_2_s.o
3480 split_s390_z3.stdout: split_s390_z3
3481         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3482 split_s390_z4: split_s390_1_z4.o split_s390_2_s.o ../ld-new
3483         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_z4.o split_s390_2_s.o
3484 split_s390_z4.stdout: split_s390_z4
3485         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3486 split_s390_n1: split_s390_1_n1.o split_s390_2_s.o ../ld-new
3487         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_n1.o split_s390_2_s.o
3488 split_s390_n1.stdout: split_s390_n1
3489         $(TEST_OBJDUMP) -d $< > $@
3490 split_s390_n2: split_s390_1_n2.o split_s390_2_s.o ../ld-new
3491         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_n2.o split_s390_2_s.o
3492 split_s390_n2.stdout: split_s390_n2
3493         $(TEST_OBJDUMP) -d $< > $@
3494 split_s390_z1_ns: split_s390_1_z1.o split_s390_2_ns.o ../ld-new
3495         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_z1.o split_s390_2_ns.o
3496 split_s390_z1_ns.stdout: split_s390_z1_ns
3497         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3498 split_s390_z2_ns: split_s390_1_z2.o split_s390_2_ns.o ../ld-new
3499         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_z2.o split_s390_2_ns.o
3500 split_s390_z2_ns.stdout: split_s390_z2_ns
3501         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3502 split_s390_z3_ns: split_s390_1_z3.o split_s390_2_ns.o ../ld-new
3503         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_z3.o split_s390_2_ns.o
3504 split_s390_z3_ns.stdout: split_s390_z3_ns
3505         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3506 split_s390_z4_ns: split_s390_1_z4.o split_s390_2_ns.o ../ld-new
3507         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_z4.o split_s390_2_ns.o
3508 split_s390_z4_ns.stdout: split_s390_z4_ns
3509         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3510 split_s390_n1_ns: split_s390_1_n1.o split_s390_2_ns.o ../ld-new
3511         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_n1.o split_s390_2_ns.o
3512 split_s390_n1_ns.stdout: split_s390_n1_ns
3513         $(TEST_OBJDUMP) -d $< > $@
3514 split_s390_n2_ns.stdout: split_s390_1_n2.o split_s390_2_ns.o ../ld-new
3515         ../ld-new $(SPLIT_DEFSYMS) -o split_s390_n2 split_s390_1_n2.o split_s390_2_ns.o > $@ 2>&1 || exit 0
3516 split_s390_a1.stdout: split_s390_1_a1.o split_s390_2_ns.o ../ld-new
3517         ../ld-new $(SPLIT_DEFSYMS) -o split_s390_a1 split_s390_1_a1.o split_s390_2_ns.o > $@ 2>&1 || exit 0
3518 split_s390_a2: split_s390_1_a2.o split_s390_2_ns.o ../ld-new
3519         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390_1_a2.o split_s390_2_ns.o
3520 split_s390_a2.stdout: split_s390_a2
3521         $(TEST_OBJDUMP) -d $< > $@
3522 split_s390_r.stdout: split_s390_1_z1.o split_s390_2_ns.o ../ld-new
3523         ../ld-new -r split_s390_1_z1.o split_s390_2_ns.o -o split_s390_r > $@ 2>&1 || exit 0
3524 split_s390x_1_z1.o: split_s390x_1_z1.s
3525         $(TEST_AS) -m64 -o $@ $<
3526 split_s390x_1_z2.o: split_s390x_1_z2.s
3527         $(TEST_AS) -m64 -o $@ $<
3528 split_s390x_1_z3.o: split_s390x_1_z3.s
3529         $(TEST_AS) -m64 -o $@ $<
3530 split_s390x_1_z4.o: split_s390x_1_z4.s
3531         $(TEST_AS) -m64 -o $@ $<
3532 split_s390x_1_n1.o: split_s390x_1_n1.s
3533         $(TEST_AS) -m64 -o $@ $<
3534 split_s390x_1_n2.o: split_s390x_1_n2.s
3535         $(TEST_AS) -m64 -o $@ $<
3536 split_s390x_1_a1.o: split_s390x_1_a1.s
3537         $(TEST_AS) -m64 -o $@ $<
3538 split_s390x_1_a2.o: split_s390x_1_a2.s
3539         $(TEST_AS) -m64 -o $@ $<
3540 split_s390x_2_s.o: split_s390x_2_s.s
3541         $(TEST_AS) -m64 -o $@ $<
3542 split_s390x_2_ns.o: split_s390x_2_ns.s
3543         $(TEST_AS) -m64 -o $@ $<
3544 split_s390x_z1: split_s390x_1_z1.o split_s390x_2_s.o ../ld-new
3545         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_z1.o split_s390x_2_s.o
3546 split_s390x_z1.stdout: split_s390x_z1
3547         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3548 split_s390x_z2: split_s390x_1_z2.o split_s390x_2_s.o ../ld-new
3549         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_z2.o split_s390x_2_s.o
3550 split_s390x_z2.stdout: split_s390x_z2
3551         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3552 split_s390x_z3: split_s390x_1_z3.o split_s390x_2_s.o ../ld-new
3553         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_z3.o split_s390x_2_s.o
3554 split_s390x_z3.stdout: split_s390x_z3
3555         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3556 split_s390x_z4: split_s390x_1_z4.o split_s390x_2_s.o ../ld-new
3557         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_z4.o split_s390x_2_s.o
3558 split_s390x_z4.stdout: split_s390x_z4
3559         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3560 split_s390x_n1: split_s390x_1_n1.o split_s390x_2_s.o ../ld-new
3561         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_n1.o split_s390x_2_s.o
3562 split_s390x_n1.stdout: split_s390x_n1
3563         $(TEST_OBJDUMP) -d $< > $@
3564 split_s390x_n2: split_s390x_1_n2.o split_s390x_2_s.o ../ld-new
3565         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_n2.o split_s390x_2_s.o
3566 split_s390x_n2.stdout: split_s390x_n2
3567         $(TEST_OBJDUMP) -d $< > $@
3568 split_s390x_z1_ns: split_s390x_1_z1.o split_s390x_2_ns.o ../ld-new
3569         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_z1.o split_s390x_2_ns.o
3570 split_s390x_z1_ns.stdout: split_s390x_z1_ns
3571         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3572 split_s390x_z2_ns: split_s390x_1_z2.o split_s390x_2_ns.o ../ld-new
3573         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_z2.o split_s390x_2_ns.o
3574 split_s390x_z2_ns.stdout: split_s390x_z2_ns
3575         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3576 split_s390x_z3_ns: split_s390x_1_z3.o split_s390x_2_ns.o ../ld-new
3577         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_z3.o split_s390x_2_ns.o
3578 split_s390x_z3_ns.stdout: split_s390x_z3_ns
3579         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3580 split_s390x_z4_ns: split_s390x_1_z4.o split_s390x_2_ns.o ../ld-new
3581         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_z4.o split_s390x_2_ns.o
3582 split_s390x_z4_ns.stdout: split_s390x_z4_ns
3583         $(TEST_OBJDUMP) -j .rodata -j .text -D $< > $@
3584 split_s390x_n1_ns: split_s390x_1_n1.o split_s390x_2_ns.o ../ld-new
3585         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_n1.o split_s390x_2_ns.o
3586 split_s390x_n1_ns.stdout: split_s390x_n1_ns
3587         $(TEST_OBJDUMP) -d $< > $@
3588 split_s390x_n2_ns.stdout: split_s390x_1_n2.o split_s390x_2_ns.o ../ld-new
3589         ../ld-new $(SPLIT_DEFSYMS) -o split_s390x_n2 split_s390x_1_n2.o split_s390x_2_ns.o > $@ 2>&1 || exit 0
3590 split_s390x_a1.stdout: split_s390x_1_a1.o split_s390x_2_ns.o ../ld-new
3591         ../ld-new $(SPLIT_DEFSYMS) -o split_s390x_a1 split_s390x_1_a1.o split_s390x_2_ns.o > $@ 2>&1 || exit 0
3592 split_s390x_a2: split_s390x_1_a2.o split_s390x_2_ns.o ../ld-new
3593         ../ld-new $(SPLIT_DEFSYMS) -o $@ split_s390x_1_a2.o split_s390x_2_ns.o
3594 split_s390x_a2.stdout: split_s390x_a2
3595         $(TEST_OBJDUMP) -d $< > $@
3596 split_s390x_r.stdout: split_s390x_1_z1.o split_s390x_2_ns.o ../ld-new
3597         ../ld-new -r split_s390x_1_z1.o split_s390x_2_ns.o -o split_s390x_r > $@ 2>&1 || exit 0
3598 MOSTLYCLEANFILES += split_s390_z1 split_s390_z2 split_s390_z3 \
3599         split_s390_z4 split_s390_n1 split_s390_n2 split_s390_a1 \
3600         split_s390_a2 split_s390_z1_ns split_s390_z2_ns split_s390_z3_ns \
3601         split_s390_z4_ns split_s390_n1_ns split_s390_n2_ns split_s390_r \
3602         split_s390x_z1 split_s390x_z2 split_s390x_z3 split_s390x_z4 \
3603         split_s390x_n1 split_s390x_n2 split_s390x_a1 split_s390x_a2 \
3604         split_s390x_z1_ns split_s390x_z2_ns split_s390x_z3_ns \
3605         split_s390x_z4_ns split_s390x_n1_ns split_s390x_n2_ns split_s390x_r
3606
3607 endif DEFAULT_TARGET_S390
3608
3609 endif NATIVE_OR_CROSS_LINKER
3610
3611 # Tests for the dwp tool.
3612 # We don't want to rely yet on GCC support for -gsplit-dwarf,
3613 # so we use (for now) test cases in x86 assembly language,
3614 # compiled from the dwp_test_*.cc sources.
3615
3616 if DEFAULT_TARGET_X86_64
3617
3618 dwp_test_main.o: dwp_test_main.s
3619         $(TEST_AS) -o $@ $<
3620 dwp_test_1.o: dwp_test_1.s
3621         $(TEST_AS) -o $@ $<
3622 dwp_test_1b.o: dwp_test_1b.s
3623         $(TEST_AS) -o $@ $<
3624 dwp_test_2.o: dwp_test_2.s
3625         $(TEST_AS) -o $@ $<
3626
3627 dwp_test_main.dwo: dwp_test_main.o
3628         $(TEST_OBJCOPY) --extract-dwo $< $@
3629 dwp_test_1.dwo: dwp_test_1.o
3630         $(TEST_OBJCOPY) --extract-dwo $< $@
3631 dwp_test_1b.dwo: dwp_test_1b.o
3632         $(TEST_OBJCOPY) --extract-dwo $< $@
3633 dwp_test_2.dwo: dwp_test_2.o
3634         $(TEST_OBJCOPY) --extract-dwo $< $@
3635
3636 MOSTLYCLEANFILES += *.dwo *.dwp
3637 check_SCRIPTS += dwp_test_1.sh
3638 check_DATA += dwp_test_1.stdout
3639 dwp_test_1.stdout: dwp_test_1.dwp
3640         $(TEST_READELF) -wi $< > $@
3641 dwp_test_1.dwp: ../dwp dwp_test_main.dwo dwp_test_1.dwo dwp_test_1b.dwo dwp_test_2.dwo
3642         ../dwp -o $@ dwp_test_main.dwo dwp_test_1.dwo dwp_test_1b.dwo dwp_test_2.dwo
3643
3644 check_SCRIPTS += dwp_test_2.sh
3645 check_DATA += dwp_test_2.stdout
3646 dwp_test_2.stdout: dwp_test_2.dwp
3647         $(TEST_READELF) -wi $< > $@
3648 dwp_test_2.dwp: ../dwp dwp_test_2a.dwp dwp_test_2b.dwp
3649         ../dwp -o $@ dwp_test_2a.dwp dwp_test_2b.dwp
3650 dwp_test_2a.dwp: ../dwp dwp_test_main.dwo dwp_test_1.dwo
3651         ../dwp -o $@ dwp_test_main.dwo dwp_test_1.dwo
3652 dwp_test_2b.dwp: ../dwp dwp_test_1b.dwo dwp_test_2.dwo
3653         ../dwp -o $@ dwp_test_1b.dwo dwp_test_2.dwo
3654
3655 endif DEFAULT_TARGET_X86_64