* arm.cc (Arm_relocate_functions::thm_jump6): New function.
authorIan Lance Taylor <ian@airs.com>
Fri, 15 Jan 2010 15:41:42 +0000 (15:41 +0000)
committerIan Lance Taylor <ian@airs.com>
Fri, 15 Jan 2010 15:41:42 +0000 (15:41 +0000)
(Arm_relocate_functions::thm_jump8): New function.
(Arm_relocate_functions::thm_jump11): New function.
(Target_arm::Scan::local): Handle R_ARM_THM_JUMP6, R_ARM_THM_JUMP8,
R_ARM_THM_JUMP11.
(Target_arm::Scan::global): Likewise.
(Target_arm::Relocate::relocate): Likewise.
(Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
Likewise.

gold/ChangeLog
gold/arm.cc

index e006871..0c6e1a0 100644 (file)
@@ -1,3 +1,15 @@
+2010-01-15  Viktor Kutuzov  <vkutuzov@accesssoftek.com>
+
+       * arm.cc (Arm_relocate_functions::thm_jump6): New function.
+       (Arm_relocate_functions::thm_jump8): New function.
+       (Arm_relocate_functions::thm_jump11): New function.
+       (Target_arm::Scan::local): Handle R_ARM_THM_JUMP6, R_ARM_THM_JUMP8,
+       R_ARM_THM_JUMP11.
+       (Target_arm::Scan::global): Likewise.
+       (Target_arm::Relocate::relocate): Likewise.
+       (Target_arm::Relocatable_size_for_reloc::get_size_for_reloc):
+       Likewise.
+
 2010-01-14  Doug Kwan  <dougkwan@google.com>
 
        * arm.cc (map, utility): Include headers.
index cbac4a5..1ab909e 100644 (file)
@@ -122,6 +122,9 @@ const int32_t THM2_MAX_BWD_BRANCH_OFFSET = (-(1 << 24) + 4);
 // R_ARM_MOVT_PREL
 // R_ARM_THM_MOVW_PREL_NC
 // R_ARM_THM_MOVT_PREL
+// R_ARM_THM_JUMP6
+// R_ARM_THM_JUMP8
+// R_ARM_THM_JUMP11
 // 
 // TODOs:
 // - Support more relocation types as needed. 
@@ -2410,6 +2413,66 @@ class Arm_relocate_functions : public Relocate_functions<32, big_endian>
                               is_weakly_undefined_without_plt);
   }
 
+  // R_ARM_THM_JUMP6: S + A – P
+  static inline typename This::Status
+  thm_jump6(unsigned char *view,
+           const Sized_relobj<32, big_endian>* object,
+           const Symbol_value<32>* psymval,
+           Arm_address address)
+  {
+    typedef typename elfcpp::Swap<16, big_endian>::Valtype Valtype;
+    typedef typename elfcpp::Swap<16, big_endian>::Valtype Reltype;
+    Valtype* wv = reinterpret_cast<Valtype*>(view);
+    Valtype val = elfcpp::Swap<16, big_endian>::readval(wv);
+    // bit[9]:bit[7:3]:’0’ (mask: 0x02f8)
+    Reltype addend = (((val & 0x0200) >> 3) | ((val & 0x00f8) >> 2));
+    Reltype x = (psymval->value(object, addend) - address);
+    val = (val & 0xfd07) | ((x  & 0x0040) << 3) | ((val & 0x003e) << 2);
+    elfcpp::Swap<16, big_endian>::writeval(wv, val);
+    // CZB does only forward jumps.
+    return ((x > 0x007e)
+           ? This::STATUS_OVERFLOW
+           : This::STATUS_OKAY);
+  }
+
+  // R_ARM_THM_JUMP8: S + A – P
+  static inline typename This::Status
+  thm_jump8(unsigned char *view,
+           const Sized_relobj<32, big_endian>* object,
+           const Symbol_value<32>* psymval,
+           Arm_address address)
+  {
+    typedef typename elfcpp::Swap<16, big_endian>::Valtype Valtype;
+    typedef typename elfcpp::Swap<16, big_endian>::Valtype Reltype;
+    Valtype* wv = reinterpret_cast<Valtype*>(view);
+    Valtype val = elfcpp::Swap<16, big_endian>::readval(wv);
+    Reltype addend = utils::sign_extend<8>((val & 0x00ff) << 1);
+    Reltype x = (psymval->value(object, addend) - address);
+    elfcpp::Swap<16, big_endian>::writeval(wv, (val & 0xff00) | ((x & 0x01fe) >> 1));
+    return (utils::has_overflow<8>(x)
+           ? This::STATUS_OVERFLOW
+           : This::STATUS_OKAY);
+  }
+
+  // R_ARM_THM_JUMP11: S + A – P
+  static inline typename This::Status
+  thm_jump11(unsigned char *view,
+           const Sized_relobj<32, big_endian>* object,
+           const Symbol_value<32>* psymval,
+           Arm_address address)
+  {
+    typedef typename elfcpp::Swap<16, big_endian>::Valtype Valtype;
+    typedef typename elfcpp::Swap<16, big_endian>::Valtype Reltype;
+    Valtype* wv = reinterpret_cast<Valtype*>(view);
+    Valtype val = elfcpp::Swap<16, big_endian>::readval(wv);
+    Reltype addend = utils::sign_extend<11>((val & 0x07ff) << 1);
+    Reltype x = (psymval->value(object, addend) - address);
+    elfcpp::Swap<16, big_endian>::writeval(wv, (val & 0xf800) | ((x & 0x0ffe) >> 1));
+    return (utils::has_overflow<11>(x)
+           ? This::STATUS_OVERFLOW
+           : This::STATUS_OKAY);
+  }
+
   // R_ARM_BASE_PREL: B(S) + A - P
   static inline typename This::Status
   base_prel(unsigned char* view,
@@ -5138,6 +5201,9 @@ Target_arm<big_endian>::Scan::local(Symbol_table* symtab,
     case elfcpp::R_ARM_MOVT_PREL:
     case elfcpp::R_ARM_THM_MOVW_PREL_NC:
     case elfcpp::R_ARM_THM_MOVT_PREL:
+    case elfcpp::R_ARM_THM_JUMP6:
+    case elfcpp::R_ARM_THM_JUMP8:
+    case elfcpp::R_ARM_THM_JUMP11:
       break;
 
     case elfcpp::R_ARM_GOTOFF32:
@@ -5266,6 +5332,9 @@ Target_arm<big_endian>::Scan::global(Symbol_table* symtab,
     case elfcpp::R_ARM_MOVT_PREL:
     case elfcpp::R_ARM_THM_MOVW_PREL_NC:
     case elfcpp::R_ARM_THM_MOVT_PREL:
+    case elfcpp::R_ARM_THM_JUMP6:
+    case elfcpp::R_ARM_THM_JUMP8:
+    case elfcpp::R_ARM_THM_JUMP11:
       break;
 
     case elfcpp::R_ARM_THM_ABS5:
@@ -6001,6 +6070,21 @@ Target_arm<big_endian>::Relocate::relocate(
                                           thumb_bit);
       break;
 
+    case elfcpp::R_ARM_THM_JUMP6:
+      reloc_status =
+       Arm_relocate_functions::thm_jump6(view, object, psymval, address);
+      break;
+
+    case elfcpp::R_ARM_THM_JUMP8:
+      reloc_status =
+       Arm_relocate_functions::thm_jump8(view, object, psymval, address);
+      break;
+
+    case elfcpp::R_ARM_THM_JUMP11:
+      reloc_status =
+       Arm_relocate_functions::thm_jump11(view, object, psymval, address);
+      break;
+
     case elfcpp::R_ARM_PREL31:
       reloc_status = Arm_relocate_functions::prel31(view, object, psymval,
                                                    address, thumb_bit);
@@ -6127,6 +6211,9 @@ Target_arm<big_endian>::Relocatable_size_for_reloc::get_size_for_reloc(
 
     case elfcpp::R_ARM_ABS16:
     case elfcpp::R_ARM_THM_ABS5:
+    case elfcpp::R_ARM_THM_JUMP6:
+    case elfcpp::R_ARM_THM_JUMP8:
+    case elfcpp::R_ARM_THM_JUMP11:
       return 2;
 
     case elfcpp::R_ARM_ABS32: