aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-mips-elf
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2003-01-02 21:31:32 +0000
committerRichard Sandiford <rdsandiford@googlemail.com>2003-01-02 21:31:32 +0000
commit64543e1acf3388a4318688720d3e242e93fcb00b (patch)
tree437294eb3c950dc6c41c8288065b7a7ca51ed1fe /ld/testsuite/ld-mips-elf
parentcb44e358cfb2ddc38bcb8b3f0c6feebee0e15152 (diff)
downloadfsf-binutils-gdb-64543e1acf3388a4318688720d3e242e93fcb00b.zip
fsf-binutils-gdb-64543e1acf3388a4318688720d3e242e93fcb00b.tar.gz
fsf-binutils-gdb-64543e1acf3388a4318688720d3e242e93fcb00b.tar.bz2
bfd/
* elfxx-mips.c: Include libiberty.h. (elf_mips_isa, _bfd_mips_elf_mach_extends_p): Remove. (mips_set_isa_flags): New function, split out from... (_bfd_mips_elf_final_write_processing): ...here. Only call mips_set_isa_flags if the EF_MIPS_MACH bits are clear. (mips_mach_extensions): New array. (mips_32bit_flags_p): New function. (_bfd_mips_elf_merge_private_bfd_data): Rework architecture checks. Use mips_32bit_flags_p to check if one binary is 32-bit and the other is 64-bit. When adopting IBFD's architecture, adopt the bfd_mach as well as the flags. ld/testsuite/ * ld-mips-elf/jr.s: New file. * ld-mips-elf/mips-elf-flags.exp: New test.
Diffstat (limited to 'ld/testsuite/ld-mips-elf')
-rw-r--r--ld/testsuite/ld-mips-elf/jr.s1
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf-flags.exp146
2 files changed, 147 insertions, 0 deletions
diff --git a/ld/testsuite/ld-mips-elf/jr.s b/ld/testsuite/ld-mips-elf/jr.s
new file mode 100644
index 0000000..df487d8
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/jr.s
@@ -0,0 +1 @@
+ jr $31
diff --git a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
new file mode 100644
index 0000000..30f1b49
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
@@ -0,0 +1,146 @@
+# Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+if {![istarget mips*-*-*] || ![is_elf_format]} {
+ return
+}
+
+# Assemble jr.s using each of the argument lists in ARGLIST. Return the
+# list of object files on success and an empty list on failure.
+proc assemble_for_flags {arglist} {
+ global as srcdir subdir
+
+ set objs {}
+ set index 1
+
+ foreach args $arglist {
+ set obj "tmpdir/mips-flags-${index}.o"
+ if {![ld_assemble $as "$args $srcdir/$subdir/jr.s" $obj]} {
+ return ""
+ }
+ lappend objs $obj
+ incr index
+ }
+ return $objs
+}
+
+# Assemble a file using each set of arguments in ARGLIST. Check that
+# the objects can be linked together and that the readelf output
+# includes each flag named in FLAGS.
+proc good_combination {arglist flags} {
+ global ld READELF
+
+ set finalobj "tmpdir/mips-flags.o"
+ set testname "MIPS compatible objects: $arglist"
+ set objs [assemble_for_flags $arglist]
+
+ if {$objs == ""} {
+ unresolved $testname
+ } elseif {![ld_simple_link $ld $finalobj "-r $objs"]} {
+ fail $testname
+ } else {
+ catch "exec $READELF --headers $finalobj" output
+ if {![regexp "Flags: *(\[^\n\]*)" $output full gotflags]} {
+ unresolved $testname
+ } else {
+ set failed 0
+
+ # GOTFLAGS is a list of flags separated by ", ".
+ # Convert it to a tcl list.
+ regsub -all ", " $gotflags "," gotflags
+ set gotflags [split $gotflags ","]
+
+ foreach flag $flags {
+ if {[lsearch -exact $gotflags $flag] < 0} {
+ set failed 1
+ }
+ }
+ if {$failed} {
+ fail $testname
+ } else {
+ pass $testname
+ }
+ }
+ }
+}
+
+# Like good_combination, but check that the objects can't be linked
+# together successfully and that the output includes MESSAGE.
+proc bad_combination {arglist message} {
+ global link_output ld
+
+ set finalobj "tmpdir/mips-flags.o"
+ set testname "MIPS incompatible objects: $arglist"
+ set objs [assemble_for_flags $arglist]
+
+ if {$objs == ""} {
+ unresolved $testname
+ } elseif {[ld_simple_link $ld $finalobj "-r $objs"]
+ || [string first $message $link_output] < 0} {
+ fail $testname
+ } else {
+ pass $testname
+ }
+}
+
+# Routines to check for various kinds of incompatibility.
+
+proc abi_conflict {arglist firstabi secondabi} {
+ bad_combination $arglist \
+ "linking $secondabi module with previous $firstabi modules"
+}
+
+proc isa_conflict {arglist firstisa secondisa} {
+ bad_combination $arglist \
+ "linking mips:$secondisa module with previous mips:$firstisa modules"
+}
+
+proc regsize_conflict {arglist} {
+ bad_combination $arglist \
+ "linking 32-bit code with 64-bit code"
+}
+
+abi_conflict { "-mabi=eabi -mgp32" "-mips4 -mabi=32" } EABI32 O32
+abi_conflict { "-mips4 -mabi=o64" "-mips3 -mabi=eabi" } O64 EABI64
+
+isa_conflict { "-march=vr5500" "-march=sb1" } 5500 sb1
+isa_conflict { "-march=vr5400" "-march=4120" } 5400 4120
+isa_conflict { "-march=r3900" "-march=r6000" } 3900 6000
+isa_conflict { "-march=r4010" "-march=r4650" } 4010 4650
+isa_conflict { "-mips3 -mgp32" "-mips32" } 4000 isa32
+isa_conflict { "-march=sb1 -mgp32" "-mips32r2" } sb1 isa32r2
+
+regsize_conflict { "-mips4 -mgp64" "-mips2" }
+regsize_conflict { "-mips4 -mabi=o64" "-mips4 -mabi=32" }
+regsize_conflict { "-mabi=eabi -mgp32" "-mabi=eabi -mgp64" }
+regsize_conflict { "-march=vr5000 -mgp64" "-march=vr5000 -mgp32" }
+regsize_conflict { "-mips32" "-mips64" }
+regsize_conflict { "-mips32r2" "-mips64" }
+
+good_combination { "-mips4 -mgp32" "-mips2" } { mips4 32bitmode }
+good_combination { "-mips4 -mabi=32" "-mips2" } { mips4 o32 }
+good_combination { "-mips2" "-mips4 -mabi=32" } { mips4 o32 }
+good_combination { "-mips2" "-mips4 -mabi=eabi -mgp32" } { mips4 eabi32 }
+good_combination { "-mips2" "-mips32" "-mips32r2" } { mips32r2 }
+good_combination { "-mips1" "-mips32r2" "-mips32" } { mips32r2 }
+
+good_combination { "-march=vr4100" "-march=vr4120" } { 4120 }
+good_combination { "-march=vr5400" "-march=vr5500" "-mips4" } { 5500 }
+good_combination { "-mips3" "-mips4" "-march=sb1" "-mips5" } { sb1 }
+good_combination { "-mips1" "-march=3900" } { 3900 }
+
+good_combination { "-march=vr4120 -mabi=32" "-mips3 -mabi=32" } { 4120 o32 }
+good_combination { "-march=sb1 -mgp32" "-march=4000 -mgp32" } { sb1 32bitmode }