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