2004-05-28 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / bfd / coff-arm.c
index 1d605678c143edbaf84a8a5abaf4bee6b295fb7f..e51d07d583c570036f7d85601313e93e06801144 100644 (file)
@@ -4,21 +4,21 @@
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
-This file is part of BFD, the Binary File Descriptor library.
+   This file is part of BFD, the Binary File Descriptor library.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
@@ -252,11 +252,11 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
 #undef  ARM_THUMB12
 #undef  ARM_26D
 
+#define ARM_26D      0
 #define ARM_32       1
 #define ARM_RVA32    2
 #define ARM_26      3
 #define ARM_THUMB12  4
-#define ARM_26D      5
 #define ARM_SECTION  14
 #define ARM_SECREL   15
 #endif
@@ -264,7 +264,19 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
 static reloc_howto_type aoutarm_std_reloc_howto[] =
   {
 #ifdef ARM_WINCE
-    EMPTY_HOWTO (-1),
+    HOWTO (ARM_26D,
+          2,
+          2,
+          24,
+          TRUE,
+          0,
+          complain_overflow_dont,
+          aoutarm_fix_pcrel_26_done,
+          "ARM_26D",
+          FALSE,
+          0x00ffffff,
+          0x0,
+          PCRELOFFSET),
     HOWTO (ARM_32,
           0,
           2,
@@ -274,7 +286,7 @@ static reloc_howto_type aoutarm_std_reloc_howto[] =
           complain_overflow_bitfield,
           coff_arm_reloc,
           "ARM_32",
-          TRUE,
+          FALSE,
           0xffffffff,
           0xffffffff,
           PCRELOFFSET),
@@ -287,7 +299,7 @@ static reloc_howto_type aoutarm_std_reloc_howto[] =
           complain_overflow_bitfield,
           coff_arm_reloc,
           "ARM_RVA32",
-          TRUE,
+          FALSE,
           0xffffffff,
           0xffffffff,
           PCRELOFFSET),
@@ -317,19 +329,7 @@ static reloc_howto_type aoutarm_std_reloc_howto[] =
           0x000007ff,
           0x000007ff,
           PCRELOFFSET),
-    HOWTO (ARM_26D,
-          2,
-          2,
-          24,
-          FALSE,
-          0,
-          complain_overflow_dont,
-          aoutarm_fix_pcrel_26_done,
-          "ARM_26D",
-          TRUE,
-          0x00ffffff,
-          0x0,
-          FALSE),
+    EMPTY_HOWTO (-1),
     EMPTY_HOWTO (-1),
     EMPTY_HOWTO (-1),
     EMPTY_HOWTO (-1),
@@ -346,8 +346,8 @@ static reloc_howto_type aoutarm_std_reloc_howto[] =
           0,
           complain_overflow_bitfield,
           coff_arm_reloc,
-          "ARM_16",
-          TRUE,
+          "ARM_SECTION",
+          FALSE,
           0x0000ffff,
           0x0000ffff,
           PCRELOFFSET),
@@ -359,8 +359,8 @@ static reloc_howto_type aoutarm_std_reloc_howto[] =
           0,
           complain_overflow_bitfield,
           coff_arm_reloc,
-          "ARM_32",
-          TRUE,
+          "ARM_SECREL",
+          FALSE,
           0xffffffff,
           0xffffffff,
           PCRELOFFSET),
@@ -1248,9 +1248,10 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
 
       /* The relocation_section function will skip pcrel_offset relocs
          when doing a relocatable link.  However, we want to convert
-         ARM26 to ARM26D relocs if possible.  We return a fake howto in
+         ARM_26 to ARM_26D relocs if possible.  We return a fake howto in
          this case without pcrel_offset set, and adjust the addend to
-         compensate.  */
+         compensate.  'partial_inplace' is also set, since we want 'done'
+         relocations to be reflected in section's data.  */
       if (rel->r_type == ARM_26
           && h != NULL
           && info->relocatable
@@ -1269,12 +1270,17 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
               complain_overflow_signed,
               aoutarm_fix_pcrel_26 ,
               "ARM_26",
-              FALSE,
+              TRUE,
               0x00ffffff,
               0x00ffffff,
               FALSE);
 
           addend -= rel->r_vaddr - input_section->vma;
+#ifdef ARM_WINCE
+          /* FIXME: I don't know why, but the hack is necessary for correct
+                    generation of bl's instruction offset. */
+          addend -= 8;
+#endif
           howto = &fake_arm26_reloc;
         }
 
@@ -1734,10 +1740,13 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section,
 #endif
       else
 #endif /* THUMBEXTENSION */
-        rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
-                                          contents,
-                                          rel->r_vaddr - input_section->vma,
-                                          val, addend);
+        if (info->relocatable && ! howto->partial_inplace)
+            rstat = bfd_reloc_ok;
+        else
+         rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
+                                           contents,
+                                           rel->r_vaddr - input_section->vma,
+                                           val, addend);
 #if 1 /* THUMBEXTENSION */
       /* FIXME:
         Is this the best way to fix up thumb addresses? krk@cygnus.com
@@ -2198,8 +2207,8 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code)
 #define coff_bfd_copy_private_bfd_data          coff_arm_copy_private_bfd_data
 #define coff_bfd_link_hash_table_create                coff_arm_link_hash_table_create
 
-/* When doing a relocatable link, we want to convert ARM26 relocs
-   into ARM26D relocs.  */
+/* When doing a relocatable link, we want to convert ARM_26 relocs
+   into ARM_26D relocs.  */
 
 static bfd_boolean
 coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
@@ -2210,7 +2219,7 @@ coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
      struct internal_reloc *irel;
      bfd_boolean *adjustedp;
 {
-  if (irel->r_type == 3)
+  if (irel->r_type == ARM_26)
     {
       struct coff_link_hash_entry *h;
 
@@ -2219,7 +2228,7 @@ coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
          && (h->root.type == bfd_link_hash_defined
              || h->root.type == bfd_link_hash_defweak)
          && h->root.u.def.section->output_section == sec->output_section)
-       irel->r_type = 7;
+       irel->r_type = ARM_26D;
     }
   *adjustedp = FALSE;
   return TRUE;
This page took 0.027239 seconds and 4 git commands to generate.