Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf32-mips.c
index 37676778e15ceec8bdfecf3aeedf65e78ed98b80..34e61865cd9f95db799b607b4b34226a128ffcbb 100644 (file)
@@ -1,5 +1,5 @@
 /* MIPS-specific support for 32-bit ELF
-   Copyright (C) 1993-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-2021 Free Software Foundation, Inc.
 
    Most of the information added by Ian Lance Taylor, Cygnus Support,
    <ian@cygnus.com>.
@@ -63,6 +63,8 @@ static bfd_boolean mips_info_to_howto_rela
   (bfd *, arelent *, Elf_Internal_Rela *);
 static bfd_boolean mips_elf_sym_is_global
   (bfd *, asymbol *);
+static bfd_boolean mips_elf32_elfsym_local_is_section
+  (bfd *);
 static bfd_boolean mips_elf32_object_p
   (bfd *);
 static bfd_boolean mips_elf_is_local_label_name
@@ -2198,6 +2200,8 @@ mips_elf32_rtype_to_howto (bfd *abfd,
                           unsigned int r_type,
                           bfd_boolean rela_p ATTRIBUTE_UNUSED)
 {
+  reloc_howto_type *howto = NULL;
+
   switch (r_type)
     {
     case R_MIPS_GNU_VTINHERIT:
@@ -2216,17 +2220,18 @@ mips_elf32_rtype_to_howto (bfd *abfd,
       return &elf_mips_eh_howto;
     default:
       if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
-       return &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
+       howto = &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
       if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
-       return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
-      if (r_type >= (unsigned int) R_MIPS_max)
-       {
-         _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
-                             abfd, r_type);
-         bfd_set_error (bfd_error_bad_value);
-         return NULL;
-       }
-      return &elf_mips_howto_table_rel[r_type];
+       howto = &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
+      if (r_type < R_MIPS_max)
+       howto = &elf_mips_howto_table_rel[r_type];
+      if (howto != NULL && howto->name != NULL)
+       return howto;
+
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return NULL;
     }
 }
 
@@ -2239,13 +2244,9 @@ mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
 
   r_type = ELF32_R_TYPE (dst->r_info);
   cache_ptr->howto = mips_elf32_rtype_to_howto (abfd, r_type, FALSE);
+
   if (cache_ptr->howto == NULL)
-    {
-      /* xgettext:c-format */
-      _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type);
-      bfd_set_error (bfd_error_bad_value);
-      return FALSE;
-    }
+    return FALSE;
 
   /* The addend for a GPREL16 or LITERAL relocation comes from the GP
      value for the object file.  We get the addend now, rather than
@@ -2282,8 +2283,16 @@ mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
     return (sym->flags & BSF_SECTION_SYM) == 0;
   else
     return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
-           || bfd_is_und_section (bfd_get_section (sym))
-           || bfd_is_com_section (bfd_get_section (sym)));
+           || bfd_is_und_section (bfd_asymbol_section (sym))
+           || bfd_is_com_section (bfd_asymbol_section (sym)));
+}
+
+/* Likewise, return TRUE if the symbol table split overall must be
+   between section symbols and all other symbols.  */
+static bfd_boolean
+mips_elf32_elfsym_local_is_section (bfd *abfd)
+{
+  return SGI_COMPAT (abfd);
 }
 \f
 /* Set the right machine number for a MIPS ELF file.  */
@@ -2421,6 +2430,17 @@ elf32_mips_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
       }
     }
 }
+
+/* Remove the magic _gp_disp symbol from the symbol tables.  */
+
+static bfd_boolean
+elf32_mips_fixup_symbol (struct bfd_link_info *info,
+                        struct elf_link_hash_entry *h)
+{
+  if (strcmp (h->root.root.string, "_gp_disp") == 0)
+    _bfd_elf_link_hash_hide_symbol (info, h, TRUE);
+  return TRUE;
+}
 \f
 /* Depending on the target vector we generate some version of Irix
    executables or "normal" MIPS ELF ABI executables.  */
@@ -2524,6 +2544,8 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #define elf_backend_gc_mark_hook       _bfd_mips_elf_gc_mark_hook
 #define elf_backend_copy_indirect_symbol \
                                        _bfd_mips_elf_copy_indirect_symbol
+#define elf_backend_hide_symbol                _bfd_mips_elf_hide_symbol
+#define elf_backend_fixup_symbol       elf32_mips_fixup_symbol
 #define elf_backend_grok_prstatus      elf32_mips_grok_prstatus
 #define elf_backend_grok_psinfo                elf32_mips_grok_psinfo
 #define elf_backend_ecoff_debug_swap   &mips_elf32_ecoff_debug_swap
@@ -2540,6 +2562,8 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #define elf_backend_ignore_discarded_relocs \
                                        _bfd_mips_elf_ignore_discarded_relocs
 #define elf_backend_write_section      _bfd_mips_elf_write_section
+#define elf_backend_elfsym_local_is_section \
+                                       mips_elf32_elfsym_local_is_section
 #define elf_backend_mips_irix_compat   elf32_mips_irix_compat
 #define elf_backend_mips_rtype_to_howto        mips_elf32_rtype_to_howto
 #define elf_backend_sort_relocs_p      _bfd_mips_elf_sort_relocs_p
@@ -2631,11 +2655,11 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
 #include "elf32-target.h"
 /* Implement elf_backend_final_write_processing for VxWorks.  */
 
-static void
-mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
+static bfd_boolean
+mips_vxworks_final_write_processing (bfd *abfd)
 {
-  _bfd_mips_elf_final_write_processing (abfd, linker);
-  elf_vxworks_final_write_processing (abfd, linker);
+  _bfd_mips_final_write_processing (abfd);
+  return elf_vxworks_final_write_processing (abfd);
 }
 
 #undef TARGET_LITTLE_SYM
@@ -2658,6 +2682,9 @@ mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
 #define ELF_MAXPAGESIZE                        0x1000
 #define ELF_COMMONPAGESIZE             0x1000
 
+#undef ELF_TARGET_OS
+#define ELF_TARGET_OS                  is_vxworks
+
 #undef elf_backend_want_got_plt
 #define elf_backend_want_got_plt               1
 #undef elf_backend_want_plt_sym
This page took 0.024463 seconds and 4 git commands to generate.