bfd/
authorRichard Sandiford <rdsandiford@googlemail.com>
Mon, 18 Aug 2008 18:14:05 +0000 (18:14 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Mon, 18 Aug 2008 18:14:05 +0000 (18:14 +0000)
* elfxx-mips.c (_bfd_mips_elf_copy_indirect_symbol): Copy MIPS16
stub information.

ld/testsuite/
* ld-mips-elf/mips16-pic-4a.s, ld-mips-elf/mips16-pic-4b.s,
ld-mips-elf/mips16-pic-4.ver, ld-mips-elf/mips16-pic-4a.dd,
ld-mips-elf/mips16-pic-4a.nd, ld-mips-elf/mips16-pic-4a.gd,
ld-mips-elf/mips16-pic-4c.s, ld-mips-elf/mips16-pic-4b.dd: New tests.
* ld-mips-elf/mips-elf.exp: Run them.

12 files changed:
bfd/ChangeLog
bfd/elfxx-mips.c
ld/testsuite/ChangeLog
ld/testsuite/ld-mips-elf/mips-elf.exp
ld/testsuite/ld-mips-elf/mips16-pic-4.ver [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-pic-4a.dd [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-pic-4a.gd [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-pic-4a.nd [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-pic-4a.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-pic-4b.dd [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-pic-4b.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips16-pic-4c.s [new file with mode: 0644]

index bd98cfe..6c3dd56 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-18  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * elfxx-mips.c (_bfd_mips_elf_copy_indirect_symbol): Copy MIPS16
+       stub information.
+
 2008-08-17  Nick Clifton  <nickc@redhat.com>
 
        * elf32-arm.c: Tidy up the code.
index eb6d55e..43a4604 100644 (file)
@@ -10923,6 +10923,26 @@ _bfd_mips_elf_copy_indirect_symbol (struct bfd_link_info *info,
     dirmips->readonly_reloc = TRUE;
   if (indmips->no_fn_stub)
     dirmips->no_fn_stub = TRUE;
+  if (indmips->fn_stub)
+    {
+      dirmips->fn_stub = indmips->fn_stub;
+      indmips->fn_stub = NULL;
+    }
+  if (indmips->need_fn_stub)
+    {
+      dirmips->need_fn_stub = TRUE;
+      indmips->need_fn_stub = FALSE;
+    }
+  if (indmips->call_stub)
+    {
+      dirmips->call_stub = indmips->call_stub;
+      indmips->call_stub = NULL;
+    }
+  if (indmips->call_fp_stub)
+    {
+      dirmips->call_fp_stub = indmips->call_fp_stub;
+      indmips->call_fp_stub = NULL;
+    }
   if (indmips->global_got_area < dirmips->global_got_area)
     dirmips->global_got_area = indmips->global_got_area;
   if (indmips->global_got_area < GGA_NONE)
index d909938..b7f56c2 100644 (file)
@@ -1,3 +1,11 @@
+2008-08-18  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * ld-mips-elf/mips16-pic-4a.s, ld-mips-elf/mips16-pic-4b.s,
+       ld-mips-elf/mips16-pic-4.ver, ld-mips-elf/mips16-pic-4a.dd,
+       ld-mips-elf/mips16-pic-4a.nd, ld-mips-elf/mips16-pic-4a.gd,
+       ld-mips-elf/mips16-pic-4c.s, ld-mips-elf/mips16-pic-4b.dd: New tests.
+       * ld-mips-elf/mips-elf.exp: Run them.
+
 2008-08-17  Nick Clifton  <nickc@redhat.com>
 
        * ld-elf/sec-to-seg1.s: Shorten test data to align the section to
index 72964f9..fa098b1 100644 (file)
@@ -84,7 +84,19 @@ if { $linux_gnu } {
              { { objdump -dr mips16-pic-3.dd } \
                { readelf --relocs mips16-pic-3.rd } \
                { readelf -A mips16-pic-3.gd } } \
-             "mips16-pic-3"]]
+             "mips16-pic-3"] \
+       [list "MIPS16 PIC test 4 (shared library)" \
+             "-shared -melf32btsmip -T mips16-pic-1.ld --version-script mips16-pic-4.ver" \
+             "-EB -32" { mips16-pic-4a.s mips16-pic-4b.s } \
+             { { objdump -dr mips16-pic-4a.dd } \
+               { readelf --symbols mips16-pic-4a.nd } \
+               { readelf -A mips16-pic-4a.gd } } \
+             "mips16-pic-4.so"] \
+       [list "MIPS16 PIC test 4 (executable)" \
+             "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-4.so" \
+             "-EB -32" { mips16-pic-4c.s } \
+             { { objdump -dr mips16-pic-4b.dd } } \
+             "mips16-pic-4"]]
 }
 
 if { [istarget mips64*-linux-gnu] } {
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-4.ver b/ld/testsuite/ld-mips-elf/mips16-pic-4.ver
new file mode 100644 (file)
index 0000000..fc7b185
--- /dev/null
@@ -0,0 +1,8 @@
+V1 {
+  global:
+    f1;
+    f2;
+    f3;
+  local:
+    *;
+};
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-4a.dd b/ld/testsuite/ld-mips-elf/mips16-pic-4a.dd
new file mode 100644 (file)
index 0000000..d4e4f22
--- /dev/null
@@ -0,0 +1,23 @@
+
+.*
+
+
+Disassembly of section \.text:
+
+00040400 <f2>:
+.*     jr      ra
+.*     nop
+
+00040408 <f3>:
+.*     jr      ra
+.*     nop
+
+00040410 <_f1>:
+.*     jr      ra
+.*     nop
+#...
+
+00040420 <f1@@V1>:
+.*     lw      t9,-32744\(gp\)
+.*     jr      t9
+.*     mfc1    a0,\$f12
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-4a.gd b/ld/testsuite/ld-mips-elf/mips16-pic-4a.gd
new file mode 100644 (file)
index 0000000..1ab835e
--- /dev/null
@@ -0,0 +1,13 @@
+
+Primary GOT:
+ Canonical gp value: 00057ff0
+
+ Reserved entries:
+   Address     Access  Initial Purpose
+  00050000 -32752\(gp\) 00000000 Lazy resolver
+  00050004 -32748\(gp\) 80000000 Module pointer \(GNU extension\)
+
+ Local entries:
+   Address     Access  Initial
+  00050008 -32744\(gp\) 00040411
+
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-4a.nd b/ld/testsuite/ld-mips-elf/mips16-pic-4a.nd
new file mode 100644 (file)
index 0000000..6eca610
--- /dev/null
@@ -0,0 +1,10 @@
+
+Symbol table '\.dynsym' contains 6 entries:
+   Num:    Value  Size Type    Bind   Vis      Ndx Name
+     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
+     1: 00040400     0 SECTION LOCAL  DEFAULT   .* 
+     2: 00040420    12 FUNC    GLOBAL DEFAULT   .* f1@@V1
+     3: 00000000     0 OBJECT  GLOBAL DEFAULT  ABS V1
+     4: 00040408     8 FUNC    GLOBAL DEFAULT   .* f3@@V1
+     5: 00040400     8 FUNC    GLOBAL DEFAULT   .* f2@@V1
+#pass
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-4a.s b/ld/testsuite/ld-mips-elf/mips16-pic-4a.s
new file mode 100644 (file)
index 0000000..812d9d7
--- /dev/null
@@ -0,0 +1,33 @@
+       .abicalls
+       .set    noreorder
+
+       # Define a stub for f1, which is defined in another file.
+       #
+       # (It's questionable whether defining the stub and real function
+       # in separate files is really valid or useful.  However, if we
+       # accept it without error, we should do something useful with it.)
+
+       .section .mips16.fn.f1, "ax", @progbits
+       .ent    __fn
+__fn:
+       .reloc  0,R_MIPS_NONE,f1
+       la      $25,_f1
+       jr      $25
+       mfc1    $4,$f12
+       .end    __fn
+
+       # Define dummy functions for the executable to call.
+
+       .macro  dummy,name
+       .text
+       .global \name
+       .type   \name,@function
+       .ent    \name
+\name:
+       jr      $31
+       nop
+       .end    \name
+       .endm
+
+       dummy   f2
+       dummy   f3
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-4b.dd b/ld/testsuite/ld-mips-elf/mips16-pic-4b.dd
new file mode 100644 (file)
index 0000000..ddc55c3
--- /dev/null
@@ -0,0 +1,35 @@
+
+.*
+
+
+Disassembly of section \.text:
+
+00040400 <__start>:
+.*     jalx    40410 <__call>
+.*     nop
+.*     jalx    40420 <__call_fp>
+.*     nop
+#...
+
+00040410 <__call>:
+.*0004         lui     t9,.*
+.*0460         addiu   t9,t9,.*
+.*     jr      t9
+.*     nop
+
+00040420 <__call_fp>:
+.*0004         lui     t9,.*
+.*0470         addiu   t9,t9,.*
+.*     jr      t9
+.*     nop
+
+Disassembly of section \.plt:
+
+00040440 <_PROCEDURE_LINKAGE_TABLE_>:
+#...
+
+00040460 <f2@plt>:
+#...
+
+00040470 <f3@plt>:
+#...
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-4b.s b/ld/testsuite/ld-mips-elf/mips16-pic-4b.s
new file mode 100644 (file)
index 0000000..9cb5cb4
--- /dev/null
@@ -0,0 +1,15 @@
+       .abicalls
+       .set    noreorder
+
+       # Define a MIPS16 function f1@@V1.
+
+       .global _f1
+       .symver _f1,f1@@V1
+
+       .set    mips16
+       .type   _f1,@function
+       .ent    _f1
+_f1:
+       jr      $31
+       nop
+       .end    _f1
diff --git a/ld/testsuite/ld-mips-elf/mips16-pic-4c.s b/ld/testsuite/ld-mips-elf/mips16-pic-4c.s
new file mode 100644 (file)
index 0000000..338d378
--- /dev/null
@@ -0,0 +1,38 @@
+       .abicalls
+       .option pic0
+       .set    noreorder
+
+       # Create a call stub for f2.  We pretend that f2 takes floating-point
+       # arguments but doesn't return a floating-point value.
+
+       .section .mips16.call.f2, "ax", @progbits
+       .ent    __call
+__call:
+       la      $25,f2
+       jr      $25
+       nop
+       .end    __call
+
+       # Create a call stub for f3.  We pretend that f3 returns a
+       # floating-point value.
+
+       .section .mips16.call.fp.f3, "ax", @progbits
+       .ent    __call_fp
+__call_fp:
+       la      $25,f3
+       jr      $25
+       nop
+       .end    __call_fp
+
+       # Make sure that f2 and f3 are called from MIPS16 code.
+       .set    mips16
+       .text
+       .global __start
+       .type   __start,@function
+       .ent    __start
+__start:
+       jal     f2
+       nop
+       jal     f3
+       nop
+       .end    __start