This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Missing hunk in MIPS16 PIC support
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: binutils at sourceware dot org
- Date: Sat, 16 Aug 2008 18:39:59 +0100
- Subject: Missing hunk in MIPS16 PIC support
I'd missed a hunk when porting the MIPS16 PIC patch to mainline.
We were supposed to move stub information for indirect symbols
to the target function.
I only noticed this week, when running tests for the non-PIC gcc patch.
As penance, I've added a binutils test to make this more visible.
Tested on mips64-linux-gnu. OK to install?
Richard
bfd/
* 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.
Index: bfd/elfxx-mips.c
===================================================================
--- bfd/elfxx-mips.c 2008-08-16 17:46:46.000000000 +0100
+++ bfd/elfxx-mips.c 2008-08-16 17:54:15.000000000 +0100
@@ -10922,6 +10922,26 @@ _bfd_mips_elf_copy_indirect_symbol (stru
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: ld/testsuite/ld-mips-elf/mips16-pic-4a.s
===================================================================
--- /dev/null 2008-08-16 08:33:17.552097000 +0100
+++ ld/testsuite/ld-mips-elf/mips16-pic-4a.s 2008-08-16 18:13:40.000000000 +0100
@@ -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
Index: ld/testsuite/ld-mips-elf/mips16-pic-4b.s
===================================================================
--- /dev/null 2008-08-16 08:33:17.552097000 +0100
+++ ld/testsuite/ld-mips-elf/mips16-pic-4b.s 2008-08-16 17:59:52.000000000 +0100
@@ -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
Index: ld/testsuite/ld-mips-elf/mips16-pic-4.ver
===================================================================
--- /dev/null 2008-08-16 08:33:17.552097000 +0100
+++ ld/testsuite/ld-mips-elf/mips16-pic-4.ver 2008-08-16 18:05:37.000000000 +0100
@@ -0,0 +1,8 @@
+V1 {
+ global:
+ f1;
+ f2;
+ f3;
+ local:
+ *;
+};
Index: ld/testsuite/ld-mips-elf/mips16-pic-4a.dd
===================================================================
--- /dev/null 2008-08-16 08:33:17.552097000 +0100
+++ ld/testsuite/ld-mips-elf/mips16-pic-4a.dd 2008-08-16 18:15:26.000000000 +0100
@@ -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
Index: ld/testsuite/ld-mips-elf/mips16-pic-4a.nd
===================================================================
--- /dev/null 2008-08-16 08:33:17.552097000 +0100
+++ ld/testsuite/ld-mips-elf/mips16-pic-4a.nd 2008-08-16 18:39:01.000000000 +0100
@@ -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
Index: ld/testsuite/ld-mips-elf/mips16-pic-4a.gd
===================================================================
--- /dev/null 2008-08-16 08:33:17.552097000 +0100
+++ ld/testsuite/ld-mips-elf/mips16-pic-4a.gd 2008-08-16 18:14:37.000000000 +0100
@@ -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
+
Index: ld/testsuite/ld-mips-elf/mips16-pic-4c.s
===================================================================
--- /dev/null 2008-08-16 08:33:17.552097000 +0100
+++ ld/testsuite/ld-mips-elf/mips16-pic-4c.s 2008-08-16 18:21:17.000000000 +0100
@@ -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
Index: ld/testsuite/ld-mips-elf/mips16-pic-4b.dd
===================================================================
--- /dev/null 2008-08-16 08:33:17.552097000 +0100
+++ ld/testsuite/ld-mips-elf/mips16-pic-4b.dd 2008-08-16 18:20:24.000000000 +0100
@@ -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>:
+#...
Index: ld/testsuite/ld-mips-elf/mips-elf.exp
===================================================================
--- ld/testsuite/ld-mips-elf/mips-elf.exp 2008-08-16 18:03:24.000000000 +0100
+++ ld/testsuite/ld-mips-elf/mips-elf.exp 2008-08-16 18:20:45.000000000 +0100
@@ -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] } {