Handle R_X86_64_64 properly for x32
[deliverable/binutils-gdb.git] / bfd / elf32-dlx.c
index b1f6257641c2db0460946305d797840a90f0a9aa..29b89104e9e776eb3e81985d7bb88eaff073b8f8 100644 (file)
@@ -1,11 +1,12 @@
 /* DLX specific support for 32-bit ELF
 /* DLX specific support for 32-bit ELF
-   Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2011
+   Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -18,8 +19,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/dlx.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/dlx.h"
@@ -27,6 +28,7 @@
 #define USE_REL 1
 
 #define bfd_elf32_bfd_reloc_type_lookup elf32_dlx_reloc_type_lookup
 #define USE_REL 1
 
 #define bfd_elf32_bfd_reloc_type_lookup elf32_dlx_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup elf32_dlx_reloc_name_lookup
 #define elf_info_to_howto               elf32_dlx_info_to_howto
 #define elf_info_to_howto_rel           elf32_dlx_info_to_howto_rel
 #define elf_backend_check_relocs        elf32_dlx_check_relocs
 #define elf_info_to_howto               elf32_dlx_info_to_howto
 #define elf_info_to_howto_rel           elf32_dlx_info_to_howto_rel
 #define elf_backend_check_relocs        elf32_dlx_check_relocs
@@ -137,9 +139,8 @@ elf32_dlx_relocate16 (bfd *abfd,
   /* Can not support a long jump to sections other then .text.  */
   if (strcmp (input_section->name, symbol->section->output_section->name) != 0)
     {
   /* Can not support a long jump to sections other then .text.  */
   if (strcmp (input_section->name, symbol->section->output_section->name) != 0)
     {
-      fprintf (stderr,
-              "BFD Link Error: branch (PC rel16) to section (%s) not supported\n",
-              symbol->section->output_section->name);
+      (*_bfd_error_handler) (_("BFD Link Error: branch (PC rel16) to section (%s) not supported"),
+                            symbol->section->output_section->name);
       return bfd_reloc_undefined;
     }
 
       return bfd_reloc_undefined;
     }
 
@@ -200,9 +201,8 @@ elf32_dlx_relocate26 (bfd *abfd,
   /* Can not support a long jump to sections other then .text   */
   if (strcmp (input_section->name, symbol->section->output_section->name) != 0)
     {
   /* Can not support a long jump to sections other then .text   */
   if (strcmp (input_section->name, symbol->section->output_section->name) != 0)
     {
-      fprintf (stderr,
-              "BFD Link Error: jump (PC rel26) to section (%s) not supported\n",
-              symbol->section->output_section->name);
+      (*_bfd_error_handler) (_("BFD Link Error: jump (PC rel26) to section (%s) not supported"),
+                            symbol->section->output_section->name);
       return bfd_reloc_undefined;
     }
 
       return bfd_reloc_undefined;
     }
 
@@ -426,7 +426,7 @@ elf32_dlx_check_relocs (bfd *abfd,
                        const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
                        const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
-  struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+  struct elf_link_hash_entry **sym_hashes;
   const Elf_Internal_Rela *rel;
   const Elf_Internal_Rela *rel_end;
 
   const Elf_Internal_Rela *rel;
   const Elf_Internal_Rela *rel_end;
 
@@ -435,9 +435,6 @@ elf32_dlx_check_relocs (bfd *abfd,
 
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
 
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
-  sym_hashes_end = sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
-  if (!elf_bad_symtab (abfd))
-    sym_hashes_end -= symtab_hdr->sh_info;
 
   rel_end = relocs + sec->reloc_count;
   for (rel = relocs; rel < rel_end; rel++)
 
   rel_end = relocs + sec->reloc_count;
   for (rel = relocs; rel < rel_end; rel++)
@@ -468,7 +465,9 @@ elf32_dlx_check_relocs (bfd *abfd,
         /* This relocation describes which C++ vtable entries are actually
            used.  Record for later use during GC.  */
         case R_DLX_GNU_VTENTRY:
         /* This relocation describes which C++ vtable entries are actually
            used.  Record for later use during GC.  */
         case R_DLX_GNU_VTENTRY:
-          if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+          BFD_ASSERT (h != NULL);
+          if (h != NULL
+              && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
             return FALSE;
           break;
         }
             return FALSE;
           break;
         }
@@ -505,6 +504,31 @@ elf32_dlx_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
     }
 }
 
     }
 }
 
+static reloc_howto_type *
+elf32_dlx_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                            const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < sizeof (dlx_elf_howto_table) / sizeof (dlx_elf_howto_table[0]);
+       i++)
+    if (dlx_elf_howto_table[i].name != NULL
+       && strcasecmp (dlx_elf_howto_table[i].name, r_name) == 0)
+      return &dlx_elf_howto_table[i];
+
+  if (strcasecmp (elf_dlx_gnu_rel16_s2.name, r_name) == 0)
+    return &elf_dlx_gnu_rel16_s2;
+  if (strcasecmp (elf_dlx_gnu_rel26_s2.name, r_name) == 0)
+    return &elf_dlx_gnu_rel26_s2;
+  if (strcasecmp (elf_dlx_reloc_16_hi.name, r_name) == 0)
+    return &elf_dlx_reloc_16_hi;
+  if (strcasecmp (elf_dlx_reloc_16_lo.name, r_name) == 0)
+    return &elf_dlx_reloc_16_lo;
+
+  return NULL;
+}
+
 static reloc_howto_type *
 dlx_rtype_to_howto (unsigned int r_type)
 {
 static reloc_howto_type *
 dlx_rtype_to_howto (unsigned int r_type)
 {
This page took 0.02797 seconds and 4 git commands to generate.