Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf32-mt.c
index 8df3e069ddfd0f4c477ba9d971485cd9b8e35541..f5b08194bdd0888b406dc8353a17527ea22eb44a 100644 (file)
@@ -1,5 +1,5 @@
 /* Morpho Technologies MT specific support for 32-bit ELF
-   Copyright (C) 2001-2017 Free Software Foundation, Inc.
+   Copyright (C) 2001-2021 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -28,7 +28,7 @@
 static reloc_howto_type * mt_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
 
-static void mt_info_to_howto_rela
+static bool mt_info_to_howto_rela
   (bfd *, arelent *, Elf_Internal_Rela *);
 
 static bfd_reloc_status_type mt_elf_relocate_hi16
@@ -38,7 +38,7 @@ static bfd_reloc_status_type mt_final_link_relocate
   (reloc_howto_type *, bfd *, asection *, bfd_byte *,
    Elf_Internal_Rela *, bfd_vma);
 
-static bfd_boolean mt_elf_relocate_section
+static int mt_elf_relocate_section
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
 
@@ -50,105 +50,105 @@ static reloc_howto_type mt_elf_howto_table [] =
          0,                      /* rightshift */
          3,                      /* size (0 = byte, 1 = short, 2 = long) */
          0,                      /* bitsize */
-         FALSE,                  /* pc_relative */
+         false,                  /* pc_relative */
          0,                      /* bitpos */
          complain_overflow_dont, /* complain_on_overflow */
          bfd_elf_generic_reloc,  /* special_function */
          "R_MT_NONE",          /* name */
-         FALSE,                  /* partial_inplace */
+         false,                  /* partial_inplace */
          0 ,                     /* src_mask */
          0,                      /* dst_mask */
-         FALSE),                 /* pcrel_offset */
+         false),                 /* pcrel_offset */
 
   /* A 16 bit absolute relocation.  */
   HOWTO (R_MT_16,            /* type */
          0,                      /* rightshift */
          2,                      /* size (0 = byte, 1 = short, 2 = long) */
          16,                     /* bitsize */
-         FALSE,                  /* pc_relative */
+         false,                  /* pc_relative */
          0,                      /* bitpos */
          complain_overflow_dont, /* complain_on_overflow */
          bfd_elf_generic_reloc,  /* special_function */
          "R_MT_16",            /* name */
-         FALSE,                  /* partial_inplace */
+         false,                  /* partial_inplace */
          0 ,                     /* src_mask */
          0xffff,                 /* dst_mask */
-         FALSE),                 /* pcrel_offset */
+         false),                 /* pcrel_offset */
 
   /* A 32 bit absolute relocation.  */
   HOWTO (R_MT_32,            /* type */
          0,                      /* rightshift */
          2,                      /* size (0 = byte, 1 = short, 2 = long) */
          32,                     /* bitsize */
-         FALSE,                  /* pc_relative */
+         false,                  /* pc_relative */
          0,                      /* bitpos */
          complain_overflow_dont, /* complain_on_overflow */
          bfd_elf_generic_reloc,  /* special_function */
          "R_MT_32",            /* name */
-         FALSE,                  /* partial_inplace */
+         false,                  /* partial_inplace */
          0 ,                     /* src_mask */
          0xffffffff,             /* dst_mask */
-         FALSE),                 /* pcrel_offset */
+         false),                 /* pcrel_offset */
 
   /* A 32 bit pc-relative relocation.  */
   HOWTO (R_MT_32_PCREL,              /* type */
          0,                      /* rightshift */
          2,                      /* size (0 = byte, 1 = short, 2 = long) */
          32,                     /* bitsize */
-         TRUE,                   /* pc_relative */
+         true,                   /* pc_relative */
          0,                      /* bitpos */
          complain_overflow_dont, /* complain_on_overflow */
          bfd_elf_generic_reloc,  /* special_function */
          "R_MT_32_PCREL",    /* name */
-         FALSE,                  /* partial_inplace */
+         false,                  /* partial_inplace */
          0 ,                     /* src_mask */
          0xffffffff,             /* dst_mask */
-         TRUE),                  /* pcrel_offset */
+         true),                  /* pcrel_offset */
 
   /* A 16 bit pc-relative relocation.  */
   HOWTO (R_MT_PC16,          /* type */
          0,                      /* rightshift */
          2,                      /* size (0 = byte, 1 = short, 2 = long) */
          16,                     /* bitsize */
-         TRUE,                   /* pc_relative */
+         true,                   /* pc_relative */
          0,                      /* bitpos */
          complain_overflow_signed, /* complain_on_overflow */
          bfd_elf_generic_reloc,  /* special_function */
          "R_MT_PC16",          /* name */
-         FALSE,                  /* partial_inplace */
+         false,                  /* partial_inplace */
          0,                      /* src_mask */
          0xffff,                 /* dst_mask */
-         TRUE),                  /* pcrel_offset */
+         true),                  /* pcrel_offset */
 
   /* high 16 bits of symbol value.  */
   HOWTO (R_MT_HI16,         /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_MT_HI16",        /* name */
-        FALSE,                  /* partial_inplace */
+        false,                  /* partial_inplace */
         0xffff0000,            /* src_mask */
         0xffff0000,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   /* Low 16 bits of symbol value.  */
   HOWTO (R_MT_LO16,         /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_MT_LO16",        /* name */
-        FALSE,                  /* partial_inplace */
+        false,                  /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 };
 
 /* Map BFD reloc types to MT ELF reloc types.  */
@@ -227,11 +227,10 @@ mt_elf_relocate_hi16
 
 /* Set the howto pointer for a MT ELF reloc.  */
 
-static void
-mt_info_to_howto_rela
-    (bfd *              abfd ATTRIBUTE_UNUSED,
-     arelent *          cache_ptr,
-     Elf_Internal_Rela * dst)
+static bool
+mt_info_to_howto_rela (bfd *abfd,
+                      arelent *cache_ptr,
+                      Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
@@ -239,10 +238,13 @@ mt_info_to_howto_rela
   if (r_type >= (unsigned int) R_MT_max)
     {
       /* xgettext:c-format */
-      _bfd_error_handler (_("%B: invalid MT reloc number: %d"), abfd, r_type);
-      r_type = 0;
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return false;
     }
   cache_ptr->howto = & mt_elf_howto_table [r_type];
+  return true;
 }
 
 /* Perform a single relocation.  By default we use the standard BFD
@@ -295,7 +297,7 @@ mt_final_link_relocate
    section, which means that the addend must be adjusted
    accordingly.  */
 
-static bfd_boolean
+static int
 mt_elf_relocate_section
     (bfd *                  output_bfd ATTRIBUTE_UNUSED,
      struct bfd_link_info *  info,
@@ -344,12 +346,12 @@ mt_elf_relocate_section
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
-         name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+         name = name == NULL ? bfd_section_name (sec) : name;
        }
       else
        {
-         bfd_boolean unresolved_reloc;
-         bfd_boolean warned, ignored;
+         bool unresolved_reloc;
+         bool warned, ignored;
 
          RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
                                   r_symndx, symtab_hdr, sym_hashes,
@@ -393,7 +395,7 @@ mt_elf_relocate_section
 
            case bfd_reloc_undefined:
              (*info->callbacks->undefined_symbol)
-               (info, name, input_bfd, input_section, rel->r_offset, TRUE);
+               (info, name, input_bfd, input_section, rel->r_offset, true);
              break;
 
            case bfd_reloc_outofrange:
@@ -415,27 +417,26 @@ mt_elf_relocate_section
        }
     }
 
-  return TRUE;
+  return true;
 }
 
 /* Look through the relocs for a section during the first phase.
    Since we don't do .gots or .plts, we just need to consider the
    virtual table relocs for gc.  */
 
-static bfd_boolean
-mt_elf_check_relocs
-    (bfd *                    abfd,
-     struct bfd_link_info *    info,
-     asection *                       sec,
-     const Elf_Internal_Rela * relocs)
+static bool
+mt_elf_check_relocs (bfd *abfd,
+                    struct bfd_link_info *info,
+                    asection *sec,
+                    const Elf_Internal_Rela *relocs)
 {
-  Elf_Internal_Shdr *          symtab_hdr;
-  struct elf_link_hash_entry ** sym_hashes;
-  const Elf_Internal_Rela *    rel;
-  const Elf_Internal_Rela *    rel_end;
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  const Elf_Internal_Rela *rel;
+  const Elf_Internal_Rela *rel_end;
 
   if (bfd_link_relocatable (info))
-    return TRUE;
+    return true;
 
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
@@ -458,7 +459,7 @@ mt_elf_check_relocs
        }
     }
 
-  return TRUE;
+  return true;
 }
 
 /* Return the MACH for an e_flags value.  */
@@ -476,64 +477,63 @@ elf32_mt_machine (bfd *abfd)
   return bfd_mach_ms1;
 }
 
-static bfd_boolean
-mt_elf_object_p (bfd * abfd)
+static bool
+mt_elf_object_p (bfd *abfd)
 {
   bfd_default_set_arch_mach (abfd, bfd_arch_mt, elf32_mt_machine (abfd));
 
-  return TRUE;
+  return true;
 }
 
 /* Function to set the ELF flag bits.  */
 
-static bfd_boolean
-mt_elf_set_private_flags (bfd *    abfd,
-                          flagword flags)
+static bool
+mt_elf_set_private_flags (bfd *abfd, flagword flags)
 {
   elf_elfheader (abfd)->e_flags = flags;
-  elf_flags_init (abfd) = TRUE;
-  return TRUE;
+  elf_flags_init (abfd) = true;
+  return true;
 }
 
 /* Merge backend specific data from an object file to the output
    object file when linking.  */
 
-static bfd_boolean
+static bool
 mt_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 {
   bfd *obfd = info->output_bfd;
-  flagword     old_flags, new_flags;
-  bfd_boolean  ok = TRUE;
+  flagword old_flags, new_flags;
+  bool ok = true;
 
   /* Check if we have the same endianness.  */
   if (!_bfd_generic_verify_endian_match (ibfd, info))
-    return FALSE;
+    return false;
 
   /* If they're not both mt, then merging is meaningless, so just
      don't do it.  */
   if (strcmp (ibfd->arch_info->arch_name, "mt") != 0)
-    return TRUE;
+    return true;
   if (strcmp (obfd->arch_info->arch_name, "mt") != 0)
-    return TRUE;
+    return true;
 
   new_flags = elf_elfheader (ibfd)->e_flags;
   old_flags = elf_elfheader (obfd)->e_flags;
 
 #ifdef DEBUG
-  _bfd_error_handler ("%B: old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s",
+  _bfd_error_handler ("%pB: old_flags = 0x%.8x, new_flags = 0x%.8x, init = %s",
                      ibfd, old_flags, new_flags, elf_flags_init (obfd) ? "yes" : "no");
 #endif
 
   if (!elf_flags_init (obfd))
     {
       old_flags = new_flags;
-      elf_flags_init (obfd) = TRUE;
+      elf_flags_init (obfd) = true;
     }
   else if ((new_flags & EF_MT_CPU_MASK) != (old_flags & EF_MT_CPU_MASK))
     {
       /* CPU has changed.  This is invalid, because MRISC, MRISC2 and
         MS2 are not subsets of each other.   */
-      ok = FALSE;
+      ok = false;
     }
 
   if (ok)
@@ -545,10 +545,10 @@ mt_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   return ok;
 }
 
-static bfd_boolean
-mt_elf_print_private_bfd_data (bfd * abfd, void * ptr)
+static bool
+mt_elf_print_private_bfd_data (bfd *abfd, void *ptr)
 {
-  FILE *   file = (FILE *) ptr;
+  FILE *file = (FILE *) ptr;
   flagword flags;
 
   BFD_ASSERT (abfd != NULL && ptr != NULL);
@@ -569,7 +569,7 @@ mt_elf_print_private_bfd_data (bfd * abfd, void * ptr)
 
   fputc ('\n', file);
 
-  return TRUE;
+  return true;
 }
 
 \f
This page took 0.031211 seconds and 4 git commands to generate.