Fix partial REL relocs.
authorNick Clifton <nickc@redhat.com>
Thu, 19 Aug 1999 10:12:28 +0000 (10:12 +0000)
committerNick Clifton <nickc@redhat.com>
Thu, 19 Aug 1999 10:12:28 +0000 (10:12 +0000)
bfd/ChangeLog
bfd/elf32-arm.h

index 0c5f4577fe7b2fcbb84d30ff160acc64aaf56497..8fde0966ddc503aadde5706cb7f550bb82f3cc8e 100644 (file)
@@ -1,3 +1,10 @@
+1999-08-19  Nick Clifton  <nickc@cygnus.com>
+
+       * elf32-arm.h (arm_add_to_rel): New function.  Add a value to
+       a REL style reloc.
+       (elf32_arm_relocate_section): Use arm_add_to_rel to increment
+       REL relocs when performing a partial relocation.
+
 1999-08-18  Donn Terry  <donn@interix.com>
 
        * cofflink.c: Move definitions of N_TMASK, et. al., out of
index da7217aae68a6cfea8a65ec93f034907d458c597..0dc397bd9dca153b1339d49d832dfae1164a9595 100644 (file)
@@ -1581,6 +1581,45 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd,
     }
 }
 
+#ifdef USE_REL
+/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS.  */
+static void
+arm_add_to_rel (abfd, address, howto, increment)
+     bfd *              abfd;
+     bfd_vma            address;
+     reloc_howto_type * howto;
+     bfd_signed_vma     increment;
+{
+  bfd_vma        contents;
+  bfd_signed_vma addend;
+
+  contents = bfd_get_32 (abfd, address);
+
+  /* Get the (signed) value from the instruction.  */
+  addend = contents & howto->src_mask;
+  if (addend & ((howto->src_mask + 1) >> 1))
+    {
+      bfd_signed_vma mask;
+      
+      mask = -1;
+      mask &= ~ howto->src_mask;
+      addend |= mask;
+    }
+
+  /* Add in the increment, (which is a byte value).  */
+  addend <<= howto->size;
+  addend +=  increment;
+      
+  /* Should we check for overflow here ?  */
+
+  /* Drop any undesired bits.  */
+  addend >>= howto->rightshift;
+  
+  contents = (contents & ~ howto->dst_mask) | (addend & howto->dst_mask);
+  
+  bfd_put_32 (abfd, contents, address);
+}
+#endif /* USE_REL */
 
 /* Relocate an ARM ELF section.  */
 static boolean
@@ -1641,18 +1680,8 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
                {
                  sec = local_sections[r_symndx];
 #ifdef USE_REL
-                 {
-                   bfd_vma val;
-                   bfd_vma insn;
-
-                   insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
-                   val = insn + ((sec->output_offset + sym->st_value)
-                                 >> howto->rightshift);
-                   val &= howto->dst_mask;
-                   val |= insn & ~(howto->dst_mask);
-
-                   bfd_put_32 (input_bfd, val, contents + rel->r_offset);
-                 }
+                 arm_add_to_rel (input_bfd, contents + rel->r_offset,
+                                 howto, sec->output_offset + sym->st_value);
 #else
                  rel->r_addend += (sec->output_offset + sym->st_value)
                    >> howto->rightshift;
This page took 0.033095 seconds and 4 git commands to generate.