Convert generic probe interface to C++ (and perform some cleanups)
[deliverable/binutils-gdb.git] / bfd / pe-mips.c
index 32308a088b17be8e64ee5c7e2fcc3274a812af84..d746a44083666776feb9cb24e2c862178bd52111 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for MIPS PE COFF files.
-   Copyright (C) 1990-2014 Free Software Foundation, Inc.
+   Copyright (C) 1990-2017 Free Software Foundation, Inc.
    Modified from coff-i386.c by DJ Delorie, dj@cygnus.com
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -95,44 +95,44 @@ coff_mips_reloc (bfd *abfd,
 #define DOIT(x) \
   x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + (diff >> howto->rightshift)) & howto->dst_mask))
 
-    if (diff != 0)
-      {
-       reloc_howto_type *howto = reloc_entry->howto;
-       unsigned char *addr = (unsigned char *) data + reloc_entry->address;
+  if (diff != 0)
+    {
+      reloc_howto_type *howto = reloc_entry->howto;
+      unsigned char *addr = (unsigned char *) data + reloc_entry->address;
 
-       switch (howto->size)
+      switch (howto->size)
+       {
+       case 0:
          {
-         case 0:
-           {
-             char x = bfd_get_8 (abfd, addr);
+           char x = bfd_get_8 (abfd, addr);
 
-             DOIT (x);
-             bfd_put_8 (abfd, x, addr);
-           }
-           break;
-
-         case 1:
-           {
-             short x = bfd_get_16 (abfd, addr);
+           DOIT (x);
+           bfd_put_8 (abfd, x, addr);
+         }
+         break;
 
-             DOIT (x);
-             bfd_put_16 (abfd, (bfd_vma) x, addr);
-           }
-           break;
+       case 1:
+         {
+           short x = bfd_get_16 (abfd, addr);
 
-         case 2:
-           {
-             long x = bfd_get_32 (abfd, addr);
+           DOIT (x);
+           bfd_put_16 (abfd, (bfd_vma) x, addr);
+         }
+         break;
 
-             DOIT (x);
-             bfd_put_32 (abfd, (bfd_vma) x, addr);
-           }
-           break;
+       case 2:
+         {
+           long x = bfd_get_32 (abfd, addr);
 
-         default:
-           abort ();
+           DOIT (x);
+           bfd_put_32 (abfd, (bfd_vma) x, addr);
          }
-      }
+         break;
+
+       default:
+         abort ();
+       }
+    }
 
   /* Now let bfd_perform_relocation finish everything up.  */
   return bfd_reloc_continue;
@@ -339,6 +339,8 @@ static reloc_howto_type howto_table[] =
         FALSE),                /* Pcrel_offset. */
 };
 
+#define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0]))
+
 /* Turn a howto into a reloc nunmber.  */
 
 #define SELECT_RELOC(x, howto) { x.r_type = howto->type; }
@@ -347,8 +349,11 @@ static reloc_howto_type howto_table[] =
 /* Customize coffcode.h.  */
 #define MIPS 1
 
-#define RTYPE2HOWTO(cache_ptr, dst) \
-           (cache_ptr)->howto = howto_table + (dst)->r_type;
+#define RTYPE2HOWTO(cache_ptr, dst)                            \
+  ((cache_ptr)->howto =                                                \
+   ((dst)->r_type < NUM_HOWTOS                                 \
+    ? howto_table + (dst)->r_type                              \
+    : NULL))
 
 /* Compute the addend of a reloc.  If the reloc is to a common symbol,
    the object file contains the value of the common symbol.  By the
@@ -370,7 +375,7 @@ static reloc_howto_type howto_table[] =
       coffsym = (obj_symbols (abfd)                            \
                 + (cache_ptr->sym_ptr_ptr - symbols));         \
     else if (ptr)                                              \
-      coffsym = coff_symbol_from (abfd, ptr);                  \
+      coffsym = coff_symbol_from (ptr);                                \
     if (coffsym != NULL                                                \
        && coffsym->native->u.syment.n_scnum == 0)              \
       cache_ptr->addend = - coffsym->native->u.syment.n_value; \
@@ -379,7 +384,8 @@ static reloc_howto_type howto_table[] =
       cache_ptr->addend = - (ptr->section->vma + ptr->value);  \
     else                                                       \
       cache_ptr->addend = 0;                                   \
-    if (ptr && howto_table[reloc.r_type].pc_relative)          \
+    if (ptr && reloc.r_type < NUM_HOWTOS                       \
+       && howto_table[reloc.r_type].pc_relative)               \
       cache_ptr->addend += asect->vma;                         \
   }
 
@@ -509,9 +515,7 @@ coff_mips_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 {
   unsigned int i;
 
-  for (i = 0;
-       i < sizeof (howto_table) / sizeof (howto_table[0]);
-       i++)
+  for (i = 0; i < NUM_HOWTOS; i++)
     if (howto_table[i].name != NULL
        && strcasecmp (howto_table[i].name, r_name) == 0)
       return &howto_table[i];
@@ -599,9 +603,9 @@ coff_pe_mips_relocate_section (bfd *output_bfd,
   struct internal_reloc *rel_end;
   unsigned int i;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     {
-      (*_bfd_error_handler)
+      _bfd_error_handler
        (_("%B: `ld -r' not supported with PE MIPS objects\n"), input_bfd);
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
@@ -657,7 +661,7 @@ coff_pe_mips_relocate_section (bfd *output_bfd,
          then we should ignore the symbol value.  */
       if (howto->pc_relative && howto->pcrel_offset)
        {
-         if (info->relocatable)
+         if (bfd_link_relocatable (info))
            continue;
          if (sym != NULL && sym->n_scnum != 0)
            addend += sym->n_value;
@@ -697,13 +701,10 @@ coff_pe_mips_relocate_section (bfd *output_bfd,
                     + sec->output_offset);
              }
 
-         else if (! info->relocatable)
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                    (info, h->root.root.string, input_bfd, input_section,
-                     rel->r_vaddr - input_section->vma, TRUE)))
-               return FALSE;
-           }
+         else if (! bfd_link_relocatable (info))
+           (*info->callbacks->undefined_symbol)
+             (info, h->root.root.string, input_bfd, input_section,
+              rel->r_vaddr - input_section->vma, TRUE);
        }
 
       src = rel->r_vaddr + input_section->output_section->vma
@@ -714,9 +715,11 @@ coff_pe_mips_relocate_section (bfd *output_bfd,
           mem = pointer to memory we're fixing up
           val = VMA of what we need to refer to.  */
 
-#define UI(x) (*_bfd_error_handler) (_("%B: unimplemented %s\n"), \
-                                    input_bfd, x); \
-             bfd_set_error (bfd_error_bad_value);
+#define UI(x)                                                 \
+      /* xgettext:c-format */                                 \
+       _bfd_error_handler (_("%B: unimplemented %s\n"),       \
+                           input_bfd, x);                     \
+       bfd_set_error (bfd_error_bad_value);
 
       switch (rel->r_type)
        {
@@ -740,7 +743,7 @@ coff_pe_mips_relocate_section (bfd *output_bfd,
          targ = val + (tmp & 0x03ffffff) * 4;
          if ((src & 0xf0000000) != (targ & 0xf0000000))
            {
-             (*_bfd_error_handler) (_("%B: jump too far away\n"), input_bfd);
+             _bfd_error_handler (_("%B: jump too far away\n"), input_bfd);
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
@@ -766,8 +769,8 @@ coff_pe_mips_relocate_section (bfd *output_bfd,
              targ = val + low + ((tmp & 0xffff) << 16);
              break;
            default:
-             (*_bfd_error_handler) (_("%B: bad pair/reflo after refhi\n"),
-                                    input_bfd);
+             _bfd_error_handler (_("%B: bad pair/reflo after refhi\n"),
+                                 input_bfd);
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
            }
@@ -856,7 +859,7 @@ const bfd_target
 #ifdef TARGET_SYM
   TARGET_SYM =
 #else
-  mipslpe_vec =
+  mips_pe_le_vec =
 #endif
 {
 #ifdef TARGET_NAME
This page took 0.027494 seconds and 4 git commands to generate.