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