Update year range in copyright notice of binutils files
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elfvsb / elfvsb.exp
CommitLineData
6fc49d28 1# Expect script for ld-visibility tests
b3adc24a 2# Copyright (C) 2000-2020 Free Software Foundation, Inc.
6fc49d28 3#
f96b4a7b
NC
4# This file is part of the GNU Binutils.
5#
6# This program is free software; you can redistribute it and/or modify
6fc49d28 7# it under the terms of the GNU General Public License as published by
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
6fc49d28 9# (at your option) any later version.
f96b4a7b 10#
6fc49d28
L
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
f96b4a7b 15#
6fc49d28
L
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
6fc49d28
L
20#
21# Written by Ian Lance Taylor (ian@cygnus.com)
22# and H.J. Lu (hjl@gnu.org)
23#
24
25# Make sure that ld can generate ELF shared libraries with visibility.
26
d9816402 27# Check to see if the C compiler works
44ed8092 28if { ![check_compiler_available] } {
d9816402
AM
29 return
30}
31
6fc49d28
L
32# This test can only be run on a couple of ELF platforms.
33# Square bracket expressions seem to confuse istarget.
19c7c582
AM
34if { ![istarget hppa*64*-*-hpux*] \
35 && ![istarget hppa*-*-linux*] \
36 && ![istarget i?86-*-linux*] \
5940a93c 37 && ![istarget i?86-*-gnu*] \
5a68afcf 38 && ![istarget *-*-nacl*] \
ad995491 39 && ![istarget ia64-*-linux*] \
6fc49d28 40 && ![istarget m68k-*-linux*] \
66517a2f 41 && ![istarget mips*-*-linux*] \
81cacc15 42 && ![istarget powerpc*-*-linux*] \
4f38fc1c 43 && ![istarget arm*-*-linux*] \
2ffd68ef 44 && ![istarget alpha*-*-linux*] \
9147e853
JJ
45 && ![istarget sparc*-*-linux*] \
46 && ![istarget s390*-*-linux*] \
59758b1c 47 && ![istarget sh\[34\]*-*-linux*] \
9147e853 48 && ![istarget x86_64-*-linux*] } {
6fc49d28
L
49 return
50}
51
04827a14
L
52set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
53foreach t $test_list {
54 # We need to strip the ".d", but can leave the dirname.
55 verbose [file rootname $t]
56 run_dump_test [file rootname $t]
57}
58
6fc49d28
L
59set tmpdir tmpdir
60set SHCFLAG ""
a9f844b1 61set shared_needs_pic "no"
91f8bf69 62set COMPRESS_LDFLAG "-Wl,--compress-debug-sections=zlib-gabi"
6fc49d28
L
63
64if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
65
66 # AIX shared libraries do not seem to support useful features,
67 # like overriding the shared library function or letting the
68 # shared library refer to objects defined in the main program. We
69 # avoid testing those features.
70 set SHCFLAG "-DXCOFF_TEST"
71
72 # The AIX 3.2.5 loader appears to randomly fail when loading
73 # shared libraries from NSF mounted partitions, so we avoid any
74 # potential problems by using a local directory.
75 catch {exec /bin/sh -c "echo $$"} pid
76 set tmpdir /usr/tmp/ld.$pid
77 catch "exec mkdir $tmpdir" exec_status
78
79 # On AIX, we need to explicitly export the symbols the shared
80 # library is going to provide, and need.
81 set file [open $tmpdir/xcoff.exp w]
82 puts $file shlibvar1
83 puts $file shlibvar2
84 puts $file shlib_shlibvar1
85 puts $file shlib_shlibvar2
86 puts $file shlib_shlibcall
87 puts $file shlib_shlibcalled
88 puts $file shlib_checkfunptr1
89 puts $file shlib_getfunptr1
90 puts $file shlib_check
91 close $file
92}
93
a9f844b1
NC
94if [istarget arm*-*-linux*] {
95 # On ARM section anchors can change the symbol pre-emptability for
5a68afcf 96 # non-PIC shared libraries, causing these tests to fail. Turn section
a9f844b1
NC
97 # anchors off.
98 set SHCFLAG "-fno-section-anchors"
99
5a68afcf 100 # On targets that have MOVW the compiler will emit relocations which
a9f844b1 101 # the linker doesn't support when compiling -shared without -fpic. The
5a68afcf 102 # test to find out whether we want to XFAIL the non-PIC tests requires
a9f844b1 103 # a compile - so we pre-calculate it here. We also note that this can
0085488a
WN
104 # only affect arm*-*-*eabi* targets as the old ABI doesn't support v7.
105 if [istarget arm*-*-*eabi*] {
a9f844b1
NC
106 set file [open $tmpdir/movw-detect.c w]
107 puts $file "void foo(void) { __asm (\"movw r0, #0\"); }"
108 close $file
109 if [run_host_cmd_yesno "$CC" "$CFLAGS -c $tmpdir/movw-detect.c -o $tmpdir/movw-detect.o"] {
110 set shared_needs_pic "yes"
111 }
112 }
113}
114
08c44e65
L
115set support_protected "no"
116
5940a93c 117if { [istarget *-*-linux*]
5a68afcf 118 || [istarget *-*-nacl*]
5940a93c 119 || [istarget *-*-gnu*] } {
360e9586 120 if [ld_compile "$CC -g $CFLAGS -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] {
d9816402 121 if [ld_link $CC $tmpdir/main "$tmpdir/main.o"] {
08c44e65
L
122 catch "exec $tmpdir/main" support_protected
123 }
124 }
125}
126
6fc49d28
L
127# The test procedure.
128proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
b765d4e3 129 global CC
6fc49d28
L
130 global srcdir
131 global subdir
132 global exec_output
133 global link_output
134 global host_triplet
135 global tmpdir
136
137 if [llength $args] { set shldflags [lindex $args 0] } else { set shldflags "" }
138
139 # Build the shared library.
140 # On AIX, we need to use an export file.
141 set shared -shared
142 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
143 set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
144 }
d9816402 145 if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
7cda33a1 146 if { [ string match $visibility "hidden_undef" ]
1ba54ee0
AM
147 && [regexp "undefined reference to \`\.?visibility\'" $link_output]
148 && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
7cda33a1
L
149 pass "$testname"
150 } else { if { [ string match $visibility "protected_undef" ]
1ba54ee0
AM
151 && [regexp "undefined reference to \`\.?visibility\'" $link_output]
152 && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
7cda33a1
L
153 pass "$testname"
154 } else {
155 fail "$testname"
156 }}
6fc49d28
L
157 return
158 }
159
160 # Link against the shared library. Use -rpath so that the
161 # dynamic linker can locate the shared library at runtime.
162 # On AIX, we must include /lib in -rpath, as otherwise the loader
163 # can not find -lc.
164 set rpath $tmpdir
165 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
166 set rpath /lib:$tmpdir
167 }
d9816402 168 if ![ld_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
6fc49d28 169 if { [ string match $visibility "hidden" ]
1ba54ee0
AM
170 && [regexp "undefined reference to \`\.?visibility\'" $link_output]
171 && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
7cda33a1
L
172 pass "$testname"
173 } else { if { [ string match $visibility "hidden_undef_def" ]
1ba54ee0
AM
174 && [regexp "undefined reference to \`\.?visibility\'" $link_output]
175 && [regexp "undefined reference to \`visibility_def\'" $link_output]
176 && [regexp "undefined reference to \`\.?visibility_func\'" $link_output]
177 && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
6fc49d28
L
178 pass "$testname"
179 } else {
180 fail "$testname"
7cda33a1 181 }}
6fc49d28
L
182 return
183 }
184
7cda33a1
L
185 if { [ string match $visibility "hidden" ]
186 || [ string match $visibility "hidden_undef" ]
187 || [ string match $visibility "protected_undef" ] } {
6fc49d28
L
188 fail "$testname"
189 }
190
d9816402
AM
191 if ![isnative] {
192 unsupported "$testname"
193 return
194 }
195
6fc49d28
L
196 # Run the resulting program
197 send_log "$tmpdir/$progname >$tmpdir/$progname.out\n"
198 verbose "$tmpdir/$progname >$tmpdir/$progname.out"
199 catch "exec $tmpdir/$progname >$tmpdir/$progname.out" exec_output
200 if ![string match "" $exec_output] then {
201 send_log "$exec_output\n"
202 verbose "$exec_output"
203 fail "$testname"
204 return
205 }
206
207 send_log "diff $tmpdir/$progname.out $srcdir/$subdir/$dat.dat\n"
208 verbose "diff $tmpdir/$progname.out $srcdir/$subdir/$dat.dat"
209 catch "exec diff $tmpdir/$progname.out $srcdir/$subdir/$dat.dat" exec_output
210 set exec_output [prune_warnings $exec_output]
211
212 if {![string match "" $exec_output]} then {
213 send_log "$exec_output\n"
214 verbose "$exec_output"
215 fail "$testname"
216 return
217 }
218
219 pass "$testname"
220}
221
222proc visibility_run {visibility} {
223 global CC
224 global CFLAGS
225 global SHCFLAG
226 global srcdir
227 global subdir
228 global tmpdir
229 global picflag
230 global target_triplet
08c44e65 231 global support_protected
a9f844b1 232 global shared_needs_pic
faebca03 233 global PLT_CFLAGS
922109c7 234 global NOPIE_CFLAGS
91f8bf69 235 global COMPRESS_LDFLAG
6fc49d28
L
236
237 if [ string match $visibility "hidden" ] {
238 set VSBCFLAG "-DHIDDEN_TEST"
239 } else { if [ string match $visibility "hidden_normal" ] {
240 set VSBCFLAG "-DHIDDEN_NORMAL_TEST"
7cda33a1
L
241 } else { if [ string match $visibility "hidden_undef" ] {
242 set VSBCFLAG "-DHIDDEN_UNDEF_TEST"
243 } else { if [ string match $visibility "hidden_undef_def" ] {
244 set VSBCFLAG "-DHIDDEN_UNDEF_TEST -DDSO_DEFINE_TEST"
245 } else { if [ string match $visibility "hidden_weak" ] {
246 set VSBCFLAG "-DHIDDEN_WEAK_TEST"
6fc49d28
L
247 } else { if [ string match $visibility "protected" ] {
248 set VSBCFLAG "-DPROTECTED_TEST"
7cda33a1
L
249 } else { if [ string match $visibility "protected_undef" ] {
250 set VSBCFLAG "-DPROTECTED_UNDEF_TEST"
251 } else { if [ string match $visibility "protected_undef_def" ] {
252 set VSBCFLAG "-DPROTECTED_UNDEF_TEST -DDSO_DEFINE_TEST"
253 } else { if [ string match $visibility "protected_weak" ] {
254 set VSBCFLAG "-DPROTECTED_WEAK_TEST"
6fc49d28
L
255 } else {
256 set VSBCFLAG ""
7cda33a1 257 }}}}}}}}}
6fc49d28 258
37095d07
AM
259 # Ensure we always start with a clean slate, for the "file exists"
260 # tests below.
261 remote_file host delete $tmpdir/sh1p.o $tmpdir/sh2p.o $tmpdir/sh1np.o $tmpdir/sh2np.o
262
fb35d3d8
DD
263 if { [istarget powerpc*-*-linux*] \
264 || ( [istarget mips*-*-linux*] && [at_least_gcc_version 4 3] )} {
2893311c
AM
265 # Testing non-PIC libraries is a waste of effort on any target.
266 # If you don't pass -fpic or -fPIC to gcc, gcc will assume quite
267 # reasonably that you are not compiling for a shared library.
268 # It can then make optimisations that result in shared library
269 # functions and variables not being overridable. Newer versions
270 # of gcc are more likely to do this.
271 } else {
faebca03
L
272 # Compile the main program. Make sure that PLT is used since PLT
273 # is expected.
274 if ![ld_compile "$CC -g $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
6fc49d28
L
275 unresolved "visibility ($visibility) (non PIC)"
276 unresolved "visibility ($visibility)"
277 } else {
278 # The shared library is composed of two files. First compile them
279 # without using -fpic. That should work on an ELF system,
280 # although it will be less efficient because the dynamic linker
281 # will need to do more relocation work. However, note that not
282 # using -fpic will cause some of the tests to return different
faebca03 283 # results. Make sure that PLT is used since PLT is expected.
922109c7
L
284 if { ![ld_compile "$CC -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
285 || ![ld_compile "$CC -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
6fc49d28
L
286 unresolved "visibility ($visibility) (non PIC)"
287 } else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
ad995491 288 visibility_test $visibility vnp "visibility ($visibility) (non PIC)" mainnp.o sh1np.o sh2np.o xcoff
6fc49d28
L
289 } else {
290 # SunOS non PIC shared libraries don't permit some cases of
291 # overriding.
1345a0c0
L
292 if { [ string match $visibility "protected" ]
293 || [ string match $visibility "protected_undef_def" ] } {
08c44e65
L
294 if [ string match $support_protected "no" ] {
295 setup_xfail $target_triplet
296 }
6fc49d28 297 }
212a6b8e
RH
298
299 # Non-pic code uses name binding rules for applications to
300 # reference variables by gp-relative relocs, which can't be
301 # used with overridable symbols.
ad995491
L
302 if { ![ string match $visibility "hidden_undef" ]
303 && ![ string match $visibility "protected_undef" ] } {
304 setup_xfail "ia64-*-linux*"
212a6b8e 305 setup_xfail "alpha*-*-linux*"
ad995491 306 }
4648dfcf
MS
307 if { ![ string match $visibility "hidden" ]
308 && ![ string match $visibility "hidden_undef" ]
309 && ![ string match $visibility "hidden_undef_def" ]
310 && ![ string match $visibility "protected_undef" ] } {
311 setup_xfail "s390x-*-linux*"
4dc570c2
JJ
312 if { [istarget sparc*-*-linux*] && [is_elf64 $tmpdir/mainnp.o] } {
313 setup_xfail "sparc*-*-linux*"
314 }
4648dfcf 315 }
8b778942
L
316 if { [is_elf64 $tmpdir/mainnp.o] } {
317 setup_xfail "x86_64-*-linux*"
318 }
3c995545 319 setup_xfail "x86_64-*-linux-gnux32"
c0d48c0b
DA
320 if { ![istarget hppa*64*-*-linux*] } {
321 setup_xfail "hppa*-*-linux*"
322 }
a9f844b1
NC
323 if [ string match $shared_needs_pic "yes" ] {
324 setup_xfail "arm*-*-linux*"
325 }
212a6b8e 326
6fc49d28
L
327 visibility_test $visibility vnp "visibility ($visibility) (non PIC)" mainnp.o sh1np.o sh2np.o elfvsb
328
329 # Test ELF shared library relocations with a non-zero load
330 # address for the library. Near as I can tell, the R_*_RELATIVE
331 # relocations for various targets are broken in the case where
332 # the load address is not zero (which is the default).
1345a0c0
L
333 if { [ string match $visibility "protected" ]
334 || [ string match $visibility "protected_undef_def" ] } {
08c44e65
L
335 if [ string match $support_protected "no" ] {
336 setup_xfail $target_triplet
337 }
6fc49d28 338 }
d1d8dddf
L
339 if { [ string match $visibility "hidden_normal" ]
340 || [ string match $visibility "hidden_weak" ]
341 || [ string match $visibility "protected" ]
342 || [ string match $visibility "protected_undef_def" ]
343 || [ string match $visibility "protected_weak" ]
344 || [ string match $visibility "normal" ] } {
345 setup_xfail "powerpc-*-linux*"
8c37241b 346 setup_xfail "s390x-*-linux*"
4dc570c2
JJ
347 if { [istarget sparc*-*-linux*] && [is_elf64 $tmpdir/mainnp.o] } {
348 setup_xfail "sparc*-*-linux*"
349 }
d1d8dddf 350 }
ad995491
L
351 if { ![ string match $visibility "hidden_undef" ]
352 && ![ string match $visibility "protected_undef" ] } {
353 setup_xfail "ia64-*-linux*"
212a6b8e 354 setup_xfail "alpha*-*-linux*"
66517a2f 355 setup_xfail "mips*-*-linux*"
ad995491 356 }
8b778942
L
357 if { [is_elf64 $tmpdir/mainnp.o] } {
358 setup_xfail "x86_64-*-linux*"
359 }
3c995545 360 setup_xfail "x86_64-*-linux-gnux32"
c0d48c0b
DA
361 if { ![istarget hppa*64*-*-linux*] } {
362 setup_xfail "hppa*-*-linux*"
363 }
a9f844b1
NC
364 if [ string match $shared_needs_pic "yes" ] {
365 setup_xfail "arm*-*-linux*"
366 }
c0d48c0b 367
6fc49d28
L
368 visibility_test $visibility vnp "visibility ($visibility) (non PIC, load offset)" \
369 mainnp.o sh1np.o sh2np.o elfvsb \
bab55c05 370 "-Wl,-T,$srcdir/$subdir/elf-offset.ld,--hash-style=sysv"
6fc49d28
L
371 } }
372
373 # Now compile the code using -fpic.
374
5a68afcf 375 if { ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG -DSHARED $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o]
125c6493 376 || ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG -DSHARED $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
6fc49d28
L
377 unresolved "visibility ($visibility)"
378 } else {
1345a0c0
L
379 if { [ string match $visibility "protected" ]
380 || [ string match $visibility "protected_undef_def" ] } {
08c44e65
L
381 if [ string match $support_protected "no" ] {
382 setup_xfail $target_triplet
383 }
6fc49d28 384 }
c9098af4 385 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
6fc49d28
L
386 visibility_test $visibility vp "visibility ($visibility)" mainnp.o sh1p.o sh2p.o xcoff
387 } else {
91f8bf69 388 visibility_test $visibility vp "visibility ($visibility)" mainnp.o sh1p.o sh2p.o elfvsb $COMPRESS_LDFLAG
c9098af4 389 }
6fc49d28 390 }
2893311c 391 }}
6fc49d28 392
2893311c
AM
393 if { [istarget powerpc*-*-linux*] } {
394 # Don't bother.
395 } else {
6fc49d28 396 # Now do the same tests again, but this time compile main.c PIC.
125c6493 397 if ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG -DSHARED $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
6fc49d28
L
398 unresolved "visibility ($visibility) (PIC main, non PIC so)"
399 unresolved "visibility ($visibility) (PIC main)"
400 } else {
37095d07
AM
401 if { [ remote_file host exists $tmpdir/sh1np.o ]
402 && [ remote_file host exists $tmpdir/sh2np.o ] } {
6fc49d28
L
403 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
404 visibility_test $visibility vmpnp "visibility ($visibility) (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o xcoff
405 } else {
406 # SunOS non PIC shared libraries don't permit some cases of
407 # overriding.
1345a0c0
L
408 if { [ string match $visibility "protected" ]
409 || [ string match $visibility "protected_undef_def" ] } {
08c44e65
L
410 if [ string match $support_protected "no" ] {
411 setup_xfail $target_triplet
412 }
6fc49d28 413 }
ad995491
L
414 if { ![ string match $visibility "hidden_undef" ]
415 && ![ string match $visibility "protected_undef" ] } {
416 setup_xfail "ia64-*-linux*"
212a6b8e 417 setup_xfail "alpha*-*-linux*"
ad995491 418 }
4648dfcf
MS
419 if { ![ string match $visibility "hidden" ]
420 && ![ string match $visibility "hidden_undef" ]
421 && ![ string match $visibility "hidden_undef_def" ]
422 && ![ string match $visibility "protected_undef" ] } {
423 setup_xfail "s390x-*-linux*"
4dc570c2
JJ
424 if { [istarget sparc*-*-linux*] && [is_elf64 $tmpdir/mainp.o] } {
425 setup_xfail "sparc*-*-linux*"
426 }
4648dfcf 427 }
8b778942
L
428 if { [is_elf64 $tmpdir/mainp.o] } {
429 setup_xfail "x86_64-*-linux*"
430 }
3c995545 431 setup_xfail "x86_64-*-linux-gnux32"
c0d48c0b
DA
432 if { ![istarget hppa*64*-*-linux*] } {
433 setup_xfail "hppa*-*-linux*"
434 }
a9f844b1
NC
435 if [ string match $shared_needs_pic "yes" ] {
436 setup_xfail "arm*-*-linux*"
437 }
c0d48c0b 438
6fc49d28
L
439 visibility_test $visibility vmpnp "visibility ($visibility) (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o elfvsb
440 }
441 } else {
442 unresolved "visibility (PIC main, non PIC so)"
443 }
444
37095d07
AM
445 if { [ remote_file host exists $tmpdir/sh1p.o ]
446 && [ remote_file host exists $tmpdir/sh2p.o ] } {
1345a0c0
L
447 if { [ string match $visibility "protected" ]
448 || [ string match $visibility "protected_undef_def" ] } {
08c44e65
L
449 if [ string match $support_protected "no" ] {
450 setup_xfail $target_triplet
451 }
6fc49d28
L
452 }
453 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
454 visibility_test $visibility vmpp "visibility ($visibility) (PIC main)" mainp.o sh1p.o sh2p.o xcoff
455 } else {
456 visibility_test $visibility vmpp "visibility ($visibility) (PIC main)" mainp.o sh1p.o sh2p.o elfvsb
457 }
458 } else {
459 unresolved "visibility ($visibility) (PIC main)"
460 }
2893311c 461 }}
6fc49d28
L
462}
463
fb35d3d8
DD
464# Old version of GCC for MIPS default to enabling -fpic
465# and get confused if it is used on the command line.
466if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
6fc49d28
L
467 set picflag ""
468} else {
469 # Unfortunately, the gcc argument is -fpic and the cc argument is
470 # -KPIC. We have to try both.
471 set picflag "-fpic"
472 send_log "$CC $picflag\n"
473 verbose "$CC $picflag"
474 catch "exec $CC $picflag" exec_output
475 send_log "$exec_output\n"
476 verbose "--" "$exec_output"
477 if { [string match "*illegal option*" $exec_output] \
478 || [string match "*option ignored*" $exec_output] \
479 || [string match "*unrecognized option*" $exec_output] \
480 || [string match "*passed to ld*" $exec_output] } {
c9098af4 481 set picflag "-KPIC"
6fc49d28
L
482 }
483}
484verbose "Using $picflag to compile PIC code"
485
486visibility_run hidden
487visibility_run hidden_normal
7cda33a1
L
488visibility_run hidden_undef
489visibility_run hidden_undef_def
490visibility_run hidden_weak
6fc49d28 491visibility_run protected
7cda33a1
L
492visibility_run protected_undef
493visibility_run protected_undef_def
494visibility_run protected_weak
6fc49d28
L
495visibility_run normal
496
22d5e339
L
497if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
498 unresolved "common hidden symbol"
499} else {
d9816402 500 if ![ld_link $ld tmpdir/common "tmpdir/common.o"] {
22d5e339
L
501 fail "common hidden symbol"
502 } else {
503 pass "common hidden symbol"
504 }
505}
506
507if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
508 unresolved "weak hidden symbol"
509} else {
125c6493 510 if { ![ld_compile "$CC -g $CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
22d5e339
L
511 unresolved "weak hidden symbol"
512 } else {
d9816402 513 if ![ld_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
22d5e339
L
514 fail "weak hidden symbol"
515 } else {
d9816402 516 if ![ld_link $ld tmpdir/weak "tmpdir/test.o tmpdir/sh3.o"] {
22d5e339
L
517 fail "weak hidden symbol DSO last"
518 } else {
519 pass "weak hidden symbol DSO last"
520 }
d9816402 521 if ![ld_link $ld tmpdir/weak "tmpdir/sh3.so tmpdir/test.o"] {
22d5e339
L
522 fail "weak hidden symbol DSO first"
523 } else {
524 pass "weak hidden symbol DSO first"
525 }
526 }
527 }
528}
529
6fc49d28
L
530if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
531 # Remove the temporary directory.
532 catch "exec rm -rf $tmpdir" exec_status
533}
This page took 1.159422 seconds and 4 git commands to generate.