]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-elf/exclude.exp
Update FSF addresses
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-elf / exclude.exp
1 # Expect script for --exclude-libs tests
2 # Copyright 2004 Free Software Foundation, Inc.
3 #
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17
18 # Make sure that ld can hide symbols from libraries when building a shared
19 # library.
20
21 # This test can only be run on ELF platforms.
22 if ![is_elf_format] {
23 return
24 }
25
26 # No shared lib support on this target.
27 if { [istarget "mcore-*-*"] } {
28 return
29 }
30
31 global ar
32 global as
33 global ld
34 global nm
35 global nm_output
36
37 set test1 "ld link shared library"
38 set test2 "ld export symbols from archive"
39 set test3 "ld link shared library with --exclude-libs"
40 set test4 "ld exclude symbols from archive - --exclude-libs libexclude"
41 set test5 "ld exclude symbols from archive - --exclude-libs libexclude.a"
42 set test6 "ld exclude symbols from archive - --exclude-libs ALL"
43 set test7 "ld exclude symbols from archive - --exclude-libs foo:libexclude.a"
44 set test8 "ld exclude symbols from archive - --exclude-libs foo,libexclude.a"
45 set test9 "ld don't exclude symbols from archive - --exclude-libs foo:bar"
46
47 if { ![ld_assemble $as $srcdir/$subdir/exclude1.s tmpdir/exclude1.o ]
48 || ![ld_assemble $as $srcdir/$subdir/exclude2.s tmpdir/exclude2.o] } {
49 unresolved $test1
50 return
51 }
52
53 catch "exec rm -f tmpdir/libexclude.a" catch_output
54 catch "exec $ar cq tmpdir/libexclude.a tmpdir/exclude2.o" catch_output
55 if {![string match "" $catch_output]} {
56 unresolved $test1
57 return
58 }
59
60 # Test that the symbol is normally exported.
61
62 if { [ld_simple_link $ld tmpdir/exclude.so "--shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
63 pass $test1
64 } else {
65 if [string match "*shared not supported*" $link_output] {
66 unsupported "$test1 - -shared is not supported by this target"
67 } else {
68 fail $test1
69 }
70 return
71 }
72
73 if ![ld_nm $nm "-D" tmpdir/exclude.so] {
74 unresolved $test2
75 } elseif { [info exists nm_output(exclude_sym)] } {
76 pass $test2
77 } else {
78 fail $test2
79 }
80
81 # Test --exclude-libs libexclude
82
83 if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude --shared tmpdir/exclude1.o -Ltmpdir -lexclude"] } {
84 pass $test3
85 } else {
86 fail $test3
87 }
88
89 if ![ld_nm $nm "-D" tmpdir/exclude.so] {
90 unresolved $test4
91 } elseif { ! [info exists nm_output(exclude_sym)] } {
92 pass $test4
93 } else {
94 fail $test4
95 }
96
97 # Test alternate spellings of --exclude-libs
98
99 if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
100 && [ld_nm $nm "-D" tmpdir/exclude.so]
101 && ! [info exists nm_output(exclude_sym)] } {
102 pass $test5
103 } else {
104 fail $test5
105 }
106
107 if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs ALL --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
108 && [ld_nm $nm "-D" tmpdir/exclude.so]
109 && ! [info exists nm_output(exclude_sym)] } {
110 pass $test6
111 } else {
112 fail $test6
113 }
114
115 if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
116 && [ld_nm $nm "-D" tmpdir/exclude.so]
117 && ! [info exists nm_output(exclude_sym)] } {
118 pass $test7
119 } else {
120 fail $test7
121 }
122
123 if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo,libexclude.a --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
124 && [ld_nm $nm "-D" tmpdir/exclude.so]
125 && ! [info exists nm_output(exclude_sym)] } {
126 pass $test8
127 } else {
128 fail $test8
129 }
130
131 if { [ld_simple_link $ld tmpdir/exclude.so "--exclude-libs foo:bar --shared tmpdir/exclude1.o -Ltmpdir -lexclude"]
132 && [ld_nm $nm "-D" tmpdir/exclude.so]
133 && [info exists nm_output(exclude_sym)] } {
134 pass $test9
135 } else {
136 fail $test9
137 }