unrecognized/unsupported reloc message
[deliverable/binutils-gdb.git] / bfd / elf32-xgate.c
index bd5ebc476d4fe843c1817e6769a8b0fdce769fa7..3e2669c2ce465d4b1112b02edf53e2282422cdfe 100644 (file)
@@ -1,6 +1,5 @@
 /* Freescale XGATE-specific support for 32-bit ELF
-   Copyright 2010, 2011, 2012
-   Free Software Foundation, Inc.
+   Copyright (C) 2010-2018 Free Software Foundation, Inc.
    Contributed by Sean Keys(skeys@ipdatasys.com)
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -53,8 +52,8 @@ static reloc_howto_type elf_xgate_howto_table[] =
   /* This reloc does nothing.  */
   HOWTO (R_XGATE_NONE, /* type */
         0, /* rightshift */
-        2, /* size (0 = byte, 1 = short, 2 = long) */
-        32, /* bitsize */
+        3, /* size (0 = byte, 1 = short, 2 = long) */
+        0, /* bitsize */
         FALSE, /* pc_relative */
         0, /* bitpos */
         complain_overflow_dont,/* complain_on_overflow */
@@ -106,8 +105,8 @@ static reloc_howto_type elf_xgate_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_XGATE_16", /* name */
         FALSE, /* partial_inplace */
-        0x00ff, /* src_mask */
-        0x00ff, /* dst_mask */
+        0xffff, /* src_mask */
+        0xffff, /* dst_mask */
         FALSE), /* pcrel_offset */
 
   /* A 32 bit absolute relocation.  This one is never used for the
@@ -407,7 +406,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
   for (i = 0; i < ARRAY_SIZE (elf_xgate_howto_table); i++)
     if (elf_xgate_howto_table[i].name != NULL
-        && strcasecmp (elf_xgate_howto_table[i].name, r_name) == 0)
+       && strcasecmp (elf_xgate_howto_table[i].name, r_name) == 0)
       return &elf_xgate_howto_table[i];
 
   return NULL;
@@ -416,31 +415,37 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 /* Set the howto pointer for an XGATE ELF reloc.  */
 
 static void
-xgate_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
+xgate_info_to_howto_rel (bfd *abfd,
                         arelent *cache_ptr,
                         Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
   r_type = ELF32_R_TYPE (dst->r_info);
-  BFD_ASSERT(r_type < (unsigned int) R_XGATE_max);
+  if (r_type >= (unsigned int) R_XGATE_max)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      r_type = 0;
+    }
   cache_ptr->howto = &elf_xgate_howto_table[r_type];
 }
 
-/* Free the derived linker hash table.  */
+/* Destroy an XGATE ELF linker hash table.  */
 
-void
-xgate_elf_bfd_link_hash_table_free (struct bfd_link_hash_table *hash)
+static void
+xgate_elf_bfd_link_hash_table_free (bfd *obfd)
 {
   struct xgate_elf_link_hash_table *ret =
-      (struct xgate_elf_link_hash_table *) hash;
+      (struct xgate_elf_link_hash_table *) obfd->link.hash;
 
   bfd_hash_table_free (ret->stub_hash_table);
   free (ret->stub_hash_table);
-  _bfd_generic_link_hash_table_free (hash);
+  _bfd_elf_link_hash_table_free (obfd);
 }
 
-/* Create a XGATE ELF linker hash table.  */
+/* Create an XGATE ELF linker hash table.  */
 
 static struct bfd_link_hash_table*
 xgate_elf_bfd_link_hash_table_create (bfd *abfd)
@@ -448,11 +453,10 @@ xgate_elf_bfd_link_hash_table_create (bfd *abfd)
   struct xgate_elf_link_hash_table *ret;
   bfd_size_type amt = sizeof(struct xgate_elf_link_hash_table);
 
-  ret = (struct xgate_elf_link_hash_table *) bfd_malloc (amt);
+  ret = (struct xgate_elf_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct xgate_elf_link_hash_table *) NULL)
     return NULL;
 
-  memset (ret, 0, amt);
   if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
       _bfd_elf_link_hash_newfunc, sizeof(struct elf_link_hash_entry),
       XGATE_ELF_DATA))
@@ -463,21 +467,21 @@ xgate_elf_bfd_link_hash_table_create (bfd *abfd)
 
   /* Init the stub hash table too.  */
   amt = sizeof(struct bfd_hash_table);
-  ret->stub_hash_table = (struct bfd_hash_table*) bfd_malloc (amt);
+  ret->stub_hash_table = (struct bfd_hash_table*) bfd_zmalloc (amt);
   if (ret->stub_hash_table == NULL)
     {
-      free (ret);
+      _bfd_elf_link_hash_table_free (abfd);
       return NULL;
     }
 
   if (!bfd_hash_table_init (ret->stub_hash_table, stub_hash_newfunc,
       sizeof(struct elf32_xgate_stub_hash_entry)))
-    return NULL;
-
-  ret->stub_bfd = NULL;
-  ret->stub_section = 0;
-  ret->add_stub_section = NULL;
-  ret->sym_cache.abfd = NULL;
+    {
+      free (ret->stub_hash_table);
+      _bfd_elf_link_hash_table_free (abfd);
+      return NULL;
+    }
+  ret->root.root.hash_table_free = xgate_elf_bfd_link_hash_table_free;
 
   return &ret->root.root;
 }
@@ -529,12 +533,15 @@ stub_hash_newfunc (struct bfd_hash_entry *entry,
 bfd_boolean
 elf32_xgate_add_symbol_hook (bfd *abfd ATTRIBUTE_UNUSED,
                             struct bfd_link_info *info ATTRIBUTE_UNUSED,
-                            Elf_Internal_Sym *sym ATTRIBUTE_UNUSED,
+                            Elf_Internal_Sym *sym,
                             const char **namep ATTRIBUTE_UNUSED,
                             flagword *flagsp ATTRIBUTE_UNUSED,
                             asection **secp ATTRIBUTE_UNUSED,
                             bfd_vma *valp ATTRIBUTE_UNUSED)
 {
+  /* For some reason the st_target_internal value is not retained
+     after xgate_frob_symbol is called, hence this temp hack.  */
+  sym->st_target_internal = 1;
   return TRUE;
 }
 
@@ -649,16 +656,6 @@ _bfd_xgate_elf_set_private_flags (bfd *abfd ATTRIBUTE_UNUSED,
   return TRUE;
 }
 
-/* Merge backend specific data from an object file to the output
-   object file when linking.  */
-
-bfd_boolean
-_bfd_xgate_elf_merge_private_bfd_data (bfd *ibfd ATTRIBUTE_UNUSED,
-                                      bfd *obfd ATTRIBUTE_UNUSED)
-{
-  return TRUE;
-}
-
 bfd_boolean
 _bfd_xgate_elf_print_private_bfd_data (bfd *abfd, void *ptr)
 {
@@ -696,34 +693,32 @@ elf32_xgate_post_process_headers (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_in
 
 }
 
-#define ELF_ARCH                             bfd_arch_xgate
-#define ELF_MACHINE_CODE                     EM_XGATE
-#define ELF_TARGET_ID                        XGATE_ELF_DATA
+#define ELF_ARCH                            bfd_arch_xgate
+#define ELF_MACHINE_CODE                    EM_XGATE
+#define ELF_TARGET_ID                       XGATE_ELF_DATA
 
-#define ELF_MAXPAGESIZE                      0x1000
+#define ELF_MAXPAGESIZE                             0x1000
 
-#define TARGET_BIG_SYM                       bfd_elf32_xgate_vec
-#define TARGET_BIG_NAME                      "elf32-xgate"
+#define TARGET_BIG_SYM                      xgate_elf32_vec
+#define TARGET_BIG_NAME                             "elf32-xgate"
 
-#define elf_info_to_howto                    0
-#define elf_info_to_howto_rel                xgate_info_to_howto_rel
-#define elf_backend_check_relocs             elf32_xgate_check_relocs
-#define elf_backend_relocate_section         elf32_xgate_relocate_section
-#define elf_backend_object_p                 xgate_elf_set_mach_from_flags
+#define elf_info_to_howto                   0
+#define elf_info_to_howto_rel               xgate_info_to_howto_rel
+#define elf_backend_check_relocs            elf32_xgate_check_relocs
+#define elf_backend_relocate_section        elf32_xgate_relocate_section
+#define elf_backend_object_p                xgate_elf_set_mach_from_flags
 #define elf_backend_final_write_processing   0
-#define elf_backend_can_gc_sections          1
-#define elf_backend_special_sections         elf32_xgate_special_sections
+#define elf_backend_can_gc_sections         1
+#define elf_backend_special_sections        elf32_xgate_special_sections
 #define elf_backend_post_process_headers     elf32_xgate_post_process_headers
-#define elf_backend_add_symbol_hook          elf32_xgate_add_symbol_hook
+#define elf_backend_add_symbol_hook         elf32_xgate_add_symbol_hook
 
 #define bfd_elf32_bfd_link_hash_table_create xgate_elf_bfd_link_hash_table_create
-#define bfd_elf32_bfd_link_hash_table_free   xgate_elf_bfd_link_hash_table_free
-#define bfd_elf32_bfd_merge_private_bfd_data _bfd_xgate_elf_merge_private_bfd_data
-#define bfd_elf32_bfd_set_private_flags      _bfd_xgate_elf_set_private_flags
+#define bfd_elf32_bfd_set_private_flags             _bfd_xgate_elf_set_private_flags
 #define bfd_elf32_bfd_print_private_bfd_data _bfd_xgate_elf_print_private_bfd_data
 
 #define xgate_stub_hash_lookup(table, string, create, copy)    \
     ((struct elf32_xgate_stub_hash_entry *) \
-        bfd_hash_lookup ((table), (string), (create), (copy)))
+       bfd_hash_lookup ((table), (string), (create), (copy)))
 
 #include "elf32-target.h"
This page took 0.032979 seconds and 4 git commands to generate.