This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH for PR 16720] wrong overflow check in R_MIPS_HI16

Hi all,
  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 for more 
details, and the files to reproduce the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]