old-cross-binutils/ld/testsuite/ld-mips-elf/mips-elf.exp

180 lines
6.2 KiB
Text
Raw Normal View History

# Expect script for MIPS ELF linker tests
# Copyright 2002, 2003, 2004, 2005 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
2005-05-12 07:32:09 +00:00
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
#
if {![istarget mips*-*-*] || ![is_elf_format]} {
return
}
set has_newabi [expr [istarget *-*-irix6*] || [istarget mips64*-*-linux*]]
set linux_gnu [expr [istarget mips*-*-linux*]]
set embedded_elf [expr [istarget mips*-*-elf]]
# Check MIPS16 markings being passed through link.
run_dump_test "mips16-1"
# MIPS branch offset final link checking.
run_dump_test "branch-misc-1"
# Test multi-got link. We only do this on GNU/Linux because it requires
# the "traditional" emulations.
if { $linux_gnu } {
run_dump_test "multi-got-1"
run_dump_test "multi-got-no-shared"
}
if $has_newabi {
run_dump_test "elf-rel-got-n32"
run_dump_test "elf-rel-xgot-n32"
if { $linux_gnu } {
run_dump_test "elf-rel-got-n64-linux"
run_dump_test "elf-rel-xgot-n64-linux"
} else {
run_dump_test "elf-rel-got-n64"
run_dump_test "elf-rel-xgot-n64"
}
run_dump_test "relax-jalr-n32"
run_dump_test "relax-jalr-n32-shared"
run_dump_test "relax-jalr-n64"
run_dump_test "relax-jalr-n64-shared"
}
if { $linux_gnu } {
run_dump_test "rel32-o32"
run_dump_test "rel32-n32"
run_dump_test "rel64"
}
if { $embedded_elf } {
run_dump_test "region1"
}
if $embedded_elf {
# This could work on other targets too, but would need the appropriate
# ld -m switch.
run_dump_test "reloc-1-rel"
}
if $has_newabi {
run_dump_test "reloc-1-n32"
if $linux_gnu {
# Uses a linux-specific ld -m switch
run_dump_test "reloc-1-n64"
}
}
run_dump_test "reloc-2"
run_dump_test "reloc-merge-lo16"
if {$has_newabi && $linux_gnu} {
run_dump_test "eh-frame1-n32"
run_dump_test "eh-frame1-n64"
run_dump_test "eh-frame2-n32"
run_dump_test "eh-frame2-n64"
}
if {$embedded_elf} {
run_dump_test "eh-frame3"
run_dump_test "eh-frame4"
}
run_dump_test "jaloverflow"
run_dump_test "jaloverflow-2"
if {$has_newabi} {
run_dump_test "jalbal"
}
bfd/: 2005-02-15 Nigel Stephens <nigel@mips.com> Maciej W. Rozycki <macro@mips.com> * elf32-mips.c (elf_mips16_howto_table_rel): New array for MIPS16 reloc howtos. Add R_MIPS16_HI16 and R_MIPS16_LO16 relocs and R_MIPS16_GOT16 and R_MIPS16_CALL16 placeholders. (elf_mips16_jump_howto): Move into elf_mips16_howto_table_rel. (elf_mips16_gprel_howto): Likewise. Redefine src_mask and dst_mask. (mips16_gprel_reloc): Remove bit shuffling; call _bfd_mips16_elf_reloc_unshuffle(), _bfd_mips_elf_gprel16_with_gp() and _bfd_mips16_elf_reloc_shuffle() instead. (mips16_reloc_map): New reloc map for MIPS16 relocs. (bfd_elf32_bfd_reloc_type_lookup): Use mips16_reloc_map for MIPS16 relocs. (mips_elf32_rtype_to_howto): Fetch MIPS16 howtos from elf_mips16_howto_table_rel. * elf64-mips.c (mips16_elf64_howto_table_rel): New array for MIPS16 REL reloc howtos. Add R_MIPS16_HI16 and R_MIPS16_LO16 relocs and R_MIPS16_GOT16 and R_MIPS16_CALL16 placeholders. (elf_mips16_jump_howto): Move into mips16_elf64_howto_table_rel. (elf_mips16_gprel_howto): Likewise. Redefine src_mask and dst_mask. (mips16_elf64_howto_table_rela): New array for MIPS16 RELA reloc howtos. Add R_MIPS16_26, R_MIPS16_GPREL, R_MIPS16_HI16 and R_MIPS16_LO16 relocs and R_MIPS16_GOT16 and R_MIPS16_CALL16 placeholders. (mips16_gprel_reloc): Remove bit shuffling; call _bfd_mips16_elf_reloc_unshuffle(), _bfd_mips_elf_gprel16_with_gp() and _bfd_mips16_elf_reloc_shuffle() instead. (mips16_reloc_map): New reloc map for MIPS16 relocs. (bfd_elf64_bfd_reloc_type_lookup): Use mips16_reloc_map for MIPS16 relocs. (mips_elf64_rtype_to_howto): Fetch MIPS16 howtos from mips16_elf64_howto_table_rela or mips16_elf64_howto_table_rel. * elfn32-mips.c (elf_mips16_howto_table_rel): New array for MIPS16 REL reloc howtos. Add R_MIPS16_HI16 and R_MIPS16_LO16 relocs and R_MIPS16_GOT16 and R_MIPS16_CALL16 placeholders. (elf_mips16_jump_howto): Move into elf_mips16_howto_table_rel. (elf_mips16_gprel_howto): Likewise. Redefine src_mask and dst_mask. (mips16_gprel_reloc): Remove bit shuffling; call _bfd_mips16_elf_reloc_unshuffle(), _bfd_mips_elf_gprel16_with_gp() and _bfd_mips16_elf_reloc_shuffle() instead. (mips16_reloc_map): New reloc map for MIPS16 relocs. (bfd_elf32_bfd_reloc_type_lookup): Use mips16_reloc_map for MIPS16 relocs. (mips_elf_n32_rtype_to_howto): Fetch MIPS16 howtos from elf_mips16_howto_table_rela or elf_mips16_howto_table_rel. * elfxx-mips.c (_bfd_mips16_elf_reloc_unshuffle): New function to handle bit shuffling for MIPS16 relocs. (_bfd_mips16_elf_reloc_shuffle): Likewise. (_bfd_mips_elf_lo16_reloc): Use _bfd_mips16_elf_reloc_unshuffle() and _bfd_mips16_elf_reloc_shuffle(). (_bfd_mips_elf_generic_reloc): Likewise. (mips_elf_calculate_relocation): Likewise. Handle R_MIPS16_HI16 and R_MIPS16_LO16. (mips_elf_obtain_contents): Remove bit shuffling. (mips_elf_perform_relocation): Likewise; call _bfd_mips16_elf_reloc_unshuffle() and _bfd_mips16_elf_reloc_shuffle() instead. (_bfd_mips_elf_relocate_section): Likewise. Handle R_MIPS16_HI16 and R_MIPS16_LO16. * elfxx-mips.h (_bfd_mips16_elf_reloc_unshuffle): Declare. (_bfd_mips16_elf_reloc_shuffle): Likewise. * reloc.c (BFD_RELOC_MIPS16_HI16): New reloc. (BFD_RELOC_MIPS16_HI16_S): Likewise. (BFD_RELOC_MIPS16_LO16): Likewise. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. gas/: 2005-02-15 Nigel Stephens <nigel@mips.com> Maciej W. Rozycki <macro@mips.com> * config/tc-mips.c (reloc_needs_lo_p): Handle BFD_RELOC_MIPS16_HI16_S. (fixup_has_matching_lo_p): Handle BFD_RELOC_MIPS16_LO16. (append_insn): Add BFD_RELOC_MIPS16_GPREL, BFD_RELOC_MIPS16_HI16_S and BFD_RELOC_MIPS16_LO16 to relocs to suppress overflow complaints on. (mips16_ip): Resolve BFD_RELOC_MIPS16_HI16_S, BFD_RELOC_MIPS16_HI16 and BFD_RELOC_MIPS16_LO16 for constants. Call my_getSmallExpression() to parse percent operators. (percent_op_match, mips_percent_op): Separate definitions. (mips16_percent_op): Define percent operators for the MIPS16 mode. (parse_relocation): Handle the MIPS16 mode using mips16_percent_op. (md_apply_fix3): Handle BFD_RELOC_MIPS16_HI16, BFD_RELOC_MIPS16_HI16_S and BFD_RELOC_MIPS16_LO16. gas/testsuite/: 2005-02-15 Nigel Stephens <nigel@mips.com> Maciej W. Rozycki <macro@mips.com> * gas/mips/mips16-hilo.d: New test for the R_MIPS16_HI16 and R_MIPS16_LO16 relocs. * gas/mips/mips16-hilo-n32.d: Likewise, for the n32 ABI. * gas/mips/mips16-hilo.s: Source for the new tests. * gas/mips/mips.exp: Run the new tests. include/: 2005-02-15 Nigel Stephens <nigel@mips.com> Maciej W. Rozycki <macro@mips.com> * elf/mips.h (R_MIPS16_GOT16): New reloc code. (R_MIPS16_CALL16): Likewise. (R_MIPS16_HI16): Likewise. (R_MIPS16_LO16): Likewise. (R_MIPS16_min): New fake reloc code. (R_MIPS16_max): Likewise. ld/testsuite/: 2005-02-15 Nigel Stephens <nigel@mips.com> Maciej W. Rozycki <macro@mips.com> * ld-mips-elf/mips16-hilo.d: New test for the R_MIPS16_HI16 and R_MIPS16_LO16 relocs. * ld-mips-elf/mips16-hilo-n32.d: Likewise, for the n32 ABI. * ld-mips-elf/mips16-hilo.s: Auxiliary source for the new tests. * ld-mips-elf/mips-elf.exp: Run the new tests.
2005-02-15 19:57:54 +00:00
run_dump_test "mips16-hilo"
if {$has_newabi} {
run_dump_test "mips16-hilo-n32"
}
if { $linux_gnu } {
run_dump_test "textrel-1"
}
if $has_newabi {
run_dump_test "emit-relocs-1"
}
# For tests which may involve multiple files, use run_ld_link_tests.
# List contains test-items with 3 items followed by 2 lists:
# 0:name 1:ld options 2:assembler options
# 3:filenames of assembler files 4: action and options. 5: name of output file
# Actions:
# objdump: Apply objdump options on result. Compare with regex (last arg).
# nm: Apply nm options on result. Compare with regex (last arg).
# readelf: Apply readelf options on result. Compare with regex (last arg).
set mips_tls_tests {
{"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld"
"-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
{{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
"tls-static-o32"}
{"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld"
"-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
{{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
"tlslib-o32.so"}
{"Dynamic executable with TLS"
"-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so"
"-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
{{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
"tls-dynamic-o32"}
{"Shared library with multiple GOTs and TLS"
"-shared -melf32btsmip -T mips-lib.ld"
"-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
{{readelf {-d -r} tls-multi-got-1.r}
{objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
{objdump -Rsj.got tls-multi-got-1.got}}
"tlslib-multi.so"}
{"Shared library with TLS and versioning"
"-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver"
"-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
{{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
"tlslib-o32-ver.so"}
{"Dynamic executable with TLS and versioning"
"-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so"
"-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
{{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
"tls-dynamic-o32-ver"}
{"Dynamic executable with TLS and versioning (order 2)"
"-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o"
"-EB -march=mips1 -32 -KPIC" {}
{{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
"tls-dynamic-o32-ver-2"}
{"Dynamic executable with TLS and versioning (order 3)"
"-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o"
"-EB -march=mips1 -32 -KPIC" {}
{{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
"tls-dynamic-o32-ver-3"}
{"Shared library with TLS and hidden symbols"
"-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver"
"-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
{{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
"tlslib-o32-hidden.so"}
{"Shared library with TLS and hidden symbols (2)"
"-shared -melf32btsmip -T mips-lib.ld"
"-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
{{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
"tls-hidden2.so"}
}
if {[istarget mips*-*-linux*]} {
run_ld_link_tests $mips_tls_tests
}