This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
MIPS R_MIPS_HI16 relocs
- From: Andrew Haley <aph at cambridge dot redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 19 Dec 2001 18:46:34 +0000 (GMT)
- Subject: MIPS R_MIPS_HI16 relocs
I'm having a problem where R_MIPS_HI16 relocs to _gp_disp are
overflowing.
This seems to happen whenever the value of gp is less than the value
of the relocation, thus meaning that R_MIPS_HI16 is negative.
Given that a R_MIPS_HI16 reloc is the high 16 bits of a 32-bit offset,
I cannot see that there is any need to forbid negative values. But
that is what we do, for some reason.
I'm not sure that is is worth checking at all, since I don't think
that the calculated value can ever exceed 32 bits. However, I've left
in a sanity check.
Without this patch, R_MIPS_HI16 gp relocs can only be 15 bits long.
OK?
Andrew.
2001-12-19 Andrew Haley <aph@cambridge.redhat.com>
* elf32-mips.c (mips_elf_calculate_relocation): Allow -ve values
in R_MIPS_HI16 relocs.
Index: elf32-mips.c
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/elf32-mips.c,v
retrieving revision 1.205.12.1
diff -u -r1.205.12.1 elf32-mips.c
--- elf32-mips.c 2001/11/15 13:57:18 1.205.12.1
+++ elf32-mips.c 2001/12/19 18:21:21
@@ -6410,8 +6410,9 @@
}
else
{
- value = mips_elf_high (addend + gp - p);
- overflowed_p = mips_elf_overflow_p (value, 16);
+ value = addend + gp - p;
+ overflowed_p = mips_elf_overflow_p (value, 32);
+ value = mips_elf_high (value);
}
break;