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