1 # Expect script
for common symbol override
, MIPS variation.
3 # Copyright
(C
) 2011-2022 Free Software Foundation
, Inc.
5 # This file is part of the GNU Binutils.
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.
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.
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
,
24 # Written by Maciej W. Rozycki
<macro@codesourcery.com
>
27 # This test is
for MIPS shared
-library targets.
28 if { ![istarget mips
*-*-*]
30 ||
![check_shared_lib_support
] } {
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
*]]
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
63 set abi_ldemul
(o32
) elf32btsmip
64 set abi_ldemul
(n32
) elf32btsmipn32
65 set abi_ldemul
(n64
) elf64btsmip
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
74 set abi_ldemul
(o32
) elf32btsmip_fbsd
75 set abi_ldemul
(n32
) elf32btsmipn32_fbsd
76 set abi_ldemul
(n64
) elf64btsmip_fbsd
78 } elseif
{ [istarget
*vr4100
*-*-elf
*] \
79 ||
[istarget
*vr4300
*-*-elf
*] \
80 ||
[istarget
*vr5000
*-*-elf
*] } {
81 if [istarget
*el
-*-*] {
82 set abi_ldemul
(o32
) elf32l4300
84 set abi_ldemul
(o32
) elf32b4300
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
94 set abi_ldemul
(o32
) elf32ebmip
97 if [istarget
*el
-*-*] {
98 set abi_ldemul
(o32
) elf32lsmip
99 set abi_ldemul
(n32
) elf32lmipn32
100 set abi_ldemul
(n64
) elf64lmip
102 set abi_ldemul
(o32
) elf32bsmip
103 set abi_ldemul
(n32
) elf32bmipn32
104 set abi_ldemul
(n64
) elf64bmip
108 proc mips_comm_data_test
{ abi flag emul reloc
} {
110 set testname
"MIPS $abi/$reloc common symbol override test"
112 # There
's no "-z copyreloc" option, deal with it.
113 set ZFLAG [string map [list copyreloc "" nocopyreloc "-z $reloc"] $reloc]
115 set LDFLAGS "-m$emul"
117 # Define a global symbol.
118 run_ld_link_tests [list \
120 "$testname (auxiliary shared object build)" \
121 "$LDFLAGS -shared" "" \
122 "$AFLAGS -call_shared" \
123 { ../ld-elf/comm-data1.s } \
125 { readelf -s ../ld-elf/comm-data1.sd } \
127 "libmips-$abi-$reloc-comm-data.so" \
131 # Set the pointer size according to the ABI.
132 if { $abi == "n64" } {
133 append AFLAGS " --defsym ELF64=1"
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 \
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 } \
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 } \
151 "mips-$abi-$reloc-comm-data" \
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-*-*".
161 lappend abis o32 -32 $abi_ldemul(o32)
164 lappend abis n32 "-n32 -march=mips3" $abi_ldemul(n32)
167 lappend abis n64 "-64 -march=mips3" $abi_ldemul(n64)
169 set relocs { copyreloc nocopyreloc }
170 foreach { abi flag emul } $abis {
171 foreach reloc $relocs {
172 mips_comm_data_test $abi $flag $emul $reloc