2007-07-27 Michael Snyder <msnyder@access-company.com>
[binutils-gdb.git] / bfd / elf32-dlx.c
index ae42baf3a632c424b3b7088c9704a64fb4497f68..eebacebe865bcbfdd3af9548bbd721c27e2eedf5 100644 (file)
@@ -1,11 +1,12 @@
 /* DLX specific support for 32-bit ELF
-   Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright 2002, 2003, 2004, 2005, 2007
+   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
-   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,
@@ -18,8 +19,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.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 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
@@ -505,6 +507,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)
 {
@@ -512,21 +539,15 @@ dlx_rtype_to_howto (unsigned int r_type)
     {
     case R_DLX_RELOC_16_PCREL:
       return & elf_dlx_gnu_rel16_s2;
-      break;
     case R_DLX_RELOC_26_PCREL:
       return & elf_dlx_gnu_rel26_s2;
-      break;
     case R_DLX_RELOC_16_HI:
       return & elf_dlx_reloc_16_hi;
-      break;
     case R_DLX_RELOC_16_LO:
       return & elf_dlx_reloc_16_lo;
-      break;
-
     default:
       BFD_ASSERT (r_type < (unsigned int) R_DLX_max);
       return & dlx_elf_howto_table[r_type];
-      break;
     }
 }