summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Demetriou <cgd@google.com>2002-01-02 18:59:32 +0000
committerChris Demetriou <cgd@google.com>2002-01-02 18:59:32 +0000
commita657e7c198e219e5e540a804f9e5dfb0d81ba886 (patch)
tree29a4f1dcec826a1121a21ba0c139e713d82d4bac
parent20d54542b93d43f80c98f5a329c13f39e4835075 (diff)
downloadbinutils-gdb-a657e7c198e219e5e540a804f9e5dfb0d81ba886.tar.gz
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).
-rw-r--r--gas/testsuite/ChangeLog11
-rw-r--r--gas/testsuite/gas/mips/empic3_e.d47
-rw-r--r--gas/testsuite/gas/mips/empic3_e.s46
-rw-r--r--gas/testsuite/gas/mips/empic3_g1.d47
-rw-r--r--gas/testsuite/gas/mips/empic3_g1.s46
-rw-r--r--gas/testsuite/gas/mips/empic3_g2.d47
-rw-r--r--gas/testsuite/gas/mips/empic3_g2.s46
-rw-r--r--gas/testsuite/gas/mips/mips.exp3
-rw-r--r--ld/testsuite/ChangeLog25
-rw-r--r--ld/testsuite/ld-mips-elf/empic1-ln.d27
-rw-r--r--ld/testsuite/ld-mips-elf/empic1-lp.d26
-rw-r--r--ld/testsuite/ld-mips-elf/empic1-mn.d25
-rw-r--r--ld/testsuite/ld-mips-elf/empic1-mp.d25
-rw-r--r--ld/testsuite/ld-mips-elf/empic1-ref.s9
-rw-r--r--ld/testsuite/ld-mips-elf/empic1-sn.d23
-rw-r--r--ld/testsuite/ld-mips-elf/empic1-sp.d23
-rw-r--r--ld/testsuite/ld-mips-elf/empic1-space.s5
-rw-r--r--ld/testsuite/ld-mips-elf/empic1-tgt.s8
-rw-r--r--ld/testsuite/ld-mips-elf/empic2-fwd-0.d20
-rw-r--r--ld/testsuite/ld-mips-elf/empic2-fwd-1.d21
-rw-r--r--ld/testsuite/ld-mips-elf/empic2-fwd-tgt.s7
-rw-r--r--ld/testsuite/ld-mips-elf/empic2-ref.s6
-rw-r--r--ld/testsuite/ld-mips-elf/empic2-rev-0.d22
-rw-r--r--ld/testsuite/ld-mips-elf/empic2-rev-1.d24
-rw-r--r--ld/testsuite/ld-mips-elf/empic2-rev-tgt.s8
-rw-r--r--ld/testsuite/ld-mips-elf/empic2-space.s5
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp38
27 files changed, 640 insertions, 0 deletions
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index daa30510a70..7fdf423a73e 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -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
index 00000000000..24ec944ab2f
--- /dev/null
+++ b/gas/testsuite/gas/mips/empic3_e.d
@@ -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
index 00000000000..7a8d21aa2a3
--- /dev/null
+++ b/gas/testsuite/gas/mips/empic3_e.s
@@ -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
index 00000000000..3e0f5baa32e
--- /dev/null
+++ b/gas/testsuite/gas/mips/empic3_g1.d
@@ -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
index 00000000000..cf1df44a8cf
--- /dev/null
+++ b/gas/testsuite/gas/mips/empic3_g1.s
@@ -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
index 00000000000..2a6a452f9c3
--- /dev/null
+++ b/gas/testsuite/gas/mips/empic3_g2.d
@@ -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
index 00000000000..4c070ee04ad
--- /dev/null
+++ b/gas/testsuite/gas/mips/empic3_g2.s
@@ -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
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index 8c3621618c3..f5cccc1ac7e 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -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"
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 42a495e81f5..17f81579459 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -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
index 00000000000..eb784786d29
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic1-ln.d
@@ -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
index 00000000000..bd11e525b61
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic1-lp.d
@@ -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
index 00000000000..fa43abf27d1
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic1-mn.d
@@ -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
index 00000000000..27d157477ff
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic1-mp.d
@@ -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
index 00000000000..dfa345e6ba6
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic1-ref.s
@@ -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
index 00000000000..6d041edf34d
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic1-sn.d
@@ -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
index 00000000000..f91d6259475
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic1-sp.d
@@ -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
index 00000000000..9c30cfbccfc
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic1-space.s
@@ -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
index 00000000000..909488cedce
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic1-tgt.s
@@ -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
index 00000000000..e53f1faa134
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic2-fwd-0.d
@@ -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
index 00000000000..e7208520da8
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic2-fwd-1.d
@@ -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
index 00000000000..915cf456b22
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic2-fwd-tgt.s
@@ -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
index 00000000000..c0ae00c5ab4
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic2-ref.s
@@ -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
index 00000000000..9bd9accb258
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic2-rev-0.d
@@ -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
index 00000000000..1a38ec2c7c3
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic2-rev-1.d
@@ -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
index 00000000000..8124cfe750c
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic2-rev-tgt.s
@@ -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
index 00000000000..9c30cfbccfc
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/empic2-space.s
@@ -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
index 00000000000..b47b32628f8
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -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"
+ }
+}