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