]> oss.titaniummirror.com Git - msp430-binutils.git/blobdiff - bfd/coff-arm.c
Merge commit 'upstream/2.20'
[msp430-binutils.git] / bfd / coff-arm.c
index b9f8c366d0175ba382537c06d43cffd0edbab00c..422c53ea0c2a01358fde2db350769dc7321d97b1 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for ARM COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -939,21 +939,24 @@ coff_arm_link_hash_table_create (bfd * abfd)
   return & ret->root.root;
 }
 
-static void
+static bfd_boolean
 arm_emit_base_file_entry (struct bfd_link_info *info,
                          bfd *output_bfd,
                          asection *input_section,
                          bfd_vma reloc_offset)
 {
-  bfd_vma addr = reloc_offset
-                - input_section->vma
-                + input_section->output_offset
-                  + input_section->output_section->vma;
+  bfd_vma addr = (reloc_offset
+                 - input_section->vma
+                 + input_section->output_offset
+                 + input_section->output_section->vma);
 
   if (coff_data (output_bfd)->pe)
      addr -= pe_data (output_bfd)->pe_opthdr.ImageBase;
-  fwrite (& addr, 1, sizeof (addr), (FILE *) info->base_file);
+  if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) == 1)
+    return TRUE;
 
+  bfd_set_error (bfd_error_system_call);
+  return FALSE;
 }
 \f
 #ifndef ARM_WINCE
@@ -1329,8 +1332,8 @@ coff_arm_relocate_section (bfd *output_bfd,
 
               if (howto->type == ARM_26)
                 {
-                  if (   h->class == C_THUMBSTATFUNC
-                     || h->class == C_THUMBEXTFUNC)
+                  if (   h->symbol_class == C_THUMBSTATFUNC
+                     || h->symbol_class == C_THUMBEXTFUNC)
                    {
                      /* Arm code calling a Thumb function.  */
                      unsigned long int                 tmp;
@@ -1381,10 +1384,10 @@ coff_arm_relocate_section (bfd *output_bfd,
                          bfd_put_32 (output_bfd, h_val | a2t3_func_addr_insn,
                                      s->contents + my_offset + 8);
 
-                          if (info->base_file)
-                            arm_emit_base_file_entry (info, output_bfd, s,
-                                                      my_offset + 8);
-
+                          if (info->base_file
+                             && !arm_emit_base_file_entry (info, output_bfd,
+                                                           s, my_offset + 8))
+                           return FALSE;
                        }
 
                      BFD_ASSERT (my_offset <= globals->arm_glue_size);
@@ -1416,9 +1419,9 @@ coff_arm_relocate_section (bfd *output_bfd,
              /* Note: We used to check for ARM_THUMB9 and ARM_THUMB12.  */
               else if (howto->type == ARM_THUMB23)
                 {
-                  if (   h->class == C_EXT
-                     || h->class == C_STAT
-                     || h->class == C_LABEL)
+                  if (   h->symbol_class == C_EXT
+                     || h->symbol_class == C_STAT
+                     || h->symbol_class == C_LABEL)
                    {
                      /* Thumb code calling an ARM function.  */
                      asection *                         s = 0;
@@ -1486,9 +1489,11 @@ coff_arm_relocate_section (bfd *output_bfd,
                              bfd_put_32 (output_bfd, h_val,
                                          s->contents + my_offset + 16);
 
-                              if (info->base_file)
-                                arm_emit_base_file_entry (info, output_bfd, s,
-                                                         my_offset + 16);
+                              if (info->base_file
+                                 && !arm_emit_base_file_entry (info,
+                                                               output_bfd, s,
+                                                               my_offset + 16))
+                               return FALSE;
                            }
                          else
                            {
@@ -1572,13 +1577,13 @@ coff_arm_relocate_section (bfd *output_bfd,
            }
        }
 
-      if (info->base_file)
-       {
-         /* Emit a reloc if the backend thinks it needs it.  */
-         if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
-            arm_emit_base_file_entry (info, output_bfd, input_section,
-                                     rel->r_vaddr);
-       }
+      /* Emit a reloc if the backend thinks it needs it.  */
+      if (info->base_file
+         && sym
+         && pe_data(output_bfd)->in_reloc_p(output_bfd, howto)
+         && !arm_emit_base_file_entry (info, output_bfd, input_section,
+                                       rel->r_vaddr))
+       return FALSE;
 
       if (done)
        rstat = bfd_reloc_ok;
@@ -1716,8 +1721,8 @@ coff_arm_relocate_section (bfd *output_bfd,
          int patchit = FALSE;
 
          if (h != NULL
-             && (   h->class == C_THUMBSTATFUNC
-                 || h->class == C_THUMBEXTFUNC))
+             && (   h->symbol_class == C_THUMBSTATFUNC
+                 || h->symbol_class == C_THUMBEXTFUNC))
            {
              patchit = TRUE;
            }
@@ -1927,7 +1932,7 @@ record_thumb_to_arm_glue (struct bfd_link_info *        info,
 
   /* If we mark it 'thumb', the disassembler will do a better job.  */
   myh = (struct coff_link_hash_entry *) bh;
-  myh->class = C_THUMBEXTFUNC;
+  myh->symbol_class = C_THUMBEXTFUNC;
 
   free (tmp_name);
 
@@ -2091,7 +2096,7 @@ bfd_arm_process_before_allocation (bfd *                   abfd,
                 the target of the call. If it is a thumb target, we
                 insert glue.  */
 
-             if (h->class == C_THUMBEXTFUNC)
+             if (h->symbol_class == C_THUMBEXTFUNC)
                record_arm_to_thumb_glue (info, h);
              break;
 
@@ -2105,7 +2110,7 @@ bfd_arm_process_before_allocation (bfd *                   abfd,
                 for it.  This is not really a problem, since the link
                 is doomed anyway.  */
 
-             switch (h->class)
+             switch (h->symbol_class)
                {
                case C_EXT:
                case C_STAT:
@@ -2203,7 +2208,7 @@ coff_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
            {
              _bfd_error_handler
                /* xgettext: c-format */
-               (_("ERROR: %B is compiled for APCS-%d, whereas %B is compiled for APCS-%d"),
+               (_("error: %B is compiled for APCS-%d, whereas %B is compiled for APCS-%d"),
                 ibfd, obfd,
                 APCS_26_FLAG (ibfd) ? 26 : 32,
                 APCS_26_FLAG (obfd) ? 26 : 32
@@ -2219,10 +2224,10 @@ coff_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
 
              if (APCS_FLOAT_FLAG (ibfd))
                /* xgettext: c-format */
-               msg = _("ERROR: %B passes floats in float registers, whereas %B passes them in integer registers");
+               msg = _("error: %B passes floats in float registers, whereas %B passes them in integer registers");
              else
                /* xgettext: c-format */
-               msg = _("ERROR: %B passes floats in integer registers, whereas %B passes them in float registers");
+               msg = _("error: %B passes floats in integer registers, whereas %B passes them in float registers");
 
              _bfd_error_handler (msg, ibfd, obfd);
 
@@ -2236,10 +2241,10 @@ coff_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
 
              if (PIC_FLAG (ibfd))
                /* xgettext: c-format */
-               msg = _("ERROR: %B is compiled as position independent code, whereas target %B is absolute position");
+               msg = _("error: %B is compiled as position independent code, whereas target %B is absolute position");
              else
                /* xgettext: c-format */
-               msg = _("ERROR: %B is compiled as absolute position code, whereas target %B is position independent");
+               msg = _("error: %B is compiled as absolute position code, whereas target %B is position independent");
              _bfd_error_handler (msg, ibfd, obfd);
 
              bfd_set_error (bfd_error_wrong_format);
@@ -2523,6 +2528,10 @@ coff_arm_final_link_postscript (bfd * abfd ATTRIBUTE_UNUSED,
   return bfd_arm_update_notes (abfd, ARM_NOTE_SECTION);
 }
 
+#ifndef bfd_pe_print_pdata
+#define bfd_pe_print_pdata     NULL
+#endif
+
 #include "coffcode.h"
 
 #ifndef TARGET_LITTLE_SYM