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