Fix @pltoff linker segfault for non-shared link.
[deliverable/binutils-gdb.git] / bfd / aoutx.h
index d8b465c47b8c2a3ba0148b01e7f6df25d73c3613..4fa529cf5076889996d9d2e3565a1d64c2f59666 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD semi-generic back-end for a.out binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-   2001, 2002
+   2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -105,9 +105,7 @@ DESCRIPTION
        in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in}
        to use the
        @file{@var{XXX}.mt} file (by setting "<<bfd_target=XXX>>") when your
-       configuration is selected.
-
-*/
+       configuration is selected.  */
 
 /* Some assumptions:
    * Any BFD with D_PAGED set is ZMAGIC, and vice versa.
@@ -157,9 +155,8 @@ DESCRIPTION
        The standard records contain only an
        address, a symbol index, and a type field. The extended records
        (used on 29ks and sparcs) also have a full integer for an
-       addend.
+       addend.  */
 
-*/
 #ifndef CTOR_TABLE_RELOC_HOWTO
 #define CTOR_TABLE_RELOC_IDX 2
 #define CTOR_TABLE_RELOC_HOWTO(BFD)                                    \
@@ -230,7 +227,8 @@ reloc_howto_type howto_table_ext[] =
 
 /* Convert standard reloc records to "arelent" format (incl byte swap).  */
 
-reloc_howto_type howto_table_std[] = {
+reloc_howto_type howto_table_std[] =
+{
   /* type              rs size bsz  pcrel bitpos ovrf                     sf name     part_inpl readmask  setmask    pcdone.  */
 HOWTO ( 0,            0,  0,   8,  FALSE, 0, complain_overflow_bitfield,0,"8",         TRUE, 0x000000ff,0x000000ff, FALSE),
 HOWTO ( 1,            0,  1,   16, FALSE, 0, complain_overflow_bitfield,0,"16",        TRUE, 0x0000ffff,0x0000ffff, FALSE),
@@ -543,8 +541,8 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
   if (! NAME(aout,make_sections) (abfd))
     goto error_ret;
 
-  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
@@ -570,7 +568,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.  */
@@ -634,7 +631,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)))
+                              + obj_textsec (abfd)->size)))
     abfd->flags |= EXEC_P;
 #ifdef STAT_FOR_EXEC
   else
@@ -800,8 +797,10 @@ NAME(aout,machine_type) (arch, machine, unknown)
        case bfd_mach_mips12000:
        case bfd_mach_mips16:
        case bfd_mach_mipsisa32:
+       case bfd_mach_mipsisa32r2:
        case bfd_mach_mips5:
        case bfd_mach_mipsisa64:
+       case bfd_mach_mipsisa64r2:
        case bfd_mach_mips_sb1:
          /* FIXME: These should be MIPS3, MIPS4, MIPS16, MIPS32, etc.  */
          arch_flags = M_MIPS2;
@@ -831,6 +830,10 @@ NAME(aout,machine_type) (arch, machine, unknown)
        arch_flags = M_CRIS;
       break;
 
+    case bfd_arch_m88k:
+      *unknown = FALSE;
+      break;
+
     default:
       arch_flags = M_UNKNOWN;
     }
@@ -907,8 +910,8 @@ 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)
@@ -916,7 +919,7 @@ adjust_o_magic (abfd, execp)
 #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;
@@ -924,8 +927,8 @@ 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)
@@ -933,7 +936,7 @@ adjust_o_magic (abfd, execp)
 #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;
@@ -946,16 +949,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);
 }
 
@@ -1005,7 +1008,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
@@ -1013,18 +1016,18 @@ 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)
@@ -1032,17 +1035,17 @@ adjust_z_magic (abfd, execp)
       asection * text = obj_textsec (abfd);
       asection * data = obj_datasec (abfd);
 
-      text_pad = data->vma - (text->vma + text->_raw_size);
+      text_pad = data->vma - (text->vma + text->size);
       /* Only pad the text section if the data
         section is going to be placed after it.  */
       if (text_pad > 0)
-       text->_raw_size += text_pad;
+       text->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)
@@ -1051,17 +1054,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
@@ -1070,11 +1073,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
@@ -1092,8 +1095,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;
@@ -1102,10 +1105,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)
@@ -1114,9 +1117,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);
 }
 
@@ -1134,11 +1137,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
@@ -1176,11 +1179,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
@@ -1202,11 +1205,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;
@@ -1265,7 +1268,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;
 {
@@ -1580,8 +1583,8 @@ translate_from_native_sym_flags (abfd, cache_ptr)
 
        reloc->next = section->constructor_chain;
        section->constructor_chain = reloc;
-       reloc->relent.address = section->_raw_size;
-       section->_raw_size += BYTES_IN_WORD;
+       reloc->relent.address = section->size;
+       section->size += BYTES_IN_WORD;
 
        reloc->relent.howto = CTOR_TABLE_RELOC_HOWTO (abfd);
 
@@ -2026,7 +2029,7 @@ error_return:
 }
 \f
 long
-NAME(aout,get_symtab) (abfd, location)
+NAME(aout,canonicalize_symtab) (abfd, location)
      bfd *abfd;
      asymbol **location;
 {
@@ -3066,9 +3069,10 @@ NAME(aout,link_hash_table_create) (abfd)
   struct aout_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct aout_link_hash_table);
 
-  ret = (struct aout_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct aout_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return (struct bfd_link_hash_table *) NULL;
+
   if (! NAME(aout,link_hash_table_init) (ret, abfd,
                                         NAME(aout,link_hash_newfunc)))
     {
@@ -3253,7 +3257,7 @@ aout_link_check_ar_symbols (abfd, info, pneeded)
             and this object file from the archive includes:
                 int a = 5;
             In such a case, whether to include this object is target
-             dependant for backward compatability.
+             dependant for backward compatibility.
 
             FIXME: The SunOS 4.1.3 linker will pull in the archive
             element if the symbol is defined in the .data section,
@@ -3749,7 +3753,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;
@@ -3759,7 +3763,7 @@ NAME(aout,final_link) (abfd, info, callback)
     {
       bfd_size_type sz;
 
-      if (info->relocateable)
+      if (info->relocatable)
        {
          if (bfd_get_flavour (sub) == bfd_target_aout_flavour)
            {
@@ -3773,7 +3777,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);
@@ -3783,10 +3787,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;
 
@@ -3803,7 +3807,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)
@@ -3905,10 +3909,8 @@ NAME(aout,final_link) (abfd, info, callback)
   for (o = abfd->sections; o != NULL; o = o->next)
     {
       for (p = o->link_order_head; p != NULL; p = p->next)
-       {
-         if (p->type == bfd_indirect_link_order)
-           p->u.indirect.section->linker_mark = TRUE;
-       }
+       if (p->type == bfd_indirect_link_order)
+         p->u.indirect.section->linker_mark = TRUE;
     }
 
   have_link_order_relocs = FALSE;
@@ -4743,7 +4745,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))
@@ -4788,9 +4790,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;
@@ -4852,7 +4854,7 @@ aout_link_input_section_std (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;
@@ -4868,7 +4870,7 @@ aout_link_input_section_std (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);
@@ -4937,9 +4939,9 @@ aout_link_input_section_std (finfo, input_bfd, input_section, relocs,
       }
 #endif
 
-      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)
            {
@@ -5197,7 +5199,7 @@ aout_link_input_section_ext (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;
@@ -5213,7 +5215,7 @@ aout_link_input_section_ext (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);
@@ -5258,9 +5260,9 @@ aout_link_input_section_ext (finfo, input_bfd, input_section, relocs,
 
       BFD_ASSERT (r_type < TABLE_SIZE (howto_table_ext));
 
-      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
              || r_type == (unsigned int) RELOC_BASE10
This page took 0.032537 seconds and 4 git commands to generate.