]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-mips-elf/comm-data.exp
PR ld/13813
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-mips-elf / comm-data.exp
1 # Expect script for common symbol override, MIPS variation.
2 #
3 # Copyright 2011 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 # Exclude non-Linux targets; feel free to include your favorite one
28 # if you like.
29 if ![istarget mips*-*-linux*] {
30 return
31 }
32
33 proc mips_comm_data_test { abi flag emul reloc } {
34
35 set testname "MIPS $abi/$reloc common symbol override test"
36
37 # There's no "-z copyreloc" option, deal with it.
38 set ZFLAG [string map [list copyreloc "" nocopyreloc "-z $reloc"] $reloc]
39 set AFLAGS "$flag -EB"
40 set LDFLAGS "-m$emul"
41
42 # Define a global symbol.
43 run_ld_link_tests [list \
44 [list \
45 "$testname (auxiliary shared object build)" \
46 "$LDFLAGS -shared" \
47 "$AFLAGS -call_shared" \
48 { ../ld-elf/comm-data1.s } \
49 { \
50 { readelf -s ../ld-elf/comm-data1.sd } \
51 } \
52 "libmips-$abi-$reloc-comm-data.so" \
53 ] \
54 ]
55
56 # Set the pointer size according to the ABI.
57 if { $abi == "n64" } {
58 append AFLAGS " --defsym ELF64=1"
59 }
60
61 # Verify that a common symbol has been converted to an undefined
62 # reference to the global symbol of the same name defined above
63 # and that the debug reference has been dropped.
64 run_ld_link_tests [list \
65 [list \
66 "$testname" \
67 "$LDFLAGS $ZFLAG -Ltmpdir -lmips-$abi-$reloc-comm-data" \
68 "$AFLAGS -call_nonpic" \
69 { ../ld-elf/comm-data2.s } \
70 { \
71 { readelf -s ../ld-elf/comm-data2.sd } \
72 { readelf -r ../ld-elf/comm-data2.rd } \
73 { readelf "-x .debug_foo" ../ld-elf/comm-data2.xd } \
74 } \
75 "mips-$abi-$reloc-comm-data" \
76 ] \
77 ]
78 }
79
80 # For targets that default to a specific ISA (instead of "from-abi"),
81 # the 64-bit -march option is required to override it, like for
82 # "mipsisa32r2el-*-*".
83 set abis { o32 -32 elf32btsmip n32 "-n32 -march=mips3" elf32btsmipn32 n64 "-64 -march=mips3" elf64btsmip }
84 set relocs { copyreloc nocopyreloc }
85 foreach { abi flag emul } $abis {
86 foreach reloc $relocs {
87 mips_comm_data_test $abi $flag $emul $reloc
88 }
89 }