2002-01-02 Chris Demetriou <cgd@broadcom.com>
authorChris Demetriou <cgd@google.com>
Wed, 2 Jan 2002 18:59:32 +0000 (18:59 +0000)
committerChris Demetriou <cgd@google.com>
Wed, 2 Jan 2002 18:59:32 +0000 (18:59 +0000)
        * ld-mips-elf/empic1-ln.d: New file to test basic linking of
        R_MIPS_GNU_REL_HI16 and R_MIPS_GNU_REL_LO16 relocations.
        * ld-mips-elf/empic1-lp.d: Likewise.
        * ld-mips-elf/empic1-mn.d: Likewise.
        * ld-mips-elf/empic1-mp.d: Likewise.
        * ld-mips-elf/empic1-sn.d: Likewise.
        * ld-mips-elf/empic1-sp.d: Likewise.
        * ld-mips-elf/empic1-ref.s: Likewise.
        * ld-mips-elf/empic1-space.s: Likewise.
        * ld-mips-elf/empic1-tgt.s: Likewise.
        * ld-mips-elf/empic2-fwd-0.d: New file to test
        R_MIPS_GNU_REL_HI16 and R_MIPS_GNU_REL_LO16 relocation edge
        cases.
        * ld-mips-elf/empic2-fwd-1.d: Likewise.
        * ld-mips-elf/empic2-rev-0.d: Likewise.
        * ld-mips-elf/empic2-rev-1.d: Likewise.
        * ld-mips-elf/empic2-ref.s: Likewise.
        * ld-mips-elf/empic2-space.s: Likewise.
        * ld-mips-elf/empic2-fwd-tgt.s: Likewise.
        * ld-mips-elf/empic2-rev-tgt.s: Likewise.
        * ld-mips-elf/mips-elf.exp: New file to run MIPS 32-bit ELF
        tests (including those above).

27 files changed:
gas/testsuite/ChangeLog
gas/testsuite/gas/mips/empic3_e.d [new file with mode: 0644]
gas/testsuite/gas/mips/empic3_e.s [new file with mode: 0644]
gas/testsuite/gas/mips/empic3_g1.d [new file with mode: 0644]
gas/testsuite/gas/mips/empic3_g1.s [new file with mode: 0644]
gas/testsuite/gas/mips/empic3_g2.d [new file with mode: 0644]
gas/testsuite/gas/mips/empic3_g2.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips.exp
ld/testsuite/ChangeLog
ld/testsuite/ld-mips-elf/empic1-ln.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic1-lp.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic1-mn.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic1-mp.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic1-ref.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic1-sn.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic1-sp.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic1-space.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic1-tgt.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic2-fwd-0.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic2-fwd-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic2-fwd-tgt.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic2-ref.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic2-rev-0.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic2-rev-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic2-rev-tgt.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/empic2-space.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-elf.exp [new file with mode: 0644]

index daa30510a705bdbbdc58b394671d2372b9a75f6f..7fdf423a73e44e2d9fab40d79317424301cc02bc 100644 (file)
@@ -1,3 +1,14 @@
+2002-01-02  Chris Demetriou  <cgd@broadcom.com>
+
+       * gas/mips/empic3_e.d: New file to test -membedded-pic
+       R_MIPS_GNU_REL_HI16 and R_MIPS_GNU_REL_LO16 relocations.
+       * gas/mips/empic3_e.s: Likewise.
+       * gas/mips/empic3_g1.d: Likewise.
+       * gas/mips/empic3_g1.s: Likewise.
+       * gas/mips/empic3_g2.d: Likewise.
+       * gas/mips/empic3_g2.s: Likewise.
+       * gas/mips/mips.exp: Run the new tests.
+
 2001-12-21  Anders Norlander  <anorland@synergenix.se>
 
        * gas/all/incbin.dat: New [binary] file.
diff --git a/gas/testsuite/gas/mips/empic3_e.d b/gas/testsuite/gas/mips/empic3_e.d
new file mode 100644 (file)
index 0000000..24ec944
--- /dev/null
@@ -0,0 +1,47 @@
+#objdump: --prefix-addresses -dr --show-raw-insn -mmips:4000
+#name: MIPS empic3 (external)
+#as: -membedded-pic -mips3
+
+# Check PC-relative HI/LO relocs relocs for -membedded-pic when HI and
+# LO are split over a 32K boundary.
+
+.*: +file format elf.*mips.*
+
+Disassembly of section .text:
+       ...
+       ...
+0000fffc <[^>]*> 3c020001      lui     v0,0x1
+[      ]*fffc: R_MIPS_GNU_REL_HI16     ext
+00010000 <[^>]*> 64428000      daddiu  v0,v0,-32768
+[      ]*10000: R_MIPS_GNU_REL_LO16    ext
+       ...
+00017ffc <[^>]*> 3c020001      lui     v0,0x1
+[      ]*17ffc: R_MIPS_GNU_REL_HI16    ext
+00018000 <[^>]*> 64420000      daddiu  v0,v0,0
+[      ]*18000: R_MIPS_GNU_REL_LO16    ext
+       ...
+0001fffc <[^>]*> 3c020002      lui     v0,0x2
+[      ]*1fffc: R_MIPS_GNU_REL_HI16    ext
+00020000 <[^>]*> 0043102d      daddu   v0,v0,v1
+00020004 <[^>]*> 64428004      daddiu  v0,v0,-32764
+[      ]*20004: R_MIPS_GNU_REL_LO16    ext
+       ...
+00027ffc <[^>]*> 3c020002      lui     v0,0x2
+[      ]*27ffc: R_MIPS_GNU_REL_HI16    ext
+00028000 <[^>]*> 0043102d      daddu   v0,v0,v1
+00028004 <[^>]*> 64420004      daddiu  v0,v0,4
+[      ]*28004: R_MIPS_GNU_REL_LO16    ext
+       ...
+0002fff8 <[^>]*> 3c020003      lui     v0,0x3
+[      ]*2fff8: R_MIPS_GNU_REL_HI16    ext
+0002fffc <[^>]*> 0043102d      daddu   v0,v0,v1
+00030000 <[^>]*> 64428000      daddiu  v0,v0,-32768
+[      ]*30000: R_MIPS_GNU_REL_LO16    ext
+       ...
+00037ff8 <[^>]*> 3c020003      lui     v0,0x3
+[      ]*37ff8: R_MIPS_GNU_REL_HI16    ext
+00037ffc <[^>]*> 0043102d      daddu   v0,v0,v1
+00038000 <[^>]*> 64420000      daddiu  v0,v0,0
+[      ]*38000: R_MIPS_GNU_REL_LO16    ext
+       ...
+       ...
diff --git a/gas/testsuite/gas/mips/empic3_e.s b/gas/testsuite/gas/mips/empic3_e.s
new file mode 100644 (file)
index 0000000..7a8d21a
--- /dev/null
@@ -0,0 +1,46 @@
+# Check PC-relative HI/LO relocs relocs for -membedded-pic when HI and
+# LO are split over a 32K boundary.
+
+        .text
+        .set noreorder
+
+       SYM_TO_TEST = ext
+
+       .globl  ext
+
+       .org    0x00000
+       .globl  g1
+g1:
+l1:
+
+       .org    0x08000
+       .globl  fn
+       .ent    fn
+fn:
+       .org    (0x10000 - 4)
+       la      $2, SYM_TO_TEST - fn            # expands to 2 instructions
+
+       .org    (0x18000 - 4)
+       la      $2, SYM_TO_TEST - fn            # expands to 2 instructions
+
+       .org    (0x20000 - 4)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .org    (0x28000 - 4)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .org    (0x30000 - 8)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .org    (0x38000 - 8)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .end fn
+
+       .org    0x40000
+       .globl  g2
+g2:
+l2:
+
+# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
+      .space  8
diff --git a/gas/testsuite/gas/mips/empic3_g1.d b/gas/testsuite/gas/mips/empic3_g1.d
new file mode 100644 (file)
index 0000000..3e0f5ba
--- /dev/null
@@ -0,0 +1,47 @@
+#objdump: --prefix-addresses -dr --show-raw-insn -mmips:4000
+#name: MIPS empic3 (global, negative)
+#as: -membedded-pic -mips3
+
+# Check PC-relative HI/LO relocs relocs for -membedded-pic when HI and
+# LO are split over a 32K boundary.
+
+.*: +file format elf.*mips.*
+
+Disassembly of section .text:
+       ...
+       ...
+0000fffc <[^>]*> 3c020001      lui     v0,0x1
+[      ]*fffc: R_MIPS_GNU_REL_HI16     .text
+00010000 <[^>]*> 64428000      daddiu  v0,v0,-32768
+[      ]*10000: R_MIPS_GNU_REL_LO16    .text
+       ...
+00017ffc <[^>]*> 3c020001      lui     v0,0x1
+[      ]*17ffc: R_MIPS_GNU_REL_HI16    .text
+00018000 <[^>]*> 64420000      daddiu  v0,v0,0
+[      ]*18000: R_MIPS_GNU_REL_LO16    .text
+       ...
+0001fffc <[^>]*> 3c020002      lui     v0,0x2
+[      ]*1fffc: R_MIPS_GNU_REL_HI16    .text
+00020000 <[^>]*> 0043102d      daddu   v0,v0,v1
+00020004 <[^>]*> 64428004      daddiu  v0,v0,-32764
+[      ]*20004: R_MIPS_GNU_REL_LO16    .text
+       ...
+00027ffc <[^>]*> 3c020002      lui     v0,0x2
+[      ]*27ffc: R_MIPS_GNU_REL_HI16    .text
+00028000 <[^>]*> 0043102d      daddu   v0,v0,v1
+00028004 <[^>]*> 64420004      daddiu  v0,v0,4
+[      ]*28004: R_MIPS_GNU_REL_LO16    .text
+       ...
+0002fff8 <[^>]*> 3c020003      lui     v0,0x3
+[      ]*2fff8: R_MIPS_GNU_REL_HI16    .text
+0002fffc <[^>]*> 0043102d      daddu   v0,v0,v1
+00030000 <[^>]*> 64428000      daddiu  v0,v0,-32768
+[      ]*30000: R_MIPS_GNU_REL_LO16    .text
+       ...
+00037ff8 <[^>]*> 3c020003      lui     v0,0x3
+[      ]*37ff8: R_MIPS_GNU_REL_HI16    .text
+00037ffc <[^>]*> 0043102d      daddu   v0,v0,v1
+00038000 <[^>]*> 64420000      daddiu  v0,v0,0
+[      ]*38000: R_MIPS_GNU_REL_LO16    .text
+       ...
+       ...
diff --git a/gas/testsuite/gas/mips/empic3_g1.s b/gas/testsuite/gas/mips/empic3_g1.s
new file mode 100644 (file)
index 0000000..cf1df44
--- /dev/null
@@ -0,0 +1,46 @@
+# Check PC-relative HI/LO relocs relocs for -membedded-pic when HI and
+# LO are split over a 32K boundary.
+
+        .text
+        .set noreorder
+
+       SYM_TO_TEST = g1
+
+       .globl  ext
+
+       .org    0x00000
+       .globl  g1
+g1:
+l1:
+
+       .org    0x08000
+       .globl  fn
+       .ent    fn
+fn:
+       .org    (0x10000 - 4)
+       la      $2, SYM_TO_TEST - fn            # expands to 2 instructions
+
+       .org    (0x18000 - 4)
+       la      $2, SYM_TO_TEST - fn            # expands to 2 instructions
+
+       .org    (0x20000 - 4)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .org    (0x28000 - 4)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .org    (0x30000 - 8)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .org    (0x38000 - 8)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .end fn
+
+       .org    0x40000
+       .globl  g2
+g2:
+l2:
+
+# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
+      .space  8
diff --git a/gas/testsuite/gas/mips/empic3_g2.d b/gas/testsuite/gas/mips/empic3_g2.d
new file mode 100644 (file)
index 0000000..2a6a452
--- /dev/null
@@ -0,0 +1,47 @@
+#objdump: --prefix-addresses -dr --show-raw-insn -mmips:4000
+#name: MIPS empic3 (global, positive)
+#as: -membedded-pic -mips3
+
+# Check PC-relative HI/LO relocs relocs for -membedded-pic when HI and
+# LO are split over a 32K boundary.
+
+.*: +file format elf.*mips.*
+
+Disassembly of section .text:
+       ...
+       ...
+0000fffc <[^>]*> 3c020005      lui     v0,0x5
+[      ]*fffc: R_MIPS_GNU_REL_HI16     .text
+00010000 <[^>]*> 64428000      daddiu  v0,v0,-32768
+[      ]*10000: R_MIPS_GNU_REL_LO16    .text
+       ...
+00017ffc <[^>]*> 3c020005      lui     v0,0x5
+[      ]*17ffc: R_MIPS_GNU_REL_HI16    .text
+00018000 <[^>]*> 64420000      daddiu  v0,v0,0
+[      ]*18000: R_MIPS_GNU_REL_LO16    .text
+       ...
+0001fffc <[^>]*> 3c020006      lui     v0,0x6
+[      ]*1fffc: R_MIPS_GNU_REL_HI16    .text
+00020000 <[^>]*> 0043102d      daddu   v0,v0,v1
+00020004 <[^>]*> 64428004      daddiu  v0,v0,-32764
+[      ]*20004: R_MIPS_GNU_REL_LO16    .text
+       ...
+00027ffc <[^>]*> 3c020006      lui     v0,0x6
+[      ]*27ffc: R_MIPS_GNU_REL_HI16    .text
+00028000 <[^>]*> 0043102d      daddu   v0,v0,v1
+00028004 <[^>]*> 64420004      daddiu  v0,v0,4
+[      ]*28004: R_MIPS_GNU_REL_LO16    .text
+       ...
+0002fff8 <[^>]*> 3c020007      lui     v0,0x7
+[      ]*2fff8: R_MIPS_GNU_REL_HI16    .text
+0002fffc <[^>]*> 0043102d      daddu   v0,v0,v1
+00030000 <[^>]*> 64428000      daddiu  v0,v0,-32768
+[      ]*30000: R_MIPS_GNU_REL_LO16    .text
+       ...
+00037ff8 <[^>]*> 3c020007      lui     v0,0x7
+[      ]*37ff8: R_MIPS_GNU_REL_HI16    .text
+00037ffc <[^>]*> 0043102d      daddu   v0,v0,v1
+00038000 <[^>]*> 64420000      daddiu  v0,v0,0
+[      ]*38000: R_MIPS_GNU_REL_LO16    .text
+       ...
+       ...
diff --git a/gas/testsuite/gas/mips/empic3_g2.s b/gas/testsuite/gas/mips/empic3_g2.s
new file mode 100644 (file)
index 0000000..4c070ee
--- /dev/null
@@ -0,0 +1,46 @@
+# Check PC-relative HI/LO relocs relocs for -membedded-pic when HI and
+# LO are split over a 32K boundary.
+
+        .text
+        .set noreorder
+
+       SYM_TO_TEST = g2
+
+       .globl  ext
+
+       .org    0x00000
+       .globl  g1
+g1:
+l1:
+
+       .org    0x08000
+       .globl  fn
+       .ent    fn
+fn:
+       .org    (0x10000 - 4)
+       la      $2, SYM_TO_TEST - fn            # expands to 2 instructions
+
+       .org    (0x18000 - 4)
+       la      $2, SYM_TO_TEST - fn            # expands to 2 instructions
+
+       .org    (0x20000 - 4)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .org    (0x28000 - 4)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .org    (0x30000 - 8)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .org    (0x38000 - 8)
+       la      $2, (SYM_TO_TEST - fn)($3)      # expands to 3 instructions
+
+       .end fn
+
+       .org    0x40000
+       .globl  g2
+g2:
+l2:
+
+# Force at least 8 (non-delay-slot) zero bytes, to make 'objdump' print ...
+      .space  8
index 8c3621618c363c919c329b4a56386b2a3354a8cd..f5cccc1ac7e526316397c0b15bdb19c9dc75dbb1 100644 (file)
@@ -163,6 +163,9 @@ if { [istarget mips*-*-*] } then {
        run_dump_test "elf-rel5"
        run_dump_test "${tmips}${el}empic"
        run_dump_test "empic2"
+       run_dump_test "empic3_e"
+       run_dump_test "empic3_g1"
+       run_dump_test "empic3_g2"
        if { !$no_mips16 } { 
            run_dump_test "${tmips}mips${el}16-e" 
            run_dump_test "${tmips}mips${el}16-f" 
index 42a495e81f5e63a65d8c2abf56441b849a7a47a6..17f8157945941e3782c6e621d9fcdfaaa6145496 100644 (file)
@@ -1,3 +1,28 @@
+2002-01-02  Chris Demetriou  <cgd@broadcom.com>
+
+       * ld-mips-elf/empic1-ln.d: New file to test basic linking of
+       R_MIPS_GNU_REL_HI16 and R_MIPS_GNU_REL_LO16 relocations.
+       * ld-mips-elf/empic1-lp.d: Likewise.
+       * ld-mips-elf/empic1-mn.d: Likewise.
+       * ld-mips-elf/empic1-mp.d: Likewise.
+       * ld-mips-elf/empic1-sn.d: Likewise.
+       * ld-mips-elf/empic1-sp.d: Likewise.
+       * ld-mips-elf/empic1-ref.s: Likewise.
+       * ld-mips-elf/empic1-space.s: Likewise.
+       * ld-mips-elf/empic1-tgt.s: Likewise.
+       * ld-mips-elf/empic2-fwd-0.d: New file to test
+       R_MIPS_GNU_REL_HI16 and R_MIPS_GNU_REL_LO16 relocation edge
+       cases.
+       * ld-mips-elf/empic2-fwd-1.d: Likewise.
+       * ld-mips-elf/empic2-rev-0.d: Likewise.
+       * ld-mips-elf/empic2-rev-1.d: Likewise.
+       * ld-mips-elf/empic2-ref.s: Likewise.
+       * ld-mips-elf/empic2-space.s: Likewise.
+       * ld-mips-elf/empic2-fwd-tgt.s: Likewise.
+       * ld-mips-elf/empic2-rev-tgt.s: Likewise.
+       * ld-mips-elf/mips-elf.exp: New file to run MIPS 32-bit ELF
+       tests (including those above).
+
 2001-11-30  H.J. Lu <hjl@gnu.org>
 
        * ld-elfvers/vers.exp (build_vers_lib): Preserve the library
diff --git a/ld/testsuite/ld-mips-elf/empic1-ln.d b/ld/testsuite/ld-mips-elf/empic1-ln.d
new file mode 100644 (file)
index 0000000..eb78478
--- /dev/null
@@ -0,0 +1,27 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #1-ln (large negative)
+#as: -membedded-pic -mips3
+#source: empic1-tgt.s
+#source: empic1-space.s
+#source: empic1-space.s
+#source: empic1-ref.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+SYMBOL TABLE:
+#...
+0+410020 g     F .text [0-9a-f]+ foo
+#...
+0+400000 g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+       ...
+       ...
+       ...
+0+410020 <[^>]*> 00000000      nop
+0+410024 <[^>]*> 3c02ffff      lui     v0,0xffff
+0+410028 <[^>]*> 6442ffe0      daddiu  v0,v0,-32
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic1-lp.d b/ld/testsuite/ld-mips-elf/empic1-lp.d
new file mode 100644 (file)
index 0000000..bd11e52
--- /dev/null
@@ -0,0 +1,26 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #1-lp (large positive)
+#as: -membedded-pic -mips3
+#source: empic1-ref.s
+#source: empic1-space.s
+#source: empic1-space.s
+#source: empic1-tgt.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+SYMBOL TABLE:
+#...
+0+400000 g     F .text [0-9a-f]+ foo
+#...
+0+410020 g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+0+400000 <[^>]*> 00000000      nop
+0+400004 <[^>]*> 3c020001      lui     v0,0x1
+0+400008 <[^>]*> 64420020      daddiu  v0,v0,32
+       ...
+       ...
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic1-mn.d b/ld/testsuite/ld-mips-elf/empic1-mn.d
new file mode 100644 (file)
index 0000000..fa43abf
--- /dev/null
@@ -0,0 +1,25 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #1-mn (medium negative)
+#as: -membedded-pic -mips3
+#source: empic1-tgt.s
+#source: empic1-space.s
+#source: empic1-ref.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+SYMBOL TABLE:
+#...
+0+408020 g     F .text [0-9a-f]+ foo
+#...
+0+400000 g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+       ...
+       ...
+0+408020 <[^>]*> 00000000      nop
+0+408024 <[^>]*> 3c02ffff      lui     v0,0xffff
+0+408028 <[^>]*> 64427fe0      daddiu  v0,v0,32736
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic1-mp.d b/ld/testsuite/ld-mips-elf/empic1-mp.d
new file mode 100644 (file)
index 0000000..27d1574
--- /dev/null
@@ -0,0 +1,25 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #1-mp (medium positive)
+#as: -membedded-pic -mips3
+#source: empic1-ref.s
+#source: empic1-space.s
+#source: empic1-tgt.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+SYMBOL TABLE:
+#...
+0+400000 g     F .text [0-9a-f]+ foo
+#...
+0+408020 g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+0+400000 <[^>]*> 00000000      nop
+0+400004 <[^>]*> 3c020001      lui     v0,0x1
+0+400008 <[^>]*> 64428020      daddiu  v0,v0,-32736
+       ...
+       ...
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic1-ref.s b/ld/testsuite/ld-mips-elf/empic1-ref.s
new file mode 100644 (file)
index 0000000..dfa345e
--- /dev/null
@@ -0,0 +1,9 @@
+
+       .globl  foo
+       .ent    foo
+foo:
+       nop
+       la      $2, bar - foo
+       .end    foo
+
+       .p2align 5
diff --git a/ld/testsuite/ld-mips-elf/empic1-sn.d b/ld/testsuite/ld-mips-elf/empic1-sn.d
new file mode 100644 (file)
index 0000000..6d041ed
--- /dev/null
@@ -0,0 +1,23 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #1-sn (small negative)
+#as: -membedded-pic -mips3
+#source: empic1-tgt.s
+#source: empic1-ref.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+SYMBOL TABLE:
+#...
+0+400020 g     F .text [0-9a-f]+ foo
+#...
+0+400000 g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+       ...
+0+400020 <[^>]*> 00000000      nop
+0+400024 <[^>]*> 3c020000      lui     v0,0x0
+0+400028 <[^>]*> 6442ffe0      daddiu  v0,v0,-32
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic1-sp.d b/ld/testsuite/ld-mips-elf/empic1-sp.d
new file mode 100644 (file)
index 0000000..f91d625
--- /dev/null
@@ -0,0 +1,23 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #1-sp (small positive)
+#as: -membedded-pic -mips3
+#source: empic1-ref.s
+#source: empic1-tgt.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+SYMBOL TABLE:
+#...
+0+400000 g     F .text [0-9a-f]+ foo
+#...
+0+400020 g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+0+400000 <[^>]*> 00000000      nop
+0+400004 <[^>]*> 3c020000      lui     v0,0x0
+0+400008 <[^>]*> 64420020      daddiu  v0,v0,32
+       ...
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic1-space.s b/ld/testsuite/ld-mips-elf/empic1-space.s
new file mode 100644 (file)
index 0000000..9c30cfb
--- /dev/null
@@ -0,0 +1,5 @@
+
+       .ent    space
+space:
+       .space  (32 * 1024)
+       .end    space
diff --git a/ld/testsuite/ld-mips-elf/empic1-tgt.s b/ld/testsuite/ld-mips-elf/empic1-tgt.s
new file mode 100644 (file)
index 0000000..909488c
--- /dev/null
@@ -0,0 +1,8 @@
+
+       .globl  bar
+       .ent    bar
+bar:
+       nop
+       .end    bar
+
+       .p2align 5
diff --git a/ld/testsuite/ld-mips-elf/empic2-fwd-0.d b/ld/testsuite/ld-mips-elf/empic2-fwd-0.d
new file mode 100644 (file)
index 0000000..e53f1fa
--- /dev/null
@@ -0,0 +1,20 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #2-fwd-0 (0x7ffc forward edge case)
+#as: -membedded-pic -mips3
+#source: empic2-ref.s
+#source: empic2-fwd-tgt.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+#...
+0+400000 g     F .text [0-9a-f]+ foo
+#...
+0+407ffc g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+0+400000 <[^>]*> 3c020000      lui     v0,0x0
+0+400004 <[^>]*> 64427ffc      daddiu  v0,v0,32764
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic2-fwd-1.d b/ld/testsuite/ld-mips-elf/empic2-fwd-1.d
new file mode 100644 (file)
index 0000000..e720852
--- /dev/null
@@ -0,0 +1,21 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #2-fwd-1 (0xfffc forward edge case)
+#as: -membedded-pic -mips3
+#source: empic2-ref.s
+#source: empic2-space.s
+#source: empic2-fwd-tgt.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+#...
+0+400000 g     F .text [0-9a-f]+ foo
+#...
+0+40fffc g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+0+400000 <[^>]*> 3c020001      lui     v0,0x1
+0+400004 <[^>]*> 6442fffc      daddiu  v0,v0,-4
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic2-fwd-tgt.s b/ld/testsuite/ld-mips-elf/empic2-fwd-tgt.s
new file mode 100644 (file)
index 0000000..915cf45
--- /dev/null
@@ -0,0 +1,7 @@
+
+       .space (32768 - 16 - 4)         # 16..32764
+
+       .globl  bar
+       .ent    bar
+bar:
+       .end    bar
diff --git a/ld/testsuite/ld-mips-elf/empic2-ref.s b/ld/testsuite/ld-mips-elf/empic2-ref.s
new file mode 100644 (file)
index 0000000..c0ae00c
--- /dev/null
@@ -0,0 +1,6 @@
+       .globl  foo
+       .ent    foo
+foo:
+       la      $2,bar-foo
+
+       .p2align 4
diff --git a/ld/testsuite/ld-mips-elf/empic2-rev-0.d b/ld/testsuite/ld-mips-elf/empic2-rev-0.d
new file mode 100644 (file)
index 0000000..9bd9acc
--- /dev/null
@@ -0,0 +1,22 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #2-rev-0 (0x0004 backward edge case)
+#as: -membedded-pic -mips3
+#source: empic2-rev-tgt.s
+#source: empic2-ref.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+#...
+0+408000 g     F .text [0-9a-f]+ foo
+#...
+0+407ffc g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+       ...
+0+407ffc <[^>]*> 00000000      nop
+0+408000 <[^>]*> 3c020000      lui     v0,0x0
+0+408004 <[^>]*> 6442fffc      daddiu  v0,v0,-4
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic2-rev-1.d b/ld/testsuite/ld-mips-elf/empic2-rev-1.d
new file mode 100644 (file)
index 0000000..1a38ec2
--- /dev/null
@@ -0,0 +1,24 @@
+#name: MIPS 32-bit ELF embedded-pic relocs #2-rev-1 (0x8004 backward edge case)
+#as: -membedded-pic -mips3
+#source: empic2-rev-tgt.s
+#source: empic2-space.s
+#source: empic2-ref.s
+#objdump: --prefix-addresses -tdr --show-raw-insn -mmips:4000
+#ld: -Ttext 0x400000 -e 0x400000
+
+.*:     file format elf.*mips.*
+
+#...
+0+410000 g     F .text [0-9a-f]+ foo
+#...
+0+407ffc g     F .text [0-9a-f]+ bar
+#...
+
+Disassembly of section \.text:
+       ...
+0+407ffc <[^>]*> 00000000      nop
+       ...
+0+410000 <[^>]*> 3c02ffff      lui     v0,0xffff
+0+410004 <[^>]*> 64427ffc      daddiu  v0,v0,32764
+       ...
+#pass
diff --git a/ld/testsuite/ld-mips-elf/empic2-rev-tgt.s b/ld/testsuite/ld-mips-elf/empic2-rev-tgt.s
new file mode 100644 (file)
index 0000000..8124cfe
--- /dev/null
@@ -0,0 +1,8 @@
+
+       .space (32768 - 4)
+
+       .globl  bar
+       .ent    bar
+bar:
+       .space  4
+       .end    bar
diff --git a/ld/testsuite/ld-mips-elf/empic2-space.s b/ld/testsuite/ld-mips-elf/empic2-space.s
new file mode 100644 (file)
index 0000000..9c30cfb
--- /dev/null
@@ -0,0 +1,5 @@
+
+       .ent    space
+space:
+       .space  (32 * 1024)
+       .end    space
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
new file mode 100644 (file)
index 0000000..b47b326
--- /dev/null
@@ -0,0 +1,38 @@
+# Expect script for MIPS ELF linker tests
+#   Copyright 2002 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*-*-*] } then {
+
+    # Run embedded-pic tests only if generic ELF.
+    if { [istarget mips*-*-elf] } {
+       # Check basic PC-relative HI/LO relocs.
+       run_dump_test "empic1-ln"
+       run_dump_test "empic1-lp"
+       run_dump_test "empic1-mn"
+       run_dump_test "empic1-mp"
+       run_dump_test "empic1-sn"
+       run_dump_test "empic1-sp"
+
+       # PC-relative HI/LO reloc edge-case regression tests.
+       # As of 2001-12-26, the linker botches the fwd-0 and rev-1 tests.
+       run_dump_test "empic2-fwd-0"
+       run_dump_test "empic2-fwd-1"
+       run_dump_test "empic2-rev-0"
+       run_dump_test "empic2-rev-1"
+    }
+}