MIPS/LD/testsuite: mips-elf-flags: Use `remote_exec' to call `readelf'
[deliverable/binutils-gdb.git] / ld / testsuite / ld-mips-elf / mips-elf-flags.exp
CommitLineData
2571583a 1# Copyright (C) 2003-2017 Free Software Foundation, Inc.
64543e1a 2#
f96b4a7b
NC
3# This file is part of the GNU Binutils.
4#
5# This program is free software; you can redistribute it and/or modify
64543e1a 6# it under the terms of the GNU General Public License as published by
f96b4a7b 7# the Free Software Foundation; either version 3 of the License, or
64543e1a
RS
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
f96b4a7b
NC
17# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
18# MA 02110-1301, USA.
64543e1a
RS
19
20if {![istarget mips*-*-*] || ![is_elf_format]} {
21 return
22}
23
697380b3
AO
24global ldemul
25if {[istarget mips*-*-irix6*]} {
0c29b4cc 26 set ldemul "-melf32bsmip"
697380b3
AO
27} elseif {[istarget mips*el-*-linux*]} {
28 set ldemul "-melf32ltsmip"
29} elseif {[istarget mips*-*-linux*]} {
30 set ldemul "-melf32btsmip"
aeffff67
RS
31} elseif {[istarget mips*el-*-*freebsd*]} {
32 set ldemul "-melf32ltsmip_fbsd"
33} elseif {[istarget mips*-*-*freebsd*]} {
34 set ldemul "-melf32btsmip_fbsd"
697380b3
AO
35} else {
36 set ldemul ""
37}
38
64543e1a
RS
39# Assemble jr.s using each of the argument lists in ARGLIST. Return the
40# list of object files on success and an empty list on failure.
41proc assemble_for_flags {arglist} {
42 global as srcdir subdir
43
44 set objs {}
45 set index 1
46
47 foreach args $arglist {
48 set obj "tmpdir/mips-flags-${index}.o"
49 if {![ld_assemble $as "$args $srcdir/$subdir/jr.s" $obj]} {
50 return ""
51 }
52 lappend objs $obj
53 incr index
54 }
55 return $objs
56}
57
58# Assemble a file using each set of arguments in ARGLIST. Check that
b1a2d7a0 59# the objects can be linked together and that the `readelf -h' output
64543e1a
RS
60# includes each flag named in FLAGS.
61proc good_combination {arglist flags} {
697380b3 62 global ld ldemul READELF
64543e1a
RS
63
64 set finalobj "tmpdir/mips-flags.o"
65 set testname "MIPS compatible objects: $arglist"
66 set objs [assemble_for_flags $arglist]
67
68 if {$objs == ""} {
69 unresolved $testname
d9816402 70 } elseif {![ld_link "$ld $ldemul" $finalobj "-r $objs"]} {
64543e1a
RS
71 fail $testname
72 } else {
1284e99a
MR
73 set cmd "$READELF -h $finalobj"
74 send_log "$cmd\n"
75 set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]]]
76 set output [lindex $cmdret 1]
77 set cmdret [lindex $cmdret 0]
78 if {$cmdret != 0 \
79 || ![regexp "Flags: *(\[^\n\r\]*)" $output full gotflags]} {
64543e1a
RS
80 unresolved $testname
81 } else {
82 set failed 0
83
84 # GOTFLAGS is a list of flags separated by ", ".
85 # Convert it to a tcl list.
86 regsub -all ", " $gotflags "," gotflags
87 set gotflags [split $gotflags ","]
88
89 foreach flag $flags {
90 if {[lsearch -exact $gotflags $flag] < 0} {
91 set failed 1
92 }
93 }
94 if {$failed} {
95 fail $testname
96 } else {
97 pass $testname
98 }
99 }
100 }
101}
102
103# Like good_combination, but check that the objects can't be linked
104# together successfully and that the output includes MESSAGE.
105proc bad_combination {arglist message} {
697380b3 106 global link_output ld ldemul
64543e1a
RS
107
108 set finalobj "tmpdir/mips-flags.o"
109 set testname "MIPS incompatible objects: $arglist"
110 set objs [assemble_for_flags $arglist]
111
112 if {$objs == ""} {
113 unresolved $testname
d9816402 114 } elseif {[ld_link "$ld $ldemul" $finalobj "-r $objs"]
64543e1a
RS
115 || [string first $message $link_output] < 0} {
116 fail $testname
117 } else {
118 pass $testname
119 }
120}
121
122# Routines to check for various kinds of incompatibility.
123
124proc abi_conflict {arglist firstabi secondabi} {
125 bad_combination $arglist \
126 "linking $secondabi module with previous $firstabi modules"
127}
128
129proc isa_conflict {arglist firstisa secondisa} {
130 bad_combination $arglist \
131 "linking mips:$secondisa module with previous mips:$firstisa modules"
132}
133
134proc regsize_conflict {arglist} {
135 bad_combination $arglist \
136 "linking 32-bit code with 64-bit code"
137}
138
139abi_conflict { "-mabi=eabi -mgp32" "-mips4 -mabi=32" } EABI32 O32
c97c330b 140abi_conflict { "-mips4 -mabi=o64" "-mips3 -mabi=eabi" } O64 EABI64
64543e1a 141
c97c330b
MF
142isa_conflict { "-march=vr5500 -32" "-march=sb1 -32" } 5500 sb1
143isa_conflict { "-march=vr5400 -32" "-march=4120 -32" } 5400 4120
144isa_conflict { "-march=r3900 -32" "-march=r6000 -32" } 3900 6000
145isa_conflict { "-march=r4010 -32" "-march=r4650 -32" } 4010 4650
146isa_conflict { "-mips3 -mgp32 -32" "-mips32 -32" } 4000 isa32
697380b3 147isa_conflict { "-march=sb1 -mgp32 -32" "-mips32r2 -32" } sb1 isa32r2
c97c330b
MF
148isa_conflict { "-march=sb1 -32" "-mips64r2 -32" } sb1 isa64r2
149
150isa_conflict { "-march=vr4100 -32" "-march=r10000 -32" } 4100 8000
151isa_conflict { "-march=r5900 -32" "-march=vr4111 -32" } 5900 4111
152isa_conflict { "-march=loongson2e -32" "-march=loongson2f -32" } loongson_2e loongson_2f
153isa_conflict { "-march=loongson3a -32" "-march=loongson2f -32" } loongson_3a loongson_2f
154
155regsize_conflict { "-mips4 -mgp64 -mabi=o64" "-mips2 -32" }
156regsize_conflict { "-mips4 -mabi=o64" "-mips4 -mabi=32" }
157regsize_conflict { "-mips4 -mabi=eabi -mgp32" "-mips4 -mabi=eabi -mgp64" }
158regsize_conflict { "-march=vr5000 -mgp64 -mabi=o64" "-march=vr5000 -mgp32 -32" }
159regsize_conflict { "-mips32 -32" "-mips64 -mabi=o64" }
160regsize_conflict { "-mips32r2 -32" "-mips64 -mabi=o64" }
161regsize_conflict { "-mips32r2 -32" "-mips64r2 -mabi=o64" }
162
163good_combination { "-mips4 -mgp32 -32" "-mips2 -32" } { mips4 o32 }
164good_combination { "-mips4 -mabi=32" "-mips2 -32" } { mips4 o32 }
165good_combination { "-mips2 -32" "-mips4 -mabi=32" } { mips4 o32 }
166good_combination { "-mips2 -mabi=eabi" "-mips4 -mabi=eabi -mgp32" } { mips4 eabi32 }
167good_combination { "-mips2 -32" "-mips32 -32" "-mips32r2 -32" } { mips32r2 }
168good_combination { "-mips1 -32" "-mips32r2 -32" "-mips32 -32" } { mips32r2 }
169
170good_combination { "-march=vr4100 -32" "-march=vr4120 -32" } { 4120 }
171good_combination { "-march=vr5400 -32" "-march=vr5500 -32" "-mips4 -32" } { 5500 }
172good_combination { "-mips3 -32" "-mips4 -32" "-march=sb1 -32" "-mips5 -32" } { sb1 }
173good_combination { "-mips1 -32" "-march=3900 -32" } { 3900 }
174good_combination { "-mips3 -32" "-mips64r2 -32" " -mips64 -32" } { mips64r2 }
175
176good_combination { "-march=vr4120 -mabi=32" "-mips3 -mabi=32" } { 4120 o32 }
177good_combination { "-march=sb1 -mgp32 -32" "-march=4000 -mgp32 -32" } { sb1 o32 }
178good_combination { "-mips32 -mabi=32" "-march=sb1 -mabi=32" } { sb1 o32 }
179good_combination { "-mips64r2 -mabi=32" "-mips32 -mabi=32" } { mips64r2 o32 }
180good_combination { "-mips5 -mabi=o64" "-mips64r2 -mabi=o64" } { mips64r2 o64 }
This page took 1.220993 seconds and 4 git commands to generate.