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