1fc4e61a19127d31b7768904262900cd71165be3
[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 "readelf -s provide-hidden-dynsec.nd"] \
90         "provide-hidden-4"] \
91     [list \
92         "$testname 5" \
93         "-T provide-hidden-1.ld" "" \
94         "" \
95         [list provide-hidden-4.s] \
96         [list \
97             [list readelf -s provide-hidden-sec.nd] \
98             [list readelf -s provide-hidden-dyn.nd]] \
99         "provide-hidden-5"] \
100     [list \
101         "$testname 6" \
102         "$LFLAGS -T provide-hidden-1.ld" "tmpdir/provide-hidden-s.so" \
103         "" \
104         [list provide-hidden-4.s] \
105         [list \
106             [list readelf -s provide-hidden-sec.nd] \
107             [list readelf -s provide-hidden-dyn.nd]] \
108         "provide-hidden-6"] \
109     [list \
110         "$testname 7" \
111         "-T provide-hidden-2.ld" "" \
112         "" \
113         [list provide-hidden-1.s] \
114         [list \
115             [list readelf -s provide-hidden-def.nd] \
116             [list readelf -s provide-hidden-dyn.nd]] \
117         "provide-hidden-7"] \
118     [list \
119         "$testname 8" \
120         "-T provide-hidden-2.ld" "" \
121         "" \
122         [list provide-hidden-2.s] \
123         [list \
124             [list readelf -s provide-hidden-def.nd] \
125             [list readelf -s provide-hidden-dyn.nd]] \
126         "provide-hidden-8"] \
127     [list \
128         "$testname 9" \
129         "-T provide-hidden-2.ld" "" \
130         "" \
131         [list provide-hidden-3.s] \
132         [list \
133             [list readelf -s provide-hidden-abs.nd] \
134             [list readelf -s provide-hidden-dyn.nd]] \
135         "provide-hidden-9"] \
136     [list \
137         "$testname 10" \
138         "$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
139         "" \
140         [list provide-hidden-3.s] \
141         [list "readelf -s provide-hidden-dynabs.nd"] \
142         "provide-hidden-10"] \
143     [list \
144         "$testname 11" \
145         "-T provide-hidden-2.ld" "" \
146         "" \
147         [list provide-hidden-4.s] \
148         [list \
149             [list readelf -s provide-hidden-abs.nd] \
150             [list readelf -s provide-hidden-dyn.nd]] \
151         "provide-hidden-11"] \
152     [list \
153         "$testname 12" \
154         "$LFLAGS -T provide-hidden-2.ld" "tmpdir/provide-hidden-s.so" \
155         "" \
156         [list provide-hidden-4.s] \
157         [list \
158             [list readelf -s provide-hidden-abs.nd] \
159             [list readelf -s provide-hidden-dyn.nd]] \
160         "provide-hidden-12"]]