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