This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: [PATCH, MIPS] When calculating a relocation using an undefined weak symbol don't check for overflow.
- From: Matthew Fortune <Matthew dot Fortune at imgtec dot com>
- To: Richard Sandiford <rdsandiford at googlemail dot com>, Alan Modra <amodra at gmail dot com>
- Cc: "Tristan Gingold (gingold at adacore dot com)" <gingold at adacore dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>, Andrew Bennett <Andrew dot Bennett at imgtec dot com>
- Date: Thu, 18 Dec 2014 21:34:17 +0000
- Subject: RE: [PATCH, MIPS] When calculating a relocation using an undefined weak symbol don't check for overflow.
- Authentication-results: sourceware.org; auth=none
- References: <0DA23CC379F5F945ACB41CF394B9827720F35D28 at LEMAIL01 dot le dot imgtec dot org> <87fvczuhxz dot fsf at googlemail dot com> <0DA23CC379F5F945ACB41CF394B9827720F3A4EE at LEMAIL01 dot le dot imgtec dot org> <20141204113258 dot GZ20383 at bubble dot grove dot modra dot org>
Alan Modra <amodra@gmail.com> writes:
> On Tue, Dec 02, 2014 at 01:40:03PM +0000, Andrew Bennett wrote:
> > > > bfd/
> > > > * elfxx-mips.c (mips_elf_calculate_relocation): Only check
> for overflow
> > > > on non-weak undefined symbols.
> > > >
> > > > ld/testsuite/
> > > > * ld-mips-elf/mips-elf.exp: Add in undefined weak overflow
> tests for
> > > > o32, n32 and n64.
> > > > * ld-mips-elf/undefweak-overflow.s: New test.
> > > > * ld-mips-elf/undefweak-overflow.d: New test.
> > > > * ld-mips-elf/undefweak-overflow-n64.d: New test.
> > > > * ld-mips-elf/undefweak-overflow-n64.d: New test.
> > >
> > > OK, thanks, and sorry for the slow reply.
> >
> > That's ok. I have now committed the patch.
>
> mipsisa32el-linux +FAIL: undefined weak symbol overflow (n32)
> mipsisa32el-linux +FAIL: undefined weak symbol overflow (n64) tx39-elf
> +FAIL: undefined weak symbol overflow
I've been through and fixed these and tested across a large number
of MIPS target triplets. (I have a follow up for the tx39-elf gnu attr
test failures too)
OK to commit?
Thanks,
Matthew
ld/testsuite/
* ld-mips-elf/mips-elf.exp: Update undefweak-overflow tests.
* ld-mips-elf/undefweak-overflow-n32.d: Remove.
* ld-mips-elf/undefweak-overflow-n64.d: Likewise.
* ld-mips-elf/undefweak-overflow.s: Set mips64r6, noreorder and
add a label to mark the micromips region.
* ld-mips-elf/undefweak-overflow.d: Update expected output.
---
ld/testsuite/ld-mips-elf/mips-elf.exp | 9 +++--
ld/testsuite/ld-mips-elf/undefweak-overflow-n32.d | 23 -------------
ld/testsuite/ld-mips-elf/undefweak-overflow-n64.d | 23 -------------
ld/testsuite/ld-mips-elf/undefweak-overflow.d | 42 +++++++++++++----------
ld/testsuite/ld-mips-elf/undefweak-overflow.s | 27 +++++++++------
5 files changed, 46 insertions(+), 78 deletions(-)
delete mode 100644 ld/testsuite/ld-mips-elf/undefweak-overflow-n32.d
delete mode 100644 ld/testsuite/ld-mips-elf/undefweak-overflow-n64.d
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 21c809f..7b901c6 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -434,11 +434,14 @@ if {$linux_gnu} {
run_dump_test "jaloverflow"
run_dump_test "jaloverflow-2"
-run_dump_test "undefweak-overflow"
+run_dump_test "undefweak-overflow" [list [list as $abi_asflags(o32)] \
+ [list ld $abi_ldflags(o32)]]
if {$has_newabi} {
- run_dump_test "undefweak-overflow-n32"
- run_dump_test "undefweak-overflow-n64"
+ run_dump_test "undefweak-overflow" [list [list as $abi_asflags(n32)] \
+ [list ld $abi_ldflags(n32)]]
+ run_dump_test "undefweak-overflow" [list [list as $abi_asflags(n64)] \
+ [list ld $abi_ldflags(n64)]]
}
if {$has_newabi} {
diff --git a/ld/testsuite/ld-mips-elf/undefweak-overflow-n32.d b/ld/testsuite/ld-mips-elf/undefweak-overflow-n32.d
deleted file mode 100644
index 4d965b8..0000000
--- a/ld/testsuite/ld-mips-elf/undefweak-overflow-n32.d
+++ /dev/null
@@ -1,23 +0,0 @@
-#name: undefined weak symbol overflow (n32)
-#source: undefweak-overflow.s
-#as: -n32 -EB
-#ld: -melf32btsmipn32 -Ttext=0x20000000 -e start
-#objdump: -dr
-#...
-0*20000000: d85fffff.*
-0*20000004: 00000000.*
-0*20000008: f85ffffd.*
-0*2000000c: ec4ffffd.*
-0*20000010: ec5bfffe.*
-0*20000014: cbfffffa.*
-0*20000018: 3c04e000.*
-0*2000001c: 1000fff8.*
-0*20000020: 2484ffe0.*
-0*20000024: 0411fff6.*
-0*20000028: 00000000.*
-0*2000002c: 3c047fd0.*
-0*20000030: 8e670c00.*
-0*20000034: cfe50c00.*
-0*20000038: 9400ffe2.*
-0*2000003c: 0c000c00.*
-#pass
diff --git a/ld/testsuite/ld-mips-elf/undefweak-overflow-n64.d b/ld/testsuite/ld-mips-elf/undefweak-overflow-n64.d
deleted file mode 100644
index e0d9fda..0000000
--- a/ld/testsuite/ld-mips-elf/undefweak-overflow-n64.d
+++ /dev/null
@@ -1,23 +0,0 @@
-#name: undefined weak symbol overflow (n64)
-#source: undefweak-overflow.s
-#as: -64 -EB
-#ld: -melf64btsmip -Ttext=0x20000000 -e start
-#objdump: -dr
-#...
- 0*20000000: d85fffff.*
- 0*20000004: 00000000.*
- 0*20000008: f85ffffd.*
- 0*2000000c: ec4ffffd.*
- 0*20000010: ec5bfffe.*
- 0*20000014: cbfffffa.*
- 0*20000018: 3c04e000.*
- 0*2000001c: 1000fff8.*
- 0*20000020: 2484ffe0.*
- 0*20000024: 0411fff6.*
- 0*20000028: 00000000.*
- 0*2000002c: 3c047fd0.*
- 0*20000030: 8e670c00.*
- 0*20000034: cfe50c00.*
- 0*20000038: 9400ffe2.*
- 0*2000003c: 0c000c00.*
-#pass
diff --git a/ld/testsuite/ld-mips-elf/undefweak-overflow.d b/ld/testsuite/ld-mips-elf/undefweak-overflow.d
index 18b3a90..4dc5814 100644
--- a/ld/testsuite/ld-mips-elf/undefweak-overflow.d
+++ b/ld/testsuite/ld-mips-elf/undefweak-overflow.d
@@ -1,23 +1,27 @@
#name: undefined weak symbol overflow
#source: undefweak-overflow.s
-#as: -32 -EB
-#ld: -melf32btsmip -Ttext=0x20000000 -e start
-#objdump: -dr
+#ld: -Ttext=0x20000000 -e start
+#objdump: -dr --show-raw-insn
#...
-0*20000000: d85fffff.*
-0*20000004: 00000000.*
-0*20000008: f85ffffd.*
-0*2000000c: ec4ffffd.*
-0*20000010: ec5bfffe.*
-0*20000014: cbfffffa.*
-0*20000018: 3c04e000.*
-0*2000001c: 1000fff8.*
-0*20000020: 2484ffe0.*
-0*20000024: 0411fff6.*
-0*20000028: 00000000.*
-0*2000002c: 3c047fd0.*
-0*20000030: 8e670c00.*
-0*20000034: cfe50c00.*
-0*20000038: 9400ffe2.*
-0*2000003c: 0c000c00.*
+0*20000000 <_ftext>:
+ *20000000: d85fffff beqzc v0,20000000 <_ftext>
+ *20000004: 00000000 nop
+ *20000008: f85ffffd bnezc v0,20000000 <_ftext>
+ *2000000c: ec4ffffd lwpc v0,20000000 <_ftext>
+ *20000010: ec5bfffe ldpc v0,20000000 <_ftext>
+ *20000014: cbfffffa bc 20000000 <_ftext>
+ *20000018: ec9ee000 auipc a0,0xe000
+ *2000001c: 2484ffe8 addiu a0,a0,-24
+ *20000020: 1000fff7 b 20000000 <_ftext>
+ *20000024: 00000000 nop
+ *20000028: 0411fff5 bal 20000000 <_ftext>
+ *2000002c: 3c...... lui a0,0x....
+
+0*20000030 <micro>:
+ *20000030: 8e67 beqz a0,20000000 <_ftext>
+ *20000032: 0c00 nop
+ *20000034: cfe5 b 20000000 <_ftext>
+ *20000036: 0c00 nop
+ *20000038: 9400 ffe2 b 20000000 <_ftext>
+ *2000003c: 0c00 nop
#pass
diff --git a/ld/testsuite/ld-mips-elf/undefweak-overflow.s b/ld/testsuite/ld-mips-elf/undefweak-overflow.s
index 525f11b..2cec4b9 100644
--- a/ld/testsuite/ld-mips-elf/undefweak-overflow.s
+++ b/ld/testsuite/ld-mips-elf/undefweak-overflow.s
@@ -1,25 +1,32 @@
# relocs against undefined weak symbols should not be treated as
# overflowing
-
+ .module mips64r6
.globl start
.weak foo
start:
+ .set noreorder
.set mips64r6
beqzc $2, foo
+ nop
bnezc $2, foo
lwpc $2, foo
ldpc $2, foo
bc foo
- lui $4, %pcrel_hi(foo)
- addiu $4, $4, %pcrel_lo(foo)
+ auipc $4, %pcrel_hi(foo)
+ addiu $4, $4, %pcrel_lo(foo+4)
- .set mips32r2
- b foo
- bal foo
- lui $4, %gp_rel(foo)
+ b foo
+ nop
+ bal foo
+ lui $4, %gp_rel(foo)
+ .set mips32r2
.set micromips
- beqz16 $4, foo
- b16 foo
- b foo
+micro:
+ beqz16 $4, foo
+ nop
+ b16 foo
+ nop
+ b foo
+ nop
--
1.9.4