2005-02-14 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / bfd / pdp11.c
index 95d78a1103dcbeefa0e685d3b7dbea185ab2a0fe..20e9bf3cf5829958535931b87f26d7ac49eb70ac 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for PDP-11 a.out binaries.
-   Copyright 2001, 2002 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -134,9 +134,9 @@ struct pdp11_external_nlist
 static bfd_boolean MY(write_object_contents) PARAMS ((bfd *abfd));
 #define MY_text_includes_header 1
 
-bfd_vma                bfd_getp32         PARAMS ((const bfd_byte *));
-bfd_signed_vma bfd_getp_signed_32 PARAMS ((const bfd_byte *));
-void           bfd_putp32         PARAMS ((bfd_vma, bfd_byte *));
+static bfd_vma bfd_getp32 (const void *);
+static bfd_signed_vma bfd_getp_signed_32 (const void *);
+static void bfd_putp32 (bfd_vma, void *);
 
 #define MY_BFD_TARGET
 
@@ -341,11 +341,6 @@ DESCRIPTION
 
 #define RELOC_SIZE 2
 
-struct pdp11_aout_reloc_external
-{
-  bfd_byte e_reloc_entry[2];
-};
-
 #define RELFLG         0x0001  /* pc-relative flag */
 #define RTYPE          0x000e  /* type mask */
 #define RIDXMASK       0xfff0  /* index mask */
@@ -368,9 +363,9 @@ static void adjust_z_magic PARAMS ((bfd *, struct internal_exec *));
 static void adjust_n_magic PARAMS ((bfd *, struct internal_exec *));
 
 static int pdp11_aout_write_headers PARAMS ((bfd *, struct internal_exec *));
-void pdp11_aout_swap_reloc_out PARAMS  ((bfd *, arelent *, struct pdp11_aout_reloc_external *));
+void pdp11_aout_swap_reloc_out PARAMS  ((bfd *, arelent *, bfd_byte *));
 void pdp11_aout_swap_reloc_in
-PARAMS ((bfd *, struct pdp11_aout_reloc_external *, arelent *,
+PARAMS ((bfd *, bfd_byte *, arelent *,
         bfd_size_type, asymbol **, bfd_size_type));
 
 /*
@@ -741,8 +736,8 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
   if (! NAME(aout,make_sections) (abfd))
     return NULL;
 
-  obj_datasec (abfd)->_raw_size = execp->a_data;
-  obj_bsssec (abfd)->_raw_size = execp->a_bss;
+  obj_datasec (abfd)->size = execp->a_data;
+  obj_bsssec (abfd)->size = execp->a_bss;
 
   obj_textsec (abfd)->flags =
     (execp->a_trsize != 0
@@ -768,7 +763,6 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
   struct exec *execp = exec_hdr (abfd);
 
   obj_textsec (abfd)->size = N_TXTSIZE(*execp);
-  obj_textsec (abfd)->raw_size = N_TXTSIZE(*execp);
   /* data and bss are already filled in since they're so standard */
 
   /* The virtual memory addresses of the sections */
@@ -826,7 +820,7 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
 
   if (execp->a_entry != 0
       || (execp->a_entry >= obj_textsec(abfd)->vma
-         && execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))
+         && execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->size))
     abfd->flags |= EXEC_P;
 #ifdef STAT_FOR_EXEC
   else
@@ -848,15 +842,7 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
     }
 #endif /* STAT_FOR_EXEC */
 
-  if (result)
-    {
-#if 0 /* These should be set correctly anyways.  */
-      abfd->sections = obj_textsec (abfd);
-      obj_textsec (abfd)->next = obj_datasec (abfd);
-      obj_datasec (abfd)->next = obj_bsssec (abfd);
-#endif
-    }
-  else
+  if (!result)
     {
       free (rawptr);
       abfd->tdata.aout_data = oldrawptr;
@@ -1074,16 +1060,13 @@ adjust_o_magic (abfd, execp)
   else
     vma = obj_textsec (abfd)->vma;
 
-  pos += obj_textsec (abfd)->_raw_size;
-  vma += obj_textsec (abfd)->_raw_size;
+  pos += obj_textsec (abfd)->size;
+  vma += obj_textsec (abfd)->size;
 
   /* Data.  */
   if (!obj_datasec (abfd)->user_set_vma)
     {
-#if 0      /* ?? Does alignment in the file image really matter? */
-      pad = align_power (vma, obj_datasec (abfd)->alignment_power) - vma;
-#endif
-      obj_textsec (abfd)->_raw_size += pad;
+      obj_textsec (abfd)->size += pad;
       pos += pad;
       vma += pad;
       obj_datasec (abfd)->vma = vma;
@@ -1091,16 +1074,13 @@ adjust_o_magic (abfd, execp)
   else
     vma = obj_datasec (abfd)->vma;
   obj_datasec (abfd)->filepos = pos;
-  pos += obj_datasec (abfd)->_raw_size;
-  vma += obj_datasec (abfd)->_raw_size;
+  pos += obj_datasec (abfd)->size;
+  vma += obj_datasec (abfd)->size;
 
   /* BSS.  */
   if (! obj_bsssec (abfd)->user_set_vma)
     {
-#if 0
-      pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma;
-#endif
-      obj_datasec (abfd)->_raw_size += pad;
+      obj_datasec (abfd)->size += pad;
       pos += pad;
       vma += pad;
       obj_bsssec (abfd)->vma = vma;
@@ -1113,16 +1093,16 @@ adjust_o_magic (abfd, execp)
       pad = obj_bsssec (abfd)->vma - vma;
       if (pad > 0)
        {
-         obj_datasec (abfd)->_raw_size += pad;
+         obj_datasec (abfd)->size += pad;
          pos += pad;
        }
     }
   obj_bsssec (abfd)->filepos = pos;
 
   /* Fix up the exec header.  */
-  execp->a_text = obj_textsec (abfd)->_raw_size;
-  execp->a_data = obj_datasec (abfd)->_raw_size;
-  execp->a_bss  = obj_bsssec (abfd)->_raw_size;
+  execp->a_text = obj_textsec (abfd)->size;
+  execp->a_data = obj_datasec (abfd)->size;
+  execp->a_bss  = obj_bsssec (abfd)->size;
   N_SET_MAGIC (*execp, OMAGIC);
 }
 
@@ -1172,7 +1152,7 @@ adjust_z_magic (abfd, execp)
   /* Find start of data.  */
   if (ztih)
     {
-      text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->_raw_size;
+      text_end = obj_textsec (abfd)->filepos + obj_textsec (abfd)->size;
       text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
     }
   else
@@ -1180,33 +1160,33 @@ adjust_z_magic (abfd, execp)
       /* Note that if page_size == zmagic_disk_block_size, then
         filepos == page_size, and this case is the same as the ztih
         case.  */
-      text_end = obj_textsec (abfd)->_raw_size;
+      text_end = obj_textsec (abfd)->size;
       text_pad += BFD_ALIGN (text_end, adata (abfd).page_size) - text_end;
       text_end += obj_textsec (abfd)->filepos;
     }
 
-  obj_textsec (abfd)->_raw_size += text_pad;
+  obj_textsec (abfd)->size += text_pad;
   text_end += text_pad;
 
   /* Data.  */
   if (!obj_datasec(abfd)->user_set_vma)
     {
       bfd_vma vma;
-      vma = obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size;
+      vma = obj_textsec(abfd)->vma + obj_textsec(abfd)->size;
       obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size);
     }
   if (abdp && abdp->zmagic_mapped_contiguous)
     {
       text_pad = (obj_datasec(abfd)->vma
                  - obj_textsec(abfd)->vma
-                 - obj_textsec(abfd)->_raw_size);
-      obj_textsec(abfd)->_raw_size += text_pad;
+                 - obj_textsec(abfd)->size);
+      obj_textsec(abfd)->size += text_pad;
     }
   obj_datasec (abfd)->filepos = (obj_textsec (abfd)->filepos
-                               + obj_textsec (abfd)->_raw_size);
+                               + obj_textsec (abfd)->size);
 
   /* Fix up exec header while we're at it.  */
-  execp->a_text = obj_textsec(abfd)->_raw_size;
+  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)
@@ -1215,17 +1195,17 @@ adjust_z_magic (abfd, execp)
     N_SET_MAGIC (*execp, ZMAGIC);
 
   /* Spec says data section should be rounded up to page boundary.  */
-  obj_datasec(abfd)->_raw_size
-    = align_power (obj_datasec(abfd)->_raw_size,
+  obj_datasec(abfd)->size
+    = align_power (obj_datasec(abfd)->size,
                   obj_bsssec(abfd)->alignment_power);
-  execp->a_data = BFD_ALIGN (obj_datasec(abfd)->_raw_size,
+  execp->a_data = BFD_ALIGN (obj_datasec(abfd)->size,
                             adata(abfd).page_size);
-  data_pad = execp->a_data - obj_datasec(abfd)->_raw_size;
+  data_pad = execp->a_data - obj_datasec(abfd)->size;
 
   /* BSS.  */
   if (!obj_bsssec(abfd)->user_set_vma)
     obj_bsssec(abfd)->vma = (obj_datasec(abfd)->vma
-                            + obj_datasec(abfd)->_raw_size);
+                            + obj_datasec(abfd)->size);
   /* If the BSS immediately follows the data section and extra space
      in the page is left after the data section, fudge data
      in the header so that the bss section looks smaller by that
@@ -1234,11 +1214,11 @@ adjust_z_magic (abfd, execp)
      could have explicitly set the BSS vma to immediately follow
      the data section.)  */
   if (align_power (obj_bsssec(abfd)->vma, obj_bsssec(abfd)->alignment_power)
-      == obj_datasec(abfd)->vma + obj_datasec(abfd)->_raw_size)
-    execp->a_bss = (data_pad > obj_bsssec(abfd)->_raw_size) ? 0 :
-      obj_bsssec(abfd)->_raw_size - data_pad;
+      == obj_datasec(abfd)->vma + obj_datasec(abfd)->size)
+    execp->a_bss = (data_pad > obj_bsssec(abfd)->size) ? 0 :
+      obj_bsssec(abfd)->size - data_pad;
   else
-    execp->a_bss = obj_bsssec(abfd)->_raw_size;
+    execp->a_bss = obj_bsssec(abfd)->size;
 }
 
 static void
@@ -1256,8 +1236,8 @@ adjust_n_magic (abfd, execp)
     obj_textsec(abfd)->vma = vma;
   else
     vma = obj_textsec(abfd)->vma;
-  pos += obj_textsec(abfd)->_raw_size;
-  vma += obj_textsec(abfd)->_raw_size;
+  pos += obj_textsec(abfd)->size;
+  vma += obj_textsec(abfd)->size;
 
   /* Data.  */
   obj_datasec(abfd)->filepos = pos;
@@ -1266,10 +1246,10 @@ adjust_n_magic (abfd, execp)
   vma = obj_datasec(abfd)->vma;
 
   /* Since BSS follows data immediately, see if it needs alignment.  */
-  vma += obj_datasec(abfd)->_raw_size;
+  vma += obj_datasec(abfd)->size;
   pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma;
-  obj_datasec(abfd)->_raw_size += pad;
-  pos += obj_datasec(abfd)->_raw_size;
+  obj_datasec(abfd)->size += pad;
+  pos += obj_datasec(abfd)->size;
 
   /* BSS.  */
   if (!obj_bsssec(abfd)->user_set_vma)
@@ -1278,9 +1258,9 @@ adjust_n_magic (abfd, execp)
     vma = obj_bsssec(abfd)->vma;
 
   /* Fix up exec header.  */
-  execp->a_text = obj_textsec(abfd)->_raw_size;
-  execp->a_data = obj_datasec(abfd)->_raw_size;
-  execp->a_bss = obj_bsssec(abfd)->_raw_size;
+  execp->a_text = obj_textsec(abfd)->size;
+  execp->a_data = obj_datasec(abfd)->size;
+  execp->a_bss = obj_bsssec(abfd)->size;
   N_SET_MAGIC (*execp, NMAGIC);
 }
 
@@ -1298,11 +1278,11 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
   if (adata(abfd).magic != undecided_magic)
     return TRUE;
 
-  obj_textsec(abfd)->_raw_size =
-    align_power(obj_textsec(abfd)->_raw_size,
+  obj_textsec(abfd)->size =
+    align_power(obj_textsec(abfd)->size,
                obj_textsec(abfd)->alignment_power);
 
-  *text_size = obj_textsec (abfd)->_raw_size;
+  *text_size = obj_textsec (abfd)->size;
   /* Rule (heuristic) for when to pad to a new page.  Note that there
      are (at least) two ways demand-paged (ZMAGIC) files have been
      handled.  Most Berkeley-based systems start the text segment at
@@ -1336,11 +1316,11 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
              }
              str;
            }),
-          obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
+          obj_textsec(abfd)->vma, obj_textsec(abfd)->size,
                obj_textsec(abfd)->alignment_power,
-          obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
+          obj_datasec(abfd)->vma, obj_datasec(abfd)->size,
                obj_datasec(abfd)->alignment_power,
-          obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size,
+          obj_bsssec(abfd)->vma, obj_bsssec(abfd)->size,
                obj_bsssec(abfd)->alignment_power);
 #endif
 #endif
@@ -1362,11 +1342,11 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
 
 #ifdef BFD_AOUT_DEBUG
   fprintf (stderr, "       text=<%x,%x,%x> data=<%x,%x,%x> bss=<%x,%x>\n",
-          obj_textsec(abfd)->vma, obj_textsec(abfd)->_raw_size,
+          obj_textsec(abfd)->vma, obj_textsec(abfd)->size,
                obj_textsec(abfd)->filepos,
-          obj_datasec(abfd)->vma, obj_datasec(abfd)->_raw_size,
+          obj_datasec(abfd)->vma, obj_datasec(abfd)->size,
                obj_datasec(abfd)->filepos,
-          obj_bsssec(abfd)->vma, obj_bsssec(abfd)->_raw_size);
+          obj_bsssec(abfd)->vma, obj_bsssec(abfd)->size);
 #endif
 
   return TRUE;
@@ -1429,7 +1409,7 @@ bfd_boolean
 NAME(aout,set_section_contents) (abfd, section, location, offset, count)
      bfd *abfd;
      sec_ptr section;
-     PTR location;
+     const PTR location;
      file_ptr offset;
      bfd_size_type count;
 {
@@ -1673,9 +1653,8 @@ translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
       /* This case occurs, e.g., for the *DEBUG* section of a COFF
         file.  */
       (*_bfd_error_handler)
-       ("%s: can not represent section for symbol `%s' in a.out object file format",
-        bfd_archive_filename (abfd),
-        cache_ptr->name != NULL ? cache_ptr->name : "*unknown*");
+       ("%B: can not represent section for symbol `%s' in a.out object file format",
+        abfd, cache_ptr->name != NULL ? cache_ptr->name : "*unknown*");
       bfd_set_error (bfd_error_nonrepresentable_section);
       return FALSE;
     }
@@ -1701,8 +1680,8 @@ translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
   else
     {
       (*_bfd_error_handler)
-       ("%s: can not represent section `%s' in a.out object file format",
-        bfd_archive_filename (abfd), bfd_get_section_name (abfd, sec));
+       ("%B: can not represent section `%A' in a.out object file format",
+        abfd, sec);
       bfd_set_error (bfd_error_nonrepresentable_section);
       return FALSE;
     }
@@ -1715,41 +1694,6 @@ translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
   else if ((cache_ptr->flags & BSF_GLOBAL) != 0)
     sym_pointer->e_type[0] |= N_EXT;
 
-#if 0
-  if ((cache_ptr->flags & BSF_CONSTRUCTOR) != 0)
-    {
-      int type = ((aout_symbol_type *) cache_ptr)->type;
-
-
-      switch (type)
-       {
-       case N_ABS:     type = N_SETA; break;
-       case N_TEXT:    type = N_SETT; break;
-       case N_DATA:    type = N_SETD; break;
-       case N_BSS:     type = N_SETB; break;
-       }
-      sym_pointer->e_type[0] = type;
-    }
-#endif
-
-#if 0
-  if ((cache_ptr->flags & BSF_WEAK) != 0)
-    {
-      int type;
-
-      switch (sym_pointer->e_type[0] & N_TYPE)
-       {
-       default:
-       case N_ABS:     type = N_WEAKA; break;
-       case N_TEXT:    type = N_WEAKT; break;
-       case N_DATA:    type = N_WEAKD; break;
-       case N_BSS:     type = N_WEAKB; break;
-       case N_UNDF:    type = N_WEAKU; break;
-       }
-      sym_pointer->e_type[0] = type;
-    }
-#endif
-
   PUT_WORD(abfd, value, sym_pointer->e_value);
 
   return TRUE;
@@ -2008,7 +1952,7 @@ error_return:
 
 \f
 long
-NAME(aout,get_symtab) (abfd, location)
+NAME(aout,canonicalize_symtab) (abfd, location)
      bfd *abfd;
      asymbol **location;
 {
@@ -2034,7 +1978,7 @@ void
 pdp11_aout_swap_reloc_out (abfd, g, natptr)
      bfd *abfd;
      arelent *g;
-     register struct pdp11_aout_reloc_external *natptr;
+     bfd_byte *natptr;
 {
   int r_index;
   int r_pcrel;
@@ -2070,33 +2014,9 @@ pdp11_aout_swap_reloc_out (abfd, g, natptr)
   else
     r_index = (*(g->sym_ptr_ptr))->KEEPIT;
 
-#if 0
-  if (bfd_is_abs_section (bfd_get_section (sym)))
-    {
-      r_extern = 0;
-      r_index = N_ABS;
-      r_type = RABS;
-    }
-  else if ((sym->flags & BSF_SECTION_SYM) == 0)
-    {
-      if (bfd_is_und_section (bfd_get_section (sym))
-         || (sym->flags & BSF_GLOBAL) != 0)
-       r_extern = 1;
-      else
-       r_extern = 0;
-      r_index = (*(g->sym_ptr_ptr))->KEEPIT;
-    }
-  else
-    {
-      /* Just an ordinary section */
-      r_extern = 0;
-      r_index = output_section->target_index;
-    }
-#endif
-
   reloc_entry = r_index << 4 | r_type | r_pcrel;
 
-  PUT_WORD (abfd, reloc_entry, natptr->e_reloc_entry);
+  PUT_WORD (abfd, reloc_entry, natptr);
 }
 
 /* BFD deals internally with all things based from the section they're
@@ -2149,7 +2069,7 @@ void
 pdp11_aout_swap_reloc_in (abfd, bytes, cache_ptr, offset,
                          symbols, symcount)
      bfd *abfd;
-     struct pdp11_aout_reloc_external *bytes;
+     bfd_byte *bytes;
      arelent *cache_ptr;
      bfd_size_type offset;
      asymbol **symbols;
@@ -2196,7 +2116,7 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
      sec_ptr asect;
      asymbol **symbols;
 {
-  struct pdp11_aout_reloc_external *rptr;
+  bfd_byte *rptr;
   bfd_size_type count;
   bfd_size_type reloc_size;
   PTR relocs;
@@ -2262,16 +2182,14 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
 
   cache_ptr = reloc_cache;
 
-  rptr = (struct pdp11_aout_reloc_external *) relocs;
+  rptr = relocs;
   for (counter = 0;
        counter < count;
-       counter++, ((char *)rptr) += RELOC_SIZE, cache_ptr++)
+       counter++, rptr += RELOC_SIZE, cache_ptr++)
     {
       while (GET_WORD (abfd, (PTR)rptr) == 0)
        {
-         rptr =
-           (struct pdp11_aout_reloc_external *)
-           ((char *) rptr + RELOC_SIZE);
+         rptr += RELOC_SIZE;
          if ((char *) rptr >= (char *) relocs + reloc_size)
            goto done;
        }
@@ -2306,15 +2224,7 @@ NAME(aout,squirt_out_relocs) (abfd, section)
   unsigned int count = section->reloc_count;
   bfd_size_type natsize;
 
-#if 0
-  /* If we're writing an .o file, we must write
-     relocation information, even if there is none. */
-  if ((count == 0 || section->orelocation == NULL) &&
-      <writing_executable>)
-    return TRUE;
-#endif
-
-  natsize = bfd_get_section_size_before_reloc (section);
+  natsize = section->size;
   native = (unsigned char *) bfd_zalloc (abfd, natsize);
   if (!native)
     return FALSE;
@@ -2324,10 +2234,9 @@ NAME(aout,squirt_out_relocs) (abfd, section)
     {
       while (count > 0)
        {
-         struct pdp11_aout_reloc_external *r;
+         bfd_byte *r;
 
-         r = (struct pdp11_aout_reloc_external *)
-           (native + (*generic)->address);
+         r = native + (*generic)->address;
          pdp11_aout_swap_reloc_out (abfd, *generic, r);
          count--;
          generic++;
@@ -2469,7 +2378,6 @@ NAME(aout,get_symbol_info) (abfd, symbol, ret)
     }
 }
 
-/*ARGSUSED*/
 void
 NAME(aout,print_symbol) (abfd, afile, symbol, how)
      bfd * abfd;
@@ -3196,12 +3104,6 @@ aout_link_add_symbols (abfd, info)
 
       type = H_GET_8 (abfd, p->e_type);
 
-#if 0 /* not supported in PDP-11 a.out */
-      /* Ignore debugging symbols.  */
-      if ((type & N_STAB) != 0)
-       continue;
-#endif
-
       name = strings + GET_WORD (abfd, p->e_strx);
       value = GET_WORD (abfd, p->e_value);
       flags = BSF_GLOBAL;
@@ -3357,7 +3259,7 @@ static bfd_boolean pdp11_aout_link_input_section
   PARAMS ((struct aout_final_link_info *finfo,
           bfd *input_bfd,
           asection *input_section,
-          struct pdp11_aout_reloc_external *relocs,
+          bfd_byte *relocs,
           bfd_size_type rel_size,
           bfd_byte *contents));
 
@@ -3436,7 +3338,7 @@ NAME(aout,final_link) (abfd, info, callback)
   includes_hash_initialized = TRUE;
 
   /* Figure out the largest section size.  Also, if generating
-     relocateable output, count the relocs.  */
+     relocatable output, count the relocs.  */
   trsize = 0;
   drsize = 0;
   max_contents_size = 0;
@@ -3446,7 +3348,7 @@ NAME(aout,final_link) (abfd, info, callback)
     {
       size_t sz;
 
-      if (info->relocateable)
+      if (info->relocatable)
        {
          if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
            {
@@ -3460,7 +3362,7 @@ NAME(aout,final_link) (abfd, info, callback)
                 work out the number of relocs needed, and then multiply
                 by the reloc size.  */
              (*_bfd_error_handler)
-               ("%s: relocateable link from %s to %s not supported",
+               ("%s: relocatable link from %s to %s not supported",
                 bfd_get_filename (abfd),
                 sub->xvec->name, abfd->xvec->name);
              bfd_set_error (bfd_error_invalid_operation);
@@ -3470,10 +3372,10 @@ NAME(aout,final_link) (abfd, info, callback)
 
       if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
        {
-         sz = bfd_section_size (sub, obj_textsec (sub));
+         sz = obj_textsec (sub)->size;
          if (sz > max_contents_size)
            max_contents_size = sz;
-         sz = bfd_section_size (sub, obj_datasec (sub));
+         sz = obj_datasec (sub)->size;
          if (sz > max_contents_size)
            max_contents_size = sz;
 
@@ -3490,7 +3392,7 @@ NAME(aout,final_link) (abfd, info, callback)
        }
     }
 
-  if (info->relocateable)
+  if (info->relocatable)
     {
       if (obj_textsec (abfd) != (asection *) NULL)
        trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
@@ -4425,7 +4327,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
   PTR relocs;
 
   /* Get the section contents.  */
-  input_size = bfd_section_size (input_bfd, input_section);
+  input_size = input_section->size;
   if (! bfd_get_section_contents (input_bfd, input_section,
                                  (PTR) finfo->contents,
                                  (file_ptr) 0, input_size))
@@ -4448,7 +4350,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
 
   /* Relocate the section contents.  */
   if (! pdp11_aout_link_input_section (finfo, input_bfd, input_section,
-                                      (struct pdp11_aout_reloc_external *) relocs,
+                                      (bfd_byte *) relocs,
                                       rel_size, finfo->contents))
     return FALSE;
 
@@ -4460,9 +4362,9 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
                                  input_size))
     return FALSE;
 
-  /* If we are producing relocateable output, the relocs were
+  /* If we are producing relocatable output, the relocs were
      modified, and we now write them out.  */
-  if (finfo->info->relocateable && rel_size > 0)
+  if (finfo->info->relocatable && rel_size > 0)
     {
       if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
        return FALSE;
@@ -4512,7 +4414,7 @@ pdp11_aout_link_input_section (finfo, input_bfd, input_section, relocs,
      struct aout_final_link_info *finfo;
      bfd *input_bfd;
      asection *input_section;
-     struct pdp11_aout_reloc_external *relocs;
+     bfd_byte *relocs;
      bfd_size_type rel_size;
      bfd_byte *contents;
 {
@@ -4521,14 +4423,14 @@ pdp11_aout_link_input_section (finfo, input_bfd, input_section, relocs,
             struct aout_link_hash_entry *, PTR, bfd_byte *, bfd_boolean *,
             bfd_vma *));
   bfd *output_bfd;
-  bfd_boolean relocateable;
+  bfd_boolean relocatable;
   struct external_nlist *syms;
   char *strings;
   struct aout_link_hash_entry **sym_hashes;
   int *symbol_map;
   bfd_size_type reloc_count;
-  register struct pdp11_aout_reloc_external *rel;
-  struct pdp11_aout_reloc_external *rel_end;
+  bfd_byte *rel;
+  bfd_byte *rel_end;
 
   output_bfd = finfo->output_bfd;
   check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
@@ -4537,7 +4439,7 @@ pdp11_aout_link_input_section (finfo, input_bfd, input_section, relocs,
   BFD_ASSERT (input_bfd->xvec->header_byteorder
              == output_bfd->xvec->header_byteorder);
 
-  relocateable = finfo->info->relocateable;
+  relocatable = finfo->info->relocatable;
   syms = obj_aout_external_syms (input_bfd);
   strings = obj_aout_external_strings (input_bfd);
   sym_hashes = obj_aout_sym_hashes (input_bfd);
@@ -4545,8 +4447,8 @@ pdp11_aout_link_input_section (finfo, input_bfd, input_section, relocs,
 
   reloc_count = rel_size / RELOC_SIZE;
   rel = relocs;
-  rel_end = (struct pdp11_aout_reloc_external *)(((char *)rel) + rel_size);
-  for (; rel < rel_end; ((char *)rel) += RELOC_SIZE)
+  rel_end = rel + rel_size;
+  for (; rel < rel_end; rel += RELOC_SIZE)
     {
       bfd_vma r_addr;
       int r_index;
@@ -4578,9 +4480,9 @@ pdp11_aout_link_input_section (finfo, input_bfd, input_section, relocs,
        howto = howto_table_pdp11 + howto_idx;
       }
 
-      if (relocateable)
+      if (relocatable)
        {
-         /* We are generating a relocateable output file, and must
+         /* We are generating a relocatable output file, and must
             modify the reloc accordingly.  */
          if (r_extern)
            {
@@ -4654,10 +4556,10 @@ pdp11_aout_link_input_section (finfo, input_bfd, input_section, relocs,
                }
 
              /* Write out the new r_index value.  */
-             reloc_entry = GET_WORD (input_bfd, rel->e_reloc_entry);
+             reloc_entry = GET_WORD (input_bfd, rel);
              reloc_entry &= RIDXMASK;
              reloc_entry |= r_index << 4;
-             PUT_WORD (input_bfd, reloc_entry, rel->e_reloc_entry);
+             PUT_WORD (input_bfd, reloc_entry, rel);
            }
          else
            {
@@ -4672,13 +4574,7 @@ pdp11_aout_link_input_section (finfo, input_bfd, input_section, relocs,
            }
 
          /* Change the address of the relocation.  */
-#if 0
-         PUT_WORD (output_bfd,
-                   r_addr + input_section->output_offset,
-                   rel->r_address);
-#else
-fprintf (stderr, "TODO: change the address of the relocation\n");
-#endif
+         fprintf (stderr, "TODO: change the address of the relocation\n");
 
          /* Adjust a PC relative relocation by removing the reference
             to the original address in the section and including the
@@ -4786,7 +4682,7 @@ fprintf (stderr, "TODO: change the address of the relocation\n");
                const char *name;
 
                if (h != NULL)
-                 name = h->root.root.string;
+                 name = NULL;
                else if (r_extern)
                  name = strings + GET_WORD (input_bfd,
                                             syms[r_index].e_strx);
@@ -4798,8 +4694,9 @@ fprintf (stderr, "TODO: change the address of the relocation\n");
                    name = bfd_section_name (input_bfd, s);
                  }
                if (! ((*finfo->info->callbacks->reloc_overflow)
-                      (finfo->info, name, howto->name,
-                       (bfd_vma) 0, input_bfd, input_section, r_addr)))
+                      (finfo->info, (h ? &h->root : NULL), name,
+                       howto->name, (bfd_vma) 0, input_bfd,
+                       input_section, r_addr)))
                  return FALSE;
              }
              break;
@@ -4965,7 +4862,7 @@ aout_link_reloc_link_order (finfo, o, p)
          abort ();
        case bfd_reloc_overflow:
          if (! ((*finfo->info->callbacks->reloc_overflow)
-                (finfo->info,
+                (finfo->info, NULL,
                  (p->type == bfd_section_reloc_link_order
                   ? bfd_section_name (finfo->output_bfd,
                                       pr->u.section)
@@ -5005,31 +4902,38 @@ aout_link_reloc_link_order (finfo, o, p)
 }
 /* end of modified aoutx.h */
 
-bfd_vma
-bfd_getp32 (addr)
-     const bfd_byte *addr;
+static bfd_vma
+bfd_getp32 (const void *p)
 {
-  return (((((bfd_vma)addr[1] << 8) | addr[0]) << 8)
-         | addr[3]) << 8 | addr[2];
+  const bfd_byte *addr = p;
+  unsigned long v;
+  v = (unsigned long) addr[1] << 24;
+  v |= (unsigned long) addr[0] << 16;
+  v |= (unsigned long) addr[3] << 8;
+  v |= (unsigned long) addr[2];
+  return v;
 }
 
 #define COERCE32(x) (((bfd_signed_vma) (x) ^ 0x80000000) - 0x80000000)
 
-bfd_signed_vma
-bfd_getp_signed_32 (addr)
-     const bfd_byte *addr;
+static bfd_signed_vma
+bfd_getp_signed_32 (const void *p)
 {
-  return COERCE32((((((bfd_vma)addr[1] << 8) | addr[0]) << 8)
-                  | addr[3]) << 8 | addr[2]);
+  const bfd_byte *addr = p;
+  unsigned long v;
+  v = (unsigned long) addr[1] << 24;
+  v |= (unsigned long) addr[0] << 16;
+  v |= (unsigned long) addr[3] << 8;
+  v |= (unsigned long) addr[2];
+  return COERCE32 (v);
 }
 
-void
-bfd_putp32 (data, addr)
-     bfd_vma data;
-     bfd_byte *addr;
+static void
+bfd_putp32 (bfd_vma data, void *p)
 {
-  addr[0] = (bfd_byte)(data >> 16);
-  addr[1] = (bfd_byte)(data >> 24);
-  addr[2] = (bfd_byte)data;
-  addr[3] = (bfd_byte)(data >>  8);
+  bfd_byte *addr = p;
+  addr[0] = (data >> 16) & 0xff;
+  addr[1] = (data >> 24) & 0xff;
+  addr[2] = (data >> 0) & 0xff;
+  addr[3] = (data >> 8) & 0xff;
 }
This page took 0.037215 seconds and 4 git commands to generate.