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