1 # Process this file with automake to generate Makefile.in
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.
9 # The two_file_test tests -fmerge-constants, so we simply always turn
10 # it on. This may need to be controlled by a configure option
12 AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) -fmerge-constants
15 -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../include \
16 -I$(srcdir)/../../elfcpp \
17 -DLOCALEDIR="\"$(datadir)/locale\"" \
21 THREADSLIB = -lpthread
24 # 'make clean' is good about deleting some intermediate files (such as
25 # .o's), but not all of them (such as .so's and .err files). We
26 # improve on that here. automake-1.9 info docs say "mostlyclean" is
27 # the right choice for files 'make' builds that people rebuild.
28 MOSTLYCLEANFILES = *.so
31 # We will add to these later, for each individual test. Note
32 # that we add each test under check_SCRIPTS or check_PROGRAMS;
33 # the TESTS variable is automatically populated from these.
37 TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
39 # ---------------------------------------------------------------------
40 # These tests test the internals of gold (unittests).
42 # Infrastucture needed for the unittests
43 check_LIBRARIES = libgoldtest.a
44 libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc
47 libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL_DEP)
48 LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \
52 # The unittests themselves
53 check_PROGRAMS += object_unittest
54 object_unittest_SOURCES = object_unittest.cc
56 check_PROGRAMS += binary_unittest
57 binary_unittest_SOURCES = binary_unittest.cc
60 # ---------------------------------------------------------------------
61 # These tests test the output of gold (end-to-end tests). In
62 # particular, they make sure that gold can link "difficult" object
63 # files, and the resulting object files run correctly. These can only
64 # run if we've built ld-new for the native architecture (that is,
65 # we're not cross-compiling it), since we run ld-new as part of these
66 # tests. We use the gcc-specific flag '-B' to use our linker instead
67 # of the default linker, which is why we only run our tests under gcc.
72 # Infrastucture needed for the unittests: a directory where the linker
73 # is named 'ld'. This is because the -B flag appends 'ld' to its arg.
74 gcctestdir/ld: ../ld-new
75 test -d gcctestdir || mkdir -p gcctestdir
77 (cd gcctestdir && $(LN_S) ../../ld-new ld)
79 # Each of these .o's is a useful, small complete program. They're
80 # particularly useful for making sure ld-new's flags do what they're
81 # supposed to (hence their names), but are used for many tests that
82 # don't actually involve analyzing input data.
83 flagstest_debug.o: constructor_test.cc
84 $(CXXCOMPILE) -O0 -g -c -o $@ $<
85 flagstest_ndebug.o: constructor_test.cc
86 $(CXXCOMPILE) -O0 -c -o $@ $<
89 check_PROGRAMS += basic_test
90 check_PROGRAMS += basic_static_test
91 check_PROGRAMS += basic_pic_test
92 check_PROGRAMS += basic_static_pic_test
93 basic_test.o: basic_test.cc
94 $(CXXCOMPILE) -O0 -c -o $@ $<
95 basic_test: basic_test.o gcctestdir/ld
96 $(CXXLINK) -Bgcctestdir/ basic_test.o
97 basic_static_test: basic_test.o gcctestdir/ld
98 $(CXXLINK) -Bgcctestdir/ -static basic_test.o
100 basic_pic_test.o: basic_test.cc
101 $(CXXCOMPILE) -O0 -c -fpic -o $@ $<
102 basic_pic_test: basic_pic_test.o gcctestdir/ld
103 $(CXXLINK) -Bgcctestdir/ basic_pic_test.o
104 basic_static_pic_test: basic_pic_test.o gcctestdir/ld
105 $(CXXLINK) -Bgcctestdir/ -static basic_pic_test.o
108 check_PROGRAMS += constructor_test
109 check_PROGRAMS += constructor_static_test
110 constructor_test_SOURCES = constructor_test.cc
111 constructor_test_DEPENDENCIES = gcctestdir/ld
112 constructor_test_LDFLAGS = -Bgcctestdir/
114 constructor_static_test_SOURCES = $(constructor_test_SOURCES)
115 constructor_static_test_DEPENDENCIES = $(constructor_test_DEPENDENCIES)
116 constructor_static_test_LDFLAGS = $(constructor_test_LDFLAGS) -static
119 check_PROGRAMS += two_file_test
120 check_PROGRAMS += two_file_static_test
121 check_PROGRAMS += two_file_pic_test
122 two_file_test_SOURCES = \
124 two_file_test_1b.cc \
126 two_file_test_main.cc \
128 two_file_test_DEPENDENCIES = gcctestdir/ld
129 two_file_test_LDFLAGS = -Bgcctestdir/
131 two_file_static_test_SOURCES = $(two_file_test_SOURCES)
132 two_file_static_test_DEPENDENCIES = $(two_file_test_DEPENDENCIES)
133 two_file_static_test_LDFLAGS = $(two_file_test_LDFLAGS) -static
135 two_file_pic_test_SOURCES = two_file_test_main.cc
136 two_file_pic_test_DEPENDENCIES = \
137 gcctestdir/ld two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o
138 two_file_pic_test_LDFLAGS = -Bgcctestdir/
139 two_file_pic_test_LDADD = two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o
142 check_PROGRAMS += two_file_shared_1_test
143 check_PROGRAMS += two_file_shared_2_test
144 check_PROGRAMS += two_file_shared_1_pic_2_test
145 check_PROGRAMS += two_file_shared_2_pic_1_test
146 check_PROGRAMS += two_file_same_shared_test
147 check_PROGRAMS += two_file_separate_shared_12_test
148 check_PROGRAMS += two_file_separate_shared_21_test
149 two_file_test_1_pic.o: two_file_test_1.cc
150 $(CXXCOMPILE) -c -fpic -o $@ $<
151 two_file_test_1b_pic.o: two_file_test_1b.cc
152 $(CXXCOMPILE) -c -fpic -o $@ $<
153 two_file_test_2_pic.o: two_file_test_2.cc
154 $(CXXCOMPILE) -c -fpic -o $@ $<
155 two_file_shared_1.so: two_file_test_1_pic.o two_file_test_1b_pic.o gcctestdir/ld
156 $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o
157 two_file_shared_2.so: two_file_test_2_pic.o gcctestdir/ld
158 $(CXXLINK) -Bgcctestdir/ -shared two_file_test_2_pic.o
159 two_file_shared.so: two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o gcctestdir/ld
160 $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2_pic.o
162 two_file_shared_1_test_SOURCES = two_file_test_2.cc two_file_test_main.cc
163 two_file_shared_1_test_DEPENDENCIES = gcctestdir/ld two_file_shared_1.so
164 two_file_shared_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
165 two_file_shared_1_test_LDADD = two_file_shared_1.so
167 two_file_shared_2_test_SOURCES = two_file_test_1.cc two_file_test_1b.cc two_file_test_main.cc
168 two_file_shared_2_test_DEPENDENCIES = gcctestdir/ld two_file_shared_2.so
169 two_file_shared_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
170 two_file_shared_2_test_LDADD = two_file_shared_2.so
172 two_file_shared_1_pic_2_test_SOURCES = two_file_test_main.cc
173 two_file_shared_1_pic_2_test_DEPENDENCIES = \
174 gcctestdir/ld two_file_shared_1.so two_file_test_1_pic.o two_file_test_1b_pic.o
175 two_file_shared_1_pic_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
176 two_file_shared_1_pic_2_test_LDADD = two_file_test_1_pic.o two_file_test_1b_pic.o two_file_shared_2.so
178 two_file_shared_2_pic_1_test_SOURCES = two_file_test_main.cc
179 two_file_shared_2_pic_1_test_DEPENDENCIES = \
180 gcctestdir/ld two_file_shared_2.so two_file_test_2_pic.o
181 two_file_shared_2_pic_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
182 two_file_shared_2_pic_1_test_LDADD = two_file_test_2_pic.o two_file_shared_1.so
184 two_file_same_shared_test_SOURCES = two_file_test_main.cc
185 two_file_same_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared.so
186 two_file_same_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
187 two_file_same_shared_test_LDADD = two_file_shared.so
189 two_file_separate_shared_12_test_SOURCES = two_file_test_main.cc
190 two_file_separate_shared_12_test_DEPENDENCIES = \
191 gcctestdir/ld two_file_shared_1.so two_file_shared_2.so
192 two_file_separate_shared_12_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
193 two_file_separate_shared_12_test_LDADD = \
194 two_file_shared_1.so two_file_shared_2.so
196 two_file_separate_shared_21_test_SOURCES = two_file_test_main.cc
197 two_file_separate_shared_21_test_DEPENDENCIES = \
198 gcctestdir/ld two_file_shared_1.so two_file_shared_2.so
199 two_file_separate_shared_21_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
200 two_file_separate_shared_21_test_LDADD = \
201 two_file_shared_2.so two_file_shared_1.so
203 check_PROGRAMS += two_file_relocatable_test
204 two_file_relocatable_test_SOURCES = two_file_test_main.cc
205 two_file_relocatable_test_DEPENDENCIES = \
206 gcctestdir/ld two_file_relocatable.o
207 two_file_relocatable_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
208 two_file_relocatable_test_LDADD = two_file_relocatable.o
209 two_file_relocatable.o: gcctestdir/ld two_file_test_1.o two_file_test_1b.o two_file_test_2.o
210 gcctestdir/ld -r -o $@ two_file_test_1.o two_file_test_1b.o two_file_test_2.o
212 # The nonpic tests will fail on platforms which can not put non-PIC
213 # code into shared libraries, so we just don't run them in that case.
214 if FN_PTRS_IN_SO_WITHOUT_PIC
216 check_PROGRAMS += two_file_shared_1_nonpic_test
217 check_PROGRAMS += two_file_shared_2_nonpic_test
218 check_PROGRAMS += two_file_same_shared_nonpic_test
219 check_PROGRAMS += two_file_separate_shared_12_nonpic_test
220 check_PROGRAMS += two_file_separate_shared_21_nonpic_test
221 check_PROGRAMS += two_file_mixed_shared_test
222 check_PROGRAMS += two_file_mixed_2_shared_test
223 two_file_shared_1_nonpic.so: two_file_test_1.o gcctestdir/ld
224 $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b.o
225 two_file_shared_2_nonpic.so: two_file_test_2.o gcctestdir/ld
226 $(CXXLINK) -Bgcctestdir/ -shared two_file_test_2.o
227 two_file_shared_nonpic.so: two_file_test_1.o two_file_test_1b.o two_file_test_2.o gcctestdir/ld
228 $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b.o two_file_test_2.o
229 two_file_shared_mixed.so: two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2.o gcctestdir/ld
230 $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1_pic.o two_file_test_1b_pic.o two_file_test_2.o
231 two_file_shared_mixed_1.so: two_file_test_1.o two_file_test_1b_pic.o two_file_shared_2.so gcctestdir/ld
232 $(CXXLINK) -Bgcctestdir/ -shared two_file_test_1.o two_file_test_1b_pic.o two_file_shared_2.so
234 two_file_shared_1_nonpic_test_SOURCES = \
235 two_file_test_2.cc two_file_test_main.cc
236 two_file_shared_1_nonpic_test_DEPENDENCIES = \
237 gcctestdir/ld two_file_shared_1_nonpic.so
238 two_file_shared_1_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
239 two_file_shared_1_nonpic_test_LDADD = two_file_shared_1_nonpic.so
241 two_file_shared_2_nonpic_test_SOURCES = \
242 two_file_test_1.cc two_file_test_1b.cc two_file_test_main.cc
243 two_file_shared_2_nonpic_test_DEPENDENCIES = \
244 gcctestdir/ld two_file_shared_2_nonpic.so
245 two_file_shared_2_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
246 two_file_shared_2_nonpic_test_LDADD = two_file_shared_2_nonpic.so
248 two_file_same_shared_nonpic_test_SOURCES = two_file_test_main.cc
249 two_file_same_shared_nonpic_test_DEPENDENCIES = \
250 gcctestdir/ld two_file_shared_nonpic.so
251 two_file_same_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
252 two_file_same_shared_nonpic_test_LDADD = two_file_shared_nonpic.so
254 two_file_separate_shared_12_nonpic_test_SOURCES = two_file_test_main.cc
255 two_file_separate_shared_12_nonpic_test_DEPENDENCIES = \
256 gcctestdir/ld two_file_shared_1_nonpic.so two_file_shared_2_nonpic.so
257 two_file_separate_shared_12_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
258 two_file_separate_shared_12_nonpic_test_LDADD = \
259 two_file_shared_1_nonpic.so two_file_shared_2_nonpic.so
261 two_file_separate_shared_21_nonpic_test_SOURCES = two_file_test_main.cc
262 two_file_separate_shared_21_nonpic_test_DEPENDENCIES = \
263 gcctestdir/ld two_file_shared_1_nonpic.so two_file_shared_2_nonpic.so
264 two_file_separate_shared_21_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
265 two_file_separate_shared_21_nonpic_test_LDADD = \
266 two_file_shared_2_nonpic.so two_file_shared_1_nonpic.so
268 two_file_mixed_shared_test_SOURCES = two_file_test_main.cc
269 two_file_mixed_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared_mixed.so
270 two_file_mixed_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
271 two_file_mixed_shared_test_LDADD = two_file_shared_mixed.so
273 two_file_mixed_2_shared_test_SOURCES = two_file_test_main.cc
274 two_file_mixed_2_shared_test_DEPENDENCIES = gcctestdir/ld two_file_shared_mixed_1.so two_file_shared_2.so
275 two_file_mixed_2_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
276 two_file_mixed_2_shared_test_LDADD = two_file_shared_mixed_1.so two_file_shared_2.so
278 endif FN_PTRS_IN_SO_WITHOUT_PIC
281 check_PROGRAMS += exception_test
282 check_PROGRAMS += exception_static_test
283 check_PROGRAMS += exception_shared_1_test
284 check_PROGRAMS += exception_shared_2_test
285 check_PROGRAMS += exception_same_shared_test
286 check_PROGRAMS += exception_separate_shared_12_test
287 check_PROGRAMS += exception_separate_shared_21_test
288 exception_test_1_pic.o: exception_test_1.cc
289 $(CXXCOMPILE) -c -fpic -o $@ $<
290 exception_test_2_pic.o: exception_test_2.cc
291 $(CXXCOMPILE) -c -fpic -o $@ $<
292 exception_shared_1.so: exception_test_1_pic.o gcctestdir/ld
293 $(CXXLINK) -Bgcctestdir/ -shared exception_test_1_pic.o
294 exception_shared_2.so: exception_test_2_pic.o gcctestdir/ld
295 $(CXXLINK) -Bgcctestdir/ -shared exception_test_2_pic.o
296 exception_shared.so: exception_test_1_pic.o exception_test_2_pic.o gcctestdir/ld
297 $(CXXLINK) -Bgcctestdir/ -shared exception_test_1_pic.o exception_test_2_pic.o
299 exception_test_SOURCES = \
300 exception_test_main.cc \
301 exception_test_1.cc \
302 exception_test_2.cc \
304 exception_test_DEPENDENCIES = gcctestdir/ld
305 exception_test_LDFLAGS = -Bgcctestdir/
307 exception_static_test_SOURCES = $(exception_test_SOURCES)
308 exception_static_test_DEPENDENCIES = $(exception_test_DEPENDENCIES)
309 exception_static_test_LDFLAGS = $(exception_test_LDFLAGS) -static
311 exception_shared_1_test_SOURCES = exception_test_2.cc exception_test_main.cc
312 exception_shared_1_test_DEPENDENCIES = gcctestdir/ld exception_shared_1.so
313 exception_shared_1_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
314 exception_shared_1_test_LDADD = exception_shared_1.so
316 exception_shared_2_test_SOURCES = exception_test_1.cc exception_test_main.cc
317 exception_shared_2_test_DEPENDENCIES = gcctestdir/ld exception_shared_2.so
318 exception_shared_2_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
319 exception_shared_2_test_LDADD = exception_shared_2.so
321 exception_same_shared_test_SOURCES = exception_test_main.cc
322 exception_same_shared_test_DEPENDENCIES = gcctestdir/ld exception_shared.so
323 exception_same_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
324 exception_same_shared_test_LDADD = exception_shared.so
326 exception_separate_shared_12_test_SOURCES = exception_test_main.cc
327 exception_separate_shared_12_test_DEPENDENCIES = \
328 gcctestdir/ld exception_shared_1.so exception_shared_2.so
329 exception_separate_shared_12_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
330 exception_separate_shared_12_test_LDADD = \
331 exception_shared_1.so exception_shared_2.so
333 exception_separate_shared_21_test_SOURCES = exception_test_main.cc
334 exception_separate_shared_21_test_DEPENDENCIES = \
335 gcctestdir/ld exception_shared_1.so exception_shared_2.so
336 exception_separate_shared_21_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
337 exception_separate_shared_21_test_LDADD = \
338 exception_shared_2.so exception_shared_1.so
341 check_PROGRAMS += weak_test
342 weak_test_SOURCES = weak_test.cc
343 weak_test_DEPENDENCIES = gcctestdir/ld
344 weak_test_LDFLAGS = -Bgcctestdir/
349 check_PROGRAMS += tls_test
350 check_PROGRAMS += tls_pic_test
351 check_PROGRAMS += tls_shared_test
352 check_PROGRAMS += tls_shared_ie_test
353 tls_test_pic.o: tls_test.cc
354 $(CXXCOMPILE) -c -fpic -o $@ $<
355 tls_test_file2_pic.o: tls_test_file2.cc
356 $(CXXCOMPILE) -c -fpic -o $@ $<
357 tls_test_shared.so: tls_test_pic.o tls_test_file2_pic.o gcctestdir/ld
358 $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic.o tls_test_file2_pic.o
360 tls_test_pic_ie.o: tls_test.cc
361 $(CXXCOMPILE) -c -fpic -ftls-model=initial-exec -o $@ $<
362 tls_test_file2_pic_ie.o: tls_test_file2.cc
363 $(CXXCOMPILE) -c -fpic -ftls-model=initial-exec -o $@ $<
364 tls_test_ie_shared.so: tls_test_pic_ie.o tls_test_file2_pic_ie.o gcctestdir/ld
365 $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic_ie.o tls_test_file2_pic_ie.o
367 tls_test_SOURCES = tls_test.cc tls_test_file2.cc tls_test_main.cc tls_test.h
368 tls_test_DEPENDENCIES = gcctestdir/ld
369 tls_test_LDFLAGS = -Bgcctestdir/
370 tls_test_LDADD = -lpthread
372 tls_pic_test_SOURCES = tls_test_main.cc
373 tls_pic_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o tls_test_file2_pic.o
374 tls_pic_test_LDFLAGS = -Bgcctestdir/
375 tls_pic_test_LDADD = tls_test_pic.o tls_test_file2_pic.o -lpthread
377 tls_shared_test_SOURCES = tls_test_main.cc
378 tls_shared_test_DEPENDENCIES = gcctestdir/ld tls_test_shared.so
379 tls_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
380 tls_shared_test_LDADD = tls_test_shared.so -lpthread
382 tls_shared_ie_test_SOURCES = tls_test_main.cc
383 tls_shared_ie_test_DEPENDENCIES = gcctestdir/ld tls_test_ie_shared.so
384 tls_shared_ie_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
385 tls_shared_ie_test_LDADD = tls_test_ie_shared.so -lpthread
388 check_PROGRAMS += tls_static_test
389 check_PROGRAMS += tls_static_pic_test
391 tls_static_test_SOURCES = $(tls_test_SOURCES)
392 tls_static_test_DEPENDENCIES = $(tls_test_DEPENDENCIES)
393 tls_static_test_LDFLAGS = $(tls_test_LDFLAGS) -static
394 tls_static_test_LDADD = $(tls_test_LDADD)
396 tls_static_pic_test_SOURCES = $(tls_pic_test_SOURCES)
397 tls_static_pic_test_DEPENDENCIES = $(tls_pic_test_DEPENDENCIES)
398 tls_static_pic_test_LDFLAGS = $(tls_pic_test_LDFLAGS) -static
399 tls_static_pic_test_LDADD = $(tls_pic_test_LDADD)
402 if FN_PTRS_IN_SO_WITHOUT_PIC
403 check_PROGRAMS += tls_shared_nonpic_test
404 tls_test_shared_nonpic.so: tls_test.o tls_test_file2.o gcctestdir/ld
405 $(CXXLINK) -Bgcctestdir/ -shared tls_test.o tls_test_file2.o
407 tls_shared_nonpic_test_SOURCES = tls_test_main.cc
408 tls_shared_nonpic_test_DEPENDENCIES = gcctestdir/ld tls_test_shared_nonpic.so
409 tls_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
410 tls_shared_nonpic_test_LDADD = tls_test_shared_nonpic.so -lpthread
411 endif FN_PTRS_IN_SO_WITHOUT_PIC
416 # Test --detect-odr-violations
417 check_SCRIPTS += debug_msg.sh
419 # Create the data files that debug_msg.sh analyzes.
420 check_DATA += debug_msg.err
421 MOSTLYCLEANFILES += debug_msg.err
422 debug_msg.o: debug_msg.cc
423 $(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/debug_msg.cc
424 odr_violation1.o: odr_violation1.cc
425 $(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/odr_violation1.cc
426 odr_violation2.o: odr_violation2.cc
427 $(CXXCOMPILE) -O0 -g -c -w -o $@ $(srcdir)/odr_violation2.cc
428 debug_msg.err: debug_msg.o odr_violation1.o odr_violation2.o gcctestdir/ld
429 @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o "2>$@"
430 @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o 2>$@; \
432 echo 1>&2 "Link of debug_msg should have failed"; \
437 # See if we can also detect problems when we're linking .so's, not .o's.
438 check_DATA += debug_msg_so.err
439 MOSTLYCLEANFILES += debug_msg_so.err
440 debug_msg.so: debug_msg.cc gcctestdir/ld
441 $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
442 odr_violation1.so: odr_violation1.cc gcctestdir/ld
443 $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
444 odr_violation2.so: odr_violation2.cc gcctestdir/ld
445 $(CXXCOMPILE) -Bgcctestdir/ -O0 -g -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
446 debug_msg_so.err: debug_msg.so odr_violation1.so odr_violation2.so gcctestdir/ld
447 @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so "2>$@"
448 @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so 2>$@; \
450 echo 1>&2 "Link of debug_msg_so should have failed"; \
455 # We also want to make sure we do something reasonable when there's no
456 # debug info available. For the best test, we use .so's.
457 check_DATA += debug_msg_ndebug.err
458 MOSTLYCLEANFILES += debug_msg_ndebug.err
459 debug_msg_ndebug.so: debug_msg.cc gcctestdir/ld
460 $(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/debug_msg.cc
461 odr_violation1_ndebug.so: odr_violation1.cc gcctestdir/ld
462 $(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation1.cc
463 odr_violation2_ndebug.so: odr_violation2.cc gcctestdir/ld
464 $(CXXCOMPILE) -Bgcctestdir/ -O0 -g0 -shared -fPIC -w -o $@ $(srcdir)/odr_violation2.cc
465 debug_msg_ndebug.err: debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so gcctestdir/ld
466 @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so "2>$@"
467 @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so 2>$@; \
469 echo 1>&2 "Link of debug_msg_ndebug should have failed"; \
475 # Similar to --detect-odr-violations: check for undefined symbols in .so's
476 check_SCRIPTS += undef_symbol.sh
477 check_DATA += undef_symbol.err
478 MOSTLYCLEANFILES += undef_symbol.err
479 undef_symbol.o: undef_symbol.cc
480 $(CXXCOMPILE) -O0 -g -c -fPIC $<
481 undef_symbol.so: undef_symbol.o gcctestdir/ld
482 $(CXXLINK) -Bgcctestdir/ -shared undef_symbol.o
483 undef_symbol.err: undef_symbol_main.o undef_symbol.so gcctestdir/ld
484 @echo $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so "2>$@"
485 @if $(CXXLINK) -Bgcctestdir/ -o undef_symbol_test undef_symbol_main.o undef_symbol.so 2>$@; \
487 echo 1>&2 "Link of undef_symbol_test should have failed"; \
493 # Test --compress-debug-sections. FIXME: check we actually compress.
494 check_PROGRAMS += flagstest_compress_debug_sections
495 flagstest_compress_debug_sections: flagstest_debug.o gcctestdir/ld
496 $(CXXLINK) -Bgcctestdir/ -o $@ $< --compress-debug-sections=zlib
500 # Test -o when emitting to a special file (such as something in /dev).
501 check_PROGRAMS += flagstest_o_specialfile
502 flagstest_o_specialfile: flagstest_debug.o gcctestdir/ld
503 $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< 2>&1 | cat > $@
507 # The specialfile output has a tricky case when we also compress debug
508 # sections, because it requires output-file resizing.
509 check_PROGRAMS += flagstest_o_specialfile_and_compress_debug_sections
510 flagstest_o_specialfile_and_compress_debug_sections: flagstest_debug.o \
512 $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< --compress-debug-sections=zlib 2>&1 | cat > $@
516 # Test symbol versioning.
517 check_PROGRAMS += ver_test
518 ver_test_SOURCES = ver_test_main.cc
519 ver_test_DEPENDENCIES = gcctestdir/ld ver_test_1.so ver_test_2.so ver_test_4.so
520 ver_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
521 ver_test_LDADD = ver_test_1.so ver_test_2.so ver_test_4.so
522 ver_test_1.so: ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so gcctestdir/ld
523 $(CXXLINK) -Bgcctestdir/ -shared ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so
524 ver_test_2.so: ver_test_2.o $(srcdir)/ver_test_2.script ver_test_4.so gcctestdir/ld
525 $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_2.script ver_test_2.o ver_test_4.so
526 ver_test_4.so: ver_test_4.o $(srcdir)/ver_test_4.script gcctestdir/ld
527 $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o
528 ver_test_1.o: ver_test_1.cc
529 $(CXXCOMPILE) -c -fpic -o $@ $<
530 ver_test_2.o: ver_test_2.cc
531 $(CXXCOMPILE) -c -fpic -o $@ $<
532 ver_test_3.o: ver_test_3.cc
533 $(CXXCOMPILE) -c -fpic -o $@ $<
534 ver_test_4.o: ver_test_4.cc
535 $(CXXCOMPILE) -c -fpic -o $@ $<
537 check_PROGRAMS += script_test_1
538 script_test_1_SOURCES = script_test_1.cc
539 script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
540 script_test_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_1.t
542 check_PROGRAMS += script_test_2
543 script_test_2_SOURCES = script_test_2.cc script_test_2a.cc script_test_2b.cc
544 script_test_2_DEPENDENCIES = gcctestdir/ld script_test_2.t
545 script_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_2.t
547 check_PROGRAMS += justsyms
548 justsyms_SOURCES = justsyms_1.cc
549 justsyms_DEPENDENCIES = gcctestdir/ld justsyms_2r.o
550 justsyms_LDFLAGS = -Bgcctestdir/ -Wl,-R,justsyms_2r.o
551 justsyms_2.o: justsyms_2.cc
552 $(CXXCOMPILE) -c -o $@ $<
553 justsyms_2r.o: justsyms_2.o gcctestdir/ld
554 gcctestdir/ld -o $@ -r -T $(srcdir)/justsyms.t justsyms_2.o
556 check_PROGRAMS += binary_test
557 binary_test_SOURCES = binary_test.cc
558 binary_test_DEPENDENCIES = gcctestdir/ld binary.txt
559 binary_test_LDFLAGS = -Bgcctestdir/ -Wl,--format,binary,binary.txt,--format,elf
560 # Copy the file to the build directory to avoid worrying about the
561 # full pathname in the generated symbols.
562 binary.txt: $(srcdir)/binary.in
566 if OBJDUMP_AND_CPPFILT
567 check_SCRIPTS += ver_matching_test.sh
568 check_DATA += ver_matching_test.stdout
569 MOSTLYCLEANFILES += ver_matching_test.stdout
570 ver_matching_def.so: ver_matching_def.cc gcctestdir/ld
571 $(CXXLINK) -O0 -Bgcctestdir/ -shared $(srcdir)/ver_matching_def.cc -Wl,--version-script=$(srcdir)/version_script.map
572 ver_matching_test.stdout: ver_matching_def.so
573 objdump -T ver_matching_def.so | c++filt > ver_matching_test.stdout
575 check_PROGRAMS += script_test_3
576 check_SCRIPTS += script_test_3.sh
577 check_DATA += script_test_3.stdout
578 MOSTLYCLEANFILES += script_test_3.stdout
579 script_test_3: basic_test.o gcctestdir/ld script_test_3.t
580 $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_3.t
581 script_test_3.stdout: script_test_3
582 objdump -p script_test_3 > script_test_3.stdout
583 endif OBJDUMP_AND_CPPFILT