This is the mail archive of the
mailing list for the binutils project.
[PATCH for PR 16720] wrong overflow check in R_MIPS_HI16
- From: ma dot jiang at zte dot com dot cn
- To: binutils at sourceware dot org
- Date: Mon, 28 Nov 2016 15:39:23 +0800
- Subject: [PATCH for PR 16720] wrong overflow check in R_MIPS_HI16
- Authentication-results: sourceware.org; auth=none
There are a wrong overflow check for R_MIPS_HI16 in gnu-ld. When your "
addend + gp - p" is a negative number, you could get the error
"relocation truncated to fit: R_MIPS_HI16 against `_gp_disp'". This is
*NOT* right, as the mips abi said that R_MIPS_HI16 need no overflow
checks. Moreover, Only the o32 abi support R_MIPS_HI16 for _gp_disp, per
the mips abi. R_MIPS_HI16 should never get overflowed, because under o32
abi, the address width is 32.
So, I think we should just get rid of the overflow check for R_MIPS_HI16
,as the value should always be OK. Here is the patch for trunk.
--- bfd/elfxx-mips.c.orig 2016-11-28 23:09:23.343671301
+++ bfd/elfxx-mips.c 2016-11-28 23:23:49.452670956 +0800
@@ -5875,7 +5875,6 @@ mips_elf_calculate_relocation (bfd *abfd
value = mips_elf_high (addend + gp - p - 1);
value = mips_elf_high (addend + gp - p);
- overflowed_p = mips_elf_overflow_p (value, 16);
See https://sourceware.org/bugzilla/show_bug.cgi?id=16720 for more
details, and the files to reproduce the bug.