]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-mips-elf/comm-data.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-mips-elf / comm-data.exp
1 # Expect script for common symbol override, MIPS variation.
2 #
3 # Copyright (C) 2011-2021 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 # This test is for MIPS shared-library targets.
28 if { ![istarget mips*-*-*]
29 || ![is_elf_format]
30 || ![check_shared_lib_support] } {
31 return
32 }
33
34 set has_o32abi [expr ![istarget *-*-openbsd*] \
35 && ![istarget mips64*-ps2-elf*]]
36 set has_n32abi [expr [istarget *-img-elf*] \
37 || [istarget *-mti-elf*] \
38 || [istarget *-ps2-elf*] \
39 || [istarget *-sde-elf*] \
40 || [istarget *-*-freebsd*] \
41 || [istarget *-*-irix6*] \
42 || [istarget *-*-kfreebsd*-gnu] \
43 || [istarget *-*-linux*]]
44 set has_n64abi [expr [istarget *-*-freebsd*] \
45 || [istarget *-*-irix6*] \
46 || [istarget *-*-kfreebsd*-gnu] \
47 || [istarget *-*-linux*] \
48 || [istarget *-*-netbsd*] \
49 || [istarget *-*-openbsd*]]
50
51 if {[istarget *-img-elf*] \
52 || [istarget *-mti-elf*] \
53 || [istarget *-sde-elf*] \
54 || [istarget *-*-netbsd*] \
55 || [istarget *-*-linux*] \
56 || [istarget *-*-openbsd*] \
57 || [istarget *-*-sysv4*] } {
58 if [istarget *el-*-*] {
59 set abi_ldemul(o32) elf32ltsmip
60 set abi_ldemul(n32) elf32ltsmipn32
61 set abi_ldemul(n64) elf64ltsmip
62 } else {
63 set abi_ldemul(o32) elf32btsmip
64 set abi_ldemul(n32) elf32btsmipn32
65 set abi_ldemul(n64) elf64btsmip
66 }
67 } elseif { [istarget *-*-freebsd*] \
68 || [istarget *-*-kfreebsd*-gnu] } {
69 if [istarget *el-*-*] {
70 set abi_ldemul(o32) elf32ltsmip_fbsd
71 set abi_ldemul(n32) elf32ltsmipn32_fbsd
72 set abi_ldemul(n64) elf64ltsmip_fbsd
73 } else {
74 set abi_ldemul(o32) elf32btsmip_fbsd
75 set abi_ldemul(n32) elf32btsmipn32_fbsd
76 set abi_ldemul(n64) elf64btsmip_fbsd
77 }
78 } elseif { [istarget *vr4100*-*-elf*] \
79 || [istarget *vr4300*-*-elf*] \
80 || [istarget *vr5000*-*-elf*] } {
81 if [istarget *el-*-*] {
82 set abi_ldemul(o32) elf32l4300
83 } else {
84 set abi_ldemul(o32) elf32b4300
85 }
86 } elseif { [istarget *-ps2-elf*] } {
87 set abi_ldemul(o32) elf32lr5900
88 set abi_ldemul(n32) elf32lr5900n32
89 } elseif { [istarget *-*-elf*] \
90 || [istarget *-*-rtems*] } {
91 if [istarget *el-*-*] {
92 set abi_ldemul(o32) elf32elmip
93 } else {
94 set abi_ldemul(o32) elf32ebmip
95 }
96 } else {
97 if [istarget *el-*-*] {
98 set abi_ldemul(o32) elf32lsmip
99 set abi_ldemul(n32) elf32lmipn32
100 set abi_ldemul(n64) elf64lmip
101 } else {
102 set abi_ldemul(o32) elf32bsmip
103 set abi_ldemul(n32) elf32bmipn32
104 set abi_ldemul(n64) elf64bmip
105 }
106 }
107
108 proc mips_comm_data_test { abi flag emul reloc } {
109
110 set testname "MIPS $abi/$reloc common symbol override test"
111
112 # There's no "-z copyreloc" option, deal with it.
113 set ZFLAG [string map [list copyreloc "" nocopyreloc "-z $reloc"] $reloc]
114 set AFLAGS "$flag"
115 set LDFLAGS "-m$emul"
116
117 # Define a global symbol.
118 run_ld_link_tests [list \
119 [list \
120 "$testname (auxiliary shared object build)" \
121 "$LDFLAGS -shared" "" \
122 "$AFLAGS -call_shared" \
123 { ../ld-elf/comm-data1.s } \
124 { \
125 { readelf -s ../ld-elf/comm-data1.sd } \
126 } \
127 "libmips-$abi-$reloc-comm-data.so" \
128 ] \
129 ]
130
131 # Set the pointer size according to the ABI.
132 if { $abi == "n64" } {
133 append AFLAGS " --defsym ELF64=1"
134 }
135
136 # Verify that a common symbol has been converted to an undefined
137 # reference to the global symbol of the same name defined above
138 # and that the debug reference has been dropped.
139 run_ld_link_tests [list \
140 [list \
141 "$testname" \
142 "$LDFLAGS -call_shared $ZFLAG -T ../ld-elf/comm-data2.ld -Ltmpdir\
143 -lmips-$abi-$reloc-comm-data" "" \
144 "$AFLAGS -call_nonpic" \
145 { ../ld-elf/comm-data2.s } \
146 { \
147 { readelf -s ../ld-elf/comm-data2.sd } \
148 { readelf -r ../ld-elf/comm-data2.rd } \
149 { readelf "-x .debug_foo" ../ld-elf/comm-data2.xd } \
150 } \
151 "mips-$abi-$reloc-comm-data" \
152 ] \
153 ]
154 }
155
156 # For targets that default to a specific ISA (instead of "from-abi"),
157 # the 64-bit -march option is required to override it, like for
158 # "mipsisa32r2el-*-*".
159 set abis ""
160 if $has_o32abi {
161 lappend abis o32 -32 $abi_ldemul(o32)
162 }
163 if $has_n32abi {
164 lappend abis n32 "-n32 -march=mips3" $abi_ldemul(n32)
165 }
166 if $has_n64abi {
167 lappend abis n64 "-64 -march=mips3" $abi_ldemul(n64)
168 }
169 set relocs { copyreloc nocopyreloc }
170 foreach { abi flag emul } $abis {
171 foreach reloc $relocs {
172 mips_comm_data_test $abi $flag $emul $reloc
173 }
174 }