*** empty log message ***
[binutils-gdb.git] / bfd / pdp11.c
index 9f3942bc1caca55eece5f034217b1eb3a02612fa..faf7a689e88b81ebf3c7c22434307fb5fa8f4672 100644 (file)
@@ -1,11 +1,12 @@
 /* BFD back-end for PDP-11 a.out binaries.
-   Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+   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,
@@ -15,7 +16,9 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02110-1301, USA. */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA. */
+
 
 /* BFD backend for PDP-11, running 2.11BSD in particular.
 
 #define N_FLAGS(exec)          0
 
 #define N_SET_FLAGS(exec, flags) do { } while (0)
-#define N_BADMAG(x) (((x).a_info != OMAGIC)   \
-                 && ((x).a_info != NMAGIC)   \
-                 && ((x).a_info != A_MAGIC3) \
-                 && ((x).a_info != A_MAGIC4) \
-                 && ((x).a_info != A_MAGIC5) \
-                 && ((x).a_info != A_MAGIC6))
+#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC      \
+                    && N_MAGIC(x) != NMAGIC    \
+                    && N_MAGIC(x) != ZMAGIC)
 
+#include "sysdep.h"
 #include "bfd.h"
 
 #define external_exec pdp11_external_exec
@@ -122,7 +123,6 @@ struct pdp11_external_nlist
 
 #define WRITE_HEADERS(abfd, execp) pdp11_aout_write_headers (abfd, execp)
 
-#include "sysdep.h"
 #include "libbfd.h"
 #include "libaout.h"
 
@@ -276,6 +276,22 @@ NAME (aout, reloc_type_lookup) (bfd * abfd ATTRIBUTE_UNUSED,
     }
 }
 
+reloc_howto_type *
+NAME (aout, reloc_name_lookup) (bfd *abfd ATTRIBUTE_UNUSED,
+                                     const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < sizeof (howto_table_pdp11) / sizeof (howto_table_pdp11[0]);
+       i++)
+    if (howto_table_pdp11[i].name != NULL
+       && strcasecmp (howto_table_pdp11[i].name, r_name) == 0)
+      return &howto_table_pdp11[i];
+
+  return NULL;
+}
+
 static int
 pdp11_aout_write_headers (bfd *abfd, struct internal_exec *execp)
 {
@@ -488,19 +504,12 @@ NAME (aout, some_aout_object_p) (bfd *abfd,
       abfd->flags |= D_PAGED | WP_TEXT;
       adata (abfd).magic = z_magic;
     }
-  else if (N_MAGIC (*execp) == QMAGIC)
-    {
-      abfd->flags |= D_PAGED | WP_TEXT;
-      adata (abfd).magic = z_magic;
-      adata (abfd).subformat = q_magic_format;
-    }
   else if (N_MAGIC (*execp) == NMAGIC)
     {
       abfd->flags |= WP_TEXT;
       adata (abfd).magic = n_magic;
     }
-  else if (N_MAGIC (*execp) == OMAGIC
-          || N_MAGIC (*execp) == BMAGIC)
+  else if (N_MAGIC (*execp) == OMAGIC)
     adata (abfd).magic = o_magic;
   else
     {
@@ -719,10 +728,6 @@ NAME (aout, machine_type) (enum bfd_architecture arch,
        arch_flags = M_386;
       break;
 
-    case bfd_arch_a29k:
-      if (machine == 0)        arch_flags = M_29K;
-      break;
-
     case bfd_arch_arm:
       if (machine == 0)        arch_flags = M_ARM;
       break;
@@ -943,10 +948,7 @@ adjust_z_magic (bfd *abfd, struct internal_exec *execp)
   execp->a_text = obj_textsec(abfd)->size;
   if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted)))
     execp->a_text += adata(abfd).exec_bytes_size;
-  if (obj_aout_subformat (abfd) == q_magic_format)
-    N_SET_MAGIC (*execp, QMAGIC);
-  else
-    N_SET_MAGIC (*execp, ZMAGIC);
+  N_SET_MAGIC (*execp, ZMAGIC);
 
   /* Spec says data section should be rounded up to page boundary.  */
   obj_datasec(abfd)->size
@@ -1114,32 +1116,27 @@ NAME (aout, new_section_hook) (bfd *abfd, asection *newsect)
   if (bfd_get_format (abfd) == bfd_object)
     {
       if (obj_textsec (abfd) == NULL
-         && ! strcmp (newsect->name, ".text"))
+         && !strcmp (newsect->name, ".text"))
        {
          obj_textsec(abfd)= newsect;
          newsect->target_index = N_TEXT;
-         return TRUE;
        }
-
-    if (obj_datasec (abfd) == NULL
-       && ! strcmp (newsect->name, ".data"))
-      {
-       obj_datasec (abfd) = newsect;
-       newsect->target_index = N_DATA;
-       return TRUE;
-      }
-
-    if (obj_bsssec (abfd) == NULL
-       && !strcmp (newsect->name, ".bss"))
-      {
-       obj_bsssec (abfd) = newsect;
-       newsect->target_index = N_BSS;
-       return TRUE;
-      }
-  }
+      else if (obj_datasec (abfd) == NULL
+              && !strcmp (newsect->name, ".data"))
+       {
+         obj_datasec (abfd) = newsect;
+         newsect->target_index = N_DATA;
+       }
+      else if (obj_bsssec (abfd) == NULL
+              && !strcmp (newsect->name, ".bss"))
+       {
+         obj_bsssec (abfd) = newsect;
+         newsect->target_index = N_BSS;
+       }
+    }
 
   /* We allow more than three sections internally.  */
-  return TRUE;
+  return _bfd_generic_new_section_hook (abfd, newsect);
 }
 
 bfd_boolean
@@ -2379,7 +2376,8 @@ NAME (aout, find_nearest_line) (bfd *abfd,
 }
 
 int
-NAME (aout, sizeof_headers) (bfd *abfd, bfd_boolean execable ATTRIBUTE_UNUSED)
+NAME (aout, sizeof_headers) (bfd *abfd,
+                            struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   return adata (abfd).exec_bytes_size;
 }
@@ -2450,9 +2448,10 @@ NAME (aout, link_hash_table_init) (struct aout_link_hash_table *table,
                                   bfd *abfd,
                                   struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
                                                                     struct bfd_hash_table *,
-                                                                    const char *))
+                                                                    const char *),
+                                  unsigned int entsize)
 {
-  return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+  return _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize);
 }
 
 /* Create an a.out link hash table.  */
@@ -2467,7 +2466,8 @@ NAME (aout, link_hash_table_create) (bfd *abfd)
   if (ret == NULL)
     return NULL;
   if (! NAME (aout, link_hash_table_init) (ret, abfd,
-                                          NAME (aout, link_hash_newfunc)))
+                                          NAME (aout, link_hash_newfunc),
+                                          sizeof (struct aout_link_hash_entry)))
     {
       free (ret);
       return NULL;
@@ -3661,9 +3661,10 @@ NAME (aout, final_link) (bfd *abfd,
   aout_info.symbol_map = NULL;
   aout_info.output_syms = NULL;
 
-  if (! bfd_hash_table_init_n (&aout_info.includes.root,
-                              aout_link_includes_newfunc,
-                              251))
+  if (!bfd_hash_table_init_n (&aout_info.includes.root,
+                             aout_link_includes_newfunc,
+                             sizeof (struct aout_link_includes_entry),
+                             251))
     goto error_return;
   includes_hash_initialized = TRUE;
 
@@ -3726,11 +3727,11 @@ NAME (aout, final_link) (bfd *abfd,
     {
       if (obj_textsec (abfd) != NULL)
        trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
-                                                ->link_order_head)
+                                                ->map_head.link_order)
                   * obj_reloc_entry_size (abfd));
       if (obj_datasec (abfd) != NULL)
        drsize += (_bfd_count_link_order_relocs (obj_datasec (abfd)
-                                                ->link_order_head)
+                                                ->map_head.link_order)
                   * obj_reloc_entry_size (abfd));
     }
 
@@ -3821,7 +3822,7 @@ NAME (aout, final_link) (bfd *abfd,
      include.  */
   for (o = abfd->sections; o != NULL; o = o->next)
     {
-      for (p = o->link_order_head; p != NULL; p = p->next)
+      for (p = o->map_head.link_order; p != NULL; p = p->next)
        if (p->type == bfd_indirect_link_order)
          p->u.indirect.section->linker_mark = TRUE;
     }
@@ -3829,7 +3830,7 @@ NAME (aout, final_link) (bfd *abfd,
   have_link_order_relocs = FALSE;
   for (o = abfd->sections; o != NULL; o = o->next)
     {
-      for (p = o->link_order_head;
+      for (p = o->map_head.link_order;
           p != NULL;
           p = p->next)
        {
@@ -3872,7 +3873,7 @@ NAME (aout, final_link) (bfd *abfd,
     {
       for (o = abfd->sections; o != NULL; o = o->next)
        {
-         for (p = o->link_order_head;
+         for (p = o->map_head.link_order;
               p != NULL;
               p = p->next)
            {