Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf32-epiphany.c
index 25ed0fe272cd7a587f9bfe52e79349cd750429c9..c0e3ae5cd28ee258ff12ff95e941350588831690 100644 (file)
@@ -1,5 +1,5 @@
 /* Adapteva epiphany specific support for 32-bit ELF
 /* Adapteva epiphany specific support for 32-bit ELF
-   Copyright (C) 2000-2016 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 Free Software Foundation, Inc.
    Contributed by Embecosm on behalf of Adapteva, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
    Contributed by Embecosm on behalf of Adapteva, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -32,7 +32,7 @@ struct misc
 {
   Elf_Internal_Shdr *  symtab_hdr;
   Elf_Internal_Rela *  irelbase;
 {
   Elf_Internal_Shdr *  symtab_hdr;
   Elf_Internal_Rela *  irelbase;
-  bfd_byte *           contents;
+  bfd_byte *          contents;
   Elf_Internal_Sym *   isymbuf;
 };
 
   Elf_Internal_Sym *   isymbuf;
 };
 
@@ -48,29 +48,29 @@ static bfd_boolean epiphany_relaxed = FALSE;
 static reloc_howto_type epiphany_elf_howto_table [] =
 {
 #define AHOW(t,rs,s,bs,pr,bp,co,name,sm,dm)    \
 static reloc_howto_type epiphany_elf_howto_table [] =
 {
 #define AHOW(t,rs,s,bs,pr,bp,co,name,sm,dm)    \
-    HOWTO(t,                    /* type */ \
-         rs,                   /* rightshift */ \
-         s,                    /* size (0 = byte, 1 = short, 2 = long) */ \
-         bs,                   /* bitsize */ \
-         pr,                   /* pc_relative */ \
-         bp,                   /* bitpos */ \
+    HOWTO(t,                   /* type */ \
+         rs,                   /* rightshift */ \
+         s,                    /* size (0 = byte, 1 = short, 2 = long) */ \
+         bs,                   /* bitsize */ \
+         pr,                   /* pc_relative */ \
+         bp,                   /* bitpos */ \
          co,                   /* complain_on_overflow */             \
          bfd_elf_generic_reloc,/* special_function */ \
          co,                   /* complain_on_overflow */             \
          bfd_elf_generic_reloc,/* special_function */ \
-         name,                 /* name */ \
-         FALSE,                /* partial_inplace */ \
-         sm,                   /* src_mask */ \
-         dm,                   /* dst_mask */ \
-         pr)                   /* pcrel_offset */
+         name,                 /* name */ \
+         FALSE,                /* partial_inplace */ \
+         sm,                   /* src_mask */ \
+         dm,                   /* dst_mask */ \
+         pr)                   /* pcrel_offset */
 
   /* This reloc does nothing.  */
 
   /* This reloc does nothing.  */
-  AHOW (R_EPIPHANY_NONE,    0, 3,0, FALSE, 0, complain_overflow_dont,     "R_EPIPHANY_NONE",        0,          0),
+  AHOW (R_EPIPHANY_NONE,    0, 3,0, FALSE, 0, complain_overflow_dont,    "R_EPIPHANY_NONE",        0,          0),
 
   /* 8 bit absolute (not likely) */
 
   /* 8 bit absolute (not likely) */
-  AHOW (R_EPIPHANY_8,       0, 0, 8, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_8",      0x000000ff, 0x000000ff),
+  AHOW (R_EPIPHANY_8,      0, 0, 8, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_8",      0x000000ff, 0x000000ff),
   /* 16 bit absolute */
   /* 16 bit absolute */
-  AHOW (R_EPIPHANY_16,      0, 1,16, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_16",     0x0000ffff, 0x00ff1fe0),
+  AHOW (R_EPIPHANY_16,     0, 1,16, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_16",     0x0000ffff, 0x00ff1fe0),
   /* A 32 bit absolute relocation.  */
   /* A 32 bit absolute relocation.  */
-  AHOW (R_EPIPHANY_32,      0, 2,32, FALSE, 0, complain_overflow_dont,     "R_EPIPHANY_32",     0xffffffff, 0xffffffff),
+  AHOW (R_EPIPHANY_32,     0, 2,32, FALSE, 0, complain_overflow_dont,     "R_EPIPHANY_32",     0xffffffff, 0xffffffff),
 
   /*  8 bit relative relocation */
   HOWTO ( R_EPIPHANY_8_PCREL,  0, 0,  8, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", FALSE, 0x000000ff, 0x000000ff, FALSE),
 
   /*  8 bit relative relocation */
   HOWTO ( R_EPIPHANY_8_PCREL,  0, 0,  8, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", FALSE, 0x000000ff, 0x000000ff, FALSE),
@@ -80,22 +80,22 @@ static reloc_howto_type epiphany_elf_howto_table [] =
   HOWTO ( R_EPIPHANY_32_PCREL, 0, 2, 32, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", FALSE, 0x000000ff, 0x000000ff, FALSE),
 
   /* 8 bit pc-relative relocation */
   HOWTO ( R_EPIPHANY_32_PCREL, 0, 2, 32, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", FALSE, 0x000000ff, 0x000000ff, FALSE),
 
   /* 8 bit pc-relative relocation */
-  AHOW (R_EPIPHANY_SIMM8,   1, 0, 8,  TRUE, 8, complain_overflow_signed,   "R_EPIPHANY_SIMM8",   0x000000ff, 0x0000ff00),
+  AHOW (R_EPIPHANY_SIMM8,   1, 0, 8,  TRUE, 8, complain_overflow_signed,   "R_EPIPHANY_SIMM8",  0x000000ff, 0x0000ff00),
   /* 24 bit pc-relative relocation */
   /* 24 bit pc-relative relocation */
-  AHOW (R_EPIPHANY_SIMM24,  1, 2,24,  TRUE, 8, complain_overflow_signed,   "R_EPIPHANY_SIMM24",  0x00ffffff, 0xffffff00),
+  AHOW (R_EPIPHANY_SIMM24,  1, 2,24,  TRUE, 8, complain_overflow_signed,   "R_EPIPHANY_SIMM24",         0x00ffffff, 0xffffff00),
 
   /* %HIGH(EA) */
 
   /* %HIGH(EA) */
-  AHOW (R_EPIPHANY_HIGH,    0, 2,16, FALSE, 0, complain_overflow_dont,     "R_EPIPHANY_HIGH",    0x0ff01fe0, 0x0ff01fe0),
+  AHOW (R_EPIPHANY_HIGH,    0, 2,16, FALSE, 0, complain_overflow_dont,    "R_EPIPHANY_HIGH",    0x0ff01fe0, 0x0ff01fe0),
 
   /* %LOW(EA) */
 
   /* %LOW(EA) */
-  AHOW (R_EPIPHANY_LOW,     0, 2,16, FALSE, 0, complain_overflow_dont, "R_EPIPHANY_LOW",     0x0ff01fe0, 0x0ff01fe0),
+  AHOW (R_EPIPHANY_LOW,            0, 2,16, FALSE, 0, complain_overflow_dont,  "R_EPIPHANY_LOW",     0x0ff01fe0, 0x0ff01fe0),
 
   /* simm11 */
 
   /* simm11 */
-  AHOW (R_EPIPHANY_SIMM11,  0, 2,11, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_SIMM11",  0x00ff0380, 0x00ff0380),
+  AHOW (R_EPIPHANY_SIMM11,  0, 2,11, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_SIMM11",         0x00ff0380, 0x00ff0380),
   /* imm12 - sign-magnitude */
   /* imm12 - sign-magnitude */
-  AHOW (R_EPIPHANY_IMM11,   0, 2,11, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_IMM12",   0x00ff0380, 0x00ff0380),
+  AHOW (R_EPIPHANY_IMM11,   0, 2,11, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_IMM12",  0x00ff0380, 0x00ff0380),
   /* imm8 */
   /* imm8 */
-  AHOW (R_EPIPHANY_IMM8,    0, 1, 8, FALSE, 8, complain_overflow_signed,   "R_EPIPHANY_IMM8",    0x0000ff00, 0x0000ff00)
+  AHOW (R_EPIPHANY_IMM8,    0, 1, 8, FALSE, 8, complain_overflow_signed,   "R_EPIPHANY_IMM8",   0x0000ff00, 0x0000ff00)
 
 
 };
 
 
 };
@@ -362,8 +362,8 @@ epiphany_elf_relax_section (bfd *abfd, asection *sec,
 
 /* Set the howto pointer for a EPIPHANY ELF reloc.  */
 
 
 /* Set the howto pointer for a EPIPHANY ELF reloc.  */
 
-static void
-epiphany_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+epiphany_info_to_howto_rela (bfd * abfd,
                             arelent * cache_ptr,
                             Elf_Internal_Rela * dst)
 {
                             arelent * cache_ptr,
                             Elf_Internal_Rela * dst)
 {
@@ -372,10 +372,14 @@ epiphany_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
   r_type = ELF32_R_TYPE (dst->r_info);
   if (r_type >= (unsigned int) R_EPIPHANY_max)
     {
   r_type = ELF32_R_TYPE (dst->r_info);
   if (r_type >= (unsigned int) R_EPIPHANY_max)
     {
-      _bfd_error_handler (_("%B: invalid Epiphany reloc number: %d"), abfd, r_type);
-      r_type = 0;
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & epiphany_elf_howto_table [r_type];
     }
   cache_ptr->howto = & epiphany_elf_howto_table [r_type];
+  return TRUE;
 }
 
 /* Perform a single relocation.
 }
 
 /* Perform a single relocation.
@@ -383,11 +387,11 @@ epiphany_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
 
 static bfd_reloc_status_type
 epiphany_final_link_relocate (reloc_howto_type *  howto,
 
 static bfd_reloc_status_type
 epiphany_final_link_relocate (reloc_howto_type *  howto,
-                             bfd *               input_bfd,
-                             asection *          input_section,
-                             bfd_byte *          contents,
+                             bfd *               input_bfd,
+                             asection *          input_section,
+                             bfd_byte *          contents,
                              Elf_Internal_Rela * rel,
                              Elf_Internal_Rela * rel,
-                             bfd_vma             relocation)
+                             bfd_vma             relocation)
 {
   switch (howto->type)
     {
 {
   switch (howto->type)
     {
@@ -420,9 +424,10 @@ epiphany_final_link_relocate (reloc_howto_type *  howto,
       relocation += rel->r_addend;
       if ((unsigned int) relocation > 0x7ff)
        return bfd_reloc_outofrange;
       relocation += rel->r_addend;
       if ((unsigned int) relocation > 0x7ff)
        return bfd_reloc_outofrange;
+      /* Fall through.  */
     disp11:
     disp11:
-      relocation = ((relocation & 7) << 5)
-       || ((relocation & 0x7f8 )  << 13);
+      relocation = (((relocation & 7) << 5)
+                   | ((relocation & 0x7f8 ) << 13));
       return _bfd_relocate_contents (howto, input_bfd, relocation,
                                     contents + rel->r_offset);
 
       return _bfd_relocate_contents (howto, input_bfd, relocation,
                                     contents + rel->r_offset);
 
@@ -488,15 +493,15 @@ epiphany_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   for (rel = relocs; rel < relend; rel ++)
     {
 
   for (rel = relocs; rel < relend; rel ++)
     {
-      reloc_howto_type *           howto;
-      unsigned long                r_symndx;
-      Elf_Internal_Sym *           sym;
-      asection *                   sec;
+      reloc_howto_type *          howto;
+      unsigned long               r_symndx;
+      Elf_Internal_Sym *          sym;
+      asection *                  sec;
       struct elf_link_hash_entry * h;
       struct elf_link_hash_entry * h;
-      bfd_vma                      relocation;
-      bfd_reloc_status_type        r;
-      const char *                 name = NULL;
-      int                          r_type ATTRIBUTE_UNUSED;
+      bfd_vma                     relocation;
+      bfd_reloc_status_type       r;
+      const char *                name = NULL;
+      int                         r_type ATTRIBUTE_UNUSED;
 
       r_type = ELF32_R_TYPE (rel->r_info);
       r_symndx = ELF32_R_SYM (rel->r_info);
 
       r_type = ELF32_R_TYPE (rel->r_info);
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -513,7 +518,7 @@ epiphany_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
 
          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
        {
        }
       else
        {
@@ -547,13 +552,13 @@ epiphany_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
          switch (r)
            {
            case bfd_reloc_overflow:
          switch (r)
            {
            case bfd_reloc_overflow:
-             r = info->callbacks->reloc_overflow
+             (*info->callbacks->reloc_overflow)
                (info, (h ? &h->root : NULL), name, howto->name,
                 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
              break;
 
            case bfd_reloc_undefined:
                (info, (h ? &h->root : NULL), name, howto->name,
                 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
              break;
 
            case bfd_reloc_undefined:
-             r = info->callbacks->undefined_symbol
+             (*info->callbacks->undefined_symbol)
                (info, name, input_bfd, input_section, rel->r_offset, TRUE);
              break;
 
                (info, name, input_bfd, input_section, rel->r_offset, TRUE);
              break;
 
@@ -578,11 +583,8 @@ epiphany_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
            }
 
          if (msg)
            }
 
          if (msg)
-           r = info->callbacks->warning
-             (info, msg, name, input_bfd, input_section, rel->r_offset);
-
-         if (! r)
-           return FALSE;
+           (*info->callbacks->warning) (info, msg, name, input_bfd,
+                                        input_section, rel->r_offset);
        }
     }
 
        }
     }
 
@@ -601,7 +603,7 @@ epiphany_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 #define elf_info_to_howto_rel                  NULL
 #define elf_info_to_howto                      epiphany_info_to_howto_rela
 
 #define elf_info_to_howto_rel                  NULL
 #define elf_info_to_howto                      epiphany_info_to_howto_rela
 
-#define elf_backend_can_gc_sections            1
+#define elf_backend_can_gc_sections            1
 #define elf_backend_rela_normal                        1
 #define elf_backend_relocate_section           epiphany_elf_relocate_section
 
 #define elf_backend_rela_normal                        1
 #define elf_backend_relocate_section           epiphany_elf_relocate_section
 
This page took 0.027969 seconds and 4 git commands to generate.