From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4230 invoked by alias); 8 Dec 2004 20:27:45 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 4140 invoked from network); 8 Dec 2004 20:27:39 -0000 Received: from unknown (209.128.65.135) by sourceware.org with QMTP; 8 Dec 2004 20:27:39 -0000 Received: (qmail 15169 invoked by uid 10); 8 Dec 2004 20:27:38 -0000 Received: (qmail 11375 invoked by uid 500); 8 Dec 2004 20:27:30 -0000 Message-ID: <20041208202730.11374.qmail@gossamer.airs.com> Date: Wed, 08 Dec 2004 20:27:00 -0000 From: Ian Lance Taylor To: binutils@sourceware.org Subject: Test for overflow in the R_MIPS_26 reloc X-SW-Source: 2004-12/txt/msg00077.txt.bz2 A long time ago I patched the linker to detect overflow when processing the R_MIPS_26 reloc. At some point after that that overflow test was lost. I'm about to check in this patch to restore it. I am also adding a test case to the linker testsuite. Ian bfd/ChangeLog: 2004-12-08 Ian Lance Taylor * elfxx-mips.c (mips_elf_calculate_relocation): Test for R_MIPS_26 overflow. ld/testsuite/ChangeLog: 2004-12-08 Ian Lance Taylor * ld-mips-elf/jaloverflow.d: New test. * ld-mips-elf/jaloverflow.s: New test. * ld-mips-elf/mips-elf.exp: Run it. Index: elfxx-mips.c =================================================================== RCS file: /cvs/src/src/bfd/elfxx-mips.c,v retrieving revision 1.113 diff -p -u -r1.113 elfxx-mips.c --- elfxx-mips.c 16 Nov 2004 09:54:10 -0000 1.113 +++ elfxx-mips.c 8 Dec 2004 20:24:55 -0000 @@ -3350,7 +3350,10 @@ mips_elf_calculate_relocation (bfd *abfd if (local_p) value = ((addend | ((p + 4) & 0xf0000000)) + symbol) >> 2; else - value = (_bfd_mips_elf_sign_extend (addend, 28) + symbol) >> 2; + { + value = (_bfd_mips_elf_sign_extend (addend, 28) + symbol) >> 2; + overflowed_p = (value >> 26) != ((p + 4) >> 28); + } value &= howto->dst_mask; break; Index: ld-mips-elf/jaloverflow.d =================================================================== RCS file: ld-mips-elf/jaloverflow.d diff -N ld-mips-elf/jaloverflow.d --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld-mips-elf/jaloverflow.d 8 Dec 2004 20:24:16 -0000 @@ -0,0 +1,11 @@ +#name: JAL overflow +#source: jaloverflow.s +#as: +#ld: -Ttext=0xffffff0 -e start +#error: .*relocation truncated to fit.* + +# This tests whether we correctly detect overflow in the jal +# instruction. jal is a bit weird since the upper four bits of the +# destination address are taken from the source address. So overflow +# occurs if the source and destination address do not have the same +# most significant four bits. Index: ld-mips-elf/jaloverflow.s =================================================================== RCS file: ld-mips-elf/jaloverflow.s diff -N ld-mips-elf/jaloverflow.s --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ld-mips-elf/jaloverflow.s 8 Dec 2004 20:24:16 -0000 @@ -0,0 +1,12 @@ +# This file gets linked to start at 0xffffff0, so the call is an overflow. + .text + .global start + .set noreorder +start: + nop + nop + nop + nop + jal start + nop + .type start, @function Index: ld-mips-elf/mips-elf.exp =================================================================== RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/mips-elf.exp,v retrieving revision 1.19 diff -u -r1.19 mips-elf.exp --- ld-mips-elf/mips-elf.exp 16 Nov 2004 10:16:30 -0000 1.19 +++ ld-mips-elf/mips-elf.exp 8 Dec 2004 20:24:16 -0000 @@ -79,3 +79,5 @@ run_dump_test "eh-frame1-n32" run_dump_test "eh-frame1-n64" } + +run_dump_test "jaloverflow"