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