AArch64: Have -D override mapping symbol as documented.
[deliverable/binutils-gdb.git] / bfd / coff-mips.c
index 298671c11227f0b34ebf8e5cfd9eecc98682e10a..3ada9ceb0f99a0806d85f70b27f66cc599c78b5e 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for MIPS Extended-Coff files.
-   Copyright (C) 1990-2014 Free Software Foundation, Inc.
+   Copyright (C) 1990-2019 Free Software Foundation, Inc.
    Original version by Per Bothner.
    Full support added by Ian Lance Taylor, ian@cygnus.com.
 
@@ -131,7 +131,7 @@ static reloc_howto_type mips_howto_table[] =
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
-                               /* This needs complex overflow
+                               /* This needs complex overflow
                                   detection, because the upper four
                                   bits must match the PC.  */
         mips_generic_reloc,    /* special_function */
@@ -504,6 +504,12 @@ mips_reflo_reloc (bfd *abfd ATTRIBUTE_UNUSED,
          unsigned long vallo;
          struct mips_hi *next;
 
+         if (! bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
+                                          input_section,
+                                          reloc_entry->address
+                                          * bfd_octets_per_byte (abfd)))
+           return bfd_reloc_outofrange;
+
          /* Do the REFHI relocation.  Note that we actually don't
             need to know anything about the REFLO itself, except
             where to find the low 16 bits of the addend needed by the
@@ -886,7 +892,7 @@ mips_relocate_section (bfd *output_bfd,
          struct external_reloc *lo_ext_rel;
 
          /* As a GNU extension, permit an arbitrary number of REFHI
-             relocs before the REFLO reloc.  This permits gcc to emit
+            relocs before the REFLO reloc.  This permits gcc to emit
             the HI and LO relocs itself.  */
          for (lo_ext_rel = ext_rel + 1;
               lo_ext_rel < ext_rel_end;
@@ -940,11 +946,10 @@ mips_relocate_section (bfd *output_bfd,
        {
          if (gp_undefined)
            {
-             if (! ((*info->callbacks->reloc_dangerous)
-                    (info, _("GP relative relocation used when GP not defined"),
-                     input_bfd, input_section,
-                     int_rel.r_vaddr - input_section->vma)))
-               return FALSE;
+             (*info->callbacks->reloc_dangerous)
+               (info, _("GP relative relocation used when GP not defined"),
+                input_bfd, input_section,
+                int_rel.r_vaddr - input_section->vma);
              /* Only give the error once per link.  */
              gp = 4;
              _bfd_set_gp_value (output_bfd, gp);
@@ -960,7 +965,7 @@ mips_relocate_section (bfd *output_bfd,
                 and the GP value of OUTPUT_BFD (which is in GP).  */
              addend = ecoff_data (input_bfd)->gp - gp;
            }
-         else if (! info->relocatable
+         else if (! bfd_link_relocatable (info)
                   || h->root.type == bfd_link_hash_defined
                   || h->root.type == bfd_link_hash_defweak)
            {
@@ -986,7 +991,7 @@ mips_relocate_section (bfd *output_bfd,
            }
        }
 
-      if (info->relocatable)
+      if (bfd_link_relocatable (info))
        {
          /* We are generating relocatable output, and must convert
             the existing reloc.  */
@@ -1075,11 +1080,9 @@ mips_relocate_section (bfd *output_bfd,
                  if (int_rel.r_symndx == -1)
                    {
                      /* This symbol is not being written out.  */
-                     if (! ((*info->callbacks->unattached_reloc)
-                            (info, h->root.root.string, input_bfd,
-                             input_section,
-                             int_rel.r_vaddr - input_section->vma)))
-                       return FALSE;
+                     (*info->callbacks->unattached_reloc)
+                       (info, h->root.root.string, input_bfd, input_section,
+                        int_rel.r_vaddr - input_section->vma);
                      int_rel.r_symndx = 0;
                    }
                  relocation = 0;
@@ -1151,11 +1154,9 @@ mips_relocate_section (bfd *output_bfd,
                }
              else
                {
-                 if (! ((*info->callbacks->undefined_symbol)
-                        (info, h->root.root.string, input_bfd,
-                         input_section,
-                         int_rel.r_vaddr - input_section->vma, TRUE)))
-                   return FALSE;
+                 (*info->callbacks->undefined_symbol)
+                   (info, h->root.root.string, input_bfd, input_section,
+                    int_rel.r_vaddr - input_section->vma, TRUE);
                  relocation = 0;
                }
            }
@@ -1223,11 +1224,10 @@ mips_relocate_section (bfd *output_bfd,
                  name = NULL;
                else
                  name = bfd_section_name (input_bfd, s);
-               if (! ((*info->callbacks->reloc_overflow)
-                      (info, (h ? &h->root : NULL), name, howto->name,
-                       (bfd_vma) 0, input_bfd, input_section,
-                       int_rel.r_vaddr - input_section->vma)))
-                 return FALSE;
+               (*info->callbacks->reloc_overflow)
+                 (info, (h ? &h->root : NULL), name, howto->name,
+                  (bfd_vma) 0, input_bfd, input_section,
+                  int_rel.r_vaddr - input_section->vma);
              }
              break;
            }
@@ -1236,6 +1236,67 @@ mips_relocate_section (bfd *output_bfd,
 
   return TRUE;
 }
+
+static void
+mips_ecoff_swap_coff_aux_in (bfd *abfd ATTRIBUTE_UNUSED,
+                            void *ext1 ATTRIBUTE_UNUSED,
+                            int type ATTRIBUTE_UNUSED,
+                            int in_class ATTRIBUTE_UNUSED,
+                            int indx ATTRIBUTE_UNUSED,
+                            int numaux ATTRIBUTE_UNUSED,
+                            void *in1 ATTRIBUTE_UNUSED)
+{
+}
+
+static void
+mips_ecoff_swap_coff_sym_in (bfd *abfd ATTRIBUTE_UNUSED,
+                            void *ext1 ATTRIBUTE_UNUSED,
+                            void *in1 ATTRIBUTE_UNUSED)
+{
+}
+
+static void
+mips_ecoff_swap_coff_lineno_in (bfd *abfd ATTRIBUTE_UNUSED,
+                               void *ext1 ATTRIBUTE_UNUSED,
+                               void *in1 ATTRIBUTE_UNUSED)
+{
+}
+
+static unsigned int
+mips_ecoff_swap_coff_aux_out (bfd *abfd ATTRIBUTE_UNUSED,
+                             void *inp ATTRIBUTE_UNUSED,
+                             int type ATTRIBUTE_UNUSED,
+                             int in_class ATTRIBUTE_UNUSED,
+                             int indx ATTRIBUTE_UNUSED,
+                             int numaux ATTRIBUTE_UNUSED,
+                             void *extp ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+static unsigned int
+mips_ecoff_swap_coff_sym_out (bfd *abfd ATTRIBUTE_UNUSED,
+                             void *inp ATTRIBUTE_UNUSED,
+                             void *extp ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+static unsigned int
+mips_ecoff_swap_coff_lineno_out (bfd *abfd ATTRIBUTE_UNUSED,
+                                void *inp ATTRIBUTE_UNUSED,
+                                void *extp ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+static unsigned int
+mips_ecoff_swap_coff_reloc_out (bfd *abfd ATTRIBUTE_UNUSED,
+                               void *inp ATTRIBUTE_UNUSED,
+                               void *extp ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
 \f
 /* This is the ECOFF backend structure.  The backend field of the
    target vector points to this.  */
@@ -1244,13 +1305,10 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
 {
   /* COFF backend structure.  */
   {
-    (void (*) (bfd *,void *,int,int,int,int,void *)) bfd_void, /* aux_in */
-    (void (*) (bfd *,void *,void *)) bfd_void, /* sym_in */
-    (void (*) (bfd *,void *,void *)) bfd_void, /* lineno_in */
-    (unsigned (*) (bfd *,void *,int,int,int,int,void *)) bfd_void,/*aux_out*/
-    (unsigned (*) (bfd *,void *,void *)) bfd_void, /* sym_out */
-    (unsigned (*) (bfd *,void *,void *)) bfd_void, /* lineno_out */
-    (unsigned (*) (bfd *,void *,void *)) bfd_void, /* reloc_out */
+    mips_ecoff_swap_coff_aux_in, mips_ecoff_swap_coff_sym_in,
+    mips_ecoff_swap_coff_lineno_in, mips_ecoff_swap_coff_aux_out,
+    mips_ecoff_swap_coff_sym_out, mips_ecoff_swap_coff_lineno_out,
+    mips_ecoff_swap_coff_reloc_out,
     mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out,
     mips_ecoff_swap_scnhdr_out,
     FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE,
@@ -1362,6 +1420,9 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
 #define _bfd_ecoff_section_already_linked \
   _bfd_coff_section_already_linked
 #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
+#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
+#define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop
+#define _bfd_ecoff_set_reloc _bfd_generic_set_reloc
 
 extern const bfd_target mips_ecoff_be_vec;
 
@@ -1372,9 +1433,9 @@ const bfd_target mips_ecoff_le_vec =
   BFD_ENDIAN_LITTLE,           /* data byte order is little */
   BFD_ENDIAN_LITTLE,           /* header byte order is little */
 
-  (HAS_RELOC | EXEC_P |                /* object flags */
-   HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+  (HAS_RELOC | EXEC_P          /* object flags */
+   | HAS_LINENO | HAS_DEBUG
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
   0,                           /* leading underscore */
@@ -1388,26 +1449,38 @@ const bfd_target mips_ecoff_le_vec =
      bfd_getl32, bfd_getl_signed_32, bfd_putl32,
      bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
 
-  {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
-     bfd_generic_archive_p, _bfd_dummy_target},
-  {bfd_false, _bfd_ecoff_mkobject,  /* bfd_set_format */
-     _bfd_generic_mkarchive, bfd_false},
-  {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
-     _bfd_write_archive_contents, bfd_false},
-
-     BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
-     BFD_JUMP_TABLE_COPY (_bfd_ecoff),
-     BFD_JUMP_TABLE_CORE (_bfd_nocore),
-     BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
-     BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
-     BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
-     BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
-     BFD_JUMP_TABLE_LINK (_bfd_ecoff),
-     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
-  & mips_ecoff_be_vec,
-
-  & mips_ecoff_backend_data
+  {                            /* bfd_check_format */
+    _bfd_dummy_target,
+    coff_object_p,
+    bfd_generic_archive_p,
+    _bfd_dummy_target
+  },
+  {                            /* bfd_set_format */
+    _bfd_bool_bfd_false_error,
+    _bfd_ecoff_mkobject,
+    _bfd_generic_mkarchive,
+    _bfd_bool_bfd_false_error
+  },
+  {                            /* bfd_write_contents */
+    _bfd_bool_bfd_false_error,
+    _bfd_ecoff_write_object_contents,
+    _bfd_write_archive_contents,
+    _bfd_bool_bfd_false_error
+  },
+
+  BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
+  BFD_JUMP_TABLE_COPY (_bfd_ecoff),
+  BFD_JUMP_TABLE_CORE (_bfd_nocore),
+  BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
+  BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
+  BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
+  BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
+  BFD_JUMP_TABLE_LINK (_bfd_ecoff),
+  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+  &mips_ecoff_be_vec,
+
+  &mips_ecoff_backend_data
 };
 
 const bfd_target mips_ecoff_be_vec =
@@ -1417,9 +1490,9 @@ const bfd_target mips_ecoff_be_vec =
   BFD_ENDIAN_BIG,              /* data byte order is big */
   BFD_ENDIAN_BIG,              /* header byte order is big */
 
-  (HAS_RELOC | EXEC_P |                /* object flags */
-   HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+  (HAS_RELOC | EXEC_P          /* object flags */
+   | HAS_LINENO | HAS_DEBUG
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
   0,                           /* leading underscore */
@@ -1432,26 +1505,39 @@ const bfd_target mips_ecoff_be_vec =
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
      bfd_getb32, bfd_getb_signed_32, bfd_putb32,
      bfd_getb16, bfd_getb_signed_16, bfd_putb16,
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
-    bfd_generic_archive_p, _bfd_dummy_target},
- {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
-    _bfd_generic_mkarchive, bfd_false},
- {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
-    _bfd_write_archive_contents, bfd_false},
-
-     BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
-     BFD_JUMP_TABLE_COPY (_bfd_ecoff),
-     BFD_JUMP_TABLE_CORE (_bfd_nocore),
-     BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
-     BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
-     BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
-     BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
-     BFD_JUMP_TABLE_LINK (_bfd_ecoff),
-     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
-  & mips_ecoff_le_vec,
-
-  & mips_ecoff_backend_data
+
+  {                            /* bfd_check_format */
+    _bfd_dummy_target,
+    coff_object_p,
+    bfd_generic_archive_p,
+    _bfd_dummy_target
+  },
+  {                            /* bfd_set_format */
+    _bfd_bool_bfd_false_error,
+    _bfd_ecoff_mkobject,
+    _bfd_generic_mkarchive,
+    _bfd_bool_bfd_false_error
+  },
+  {                            /* bfd_write_contents */
+    _bfd_bool_bfd_false_error,
+    _bfd_ecoff_write_object_contents,
+    _bfd_write_archive_contents,
+    _bfd_bool_bfd_false_error
+  },
+
+  BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
+  BFD_JUMP_TABLE_COPY (_bfd_ecoff),
+  BFD_JUMP_TABLE_CORE (_bfd_nocore),
+  BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
+  BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
+  BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
+  BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
+  BFD_JUMP_TABLE_LINK (_bfd_ecoff),
+  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+  &mips_ecoff_le_vec,
+
+  &mips_ecoff_backend_data
 };
 
 const bfd_target mips_ecoff_bele_vec =
@@ -1461,9 +1547,9 @@ const bfd_target mips_ecoff_bele_vec =
   BFD_ENDIAN_LITTLE,           /* data byte order is little */
   BFD_ENDIAN_BIG,              /* header byte order is big */
 
-  (HAS_RELOC | EXEC_P |                /* object flags */
-   HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+  (HAS_RELOC | EXEC_P          /* object flags */
+   | HAS_LINENO | HAS_DEBUG
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
   0,                           /* leading underscore */
@@ -1477,24 +1563,36 @@ const bfd_target mips_ecoff_bele_vec =
      bfd_getb32, bfd_getb_signed_32, bfd_putb32,
      bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
 
-  {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
-     bfd_generic_archive_p, _bfd_dummy_target},
-  {bfd_false, _bfd_ecoff_mkobject,  /* bfd_set_format */
-     _bfd_generic_mkarchive, bfd_false},
-  {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
-     _bfd_write_archive_contents, bfd_false},
-
-     BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
-     BFD_JUMP_TABLE_COPY (_bfd_ecoff),
-     BFD_JUMP_TABLE_CORE (_bfd_nocore),
-     BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
-     BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
-     BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
-     BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
-     BFD_JUMP_TABLE_LINK (_bfd_ecoff),
-     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+  {                            /* bfd_check_format */
+    _bfd_dummy_target,
+    coff_object_p,
+    bfd_generic_archive_p,
+    _bfd_dummy_target
+  },
+  {                            /* bfd_set_format */
+    _bfd_bool_bfd_false_error,
+    _bfd_ecoff_mkobject,
+    _bfd_generic_mkarchive,
+    _bfd_bool_bfd_false_error
+  },
+  {                            /* bfd_write_contents */
+    _bfd_bool_bfd_false_error,
+    _bfd_ecoff_write_object_contents,
+    _bfd_write_archive_contents,
+    _bfd_bool_bfd_false_error
+  },
+
+  BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
+  BFD_JUMP_TABLE_COPY (_bfd_ecoff),
+  BFD_JUMP_TABLE_CORE (_bfd_nocore),
+  BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
+  BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
+  BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
+  BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
+  BFD_JUMP_TABLE_LINK (_bfd_ecoff),
+  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
 
   NULL,
 
-  & mips_ecoff_backend_data
+  &mips_ecoff_backend_data
 };
This page took 0.027998 seconds and 4 git commands to generate.