MIPS: Add options to control branch ISA checks
[deliverable/binutils-gdb.git] / ld / testsuite / ld-mips-elf / mips-elf.exp
index 7b901c6f710b7f59c25e24ec30eb77841beb2a3f..7fa11c5989d1ad2d9bda5c4b392a842ef0835234 100644 (file)
@@ -1,5 +1,5 @@
 # Expect script for MIPS ELF linker tests
-#   Copyright (C) 2002-2014 Free Software Foundation, Inc.
+#   Copyright (C) 2002-2017 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -142,6 +142,49 @@ run_dump_test "mips16-1"
 
 # MIPS branch offset final link checking.
 run_dump_test "branch-misc-1"
+run_dump_test "branch-misc-2"
+run_dump_test "branch-absolute" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "branch-absolute-addend" [list [list ld $abi_ldflags(o32)]]
+if $has_newabi {
+    run_dump_test "branch-absolute-n32" [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "branch-absolute-addend-n32" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "branch-absolute-n64" [list [list ld $abi_ldflags(n64)]]
+    run_dump_test "branch-absolute-addend-n64" \
+                                       [list [list ld $abi_ldflags(n64)]]
+}
+
+run_dump_test "mips16-branch-2" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "mips16-branch-3" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "mips16-branch-addend-2" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "mips16-branch-addend-3" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "mips16-branch-absolute" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "mips16-branch-absolute-addend" \
+                                       [list [list ld $abi_ldflags(o32)]]
+if $has_newabi {
+    run_dump_test "mips16-branch-absolute-n32" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "mips16-branch-absolute-addend-n32" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "mips16-branch-absolute-n64" \
+                                       [list [list ld $abi_ldflags(n64)]]
+    run_dump_test "mips16-branch-absolute-addend-n64" \
+                                       [list [list ld $abi_ldflags(n64)]]
+}
+
+run_dump_test "micromips-branch-absolute" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "micromips-branch-absolute-addend" \
+                                       [list [list ld $abi_ldflags(o32)]]
+if $has_newabi {
+    run_dump_test "micromips-branch-absolute-n32" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "micromips-branch-absolute-addend-n32" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "micromips-branch-absolute-n64" \
+                                       [list [list ld $abi_ldflags(n64)]]
+    run_dump_test "micromips-branch-absolute-addend-n64" \
+                                       [list [list ld $abi_ldflags(n64)]]
+}
 
 # Jalx test
 run_dump_test "jalx-1"
@@ -168,6 +211,89 @@ if { $linux_gnu } {
              "jalx-2"]]
 }
 
+run_dump_test "jalx-addend" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "jalx-local" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "bal-jalx-addend" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "bal-jalx-local" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "bal-jalx-pic" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "bal-jalx-pic-ignore" [list [list ld $abi_ldflags(o32)]]
+if $has_newabi {
+    run_dump_test "jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "bal-jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "bal-jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "bal-jalx-pic-n32" [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "bal-jalx-pic-ignore-n32" [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
+    run_dump_test "jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
+    run_dump_test "bal-jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
+    run_dump_test "bal-jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
+    run_dump_test "bal-jalx-pic-n64" [list [list ld $abi_ldflags(n64)]]
+    run_dump_test "bal-jalx-pic-ignore-n64" [list [list ld $abi_ldflags(n64)]]
+}
+
+run_dump_test "unaligned-jalx-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-2" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-3" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-mips16-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-mips16-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-micromips-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-jalx-micromips-1" [list [list ld $abi_ldflags(o32)]]
+
+if $has_newabi {
+    run_dump_test "unaligned-jalx-addend-0" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jalx-addend-1" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jalx-addend-2" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jalx-addend-3" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jalx-addend-mips16-0" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jalx-addend-mips16-1" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jalx-addend-micromips-0" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jalx-addend-micromips-1" \
+                                       [list [list ld $abi_ldflags(n32)]]
+}
+
+run_dump_test "unaligned-branch" [list [list ld $abi_ldflags(o32)]]
+
+if $has_newabi {
+    run_dump_test "unaligned-branch-2" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-branch-ignore-2" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-branch-r6-1" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-branch-ignore-r6-1" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-branch-r6-2" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-branch-mips16" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-branch-ignore-mips16" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-branch-micromips" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-branch-ignore-micromips" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jump" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jump-mips16" \
+                                       [list [list ld $abi_ldflags(n32)]]
+    run_dump_test "unaligned-jump-micromips" \
+                                       [list [list ld $abi_ldflags(n32)]]
+}
+
+run_dump_test "unaligned-lwpc-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-lwpc-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-ldpc-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "unaligned-ldpc-1" [list [list ld $abi_ldflags(o32)]]
+
 # Test multi-got link.  We only do this on GNU/Linux because it requires
 # the "traditional" emulations.
 if { $linux_gnu } {
@@ -186,6 +312,15 @@ if { $linux_gnu } {
     }
 }
 
+# Test PIE debug dynamic tags
+if { $linux_gnu } {
+    run_dump_test "pie-o32"
+    if { $has_newabi } {
+       run_dump_test "pie-n32"
+       run_dump_test "pie-n64"
+    }
+}
+
 if $has_newabi {
     if { $embedded_elf } {
        run_dump_test "elf-rel-got-n32-embed" \
@@ -233,6 +368,8 @@ if { $linux_gnu } {
     #
     # The third test checks that we do the same when linking the
     # result of the first link (with no other source files).
+    #
+    # We then repeat the same three tests for microMIPS stubs.
     run_ld_link_tests {
        {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip" ""
         "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
@@ -251,6 +388,42 @@ if { $linux_gnu } {
         {{objdump -dr pic-and-nonpic-1.dd}
          {readelf --symbols pic-and-nonpic-1.nd}}
         "pic-and-nonpic-1-static2.o"}
+       {"PIC and non-PIC test 1, microMIPS (relocatable)"
+        "-r -melf32btsmip" ""
+        "-32 -EB -mips2"
+        {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
+        {{objdump -dr pic-and-nonpic-1-micromips-rel.dd}
+         {readelf --symbols pic-and-nonpic-1-micromips-rel.nd}}
+        "pic-and-nonpic-1-micromips-rel.o"}
+       {"PIC and non-PIC test 1, microMIPS (static 1)"
+        "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
+        "-32 -EB -mips2"
+        {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
+        {{objdump -dr pic-and-nonpic-1-micromips.dd}
+         {readelf --symbols pic-and-nonpic-1-micromips.nd}}
+        "pic-and-nonpic-1-micromips-static1.o"}
+    }
+    # The final executable produced with the following test is supposed
+    # to be the same as one produced with the preceding test, however
+    # as noted in PR ld/20453 it is not.  Consequently output from
+    # `objdump -dr' is not the same either.  Expect:
+    #
+    #  regexp_diff match failure
+    #  regexp "^   4103c:      f001 0415       jalx    41054 <f3>$"
+    #  line   "   4103c:       f001 0400       jalx    41000 <.pic.f3>"
+    #
+    # from the test below due to this problem.
+    setup_kfail "mips*-*-*" "ld/20453"
+    # The final check below should be folded into the `run_ld_link_tests'
+    # call above once `setup_kfail' has been removed.
+    run_ld_link_tests {
+       {"PIC and non-PIC test 1, microMIPS (static 2)"
+        "-melf32btsmip -Tpic-and-nonpic-1.ld \
+         tmpdir/pic-and-nonpic-1-micromips-rel.o" ""
+        "" {}
+        {{objdump -dr pic-and-nonpic-1-micromips.dd}
+         {readelf --symbols pic-and-nonpic-1-micromips.nd}}
+        "pic-and-nonpic-1-micromips-static2.o"}
     }
     run_dump_test "pic-and-nonpic-2"
     run_ld_link_tests {
@@ -410,6 +583,15 @@ if { $has_newabi } {
            "reloc-6b"]]
 }
 
+run_dump_test "reloc-local-overflow" [list [list ld $abi_ldflags(o32)]]
+run_ld_link_tests [list \
+    [list \
+       "MIPS link ELF o32 PIC comdat GOT16/LO16 relocation pairing" \
+       "$abi_ldflags(o32) -e bar" "" "$abi_asflags(o32) -mno-pdr" \
+       "../../../gas/testsuite/gas/mips/comdat-reloc.s" \
+       {} \
+       "comdat-reloc"]]
+
 if {$has_newabi && $linux_gnu} {
     run_dump_test "eh-frame1-n32"
     run_dump_test "eh-frame1-n64"
@@ -432,15 +614,35 @@ if {$linux_gnu} {
     run_ld_link_tests $eh_frame5_test
 }
 
+if {$embedded_elf} {
+    run_dump_test "compact-eh1"
+    run_dump_test "compact-eh2"
+    run_dump_test "compact-eh3"
+}
+
+if {$linux_gnu} {
+    run_dump_test "compact-eh4"
+    run_dump_test "compact-eh5"
+    run_dump_test "compact-eh6"
+}
+
 run_dump_test "jaloverflow"
 run_dump_test "jaloverflow-2"
+
+run_dump_test "jal-global-overflow-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "jal-global-overflow-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "jal-local-overflow-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "jal-local-overflow-1" [list [list ld $abi_ldflags(o32)]]
+
 run_dump_test "undefweak-overflow" [list [list as $abi_asflags(o32)] \
                                         [list ld $abi_ldflags(o32)]]
 
 if {$has_newabi} {
-    run_dump_test "undefweak-overflow" [list [list as $abi_asflags(n32)] \
+    run_dump_test "undefweak-overflow" [list [list name (n32)] \
+                                            [list as $abi_asflags(n32)] \
                                             [list ld $abi_ldflags(n32)]]
-    run_dump_test "undefweak-overflow" [list [list as $abi_asflags(n64)] \
+    run_dump_test "undefweak-overflow" [list [list name (n64)] \
+                                            [list as $abi_asflags(n64)] \
                                             [list ld $abi_ldflags(n64)]]
 }
 
@@ -645,6 +847,16 @@ run_ld_link_tests $mips16_intermix_test
 
 run_dump_test "mips16-local-stubs-1"
 
+set mips16_fp_stub_test [list \
+    [list "Floating-point stub for mips16 functions" \
+        "$abi_ldflags(o32)" "" \
+        "$abi_asflags(o32) -mips32r2" \
+        {mips16-fp-stub-1.s mips16-fp-stub-2.s} \
+        {{readelf --debug-dump=frames mips16-fp-stub.d}} \
+        "mips16-fp-stub"]]
+
+run_ld_link_tests $mips16_fp_stub_test
+
 set o32flagslist [list [list as $abi_asflags(o32)] [list ld $abi_ldflags(o32)]]
 
 foreach firstfpabi [list 0 1 2 3 4 5 6 7 ] {
@@ -653,12 +865,12 @@ foreach firstfpabi [list 0 1 2 3 4 5 6 7 ] {
   }
 }
 foreach firstfpabi [list 4 5 6 7 ] {
-  foreach secondfpabi [list 0 1 2 3 8] {
+  foreach secondfpabi [list 0 1 2 3 8 9] {
     run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
   }
 }
 foreach firstfpabi [list 0 1 2 3 ] {
-  foreach secondfpabi [list 0 1 2 3 8] {
+  foreach secondfpabi [list 0 1 2 3 8 9] {
     run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}"
   }
 }
@@ -767,9 +979,6 @@ foreach { abi } $abis {
             [list ehdr_start-${suff}.s] \
             [list "readelf -s ehdr_start-1.nd"] \
             "ehdr_start-1-${abi}"]]
-    if [regexp "(?:n32|n64)" "$abi"] {
-       setup_kfail "mips*-*-*" "ld/15428"
-    }
     run_ld_link_tests [list \
         [list \
             "MIPS magic __ehdr_start symbol test 2 ($abi)" \
@@ -818,13 +1027,13 @@ proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } {
     set ld_flags "$abi_ldflags($abi) -T compressed-plt-1.ld"
     set dynobj "tmpdir/compressed-plt-1-${abi}-dyn.so"
     set files [list]
-    if { $filter & 3 } {
+    if { $filter & 7 } {
        lappend files compressed-plt-1a.s
     }
-    if { $filter & 12 } {
+    if { $filter & 56 } {
        lappend files compressed-plt-1b.s
     }
-    if { $filter & 16 } {
+    if { $filter & 64 } {
        lappend files compressed-plt-1c.s
     }
     eval [list lappend files] $extra
@@ -844,27 +1053,62 @@ proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } {
 
 if { $linux_gnu } {
     build_mips_plt_lib o32
-    run_mips_plt_test "o32 PLTs for standard encoding" o32 28 0 se
-    run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 19 0 mips16-only
-    run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 19 1 umips-only
+    run_mips_plt_test "o32 PLTs for standard encoding" o32 104 0 se
+    run_mips_plt_test "o32 PLTs for standard branches" o32 16 0 branch
+    run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 69 0 mips16-only
+    run_mips_plt_test "o32 PLTs for MIPS16 branches" o32 2 0 mips16-bronly
+    run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 69 1 umips-only
+    run_mips_plt_test "o32 PLTs for microMIPS branches" o32 2 1 umips-bronly
     run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16" \
-       o32 -1 0 mips16
+       o32 109 0 mips16
+    run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 branches" \
+       o32 18 0 mips16-branch
     run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with %got" \
-       o32 -1 0 mips16-got compressed-plt-1d.s
+       o32 109 0 mips16-got compressed-plt-1d.s
     run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with .word" \
-       o32 -1 0 mips16-word compressed-plt-1e.s
+       o32 109 0 mips16-word compressed-plt-1e.s
     run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS" \
-       o32 -1 1 umips
+       o32 109 1 umips
+    run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS branches" \
+       o32 18 1 umips-branch
     run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with %got" \
-       o32 -1 1 umips-got compressed-plt-1d.s
+       o32 109 1 umips-got compressed-plt-1d.s
     run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with .word" \
-       o32 -1 1 umips-word compressed-plt-1e.s
+       o32 109 1 umips-word compressed-plt-1e.s
 
     if $has_newabi {
        build_mips_plt_lib n32
        run_mips_plt_test "n32 PLTs for mixed MIPS and MIPS16" \
-           n32 -1 0 mips16
+           n32 109 0 mips16
        run_mips_plt_test "n32 PLTs for mixed MIPS and microMIPS" \
-           n32 -1 1 umips
+           n32 109 1 umips
+    }
+}
+
+# PR ld/19908 export class tests.
+if { $linux_gnu } {
+    run_ld_link_tests [list \
+       [list "Shared library for MIPS export class symbol reference tests" \
+             "$abi_ldflags(o32) -shared" "" \
+             "$abi_asflags(o32)" \
+             { export-class-ref-f2.s } \
+             { { readelf --dyn-syms export-class-ref-lib.sd } } \
+             "export-class-ref-lib.so"]]
+    foreach { class flag } { internal 1 hidden 2 protected 3 } {
+       run_ld_link_tests [list \
+           [list "MIPS $class symbol reference test 1" \
+                 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
+                 "$abi_asflags(o32) --defsym defv=$flag" \
+                 { export-class-ref-f0.s export-class-ref-f1.s } \
+                 [list [list readelf --dyn-syms export-$class-ref.sd] \
+                       [list readelf --dyn-syms export-local-ref.sd]] \
+                 "export-$class-ref"] \
+           [list "MIPS $class symbol reference test 2" \
+                 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
+                 "$abi_asflags(o32) --defsym defv=$flag --defsym refv=$flag" \
+                 { export-class-ref-f0.s export-class-ref-f1.s } \
+                 [list [list readelf --dyn-syms export-$class-ref.sd] \
+                       [list readelf --dyn-syms export-local-ref.sd]] \
+                 "export-$class-ref"]]
     }
 }
This page took 0.030959 seconds and 4 git commands to generate.