This is the mail archive of the binutils@sources.redhat.com 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]

Patch for R_ARM_THM_PC22 relocs



Hi,

The following patch fixes the adjustment of the addendum for
R_ARM_THM_PC22 relocations when producing relocatable output.

Regards,
-velco

2000-09-28  Momchil Velikov  <velco@fadata.bg>

	* elf32-arm.h (arm_add_to_rel): Correctly adjust the addendum for
	R_ARM_THM_PC22 relocations.



--- bfd/elf32-arm.h.orig	Thu Sep 28 21:03:13 2000
+++ bfd/elf32-arm.h	Thu Sep 28 21:03:44 2000
@@ -1642,9 +1642,29 @@
      reloc_howto_type * howto;
      bfd_signed_vma     increment;
 {
-  bfd_vma        contents;
   bfd_signed_vma addend;
 
+  if (howto->type == R_ARM_THM_PC22)
+    {
+      short upper, lower;
+      upper = bfd_get_16 (abfd, address) & 0x7ff;
+      lower = bfd_get_16 (abfd, address + 2) & 0x7ff;
+      upper = (upper ^ 0x400) - 0x400; /* Sign extend.  */
+
+      addend = (upper << 12) | (lower << 1);
+      addend += increment;
+      addend >>= 1;
+
+      upper = (upper & 0xf800) | ((addend >> 11) & 0x7ff);
+      lower = (lower & 0xf800) | (addend & 0x7ff);
+      
+      bfd_put_16 (abfd, upper, address);
+      bfd_put_16 (abfd, lower, address + 2);
+    }
+  else
+    {
+      bfd_vma        contents;
+
   contents = bfd_get_32 (abfd, address);
 
   /* Get the (signed) value from the instruction.  */
@@ -1661,7 +1681,6 @@
   /* Add in the increment, (which is a byte value).  */
   switch (howto->type)
     {
-    case R_ARM_THM_PC22:
     default:
       addend += increment;
       break;
@@ -1680,6 +1699,7 @@
   contents = (contents & ~ howto->dst_mask) | (addend & howto->dst_mask);
   
   bfd_put_32 (abfd, contents, address);
+    }
 }
 #endif /* USE_REL */
 

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