aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorChung-Lin Tang <cltang@codesourcery.com>2011-12-13 06:22:01 +0000
committerChung-Lin Tang <cltang@codesourcery.com>2011-12-13 06:22:01 +0000
commit888b9c016b45d1f3d69a7cdbf1d03b8ad1bd5ba7 (patch)
treeaaad9799bfc8853280fc60018cae296da9aa169f /bfd
parent2011-12-13 Yao Qi <yao@codesourcery.com> (diff)
downloadbinutils-gdb-888b9c016b45d1f3d69a7cdbf1d03b8ad1bd5ba7.tar.gz
binutils-gdb-888b9c016b45d1f3d69a7cdbf1d03b8ad1bd5ba7.tar.bz2
binutils-gdb-888b9c016b45d1f3d69a7cdbf1d03b8ad1bd5ba7.zip
2011-12-13 Chung-Lin Tang <cltang@codesourcery.com>
* elfxx-mips.c (mips_elf_calculate_relocation): Correct R_MIPS16_HI16/R_MIPS16_LO16 handling of two cleared lower bits, update comments.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elfxx-mips.c9
2 files changed, 11 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3f1dc2540fa..f6f8300f6f4 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-13 Chung-Lin Tang <cltang@codesourcery.com>
+
+ * elfxx-mips.c (mips_elf_calculate_relocation): Correct
+ R_MIPS16_HI16/R_MIPS16_LO16 handling of two cleared lower bits,
+ update comments.
+
2011-12-12 Iain Sandoe <iains@gcc.gnu.org>
* mach-o.c (bfd_mach_o_read_section_32): Null-terminate sectname.
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 4e6d9b2bced..f4935173fe1 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -5531,10 +5531,11 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
12: addu $v0,$v1
14: move $gp,$v0
So the offsets of hi and lo relocs are the same, but the
- $pc is four higher than $t9 would be, so reduce
- both reloc addends by 4. */
+ base $pc is that used by the ADDIUPC instruction at $t9 + 4.
+ ADDIUPC clears the low two bits of the instruction address,
+ so the base is ($t9 + 4) & ~3. */
if (r_type == R_MIPS16_HI16)
- value = mips_elf_high (addend + gp - p - 4);
+ value = mips_elf_high (addend + gp - ((p + 4) & ~(bfd_vma) 0x3));
/* The microMIPS .cpload sequence uses the same assembly
instructions as the traditional psABI version, but the
incoming $t9 has the low bit set. */
@@ -5557,7 +5558,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
/* See the comment for R_MIPS16_HI16 above for the reason
for this conditional. */
if (r_type == R_MIPS16_LO16)
- value = addend + gp - p;
+ value = addend + gp - (p & ~(bfd_vma) 0x3);
else if (r_type == R_MICROMIPS_LO16
|| r_type == R_MICROMIPS_HI0_LO16)
value = addend + gp - p + 3;