ld: Hide symbols defined by HIDDEN/PROVIDE_HIDDEN
[external/binutils.git] / ld / testsuite / ld-elf / provide-hidden.exp
1 # Expect script for the PROVIDE_HIDDEN linker script command.
2 #
3 # Copyright (C) 2013-2018 Free Software Foundation, Inc.
4 #
5 # This file is part of the GNU Binutils.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 # MA 02110-1301, USA.
21 #
22
23 #
24 # Written by Maciej W. Rozycki <macro@codesourcery.com>
25 #
26
27 # Export classes only make sense for ELF shared-library targets.
28 if { ![is_elf_format] || ![check_shared_lib_support] } {
29     return
30 }
31
32 # This target requires extra GAS options when building code for shared
33 # libraries.
34 set AFLAGS_PIC ""
35 if [istarget "tic6x-*-*"] {
36     append AFLAGS_PIC " -mpic -mpid=near"
37 }
38 # These targets do not default to linking with shared libraries.
39 if { [istarget "mips*vr4100*-*-elf*"] \
40      || [istarget "mips*vr4300*-*-elf*"] \
41      || [istarget "mips*vr5000*-*-elf*"] } {
42     append LFLAGS " -call_shared"
43 }
44
45 set testname "PROVIDE_HIDDEN test"
46
47 run_ld_link_tests [list \
48     [list \
49         "$testname (auxiliary shared object)" \
50         "-shared -T provide-hidden-s.ld" "" \
51         "$AFLAGS_PIC" \
52         [list provide-hidden-1.s ] \
53         [list "readelf -s provide-hidden-s.nd"] \
54         "provide-hidden-s.so"]]
55
56 run_ld_link_tests [list \
57     [list \
58         "$testname 1" \
59         "-T provide-hidden-1.ld" "" \
60         "" \
61         [list provide-hidden-1.s] \
62         [list \
63             [list readelf -s provide-hidden-def.nd] \
64             [list readelf -s provide-hidden-dyn.nd]] \
65         "provide-hidden-1"] \
66     [list \
67         "$testname 2" \
68         "-T provide-hidden-1.ld" "" \
69         "" \
70         [list provide-hidden-2.s] \
71         [list \
72             [list readelf -s provide-hidden-def.nd] \
73             [list readelf -s provide-hidden-dyn.nd]] \
74         "provide-hidden-2"] \
75     [list \
76         "$testname 3" \
77         "-T provide-hidden-1.ld" "" \
78         "" \
79         [list provide-hidden-3.s] \
80         [list \
81             [list readelf -s provide-hidden-sec.nd] \
82             [list readelf -s provide-hidden-dyn.nd]] \
83         "provide-hidden-3"] \
84     [list \
85         "$testname 4" \
86         "$LFLAGS -T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
87         "" \
88         [list provide-hidden-3.s] \
89         [list \
90             [list readelf -s provide-hidden-sec.nd] \
91             [list readelf -s provide-hidden-dyn.nd]] \
92         "provide-hidden-4"] \
93     [list \
94         "$testname 5" \
95         "-T provide-hidden-1.ld" "" \
96         "" \
97         [list provide-hidden-4.s] \
98         [list \
99             [list readelf -s provide-hidden-sec.nd] \
100             [list readelf -s provide-hidden-dyn.nd]] \
101         "provide-hidden-5"] \
102     [list \
103         "$testname 6" \
104         "$LFLAGS -T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
105         "" \
106         [list provide-hidden-4.s] \
107         [list \
108             [list readelf -s provide-hidden-sec.nd] \
109             [list readelf -s provide-hidden-dyn.nd]] \
110         "provide-hidden-6"] \
111     [list \
112         "$testname 7" \
113         "-T provide-hidden-2.ld" "" \
114         "" \
115         [list provide-hidden-1.s] \
116         [list \
117             [list readelf -s provide-hidden-def.nd] \
118             [list readelf -s provide-hidden-dyn.nd]] \
119         "provide-hidden-7"] \
120     [list \
121         "$testname 8" \
122         "-T provide-hidden-2.ld" "" \
123         "" \
124         [list provide-hidden-2.s] \
125         [list \
126             [list readelf -s provide-hidden-def.nd] \
127             [list readelf -s provide-hidden-dyn.nd]] \
128         "provide-hidden-8"] \
129     [list \
130         "$testname 9" \
131         "-T provide-hidden-2.ld" "" \
132         "" \
133         [list provide-hidden-3.s] \
134         [list \
135             [list readelf -s provide-hidden-abs.nd] \
136             [list readelf -s provide-hidden-dyn.nd]] \
137         "provide-hidden-9"] \
138     [list \
139         "$testname 10" \
140         "$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
141         "" \
142         [list provide-hidden-3.s] \
143         [list \
144             [list readelf -s provide-hidden-abs.nd] \
145             [list readelf -s provide-hidden-dyn.nd]] \
146         "provide-hidden-10"] \
147     [list \
148         "$testname 11" \
149         "-T provide-hidden-2.ld" "" \
150         "" \
151         [list provide-hidden-4.s] \
152         [list \
153             [list readelf -s provide-hidden-abs.nd] \
154             [list readelf -s provide-hidden-dyn.nd]] \
155         "provide-hidden-11"] \
156     [list \
157         "$testname 12" \
158         "$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
159         "" \
160         [list provide-hidden-4.s] \
161         [list \
162             [list readelf -s provide-hidden-abs.nd] \
163             [list readelf -s provide-hidden-dyn.nd]] \
164         "provide-hidden-12"]]