• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_X86_64
980
981check_PROGRAMS += pr17704a_test
982pr17704a_test.o: pr17704a_test.s
983	$(TEST_AS) --64  -o $@ $<
984pr17704a_test: pr17704a_test.o gcctestdir/ld
985	gcctestdir/ld --icf=all -o $@ $<
986
987endif DEFAULT_TARGET_X86_64
988
989if DEFAULT_TARGET_I386
990
991check_SCRIPTS += i386_mov_to_lea.sh
992check_DATA += i386_mov_to_lea1.stdout  i386_mov_to_lea2.stdout \
993	i386_mov_to_lea3.stdout  i386_mov_to_lea4.stdout \
994	i386_mov_to_lea5.stdout i386_mov_to_lea6.stdout \
995	i386_mov_to_lea7.stdout i386_mov_to_lea8.stdout
996MOSTLYCLEANFILES += i386_mov_to_lea1 i386_mov_to_lea2 i386_mov_to_lea3 \
997	i386_mov_to_lea4 i386_mov_to_lea5 i386_mov_to_lea6 \
998	i386_mov_to_lea7 i386_mov_to_lea8
999
1000i386_mov_to_lea1.o: i386_mov_to_lea1.s
1001	$(TEST_AS) --32 -o $@ $<
1002i386_mov_to_lea2.o: i386_mov_to_lea2.s
1003	$(TEST_AS) --32 -o $@ $<
1004i386_mov_to_lea3.o: i386_mov_to_lea3.s
1005	$(TEST_AS) --32 -o $@ $<
1006i386_mov_to_lea4.o: i386_mov_to_lea4.s
1007	$(TEST_AS) --32 -o $@ $<
1008i386_mov_to_lea5.o: i386_mov_to_lea5.s
1009	$(TEST_AS) --32 -o $@ $<
1010i386_mov_to_lea1: i386_mov_to_lea1.o
1011	../ld-new -Bsymbolic -shared -melf_i386  -o $@ $<
1012i386_mov_to_lea2: i386_mov_to_lea1.o
1013	../ld-new  -pie -melf_i386  -o $@ $<
1014i386_mov_to_lea3: i386_mov_to_lea1.o
1015	../ld-new -melf_i386  -o $@ $<
1016i386_mov_to_lea4: i386_mov_to_lea1.o
1017	../ld-new -melf_i386 -shared  -o $@ $<
1018i386_mov_to_lea5: i386_mov_to_lea2.o
1019	../ld-new -melf_i386 -shared  -o $@ $<
1020i386_mov_to_lea6: i386_mov_to_lea3.o
1021	../ld-new -melf_i386 -shared  -o $@ $<
1022i386_mov_to_lea7: i386_mov_to_lea4.o
1023	../ld-new -melf_i386 -shared  -o $@ $<
1024i386_mov_to_lea8: i386_mov_to_lea5.o
1025	../ld-new -melf_i386 -shared  -o $@ $<
1026i386_mov_to_lea1.stdout: i386_mov_to_lea1
1027	$(TEST_OBJDUMP) -dw $< > $@
1028i386_mov_to_lea2.stdout: i386_mov_to_lea2
1029	$(TEST_OBJDUMP) -dw $< > $@
1030i386_mov_to_lea3.stdout: i386_mov_to_lea3
1031	$(TEST_OBJDUMP) -dw $< > $@
1032i386_mov_to_lea4.stdout: i386_mov_to_lea4
1033	$(TEST_OBJDUMP) -dw $< > $@
1034i386_mov_to_lea5.stdout: i386_mov_to_lea5
1035	$(TEST_OBJDUMP) -dw $< > $@
1036i386_mov_to_lea6.stdout: i386_mov_to_lea6
1037	$(TEST_OBJDUMP) -dw $< > $@
1038i386_mov_to_lea7.stdout: i386_mov_to_lea7
1039	$(TEST_OBJDUMP) -dw $< > $@
1040i386_mov_to_lea8.stdout: i386_mov_to_lea8
1041	$(TEST_OBJDUMP) -dw $< > $@
1042
1043endif DEFAULT_TARGET_I386
1044
1045check_PROGRAMS += many_sections_test
1046many_sections_test_SOURCES = many_sections_test.cc
1047many_sections_test_DEPENDENCIES = gcctestdir/ld
1048many_sections_test_LDFLAGS = -Bgcctestdir/ -rdynamic
1049many_sections_test_LDADD =
1050
1051BUILT_SOURCES += many_sections_define.h
1052MOSTLYCLEANFILES += many_sections_define.h
1053many_sections_define.h:
1054	(for i in `seq 1 70000`; do \
1055	   echo "int var_$$i __attribute__((section(\"section_$$i\"))) = $$i;"; \
1056	 done) > $@.tmp
1057	mv -f $@.tmp $@
1058
1059BUILT_SOURCES += many_sections_check.h
1060MOSTLYCLEANFILES += many_sections_check.h
1061many_sections_check.h:
1062	(for i in `seq 1 1000 70000`; do \
1063	   echo "assert(var_$$i == $$i);"; \
1064	 done) > $@.tmp
1065	mv -f $@.tmp $@
1066
1067check_PROGRAMS += many_sections_r_test
1068many_sections_r_test.o: many_sections_test.o gcctestdir/ld
1069	gcctestdir/ld -r -o $@ many_sections_test.o
1070many_sections_r_test: many_sections_r_test.o gcctestdir/ld
1071	$(CXXLINK) -Bgcctestdir/ many_sections_r_test.o $(LIBS)
1072
1073check_PROGRAMS += initpri1
1074initpri1_SOURCES = initpri1.c
1075initpri1_DEPENDENCIES = gcctestdir/ld
1076initpri1_LDFLAGS = -Bgcctestdir/
1077initpri1_LDADD =
1078
1079check_PROGRAMS += initpri2
1080initpri2_SOURCES = initpri2.c
1081initpri2_DEPENDENCIES = gcctestdir/ld
1082initpri2_LDFLAGS = -Bgcctestdir/ -Wl,--ctors-in-init-array
1083initpri2_LDADD =
1084
1085check_PROGRAMS += initpri3a
1086initpri3a_SOURCES = initpri3.c
1087initpri3a_DEPENDENCIES = gcctestdir/ld
1088initpri3a_LDFLAGS = -Bgcctestdir/
1089initpri3a_LDADD =
1090
1091# This test fails on targets not using .ctors and .dtors sections (e.g. ARM
1092# EABI). Given that gcc is moving towards using .init_array in all cases,
1093# this test is commented out.  A better fix would be checking whether gcc
1094# uses .ctors or .init_array sections in configure.
1095
1096# check_PROGRAMS += initpri3b
1097# initpri3b_SOURCES = initpri3.c
1098# initpri3b_DEPENDENCIES = gcctestdir/ld
1099# initpri3b_LDFLAGS = -Bgcctestdir/ -Wl,--no-ctors-in-init-array
1100# initpri3b_LDADD =
1101
1102# Test --detect-odr-violations
1103check_SCRIPTS += debug_msg.sh
1104
1105# Create the data files that debug_msg.sh analyzes.
1106check_DATA += debug_msg.err
1107MOSTLYCLEANFILES += debug_msg.err
1108debug_msg.o: debug_msg.cc
1109	$(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/debug_msg.cc
1110odr_violation1.o: odr_violation1.cc
1111	$(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/odr_violation1.cc
1112# Compile with different optimization flags to check that rearranged
1113# instructions don't cause a false positive.
1114odr_violation2.o: odr_violation2.cc
1115	$(CXXCOMPILE) -O2 -g -c -w -o $@ $(srcdir)/odr_violation2.cc
1116debug_msg.err: debug_msg.o odr_violation1.o odr_violation2.o gcctestdir/ld
1117	@echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o "2>$@"
1118	@if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o 2>$@; \
1119	then \
1120	  echo 1>&2 "Link of debug_msg should have failed"; \
1121	  rm -f $@; \
1122	  exit 1; \
1123	fi
1124
1125# Test error message when a vtable is undefined.
1126check_SCRIPTS += missing_key_func.sh
1127check_DATA += missing_key_func.err
1128MOSTLYCLEANFILES += missing_key_func.err
1129missing_key_func.o: missing_key_func.cc
1130	$(CXXCOMPILE) -O0 -g -c -o $@ $(srcdir)/missing_key_func.cc
1131missing_key_func.err: missing_key_func.o gcctestdir/ld
1132	@echo $(CXXLINK) -Bgcctestdir/ -o missing_key_func missing_key_func.o "2>$@"
1133	@if $(CXXLINK) -Bgcctestdir/ -o missing_key_func missing_key_func.o 2>$@; \
1134	then \
1135	  echo 1>&2 "Link of missing_key_func should have failed"; \
1136	  rm -f $@; \
1137	  exit 1; \
1138	fi
1139
1140if HAVE_ZLIB
1141
1142# Check that --detect-odr-violations works with compressed debug sections.
1143check_DATA += debug_msg_cdebug.err
1144MOSTLYCLEANFILES += debug_msg_cdebug.err
1145debug_msg_cdebug.o: debug_msg.cc gcctestdir/as
1146	$(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/debug_msg.cc
1147odr_violation1_cdebug.o: odr_violation1.cc gcctestdir/as
1148	$(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/odr_violation1.cc
1149odr_violation2_cdebug.o: odr_violation2.cc gcctestdir/as
1150	$(CXXCOMPILE) -Bgcctestdir/ -O2 -g -Wa,--compress-debug-sections -c -w -o $@ $(srcdir)/odr_violation2.cc
1151debug_msg_cdebug.err: debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o gcctestdir/ld
1152	@echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o "2>$@"
1153	@if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_cdebug debug_msg_cdebug.o odr_violation1_cdebug.o odr_violation2_cdebug.o 2>$@; \
1154	then \
1155	  echo 1>&2 "Link of debug_msg_cdebug should have failed"; \
1156	  rm -f $@; \
1157	  exit 1; \
1158	fi
1159
1160endif HAVE_ZLIB
1161
1162# See if we can also detect problems when we're linking .so's, not .o's.
1163check_DATA += debug_msg_so.err
1164MOSTLYCLEANFILES += debug_msg_so.err
1165debug_msg.so: debug_msg.cc gcctestdir/ld
1166	$(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
1167odr_violation1.so: odr_violation1.cc gcctestdir/ld
1168	$(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
1169odr_violation2.so: odr_violation2.cc gcctestdir/ld
1170	$(CXXCOMPILE) -Bgcctestdir/ -O2 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
1171debug_msg_so.err: debug_msg.so odr_violation1.so odr_violation2.so gcctestdir/ld
1172	@echo $(CXXLINK_S) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so "2>$@"
1173	@if $(CXXLINK_S) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so 2>$@; \
1174	then \
1175	  echo 1>&2 "Link of debug_msg_so should have failed"; \
1176	  rm -f $@; \
1177	  exit 1; \
1178	fi
1179
1180# We also want to make sure we do something reasonable when there's no
1181# debug info available.  For the best test, we use .so's.
1182check_DATA += debug_msg_ndebug.err
1183MOSTLYCLEANFILES += debug_msg_ndebug.err
1184debug_msg_ndebug.so: debug_msg.cc gcctestdir/ld
1185	$(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
1186odr_violation1_ndebug.so: odr_violation1.cc gcctestdir/ld
1187	$(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
1188odr_violation2_ndebug.so: odr_violation2.cc gcctestdir/ld
1189	$(CXXCOMPILE) -Bgcctestdir/ -O2 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
1190debug_msg_ndebug.err: debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so gcctestdir/ld
1191	@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>$@"
1192	@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>$@; \
1193	then \
1194	  echo 1>&2 "Link of debug_msg_ndebug should have failed"; \
1195	  rm -f $@; \
1196	  exit 1; \
1197	fi
1198
1199
1200# Similar to --detect-odr-violations: check for undefined symbols in .so's
1201check_SCRIPTS += undef_symbol.sh
1202check_DATA += undef_symbol.err
1203MOSTLYCLEANFILES += undef_symbol.err
1204undef_symbol.o: undef_symbol.cc
1205	$(CXXCOMPILE) -O0 -g -c -fPIC $<
1206undef_symbol.so: undef_symbol.o gcctestdir/ld
1207	$(CXXLINK) -Bgcctestdir/ -shared undef_symbol.o
1208undef_symbol.err: undef_symbol_main.o undef_symbol.so gcctestdir/ld
1209	@echo $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so "2>$@"
1210	@if $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so 2>$@; \
1211	then \
1212	  echo 1>&2 "Link of undef_symbol_test should have failed"; \
1213	  rm -f $@; \
1214	  exit 1; \
1215	fi
1216
1217
1218# Test -o when emitting to a special file (such as something in /dev).
1219check_PROGRAMS += flagstest_o_specialfile
1220flagstest_o_specialfile: flagstest_debug.o gcctestdir/ld
1221	$(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< 2>&1 | cat > $@
1222	chmod a+x $@
1223	test -s $@
1224
1225if HAVE_ZLIB
1226
1227# Test --compress-debug-sections.  FIXME: check we actually compress.
1228check_PROGRAMS += flagstest_compress_debug_sections
1229flagstest_compress_debug_sections: flagstest_debug.o gcctestdir/ld
1230	$(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,--compress-debug-sections=zlib
1231	test -s $@
1232
1233
1234# The specialfile output has a tricky case when we also compress debug
1235# sections, because it requires output-file resizing.
1236check_PROGRAMS += flagstest_o_specialfile_and_compress_debug_sections
1237flagstest_o_specialfile_and_compress_debug_sections: flagstest_debug.o \
1238		gcctestdir/ld
1239	$(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< -Wl,--compress-debug-sections=zlib 2>&1 | cat > $@
1240	chmod a+x $@
1241	test -s $@
1242
1243endif HAVE_ZLIB
1244
1245# Test -TText and -Tdata.
1246check_PROGRAMS += flagstest_o_ttext_1
1247flagstest_o_ttext_1: flagstest_debug.o gcctestdir/ld
1248	$(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,-Ttext,0x400000 -Wl,-Tdata,0x800000
1249
1250# This version won't be runnable, because there is no way to put the
1251# PT_PHDR segment at file offset 0.  We just make sure that we can
1252# build it without error.
1253check_DATA += flagstest_o_ttext_2
1254MOSTLYCLEANFILES += flagstest_o_ttext_2
1255flagstest_o_ttext_2: flagstest_debug.o gcctestdir/ld
1256	$(CXXLINK) -Bgcctestdir/ -o $@ $< -Wl,-Ttext,0x400010 -Wl,-Tdata,0x800010
1257
1258# Test symbol versioning.
1259check_PROGRAMS += ver_test
1260ver_test_SOURCES = ver_test_main.cc
1261ver_test_DEPENDENCIES = gcctestdir/ld ver_test_1.so ver_test_2.so ver_test_4.so
1262ver_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1263ver_test_LDADD = ver_test_1.so ver_test_2.so ver_test_4.so
1264ver_test_1.so: ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so gcctestdir/ld
1265	$(CXXLINK) -Bgcctestdir/ -shared ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so
1266ver_test_2.so: ver_test_2.o $(srcdir)/ver_test_2.script ver_test_4.so gcctestdir/ld
1267	$(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_2.script -Wl,-R,. ver_test_2.o ver_test_4.so
1268ver_test_4.so: ver_test_4.o $(srcdir)/ver_test_4.script gcctestdir/ld
1269	$(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o
1270ver_test_1.o: ver_test_1.cc
1271	$(CXXCOMPILE) -c -fpic -o $@ $<
1272ver_test_2.o: ver_test_2.cc
1273	$(CXXCOMPILE) -c -fpic -o $@ $<
1274ver_test_3.o: ver_test_3.cc
1275	$(CXXCOMPILE) -c -fpic -o $@ $<
1276ver_test_4.o: ver_test_4.cc
1277	$(CXXCOMPILE) -c -fpic -o $@ $<
1278
1279check_SCRIPTS += ver_test_1.sh
1280check_DATA += ver_test_1.syms
1281ver_test_1.syms: ver_test_1.so
1282	$(TEST_READELF) -s $< >$@ 2>/dev/null
1283
1284check_PROGRAMS += ver_test_2
1285ver_test_2_SOURCES = ver_test_main_2.cc
1286ver_test_2_DEPENDENCIES = gcctestdir/ld ver_test_4.so ver_test_2.so
1287ver_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1288ver_test_2_LDADD = ver_test_4.so ver_test_2.so
1289
1290check_SCRIPTS += ver_test_2.sh
1291check_DATA += ver_test_2.syms
1292ver_test_2.syms: ver_test_2
1293	$(TEST_READELF) -s $< >$@ 2>/dev/null
1294
1295check_SCRIPTS += ver_test_4.sh
1296check_DATA += ver_test_4.syms
1297ver_test_4.syms: ver_test_4.so
1298	$(TEST_READELF) -s $< >$@ 2>/dev/null
1299
1300ver_test_5.so: ver_test_5.o $(srcdir)/ver_test_5.script ver_test_4.so gcctestdir/ld
1301	$(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_5.script ver_test_5.o ver_test_4.so
1302ver_test_5.o: ver_test_5.cc
1303	$(CXXCOMPILE) -c -fpic -o $@ $<
1304check_SCRIPTS += ver_test_5.sh
1305check_DATA += ver_test_5.syms
1306ver_test_5.syms: ver_test_5.so
1307	$(TEST_READELF) -s $< >$@ 2>/dev/null
1308
1309check_PROGRAMS += ver_test_6
1310ver_test_6_SOURCES = ver_test_6.c
1311ver_test_6_DEPENDENCIES = gcctestdir/ld ver_test_2.so
1312ver_test_6_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1313ver_test_6_LDADD = ver_test_2.so
1314
1315ver_test_7.so: ver_test_4.o $(srcdir)/ver_test_4.script ver_test_7.o gcctestdir/ld
1316	$(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o ver_test_7.o
1317ver_test_7.o: ver_test_7.cc
1318	$(CXXCOMPILE) -c -fpic -o $@ $<
1319check_SCRIPTS += ver_test_7.sh
1320check_DATA += ver_test_7.syms
1321ver_test_7.syms: ver_test_7.so
1322	$(TEST_READELF) -s $< >$@ 2>/dev/null
1323
1324check_PROGRAMS += ver_test_8
1325ver_test_8_SOURCES = two_file_test_main.cc
1326ver_test_8_DEPENDENCIES = gcctestdir/ld ver_test_8_1.so ver_test_8_2.so
1327ver_test_8_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1328ver_test_8_LDADD = ver_test_8_1.so ver_test_8_2.so
1329ver_test_8_1.so: two_file_test_1_pic.o two_file_test_1b_pic.o ver_test_8_2.so gcctestdir/ld
1330	$(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o ver_test_8_2.so
1331ver_test_8_2.so: two_file_test_2_pic.o $(srcdir)/ver_test_8.script gcctestdir/ld
1332	$(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_8.script two_file_test_2_pic.o
1333
1334check_PROGRAMS += ver_test_9
1335ver_test_9_SOURCES = ver_test_main.cc
1336ver_test_9_DEPENDENCIES = gcctestdir/ld ver_test_9.so
1337ver_test_9_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1338ver_test_9_LDADD = ver_test_9.so
1339ver_test_9.so: ver_test_9.o ver_test_4.so ver_test_5.so gcctestdir/ld
1340	$(CXXLINK) -Bgcctestdir/ -shared -Wl,-R,. ver_test_9.o ver_test_5.so ver_test_4.so
1341ver_test_9.o: ver_test_9.cc
1342	$(CXXCOMPILE) -c -fpic -o $@ $<
1343
1344check_SCRIPTS += ver_test_10.sh
1345check_DATA += ver_test_10.syms
1346ver_test_10.syms: ver_test_10.so
1347	$(TEST_READELF) -s $< >$@ 2>/dev/null
1348ver_test_10.so: gcctestdir/ld ver_test_2.o ver_test_10.script
1349	$(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_10.script ver_test_2.o
1350
1351check_PROGRAMS += ver_test_11
1352MOSTLYCLEANFILES += ver_test_11.a
1353ver_test_11_SOURCES = ver_test_main_2.cc
1354ver_test_11_DEPENDENCIES = gcctestdir/ld ver_test_11.a
1355ver_test_11_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1356ver_test_11_LDADD = ver_test_11.a
1357ver_test_11.a: ver_test_1.o ver_test_2.o ver_test_4.o
1358	$(TEST_AR) rc $@ $^
1359
1360check_PROGRAMS += ver_test_12
1361ver_test_12_SOURCES = ver_test_main_2.cc
1362ver_test_12_DEPENDENCIES = gcctestdir/ld ver_test_12.o
1363ver_test_12_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1364ver_test_12_LDADD = ver_test_12.o
1365ver_test_12.o: gcctestdir/ld ver_test_1.o ver_test_2.o ver_test_4.o
1366	gcctestdir/ld -r -o $@ ver_test_1.o ver_test_2.o ver_test_4.o
1367
1368check_PROGRAMS += protected_1
1369protected_1_SOURCES = \
1370	protected_main_1.cc protected_main_2.cc protected_main_3.cc
1371protected_1_DEPENDENCIES = gcctestdir/ld protected_1.so
1372protected_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1373protected_1_LDADD = protected_1.so
1374
1375protected_1.so: gcctestdir/ld protected_1_pic.o protected_2_pic.o protected_3_pic.o
1376	$(CXXLINK) -Bgcctestdir/ -shared protected_1_pic.o protected_2_pic.o protected_3_pic.o
1377protected_1_pic.o: protected_1.cc
1378	$(CXXCOMPILE) -c -fpic -o $@ $<
1379protected_2_pic.o: protected_2.cc
1380	$(CXXCOMPILE) -c -fpic -o $@ $<
1381protected_3_pic.o: protected_3.cc
1382	$(CXXCOMPILE) -c -fpic -o $@ $<
1383
1384check_PROGRAMS += protected_2
1385protected_2_SOURCES = protected_main_1.cc protected_3.cc
1386protected_2_DEPENDENCIES = gcctestdir/ld protected_1.so
1387protected_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1388protected_2_LDADD = protected_1.so
1389
1390check_DATA += protected_3.err
1391MOSTLYCLEANFILES += protected_3.err
1392protected_4_pic.o: protected_4.cc
1393	$(CXXCOMPILE) -c -fpic -o $@ $<
1394protected_3.err: protected_4_pic.o gcctestdir/ld
1395	@echo $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o "2>$@"
1396	@if $(CXXLINK) -Bgcctestdir/ -shared -o protected_4.so protected_4_pic.o 2>$@; then \
1397	  echo 1>&2 "Link of protected_4.so should have failed"; \
1398	  rm -f $@; \
1399	  exit 1; \
1400	fi
1401
1402check_PROGRAMS += relro_test
1403check_SCRIPTS += relro_test.sh
1404check_DATA += relro_test.stdout
1405relro_test_SOURCES = relro_test_main.cc
1406relro_test_DEPENDENCIES = gcctestdir/ld relro_test.so
1407relro_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1408relro_test_LDADD = relro_test.so
1409relro_test.so: gcctestdir/ld relro_test_pic.o
1410	$(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro relro_test_pic.o
1411relro_test_pic.o: relro_test.cc
1412	$(CXXCOMPILE) -c -fpic -o $@ $<
1413relro_test.stdout: relro_test.so
1414	$(TEST_READELF) -SlW relro_test.so > relro_test.stdout
1415
1416check_PROGRAMS += relro_now_test
1417relro_now_test_SOURCES = relro_test_main.cc
1418relro_now_test_DEPENDENCIES = gcctestdir/ld relro_now_test.so
1419relro_now_test_LDFLAGS = -Bgcctestdir -Wl,-R,. -Wl,-z,relro -Wl,-z,now
1420relro_now_test_LDADD = relro_now_test.so
1421relro_now_test.so: gcctestdir/ld relro_test_pic.o
1422	$(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro -Wl,-z,now relro_test_pic.o
1423
1424check_PROGRAMS += relro_strip_test
1425relro_strip_test_SOURCES = relro_test_main.cc
1426relro_strip_test_DEPENDENCIES = gcctestdir/ld relro_strip_test.so
1427relro_strip_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1428relro_strip_test_LDADD = relro_strip_test.so
1429relro_strip_test.so: relro_test.so
1430	$(TEST_STRIP) -o $@ $<
1431
1432check_PROGRAMS += relro_script_test
1433relro_script_test_SOURCES = relro_test_main.cc
1434relro_script_test_DEPENDENCIES = gcctestdir/ld relro_script_test.so
1435relro_script_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
1436relro_script_test_LDADD = relro_script_test.so
1437relro_script_test.so: gcctestdir/ld relro_script_test.t relro_test_pic.o
1438	$(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro -Wl,-T,$(srcdir)/relro_script_test.t relro_test_pic.o
1439
1440check_PROGRAMS += script_test_1
1441script_test_1_SOURCES = script_test_1.cc
1442script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
1443script_test_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -Wl,-T,$(srcdir)/script_test_1.t
1444script_test_1_LDADD =
1445
1446check_PROGRAMS += script_test_2
1447script_test_2_SOURCES = script_test_2.cc script_test_2a.cc script_test_2b.cc
1448script_test_2_DEPENDENCIES = gcctestdir/ld script_test_2.t
1449script_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -Wl,-T,$(srcdir)/script_test_2.t
1450script_test_2_LDADD =
1451
1452check_PROGRAMS += justsyms
1453justsyms_SOURCES = justsyms_1.cc
1454justsyms_DEPENDENCIES = gcctestdir/ld justsyms_2r.o
1455justsyms_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_2r.o
1456justsyms_LDADD =
1457justsyms_2.o: justsyms_2.cc
1458	$(CXXCOMPILE) -c -o $@ $<
1459justsyms_2r.o: justsyms_2.o gcctestdir/ld $(srcdir)/justsyms.t
1460	gcctestdir/ld -o $@ -r -T $(srcdir)/justsyms.t justsyms_2.o
1461
1462check_PROGRAMS += justsyms_exec
1463justsyms_exec_SOURCES = justsyms_exec.c
1464justsyms_exec_DEPENDENCIES = gcctestdir/ld justsyms_lib
1465justsyms_exec_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_lib
1466justsyms_exec_LDADD =
1467MOSTLYCLEANFILES += justsyms_lib
1468justsyms_lib.o: justsyms_lib.c
1469	$(COMPILE) -c -o $@ $<
1470justsyms_lib: justsyms_lib.o gcctestdir/ld
1471	gcctestdir/ld -o $@ -Ttext=0x1000200 -Tdata=0x2000000 -e exported_func justsyms_lib.o
1472
1473check_PROGRAMS += binary_test
1474MOSTLYCLEANFILES += binary.txt
1475binary_test_SOURCES = binary_test.cc
1476binary_test_DEPENDENCIES = gcctestdir/ld binary.txt
1477binary_test_LDFLAGS = -Bgcctestdir/ -Wl,--format,binary,binary.txt,--format,elf
1478binary_test_LDADD =
1479# Copy the file to the build directory to avoid worrying about the
1480# full pathname in the generated symbols.
1481binary.txt: $(srcdir)/binary.in
1482	rm -f $@
1483	$(LN_S) $< $@
1484
1485check_SCRIPTS += ver_matching_test.sh
1486check_DATA += ver_matching_test.stdout
1487MOSTLYCLEANFILES += ver_matching_test.stdout
1488ver_matching_def.so: ver_matching_def_pic.o $(srcdir)/version_script.map gcctestdir/ld
1489	$(CXXLINK) -O0 -Bgcctestdir/ -shared ver_matching_def_pic.o -Wl,--version-script=$(srcdir)/version_script.map
1490ver_matching_def_pic.o: ver_matching_def.cc
1491	$(CXXCOMPILE) -O0 -c -fpic -o $@ $<
1492ver_matching_test.stdout: ver_matching_def.so
1493	$(TEST_OBJDUMP) -T ver_matching_def.so | $(TEST_CXXFILT) > ver_matching_test.stdout
1494
1495check_PROGRAMS += script_test_3
1496check_SCRIPTS += script_test_3.sh
1497check_DATA += script_test_3.stdout
1498MOSTLYCLEANFILES += script_test_3.stdout
1499script_test_3: basic_test.o gcctestdir/ld script_test_3.t
1500	$(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_3.t
1501script_test_3.stdout: script_test_3
1502	$(TEST_READELF) -SlW script_test_3 > script_test_3.stdout
1503
1504check_PROGRAMS += tls_phdrs_script_test
1505tls_phdrs_script_test_SOURCES = $(tls_test_SOURCES)
1506tls_phdrs_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_3.t
1507tls_phdrs_script_test_LDFLAGS = $(tls_test_LDFLAGS) -Wl,-T,$(srcdir)/script_test_3.t
1508tls_phdrs_script_test_LDADD = $(tls_test_LDADD)
1509
1510check_SCRIPTS += script_test_4.sh
1511check_DATA += script_test_4.stdout
1512MOSTLYCLEANFILES += script_test_4
1513script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
1514	$(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_4.t
1515script_test_4.stdout: script_test_4
1516	$(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
1517
1518check_PROGRAMS += tls_script_test
1519tls_script_test_SOURCES = $(tls_test_SOURCES)
1520tls_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_4.t
1521tls_script_test_LDFLAGS = $(tls_test_LDFLAGS) -Wl,-T,$(srcdir)/script_test_4.t
1522tls_script_test_LDADD = $(tls_test_LDADD)
1523
1524check_SCRIPTS += script_test_5.sh
1525check_DATA += script_test_5.stdout
1526MOSTLYCLEANFILES += script_test_5
1527script_test_5: script_test_5.o gcctestdir/ld $(srcdir)/script_test_5.t
1528	$(CXXLINK) -Bgcctestdir/ script_test_5.o -Wl,-T,$(srcdir)/script_test_5.t
1529script_test_5.stdout: script_test_5
1530	$(TEST_READELF) -SW script_test_5 > script_test_5.stdout
1531
1532check_SCRIPTS += script_test_6.sh
1533check_DATA += script_test_6.stdout
1534MOSTLYCLEANFILES += script_test_6
1535script_test_6: basic_test.o gcctestdir/ld $(srcdir)/script_test_6.t
1536	$(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_6.t \
1537	-Wl,-Ttext=0x10001000 -Wl,-Tdata=0x10200000 -Wl,-Tbss=0x10400000
1538script_test_6.stdout: script_test_6
1539	$(TEST_READELF) -SlW script_test_6 > script_test_6.stdout
1540
1541check_SCRIPTS += script_test_7.sh
1542check_DATA += script_test_7.stdout
1543MOSTLYCLEANFILES += script_test_7
1544script_test_7: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1545	$(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_7.t
1546script_test_7.stdout: script_test_7
1547	$(TEST_READELF) -SlW script_test_7 > script_test_7.stdout
1548
1549check_SCRIPTS += script_test_8.sh
1550check_DATA += script_test_8.stdout
1551MOSTLYCLEANFILES += script_test_8
1552script_test_8: basic_test.o gcctestdir/ld $(srcdir)/script_test_7.t
1553	$(CXXLINK) -Bgcctestdir/ basic_test.o -Wl,-T,$(srcdir)/script_test_7.t \
1554	-Wl,-Ttext=0x20001000 -Wl,-Tdata=0x20200000 -Wl,-Tbss=0x20400000
1555script_test_8.stdout: script_test_8
1556	$(TEST_READELF) -SlW script_test_8 > script_test_8.stdout
1557
1558check_SCRIPTS += script_test_9.sh
1559check_DATA += script_test_9.stdout
1560MOSTLYCLEANFILES += script_test_9
1561script_test_9.o: script_test_9.cc
1562	$(CXXCOMPILE) -O0 -c -o $@ $<
1563script_test_9: gcctestdir/ld $(srcdir)/script_test_9.t script_test_9.o
1564	$(CXXLINK) -Bgcctestdir/ script_test_9.o -Wl,-T,$(srcdir)/script_test_9.t
1565script_test_9.stdout: script_test_9
1566	$(TEST_READELF) -lW script_test_9 > script_test_9.stdout
1567
1568# Test scripts with a relocatable link.
1569# The -g option is necessary to trigger a bug where a section
1570# declared in a script file is assigned a non-zero starting address.
1571check_PROGRAMS += script_test_11
1572script_test_11: gcctestdir/ld script_test_11_r.o
1573	$(LINK) -Bgcctestdir/ script_test_11_r.o
1574script_test_11_r.o: gcctestdir/ld $(srcdir)/script_test_11.t script_test_11.o
1575	gcctestdir/ld -r -o $@ -T $(srcdir)/script_test_11.t script_test_11.o
1576script_test_11.o: script_test_11.c
1577	$(COMPILE) -c -g -o $@ $<
1578
1579# Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new,
1580# and --dynamic-list-cpp-typeinfo
1581
1582check_SCRIPTS += dynamic_list.sh
1583check_DATA += dynamic_list.stdout
1584MOSTLYCLEANFILES += dynamic_list dynamic_list.stdout
1585dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t
1586	$(CXXLINK) -Bgcctestdir/ basic_test.o \
1587	  -Wl,--dynamic-list $(srcdir)/dynamic_list.t \
1588	  -Wl,--dynamic-list-data \
1589	  -Wl,--dynamic-list-cpp-new \
1590	  -Wl,--dynamic-list-cpp-typeinfo
1591dynamic_list.stdout: dynamic_list
1592	$(TEST_READELF) -W --dyn-syms dynamic_list > dynamic_list.stdout
1593
1594check_PROGRAMS += dynamic_list_2
1595dynamic_list_2_SOURCES = dynamic_list_2.cc
1596dynamic_list_2_DEPENDENCIES = gcctestdir/ld dynamic_list_lib1.so dynamic_list_lib2.so
1597dynamic_list_2_LDFLAGS = -Bgcctestdir/ -L. -Wl,-R,. -Wl,--no-as-needed
1598dynamic_list_2_LDADD = dynamic_list_lib1.so dynamic_list_lib2.so
1599
1600dynamic_list_lib1.so: gcctestdir/ld dynamic_list_lib1.o
1601	$(CXXLINK) -Bgcctestdir/ -shared dynamic_list_lib1.o
1602dynamic_list_lib1.o: dynamic_list_lib1.cc
1603	$(CXXCOMPILE) -c -fpic -o $@ $<
1604
1605dynamic_list_lib2.so: gcctestdir/ld dynamic_list_lib2.o $(srcdir)/dynamic_list_2.t
1606	$(CXXLINK) -Bgcctestdir/ -shared -Wl,-Bsymbolic-functions -Wl,--dynamic-list,$(srcdir)/dynamic_list_2.t dynamic_list_lib2.o
1607dynamic_list_lib2.o: dynamic_list_lib2.cc
1608	$(CXXCOMPILE) -c -fpic -o $@ $<
1609
1610check_PROGRAMS += thin_archive_test_1
1611MOSTLYCLEANFILES += libthin1.a libthin3.a libthinall.a \
1612	alt/thin_archive_test_2.o alt/thin_archive_test_4.o \
1613	alt/libthin2.a alt/libthin4.a
1614thin_archive_test_1_SOURCES = thin_archive_main.cc
1615thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a
1616thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt
1617thin_archive_test_1_LDADD = libthin1.a -lthin2
1618
1619check_PROGRAMS += thin_archive_test_2
1620thin_archive_test_2_SOURCES = thin_archive_main.cc
1621thin_archive_test_2_DEPENDENCIES = gcctestdir/ld libthinall.a
1622thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L.
1623thin_archive_test_2_LDADD = -lthinall
1624
1625libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o
1626	rm -f $@
1627	$(TEST_AR) crT $@ $^
1628alt/libthin2.a: thin_archive_test_3.o alt/thin_archive_test_4.o
1629	rm -f $@
1630	$(TEST_AR) crT $@ $^
1631libthin3.a: thin_archive_test_1.o alt/thin_archive_test_4.o
1632	rm -f $@
1633	$(TEST_AR) crT $@ $^
1634alt/libthin4.a: alt/thin_archive_test_2.o thin_archive_test_3.o
1635	rm -f $@
1636	$(TEST_AR) crT $@ $^
1637libthinall.a: libthin3.a alt/libthin4.a
1638	rm -f $@
1639	$(TEST_AR) crT $@ $^
1640alt/thin_archive_test_2.o: thin_archive_test_2.cc
1641	test -d alt || mkdir -p alt
1642	$(CXXCOMPILE) -c -o $@ $<
1643alt/thin_archive_test_4.o: thin_archive_test_4.cc
1644	test -d alt || mkdir -p alt
1645	$(CXXCOMPILE) -c -o $@ $<
1646
1647if PLUGINS
1648
1649check_PROGRAMS += plugin_test_1
1650check_SCRIPTS += plugin_test_1.sh
1651check_DATA += plugin_test_1.err
1652MOSTLYCLEANFILES += plugin_test_1.err
1653plugin_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
1654	$(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
1655plugin_test_1.err: plugin_test_1
1656	@touch plugin_test_1.err
1657
1658check_PROGRAMS += plugin_test_2
1659check_SCRIPTS += plugin_test_2.sh
1660check_DATA += plugin_test_2.err
1661MOSTLYCLEANFILES += plugin_test_2.err
1662plugin_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
1663	$(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
1664plugin_test_2.err: plugin_test_2
1665	@touch plugin_test_2.err
1666
1667check_PROGRAMS += plugin_test_3
1668check_SCRIPTS += plugin_test_3.sh
1669check_DATA += plugin_test_3.err
1670MOSTLYCLEANFILES += plugin_test_3.err
1671plugin_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
1672	$(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
1673plugin_test_3.err: plugin_test_3
1674	@touch plugin_test_3.err
1675
1676check_PROGRAMS += plugin_test_4
1677check_SCRIPTS += plugin_test_4.sh
1678check_DATA += plugin_test_4.err
1679MOSTLYCLEANFILES += plugin_test_4.a plugin_test_4.err
1680plugin_test_4: two_file_test_main.o plugin_test_4.a gcctestdir/ld plugin_test.so
1681	$(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
1682plugin_test_4.err: plugin_test_4
1683	@touch plugin_test_4.err
1684
1685plugin_test_4.a: two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms
1686	$(TEST_AR) cr $@ $^
1687
1688check_PROGRAMS += plugin_test_5
1689plugin_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
1690	$(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
1691
1692check_PROGRAMS += plugin_test_6
1693check_SCRIPTS += plugin_test_6.sh
1694check_DATA += plugin_test_6.err
1695MOSTLYCLEANFILES += plugin_test_6.err
1696plugin_test_6: plugin_common_test_1.o.syms plugin_common_test_2.o.syms gcctestdir/ld plugin_test.so
1697	$(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
1698plugin_test_6.err: plugin_test_6
1699	@touch plugin_test_6.err
1700
1701check_PROGRAMS += plugin_test_7
1702check_SCRIPTS += plugin_test_7.sh
1703check_DATA += plugin_test_7.err plugin_test_7.o.syms
1704MOSTLYCLEANFILES += plugin_test_7.err
1705plugin_test_7: plugin_test_7_1.o plugin_test_7_1.o.syms plugin_test_7_2.o gcctestdir/ld plugin_test.so
1706	$(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
1707plugin_test_7.o.syms: plugin_test_7
1708	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1709plugin_test_7_1.o: plugin_test_7_1.c
1710	$(COMPILE) -DLTO -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1711plugin_test_7_1_orig.o: plugin_test_7_1.c
1712	$(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1713plugin_test_7_1.o.syms: plugin_test_7_1_orig.o
1714	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1715plugin_test_7_2.o: plugin_test_7_2.c
1716	$(COMPILE) -O0 -c -ffunction-sections -fdata-sections -o $@ $<
1717plugin_test_7.err: plugin_test_7
1718
1719# Test plugins with -r.
1720check_PROGRAMS += plugin_test_8
1721plugin_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
1722	../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
1723plugin_test_8: plugin_test_8.o gcctestdir/ld
1724	$(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle plugin_test_8.o
1725
1726# Test that symbols known in the IR file but not in the replacement file
1727# produce an unresolved symbol error.
1728check_DATA += plugin_test_9.err
1729MOSTLYCLEANFILES += plugin_test_9.err
1730plugin_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
1731	@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>$@"
1732	@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 \
1733	  echo 1>&2 "Link of plugin_test_9 should have failed"; \
1734	  rm -f $@; \
1735	  exit 1; \
1736	fi
1737# Make a .syms file that claims to define the symbol _Z4t16av.
1738two_file_test_1c.o.syms: two_file_test_1.o.syms two_file_test_1c.o
1739	cp two_file_test_1.o.syms $@.tmp
1740	grep "_Z4t16av" two_file_test_1b.o.syms >> $@.tmp
1741	mv -f $@.tmp $@
1742# Make a copy of two_file_test_1.o, which does not define the symbol _Z4t16av.
1743MOSTLYCLEANFILES += two_file_test_1c.o
1744two_file_test_1c.o: two_file_test_1.o
1745	cp two_file_test_1.o $@
1746
1747check_PROGRAMS += plugin_test_10
1748check_SCRIPTS += plugin_test_10.sh
1749check_DATA += plugin_test_10.sections
1750MOSTLYCLEANFILES += plugin_test_10.sections
1751plugin_test_10: plugin_common_test_1.o.syms plugin_common_test_2.o  gcctestdir/ld plugin_test.so
1752	$(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.o.syms plugin_common_test_2.o
1753plugin_test_10.sections: plugin_test_10
1754	$(TEST_READELF) -SW $< >$@ 2>/dev/null
1755
1756check_PROGRAMS += plugin_test_11
1757check_SCRIPTS += plugin_test_11.sh
1758check_DATA += plugin_test_11.err
1759MOSTLYCLEANFILES += plugin_test_11.err plugin_test_thin.a
1760PLUGIN_TEST_11_SYMS = two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms
1761plugin_test_11: two_file_test_main.o plugin_test_thin.a gcctestdir/ld plugin_test.so $(PLUGIN_TEST_11_SYMS)
1762	$(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
1763plugin_test_11.err: plugin_test_11
1764	@touch plugin_test_11.err
1765plugin_test_thin.a: two_file_test_1.o two_file_test_1b.o two_file_test_2.o
1766	rm -f $@
1767	$(TEST_AR) crT $@ $^
1768
1769plugin_test.so: plugin_test.o
1770	$(LINK) -Bgcctestdir/ -shared plugin_test.o
1771plugin_test.o: plugin_test.c
1772	$(COMPILE) -O0 -c -fpic -o $@ $<
1773
1774two_file_test_main.o.syms: two_file_test_main.o
1775	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1776two_file_test_1.o.syms: two_file_test_1.o
1777	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1778two_file_test_1b.o.syms: two_file_test_1b.o
1779	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1780two_file_test_2.o.syms: two_file_test_2.o
1781	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1782plugin_common_test_1.o.syms: plugin_common_test_1.o
1783	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1784plugin_common_test_2.o.syms: plugin_common_test_2.o
1785	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1786
1787empty.o.syms:
1788	@echo "" >$@
1789	@echo "Symbol table" >>$@
1790
1791if TLS
1792
1793check_PROGRAMS += plugin_test_tls
1794check_SCRIPTS += plugin_test_tls.sh
1795check_DATA += plugin_test_tls.err
1796MOSTLYCLEANFILES += plugin_test_tls.err
1797plugin_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
1798	$(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
1799plugin_test_tls.err: plugin_test_tls
1800	@touch plugin_test_tls.err
1801
1802two_file_test_2_tls.o.syms: two_file_test_2_tls.o
1803	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1804
1805endif TLS
1806
1807MOSTLYCLEANFILES += unused.c
1808unused.o.syms: unused.o
1809	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1810	@echo "     1: 00000000     4 FUNC    GLOBAL DEFAULT    1 UNUSED" >>$@
1811unused.o: unused.c
1812	$(COMPILE) -c -o $@ $<
1813unused.c:
1814	@cp /dev/null $@
1815
1816check_SCRIPTS += plugin_final_layout.sh
1817check_DATA += plugin_final_layout.stdout plugin_final_layout_readelf.stdout
1818MOSTLYCLEANFILES += plugin_final_layout
1819plugin_final_layout.o: plugin_final_layout.cc
1820	$(CXXCOMPILE) -O0 -c -ffunction-sections  -fdata-sections -g -o $@ $<
1821plugin_final_layout: plugin_final_layout.o plugin_section_order.so gcctestdir/ld
1822	$(CXXLINK) -Bgcctestdir/ -Wl,--plugin,"./plugin_section_order.so" plugin_final_layout.o
1823plugin_final_layout.stdout: plugin_final_layout
1824	$(TEST_NM) -n --synthetic plugin_final_layout > plugin_final_layout.stdout
1825plugin_final_layout_readelf.stdout: plugin_final_layout
1826	$(TEST_READELF) -Wl plugin_final_layout > plugin_final_layout_readelf.stdout
1827
1828plugin_section_order.so: plugin_section_order.o
1829	$(LINK) -Bgcctestdir/ -shared plugin_section_order.o
1830plugin_section_order.o: plugin_section_order.c
1831	$(COMPILE) -O0 -c -fpic -o $@ $<
1832
1833endif PLUGINS
1834
1835check_PROGRAMS += exclude_libs_test
1836check_SCRIPTS += exclude_libs_test.sh
1837check_DATA += exclude_libs_test.syms
1838MOSTLYCLEANFILES += exclude_libs_test.syms libexclude_libs_test_1.a \
1839        libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
1840exclude_libs_test_SOURCES = exclude_libs_test.c
1841exclude_libs_test_DEPENDENCIES = gcctestdir/ld libexclude_libs_test_1.a \
1842	libexclude_libs_test_2.a alt/libexclude_libs_test_3.a
1843exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. -Lalt \
1844	-Wl,--exclude-libs,dummy:libexclude_libs_test_1 \
1845	-Wl,--exclude-libs,libexclude_libs_test_3
1846exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 \
1847	alt/libexclude_libs_test_3.a
1848exclude_libs_test.syms: exclude_libs_test
1849	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1850libexclude_libs_test_1.a: exclude_libs_test_1.o
1851	$(TEST_AR) rc $@ $^
1852libexclude_libs_test_2.a: exclude_libs_test_2.o
1853	$(TEST_AR) rc $@ $^
1854alt/libexclude_libs_test_3.a: exclude_libs_test_3.o
1855	test -d alt || mkdir -p alt
1856	$(TEST_AR) rc $@ $^
1857
1858check_PROGRAMS += local_labels_test
1859local_labels_test.o: ver_test_6.c
1860	$(COMPILE) -g -c -Wa,-L -o $@ $<
1861local_labels_test: local_labels_test.o
1862	$(LINK) -Bgcctestdir/ local_labels_test.o
1863
1864check_PROGRAMS += discard_locals_test
1865check_SCRIPTS += discard_locals_test.sh
1866check_DATA += discard_locals_test.syms \
1867	discard_locals_relocatable_test1.syms \
1868	discard_locals_relocatable_test2.syms
1869MOSTLYCLEANFILES += discard_locals_test.syms \
1870	discard_locals_relocatable_test1.syms \
1871	discard_locals_relocatable_test2.syms \
1872	discard_locals_relocatable_test1.out \
1873	discard_locals_relocatable_test2.out
1874discard_locals_test_SOURCES = discard_locals_test.c
1875discard_locals_test_LDFLAGS = -Bgcctestdir/ -Wl,--discard-locals
1876discard_locals_test.syms: discard_locals_test
1877	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1878# '-Wa,-L' is required to preserve the local label used for testing.
1879discard_locals_test.o: discard_locals_test.c
1880	$(COMPILE) -c -Wa,-L -o $@ $<
1881
1882discard_locals_relocatable_test1.syms: discard_locals_relocatable_test1.out
1883	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1884discard_locals_relocatable_test.o: discard_locals_relocatable_test.c
1885	$(COMPILE) -c -Wa,-L -fPIC -o $@ $<
1886discard_locals_relocatable_test1.out: discard_locals_relocatable_test.o ../ld-new
1887	../ld-new --discard-locals -relocatable -o $@ $<
1888
1889discard_locals_relocatable_test2.syms: discard_locals_relocatable_test2.out
1890	$(TEST_READELF) -sW $< >$@ 2>/dev/null
1891discard_locals_relocatable_test2.out: discard_locals_relocatable_test.o ../ld-new
1892	../ld-new --discard-all -relocatable -o $@ $<
1893
1894if MCMODEL_MEDIUM
1895check_PROGRAMS += large
1896large_SOURCES = large.c
1897large_CFLAGS = -mcmodel=medium
1898large_DEPENDENCIES = gcctestdir/ld
1899large_LDFLAGS = -Bgcctestdir/
1900large_LDADD =
1901endif MCMODEL_MEDIUM
1902
1903# Test that hidden and internal symbols in the main program cannot be
1904# referenced by a shared library.
1905check_SCRIPTS += hidden_test.sh
1906check_DATA += hidden_test.err
1907MOSTLYCLEANFILES += hidden_test hidden_test.err hidden_test.syms
1908libhidden.so: hidden_test_1.c gcctestdir/ld
1909	$(COMPILE) -Bgcctestdir/ -g -shared -fPIC -w -o $@ $(srcdir)/hidden_test_1.c
1910hidden_test: hidden_test_main.o libhidden.so gcctestdir/ld
1911	$(LINK) -Bgcctestdir/ -Wl,-R,. hidden_test_main.o libhidden.so 2>hidden_test.err
1912hidden_test.syms: hidden_test
1913	$(TEST_NM) -D hidden_test > $@
1914hidden_test.err: hidden_test
1915	@touch hidden_test.err
1916
1917# Test -retain-symbols-file.
1918check_SCRIPTS += retain_symbols_file_test.sh
1919check_DATA += retain_symbols_file_test.stdout
1920MOSTLYCLEANFILES += retain_symbols_file_test retain_symbols_file_test.in \
1921                    retain_symbols_file_test.stdout
1922retain_symbols_file_test.so: basic_pic_test.o gcctestdir/ld
1923	echo 'main' > retain_symbols_file_test.in
1924	echo 't1' >> retain_symbols_file_test.in
1925	echo '_ZN4t16bC1Ev' >> retain_symbols_file_test.in
1926	echo '_ZNK4t20a3getEv' >> retain_symbols_file_test.in
1927	echo '_Z3t18v' >> retain_symbols_file_test.in
1928	echo '__tcf_0' >> retain_symbols_file_test.in
1929	$(CXXLINK) -Bgcctestdir/ -shared -Wl,-retain-symbols-file,retain_symbols_file_test.in basic_pic_test.o
1930retain_symbols_file_test.stdout: retain_symbols_file_test.so
1931	$(TEST_NM) -C retain_symbols_file_test.so > $@
1932
1933
1934# Test that if the output file already exists and is empty,
1935# it will get execute permission.
1936check_PROGRAMS += permission_test
1937permission_test: basic_test.o gcctestdir/ld
1938	umask 022; \
1939	rm -f $@; \
1940	touch $@; \
1941	chmod 600 $@; \
1942	$(CXXLINK) -Bgcctestdir/ basic_test.o
1943
1944# Check -l:foo.a
1945check_PROGRAMS += searched_file_test
1946MOSTLYCLEANFILES += searched_file_test searched_file_test_lib.o \
1947                    alt/searched_file_test_lib.a
1948searched_file_test_SOURCES = searched_file_test.cc
1949searched_file_test_DEPENDENCIES = alt/searched_file_test_lib.a
1950searched_file_test_LDFLAGS = -Bgcctestdir/ -Lalt
1951searched_file_test_LDADD = -l:searched_file_test_lib.a
1952searched_file_test_lib.o: searched_file_test_lib.cc
1953	$(CXXCOMPILE) -c -o $@ $<
1954alt/searched_file_test_lib.a: searched_file_test_lib.o
1955	test -d alt || mkdir -p alt
1956	$(TEST_AR) rc $@ $^
1957
1958# Test that no .gnu.version sections are created when
1959# symbol versioning is not used.
1960check_SCRIPTS += no_version_test.sh
1961check_DATA += no_version_test.stdout
1962MOSTLYCLEANFILES += libno_version_test.so no_version_test.stdout
1963# We invoke the linker directly since gcc may include additional objects that
1964# uses symbol versioning.
1965libno_version_test.so: no_version_test.o gcctestdir/ld
1966	gcctestdir/ld -shared -o $@ no_version_test.o
1967no_version_test.o: no_version_test.c
1968	$(COMPILE) -o $@ -c -fPIC $<
1969no_version_test.stdout: libno_version_test.so
1970	$(TEST_OBJDUMP) -h $< > $@
1971
1972# Test STT_GNU_IFUNC symbols.
1973if IFUNC
1974
1975ifuncmod1.o: ifuncmod1.c
1976	$(COMPILE) -c -fPIC -o $@ $<
1977ifuncmod1.so: ifuncmod1.o gcctestdir/ld
1978	$(LINK) -Bgcctestdir/ -shared ifuncmod1.o
1979
1980ifuncdep1.o: ifuncmod1.c
1981	$(COMPILE) -c -o $@ $<
1982
1983ifuncmain1pic.o: ifuncmain1.c
1984	$(COMPILE) -c -fPIC -o $@ $<
1985ifuncmain1pie.o: ifuncmain1.c
1986	$(COMPILE) -c -fPIE -o $@ $<
1987
1988if HAVE_STATIC
1989if IFUNC_STATIC
1990check_PROGRAMS += ifuncmain1static
1991ifuncmain1static_SOURCES = ifuncmain1.c
1992ifuncmain1static_DEPENDENCIES = gcctestdir/ld ifuncdep1.o
1993ifuncmain1static_LDFLAGS = -Bgcctestdir/ -static
1994ifuncmain1static_LDADD = ifuncdep1.o
1995
1996check_PROGRAMS += ifuncmain1picstatic
1997ifuncmain1picstatic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
1998	$(LINK) -Bgcctestdir/ -static ifuncmain1pic.o ifuncmod1.o
1999endif
2000endif
2001
2002check_PROGRAMS += ifuncmain1
2003ifuncmain1_SOURCES = ifuncmain1.c
2004ifuncmain1_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
2005ifuncmain1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
2006ifuncmain1_LDADD = ifuncmod1.so
2007
2008check_PROGRAMS += ifuncmain1pic
2009ifuncmain1pic: ifuncmain1pic.o ifuncmod1.so gcctestdir/ld
2010	$(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
2011
2012check_PROGRAMS += ifuncmain1vis
2013ifuncmain1vis_SOURCES = ifuncmain1vis.c
2014ifuncmain1vis_DEPENDENCIES = gcctestdir/ld ifuncmod1.so
2015ifuncmain1vis_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
2016ifuncmain1vis_LDADD = ifuncmod1.so
2017
2018check_PROGRAMS += ifuncmain1vispic
2019ifuncmain1vispic.o: ifuncmain1vis.c
2020	$(COMPILE) -c -fPIC -o $@ $<
2021ifuncmain1vispic: ifuncmain1vispic.o ifuncmod1.so gcctestdir/ld
2022	$(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.so -Wl,-R,.
2023
2024check_PROGRAMS += ifuncmain1staticpic
2025ifuncmain1staticpic: ifuncmain1pic.o ifuncmod1.o gcctestdir/ld
2026	$(LINK) -Bgcctestdir/ ifuncmain1pic.o ifuncmod1.o
2027
2028check_PROGRAMS += ifuncmain1pie
2029ifuncmain1pie: ifuncmain1pie.o ifuncmod1.so gcctestdir/ld
2030	$(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.so -Wl,-R,.
2031
2032check_PROGRAMS += ifuncmain1vispie
2033ifuncmain1vispie.o: ifuncmain1vis.c
2034	$(COMPILE) -c -fPIE -o $@ $<
2035ifuncmain1vispie: ifuncmain1vispie.o ifuncmod1.so gcctestdir/ld
2036	$(LINK) -Bgcctestdir/ -pie ifuncmain1vispie.o ifuncmod1.so -Wl,-R,.
2037
2038check_PROGRAMS += ifuncmain1staticpie
2039ifuncmain1staticpie: ifuncmain1pie.o ifuncmod1.o gcctestdir/ld
2040	$(LINK) -Bgcctestdir/ -pie ifuncmain1pie.o ifuncmod1.o
2041
2042ifuncmain2pic.o: ifuncmain2.c
2043	$(COMPILE) -c -fPIC -o $@ $<
2044
2045ifuncdep2pic.o: ifuncdep2.c
2046	$(COMPILE) -c -fPIC -o $@ $<
2047
2048if HAVE_STATIC
2049if IFUNC_STATIC
2050check_PROGRAMS += ifuncmain2static
2051ifuncmain2static_SOURCES = ifuncmain2.c ifuncdep2.c
2052ifuncmain2static_DEPENDENCIES = gcctestdir/ld
2053ifuncmain2static_LDFLAGS = -Bgcctestdir/ -static
2054ifuncmain2static_LDADD =
2055
2056check_PROGRAMS += ifuncmain2picstatic
2057ifuncmain2picstatic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
2058	$(LINK) -Bgcctestdir/ -static ifuncmain2pic.o ifuncdep2pic.o
2059endif
2060endif
2061
2062check_PROGRAMS += ifuncmain2
2063ifuncmain2_SOURCES = ifuncmain2.c ifuncdep2.c
2064ifuncmain2_DEPENDENCIES = gcctestdir/ld
2065ifuncmain2_LDFLAGS = -Bgcctestdir/
2066ifuncmain2_LDADD =
2067
2068check_PROGRAMS += ifuncmain2pic
2069ifuncmain2pic: ifuncmain2pic.o ifuncdep2pic.o gcctestdir/ld
2070	$(LINK) -Bgcctestdir/ ifuncmain2pic.o ifuncdep2pic.o
2071
2072ifuncmod3.o: ifuncmod3.c
2073	$(COMPILE) -c -fPIC -o $@ $<
2074ifuncmod3.so: ifuncmod3.o gcctestdir/ld
2075	$(LINK) -Bgcctestdir/ -shared ifuncmod3.o
2076
2077check_PROGRAMS += ifuncmain3
2078ifuncmain3_SOURCES = ifuncmain3.c
2079ifuncmain3_DEPENDENCIES = gcctestdir/ld ifuncmod3.so
2080ifuncmain3_LDFLAGS = -Bgcctestdir/ -Wl,--export-dynamic -Wl,-R,.
2081ifuncmain3_LDADD = -ldl
2082
2083ifuncmain4pic.o: ifuncmain4.c
2084	$(COMPILE) -c -fPIC -o $@ $<
2085
2086if HAVE_STATIC
2087if IFUNC_STATIC
2088check_PROGRAMS += ifuncmain4static
2089ifuncmain4static_SOURCES = ifuncmain4.c
2090ifuncmain4static_DEPENDENCIES = gcctestdir/ld
2091ifuncmain4static_LDFLAGS = -Bgcctestdir/ -static
2092ifuncmain4static_LDADD =
2093
2094check_PROGRAMS += ifuncmain4picstatic
2095ifuncmain4picstatic: ifuncmain4pic.o gcctestdir/ld
2096	$(LINK) -Bgcctestdir/ -static ifuncmain4pic.o
2097endif
2098endif
2099
2100check_PROGRAMS += ifuncmain4
2101ifuncmain4_SOURCES = ifuncmain4.c
2102ifuncmain4_DEPENDENCIES = gcctestdir/ld
2103ifuncmain4_LDFLAGS = -Bgcctestdir/
2104ifuncmain4_LDADD =
2105
2106ifuncmain5pic.o: ifuncmain5.c
2107	$(COMPILE) -c -fPIC -o $@ $<
2108
2109ifuncmain5pie.o: ifuncmain5.c
2110	$(COMPILE) -c -fPIE -o $@ $<
2111
2112ifuncmod5.o: ifuncmod5.c
2113	$(COMPILE) -c -fPIC -o $@ $<
2114ifuncmod5.so: ifuncmod5.o gcctestdir/ld
2115	$(LINK) -Bgcctestdir/ -shared ifuncmod5.o
2116
2117ifuncdep5.o: ifuncmod5.c
2118	$(COMPILE) -c -o $@ $<
2119
2120if HAVE_STATIC
2121if IFUNC_STATIC
2122check_PROGRAMS += ifuncmain5static
2123ifuncmain5static_SOURCES = ifuncmain5.c
2124ifuncmain5static_DEPENDENCIES = gcctestdir/ld ifuncdep5.o
2125ifuncmain5static_LDFLAGS = -Bgcctestdir/ -static
2126ifuncmain5static_LDADD = ifuncdep5.o
2127
2128check_PROGRAMS += ifuncmain5picstatic
2129ifuncmain5picstatic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
2130	$(LINK) -Bgcctestdir/ -static ifuncmain5pic.o ifuncmod5.o
2131endif
2132endif
2133
2134check_PROGRAMS += ifuncmain5
2135ifuncmain5_SOURCES = ifuncmain5.c
2136ifuncmain5_DEPENDENCIES = gcctestdir/ld ifuncmod5.so
2137ifuncmain5_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
2138ifuncmain5_LDADD = ifuncmod5.so
2139
2140check_PROGRAMS += ifuncmain5pic
2141ifuncmain5pic: ifuncmain5pic.o ifuncmod5.so gcctestdir/ld
2142	$(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.so -Wl,-R,.
2143
2144check_PROGRAMS += ifuncmain5staticpic
2145ifuncmain5staticpic: ifuncmain5pic.o ifuncmod5.o gcctestdir/ld
2146	$(LINK) -Bgcctestdir/ ifuncmain5pic.o ifuncmod5.o
2147
2148check_PROGRAMS += ifuncmain5pie
2149ifuncmain5pie: ifuncmain5pie.o ifuncmod5.so gcctestdir/ld
2150	$(LINK) -Bgcctestdir/ -pie ifuncmain5pie.o ifuncmod5.so -Wl,-R,.
2151
2152ifuncmain6pie.o: ifuncmain6pie.c
2153	$(COMPILE) -c -fPIE -o $@ $<
2154
2155ifuncmod6.o: ifuncmod6.c
2156	$(COMPILE) -c -fPIC -o $@ $<
2157ifuncmod6.so: ifuncmod6.o gcctestdir/ld
2158	$(LINK) -Bgcctestdir/ -shared ifuncmod6.o
2159
2160check_PROGRAMS += ifuncmain6pie
2161ifuncmain6pie: ifuncmain6pie.o ifuncmod6.so gcctestdir/ld
2162	$(LINK) -Bgcctestdir/ -pie ifuncmain6pie.o ifuncmod6.so -Wl,-R,.
2163
2164ifuncmain7pic.o: ifuncmain7.c
2165	$(COMPILE) -c -fPIC -o $@ $<
2166
2167ifuncmain7pie.o: ifuncmain7.c
2168	$(COMPILE) -c -fPIE -o $@ $<
2169
2170if HAVE_STATIC
2171if IFUNC_STATIC
2172check_PROGRAMS += ifuncmain7static
2173ifuncmain7static_SOURCES = ifuncmain7.c
2174ifuncmain7static_DEPENDENCIES = gcctestdir/ld
2175ifuncmain7static_LDFLAGS = -Bgcctestdir/ -static
2176ifuncmain7static_LDADD =
2177
2178check_PROGRAMS += ifuncmain7picstatic
2179ifuncmain7picstatic: ifuncmain7pic.o gcctestdir/ld
2180	$(LINK) -Bgcctestdir/ -static ifuncmain7pic.o
2181endif
2182endif
2183
2184check_PROGRAMS += ifuncmain7
2185ifuncmain7_SOURCES = ifuncmain7.c
2186ifuncmain7_DEPENDENCIES = gcctestdir/ld
2187ifuncmain7_LDFLAGS = -Bgcctestdir/
2188ifuncmain7_LDADD =
2189
2190check_PROGRAMS += ifuncmain7pic
2191ifuncmain7pic: ifuncmain7pic.o gcctestdir/ld
2192	$(LINK) -Bgcctestdir/ ifuncmain7pic.o
2193
2194check_PROGRAMS += ifuncmain7pie
2195ifuncmain7pie: ifuncmain7pie.o gcctestdir/ld
2196	$(LINK) -Bgcctestdir/ -pie ifuncmain7pie.o
2197
2198check_PROGRAMS += ifuncvar
2199ifuncvar1_pic.o: ifuncvar1.c
2200	$(COMPILE) -c -fPIC -o $@ $<
2201ifuncvar2_pic.o: ifuncvar2.c
2202	$(COMPILE) -c -fPIC -o $@ $<
2203ifuncvar.so: ifuncvar1_pic.o ifuncvar2_pic.o gcctestdir/ld
2204	$(LINK) -Bgcctestdir/ -shared ifuncvar1_pic.o ifuncvar2_pic.o
2205ifuncvar_SOURCES = ifuncvar3.c
2206ifuncvar_DEPENDENCIES = gcctestdir/ld ifuncvar.so
2207ifuncvar_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
2208ifuncvar_LDADD = ifuncvar.so
2209
2210endif IFUNC
2211
2212# Test that strong reference to a weak symbol in a DSO remains strong.
2213check_SCRIPTS += strong_ref_weak_def.sh
2214check_DATA += strong_ref_weak_def.stdout
2215MOSTLYCLEANFILES += strong_ref_weak_def_1.so strong_ref_weak_def_2.so \
2216	strong_ref_weak_def.stdout
2217strong_ref_weak_def_2.o: strong_ref_weak_def_2.c
2218	$(COMPILE) -o $@ -c -fPIC $<
2219strong_ref_weak_def_2.so: strong_ref_weak_def_2.o gcctestdir/ld
2220	gcctestdir/ld -shared -o $@ strong_ref_weak_def_2.o
2221strong_ref_weak_def_1.o: strong_ref_weak_def_1.c
2222	$(COMPILE) -o $@ -c -fPIC $<
2223strong_ref_weak_def_1.so: strong_ref_weak_def_1.o strong_ref_weak_def_2.so \
2224	gcctestdir/ld
2225	gcctestdir/ld -shared -o $@ strong_ref_weak_def_1.o \
2226		strong_ref_weak_def_2.so
2227strong_ref_weak_def.stdout: strong_ref_weak_def_1.so
2228	$(TEST_READELF) -sWD $< > $@
2229
2230# Test that a strong weak reference remains strong if there is another
2231# weak reference in a DSO.
2232check_SCRIPTS += dyn_weak_ref.sh
2233check_DATA += dyn_weak_ref.stdout
2234MOSTLYCLEANFILES += dyn_weak_ref_1.so dyn_weak_ref_2.so \
2235	dyn_weak_ref.stdout
2236dyn_weak_ref_2.o: dyn_weak_ref_2.c
2237	$(COMPILE) -o $@ -c -fPIC $<
2238dyn_weak_ref_2.so: dyn_weak_ref_2.o gcctestdir/ld
2239	gcctestdir/ld -shared -o $@ dyn_weak_ref_2.o
2240dyn_weak_ref_1.o: dyn_weak_ref_1.c
2241	$(COMPILE) -o $@ -c -fPIC $<
2242# We intentionally put dyn_weak_ref_2.so in front of dyn_weak_ref_1.o
2243# so that the weak ref there goes to gold's symbol table first.
2244dyn_weak_ref_1.so: dyn_weak_ref_1.o dyn_weak_ref_2.so gcctestdir/ld
2245	gcctestdir/ld -shared -o $@ dyn_weak_ref_2.so dyn_weak_ref_1.o
2246dyn_weak_ref.stdout: dyn_weak_ref_1.so
2247	$(TEST_READELF) -sWD $< > $@
2248
2249
2250# Test that --start-lib and --end-lib function correctly.
2251check_PROGRAMS += start_lib_test
2252MOSTLYCLEANFILES += libstart_lib_test.a
2253start_lib_test: start_lib_test_main.o libstart_lib_test.a start_lib_test_2.o start_lib_test_3.o \
2254	gcctestdir/ld
2255	$(LINK) -Bgcctestdir/ -o $@ start_lib_test_main.o -L. -lstart_lib_test \
2256		-Wl,--start-lib start_lib_test_2.o start_lib_test_3.o -Wl,--end-lib
2257libstart_lib_test.a: start_lib_test_1.o
2258	$(TEST_AR) rc $@ $^
2259
2260# Test that MEMORY region support works.
2261check_SCRIPTS += memory_test.sh
2262check_DATA += memory_test.stdout
2263MOSTLYCLEANFILES += memory_test.stdout memory_test memory_test.o
2264memory_test.o: memory_test.s
2265	$(COMPILE) -o $@ -c $<
2266memory_test: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t
2267	$(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -z max-page-size=0x1000 -z common-page-size=0x1000 -Wl,-T,$(srcdir)/memory_test.t -o $@ memory_test.o
2268memory_test.stdout: memory_test
2269	$(TEST_READELF) -lWS  $< > $@
2270
2271# Test INCLUDE directives in linker scripts.
2272# The binary isn't runnable, so we just check that we can build it without errors.
2273check_DATA += memory_test_2
2274MOSTLYCLEANFILES += memory_test_inc_1.t memory_test_inc_2.t memory_test_inc_3.t
2275memory_test_inc_1.t: $(srcdir)/memory_test_inc_1.t.src
2276	cp $< $@
2277memory_test_inc_2.t: $(srcdir)/memory_test_inc_2.t.src
2278	cp $< $@
2279memory_test_inc_3.t: $(srcdir)/memory_test_inc_3.t.src
2280	cp $< $@
2281memory_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
2282	$(LINK) -Bgcctestdir/ -nostartfiles -nostdlib -z max-page-size=0x1000 -z common-page-size=0x1000 -Wl,-T,$(srcdir)/memory_test.t -o $@ memory_test.o
2283
2284if HAVE_PUBNAMES
2285
2286# Test that --gdb-index functions correctly without gcc-generated pubnames.
2287check_SCRIPTS += gdb_index_test_1.sh
2288check_DATA += gdb_index_test_1.stdout
2289MOSTLYCLEANFILES += gdb_index_test_1.stdout gdb_index_test_1
2290gdb_index_test.o: gdb_index_test.cc
2291	$(CXXCOMPILE) -O0 -g -gno-pubnames -c -o $@ $<
2292gdb_index_test_1: gdb_index_test.o gcctestdir/ld
2293	$(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $<
2294gdb_index_test_1.stdout: gdb_index_test_1
2295	$(TEST_READELF) --debug-dump=gdb_index $< > $@
2296
2297if HAVE_ZLIB
2298
2299# Test that --gdb-index functions correctly with compressed debug sections.
2300check_SCRIPTS += gdb_index_test_2.sh
2301check_DATA += gdb_index_test_2.stdout
2302MOSTLYCLEANFILES += gdb_index_test_2.stdout gdb_index_test_2
2303gdb_index_test_cdebug.o: gdb_index_test.cc
2304	$(CXXCOMPILE) -Bgcctestdir/ -O0 -g -Wa,--compress-debug-sections -c -o $@ $<
2305gdb_index_test_2: gdb_index_test_cdebug.o gcctestdir/ld
2306	$(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $<
2307gdb_index_test_2.stdout: gdb_index_test_2
2308	$(TEST_READELF) --debug-dump=gdb_index $< > $@
2309
2310endif HAVE_ZLIB
2311
2312# Another simple C test (DW_AT_high_pc encoding) for --gdb-index.
2313check_SCRIPTS += gdb_index_test_3.sh
2314check_DATA += gdb_index_test_3.stdout
2315MOSTLYCLEANFILES += gdb_index_test_3.stdout gdb_index_test_3
2316gdb_index_test_3.o: gdb_index_test_3.c
2317	$(COMPILE) -O0 -g -c -o $@ $<
2318gdb_index_test_3: gdb_index_test_3.o gcctestdir/ld
2319	$(LINK) -Bgcctestdir/ -Wl,--gdb-index,--fatal-warnings $<
2320gdb_index_test_3.stdout: gdb_index_test_3
2321	$(TEST_READELF) --debug-dump=gdb_index $< > $@
2322
2323# Test that --gdb-index functions correctly with gcc-generated pubnames.
2324check_SCRIPTS += gdb_index_test_4.sh
2325check_DATA += gdb_index_test_4.stdout
2326MOSTLYCLEANFILES += gdb_index_test_4.stdout gdb_index_test_4
2327gdb_index_test_pub.o: gdb_index_test.cc
2328	$(CXXCOMPILE) -O0 -g -gpubnames -c -o $@ $<
2329gdb_index_test_4: gdb_index_test_pub.o gcctestdir/ld
2330	$(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $<
2331gdb_index_test_4.stdout: gdb_index_test_4
2332	$(TEST_READELF) --debug-dump=gdb_index $< > $@
2333
2334endif HAVE_PUBNAMES
2335
2336# Test that __ehdr_start is defined correctly.
2337check_PROGRAMS += ehdr_start_test_1
2338ehdr_start_test_1_SOURCES = ehdr_start_test.cc
2339ehdr_start_test_1_DEPENDENCIES = gcctestdir/ld
2340ehdr_start_test_1_CXXFLAGS =
2341ehdr_start_test_1_LDFLAGS = -Bgcctestdir/
2342ehdr_start_test_1_LDADD =
2343
2344# Test that __ehdr_start is defined correctly with a weak reference.
2345check_PROGRAMS += ehdr_start_test_2
2346ehdr_start_test_2_SOURCES = ehdr_start_test.cc
2347ehdr_start_test_2_DEPENDENCIES = gcctestdir/ld
2348ehdr_start_test_2_CXXFLAGS = -DEHDR_START_WEAK
2349ehdr_start_test_2_LDFLAGS = -Bgcctestdir/
2350ehdr_start_test_2_LDADD =
2351
2352# Test that __ehdr_start is defined correctly when used with a linker script.
2353check_PROGRAMS += ehdr_start_test_3
2354ehdr_start_test_3_SOURCES = ehdr_start_test.cc
2355ehdr_start_test_3_DEPENDENCIES = gcctestdir/ld $(srcdir)/ehdr_start_test.t
2356ehdr_start_test_3_CXXFLAGS = -DEHDR_START_WEAK
2357ehdr_start_test_3_LDFLAGS = -Bgcctestdir/ -Wl,-T,$(srcdir)/ehdr_start_test.t
2358ehdr_start_test_3_LDADD =
2359
2360# Test that __ehdr_start is left undefined when the text segment is not
2361# appropriately aligned.
2362check_SCRIPTS += ehdr_start_test_4.sh
2363check_DATA += ehdr_start_test_4.syms
2364MOSTLYCLEANFILES += ehdr_start_test_4
2365ehdr_start_test_4.syms: ehdr_start_test_4
2366	$(TEST_NM) ehdr_start_test_4 > $@
2367ehdr_start_test_4: ehdr_start_test_4.o gcctestdir/ld
2368	$(CXXLINK) -Bgcctestdir/ -Wl,-Ttext=0x100100 $<
2369ehdr_start_test_4.o: ehdr_start_test.cc
2370	$(CXXCOMPILE) -c -DEHDR_START_WEAK -o $@ $<
2371
2372# Test that __ehdr_start is not overridden when supplied by the user.
2373check_PROGRAMS += ehdr_start_test_5
2374ehdr_start_test_5_SOURCES = ehdr_start_test.cc ehdr_start_def.cc
2375ehdr_start_test_5_DEPENDENCIES = gcctestdir/ld
2376ehdr_start_test_5_CXXFLAGS = -DEHDR_START_USER_DEF
2377ehdr_start_test_5_LDFLAGS = -Bgcctestdir/
2378ehdr_start_test_5_LDADD =
2379
2380# Test that the --defsym option copies the symbol type and visibility.
2381check_SCRIPTS += defsym_test.sh
2382check_DATA += defsym_test.syms
2383MOSTLYCLEANFILES += defsym_test defsym_test.syms
2384defsym_test.syms: defsym_test
2385	$(TEST_READELF) -sW $< > $@
2386defsym_test: defsym_test.o gcctestdir/ld
2387	$(LINK) -Bgcctestdir/ -Wl,--defsym=bar=foo defsym_test.o
2388defsym_test.o: defsym_test.c
2389	$(COMPILE) -c -o $@ $<
2390
2391# End-to-end incremental linking tests.
2392# Incremental linking is currently supported only on the x86_64 target.
2393
2394if DEFAULT_TARGET_X86_64
2395
2396two_file_test_1_v1_ndebug.o: two_file_test_1_v1.cc
2397	$(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2398two_file_test_1_ndebug.o: two_file_test_1.cc
2399	$(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2400two_file_test_1b_ndebug.o: two_file_test_1b.cc
2401	$(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2402two_file_test_2_ndebug.o: two_file_test_2.cc
2403	$(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2404two_file_test_main_ndebug.o: two_file_test_main.cc
2405	$(CXXCOMPILE) -O0 -g0 -c -o $@ $<
2406
2407check_PROGRAMS += incremental_test_2
2408MOSTLYCLEANFILES += two_file_test_tmp_2.o
2409incremental_test_2: two_file_test_1_v1_ndebug.o two_file_test_1_ndebug.o two_file_test_1b_ndebug.o \
2410		    two_file_test_2_ndebug.o two_file_test_main_ndebug.o gcctestdir/ld
2411	cp -f two_file_test_1_v1_ndebug.o two_file_test_tmp_2.o
2412	$(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
2413	@sleep 1
2414	cp -f two_file_test_1_ndebug.o two_file_test_tmp_2.o
2415	$(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
2416
2417check_PROGRAMS += incremental_test_3
2418MOSTLYCLEANFILES += two_file_test_tmp_3.o
2419incremental_test_3: two_file_test_1.o two_file_test_1b_v1.o two_file_test_1b.o \
2420		    two_file_test_2.o two_file_test_main.o gcctestdir/ld
2421	cp -f two_file_test_1b_v1.o two_file_test_tmp_3.o
2422	$(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
2423	@sleep 1
2424	cp -f two_file_test_1b.o two_file_test_tmp_3.o
2425	$(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
2426
2427check_PROGRAMS += incremental_test_4
2428MOSTLYCLEANFILES += incremental_test_4.base two_file_test_tmp_4.o
2429incremental_test_4: two_file_test_1.o two_file_test_1b.o two_file_test_2_v1.o \
2430		    two_file_test_2.o two_file_test_main.o gcctestdir/ld
2431	cp -f two_file_test_2_v1.o two_file_test_tmp_4.o
2432	$(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
2433	mv -f incremental_test_4 incremental_test_4.base
2434	@sleep 1
2435	cp -f two_file_test_2.o two_file_test_tmp_4.o
2436	$(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
2437
2438check_PROGRAMS += incremental_test_5
2439MOSTLYCLEANFILES += two_file_test_5.a
2440incremental_test_5: two_file_test_1.o two_file_test_1b_v1.o two_file_test_1b.o \
2441		    two_file_test_2.o two_file_test_main.o gcctestdir/ld
2442	cp -f two_file_test_1b_v1.o two_file_test_tmp_5.o
2443	$(TEST_AR) rc two_file_test_5.a two_file_test_1.o two_file_test_tmp_5.o two_file_test_2.o
2444	$(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ two_file_test_main.o two_file_test_5.a
2445	@sleep 1
2446	cp -f two_file_test_1b.o two_file_test_tmp_5.o
2447	$(TEST_AR) rc two_file_test_5.a two_file_test_1.o two_file_test_tmp_5.o two_file_test_2.o
2448	$(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ two_file_test_main.o two_file_test_5.a
2449
2450# Test the --incremental-unchanged flag with an archive library.
2451# The second link should not update the library.
2452check_PROGRAMS += incremental_test_6
2453MOSTLYCLEANFILES += two_file_test_6.a
2454incremental_test_6: two_file_test_1.o two_file_test_1b_v1.o two_file_test_1b.o \
2455		    two_file_test_2.o two_file_test_main.o gcctestdir/ld
2456	cp -f two_file_test_1b.o two_file_test_tmp_6.o
2457	$(TEST_AR) rc two_file_test_6.a two_file_test_1.o two_file_test_tmp_6.o two_file_test_2.o
2458	$(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ two_file_test_main.o two_file_test_6.a
2459	@sleep 1
2460	cp -f two_file_test_1b_v1.o two_file_test_tmp_6.o
2461	$(TEST_AR) rc two_file_test_6.a two_file_test_1.o two_file_test_tmp_6.o two_file_test_2.o
2462	$(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ two_file_test_main.o -Wl,--incremental-unchanged two_file_test_6.a -Wl,--incremental-unknown
2463
2464check_PROGRAMS += incremental_copy_test
2465incremental_copy_test: copy_test_v1.o copy_test.o copy_test_1.so copy_test_2.so
2466	cp -f copy_test_v1.o copy_test_tmp.o
2467	$(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
2468	@sleep 1
2469	cp -f copy_test.o copy_test_tmp.o
2470	$(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
2471
2472check_PROGRAMS += incremental_common_test_1
2473incremental_common_test_1: common_test_1_v1.o common_test_1_v2.o gcctestdir/ld
2474	cp -f common_test_1_v1.o common_test_1_tmp.o
2475	$(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ common_test_1_tmp.o
2476	@sleep 1
2477	cp -f common_test_1_v2.o common_test_1_tmp.o
2478	$(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ common_test_1_tmp.o
2479
2480check_PROGRAMS += incremental_comdat_test_1
2481incremental_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
2482	cp -f incr_comdat_test_2_v1.o incr_comdat_test_1_tmp.o
2483	$(CXXLINK) -Wl,--incremental-full,--incremental-patch=100 -Wl,-z,norelro -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
2484	@sleep 1
2485	cp -f incr_comdat_test_2_v2.o incr_comdat_test_1_tmp.o
2486	$(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
2487	@sleep 1
2488	cp -f incr_comdat_test_2_v3.o incr_comdat_test_1_tmp.o
2489	$(CXXLINK) -Wl,--incremental-update -Wl,-z,norelro -Bgcctestdir/ incr_comdat_test_1.o incr_comdat_test_1_tmp.o
2490
2491endif DEFAULT_TARGET_X86_64
2492
2493if DEFAULT_TARGET_X86_64
2494check_PROGRAMS += exception_x86_64_bnd_test
2495exception_x86_64_bnd_test_SOURCES = exception_test_main.cc
2496exception_x86_64_bnd_test_DEPENDENCIES = gcctestdir/ld exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o
2497exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS)
2498exception_x86_64_bnd_test_LDADD = exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o
2499exception_x86_64_bnd_1.o: exception_test_1.cc gcctestdir/as
2500	$(CXXCOMPILE) -c -fpic -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $<
2501exception_x86_64_bnd_2.o: exception_test_2.cc gcctestdir/as
2502	$(CXXCOMPILE) -c -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $<
2503endif DEFAULT_TARGET_X86_64
2504
2505endif GCC
2506endif TEST_AS_NATIVE_LINKER
2507
2508# These tests work with native and cross linkers.
2509
2510if NATIVE_OR_CROSS_LINKER
2511
2512# Test script section order.
2513check_SCRIPTS += script_test_10.sh
2514check_DATA += script_test_10.stdout
2515MOSTLYCLEANFILES += script_test_10
2516script_test_10.o: script_test_10.s
2517	$(TEST_AS) -o $@ $<
2518script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld
2519	gcctestdir/ld -o $@ script_test_10.o -T $(srcdir)/script_test_10.t
2520script_test_10.stdout: script_test_10
2521	$(TEST_READELF) -SW script_test_10 > $@
2522
2523# These tests work with cross linkers only.
2524
2525if DEFAULT_TARGET_I386
2526
2527check_SCRIPTS += split_i386.sh
2528check_DATA += split_i386_1.stdout split_i386_2.stdout \
2529	split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout
2530SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
2531split_i386_1.o: split_i386_1.s
2532	$(TEST_AS) -o $@ $<
2533split_i386_2.o: split_i386_2.s
2534	$(TEST_AS) -o $@ $<
2535split_i386_3.o: split_i386_3.s
2536	$(TEST_AS) -o $@ $<
2537split_i386_4.o: split_i386_4.s
2538	$(TEST_AS) -o $@ $<
2539split_i386_n.o: split_i386_n.s
2540	$(TEST_AS) -o $@ $<
2541split_i386_1: split_i386_1.o split_i386_n.o ../ld-new
2542	../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_1.o split_i386_n.o
2543split_i386_1.stdout: split_i386_1
2544	$(TEST_OBJDUMP) -d $< > $@
2545split_i386_2: split_i386_2.o split_i386_n.o ../ld-new
2546	../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_2.o split_i386_n.o
2547split_i386_2.stdout: split_i386_2
2548	$(TEST_OBJDUMP) -d $< > $@
2549split_i386_3.stdout: split_i386_3.o split_i386_n.o ../ld-new
2550	../ld-new $(SPLIT_DEFSYMS) -o split_i386_3 split_i386_3.o split_i386_n.o > $@ 2>&1 || exit 0
2551split_i386_4: split_i386_4.o split_i386_n.o ../ld-new
2552	../ld-new $(SPLIT_DEFSYMS) -o $@ split_i386_4.o split_i386_n.o
2553split_i386_4.stdout: split_i386_4
2554	$(TEST_OBJDUMP) -d $< > $@
2555split_i386_r.stdout: split_i386_1.o split_i386_n.o ../ld-new
2556	../ld-new -r split_i386_1.o split_i386_n.o -o split_i386_r > $@ 2>&1 || exit 0
2557MOSTLYCLEANFILES += split_i386_1 split_i386_2 split_i386_3 \
2558	split_i386_4 split_i386_r
2559
2560endif DEFAULT_TARGET_I386
2561
2562if DEFAULT_TARGET_X86_64
2563
2564check_SCRIPTS += split_x86_64.sh
2565check_DATA += split_x86_64_1.stdout split_x86_64_2.stdout \
2566	split_x86_64_3.stdout split_x86_64_4.stdout split_x86_64_r.stdout
2567SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
2568split_x86_64_1.o: split_x86_64_1.s
2569	$(TEST_AS) -o $@ $<
2570split_x86_64_2.o: split_x86_64_2.s
2571	$(TEST_AS) -o $@ $<
2572split_x86_64_3.o: split_x86_64_3.s
2573	$(TEST_AS) -o $@ $<
2574split_x86_64_4.o: split_x86_64_4.s
2575	$(TEST_AS) -o $@ $<
2576split_x86_64_n.o: split_x86_64_n.s
2577	$(TEST_AS) -o $@ $<
2578split_x86_64_1: split_x86_64_1.o split_x86_64_n.o ../ld-new
2579	../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_1.o split_x86_64_n.o
2580split_x86_64_1.stdout: split_x86_64_1
2581	$(TEST_OBJDUMP) -d $< > $@
2582split_x86_64_2: split_x86_64_2.o split_x86_64_n.o ../ld-new
2583	../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_2.o split_x86_64_n.o
2584split_x86_64_2.stdout: split_x86_64_2
2585	$(TEST_OBJDUMP) -d $< > $@
2586split_x86_64_3.stdout: split_x86_64_3.o split_x86_64_n.o ../ld-new
2587	../ld-new $(SPLIT_DEFSYMS) -o split_x86_64_3 split_x86_64_3.o split_x86_64_n.o > $@ 2>&1 || exit 0
2588split_x86_64_4: split_x86_64_4.o split_x86_64_n.o ../ld-new
2589	../ld-new $(SPLIT_DEFSYMS) -o $@ split_x86_64_4.o split_x86_64_n.o
2590split_x86_64_4.stdout: split_x86_64_4
2591	$(TEST_OBJDUMP) -d $< > $@
2592split_x86_64_r.stdout: split_x86_64_1.o split_x86_64_n.o ../ld-new
2593	../ld-new -r split_x86_64_1.o split_x86_64_n.o -o split_x86_64_r > $@ 2>&1 || exit 0
2594MOSTLYCLEANFILES += split_x86_64_1 split_x86_64_2 split_x86_64_3 \
2595	split_x86_64_4 split_x86_64_r
2596
2597endif DEFAULT_TARGET_X86_64
2598
2599if DEFAULT_TARGET_X32
2600
2601check_SCRIPTS += split_x32.sh
2602check_DATA += split_x32_1.stdout split_x32_2.stdout \
2603	split_x32_3.stdout split_x32_4.stdout split_x32_r.stdout
2604SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
2605split_x32_1.o: split_x32_1.s
2606	$(TEST_AS) -o $@ $<
2607split_x32_2.o: split_x32_2.s
2608	$(TEST_AS) -o $@ $<
2609split_x32_3.o: split_x32_3.s
2610	$(TEST_AS) -o $@ $<
2611split_x32_4.o: split_x32_4.s
2612	$(TEST_AS) -o $@ $<
2613split_x32_n.o: split_x32_n.s
2614	$(TEST_AS) -o $@ $<
2615split_x32_1: split_x32_1.o split_x32_n.o ../ld-new
2616	../ld-new $(SPLIT_DEFSYMS) -o $@ split_x32_1.o split_x32_n.o
2617split_x32_1.stdout: split_x32_1
2618	$(TEST_OBJDUMP) -d $< > $@
2619split_x32_2: split_x32_2.o split_x32_n.o ../ld-new
2620	../ld-new $(SPLIT_DEFSYMS) -o $@ split_x32_2.o split_x32_n.o
2621split_x32_2.stdout: split_x32_2
2622	$(TEST_OBJDUMP) -d $< > $@
2623split_x32_3.stdout: split_x32_3.o split_x32_n.o ../ld-new
2624	../ld-new $(SPLIT_DEFSYMS) -o split_x32_3 split_x32_3.o split_x32_n.o > $@ 2>&1 || exit 0
2625split_x32_4: split_x32_4.o split_x32_n.o ../ld-new
2626	../ld-new $(SPLIT_DEFSYMS) -o $@ split_x32_4.o split_x32_n.o
2627split_x32_4.stdout: split_x32_4
2628	$(TEST_OBJDUMP) -d $< > $@
2629split_x32_r.stdout: split_x32_1.o split_x32_n.o ../ld-new
2630	../ld-new -r split_x32_1.o split_x32_n.o -o split_x32_r > $@ 2>&1 || exit 0
2631MOSTLYCLEANFILES += split_x32_1 split_x32_2 split_x32_3 \
2632	split_x32_4 split_x32_r
2633
2634endif DEFAULT_TARGET_X32
2635
2636if DEFAULT_TARGET_ARM
2637
2638check_SCRIPTS += arm_abs_global.sh
2639check_DATA += arm_abs_global.stdout
2640arm_abs_lib.o: arm_abs_lib.s
2641	$(TEST_AS) -march=armv7-a -o $@ $<
2642libarm_abs.so: arm_abs_lib.o ../ld-new
2643	../ld-new -shared -o $@ arm_abs_lib.o
2644arm_abs_global.o: arm_abs_global.s
2645	$(TEST_AS) -march=armv7-a -o $@ $<
2646arm_abs_global: arm_abs_global.o libarm_abs.so ../ld-new
2647	../ld-new -o $@ arm_abs_global.o -L. -larm_abs
2648arm_abs_global.stdout: arm_abs_global
2649	$(TEST_READELF) -r $< > $@
2650
2651MOSTLYCLEANFILES += arm_abs_global
2652
2653check_SCRIPTS += arm_branch_in_range.sh arm_branch_out_of_range.sh
2654check_DATA += arm_bl_in_range.stdout arm_bl_out_of_range.stdout \
2655	thumb_bl_in_range.stdout thumb_bl_out_of_range.stdout \
2656	thumb2_bl_in_range.stdout thumb2_bl_out_of_range.stdout \
2657	thumb_blx_in_range.stdout thumb_blx_out_of_range.stdout \
2658	thumb2_blx_in_range.stdout thumb2_blx_out_of_range.stdout \
2659	thumb_bl_out_of_range_local.stdout arm_thm_jump11.stdout \
2660	arm_thm_jump8.stdout
2661
2662arm_bl_in_range.stdout: arm_bl_in_range
2663	$(TEST_OBJDUMP) -D $< > $@
2664
2665arm_bl_in_range: arm_bl_in_range.o ../ld-new
2666	../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2667
2668arm_bl_in_range.o: arm_bl_in_range.s
2669	$(TEST_AS) -o $@ $<
2670
2671arm_bl_out_of_range.stdout: arm_bl_out_of_range
2672	$(TEST_OBJDUMP) -S $< > $@
2673
2674arm_bl_out_of_range: arm_bl_out_of_range.o ../ld-new
2675	../ld-new -T $(srcdir)/arm_branch_range.t -o $@ $<
2676
2677arm_bl_out_of_range.o: arm_bl_out_of_range.s
2678	$(TEST_AS) -o $@ $<
2679
2680thumb_bl_in_range.stdout: thumb_bl_in_range
2681	$(TEST_OBJDUMP) -D $< > $@
2682
2683thumb_bl_in_range: thumb_bl_in_range.o ../ld-new
2684	../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
2685
2686thumb_bl_in_range.o: thumb_bl_in_range.s
2687	$(TEST_AS) -o $@ -march=armv5te $<
2688
2689thumb_bl_out_of_range.stdout: thumb_bl_out_of_range
2690	$(TEST_OBJDUMP) -D $< > $@
2691
2692thumb_bl_out_of_range: thumb_bl_out_of_range.o ../ld-new
2693	../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
2694
2695thumb_bl_out_of_range.o: thumb_bl_out_of_range.s
2696	$(TEST_AS) -o $@ -march=armv5te $<
2697
2698thumb2_bl_in_range.stdout: thumb2_bl_in_range
2699	$(TEST_OBJDUMP) -D $< > $@
2700
2701thumb2_bl_in_range: thumb2_bl_in_range.o ../ld-new
2702	../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2703
2704thumb2_bl_in_range.o: thumb_bl_in_range.s
2705	$(TEST_AS) -o $@ -march=armv7-a $<
2706
2707thumb2_bl_out_of_range.stdout: thumb2_bl_out_of_range
2708	$(TEST_OBJDUMP) -D $< > $@
2709
2710thumb2_bl_out_of_range: thumb2_bl_out_of_range.o ../ld-new
2711	../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2712
2713thumb2_bl_out_of_range.o: thumb_bl_out_of_range.s
2714	$(TEST_AS) -o $@ -march=armv7-a $<
2715
2716thumb_blx_in_range.stdout: thumb_blx_in_range
2717	$(TEST_OBJDUMP) -D $< > $@
2718
2719thumb_blx_in_range: thumb_blx_in_range.o ../ld-new
2720	../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
2721
2722thumb_blx_in_range.o: thumb_blx_in_range.s
2723	$(TEST_AS) -o $@ -march=armv5te $<
2724
2725thumb_blx_out_of_range.stdout: thumb_blx_out_of_range
2726	$(TEST_OBJDUMP) -D $< > $@
2727
2728thumb_blx_out_of_range: thumb_blx_out_of_range.o ../ld-new
2729	../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
2730
2731thumb_blx_out_of_range.o: thumb_blx_out_of_range.s
2732	$(TEST_AS) -o $@ -march=armv5te $<
2733
2734thumb2_blx_in_range.stdout: thumb2_blx_in_range
2735	$(TEST_OBJDUMP) -D $< > $@
2736
2737thumb2_blx_in_range: thumb2_blx_in_range.o ../ld-new
2738	../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2739
2740thumb2_blx_in_range.o: thumb_blx_in_range.s
2741	$(TEST_AS) -o $@ -march=armv7-a $<
2742
2743thumb2_blx_out_of_range.stdout: thumb2_blx_out_of_range
2744	$(TEST_OBJDUMP) -D $< > $@
2745
2746thumb2_blx_out_of_range: thumb2_blx_out_of_range.o ../ld-new
2747	../ld-new -T $(srcdir)/thumb2_branch_range.t -o $@ $<
2748
2749thumb2_blx_out_of_range.o: thumb_blx_out_of_range.s
2750	$(TEST_AS) -o $@ -march=armv7-a $<
2751
2752thumb_bl_out_of_range_local.stdout: thumb_bl_out_of_range_local
2753	$(TEST_OBJDUMP) -D $< > $@
2754
2755thumb_bl_out_of_range_local: thumb_bl_out_of_range_local.o ../ld-new
2756	../ld-new --no-fix-arm1176 -T $(srcdir)/thumb_branch_range.t -o $@ $<
2757
2758thumb_bl_out_of_range_local.o: thumb_bl_out_of_range_local.s
2759	$(TEST_AS) -o $@ -march=armv5te $<
2760
2761arm_thm_jump11.stdout: arm_thm_jump11
2762	$(TEST_OBJDUMP) -D $< > $@
2763
2764arm_thm_jump11: arm_thm_jump11.o ../ld-new
2765	../ld-new -T $(srcdir)/arm_thm_jump11.t -o $@ $<
2766
2767arm_thm_jump11.o: arm_thm_jump11.s
2768	$(TEST_AS) -o $@ $<
2769
2770arm_thm_jump8.stdout: arm_thm_jump8
2771	$(TEST_OBJDUMP) -D $< > $@
2772
2773arm_thm_jump8: arm_thm_jump8.o ../ld-new
2774	../ld-new -T $(srcdir)/arm_thm_jump8.t -o $@ $<
2775
2776arm_thm_jump8.o: arm_thm_jump8.s
2777	$(TEST_AS) -o $@ $<
2778
2779MOSTLYCLEANFILES += arm_bl_in_range arm_bl_out_of_range thumb_bl_in_range \
2780	thumb_bl_out_of_range thumb2_bl_in_range thumb2_bl_out_of_range \
2781	thumb_blx_in_range thumb_blx_out_of_range thumb2_blx_in_range \
2782	thumb2_blx_out_of_range thumb_bl_out_of_range_local arm_thm_jump11 \
2783	arm_thm_jump8
2784
2785check_SCRIPTS += arm_fix_v4bx.sh
2786check_DATA += arm_fix_v4bx.stdout arm_fix_v4bx_interworking.stdout \
2787	arm_no_fix_v4bx.stdout
2788
2789arm_fix_v4bx.stdout: arm_fix_v4bx
2790	$(TEST_OBJDUMP) -D -j.text $< > $@
2791
2792arm_fix_v4bx: arm_fix_v4bx.o ../ld-new
2793	../ld-new --no-fix-arm1176 --fix-v4bx -o $@ $<
2794
2795arm_fix_v4bx.o: arm_fix_v4bx.s
2796	$(TEST_AS) -o $@ $<
2797
2798arm_fix_v4bx_interworking.stdout: arm_fix_v4bx_interworking
2799	$(TEST_OBJDUMP) -D -j.text $< > $@
2800
2801arm_fix_v4bx_interworking: arm_fix_v4bx.o ../ld-new
2802	../ld-new --no-fix-arm1176 --fix-v4bx-interworking -o $@ $<
2803
2804arm_no_fix_v4bx.stdout: arm_no_fix_v4bx
2805	$(TEST_OBJDUMP) -D -j.text $< > $@
2806
2807arm_no_fix_v4bx: arm_fix_v4bx.o ../ld-new
2808	../ld-new --no-fix-arm1176 -o $@ $<
2809
2810MOSTLYCLEANFILES += arm_fix_v4bx arm_fix_v4bx_interworking arm_no_fix_v4bx
2811
2812check_SCRIPTS += arm_attr_merge.sh
2813check_DATA += arm_attr_merge_6.stdout arm_attr_merge_6r.stdout \
2814	arm_attr_merge_7.stdout
2815
2816arm_attr_merge_6.stdout: arm_attr_merge_6
2817	$(TEST_READELF) -A $< > $@
2818
2819arm_attr_merge_6: arm_attr_merge_6a.o arm_attr_merge_6b.o
2820	../ld-new -o $@ arm_attr_merge_6a.o arm_attr_merge_6b.o
2821
2822arm_attr_merge_6a.o: arm_attr_merge_6a.s
2823	$(TEST_AS) -o $@ $<
2824
2825arm_attr_merge_6b.o: arm_attr_merge_6b.s
2826	$(TEST_AS) -o $@ $<
2827
2828arm_attr_merge_6r.stdout: arm_attr_merge_6r
2829	$(TEST_READELF) -A $< > $@
2830
2831arm_attr_merge_6r: arm_attr_merge_6b.o arm_attr_merge_6a.o
2832	../ld-new -o $@ arm_attr_merge_6b.o arm_attr_merge_6a.o
2833
2834arm_attr_merge_7.stdout: arm_attr_merge_7
2835	$(TEST_READELF) -A $< > $@
2836
2837arm_attr_merge_7: arm_attr_merge_7a.o arm_attr_merge_7b.o
2838	../ld-new -o $@ arm_attr_merge_7a.o arm_attr_merge_7b.o
2839
2840arm_attr_merge_7a.o: arm_attr_merge_7a.s
2841	$(TEST_AS) -o $@ $<
2842
2843arm_attr_merge_7b.o: arm_attr_merge_7b.s
2844	$(TEST_AS) -o $@ $<
2845
2846MOSTLYCLEANFILES += arm_attr_merge_6 arm_attr_merge_6r arm_attr_merge_7
2847
2848# ARM1176 workaround test.
2849check_SCRIPTS += arm_fix_1176.sh
2850check_DATA += arm_fix_1176_default_v6z.stdout arm_fix_1176_on_v6z.stdout \
2851	arm_fix_1176_off_v6z.stdout arm_fix_1176_default_v5te.stdout \
2852	arm_fix_1176_default_v7a.stdout arm_fix_1176_default_1156t2f_s.stdout
2853
2854arm_fix_1176_default_v6z.stdout: arm_fix_1176_default_v6z
2855	$(TEST_OBJDUMP) -D -j.foo $< > $@
2856
2857arm_fix_1176_default_v6z: arm_fix_1176_default_v6z.o ../ld-new
2858	../ld-new --section-start=.foo=0x2001014 -o $@ $<
2859
2860arm_fix_1176_default_v6z.o: arm_fix_1176.s
2861	$(TEST_AS) -march=armv6z -o $@ $<
2862
2863arm_fix_1176_on_v6z.stdout: arm_fix_1176_on_v6z
2864	$(TEST_OBJDUMP) -D -j.foo $< > $@
2865
2866arm_fix_1176_on_v6z: arm_fix_1176_on_v6z.o ../ld-new
2867	../ld-new --section-start=.foo=0x2001014 --fix-arm1176 -o $@ $<
2868
2869arm_fix_1176_on_v6z.o: arm_fix_1176.s
2870	$(TEST_AS) -march=armv6z -o $@ $<
2871
2872arm_fix_1176_off_v6z.stdout: arm_fix_1176_off_v6z
2873	$(TEST_OBJDUMP) -D -j.foo $< > $@
2874
2875arm_fix_1176_off_v6z: arm_fix_1176_off_v6z.o ../ld-new
2876	../ld-new --section-start=.foo=0x2001014 --no-fix-arm1176 -o $@ $<
2877
2878arm_fix_1176_off_v6z.o: arm_fix_1176.s
2879	$(TEST_AS) -march=armv6z -o $@ $<
2880
2881arm_fix_1176_default_v5te.stdout: arm_fix_1176_default_v5te
2882	$(TEST_OBJDUMP) -D -j.foo $< > $@
2883
2884arm_fix_1176_default_v5te: arm_fix_1176_default_v5te.o ../ld-new
2885	../ld-new --section-start=.foo=0x2001014 -o $@ $<
2886
2887arm_fix_1176_default_v5te.o: arm_fix_1176.s
2888	$(TEST_AS) -march=armv5te -o $@ $<
2889
2890arm_fix_1176_default_v7a.stdout: arm_fix_1176_default_v7a
2891	$(TEST_OBJDUMP) -D -j.foo $< > $@
2892
2893arm_fix_1176_default_v7a: arm_fix_1176_default_v7a.o ../ld-new
2894	../ld-new --section-start=.foo=0x2001014 -o $@ $<
2895
2896arm_fix_1176_default_v7a.o: arm_fix_1176.s
2897	$(TEST_AS) -march=armv7-a -o $@ $<
2898
2899arm_fix_1176_default_1156t2f_s.stdout: arm_fix_1176_default_1156t2f_s
2900	$(TEST_OBJDUMP) -D -j.foo $< > $@
2901
2902arm_fix_1176_default_1156t2f_s: arm_fix_1176_default_1156t2f_s.o ../ld-new
2903	../ld-new --section-start=.foo=0x2001014 -o $@ $<
2904
2905arm_fix_1176_default_1156t2f_s.o: arm_fix_1176.s
2906	$(TEST_AS) -mcpu=arm1156t2f-s -o $@ $<
2907
2908MOSTLYCLEANFILES += arm_fix_1176_default_v6z arm_fix_1176_on_v6z arm_fix_1176_off_v6z \
2909	arm_fix_1176_default_v5te arm_fix_1176_default_v7a arm_fix_1176_default_1156t2f_s
2910
2911# Cortex-A8 workaround test.
2912
2913check_SCRIPTS += arm_cortex_a8.sh
2914check_DATA += arm_cortex_a8_b_cond.stdout arm_cortex_a8_b.stdout \
2915	arm_cortex_a8_bl.stdout arm_cortex_a8_blx.stdout \
2916	arm_cortex_a8_local.stdout arm_cortex_a8_local_reloc.stdout
2917
2918arm_cortex_a8_b_cond.stdout: arm_cortex_a8_b_cond
2919	$(TEST_OBJDUMP) -D -j.text $< > $@
2920
2921arm_cortex_a8_b_cond: arm_cortex_a8_b_cond.o ../ld-new
2922	../ld-new -o $@ $<
2923
2924arm_cortex_a8_b_cond.o: arm_cortex_a8_b_cond.s
2925	$(TEST_AS) -o $@ $<
2926
2927arm_cortex_a8_b.stdout: arm_cortex_a8_b
2928	$(TEST_OBJDUMP) -D -j.text $< > $@
2929
2930arm_cortex_a8_b: arm_cortex_a8_b.o ../ld-new
2931	../ld-new --fix-cortex-a8 -o $@ $<
2932
2933arm_cortex_a8_b.o: arm_cortex_a8_b.s
2934	$(TEST_AS) -o $@ $<
2935
2936arm_cortex_a8_bl.stdout: arm_cortex_a8_bl
2937	$(TEST_OBJDUMP) -D -j.text $< > $@
2938
2939arm_cortex_a8_bl: arm_cortex_a8_bl.o ../ld-new
2940	../ld-new -o $@ $<
2941
2942arm_cortex_a8_bl.o: arm_cortex_a8_bl.s
2943	$(TEST_AS) -o $@ $<
2944
2945arm_cortex_a8_blx.stdout: arm_cortex_a8_blx
2946	$(TEST_OBJDUMP) -D -j.text $< > $@
2947
2948arm_cortex_a8_blx: arm_cortex_a8_blx.o ../ld-new
2949	../ld-new -o $@ $<
2950
2951arm_cortex_a8_blx.o: arm_cortex_a8_blx.s
2952	$(TEST_AS) -o $@ $<
2953
2954arm_cortex_a8_local.stdout: arm_cortex_a8_local
2955	$(TEST_OBJDUMP) -D -j.text $< > $@
2956
2957arm_cortex_a8_local: arm_cortex_a8_local.o ../ld-new
2958	../ld-new -o $@ $<
2959
2960arm_cortex_a8_local.o: arm_cortex_a8_local.s
2961	$(TEST_AS) -o $@ $<
2962
2963arm_cortex_a8_local_reloc.stdout: arm_cortex_a8_local_reloc
2964	$(TEST_OBJDUMP) -D -j.text $< > $@
2965
2966arm_cortex_a8_local_reloc: arm_cortex_a8_local_reloc.o ../ld-new
2967	../ld-new -o $@ $<
2968
2969arm_cortex_a8_local_reloc.o: arm_cortex_a8_local_reloc.s
2970	$(TEST_AS) -o $@ $<
2971
2972MOSTLYCLEANFILES += arm_cortex_a8_b_cond arm_cortex_a8_b arm_cortex_a8_bl \
2973	arm_cortex_a8_blx arm_cortex_a8_local arm_cortex_a8_local_reloc
2974
2975check_SCRIPTS += arm_exidx_test.sh
2976check_DATA += arm_exidx_test.stdout
2977
2978arm_exidx_test.stdout: arm_exidx_test.so
2979	$(TEST_READELF) -Sr $< > $@
2980
2981arm_exidx_test.so: arm_exidx_test.o ../ld-new
2982	../ld-new -shared -o $@ $<
2983
2984arm_exidx_test.o: arm_exidx_test.s
2985	$(TEST_AS) -o $@ $<
2986
2987check_SCRIPTS += pr12826.sh
2988check_DATA += pr12826.stdout
2989
2990pr12826.stdout: pr12826.so
2991	$(TEST_READELF) -A $< > $@
2992
2993pr12826.so: pr12826_1.o pr12826_2.o ../ld-new
2994	../ld-new -shared -o $@ $<
2995
2996pr12826_1.o: pr12826_1.s
2997	$(TEST_AS) -o $@ $<
2998
2999pr12826_2.o: pr12826_2.s
3000	$(TEST_AS) -o $@ $<
3001
3002check_SCRIPTS += arm_unaligned_reloc.sh
3003check_DATA += arm_unaligned_reloc.stdout arm_unaligned_reloc_r.stdout
3004
3005arm_unaligned_reloc.stdout: arm_unaligned_reloc
3006	$(TEST_OBJDUMP) -D $< > $@
3007
3008arm_unaligned_reloc_r.stdout: arm_unaligned_reloc_r
3009	$(TEST_OBJDUMP) -Dr $< > $@
3010
3011arm_unaligned_reloc: arm_unaligned_reloc.o ../ld-new
3012	../ld-new -o $@ $<
3013
3014arm_unaligned_reloc_r: arm_unaligned_reloc.o ../ld-new
3015	../ld-new -r -o $@ $<
3016
3017arm_unaligned_reloc.o: arm_unaligned_reloc.s
3018	$(TEST_AS) -o $@ $<
3019
3020MOSTLYCLEANFILES += arm_unaligned_reloc arm_unaligned_reloc_r
3021
3022# Check ARM to ARM farcall veneers
3023
3024check_SCRIPTS += arm_farcall_arm_arm.sh
3025check_DATA += arm_farcall_arm_arm.stdout
3026
3027arm_farcall_arm_arm.stdout: arm_farcall_arm_arm
3028	$(TEST_OBJDUMP) -d $< > $@
3029
3030arm_farcall_arm_arm: arm_farcall_arm_arm.o ../ld-new
3031	../ld-new --no-fix-arm1176 --section-start .text=0x1000 --section-start .foo=0x2001020 -o $@ $<
3032
3033arm_farcall_arm_arm.o: arm_farcall_arm_arm.s
3034	$(TEST_AS) -o $@ $<
3035
3036MOSTLYCLEANFILES += arm_farcall_arm_arm
3037
3038# Check ARM to Thumb farcall veneers
3039
3040check_SCRIPTS += arm_farcall_arm_thumb.sh
3041check_DATA += arm_farcall_arm_thumb.stdout arm_farcall_arm_thumb_5t.stdout
3042
3043arm_farcall_arm_thumb.stdout: arm_farcall_arm_thumb
3044	$(TEST_OBJDUMP) -D $< > $@
3045
3046arm_farcall_arm_thumb: arm_farcall_arm_thumb.o ../ld-new
3047	../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3048
3049arm_farcall_arm_thumb.o: arm_farcall_arm_thumb.s
3050	$(TEST_AS) -o $@ $<
3051
3052arm_farcall_arm_thumb_5t.stdout: arm_farcall_arm_thumb_5t
3053	$(TEST_OBJDUMP) -D $< > $@
3054
3055arm_farcall_arm_thumb_5t: arm_farcall_arm_thumb_5t.o ../ld-new
3056	../ld-new --no-fix-arm1176 --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3057
3058arm_farcall_arm_thumb_5t.o: arm_farcall_arm_thumb.s
3059	$(TEST_AS) -march=armv5t -o $@ $<
3060
3061MOSTLYCLEANFILES += arm_farcall_arm_thumb arm_farcall_arm_thumb_5t
3062
3063# Check Thumb to Thumb farcall veneers
3064
3065check_SCRIPTS += arm_farcall_thumb_thumb.sh
3066check_DATA += arm_farcall_thumb_thumb.stdout \
3067	      arm_farcall_thumb_thumb_5t.stdout \
3068	      arm_farcall_thumb_thumb_7m.stdout \
3069	      arm_farcall_thumb_thumb_6m.stdout
3070
3071arm_farcall_thumb_thumb.stdout: arm_farcall_thumb_thumb
3072	$(TEST_OBJDUMP) -D $< > $@
3073
3074arm_farcall_thumb_thumb: arm_farcall_thumb_thumb.o ../ld-new
3075	../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3076
3077arm_farcall_thumb_thumb.o: arm_farcall_thumb_thumb.s
3078	$(TEST_AS) -march=armv4t -o $@ $<
3079
3080arm_farcall_thumb_thumb_5t.stdout: arm_farcall_thumb_thumb_5t
3081	$(TEST_OBJDUMP) -D $< > $@
3082
3083arm_farcall_thumb_thumb_5t: arm_farcall_thumb_thumb_5t.o ../ld-new
3084	../ld-new --no-fix-arm1176 --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3085
3086arm_farcall_thumb_thumb_5t.o: arm_farcall_thumb_thumb.s
3087	$(TEST_AS) -march=armv5t -o $@ $<
3088
3089arm_farcall_thumb_thumb_7m.stdout: arm_farcall_thumb_thumb_7m
3090	$(TEST_OBJDUMP) -D $< > $@
3091
3092arm_farcall_thumb_thumb_7m: arm_farcall_thumb_thumb_7m.o ../ld-new
3093	../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3094
3095arm_farcall_thumb_thumb_7m.o: arm_farcall_thumb_thumb.s
3096	$(TEST_AS) -march=armv7-m -o $@ $<
3097
3098arm_farcall_thumb_thumb_6m.stdout: arm_farcall_thumb_thumb_6m
3099	$(TEST_OBJDUMP) -D $< > $@
3100
3101arm_farcall_thumb_thumb_6m: arm_farcall_thumb_thumb_6m.o ../ld-new
3102	../ld-new --section-start .text=0x1000 --section-start .foo=0x2001014 -o $@ $<
3103
3104arm_farcall_thumb_thumb_6m.o: arm_farcall_thumb_thumb.s
3105	$(TEST_AS) -march=armv6-m -o $@ $<
3106
3107MOSTLYCLEANFILES += arm_farcall_thumb_thumb arm_farcall_thumb_thumb_5t \
3108		    arm_farcall_thumb_thumb_7m arm_farcall_thumb_thumb_6m
3109
3110# Check Thumb to ARM farcall veneers
3111
3112check_SCRIPTS += arm_farcall_thumb_arm.sh
3113check_DATA += arm_farcall_thumb_arm.stdout \
3114	      arm_farcall_thumb_arm_5t.stdout
3115
3116arm_farcall_thumb_arm.stdout: arm_farcall_thumb_arm
3117	$(TEST_OBJDUMP) -D $< > $@
3118
3119arm_farcall_thumb_arm: arm_farcall_thumb_arm.o ../ld-new
3120	../ld-new --section-start .text=0x1c01010 --section-start .foo=0x2001014 -o $@ $<
3121
3122arm_farcall_thumb_arm.o: arm_farcall_thumb_arm.s
3123	$(TEST_AS) -o $@ $<
3124
3125arm_farcall_thumb_arm_5t.stdout: arm_farcall_thumb_arm_5t
3126	$(TEST_OBJDUMP) -D $< > $@
3127
3128arm_farcall_thumb_arm_5t: arm_farcall_thumb_arm_5t.o ../ld-new
3129	../ld-new --no-fix-arm1176 --section-start .text=0x1c01010 --section-start .foo=0x2001014 -o $@ $<
3130
3131arm_farcall_thumb_arm_5t.o: arm_farcall_thumb_arm.s
3132	$(TEST_AS) -march=armv5t -o $@ $<
3133
3134MOSTLYCLEANFILES += arm_farcall_thumb_arm arm_farcall_thumb_arm_5t
3135
3136endif DEFAULT_TARGET_ARM
3137
3138endif NATIVE_OR_CROSS_LINKER
3139
3140# Tests for the dwp tool.
3141# We don't want to rely yet on GCC support for -gsplit-dwarf,
3142# so we use (for now) test cases in x86 assembly language,
3143# compiled from the dwp_test_*.cc sources.
3144
3145if DEFAULT_TARGET_X86_64
3146
3147dwp_test_main.o: dwp_test_main.s
3148	$(TEST_AS) -o $@ $<
3149dwp_test_1.o: dwp_test_1.s
3150	$(TEST_AS) -o $@ $<
3151dwp_test_1b.o: dwp_test_1b.s
3152	$(TEST_AS) -o $@ $<
3153dwp_test_2.o: dwp_test_2.s
3154	$(TEST_AS) -o $@ $<
3155
3156dwp_test_main.dwo: dwp_test_main.o
3157	$(TEST_OBJCOPY) --extract-dwo $< $@
3158dwp_test_1.dwo: dwp_test_1.o
3159	$(TEST_OBJCOPY) --extract-dwo $< $@
3160dwp_test_1b.dwo: dwp_test_1b.o
3161	$(TEST_OBJCOPY) --extract-dwo $< $@
3162dwp_test_2.dwo: dwp_test_2.o
3163	$(TEST_OBJCOPY) --extract-dwo $< $@
3164
3165MOSTLYCLEANFILES += *.dwo *.dwp
3166check_SCRIPTS += dwp_test_1.sh
3167check_DATA += dwp_test_1.stdout
3168dwp_test_1.stdout: dwp_test_1.dwp
3169	$(TEST_READELF) -wi $< > $@
3170dwp_test_1.dwp: ../dwp dwp_test_main.dwo dwp_test_1.dwo dwp_test_1b.dwo dwp_test_2.dwo
3171	../dwp -o $@ dwp_test_main.dwo dwp_test_1.dwo dwp_test_1b.dwo dwp_test_2.dwo
3172
3173check_SCRIPTS += dwp_test_2.sh
3174check_DATA += dwp_test_2.stdout
3175dwp_test_2.stdout: dwp_test_2.dwp
3176	$(TEST_READELF) -wi $< > $@
3177dwp_test_2.dwp: ../dwp dwp_test_2a.dwp dwp_test_2b.dwp
3178	../dwp -o $@ dwp_test_2a.dwp dwp_test_2b.dwp
3179dwp_test_2a.dwp: ../dwp dwp_test_main.dwo dwp_test_1.dwo
3180	../dwp -o $@ dwp_test_main.dwo dwp_test_1.dwo
3181dwp_test_2b.dwp: ../dwp dwp_test_1b.dwo dwp_test_2.dwo
3182	../dwp -o $@ dwp_test_1b.dwo dwp_test_2.dwo
3183
3184endif DEFAULT_TARGET_X86_64
3185