1 # Copyright 2003 Free Software Foundation, Inc.
3 # This file is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 if {![istarget mips*-*-*] || ![is_elf_format]} {
21 # Assemble jr.s using each of the argument lists in ARGLIST. Return the
22 # list of object files on success and an empty list on failure.
23 proc assemble_for_flags {arglist} {
24 global as srcdir subdir
29 foreach args $arglist {
30 set obj "tmpdir/mips-flags-${index}.o"
31 if {![ld_assemble $as "$args $srcdir/$subdir/jr.s" $obj]} {
40 # Assemble a file using each set of arguments in ARGLIST. Check that
41 # the objects can be linked together and that the readelf output
42 # includes each flag named in FLAGS.
43 proc good_combination {arglist flags} {
46 set finalobj "tmpdir/mips-flags.o"
47 set testname "MIPS compatible objects: $arglist"
48 set objs [assemble_for_flags $arglist]
52 } elseif {![ld_simple_link $ld $finalobj "-r $objs"]} {
55 catch "exec $READELF --headers $finalobj" output
56 if {![regexp "Flags: *(\[^\n\]*)" $output full gotflags]} {
61 # GOTFLAGS is a list of flags separated by ", ".
62 # Convert it to a tcl list.
63 regsub -all ", " $gotflags "," gotflags
64 set gotflags [split $gotflags ","]
67 if {[lsearch -exact $gotflags $flag] < 0} {
80 # Like good_combination, but check that the objects can't be linked
81 # together successfully and that the output includes MESSAGE.
82 proc bad_combination {arglist message} {
85 set finalobj "tmpdir/mips-flags.o"
86 set testname "MIPS incompatible objects: $arglist"
87 set objs [assemble_for_flags $arglist]
91 } elseif {[ld_simple_link $ld $finalobj "-r $objs"]
92 || [string first $message $link_output] < 0} {
99 # Routines to check for various kinds of incompatibility.
101 proc abi_conflict {arglist firstabi secondabi} {
102 bad_combination $arglist \
103 "linking $secondabi module with previous $firstabi modules"
106 proc isa_conflict {arglist firstisa secondisa} {
107 bad_combination $arglist \
108 "linking mips:$secondisa module with previous mips:$firstisa modules"
111 proc regsize_conflict {arglist} {
112 bad_combination $arglist \
113 "linking 32-bit code with 64-bit code"
116 abi_conflict { "-mabi=eabi -mgp32" "-mips4 -mabi=32" } EABI32 O32
117 abi_conflict { "-mips4 -mabi=o64" "-mips3 -mabi=eabi" } O64 EABI64
119 isa_conflict { "-march=vr5500" "-march=sb1" } 5500 sb1
120 isa_conflict { "-march=vr5400" "-march=4120" } 5400 4120
121 isa_conflict { "-march=r3900" "-march=r6000" } 3900 6000
122 isa_conflict { "-march=r4010" "-march=r4650" } 4010 4650
123 isa_conflict { "-mips3 -mgp32" "-mips32" } 4000 isa32
124 isa_conflict { "-march=sb1 -mgp32" "-mips32r2" } sb1 isa32r2
126 regsize_conflict { "-mips4 -mgp64" "-mips2" }
127 regsize_conflict { "-mips4 -mabi=o64" "-mips4 -mabi=32" }
128 regsize_conflict { "-mabi=eabi -mgp32" "-mabi=eabi -mgp64" }
129 regsize_conflict { "-march=vr5000 -mgp64" "-march=vr5000 -mgp32" }
130 regsize_conflict { "-mips32" "-mips64" }
131 regsize_conflict { "-mips32r2" "-mips64" }
133 good_combination { "-mips4 -mgp32" "-mips2" } { mips4 32bitmode }
134 good_combination { "-mips4 -mabi=32" "-mips2" } { mips4 o32 }
135 good_combination { "-mips2" "-mips4 -mabi=32" } { mips4 o32 }
136 good_combination { "-mips2" "-mips4 -mabi=eabi -mgp32" } { mips4 eabi32 }
137 good_combination { "-mips2" "-mips32" "-mips32r2" } { mips32r2 }
138 good_combination { "-mips1" "-mips32r2" "-mips32" } { mips32r2 }
140 good_combination { "-march=vr4100" "-march=vr4120" } { 4120 }
141 good_combination { "-march=vr5400" "-march=vr5500" "-mips4" } { 5500 }
142 good_combination { "-mips3" "-mips4" "-march=sb1" "-mips5" } { sb1 }
143 good_combination { "-mips1" "-march=3900" } { 3900 }
145 good_combination { "-march=vr4120 -mabi=32" "-mips3 -mabi=32" } { 4120 o32 }
146 good_combination { "-march=sb1 -mgp32" "-march=4000 -mgp32" } { sb1 32bitmode }