* opncls.c (bfd_alloc_by_size_t): Set bfd_error_no_memory if
authorIan Lance Taylor <ian@airs.com>
Wed, 29 Nov 1995 22:05:37 +0000 (22:05 +0000)
committerIan Lance Taylor <ian@airs.com>
Wed, 29 Nov 1995 22:05:37 +0000 (22:05 +0000)
obstack_alloc fails.
(bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish
fails.
* libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails.
* Many files: don't set bfd_error_no_memory if one of the above
routines fails.

48 files changed:
bfd/ChangeLog
bfd/aix386-core.c
bfd/aout-adobe.c
bfd/aoutx.h
bfd/archive.c
bfd/binary.c
bfd/bout.c
bfd/cisco-core.c
bfd/coff-alpha.c
bfd/coff-i960.c
bfd/coff-mips.c
bfd/coff-ppc.c
bfd/coff-rs6000.c
bfd/coff-sh.c
bfd/coffcode.h
bfd/coffgen.c
bfd/cofflink.c
bfd/ecoff.c
bfd/ecofflink.c
bfd/elf.c
bfd/elf32-hppa.c
bfd/elf32-mips.c
bfd/elf32-sparc.c
bfd/elfcode.h
bfd/elfcore.h
bfd/elflink.h
bfd/hash.c
bfd/hppabsd-core.c
bfd/i386linux.c
bfd/i386lynx.c
bfd/i386os9k.c
bfd/ieee.c
bfd/libbfd.c
bfd/linker.c
bfd/nlm32-alpha.c
bfd/nlmcode.h
bfd/oasys.c
bfd/peicode.h
bfd/ptrace-core.c
bfd/riscix.c [new file with mode: 0644]
bfd/som.c
bfd/srec.c
bfd/sunos.c
bfd/targets.c
bfd/tekhex.c
bfd/trad-core.c
bfd/versados.c
bfd/xcofflink.c

index c9260434c73bfe5121b903c5b44de735d22d8a4e..c572746db1d80f41b4c18f38da706091c30ce4b3 100644 (file)
@@ -1,5 +1,13 @@
 Wed Nov 29 12:42:36 1995  Ian Lance Taylor  <ian@cygnus.com>
 
+       * opncls.c (bfd_alloc_by_size_t): Set bfd_error_no_memory if
+       obstack_alloc fails.
+       (bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish
+       fails.
+       * libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails.
+       * Many files: don't set bfd_error_no_memory if one of the above
+       routines fails.
+
        * elf.c (assign_file_positions_for_segments): Don't adjust p_paddr
        if p_paddr_valid is set.
        (copy_private_bfd_data): New static function.
index 7f7a6bb1ccc378d070cb97f0df351ee7bcf4e01e..ec4fc0cdaf00668956f42c96b2f94c27bbb2402c 100644 (file)
@@ -1,7 +1,7 @@
 /* BFD back-end for AIX on PS/2 core files.
    This was based on trad-core.c, which was written by John Gilmore of
         Cygnus Support.
-   Copyright 1988, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
+   Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
    Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
    Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
 
@@ -19,14 +19,7 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
-
-/* To use this file on a particular host, configure the host with these
-   parameters in the config/h-HOST file:
-
-       HDEFINES=-DAIX386_CORE=1
-       HDEPFILES=aix386-core.o
- */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
@@ -75,7 +68,7 @@ struct trad_core_struct {
   asection *sections[MAX_CORE_SEGS];
 };
 
-static bfd_target *
+static const bfd_target *
 aix386_core_file_p (abfd)
      bfd *abfd;
 {
@@ -101,10 +94,7 @@ aix386_core_file_p (abfd)
 
   mergem = (struct mergem *)bfd_zalloc (abfd, sizeof (struct mergem));
   if (mergem == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return 0;
-    }
+    return 0;
 
   core = &mergem->internal_core;
 
@@ -125,7 +115,6 @@ aix386_core_file_p (abfd)
   if (core_regsec (abfd) == NULL)
     {
     loser:
-      bfd_set_error (bfd_error_no_memory);
       bfd_release (abfd, (char *)mergem);
       return 0;
     }
@@ -198,8 +187,8 @@ aix386_core_file_p (abfd)
   core_regsec (abfd)->name = ".reg";
   core_reg2sec (abfd)->name = ".reg2";
 
-  core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
-  core_reg2sec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+  core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
+  core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
 
   core_regsec (abfd)->_raw_size = sizeof(core->cd_regs);
   core_reg2sec (abfd)->_raw_size = sizeof(core->cd_fpregs);
@@ -254,7 +243,7 @@ swap_abort()
 #define NO_GETS ((PROTO(bfd_signed_vma, (*), (const bfd_byte *))) swap_abort )
 #define        NO_PUT  ((PROTO(void,        (*), (bfd_vma, bfd_byte *))) swap_abort )
 
-bfd_target aix386_core_vec =
+const bfd_target aix386_core_vec =
   {
     "aix386-core",
     bfd_target_unknown_flavour,
@@ -268,7 +257,6 @@ bfd_target aix386_core_vec =
     0,                                         /* leading underscore */
     ' ',                                       /* ar_pad_char */
     16,                                                /* ar_max_namelen */
-    3,                                         /* minimum alignment power */
     NO_GET, NO_GETS, NO_PUT,
     NO_GET, NO_GETS, NO_PUT,
     NO_GET, NO_GETS, NO_PUT, /* data */
@@ -291,6 +279,7 @@ bfd_target aix386_core_vec =
      BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
      BFD_JUMP_TABLE_WRITE (_bfd_generic),
      BFD_JUMP_TABLE_LINK (_bfd_nolink),
+     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
 
     (PTR) 0
 };
index 7f1049de29eafc3c27109c867eae61203104dca5..80b11fedfebbde12bf97d3551a6afa37d2df6c12 100644 (file)
@@ -180,8 +180,9 @@ aout_adobe_callback (abfd)
       goto no_more_sections;
 
     default:
-      fprintf (stderr, "Unknown section type in a.out.adobe file: %x\n", 
-              ext->e_type[0]);
+      (*_bfd_error_handler)
+       ("%s: Unknown section type in a.out.adobe file: %x\n", 
+        bfd_get_filename (abfd), ext->e_type[0]);
       goto no_more_sections;
     }
 
@@ -201,10 +202,8 @@ aout_adobe_callback (abfd)
     /* Fix the name, if it is a sprintf'd name.  */
     if (sect->name == try_again) {
       newname = (char *) bfd_zalloc(abfd, strlen (sect->name));
-      if (newname == NULL) {
-       bfd_set_error (bfd_error_no_memory);
+      if (newname == NULL)
        return 0;
-      }
       strcpy (newname, sect->name);
       sect->name = newname;
     }
@@ -255,10 +254,8 @@ aout_adobe_mkobject (abfd)
   struct bout_data_struct *rawptr;
 
   rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
-  if (rawptr == NULL) {
-      bfd_set_error (bfd_error_no_memory);
+  if (rawptr == NULL)
       return false;
-    }
 
   abfd->tdata.bout_data = rawptr;
   exec_hdr (abfd) = &rawptr->e;
@@ -481,6 +478,7 @@ aout_adobe_sizeof_headers (ignore_abfd, ignore)
 #define        aout_32_sizeof_headers          aout_adobe_sizeof_headers
 #define aout_32_bfd_get_relocated_section_contents \
   bfd_generic_get_relocated_section_contents
+#define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
 #define aout_32_bfd_relax_section       bfd_generic_relax_section
 #define aout_32_bfd_link_hash_table_create \
   _bfd_generic_link_hash_table_create
index 79b33583da9256a492b28db66ff7c92eac1a9a11..91ee8d833f4227bfb1e4d43632b868bebeab6737 100644 (file)
@@ -430,10 +430,8 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
   const bfd_target *result;
 
   rawptr = (struct aout_data_struct  *) bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
-  if (rawptr == NULL) {
-    bfd_set_error (bfd_error_no_memory);
+  if (rawptr == NULL)
     return 0;
-  }
 
   oldrawptr = abfd->tdata.aout_data;
   abfd->tdata.aout_data = rawptr;
@@ -644,10 +642,8 @@ NAME(aout,mkobject) (abfd)
   /* Use an intermediate variable for clarity */
   rawptr = (struct aout_data_struct *)bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
 
-  if (rawptr == NULL) {
-    bfd_set_error (bfd_error_no_memory);
+  if (rawptr == NULL)
     return false;
-  }
 
   abfd->tdata.aout_data = rawptr;
   exec_hdr (abfd) = &(rawptr->e);
@@ -1440,10 +1436,7 @@ translate_from_native_sym_flags (abfd, cache_ptr)
 
            copy = bfd_alloc (abfd, strlen (cache_ptr->symbol.name) + 1);
            if (copy == NULL)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               return false;
-             }
+             return false;
 
            strcpy (copy, cache_ptr->symbol.name);
            section = bfd_make_section (abfd, copy);
@@ -1453,10 +1446,7 @@ translate_from_native_sym_flags (abfd, cache_ptr)
 
        reloc = (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
        if (reloc == NULL)
-         {
-           bfd_set_error (bfd_error_no_memory);
-           return false;
-         }
+         return false;
 
        /* Build a relocation entry for the constructor.  */
        switch (cache_ptr->type & N_TYPE)
@@ -1667,10 +1657,7 @@ NAME(aout,make_empty_symbol) (abfd)
   aout_symbol_type  *new =
     (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
   if (!new)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   new->symbol.the_bfd = abfd;
 
   return &new->symbol;
@@ -2377,10 +2364,8 @@ NAME(aout,squirt_out_relocs) (abfd, section)
   each_size = obj_reloc_entry_size (abfd);
   natsize = each_size * count;
   native = (unsigned char *) bfd_zalloc (abfd, natsize);
-  if (!native) {
-    bfd_set_error (bfd_error_no_memory);
+  if (!native)
     return false;
-  }
 
   generic = section->orelocation;
 
@@ -2859,10 +2844,7 @@ NAME(aout,link_hash_newfunc) (entry, table, string)
     ret = ((struct aout_link_hash_entry *)
           bfd_hash_allocate (table, sizeof (struct aout_link_hash_entry)));
   if (ret == (struct aout_link_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_hash_entry *) ret;
-    }
+    return (struct bfd_hash_entry *) ret;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct aout_link_hash_entry *)
@@ -2902,10 +2884,7 @@ NAME(aout,link_hash_table_create) (abfd)
   ret = ((struct aout_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct aout_link_hash_table)));
   if (ret == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_link_hash_table *) NULL;
-    }
+    return (struct bfd_link_hash_table *) NULL;
   if (! NAME(aout,link_hash_table_init) (ret, abfd,
                                         NAME(aout,link_hash_newfunc)))
     {
@@ -3229,10 +3208,7 @@ aout_link_add_symbols (abfd, info)
                         ((size_t) sym_count
                          * sizeof (struct aout_link_hash_entry *))));
   if (sym_hash == NULL && sym_count != 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   obj_aout_sym_hashes (abfd) = sym_hash;
 
   add_one_symbol = aout_backend_info (abfd)->add_one_symbol;
@@ -3515,7 +3491,12 @@ NAME(aout,final_link) (abfd, info, callback)
                 and call get_reloc_upper_bound and canonicalize_reloc to
                 work out the number of relocs needed, and then multiply
                 by the reloc size.  */
-             abort ();
+             (*_bfd_error_handler)
+               ("%s: relocateable link from %s to %s not supported",
+                bfd_get_filename (abfd),
+                sub->xvec->name, abfd->xvec->name);
+             bfd_set_error (bfd_error_invalid_operation);
+             goto error_return;
            }
        }
 
@@ -5270,10 +5251,7 @@ aout_link_reloc_link_order (finfo, o, p)
          size = bfd_get_reloc_size (howto);
          buf = (bfd_byte *) bfd_zmalloc (size);
          if (buf == (bfd_byte *) NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
          r = MY_relocate_contents (howto, finfo->output_bfd,
                                      pr->addend, buf);
          switch (r)
index f847384a2e939080f842bc4de0600b29236d388f..fba52a6985f4abcdc0f2f69423cb758207b0b15d 100644 (file)
@@ -187,10 +187,7 @@ _bfd_generic_mkarchive (abfd)
                              bfd_zalloc (abfd, sizeof (struct artdata)));
 
   if (bfd_ardata (abfd) == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   bfd_ardata (abfd)->cache = NULL;
   bfd_ardata (abfd)->archive_head = NULL;
@@ -251,15 +248,7 @@ bfd *
 _bfd_create_empty_archive_element_shell (obfd)
      bfd *obfd;
 {
-  bfd *nbfd;
-
-  nbfd = _bfd_new_bfd_contained_in (obfd);
-  if (nbfd == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
-  return nbfd;
+  return _bfd_new_bfd_contained_in (obfd);
 }
 
 /*
@@ -310,10 +299,7 @@ _bfd_add_bfd_to_archive_cache (arch_bfd, filepos, new_elt)
                                            sizeof (struct ar_cache)));
 
   if (new_cache == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   new_cache->ptr = filepos;
   new_cache->arelt = new_elt;
@@ -430,10 +416,7 @@ _bfd_generic_read_ar_hdr (abfd)
 
       allocptr = bfd_zalloc (abfd, allocsize);
       if (allocptr == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return NULL;
-       }
+       return NULL;
       filename = (allocptr
                  + sizeof (struct areltdata)
                  + sizeof (struct ar_hdr));
@@ -473,10 +456,7 @@ _bfd_generic_read_ar_hdr (abfd)
     {
       allocptr = bfd_zalloc (abfd, allocsize);
       if (allocptr == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return NULL;
-       }
+       return NULL;
     }
 
   ared = (struct areltdata *) allocptr;
@@ -627,8 +607,11 @@ const bfd_target *
 bfd_generic_archive_p (abfd)
      bfd *abfd;
 {
+  struct artdata *tdata_hold;
   char armag[SARMAG + 1];
 
+  tdata_hold = abfd->tdata.aout_ar_data;
+
   if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
     {
       if (bfd_get_error () != bfd_error_system_call)
@@ -651,10 +634,7 @@ bfd_generic_archive_p (abfd)
                              bfd_zalloc (abfd, sizeof (struct artdata)));
 
   if (bfd_ardata (abfd) == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   bfd_ardata (abfd)->first_file_filepos = SARMAG;
   bfd_ardata (abfd)->cache = NULL;
@@ -666,14 +646,14 @@ bfd_generic_archive_p (abfd)
   if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)))
     {
       bfd_release (abfd, bfd_ardata (abfd));
-      abfd->tdata.aout_ar_data = NULL;
+      abfd->tdata.aout_ar_data = tdata_hold;
       return NULL;
     }
 
   if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))
     {
       bfd_release (abfd, bfd_ardata (abfd));
-      abfd->tdata.aout_ar_data = NULL;
+      abfd->tdata.aout_ar_data = tdata_hold;
       return NULL;
     }
 
@@ -711,7 +691,7 @@ bfd_generic_archive_p (abfd)
              err = bfd_get_error ();
              (void) bfd_close (first);
              bfd_release (abfd, bfd_ardata (abfd));
-             abfd->tdata.aout_ar_data = NULL;
+             abfd->tdata.aout_ar_data = tdata_hold;
              bfd_set_error (err);
              return NULL;
            }
@@ -763,10 +743,7 @@ do_slurp_bsd_armap (abfd)
 
   raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
   if (raw_armap == (bfd_byte *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
     {
@@ -796,10 +773,7 @@ do_slurp_bsd_armap (abfd)
                                          (ardata->symdef_count
                                           * sizeof (carsym)));
   if (!ardata->symdefs)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   for (counter = 0, set = ardata->symdefs;
        counter < ardata->symdef_count;
@@ -877,20 +851,14 @@ do_slurp_coff_armap (abfd)
 
   ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
   if (ardata->symdefs == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   carsyms = ardata->symdefs;
   stringbase = ((char *) ardata->symdefs) + carsym_size;
 
   /* Allocate and read in the raw offsets. */
   raw_armap = (int *) bfd_alloc (abfd, ptrsize);
   if (raw_armap == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto release_symdefs;
-    }
+    goto release_symdefs;
   if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
       || bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
     {
@@ -1022,7 +990,6 @@ bfd_slurp_bsd_armap_f2 (abfd)
   raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
   if (raw_armap == NULL)
     {
-      bfd_set_error (bfd_error_no_memory);
     byebye:
       bfd_release (abfd, (PTR) mapdata);
       return false;
@@ -1060,10 +1027,7 @@ bfd_slurp_bsd_armap_f2 (abfd)
                                          (ardata->symdef_count
                                           * BSD_SYMDEF_SIZE));
   if (!ardata->symdefs)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   for (counter = 0, set = ardata->symdefs;
        counter < ardata->symdef_count;
@@ -1124,7 +1088,6 @@ _bfd_slurp_extended_name_table (abfd)
        bfd_zalloc (abfd, namedata->parsed_size);
       if (bfd_ardata (abfd)->extended_names == NULL)
        {
-         bfd_set_error (bfd_error_no_memory);
        byebye:
          bfd_release (abfd, (PTR) namedata);
          return false;
@@ -1198,10 +1161,7 @@ normalize (abfd, file)
 
   copy = (char *) bfd_alloc (abfd, last - first + 1);
   if (copy == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   memcpy (copy, first, last - first);
   copy[last - first] = 0;
@@ -1321,10 +1281,7 @@ _bfd_construct_extended_name_table (abfd, trailing_slash, tabloc, tablen)
 
   *tabloc = bfd_zalloc (abfd, total_namelen);
   if (*tabloc == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   *tablen = total_namelen;
   strptr = *tabloc;
@@ -1400,10 +1357,7 @@ bfd_ar_hdr_from_filesystem (abfd, filename)
   ared = (struct areltdata *) bfd_zalloc (abfd, sizeof (struct ar_hdr) +
                                          sizeof (struct areltdata));
   if (ared == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
 
   /* ar headers are space padded, not null padded! */
@@ -1778,7 +1732,7 @@ _bfd_compute_and_write_armap (arch, elength)
      them when done.  */
   first_name = bfd_alloc (arch, 1);
   if (first_name == NULL)
-    goto no_memory_return;
+    goto error_return;
 
   /* Drop all the files called __.SYMDEF, we're going to make our
      own */
@@ -1850,10 +1804,10 @@ _bfd_compute_and_write_armap (arch, elength)
                                             bfd_alloc (arch,
                                                        sizeof (char *)));
                      if (map[orl_count].name == NULL)
-                       goto no_memory_return;
+                       goto error_return;
                      *(map[orl_count].name) = bfd_alloc (arch, namelen + 1);
                      if (*(map[orl_count].name) == NULL)
-                       goto no_memory_return;
+                       goto error_return;
                      strcpy (*(map[orl_count].name), syms[src_count]->name);
                      (map[orl_count]).pos = (file_ptr) current;
                      (map[orl_count]).namidx = stridx;
index 1755d4afebcdc10453f3afbb6c2b00b969bd4f62..6d68b313a28d909d299d3da334f489606e33751b 100644 (file)
@@ -149,10 +149,7 @@ mangle_name (abfd, suffix)
 
   buf = (char *) bfd_alloc (abfd, size);
   if (buf == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return "";
 
   sprintf (buf, "_binary_%s_%s", bfd_get_filename (abfd), suffix);
 
@@ -177,10 +174,7 @@ binary_get_symtab (abfd, alocation)
 
   syms = (asymbol *) bfd_alloc (abfd, BIN_SYMS * sizeof (asymbol));
   if (syms == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   /* Start symbol.  */
   syms[0].the_bfd = abfd;
@@ -219,12 +213,7 @@ static asymbol *
 binary_make_empty_symbol (abfd)
      bfd *abfd;
 {
-  asymbol *ret;
-
-  ret = (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
-  if (ret == NULL)
-    bfd_set_error (bfd_error_no_memory);
-  return ret;
+  return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
 }
 
 #define binary_print_symbol _bfd_nosymbols_print_symbol
@@ -305,6 +294,8 @@ binary_sizeof_headers (abfd, exec)
 #define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define binary_bfd_final_link _bfd_generic_final_link
 #define binary_bfd_link_split_section _bfd_generic_link_split_section
+#define binary_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
 
 const bfd_target binary_vec =
 {
index c730eb60b4b1964616f7603b8ad72b6619f9a985..a896f280b7e3098ac1fdc782940444db70975612 100644 (file)
@@ -204,10 +204,8 @@ b_out_mkobject (abfd)
   struct bout_data_struct *rawptr;
 
   rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
-  if (rawptr == NULL) {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+  if (rawptr == NULL)
+    return false;
 
   abfd->tdata.bout_data = rawptr;
   exec_hdr (abfd) = &rawptr->e;
@@ -1396,6 +1394,8 @@ b_out_bfd_get_relocated_section_contents (in_abfd, link_info, link_order,
 #define b_out_bfd_final_link _bfd_generic_final_link
 #define b_out_bfd_link_split_section  _bfd_generic_link_split_section
 
+#define aout_32_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
 
 const bfd_target b_out_vec_big_host =
 {
@@ -1410,7 +1410,6 @@ const bfd_target b_out_vec_big_host =
   '_',                         /* symbol leading char */
   ' ',                         /* ar_pad_char */
   16,                          /* ar_max_namelen */
-  2,                           /* minumum alignment power */
 
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
      bfd_getl32, bfd_getl_signed_32, bfd_putl32,
@@ -1452,7 +1451,6 @@ const bfd_target b_out_vec_little_host =
   '_',                         /* symbol leading char */
   ' ',                         /* ar_pad_char */
   16,                          /* ar_max_namelen */
-  2,                           /* minum align */
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
      bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
index a253675a8d2d754793037c36535ff95ca2c009dc..3008dbaf3d34872b521a0c27591878b49d626b52 100644 (file)
@@ -16,7 +16,7 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
@@ -49,7 +49,7 @@ struct cisco_core_struct
   int sig;
 };
 \f
-static bfd_target *
+static const bfd_target *
 cisco_core_file_p (abfd)
      bfd *abfd;
 {
@@ -116,10 +116,7 @@ cisco_core_file_p (abfd)
     ((struct cisco_core_struct *)
      bfd_zmalloc (sizeof (struct cisco_core_struct)));
   if (abfd->tdata.cisco_core_data == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   switch ((crashreason) bfd_get_32 (abfd, crashinfo.reason))
     {
@@ -202,12 +199,9 @@ cisco_core_file_p (abfd)
 
   asect = (asection *) bfd_zmalloc (sizeof (asection));
   if (asect == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto error_return;
-    }
+    goto error_return;
   asect->name = ".reg";
-  asect->flags = SEC_ALLOC | SEC_HAS_CONTENTS;
+  asect->flags = SEC_HAS_CONTENTS;
   /* This can be bigger than the real size.  Set it to the size of the whole
      core file.  */
   asect->_raw_size = statbuf.st_size;
@@ -221,10 +215,7 @@ cisco_core_file_p (abfd)
      We call it .data.  */
   asect = (asection *) bfd_zmalloc (sizeof (asection));
   if (asect == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto error_return;
-    }
+    goto error_return;
   asect->name = ".data";
   asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   /* The size of memory is the size of the core file itself.  */
@@ -273,7 +264,7 @@ cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
   return true;
 }
 \f
-bfd_target cisco_core_vec =
+const bfd_target cisco_core_vec =
   {
     "trad-core",
     bfd_target_unknown_flavour,
@@ -286,7 +277,6 @@ bfd_target cisco_core_vec =
     0,                                                    /* symbol prefix */
     ' ',                                                  /* ar_pad_char */
     16,                                                           /* ar_max_namelen */
-    3,                                                    /* minimum alignment power */
     bfd_getb64, bfd_getb_signed_64, bfd_putb64,
     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
     bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
@@ -317,6 +307,7 @@ bfd_target cisco_core_vec =
        BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
        BFD_JUMP_TABLE_WRITE (_bfd_generic),
        BFD_JUMP_TABLE_LINK (_bfd_nolink),
+       BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
 
     (PTR) 0                    /* backend_data */
 };
index 402c9edd5d517caa9d29eae91a15a0bf2349a64e..d24c79124e6d1bbbccf1b272869b4badb7108ea7 100644 (file)
@@ -1387,10 +1387,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section,
                                      (NUM_RELOC_SECTIONS
                                       * sizeof (asection *))));
       if (!symndx_to_section)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       symndx_to_section[RELOC_SECTION_NONE] = NULL;
       symndx_to_section[RELOC_SECTION_TEXT] =
index ece069747fd14d8b2f083bd0192681ae8ae0b0e8..a67256c00b62e1bf1da9134c1fc76b0868df8b98 100644 (file)
@@ -212,10 +212,7 @@ coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section,
            ((PTR) bfd_zalloc (abfd,
                               sizeof (struct coff_section_tdata)));
          if (osec->used_by_bfd == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return bfd_reloc_overflow;
-           }
+           return bfd_reloc_overflow;
        }
       coff_section_data (output_bfd, osec)->tdata = (PTR) syms;
     }
@@ -549,6 +546,8 @@ coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
 {
   struct coff_link_hash_entry *h;
 
+  *adjustedp = false;
+
   h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
   if (h == NULL
       || (h->root.type != bfd_link_hash_defined
@@ -587,7 +586,6 @@ const bfd_target icoff_little_vec =
   '/',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
 
-  3,                           /* minimum alignment power */
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
      bfd_getl32, bfd_getl_signed_32, bfd_putl32,
      bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
@@ -632,7 +630,6 @@ const bfd_target icoff_big_vec =
   '/',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
 
-  3,                           /* minimum alignment power */
 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
      bfd_getl32, bfd_getl_signed_32, bfd_putl32,
      bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
index 527a0fcb016e17638af3f6589f3bb2f2a80a7b3c..591bd757ac6e45e0746dda19c813f2d56785c20e 100644 (file)
@@ -1204,10 +1204,7 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section,
                                      (NUM_RELOC_SECTIONS
                                       * sizeof (asection *))));
       if (!symndx_to_section)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       symndx_to_section[RELOC_SECTION_NONE] = NULL;
       symndx_to_section[RELOC_SECTION_TEXT] =
@@ -1801,10 +1798,7 @@ mips_read_relocs (abfd, sec)
       sec->used_by_bfd =
        (PTR) bfd_alloc_by_size_t (abfd, sizeof (struct ecoff_section_tdata));
       if (sec->used_by_bfd == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       section_tdata = ecoff_section_data (abfd, sec);
       section_tdata->external_relocs = NULL;
@@ -1822,10 +1816,7 @@ mips_read_relocs (abfd, sec)
       section_tdata->external_relocs =
        (PTR) bfd_alloc (abfd, external_relocs_size);
       if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
          || (bfd_read (section_tdata->external_relocs, 1,
@@ -2046,10 +2037,7 @@ mips_relax_section (abfd, sec, info, again)
          size = sec->reloc_count * sizeof (long);
          offsets = (long *) bfd_alloc_by_size_t (abfd, size);
          if (offsets == (long *) NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             goto error_return;
-           }
+           goto error_return;
          memset (offsets, 0, size);
          section_tdata->offsets = offsets;
        }
@@ -2226,10 +2214,7 @@ mips_relax_section (abfd, sec, info, again)
       adjust = ((struct ecoff_value_adjust *)
                bfd_alloc (abfd, sizeof (struct ecoff_value_adjust)));
       if (adjust == (struct ecoff_value_adjust *) NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
 
       adjust->start = int_rel.r_vaddr;
       adjust->end = sec->vma + sec->_raw_size;
@@ -2330,10 +2315,7 @@ bfd_mips_ecoff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
 
   relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 4);
   if (relsec->contents == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   p = relsec->contents;
 
@@ -2442,7 +2424,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
     mips_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
     _bfd_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
     _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
   },
   /* Supported architecture.  */
   bfd_arch_mips,
@@ -2519,6 +2501,10 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
 #define _bfd_ecoff_bfd_get_relocated_section_contents \
   bfd_generic_get_relocated_section_contents
 
+/* Handling file windows is generic.  */
+#define _bfd_ecoff_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
+
 /* Relaxing sections is MIPS specific.  */
 #define _bfd_ecoff_bfd_relax_section mips_relax_section
 
index 0683c6a2d7fc39a8dfcdd6552d6c357c30444f06..25deb99e6d7ef86c5e1056e546858358552d99ba 100644 (file)
@@ -152,10 +152,7 @@ ppc_coff_link_hash_table_create (abfd)
   ret = ((struct ppc_coff_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct ppc_coff_link_hash_table)));
   if (ret == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   if (! ppc_coff_link_hash_table_init (ret, abfd,
                                        ppc_coff_link_hash_newfunc))
     {
@@ -762,10 +759,18 @@ enum toc_type
   toc_64
 };
 
+enum ref_category
+{
+  priv,
+  pub,
+  data
+};
+
 struct list_ele
 {
   struct list_ele *next;
   bfd_vma addr;
+  enum ref_category cat;
   int offset;
   const char *name;
 };
@@ -774,9 +779,10 @@ extern struct list_ele *head;
 extern struct list_ele *tail;
 
 static void
-record_toc(toc_section, our_toc_offset, name)
+record_toc(toc_section, our_toc_offset, cat, name)
      asection *toc_section;
      int our_toc_offset;
+     enum ref_category cat;
      const char *name;
 {
   /* add this entry to our toc addr-offset-name list */
@@ -785,6 +791,7 @@ record_toc(toc_section, our_toc_offset, name)
   t->next = 0;
   t->offset = our_toc_offset;
   t->name = name;
+  t->cat = cat;
   t->addr = toc_section->output_offset + our_toc_offset;
 
   if (head == 0)
@@ -840,10 +847,7 @@ ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
            (int *) bfd_zalloc (abfd, 
                                obj_raw_syment_count(abfd) * sizeof(int));
          if (local_syms == 0)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
          obj_coff_local_toc_table(abfd) = local_syms;
          for (i = 0; i < obj_raw_syment_count(abfd); ++i)
            local_syms[i] = 1;
@@ -854,6 +858,15 @@ ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
          local_syms[sym] = global_toc_size;
          ret_val = global_toc_size;
          global_toc_size += 4;
+
+         /* The size must fit in a 16bit displacment */
+         if (global_toc_size >= 65535)
+           {
+             fprintf(stderr,
+                     "Exceeded toc size of 65535\n");
+             abort();
+           }
+
 #ifdef TOC_DEBUG
          fprintf(stderr,
                  "Setting toc_offset for local sym %d to %d\n",
@@ -881,6 +894,15 @@ ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
          h->toc_offset = global_toc_size;
          ret_val = global_toc_size;
          global_toc_size += 4;
+
+         /* The size must fit in a 16bit displacment */
+         if (global_toc_size >= 65535)
+           {
+             fprintf(stderr,
+                     "Exceeded toc size of 65535\n");
+             abort();
+           }
+
 #ifdef TOC_DEBUG
          fprintf(stderr,
                  "Setting toc_offset for sym %d (%s) [h=%p] to %d\n",
@@ -950,10 +972,7 @@ ppc_record_data_in_toc_entry(abfd, info, sec, sym, toc_kind)
            (int *) bfd_zalloc (abfd, 
                                obj_raw_syment_count(abfd) * sizeof(int));
          if (local_syms == 0)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
          obj_coff_local_toc_table(abfd) = local_syms;
          for (i = 0; i < obj_raw_syment_count(abfd); ++i)
            local_syms[i] = 1;
@@ -1339,16 +1358,18 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
 #ifdef TOC_DEBUG
 
                    fprintf(stderr,
-                           "Not writing out toc_offset of %d for %s\n", our_toc_offset, name);
+                           "Not writing out toc_offset of %d for %s\n", 
+                           our_toc_offset, name);
 #endif
                  }
                else
                  {
                    /* write out the toc entry */
-                   record_toc(toc_section, our_toc_offset, strdup(name));
+                   record_toc(toc_section, our_toc_offset, priv, strdup(name));
 #ifdef TOC_DEBUG
                    fprintf(stderr,
-                           "Writing out toc_offset toc_section (%p,%p)+%d val %d for %s\n", 
+                           "Writing out toc_offset "
+                           "toc_section (%p,%p)+%d val %d for %s\n", 
                            toc_section,
                            toc_section->contents,
                            our_toc_offset, 
@@ -1369,15 +1390,38 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                const char *name = h->root.root.root.string;
                our_toc_offset = h->toc_offset;
 
-               if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) == IMAGE_REL_PPC_TOCDEFN &&
-                     our_toc_offset == 1)
+               if ((r_flags & IMAGE_REL_PPC_TOCDEFN) 
+                   == IMAGE_REL_PPC_TOCDEFN 
+                   && our_toc_offset == 1)
                  {
-                   /* This is unbelievable cheese. Some knowledgable asm hacker has decided to
-                      use r2 as a base for loading a value. He/She does this by setting the
-                      tocdefn bit, and not supplying a toc definition. The behaviour is then
-                      to use the value of the symbol as a toc index. Good Grief.
+                   /* This is unbelievable cheese. Some knowledgable asm 
+                      hacker has decided to use r2 as a base for loading 
+                      a value. He/She does this by setting the tocdefn bit, 
+                      and not supplying a toc definition. The behaviour is 
+                      then to use the difference between the value of the 
+                      symbol and the actual location of the toc as the toc 
+                      index. 
+
+                      In fact, what is usually happening is, because the
+                      Import Address Table is mapped immediately following
+                      the toc, some trippy library code trying for speed on
+                      dll linkage, takes advantage of that and considers 
+                      the IAT to be part of the toc, thus saving a load.
                    */
-                   our_toc_offset = val - (toc_section->output_section->vma + toc_section->output_offset);
+                   our_toc_offset = val - 
+                     (toc_section->output_section->vma + 
+                      toc_section->output_offset);
+
+                   /* The size must still fit in a 16bit displacment */
+                   if (our_toc_offset >= 65535)
+                     {
+                       fprintf(stderr,
+                               "TOCDEFN Relocation exceeded "
+                               "displacment of 65535\n");
+                       abort();
+                     }
+
+                   record_toc(toc_section, our_toc_offset, pub, strdup(name));
                  }
                else if ((our_toc_offset & 1) != 0)
                  {
@@ -1388,17 +1432,19 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                    our_toc_offset &= ~1;
 #ifdef TOC_DEBUG
                    fprintf(stderr,
-                           "Not writing out toc_offset of %d for %s\n", our_toc_offset, name);
+                           "Not writing out toc_offset of %d for %s\n", 
+                           our_toc_offset, name);
 #endif
                  }
                else
                  {
-                   record_toc(toc_section, our_toc_offset, strdup(name));
+                   record_toc(toc_section, our_toc_offset, pub, strdup(name));
 
 #ifdef TOC_DEBUG
                    /* write out the toc entry */
                    fprintf(stderr,
-                           "Writing out toc_offset toc_section (%p,%p)+%d val %d for %s\n", 
+                           "Writing out toc_offset "
+                           "toc_section (%p,%p)+%d val %d for %s\n", 
                            toc_section,
                            toc_section->contents,
                            our_toc_offset, 
@@ -1558,7 +1604,8 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
                                             false, false, true);
                if (myh == 0) 
                  {
-                   fprintf(stderr, "Missing idata magic cookies, this cannot work anyway...\n");
+                   fprintf(stderr, "Missing idata magic cookies, "
+                           "this cannot work anyway...\n");
                    abort();
                  }
 
@@ -1704,6 +1751,13 @@ long int thunk_size;
 struct list_ele *head;
 struct list_ele *tail;
 
+static char *
+h1 = "\n\t\t\tTOC MAPPING\n\n";
+static char *
+h2 = " TOC    disassembly  Comments       Name\n";
+static char *
+h3 = " Offset  spelling                   (if present)\n";
+
 void
 dump_toc(vfile)
      void *vfile;
@@ -1711,15 +1765,38 @@ dump_toc(vfile)
   FILE *file = vfile;
   struct list_ele *t;
 
-  fprintf(file, 
-         " Offset Offset   Name if present\n");
+  fprintf(file, h1);
+  fprintf(file, h2);
+  fprintf(file, h3);
 
   for(t = head; t != 0; t=t->next)
     {
+      char *cat;
+
+      if (t->cat == priv)
+       cat = "private       ";
+      else if (t->cat == pub)
+       cat = "public        ";
+      else if (t->cat == data)
+       cat = "data-in-toc   ";
+
+      if (t->offset > global_toc_size)
+       {
+         if (t->offset <= global_toc_size + thunk_size)
+           cat = "IAT reference ";
+         else
+           cat = "Out of bounds!";
+       }
+
       fprintf(file,
-             " %2x  %04lx    %s\n",
-             t->offset - 32768, t->offset, t->name);
+             " %04lx    (%d)", t->offset, t->offset - 32768);
+      fprintf(file,
+             "    %s %s\n",
+             cat, t->name);
+
     }
+
+  fprintf(file, "\n");
 }
 
 boolean
@@ -1764,7 +1841,7 @@ ppc_process_before_allocation (abfd, info)
   asection *sec;
   struct internal_reloc *i, *rel;
 
-#if 0
+#if DEBUG_RELOC
   fprintf(stderr, 
          "ppc_process_before_allocation: BFD %s\n", 
          bfd_get_filename(abfd));
@@ -1786,6 +1863,7 @@ ppc_process_before_allocation (abfd, info)
   for (; sec != 0; sec = sec->next)
   {
     int toc_offset;
+
 #ifdef DEBUG_RELOC
     fprintf(stderr, 
            "  section %s reloc count %d\n", 
@@ -1831,6 +1909,12 @@ ppc_process_before_allocation (abfd, info)
        switch(r_type) 
          {
          case IMAGE_REL_PPC_TOCREL16:
+#if 0
+           /* FIXME:
+              This remains unimplemented for now, as it currently adds
+              un-necessary elements to the toc. All we need to do today
+              is not do anything if TOCDEFN is on.
+           */
            if ( r_flags & IMAGE_REL_PPC_TOCDEFN )
              toc_offset = ppc_record_data_in_toc_entry(abfd, info, sec, 
                                                        rel->r_symndx, 
@@ -1838,6 +1922,10 @@ ppc_process_before_allocation (abfd, info)
            else
              toc_offset = ppc_record_toc_entry(abfd, info, sec, 
                                                rel->r_symndx, default_toc);
+#endif
+           if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN )
+             toc_offset = ppc_record_toc_entry(abfd, info, sec, 
+                                               rel->r_symndx, default_toc);
            break;
          case IMAGE_REL_PPC_IMGLUE:
            ppc_mark_symbol_as_glue(abfd, rel->r_symndx, rel);
@@ -2181,9 +2269,6 @@ coff_ppc_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
   unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
   unsigned short junk    = EXTRACT_JUNK (rel->r_type);
 
-fprintf(stderr,
-       "coff_ppc_rtype_to_howto\n");
-
   /* the masking process only slices off the bottom byte for r_type. */
   if ( r_type > MAX_RELOC_INDEX ) 
     {
@@ -2320,6 +2405,20 @@ ppc_coff_swap_sym_in_hook ();
 \f
 
 #ifndef COFF_IMAGE_WITH_PE
+/* FIXME:
+   What we're trying to do here is allocate a toc section (early), and attach 
+   it to the last bfd to be processed. This avoids the problem of having a toc
+   written out before all files have been processed. This code allocates
+   a toc section for every file, and records the last one seen. There are
+   at least two problems with this approach:
+   1. We allocate whole bunches of toc sections that are ignored, but at
+      at least we will not allocate a toc if no .toc is present.
+   2. It's not clear to me that being the last bfd read necessarily means
+      that you are the last bfd closed.
+   3. Doing it on a "swap in" hook depends on when the "swap in" is called,
+      and how often, etc. It's not clear to me that there isn't a hole here.
+*/
+
 static void
 ppc_coff_swap_sym_in_hook (abfd, ext1, in1)
      bfd            *abfd;
index 242381d84baffac1f1a04de4c3cc3471b7c161d7..ba27ebe10ae81b2d815ae879c16d592630e16d50 100644 (file)
@@ -67,10 +67,7 @@ xcoff_mkobject (abfd)
     ((struct xcoff_tdata *)
      bfd_zalloc (abfd, sizeof (struct xcoff_tdata)));
   if (abfd->tdata.xcoff_obj_data == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   coff = coff_data (abfd);
   coff->symbols = (coff_symbol_type *) NULL;
   coff->conversion_table = (unsigned int *) NULL;
@@ -709,10 +706,7 @@ xcoff_slurp_armap (abfd)
   sz = strtol (hdr.size, (char **) NULL, 10);
   contents = (bfd_byte *) bfd_alloc (abfd, sz);
   if (contents == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
     return false;
 
@@ -728,10 +722,7 @@ xcoff_slurp_armap (abfd)
   bfd_ardata (abfd)->symdefs = ((carsym *)
                                bfd_alloc (abfd, c * sizeof (carsym)));
   if (bfd_ardata (abfd)->symdefs == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   /* After the count comes a list of four byte file offsets.  */
   for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
@@ -788,10 +779,7 @@ xcoff_archive_p (abfd)
     (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
 
   if (bfd_ardata (abfd) == (struct artdata *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
                                                  (char **) NULL, 10);
@@ -802,10 +790,7 @@ xcoff_archive_p (abfd)
 
   bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR);
   if (bfd_ardata (abfd)->tdata == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);
 
@@ -836,10 +821,7 @@ xcoff_read_ar_hdr (abfd)
   namlen = strtol (hdr.namlen, (char **) NULL, 10);
   hdrp = bfd_alloc (abfd, SIZEOF_AR_HDR + namlen + 1);
   if (hdrp == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
   if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen)
     return NULL;
@@ -847,10 +829,7 @@ xcoff_read_ar_hdr (abfd)
 
   ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
   if (ret == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   ret->arch_header = (char *) hdrp;
   ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
   ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
@@ -1062,10 +1041,7 @@ xcoff_write_archive_contents (abfd)
     }
   offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));
   if (offsets == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
     return false;
@@ -1118,10 +1094,7 @@ xcoff_write_archive_contents (abfd)
              sub->arelt_data = ((struct areltdata *)
                                 bfd_alloc (sub, sizeof (struct areltdata)));
              if (sub->arelt_data == NULL)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 return false;
-               }
+               return false;
            }
 
          arch_eltdata (sub)->parsed_size = s.st_size;
@@ -1282,6 +1255,26 @@ xcoff_write_archive_contents (abfd)
   return true;
 }
 \f
+/* We can't use the usual coff_sizeof_headers routine, because AIX
+   always uses an a.out header.  */
+
+/*ARGSUSED*/
+static int
+_bfd_xcoff_sizeof_headers (abfd, reloc)
+     bfd *abfd;
+     boolean reloc;
+{
+  int size;
+
+  size = FILHSZ;
+  if (xcoff_data (abfd)->full_aouthdr)
+    size += AOUTSZ;
+  else
+    size += SMALL_AOUTSZ;
+  size += abfd->section_count * SCNHSZ;
+  return size;
+}
+\f
 #define CORE_FILE_P _bfd_dummy_target
 
 #define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
@@ -1333,7 +1326,6 @@ extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd));
 
 #endif /* LYNX_CORE */
 
-#define _bfd_xcoff_sizeof_headers coff_sizeof_headers
 #define _bfd_xcoff_bfd_get_relocated_section_contents \
   coff_bfd_get_relocated_section_contents
 #define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
@@ -1341,9 +1333,18 @@ extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd));
 
 /* The transfer vector that leads the outside world to all of the above. */
 
-const bfd_target rs6000coff_vec =
+const bfd_target
+#ifdef TARGET_SYM
+  TARGET_SYM =
+#else
+  rs6000coff_vec =
+#endif
 {
+#ifdef TARGET_NAME
+  TARGET_NAME,
+#else
   "aixcoff-rs6000",            /* name */
+#endif
   bfd_target_coff_flavour,     
   true,                                /* data byte order is big */
   true,                                /* header byte order is big */
index 7a3e938d83bbedf6beb794c2e1950f6a4dcde014..a57a3531cccca76d73ccc9921a1c74ae33f71df4 100644 (file)
@@ -626,10 +626,7 @@ sh_relax_section (abfd, sec, link_info, again)
          sec->used_by_bfd =
            ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
          if (sec->used_by_bfd == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             goto error_return;
-           }
+           goto error_return;
        }
 
       coff_section_data (abfd, sec)->relocs = internal_relocs;
@@ -749,10 +746,7 @@ sh_relax_section (abfd, sec, link_info, again)
              sec->used_by_bfd =
                ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
              if (sec->used_by_bfd == NULL)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 goto error_return;
-               }
+               goto error_return;
              coff_section_data (abfd, sec)->relocs = NULL;
            }
          coff_section_data (abfd, sec)->contents = contents;
@@ -1470,7 +1464,6 @@ const bfd_target shcoff_vec =
   '_',                         /* leading symbol underscore */
   '/',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
-  2,                           /* minimum section alignment */
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
@@ -1513,7 +1506,6 @@ const bfd_target shlcoff_vec =
   '_',                         /* leading symbol underscore */
   '/',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
-  2,                           /* minimum section alignment */
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
   bfd_getl32, bfd_getl_signed_32, bfd_putl32,
   bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
@@ -1521,11 +1513,8 @@ const bfd_target shlcoff_vec =
   bfd_getl32, bfd_getl_signed_32, bfd_putl32,
   bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
 
-  /* Note that we use a special archive recognizer.
-     This is so that we only use one archive format for both
-     object file types */
   {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
-     _bfd_dummy_target, _bfd_dummy_target},   
+     bfd_generic_archive_p, _bfd_dummy_target},   
   {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
      bfd_false},
   {bfd_false, coff_write_object_contents, /* bfd_write_contents */
index 6eb7a12d9666443950cf8c5594cb4c47dc5b2418..6dc48e57655bdd59830fd769f31341db70d114d3 100644 (file)
@@ -1019,10 +1019,7 @@ coff_mkobject (abfd)
 
   abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, sizeof (coff_data_type));
   if (abfd->tdata.coff_obj_data == 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   coff = coff_data (abfd);
   coff->symbols = (coff_symbol_type *) NULL;
   coff->conversion_table = (unsigned int *) NULL;
@@ -2055,10 +2052,7 @@ coff_add_missing_symbols (abfd)
   nsyms += need_text + need_data + need_bss + need_file;
   sympp2 = (asymbol **) bfd_alloc_by_size_t (abfd, nsyms * sizeof (asymbol *));
   if (!sympp2)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   memcpy (sympp2, sympp, i * sizeof (asymbol *));
   if (need_file)
     {
@@ -2717,10 +2711,7 @@ buy_and_read (abfd, where, seek_direction, size)
 {
   PTR area = (PTR) bfd_alloc (abfd, size);
   if (!area)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (NULL);
-    }
+    return (NULL);
   if (bfd_seek (abfd, where, seek_direction) != 0
       || bfd_read (area, 1, size, abfd) != size)
     return (NULL);
@@ -2766,10 +2757,7 @@ coff_slurp_line_table (abfd, asect)
   lineno_cache =
     (alent *) bfd_alloc (abfd, (size_t) ((asect->lineno_count + 1) * sizeof (alent)));
   if (lineno_cache == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   else
     {
       unsigned int counter = 0;
@@ -2841,20 +2829,14 @@ coff_slurp_symbol_table (abfd)
                             * sizeof (coff_symbol_type))));
 
   if (cached_area == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }                          /* on error */
+    return false;
   table_ptr = ((unsigned int *)
               bfd_alloc (abfd,
                          (obj_raw_syment_count (abfd)
                           * sizeof (unsigned int))));
 
   if (table_ptr == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   else
     {
       coff_symbol_type *dst = cached_area;
@@ -3228,10 +3210,7 @@ coff_slurp_reloc_table (abfd, asect, symbols)
     bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent)));
 
   if (reloc_cache == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
 
   for (idx = 0; idx < asect->reloc_count; idx++)
index cb9b2ba630cc636c2b6439b2be041f50adf7af6e..14c0e3856c4a6a74f8ed897dd0f085840e9b830a 100644 (file)
@@ -73,10 +73,7 @@ make_a_section_from_file (abfd, hdr, target_index)
   /* Assorted wastage to null-terminate the name, thanks AT&T! */
   name = bfd_alloc (abfd, sizeof (hdr->s_name) + 1);
   if (name == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
   name[sizeof (hdr->s_name)] = 0;
 
@@ -166,10 +163,7 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a)
   readsize = nscns * scnhsz;
   external_sections = (char *) bfd_alloc (abfd, readsize);
   if (!external_sections)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto fail;
-    }
+    goto fail;
 
   if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize)
     goto fail;
@@ -451,10 +445,7 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
            (PTR) bfd_zalloc (abfd,
                              sizeof (struct coff_section_tdata));
          if (sec->used_by_bfd == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             goto error_return;
-           }
+           goto error_return;
          coff_section_data (abfd, sec)->contents = NULL;
        }
       coff_section_data (abfd, sec)->relocs = free_internal;
@@ -626,10 +617,7 @@ coff_renumber_symbols (bfd_ptr, first_undef)
                                                sizeof (asymbol *)
                                                * (symbol_count + 1));
     if (!newsyms)
-      {
-       bfd_set_error (bfd_error_no_memory);
-       return false;
-      }
+      return false;
     bfd_ptr->outsymbols = newsyms;
     for (i = 0; i < symbol_count; i++)
       if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) != 0
@@ -913,10 +901,7 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p,
   symesz = bfd_coff_symesz (abfd);
   buf = bfd_alloc (abfd, symesz);
   if (!buf)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   bfd_coff_swap_sym_out (abfd, &native->u.syment, buf);
   if (bfd_write (buf, 1, symesz, abfd) != symesz)
     return false;
@@ -930,10 +915,7 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p,
       auxesz = bfd_coff_auxesz (abfd);
       buf = bfd_alloc (abfd, auxesz);
       if (!buf)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       for (j = 0; j < native->u.syment.n_numaux; j++)
        {
          bfd_coff_swap_aux_out (abfd,
@@ -1242,10 +1224,7 @@ coff_write_linenumbers (abfd)
   linesz = bfd_coff_linesz (abfd);
   buff = bfd_alloc (abfd, linesz);
   if (!buff)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   for (s = abfd->sections; s != (asection *) NULL; s = s->next)
     {
       if (s->lineno_count)
@@ -1416,10 +1395,7 @@ build_debug_section (abfd)
   debug_section = (PTR) bfd_alloc (abfd,
                                   bfd_get_section_size_before_reloc (sect));
   if (debug_section == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* Seek to the beginning of the `.debug' section and read it. 
      Save the current position first; it is needed by our caller.
@@ -1457,10 +1433,7 @@ copy_name (abfd, name, maxlen)
     }
 
   if ((newname = (PTR) bfd_alloc (abfd, len + 1)) == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (NULL);
-    }
+    return (NULL);
   strncpy (newname, name, len);
   newname[len] = '\0';
   return newname;
@@ -1617,10 +1590,7 @@ coff_get_normalized_symtab (abfd)
   size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
   internal = (combined_entry_type *) bfd_alloc (abfd, size);
   if (internal == NULL && size != 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   internal_end = internal + obj_raw_syment_count (abfd);
 
   if (! _bfd_coff_get_external_symbols (abfd))
@@ -1726,10 +1696,7 @@ coff_get_normalized_symtab (abfd)
                }               /* possible lengths of this string. */
 
              if ((newstring = (PTR) bfd_alloc (abfd, ++i)) == NULL)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 return (NULL);
-               }               /* on error */
+               return (NULL);
              memset (newstring, 0, i);
              strncpy (newstring, internal_ptr->u.syment._n._n_name, i - 1);
              internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
@@ -1790,10 +1757,7 @@ coff_make_empty_symbol (abfd)
 {
   coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
   if (new == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (NULL);
-    }                          /* on error */
+    return (NULL);
   memset (new, 0, sizeof *new);
   new->symbol.section = 0;
   new->native = 0;
@@ -1813,17 +1777,11 @@ coff_bfd_make_debug_symbol (abfd, ptr, sz)
 {
   coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
   if (new == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (NULL);
-    }                          /* on error */
+    return (NULL);
   /* @@ This shouldn't be using a constant multiplier.  */
   new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
   if (!new->native)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (NULL);
-    }                          /* on error */
+    return (NULL);
   new->symbol.section = bfd_abs_section_ptr;
   new->symbol.flags = BSF_DEBUGGING;
   new->lineno = (alent *) NULL;
index 99b5f301db32c0dd017c1570a2e6cf11d38ff74a..78baf88657f746a5c30317925f56c09f0b1b58ee 100644 (file)
@@ -186,10 +186,7 @@ _bfd_coff_link_hash_newfunc (entry, table, string)
     ret = ((struct coff_link_hash_entry *)
           bfd_hash_allocate (table, sizeof (struct coff_link_hash_entry)));
   if (ret == (struct coff_link_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_hash_entry *) ret;
-    }
+    return (struct bfd_hash_entry *) ret;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct coff_link_hash_entry *)
@@ -204,7 +201,6 @@ _bfd_coff_link_hash_newfunc (entry, table, string)
       ret->numaux = 0;
       ret->auxbfd = NULL;
       ret->aux = NULL;
-      ret->toc_offset = 1; /* invalid toc address, sets the high bit */
     }
 
   return (struct bfd_hash_entry *) ret;
@@ -234,10 +230,7 @@ _bfd_coff_link_hash_table_create (abfd)
   ret = ((struct coff_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct coff_link_hash_table)));
   if (ret == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   if (! _bfd_coff_link_hash_table_init (ret, abfd,
                                        _bfd_coff_link_hash_newfunc))
     {
@@ -265,10 +258,7 @@ coff_debug_merge_hash_newfunc (entry, table, string)
           bfd_hash_allocate (table,
                              sizeof (struct coff_debug_merge_hash_entry)));
   if (ret == (struct coff_debug_merge_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_hash_entry *) ret;
-    }
+    return (struct bfd_hash_entry *) ret;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct coff_debug_merge_hash_entry *)
@@ -450,10 +440,7 @@ coff_link_add_symbols (abfd, info)
                         ((size_t) symcount
                          * sizeof (struct coff_link_hash_entry *))));
   if (sym_hash == NULL && symcount != 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   obj_coff_sym_hashes (abfd) = sym_hash;
   memset (sym_hash, 0,
          (size_t) symcount * sizeof (struct coff_link_hash_entry *));
@@ -531,7 +518,6 @@ coff_link_add_symbols (abfd, info)
                  (*sym_hash)->type = sym.n_type;
                  (*sym_hash)->numaux = sym.n_numaux;
                  (*sym_hash)->auxbfd = abfd;
-                 (*sym_hash)->toc_offset = 1;
                  if (sym.n_numaux != 0)
                    {
                      union internal_auxent *alloc;
@@ -544,10 +530,7 @@ coff_link_add_symbols (abfd, info)
                                                  (sym.n_numaux
                                                   * sizeof (*alloc))));
                      if (alloc == NULL)
-                       {
-                         bfd_set_error (bfd_error_no_memory);
-                         return false;
-                       }
+                       return false;
                      for (i = 0, eaux = esym + symesz, iaux = alloc;
                           i < sym.n_numaux;
                           i++, eaux += symesz, iaux++)
@@ -974,25 +957,28 @@ _bfd_coff_final_link (abfd, info)
     }
 
   /* Write out the string table.  */
-  if (bfd_seek (abfd,
-               (obj_sym_filepos (abfd)
-                + obj_raw_syment_count (abfd) * symesz),
-               SEEK_SET) != 0)
-    return false;
+  if (obj_raw_syment_count (abfd) != 0)
+    {
+      if (bfd_seek (abfd,
+                   (obj_sym_filepos (abfd)
+                    + obj_raw_syment_count (abfd) * symesz),
+                   SEEK_SET) != 0)
+       return false;
 
 #if STRING_SIZE_SIZE == 4
-  bfd_h_put_32 (abfd,
-               _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
-               (bfd_byte *) strbuf);
+      bfd_h_put_32 (abfd,
+                   _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+                   (bfd_byte *) strbuf);
 #else
  #error Change bfd_h_put_32
 #endif
 
-  if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
-    return false;
+      if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
+       return false;
 
-  if (! _bfd_stringtab_emit (abfd, finfo.strtab))
-    return false;
+      if (! _bfd_stringtab_emit (abfd, finfo.strtab))
+       return false;
+    }
 
   _bfd_stringtab_free (finfo.strtab);
 
@@ -1373,10 +1359,7 @@ coff_link_input_bfd (finfo, input_bfd)
                bfd_alloc (input_bfd,
                           sizeof (struct coff_debug_merge_type)));
          if (mt == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
          mt->class = isym.n_sclass;
 
          /* Pick up the aux entry, which points to the end of the tag
@@ -1404,10 +1387,7 @@ coff_link_input_bfd (finfo, input_bfd)
                      bfd_alloc (input_bfd,
                                 sizeof (struct coff_debug_merge_element)));
              if (*epp == NULL)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 return false;
-               }
+               return false;
 
              elename = _bfd_coff_internal_syment_name (input_bfd, islp,
                                                        elebuf);
@@ -1416,10 +1396,7 @@ coff_link_input_bfd (finfo, input_bfd)
 
              copy = (char *) bfd_alloc (input_bfd, strlen (elename) + 1);
              if (copy == NULL)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 return false;
-               }
+               return false;
              strcpy (copy, elename);
 
              (*epp)->name = copy;
@@ -2227,10 +2204,7 @@ coff_reloc_link_order (output_bfd, finfo, output_section, link_order)
       size = bfd_get_reloc_size (howto);
       buf = (bfd_byte *) bfd_zmalloc (size);
       if (buf == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       rstat = _bfd_relocate_contents (howto, output_bfd,
                                      link_order->u.reloc.p->addend, buf);
index c741efe06e0b25cc21c17f977fab9a3af2ba1226..fbc6028a4ef8607bea9e5c0a080ed787161ae197 100644 (file)
@@ -82,10 +82,7 @@ _bfd_ecoff_mkobject (abfd)
   abfd->tdata.ecoff_obj_data = ((struct ecoff_tdata *)
                                bfd_zalloc (abfd, sizeof (ecoff_data_type)));
   if (abfd->tdata.ecoff_obj_data == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   return true;
 }
@@ -580,10 +577,7 @@ _bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug)
     }
   raw = (PTR) bfd_alloc (abfd, raw_size);
   if (raw == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   if (bfd_seek (abfd,
                (ecoff_data (abfd)->sym_filepos
                 + backend->debug_swap.external_hdr_size),
@@ -629,10 +623,7 @@ _bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug)
                                         (internal_symhdr->ifdMax *
                                          sizeof (struct fdr)));
   if (debug->fdr == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   external_fdr_size = backend->debug_swap.external_fdr_size;
   fdr_ptr = debug->fdr;
   fraw_src = (char *) debug->external_fdr;
@@ -665,10 +656,7 @@ _bfd_ecoff_make_empty_symbol (abfd)
 
   new = (ecoff_symbol_type *) bfd_alloc (abfd, sizeof (ecoff_symbol_type));
   if (new == (ecoff_symbol_type *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (asymbol *) NULL;
-    }
+    return (asymbol *) NULL;
   memset ((PTR) new, 0, sizeof *new);
   new->symbol.section = (asection *) NULL;
   new->fdr = (FDR *) NULL;
@@ -882,10 +870,7 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, weak)
 
                copy = (char *) bfd_alloc (abfd, strlen (name) + 1);
                if (!copy)
-                 {
-                   bfd_set_error (bfd_error_no_memory);
-                   return false;
-                 }
+                 return false;
                strcpy (copy, name);
                section = bfd_make_section (abfd, copy);
              }
@@ -894,10 +879,7 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, weak)
            reloc_chain =
              (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
            if (!reloc_chain)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               return false;
-             }
+             return false;
            reloc_chain->relent.sym_ptr_ptr =
              bfd_get_section (asym)->symbol_ptr_ptr;
            reloc_chain->relent.address = section->_raw_size;
@@ -968,10 +950,7 @@ _bfd_ecoff_slurp_symbol_table (abfd)
   internal_size = bfd_get_symcount (abfd) * sizeof (ecoff_symbol_type);
   internal = (ecoff_symbol_type *) bfd_alloc (abfd, internal_size);
   if (internal == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   internal_ptr = internal;
   eraw_src = (char *) ecoff_data (abfd)->debug_info.external_ext;
@@ -1697,10 +1676,7 @@ ecoff_slurp_reloc_table (abfd, section, symbols)
   external_relocs = (char *) bfd_alloc (abfd, external_relocs_size);
   if (internal_relocs == (arelent *) NULL
       || external_relocs == (char *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   if (bfd_seek (abfd, section->rel_filepos, SEEK_SET) != 0)
     return false;
   if (bfd_read (external_relocs, 1, external_relocs_size, abfd)
@@ -1857,10 +1833,7 @@ _bfd_ecoff_find_nearest_line (abfd, section, ignore_symbols, offset,
        ((struct ecoff_find_line *)
         bfd_alloc (abfd, sizeof (struct ecoff_find_line)));
       if (ecoff_data (abfd)->find_line_info == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       ecoff_data (abfd)->find_line_info->find_buffer = NULL;
       ecoff_data (abfd)->find_line_info->fdrtab_len = 0;
       ecoff_data (abfd)->find_line_info->fdrtab = NULL;
@@ -2759,10 +2732,7 @@ _bfd_ecoff_write_object_contents (abfd)
          reloc_buff =
            bfd_alloc (abfd, current->reloc_count * external_reloc_size);
          if (reloc_buff == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             goto error_return;
-           }
+           goto error_return;
 
          reloc_ptr_ptr = current->orelocation;
          reloc_end = reloc_ptr_ptr + current->reloc_count;
@@ -3027,10 +2997,7 @@ _bfd_ecoff_slurp_armap (abfd)
     
   raw_armap = (char *) bfd_alloc (abfd, parsed_size);
   if (raw_armap == (char *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
     
   if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
     {
@@ -3099,10 +3066,7 @@ _bfd_ecoff_slurp_armap (abfd)
                bfd_alloc (abfd,
                           ardata->symdef_count * sizeof (struct symdef)));
   if (!symdef_ptr)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   ardata->symdefs = (carsym *) symdef_ptr;
 
@@ -3216,10 +3180,7 @@ _bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx)
   
   hashtable = (bfd_byte *) bfd_zalloc (abfd, symdefsize);
   if (!hashtable)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   current = abfd->archive_head;
   last_elt = current;
@@ -3318,10 +3279,7 @@ _bfd_ecoff_archive_p (abfd)
     (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
 
   if (bfd_ardata (abfd) == (struct artdata *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (const bfd_target *) NULL;
-    }
+    return (const bfd_target *) NULL;
 
   bfd_ardata (abfd)->first_file_filepos = SARMAG;
   bfd_ardata (abfd)->cache = NULL;
@@ -3372,10 +3330,7 @@ ecoff_link_hash_newfunc (entry, table, string)
     ret = ((struct ecoff_link_hash_entry *)
           bfd_hash_allocate (table, sizeof (struct ecoff_link_hash_entry)));
   if (ret == (struct ecoff_link_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct ecoff_link_hash_entry *)
@@ -3406,10 +3361,7 @@ _bfd_ecoff_bfd_link_hash_table_create (abfd)
   ret = ((struct ecoff_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct ecoff_link_hash_table)));
   if (ret == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   if (! _bfd_link_hash_table_init (&ret->root, abfd,
                                   ecoff_link_hash_newfunc))
     {
@@ -3839,10 +3791,7 @@ ecoff_link_add_externals (abfd, info, external_ext, ssext)
              bfd_alloc (abfd,
                         ext_count * sizeof (struct bfd_link_hash_entry *)));
   if (!sym_hash)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   ecoff_data (abfd)->sym_hashes = sym_hash;
 
   ext_ptr = (char *) external_ext;
@@ -4677,10 +4626,7 @@ ecoff_reloc_link_order (output_bfd, info, output_section, link_order)
       size = bfd_get_reloc_size (rel.howto);
       buf = (bfd_byte *) bfd_zmalloc (size);
       if (buf == (bfd_byte *) NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       rstat = _bfd_relocate_contents (rel.howto, output_bfd, addend, buf);
       switch (rstat)
        {
index d527f934e4219d6dfe87da64ee93ffbc0b99730f..b8b0631ade1d5cf7c9579576e69608467f3e2619 100644 (file)
@@ -318,10 +318,7 @@ string_hash_newfunc (entry, table, string)
     ret = ((struct string_hash_entry *)
           bfd_hash_allocate (table, sizeof (struct string_hash_entry)));
   if (ret == (struct string_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct string_hash_entry *)
@@ -1226,10 +1223,7 @@ bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug,
     return false;
   symbols = (asymbol **) bfd_alloc (output_bfd, symsize);
   if (symbols == (asymbol **) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   symcount = bfd_canonicalize_symtab (input_bfd, symbols);
   if (symcount < 0)
     return false;
@@ -1880,10 +1874,7 @@ mk_fdrtab (abfd, debug_info, debug_swap, line_info)
                       bfd_zalloc (abfd,
                                   len * sizeof (struct ecoff_fdrtab_entry)));
   if (line_info->fdrtab == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   line_info->fdrtab_len = len;
 
   tab = line_info->fdrtab;
index 677bb45d404e2d351794194b4cafa0e45cf91dd5..c6d885f5ed45c378311689ff844943068e5f28a1 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -83,10 +83,7 @@ elf_read (abfd, offset, size)
   char *buf;
 
   if ((buf = bfd_alloc (abfd, size)) == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   if (bfd_seek (abfd, offset, SEEK_SET) == -1)
     return NULL;
   if (bfd_read ((PTR) buf, size, 1, abfd) != size)
@@ -107,10 +104,7 @@ elf_mkobject (abfd)
   elf_tdata (abfd) = (struct elf_obj_tdata *)
     bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
   if (elf_tdata (abfd) == 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   /* since everything is done at close time, do we need any
      initialization? */
 
@@ -441,10 +435,7 @@ _bfd_elf_link_hash_newfunc (entry, table, string)
     ret = ((struct elf_link_hash_entry *)
           bfd_hash_allocate (table, sizeof (struct elf_link_hash_entry)));
   if (ret == (struct elf_link_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_hash_entry *) ret;
-    }
+    return (struct bfd_hash_entry *) ret;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct elf_link_hash_entry *)
@@ -498,10 +489,7 @@ _bfd_elf_link_hash_table_create (abfd)
   ret = ((struct elf_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct elf_link_hash_table)));
   if (ret == (struct elf_link_hash_table *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc))
     {
@@ -804,10 +792,7 @@ _bfd_elf_new_section_hook (abfd, sec)
 
   sdata = (struct bfd_elf_section_data *) bfd_alloc (abfd, sizeof (*sdata));
   if (!sdata)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   sec->used_by_bfd = (PTR) sdata;
   memset (sdata, 0, sizeof (*sdata));
   return true;
@@ -852,10 +837,7 @@ bfd_section_from_phdr (abfd, hdr, index)
   sprintf (namebuf, split ? "segment%da" : "segment%d", index);
   name = bfd_alloc (abfd, strlen (namebuf) + 1);
   if (!name)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   strcpy (name, namebuf);
   newsect = bfd_make_section (abfd, name);
   if (newsect == NULL)
@@ -886,10 +868,7 @@ bfd_section_from_phdr (abfd, hdr, index)
       sprintf (namebuf, "segment%db", index);
       name = bfd_alloc (abfd, strlen (namebuf) + 1);
       if (!name)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       strcpy (name, namebuf);
       newsect = bfd_make_section (abfd, name);
       if (newsect == NULL)
@@ -1032,7 +1011,6 @@ elf_fake_sections (abfd, asect, failedptrarg)
       name = bfd_alloc (abfd, sizeof ".rela" + strlen (asect->name));
       if (name == NULL)
        {
-         bfd_set_error (bfd_error_no_memory);
          *failedptr = true;
          return;
        }
@@ -1101,17 +1079,13 @@ assign_section_numbers (abfd)
   i_shdrp = ((Elf_Internal_Shdr **)
             bfd_alloc (abfd, section_number * sizeof (Elf_Internal_Shdr *)));
   if (i_shdrp == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   i_shdrp[0] = ((Elf_Internal_Shdr *)
                bfd_alloc (abfd, sizeof (Elf_Internal_Shdr)));
   if (i_shdrp[0] == NULL)
     {
       bfd_release (abfd, i_shdrp);
-      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   memset (i_shdrp[0], 0, sizeof (Elf_Internal_Shdr));
@@ -1277,10 +1251,7 @@ elf_map_symbols (abfd)
   max_index++;
   sect_syms = (asymbol **) bfd_zalloc (abfd, max_index * sizeof (asymbol *));
   if (sect_syms == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   elf_section_syms (abfd) = sect_syms;
 
   for (idx = 0; idx < symcount; idx++)
@@ -1357,10 +1328,7 @@ elf_map_symbols (abfd)
              bfd_alloc (abfd,
                         (num_locals + num_globals) * sizeof (asymbol *)));
   if (new_syms == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   for (idx = 0; idx < symcount; idx++)
     {
@@ -1536,10 +1504,7 @@ make_mapping (abfd, sections, from, to)
                   (sizeof (struct elf_segment_map)
                    + (to - from - 1) * sizeof (asection *))));
   if (m == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   m->next = NULL;
   m->p_type = PT_LOAD;
   for (i = from, hdrpp = sections + from; i < to; i++, hdrpp++)
@@ -1611,10 +1576,7 @@ map_sections_to_segments (abfd)
       m = ((struct elf_segment_map *)
           bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
       if (m == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
       m->next = NULL;
       m->p_type = PT_PHDR;
       /* FIXME: UnixWare and Solaris set PF_X, Irix 5 does not.  */
@@ -1627,10 +1589,7 @@ map_sections_to_segments (abfd)
       m = ((struct elf_segment_map *)
           bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
       if (m == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
       m->next = NULL;
       m->p_type = PT_INTERP;
       m->count = 1;
@@ -1697,10 +1656,7 @@ map_sections_to_segments (abfd)
       m = ((struct elf_segment_map *)
           bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
       if (m == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
       m->next = NULL;
       m->p_type = PT_DYNAMIC;
       m->count = 1;
@@ -1821,10 +1777,7 @@ assign_file_positions_for_segments (abfd)
   phdrs = ((Elf_Internal_Phdr *)
           bfd_alloc (abfd, alloc * sizeof (Elf_Internal_Phdr)));
   if (phdrs == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   off = bed->s->sizeof_ehdr;
   off += alloc * bed->s->sizeof_phdr;
@@ -2503,10 +2456,7 @@ copy_private_bfd_data (ibfd, obfd)
                      (sizeof (struct elf_segment_map)
                       + (csecs - 1) * sizeof (asection *))));
       if (m == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       m->next = NULL;
       m->p_type = p->p_type;
@@ -2678,10 +2628,7 @@ swap_out_syms (abfd, sttp)
     outbound_syms = bfd_alloc (abfd,
                               (1 + symcount) * bed->s->sizeof_sym);
     if (outbound_syms == NULL)
-      {
-       bfd_set_error (bfd_error_no_memory);
-       return false;
-      }
+      return false;
     symtab_hdr->contents = (PTR) outbound_syms;
 
     /* now generate the data (for "contents") */
@@ -2948,10 +2895,7 @@ _bfd_elf_make_empty_symbol (abfd)
 
   newsym = (elf_symbol_type *) bfd_zalloc (abfd, sizeof (elf_symbol_type));
   if (!newsym)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   else
     {
       newsym->symbol.the_bfd = abfd;
index 0e92f4e69b03b12dc5772f25ab746423ea6cc94e..80172d660249a340a4595ddc19686ec8505fedc6 100644 (file)
@@ -21,14 +21,14 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "obstack.h"
-#include "libelf.h"
+#include "elf-bfd.h"
 
 /* The internal type of a symbol table extension entry.  */
 typedef unsigned long symext_entryS;
@@ -219,7 +219,7 @@ static void elf_info_to_howto
   PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
 
 static boolean elf32_hppa_backend_symbol_table_processing
-  PARAMS ((bfd *, elf_symbol_type *, int));
+  PARAMS ((bfd *, elf_symbol_type *, unsigned int));
 
 static void elf32_hppa_backend_begin_write_processing
   PARAMS ((bfd *, struct bfd_link_info *));
@@ -575,10 +575,7 @@ elf32_hppa_stub_hash_newfunc (entry, table, string)
           bfd_hash_allocate (table,
                              sizeof (struct elf32_hppa_stub_hash_entry)));
   if (ret == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct elf32_hppa_stub_hash_entry *)
@@ -630,10 +627,7 @@ elf32_hppa_args_hash_newfunc (entry, table, string)
           bfd_hash_allocate (table,
                              sizeof (struct elf32_hppa_args_hash_entry)));
   if (ret == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct elf32_hppa_args_hash_entry *)
@@ -659,10 +653,7 @@ elf32_hppa_link_hash_table_create (abfd)
   ret = ((struct elf32_hppa_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct elf32_hppa_link_hash_table)));
   if (ret == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
                                      _bfd_elf_link_hash_newfunc))
     {
@@ -785,7 +776,7 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
     {
       int r_type;
       reloc_howto_type *howto;
-      long r_symndx;
+      unsigned long r_symndx;
       struct elf_link_hash_entry *h;
       Elf_Internal_Sym *sym;
       asection *sym_sec;
@@ -945,11 +936,12 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
    relocation with modifications based on format and field.  */
 
 elf32_hppa_reloc_type **
-hppa_elf_gen_reloc_type (abfd, base_type, format, field)
+hppa_elf_gen_reloc_type (abfd, base_type, format, field, ignore)
      bfd *abfd;
      elf32_hppa_reloc_type base_type;
      int format;
      int field;
+     int ignore;
 {
   elf32_hppa_reloc_type *finaltype;
   elf32_hppa_reloc_type **final_types;
@@ -1786,10 +1778,7 @@ add_entry_to_symext_chain (abfd, arg_reloc, sym_idx, symext_root, symext_last)
   /* Allocate memory and initialize this entry.  */
   symextP = (symext_chainS *) bfd_alloc (abfd, sizeof (symext_chainS) * 2);
   if (!symextP)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      abort();                 /* FIXME */
-    }
+    abort();                   /* FIXME */
 
   symextP[0].entry = ELF32_PARISC_SX_WORD (PARISC_SXT_SYMNDX, sym_idx);
   symextP[0].next = &symextP[1];
@@ -1829,10 +1818,7 @@ elf_hppa_tc_make_sections (abfd, symext_root)
   symextn_contents = (bfd_byte *) bfd_zalloc (abfd,
                                              symextn_sec->_raw_size);
   if (!symextn_contents)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      abort();                 /* FIXME */
-    }
+    abort();                   /* FIXME */
 
   /* Fill in the contents of the symbol extension chain.  */
   for (i = 0, symextP = symext_root; symextP; symextP = symextP->next, ++i)
@@ -1850,7 +1836,7 @@ static boolean
 elf32_hppa_backend_symbol_table_processing (abfd, esyms,symcnt)
      bfd *abfd;
      elf_symbol_type *esyms;
-     int symcnt;
+     unsigned int symcnt;
 {
   Elf32_Internal_Shdr *symextn_hdr =
     bfd_elf_find_section (abfd, SYMEXTN_SECTION_NAME);
@@ -1870,10 +1856,7 @@ elf32_hppa_backend_symbol_table_processing (abfd, esyms,symcnt)
   /* Allocate a buffer of the appropriate size for the symextn section.  */
   symextn_hdr->contents = bfd_zalloc(abfd,symextn_hdr->sh_size);
   if (!symextn_hdr->contents)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   /* Read in the symextn section.  */
   if (bfd_seek (abfd, symextn_hdr->sh_offset, SEEK_SET) == -1)
@@ -1948,7 +1931,7 @@ elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table, local_syms)
       return true;
     }
 
-  contents = (bfd_byte *) malloc (symextn_sec->_raw_size);
+  contents = (bfd_byte *) malloc ((size_t) symextn_sec->_raw_size);
   if (contents == NULL)
     {
       bfd_set_error (bfd_error_no_memory);
@@ -2502,10 +2485,7 @@ elf32_hppa_build_stubs (stub_bfd, info)
   size = bfd_section_size (stub_bfd, stub_sec);
   stub_sec->contents = (unsigned char *) bfd_zalloc (stub_bfd, size);
   if (stub_sec->contents == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   table = elf32_hppa_hash_table(info)->stub_hash_table;
   table->location = stub_sec->contents;
 
@@ -2757,7 +2737,8 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info)
          irelaend = irela + section->reloc_count;
          for (; irela < irelaend; irela++)
            {
-             long r_type, callee_args, caller_args, r_index, size_of_stub;
+             long r_type, callee_args, caller_args, size_of_stub;
+             unsigned long r_index;
              struct elf_link_hash_entry *hash;
              struct elf32_hppa_stub_hash_entry *stub_hash;
              struct elf32_hppa_args_hash_entry *args_hash;
@@ -2948,7 +2929,6 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info)
                                                       stub_name, true, true);
                      if (stub_hash == NULL)
                        {
-                         bfd_set_error (bfd_error_no_memory);
                          free (stub_name);
                          free (internal_relocs);
                          for (i = 0; i < bfd_count; i++)
index a4e10d397dc9b603e7fdc87086ed51dbc72debbb..118ebb07b39a3df3f8c5b8c7cee4e485628f6b9c 100644 (file)
@@ -1550,7 +1550,6 @@ mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
                bfd_alloc (abfd, sizeof (struct mips_elf_find_line)));
          if (fi == NULL)
            {
-             bfd_set_error (bfd_error_no_memory);
              msec->flags = origflags;
              return false;
            }
@@ -1570,7 +1569,6 @@ mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
                                   sizeof (struct fdr))));
          if (fi->d.fdr == NULL)
            {
-             bfd_set_error (bfd_error_no_memory);
              msec->flags = origflags;
              return false;
            }
@@ -1669,10 +1667,7 @@ mips_elf_link_hash_newfunc (entry, table, string)
           bfd_hash_allocate (table,
                              sizeof (struct mips_elf_link_hash_entry)));
   if (ret == (struct mips_elf_link_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_hash_entry *) ret;
-    }
+    return (struct bfd_hash_entry *) ret;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct mips_elf_link_hash_entry *)
@@ -1701,10 +1696,7 @@ mips_elf_link_hash_table_create (abfd)
   ret = ((struct mips_elf_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct mips_elf_link_hash_table)));
   if (ret == (struct mips_elf_link_hash_table *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
                                       mips_elf_link_hash_newfunc))
@@ -2226,6 +2218,9 @@ mips_elf_final_link (abfd, info)
            gptab_bss_sec = o;
          else
            {
+             (*_bfd_error_handler)
+               ("%s: illegal section name `%s'",
+                bfd_get_filename (abfd), o->name);
              bfd_set_error (bfd_error_nonrepresentable_section);
              return false;
            }
@@ -2372,7 +2367,6 @@ mips_elf_final_link (abfd, info)
                     bfd_alloc (abfd, c * sizeof (Elf32_External_gptab)));
          if (ext_tab == NULL)
            {
-             bfd_set_error (bfd_error_no_memory);
              free (tab);
              return false;
            }
index c3ac3112b4e2472a9450a0c7a5614a12eb9364a0..46618e756f114ac672d1afe9e8549fc449003d04 100644 (file)
@@ -310,10 +310,7 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs)
                  size = symtab_hdr->sh_info * sizeof (bfd_vma);
                  local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
                  if (local_got_offsets == NULL)
-                   {
-                     bfd_set_error (bfd_error_no_memory);
-                     return false;
-                   }
+                   return false;
                  elf_local_got_offsets (abfd) = local_got_offsets;
                  for (i = 0; i < symtab_hdr->sh_info; i++)
                    local_got_offsets[i] = (bfd_vma) -1;
@@ -719,10 +716,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
       /* Allocate memory for the section contents.  */
       s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
       if (s->contents == NULL && s->_raw_size != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
     }
 
   if (elf_hash_table (info)->dynamic_sections_created)
index 740ddda375047d0da6a4a24c886282dc37190260..0b28608d012f759f1891c6964f8f6d1ee487ef29 100644 (file)
@@ -495,7 +495,7 @@ elf_object_p (abfd)
   new_tdata = ((struct elf_obj_tdata *)
               bfd_zalloc (abfd, sizeof (struct elf_obj_tdata)));
   if (new_tdata == NULL)
-    goto got_no_memory_error;
+    goto got_no_match;
   elf_tdata (abfd) = new_tdata;
 
   /* Now that we know the byte order, swap in the rest of the header */
@@ -569,7 +569,7 @@ elf_object_p (abfd)
                            bfd_alloc (abfd,
                                       sizeof (i_shdrp) * i_ehdrp->e_shnum));
   if (!i_shdrp || !elf_elfsections (abfd))
-    goto got_no_memory_error;
+    goto got_no_match;
   if (bfd_seek (abfd, i_ehdrp->e_shoff, SEEK_SET) != 0)
     goto got_no_match;
   for (shindex = 0; shindex < i_ehdrp->e_shnum; shindex++)
@@ -585,6 +585,34 @@ elf_object_p (abfd)
        goto got_no_match;
     }
 
+  /* Read in the program headers.  */
+  if (i_ehdrp->e_phnum == 0)
+    elf_tdata (abfd)->phdr = NULL;
+  else
+    {
+      Elf_Internal_Phdr *i_phdr;
+      unsigned int i;
+
+      elf_tdata (abfd)->phdr = ((Elf_Internal_Phdr *)
+                               bfd_alloc (abfd,
+                                          (i_ehdrp->e_phnum
+                                           * sizeof (Elf_Internal_Phdr))));
+      if (elf_tdata (abfd)->phdr == NULL)
+       goto got_no_match;
+      if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) != 0)
+       goto got_no_match;
+      i_phdr = elf_tdata (abfd)->phdr;
+      for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
+       {
+         Elf_External_Phdr x_phdr;
+
+         if (bfd_read ((PTR) &x_phdr, sizeof x_phdr, 1, abfd)
+             != sizeof x_phdr)
+           goto got_no_match;
+         elf_swap_phdr_in (abfd, &x_phdr, i_phdr);
+       }
+    }
+
   /* Read in the string table containing the names of the sections.  We
      will need the base pointer to this table later. */
   /* We read this inline now, so that we don't have to go through
@@ -618,9 +646,6 @@ elf_object_p (abfd)
 got_wrong_format_error:
   bfd_set_error (bfd_error_wrong_format);
   goto got_no_match;
-got_no_memory_error:
-  bfd_set_error (bfd_error_no_memory);
-  goto got_no_match;
 got_no_match:
   if (new_tdata != NULL
       && new_tdata->elf_sect_ptr != NULL)
@@ -671,7 +696,6 @@ write_relocs (abfd, sec, data)
   rela_hdr->contents = (PTR) bfd_alloc (abfd, rela_hdr->sh_size);
   if (rela_hdr->contents == NULL)
     {
-      bfd_set_error (bfd_error_no_memory);
       *failedp = true;
       return;
     }
@@ -799,10 +823,7 @@ write_shdrs_and_ehdr (abfd)
   x_shdrp = (Elf_External_Shdr *)
     bfd_alloc (abfd, sizeof (*x_shdrp) * (i_ehdrp->e_shnum));
   if (!x_shdrp)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   for (count = 0; count < i_ehdrp->e_shnum; count++)
     {
@@ -865,10 +886,7 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic)
       symbase = ((elf_symbol_type *)
                 bfd_zalloc (abfd, symcount * sizeof (elf_symbol_type)));
       if (symbase == (elf_symbol_type *) NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return -1;
-       }
+       return -1;
       sym = symbase;
 
       /* Temporarily allocate room for the raw ELF symbols.  */
@@ -1052,10 +1070,7 @@ elf_slurp_reloc_table (abfd, asect, symbols)
   relents = ((arelent *)
             bfd_alloc (abfd, asect->reloc_count * sizeof (arelent)));
   if (relents == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto error_return;
-    }
+    goto error_return;
 
   entsize = d->rel_hdr.sh_entsize;
   BFD_ASSERT (entsize == sizeof (Elf_External_Rel)
index 558dd0da051e4cf928c8d80b3c82374a7edc7d90..7e4403d78d2aed8e10dbf2e53db1e6a46c2eecb0 100644 (file)
@@ -15,10 +15,10 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 /* Core file support */
 
-#ifdef HAVE_PROCFS             /* Some core file support requires host /proc files */
+#ifdef HAVE_SYS_PROCFS_H               /* Some core file support requires host /proc files */
 #include <sys/procfs.h>
 #else
 #define bfd_prstatus(abfd, descdata, descsz, filepos) true
@@ -26,7 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define bfd_prpsinfo(abfd, descdata, descsz, filepos) true
 #endif
 
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
 
 static boolean
 bfd_prstatus (abfd, descdata, descsz, filepos)
@@ -67,10 +67,7 @@ bfd_prpsinfo (abfd, descdata, descsz, filepos)
   if (descsz == sizeof (prpsinfo_t))
     {
       if ((core_prpsinfo (abfd) = bfd_alloc (abfd, descsz)) == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       memcpy (core_prpsinfo (abfd), descdata, descsz);
     }
   return true;
@@ -95,7 +92,7 @@ bfd_fpregset (abfd, descdata, descsz, filepos)
   return true;
 }
 
-#endif /* HAVE_PROCFS */
+#endif /* HAVE_SYS_PROCFS_H */
 
 /* Return a pointer to the args (including the command name) that were
    seen by the program that generated the core dump.  Note that for
@@ -107,7 +104,7 @@ char *
 elf_core_file_failing_command (abfd)
      bfd *abfd;
 {
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
   if (core_prpsinfo (abfd))
     {
       prpsinfo_t *p = core_prpsinfo (abfd);
@@ -135,7 +132,7 @@ int
 elf_core_file_failing_signal (abfd)
      bfd *abfd;
 {
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
   if (core_prstatus (abfd))
     {
       return ((prstatus_t *) (core_prstatus (abfd)))->pr_cursig;
@@ -155,7 +152,7 @@ elf_core_file_matches_executable_p (core_bfd, exec_bfd)
      bfd *core_bfd;
      bfd *exec_bfd;
 {
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
   char *corename;
   char *execname;
 #endif
@@ -168,7 +165,7 @@ elf_core_file_matches_executable_p (core_bfd, exec_bfd)
       return false;
     }
 
-#ifdef HAVE_PROCFS
+#ifdef HAVE_SYS_PROCFS_H
 
   /* If no prpsinfo, just return true.  Otherwise, grab the last component
      of the exec'd pathname from the prpsinfo. */
@@ -201,7 +198,7 @@ elf_core_file_matches_executable_p (core_bfd, exec_bfd)
 
   return true;
 
-#endif /* HAVE_PROCFS */
+#endif /* HAVE_SYS_PROCFS_H */
 }
 
 /* ELF core files contain a segment of type PT_NOTE, that holds much of
@@ -218,11 +215,11 @@ elf_core_file_matches_executable_p (core_bfd, exec_bfd)
    the bfd client will have to interpret the structures itself.  Even with
    /proc support, it might want these full structures for it's own reasons.
 
-   In the second level of support, where HAVE_PROCFS is defined, bfd will
-   pick apart the structures to gather some additional information that
-   clients may want, such as the general register set, the name of the
-   exec'ed file and its arguments, the signal (if any) that caused the
-   core dump, etc.
+   In the second level of support, where HAVE_SYS_PROCFS_H is defined,
+   bfd will pick apart the structures to gather some additional
+   information that clients may want, such as the general register
+   set, the name of the exec'ed file and its arguments, the signal (if
+   any) that caused the core dump, etc.
 
    */
 
@@ -241,7 +238,7 @@ elf_corefile_note (abfd, hdr)
   asection *newsect;
 
   if (hdr->p_filesz > 0
-      && (buf = (char *) malloc (hdr->p_filesz)) != NULL
+      && (buf = (char *) malloc ((size_t) hdr->p_filesz)) != NULL
       && bfd_seek (abfd, hdr->p_offset, SEEK_SET) != -1
       && bfd_read ((PTR) buf, hdr->p_filesz, 1, abfd) == hdr->p_filesz)
     {
@@ -388,10 +385,7 @@ elf_core_file_p (abfd)
   elf_tdata (abfd) =
     (struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
   if (elf_tdata (abfd) == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* FIXME, `wrong' returns from this point onward, leak memory.  */
 
@@ -449,10 +443,7 @@ elf_core_file_p (abfd)
   i_phdrp = (Elf_Internal_Phdr *)
     bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
   if (!i_phdrp)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) == -1)
     return NULL;
   for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
index 37dd4439d9807804d10fe86766ae439fccd81997..cdf3afb4b00bc3972ef781a82bceb9fd707a55fa 100644 (file)
@@ -279,10 +279,7 @@ elf_link_add_object_symbols (abfd, info)
              sz = bfd_section_size (abfd, s);
              msg = (char *) bfd_alloc (abfd, sz);
              if (msg == NULL)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 goto error_return;
-               }
+               goto error_return;
 
              if (! bfd_get_section_contents (abfd, s, msg, (file_ptr) 0, sz))
                goto error_return;
@@ -344,10 +341,7 @@ elf_link_add_object_symbols (abfd, info)
              bfd_alloc (abfd,
                         extsymcount * sizeof (struct elf_link_hash_entry *)));
   if (sym_hash == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto error_return;
-    }
+    goto error_return;
   elf_sym_hashes (abfd) = sym_hash;
 
   if (elf_elfheader (abfd)->e_type != ET_DYN)
@@ -1446,10 +1440,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
       s->_raw_size = dynsymcount * sizeof (Elf_External_Sym);
       s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
       if (s->contents == NULL && s->_raw_size != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       /* The first entry in .dynsym is a dummy symbol.  */
       isym.st_value = 0;
@@ -1473,10 +1464,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
       s->_raw_size = (2 + bucketcount + dynsymcount) * (ARCH_SIZE / 8);
       s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
       if (s->contents == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       memset (s->contents, 0, (size_t) s->_raw_size);
 
       put_word (output_bfd, bucketcount, s->contents);
@@ -1856,10 +1844,7 @@ elf_bfd_final_link (abfd, info)
             so we allocate it with bfd_alloc rather than malloc.  */
          rel_hdr->contents = (PTR) bfd_alloc (abfd, rel_hdr->sh_size);
          if (rel_hdr->contents == NULL && rel_hdr->sh_size != 0)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             goto error_return;
-           }
+           goto error_return;
 
          p = ((struct elf_link_hash_entry **)
               malloc (o->reloc_count
@@ -3044,10 +3029,7 @@ elf_reloc_link_order (output_bfd, info, output_section, link_order)
       size = bfd_get_reloc_size (howto);
       buf = (bfd_byte *) bfd_zmalloc (size);
       if (buf == (bfd_byte *) NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       rstat = _bfd_relocate_contents (howto, output_bfd,
                                      link_order->u.reloc.p->addend, buf);
       switch (rstat)
index 987c259d01c015755ccbaa646483135744602206..8ea4375d5c70172be3d513351fdd4785c6c4ac78 100644 (file)
@@ -16,7 +16,7 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
@@ -234,8 +234,12 @@ EXAMPLE
 . {* Allocate the structure if it has not already been allocated by a
 .    derived class.  *}
 .  if (ret == (@var{entry_type} *) NULL)
-.    ret = ((@var{entry_type} *)
-.         bfd_hash_allocate (table, sizeof (@var{entry_type})));
+.    {
+.      ret = ((@var{entry_type} *)
+.            bfd_hash_allocate (table, sizeof (@var{entry_type})));
+.      if (ret == (@var{entry_type} *) NULL)
+.        return NULL;
+.    }
 .
 . {* Call the allocation method of the base class.  *}
 .  ret = ((@var{entry_type} *)
@@ -311,14 +315,14 @@ bfd_hash_table_init_n (table, newfunc, size)
   alloc = size * sizeof (struct bfd_hash_entry *);
   if (!obstack_begin (&table->memory, alloc))
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   table->table = ((struct bfd_hash_entry **)
                  obstack_alloc (&table->memory, alloc));
   if (!table->table)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   memset ((PTR) table->table, 0, alloc);
@@ -399,7 +403,7 @@ bfd_hash_lookup (table, string, create, copy)
       new = (char *) obstack_alloc (&table->memory, len + 1);
       if (!new)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return (struct bfd_hash_entry *) NULL;
        }
       strcpy (new, string);
@@ -413,6 +417,32 @@ bfd_hash_lookup (table, string, create, copy)
   return hashp;
 }
 
+/* Replace an entry in a hash table.  */
+
+void
+bfd_hash_replace (table, old, nw)
+     struct bfd_hash_table *table;
+     struct bfd_hash_entry *old;
+     struct bfd_hash_entry *nw;
+{
+  unsigned int index;
+  struct bfd_hash_entry **pph;
+
+  index = old->hash % table->size;
+  for (pph = &table->table[index];
+       (*pph) != (struct bfd_hash_entry *) NULL;
+       pph = &(*pph)->next)
+    {
+      if (*pph == old)
+       {
+         *pph = nw;
+         return;
+       }
+    }
+
+  abort ();
+}
+
 /* Base method for creating a new hash table entry.  */
 
 /*ARGSUSED*/
@@ -435,7 +465,12 @@ bfd_hash_allocate (table, size)
      struct bfd_hash_table *table;
      unsigned int size;
 {
-  return obstack_alloc (&table->memory, size);
+  PTR ret;
+
+  ret = obstack_alloc (&table->memory, size);
+  if (ret == NULL && size != 0)
+    bfd_set_error (bfd_error_no_memory);
+  return ret;
 }
 
 /* Traverse a hash table.  */
@@ -459,3 +494,243 @@ bfd_hash_traverse (table, func, info)
        }
     }
 }
+\f
+/* A few different object file formats (a.out, COFF, ELF) use a string
+   table.  These functions support adding strings to a string table,
+   returning the byte offset, and writing out the table.
+
+   Possible improvements:
+   + look for strings matching trailing substrings of other strings
+   + better data structures?  balanced trees?
+   + look at reducing memory use elsewhere -- maybe if we didn't have
+     to construct the entire symbol table at once, we could get by
+     with smaller amounts of VM?  (What effect does that have on the
+     string table reductions?)  */
+
+/* An entry in the strtab hash table.  */
+
+struct strtab_hash_entry
+{
+  struct bfd_hash_entry root;
+  /* Index in string table.  */
+  bfd_size_type index;
+  /* Next string in strtab.  */
+  struct strtab_hash_entry *next;
+};
+
+/* The strtab hash table.  */
+
+struct bfd_strtab_hash
+{
+  struct bfd_hash_table table;
+  /* Size of strtab--also next available index.  */
+  bfd_size_type size;
+  /* First string in strtab.  */
+  struct strtab_hash_entry *first;
+  /* Last string in strtab.  */
+  struct strtab_hash_entry *last;
+  /* Whether to precede strings with a two byte length, as in the
+     XCOFF .debug section.  */
+  boolean xcoff;
+};
+
+static struct bfd_hash_entry *strtab_hash_newfunc
+  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+
+/* Routine to create an entry in a strtab.  */
+
+static struct bfd_hash_entry *
+strtab_hash_newfunc (entry, table, string)
+     struct bfd_hash_entry *entry;
+     struct bfd_hash_table *table;
+     const char *string;
+{
+  struct strtab_hash_entry *ret = (struct strtab_hash_entry *) entry;
+
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (ret == (struct strtab_hash_entry *) NULL)
+    ret = ((struct strtab_hash_entry *)
+          bfd_hash_allocate (table, sizeof (struct strtab_hash_entry)));
+  if (ret == (struct strtab_hash_entry *) NULL)
+    return NULL;
+
+  /* Call the allocation method of the superclass.  */
+  ret = ((struct strtab_hash_entry *)
+        bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+
+  if (ret)
+    {
+      /* Initialize the local fields.  */
+      ret->index = (bfd_size_type) -1;
+      ret->next = NULL;
+    }
+
+  return (struct bfd_hash_entry *) ret;
+}
+
+/* Look up an entry in an strtab.  */
+
+#define strtab_hash_lookup(t, string, create, copy) \
+  ((struct strtab_hash_entry *) \
+   bfd_hash_lookup (&(t)->table, (string), (create), (copy)))
+
+/* Create a new strtab.  */
+
+struct bfd_strtab_hash *
+_bfd_stringtab_init ()
+{
+  struct bfd_strtab_hash *table;
+
+  table = (struct bfd_strtab_hash *) malloc (sizeof (struct bfd_strtab_hash));
+  if (table == NULL)
+    {
+      bfd_set_error (bfd_error_no_memory);
+      return NULL;
+    }
+
+  if (! bfd_hash_table_init (&table->table, strtab_hash_newfunc))
+    {
+      free (table);
+      return NULL;
+    }
+
+  table->size = 0;
+  table->first = NULL;
+  table->last = NULL;
+  table->xcoff = false;
+
+  return table;
+}
+
+/* Create a new strtab in which the strings are output in the format
+   used in the XCOFF .debug section: a two byte length precedes each
+   string.  */
+
+struct bfd_strtab_hash *
+_bfd_xcoff_stringtab_init ()
+{
+  struct bfd_strtab_hash *ret;
+
+  ret = _bfd_stringtab_init ();
+  if (ret != NULL)
+    ret->xcoff = true;
+  return ret;
+}
+
+/* Free a strtab.  */
+
+void
+_bfd_stringtab_free (table)
+     struct bfd_strtab_hash *table;
+{
+  bfd_hash_table_free (&table->table);
+  free (table);
+}
+
+/* Get the index of a string in a strtab, adding it if it is not
+   already present.  If HASH is false, we don't really use the hash
+   table, and we don't eliminate duplicate strings.  */
+
+bfd_size_type
+_bfd_stringtab_add (tab, str, hash, copy)
+     struct bfd_strtab_hash *tab;
+     const char *str;
+     boolean hash;
+     boolean copy;
+{
+  register struct strtab_hash_entry *entry;
+
+  if (hash)
+    {
+      entry = strtab_hash_lookup (tab, str, true, copy);
+      if (entry == NULL)
+       return (bfd_size_type) -1;
+    }
+  else
+    {
+      entry = ((struct strtab_hash_entry *)
+              bfd_hash_allocate (&tab->table,
+                                 sizeof (struct strtab_hash_entry)));
+      if (entry == NULL)
+       return (bfd_size_type) -1;
+      if (! copy)
+       entry->root.string = str;
+      else
+       {
+         char *n;
+
+         n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1);
+         if (n == NULL)
+           return (bfd_size_type) -1;
+         entry->root.string = n;
+       }
+      entry->index = (bfd_size_type) -1;
+      entry->next = NULL;
+    }
+
+  if (entry->index == (bfd_size_type) -1)
+    {
+      entry->index = tab->size;
+      tab->size += strlen (str) + 1;
+      if (tab->xcoff)
+       {
+         entry->index += 2;
+         tab->size += 2;
+       }
+      if (tab->first == NULL)
+       tab->first = entry;
+      else
+       tab->last->next = entry;
+      tab->last = entry;
+    }
+
+  return entry->index;
+}
+
+/* Get the number of bytes in a strtab.  */
+
+bfd_size_type
+_bfd_stringtab_size (tab)
+     struct bfd_strtab_hash *tab;
+{
+  return tab->size;
+}
+
+/* Write out a strtab.  ABFD must already be at the right location in
+   the file.  */
+
+boolean
+_bfd_stringtab_emit (abfd, tab)
+     register bfd *abfd;
+     struct bfd_strtab_hash *tab;
+{
+  register boolean xcoff;
+  register struct strtab_hash_entry *entry;
+
+  xcoff = tab->xcoff;
+
+  for (entry = tab->first; entry != NULL; entry = entry->next)
+    {
+      register const char *str;
+      register size_t len;
+
+      str = entry->root.string;
+      len = strlen (str) + 1;
+
+      if (xcoff)
+       {
+         bfd_byte buf[2];
+
+         /* The output length includes the null byte.  */
+         bfd_put_16 (abfd, len, buf);
+         if (bfd_write ((PTR) buf, 1, 2, abfd) != 2)
+           return false;
+       }
+
+      if (bfd_write ((PTR) str, 1, len, abfd) != len)
+       return false;
+    }
+
+  return true;
+}
index 34ca1edb243f3f2919e9c03f06c845ee68b84365..91b13c48fe052bdf4ac41e2b0d224df0af78eaed 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for HPPA BSD core files.
-   Copyright 1993 Free Software Foundation, Inc.
+   Copyright 1993, 1994 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -15,7 +15,7 @@
 
    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., 675 Mass Ave, Cambridge, MA 02139, USA.
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
    Written by the Center for Software Science at the University of Utah
    and by Cygnus Support. 
@@ -28,9 +28,7 @@
    
 
 /* This file can only be compiled on systems which use HPPA-BSD style
-   core files.  In the config/XXXXXX.mh file for such a system add
-   HDEFINES=-DHPPABSD_CORE
-   HDEPFILES=hppabsd-core.o
+   core files.
 
    I would not expect this to be of use to any other host/target, but
    you never know.  */
@@ -55,9 +53,9 @@
 
 static asection *make_bfd_asection PARAMS ((bfd *, CONST char *,
                                            flagword, bfd_size_type,
-                                           bfd_vma, unsigned int));
+                                           file_ptr, unsigned int));
 static asymbol *hppabsd_core_make_empty_symbol PARAMS ((bfd *));
-static bfd_target *hppabsd_core_core_file_p PARAMS ((bfd *));
+static const bfd_target *hppabsd_core_core_file_p PARAMS ((bfd *));
 static char *hppabsd_core_core_file_failing_command PARAMS ((bfd *));
 static int hppabsd_core_core_file_failing_signal PARAMS ((bfd *));
 static boolean hppabsd_core_core_file_matches_executable_p
@@ -83,12 +81,12 @@ struct hppabsd_core_struct
 #define core_regsec(bfd) (core_hdr(bfd)->reg_section)
 
 static asection *
-make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power)
+make_bfd_asection (abfd, name, flags, _raw_size, offset, alignment_power)
      bfd *abfd;
      CONST char *name;
      flagword flags;
      bfd_size_type _raw_size;
-     bfd_vma vma;
+     file_ptr offset;
      unsigned int alignment_power;
 {
   asection *asect;
@@ -99,8 +97,7 @@ make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power)
 
   asect->flags = flags;
   asect->_raw_size = _raw_size;
-  asect->vma = vma;
-  asect->filepos = bfd_tell (abfd);
+  asect->filepos = offset;
   asect->alignment_power = alignment_power;
 
   return asect;
@@ -116,7 +113,7 @@ hppabsd_core_make_empty_symbol (abfd)
   return new;
 }
 
-static bfd_target *
+static const bfd_target *
 hppabsd_core_core_file_p (abfd)
      bfd *abfd;
 {
@@ -139,6 +136,15 @@ hppabsd_core_core_file_p (abfd)
      for PA 1.0 machines and PA 1.1 machines.   Yuk!  */
   clicksz = u.u_pcb.pcb_pgsz;
 
+  /* clicksz must be a power of two >= 2k.  */
+  if (clicksz < 0x800
+      || clicksz != (clicksz & -clicksz))
+    {
+      bfd_set_error (bfd_error_wrong_format);
+      return NULL;
+    }
+
+
   /* Sanity checks.  Make sure the size of the core file matches the
      the size computed from information within the core itself.  */
   {
@@ -168,10 +174,7 @@ hppabsd_core_core_file_p (abfd)
   coredata = (struct hppabsd_core_struct *)
     bfd_zalloc (abfd, sizeof (struct hppabsd_core_struct));
   if (!coredata)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* Make the core data and available via the tdata part of the BFD.  */
   abfd->tdata.hppabsd_core_data = coredata;
@@ -192,7 +195,7 @@ hppabsd_core_core_file_p (abfd)
   core_datasec (abfd)->vma = UDATASEG;
 
   core_regsec (abfd) = make_bfd_asection (abfd, ".reg",
-                                        SEC_ALLOC + SEC_HAS_CONTENTS,
+                                        SEC_HAS_CONTENTS,
                                         KSTAKSIZE * NBPG,
                                         NBPG * USIZE, 2);
   core_regsec (abfd)->vma = 0;
@@ -236,6 +239,8 @@ hppabsd_core_core_file_matches_executable_p (core_bfd, exec_bfd)
 #define hppabsd_core_get_lineno _bfd_nosymbols_get_lineno
 #define hppabsd_core_find_nearest_line _bfd_nosymbols_find_nearest_line
 #define hppabsd_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+#define hppabsd_core_read_minisymbols _bfd_nosymbols_read_minisymbols
+#define hppabsd_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
 
 /* If somebody calls any byte-swapping routines, shoot them.  */
 static void
@@ -250,7 +255,7 @@ swap_abort ()
 #define        NO_SIGNED_GET \
   ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
 
-bfd_target hppabsd_core_vec =
+const bfd_target hppabsd_core_vec =
   {
     "hppabsd-core",
     bfd_target_unknown_flavour,
@@ -258,12 +263,11 @@ bfd_target hppabsd_core_vec =
     true,                      /* target headers byte order */
     (HAS_RELOC | EXEC_P |      /* object flags */
      HAS_LINENO | HAS_DEBUG |
-     HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+     HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
     (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
     0,                                                    /* symbol prefix */
     ' ',                                                  /* ar_pad_char */
     16,                                                           /* ar_max_namelen */
-    3,                                                    /* minimum alignment power */
     NO_GET, NO_SIGNED_GET, NO_PUT,     /* 64 bit data */
     NO_GET, NO_SIGNED_GET, NO_PUT,     /* 32 bit data */
     NO_GET, NO_SIGNED_GET, NO_PUT,     /* 16 bit data */
@@ -294,6 +298,7 @@ bfd_target hppabsd_core_vec =
        BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
        BFD_JUMP_TABLE_WRITE (_bfd_generic),
        BFD_JUMP_TABLE_LINK (_bfd_nolink),
+       BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
 
     (PTR) 0                    /* backend_data */
 };
index 92260af02503d7d76f11446f1b88126db5994922..094c2c843b7c1bd54277fc1bbd02ece757917dbd 100644 (file)
@@ -36,6 +36,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #define MY(OP) CAT(i386linux_,OP)
 #define TARGETNAME "a.out-i386-linux"
 
+extern const bfd_target MY(vec);
+
 /* We always generate QMAGIC files in preference to ZMAGIC files.  It
    would be possible to make this a linker option, if that ever
    becomes important.  */
@@ -219,10 +221,7 @@ linux_link_hash_table_create (abfd)
   ret = ((struct linux_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
   if (ret == (struct linux_link_hash_table *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_link_hash_table *) NULL;
-    }
+    return (struct bfd_link_hash_table *) NULL;
   if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
                                         linux_link_hash_newfunc))
     {
@@ -585,10 +584,7 @@ bfd_linux_size_dynamic_sections (output_bfd, info)
       s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
       s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
       if (s->contents == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       memset (s->contents, 0, (size_t) s->_raw_size);
     }
 
index 7ed7c7e3b7e5ad5e0255f57a979d3f06c8993727..6b27bd19ed317124b7c063543114a62fd142e1a1 100644 (file)
@@ -15,15 +15,14 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #define BYTES_IN_WORD 4
-#define ARCH 32
 #define N_SHARED_LIB(x) 0
 
 #define TEXT_START_ADDR 0
-#define PAGE_SIZE 4096
-#define SEGMENT_SIZE PAGE_SIZE
+#define TARGET_PAGE_SIZE 4096
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
 #define DEFAULT_ARCH bfd_arch_i386
 
 #define MY(OP) CAT(i386lynx_aout_,OP)
@@ -83,7 +82,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "libaout.h"
 #include "aout/aout64.h"
 
-#ifdef HOST_LYNX
+#ifdef LYNX_CORE
 
 char *lynx_core_file_failing_command ();
 int lynx_core_file_failing_signal ();
@@ -95,7 +94,7 @@ const bfd_target *lynx_core_file_p ();
 #define        MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
 #define        MY_core_file_p lynx_core_file_p
 
-#endif /* HOST_LYNX */
+#endif /* LYNX_CORE */
 \f
 
 #define KEEPIT flags
@@ -144,10 +143,10 @@ NAME(lynx,swap_std_reloc_out) (abfd, g, natptr)
 
 
   if (bfd_is_com_section (output_section)
-      || output_section == &bfd_abs_section
-      || output_section == &bfd_und_section)
+      || bfd_is_abs_section (output_section)
+      || bfd_is_und_section (output_section))
     {
-      if (bfd_abs_section.symbol == sym)
+      if (bfd_abs_section_ptr->symbol == sym)
        {
          /* Whoops, looked like an abs symbol, but is really an offset
           from the abs section */
@@ -231,10 +230,10 @@ NAME(lynx,swap_ext_reloc_out) (abfd, g, natptr)
      */
 
   if (bfd_is_com_section (output_section)
-      || output_section == &bfd_abs_section
-      || output_section == &bfd_und_section)
+      || bfd_is_abs_section (output_section)
+      || bfd_is_und_section (output_section))
     {
-      if (bfd_abs_section.symbol == sym)
+      if (bfd_abs_section_ptr->symbol == sym)
        {
          /* Whoops, looked like an abs symbol, but is really an offset
         from the abs section */
@@ -314,18 +313,19 @@ NAME(lynx,swap_ext_reloc_out) (abfd, g, natptr)
     default:                                                           \
     case N_ABS:                                                                \
     case N_ABS | N_EXT:                                                        \
-     cache_ptr->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;  \
+     cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;     \
       cache_ptr->addend = ad;                                          \
       break;                                                           \
     }                                                                  \
   }                                                                    \
 
 void
-NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols)
+NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
      bfd *abfd;
      struct reloc_ext_external *bytes;
      arelent *cache_ptr;
      asymbol **symbols;
+     bfd_size_type symcount;
 {
   int r_index;
   int r_extern;
@@ -344,11 +344,12 @@ NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols)
 }
 
 void
-NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols)
+NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
      bfd *abfd;
      struct reloc_std_external *bytes;
      arelent *cache_ptr;
      asymbol **symbols;
+     bfd_size_type symcount;
 {
   int r_index;
   int r_extern;
@@ -420,7 +421,6 @@ doit:
   reloc_cache = (arelent *) malloc (count * sizeof (arelent));
   if (!reloc_cache && count != 0)
     {
-    nomem:
       bfd_set_error (bfd_error_no_memory);
       return false;
     }
@@ -430,7 +430,7 @@ doit:
   if (!relocs && reloc_size != 0)
     {
       free (reloc_cache);
-      goto nomem;
+      return false;
     }
 
   if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
@@ -448,7 +448,8 @@ doit:
 
       for (; counter < count; counter++, rptr++, cache_ptr++)
        {
-         NAME(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols);
+         NAME(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols,
+                                       bfd_get_symcount (abfd));
        }
     }
   else
@@ -459,7 +460,8 @@ doit:
 
       for (; counter < count; counter++, rptr++, cache_ptr++)
        {
-         NAME(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols);
+         NAME(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
+                                       bfd_get_symcount (abfd));
        }
 
     }
@@ -493,10 +495,7 @@ NAME(lynx,squirt_out_relocs) (abfd, section)
   natsize = each_size * count;
   native = (unsigned char *) bfd_zalloc (abfd, natsize);
   if (!native)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   generic = section->orelocation;
 
index 5db5a52c90df588c82d26b022dae83619f19c97e..e0d1dd588073408cf134b119b56408f7a036bb5f 100644 (file)
@@ -16,7 +16,7 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 
 #include "bfd.h"
@@ -26,7 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "libaout.h"           /* BFD a.out internal data structures */
 #include "os9k.h"
 
-static bfd_target *os9k_callback PARAMS ((bfd *));
+static const bfd_target *os9k_callback PARAMS ((bfd *));
 
 /* Swaps the information in an executable header taken from a raw byte
    stream memory image, into the internal exec_header structure.  */
@@ -104,7 +104,7 @@ os9k_swap_exec_header_out (abfd, execp, raw_bytes)
 
 #endif /* 0 */
 
-static bfd_target *
+static const bfd_target *
 os9k_object_p (abfd)
      bfd *abfd;
 {
@@ -139,7 +139,7 @@ os9k_object_p (abfd)
 /* Finish up the opening of a b.out file for reading.  Fill in all the
    fields that are not handled by common code.  */
 
-static bfd_target *
+static const bfd_target *
 os9k_callback (abfd)
      bfd *abfd;
 {
@@ -199,23 +199,15 @@ os9k_mkobject (abfd)
 
   rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
   if (rawptr == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   abfd->tdata.bout_data = rawptr;
   exec_hdr (abfd) = &rawptr->e;
 
-  /* For simplicity's sake we just make all the sections right here. */
   obj_textsec (abfd) = (asection *) NULL;
   obj_datasec (abfd) = (asection *) NULL;
   obj_bsssec (abfd) = (asection *) NULL;
 
-  bfd_make_section (abfd, ".text");
-  bfd_make_section (abfd, ".data");
-  bfd_make_section (abfd, ".bss");
-
   return true;
 }
 
@@ -225,6 +217,9 @@ os9k_write_object_contents (abfd)
 {
   struct external_exec swapped_hdr;
 
+  if (! aout_32_make_sections (abfd))
+    return false;
+
   exec_hdr (abfd)->a_info = BMAGIC;
 
   exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size;
@@ -288,12 +283,8 @@ os9k_set_section_contents (abfd, section, location, offset, count)
 
   if (abfd->output_has_begun == false)
     {                          /* set by bfd.c handler */
-      if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL) /*||
-                 (obj_textsec (abfd)->_cooked_size == 0) || (obj_datasec (abfd)->_cooked_size == 0)*/ )
-       {
-         bfd_set_error (bfd_error_invalid_operation);
-         return false;
-       }
+      if (! aout_32_make_sections (abfd))
+       return false;
 
       obj_textsec (abfd)->filepos = sizeof (struct internal_exec);
       obj_datasec (abfd)->filepos = obj_textsec (abfd)->filepos
@@ -329,14 +320,18 @@ os9k_sizeof_headers (ignore_abfd, ignore)
 
 #define aout_32_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
 
+#define aout_32_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
+
 #define os9k_bfd_get_relocated_section_contents \
   bfd_generic_get_relocated_section_contents
 #define os9k_bfd_relax_section bfd_generic_relax_section
 #define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define os9k_bfd_final_link _bfd_generic_final_link
+#define os9k_bfd_link_split_section  _bfd_generic_link_split_section
 
-bfd_target i386os9k_vec =
+const bfd_target i386os9k_vec =
 {
   "i386os9k",                  /* name */
   bfd_target_os9k_flavour,
@@ -347,7 +342,6 @@ bfd_target i386os9k_vec =
   0,                           /* symbol leading char */
   ' ',                         /* ar_pad_char */
   16,                          /* ar_max_namelen */
-  2,                           /* minumum alignment power */
 
   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
   bfd_getl32, bfd_getl_signed_32, bfd_putl32,
index 2d00507574aa0b11812e06067756d363252f4168..6348f6ee3b8e2fbedf4aa7488f1edfff396dabb7 100644 (file)
@@ -201,10 +201,7 @@ read_id (ieee)
   /* Buy memory and read string */
   string = bfd_alloc (ieee->abfd, length + 1);
   if (!string)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   bfd_get_string (ieee, string, length);
   string[length] = 0;
   return string;
@@ -574,10 +571,7 @@ get_symbol (abfd,
       ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd,
                                                 sizeof (ieee_symbol_type));
       if (!new_symbol)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return NULL;
-       }
+       return NULL;
 
       new_symbol->index = new_index;
       last_index = new_index;
@@ -876,10 +870,7 @@ get_section_entry (abfd, ieee, index)
       asection *section;
 
       if (!tmp)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return NULL;
-       }
+       return NULL;
       sprintf (tmp, " fsec%4d", index);
       section = bfd_make_section (abfd, tmp);
       ieee->section_table[index] = section;
@@ -1070,10 +1061,7 @@ ieee_archive_p (abfd)
   ieee_ar_data_type *ieee;
   abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type));
   if (!abfd->tdata.ieee_ar_data)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   ieee = IEEE_AR_DATA (abfd);
 
   /* FIXME: Check return value.  I'm not sure whether it needs to read
@@ -1243,7 +1231,7 @@ ieee_object_p (abfd)
   /* Determine the architecture and machine type of the object file.
      */
   {
-    bfd_arch_info_type *arch = bfd_scan_arch (processor);
+    const bfd_arch_info_type *arch = bfd_scan_arch (processor);
     if (arch == 0)
       goto got_wrong_format;
     abfd->arch_info = arch;
@@ -1297,10 +1285,7 @@ ieee_object_p (abfd)
   IEEE_DATA (abfd)->h.first_byte = (unsigned char *) bfd_alloc (ieee->h.abfd, ieee->w.r.me_record
                                                                + 50);
   if (!IEEE_DATA (abfd)->h.first_byte)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto fail;
-    }
+    goto fail;
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
     goto fail;
   /* FIXME: Check return value.  I'm not sure whether it needs to read
@@ -1421,10 +1406,7 @@ do_one (ieee, current_map, location_ptr, s)
                  (ieee_reloc_type *) bfd_alloc (ieee->h.abfd,
                                                 sizeof (ieee_reloc_type));
                  if (!r)
-                   {
-                     bfd_set_error (bfd_error_no_memory);
-                     return false;
-                   }
+                   return false;
 
                  *(current_map->reloc_tail_ptr) = r;
                  current_map->reloc_tail_ptr = &r->next;
@@ -1595,10 +1577,7 @@ ieee_slurp_section_data (abfd)
       ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;
       per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size);
       if (!per->data)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       /*SUPPRESS 68*/
       per->reloc_tail_ptr =
        (ieee_reloc_type **) & (s->relocation);
@@ -1708,10 +1687,7 @@ ieee_new_section_hook (abfd, newsect)
   newsect->used_by_bfd = (PTR)
     bfd_alloc (abfd, sizeof (ieee_per_section_type));
   if (!newsect->used_by_bfd)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   ieee_per_section (newsect)->data = (bfd_byte *) NULL;
   ieee_per_section (newsect)->section = newsect;
   return true;
@@ -1933,10 +1909,7 @@ do_with_relocs (abfd, s)
          /* Outputting a section without data, fill it up */
          stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));
          if (!stream)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
          memset ((PTR) stream, 0, (size_t) s->_raw_size);
        }
       while (current_byte_index < s->_raw_size)
@@ -2903,10 +2876,7 @@ init_for_output (abfd)
        {
          ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size));
          if (!ieee_per_section (s)->data)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
        }
     }
   return true;
@@ -3325,10 +3295,7 @@ ieee_bfd_debug_info_accumulate (abfd, section)
   {
     bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, sizeof (bfd_chain_type));
     if (!n)
-      {
-       bfd_set_error (bfd_error_no_memory);
-       abort ();               /* FIXME */
-      }
+      abort ();                /* FIXME */
     n->this = section->owner;
     n->next = (bfd_chain_type *) NULL;
 
@@ -3360,6 +3327,7 @@ ieee_bfd_debug_info_accumulate (abfd, section)
   ((boolean (*) \
     PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
    bfd_true)
+#define ieee_read_ar_hdr bfd_nullvoidptr
 #define ieee_update_armap_timestamp bfd_true
 
 #define ieee_bfd_is_local_label bfd_generic_is_local_label
@@ -3372,6 +3340,8 @@ ieee_bfd_debug_info_accumulate (abfd, section)
 
 #define ieee_set_arch_mach _bfd_generic_set_arch_mach
 
+#define ieee_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
 #define ieee_bfd_get_relocated_section_contents \
   bfd_generic_get_relocated_section_contents
 #define ieee_bfd_relax_section bfd_generic_relax_section
index 93ecca9eb6509fc0300f41f501d6c806f9db81f6..4bd8f5824eac1d8ae7cadceebf3f79104a93edd6 100644 (file)
@@ -165,8 +165,13 @@ bfd_zmalloc (size)
 {
   char *ptr = (char *) malloc ((size_t) size);
 
-  if (ptr && size)
-   memset(ptr, 0, (size_t) size);
+  if (size != 0)
+    {
+      if (ptr == NULL)
+       bfd_set_error (bfd_error_no_memory);
+      else
+       memset (ptr, 0, (size_t) size);
+    }
 
   return ptr;
 }
@@ -252,7 +257,7 @@ bfd_init_window (windowp)
 
 #undef HAVE_MPROTECT /* code's not tested yet */
 
-#if HAVE_MMAP || HAVE_MPROTECT
+#if HAVE_MMAP || HAVE_MPROTECT || HAVE_MADVISE
 #include <sys/types.h>
 #include <sys/mman.h>
 #endif
@@ -263,6 +268,12 @@ bfd_init_window (windowp)
 
 static int debug_windows;
 
+/* Currently, if USE_MMAP is undefined, none if the window stuff is
+   used.  Okay, so it's mis-named.  At least the command-line option
+   "--without-mmap" is more obvious than "--without-windows" or some
+   such.  */
+#ifdef USE_MMAP
+
 void
 bfd_free_window (windowp)
      bfd_window *windowp;
@@ -299,6 +310,7 @@ bfd_free_window (windowp)
   /* There should be no more references to i at this point.  */
   free (i);
 }
+#endif
 
 static int ok_to_map = 1;
 
@@ -314,6 +326,10 @@ bfd_get_file_window (abfd, offset, size, windowp, writable)
   bfd_window_internal *i = windowp->i;
   size_t size_to_alloc = size;
 
+#ifndef USE_MMAP
+  abort ();
+#endif
+
   if (debug_windows)
     fprintf (stderr, "bfd_get_file_window (%p, %6ld, %6ld, %p<%p,%lx,%p>, %d)",
             abfd, (long) offset, (long) size,
@@ -386,7 +402,7 @@ bfd_get_file_window (abfd, offset, size, windowp, writable)
        fprintf (stderr, "\n\tmapped %ld at %p, offset is %ld\n",
                 (long) real_size, i->data, (long) offset2);
       i->size = real_size;
-      windowp->data = i->data + offset2;
+      windowp->data = (PTR) ((bfd_byte *) i->data + offset2);
       windowp->size = size;
       i->mapped = 1;
       return true;
@@ -1014,6 +1030,7 @@ _bfd_generic_get_section_contents_in_window (abfd, section, w, offset, count)
      file_ptr offset;
      bfd_size_type count;
 {
+#ifdef USE_MMAP
   if (count == 0)
     return true;
   if (abfd->xvec->_bfd_get_section_contents != _bfd_generic_get_section_contents)
@@ -1045,6 +1062,9 @@ _bfd_generic_get_section_contents_in_window (abfd, section, w, offset, count)
          == false))
     return false;
   return true;
+#else
+  abort ();
+#endif
 }
 
 /* This generic function can only be used in implementations where creating
index 340c9080d74302e1f2a09dbecdc5eff582f01cfe..d8d9f6b5112cd89a86fb58b2bd1140e737a4232b 100644 (file)
@@ -594,10 +594,7 @@ _bfd_generic_link_hash_table_create (abfd)
   ret = ((struct generic_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct generic_link_hash_table)));
   if (ret == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_link_hash_table *) NULL;
-    }
+    return (struct bfd_link_hash_table *) NULL;
   if (! _bfd_link_hash_table_init (&ret->root, abfd,
                                   generic_link_hash_newfunc))
     {
@@ -628,10 +625,7 @@ generic_link_read_symbols (abfd)
        return false;
       abfd->outsymbols = (asymbol **) bfd_alloc (abfd, symsize);
       if (abfd->outsymbols == NULL && symsize != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       symcount = bfd_canonicalize_symtab (abfd, abfd->outsymbols);
       if (symcount < 0)
        return false;
@@ -1188,16 +1182,21 @@ generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
          struct generic_link_hash_entry *h;
 
          name = bfd_asymbol_name (p);
-         if ((p->flags & BSF_INDIRECT) != 0
-             || bfd_is_ind_section (p->section))
-           string = bfd_asymbol_name ((asymbol *) p->value);
-         else if ((p->flags & BSF_WARNING) != 0)
+         if (((p->flags & BSF_INDIRECT) != 0
+              || bfd_is_ind_section (p->section))
+             && pp + 1 < ppend)
+           {
+             pp++;
+             string = bfd_asymbol_name (*pp);
+           }
+         else if ((p->flags & BSF_WARNING) != 0
+                  && pp + 1 < ppend)
            {
              /* The name of P is actually the warning string, and the
-                value is actually a pointer to the symbol to warn
-                about.  */
+                next symbol is the one to warn about.  */
              string = name;
-             name = bfd_asymbol_name ((asymbol *) p->value);
+             pp++;
+             name = bfd_asymbol_name (*pp);
            }
          else
            string = NULL;
@@ -1495,7 +1494,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
        case DEF:
        case DEFW:
          {
-           enum bfd_link_order_type oldtype;
+           enum bfd_link_hash_type oldtype;
 
            /* Define a symbol.  */
            oldtype = h->type;
@@ -1928,10 +1927,7 @@ _bfd_generic_final_link (abfd, info)
                                           (o->reloc_count
                                            * sizeof (arelent *))));
              if (!o->orelocation)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 return false;
-               }
+               return false;
              o->flags |= SEC_RELOC;
              /* Reset the count so that it can be used as an index
                 when putting in the output relocs.  */
@@ -2360,10 +2356,7 @@ _bfd_generic_reloc_link_order (abfd, info, sec, link_order)
 
   r = (arelent *) bfd_alloc (abfd, sizeof (arelent));
   if (r == (arelent *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
       
   r->address = link_order->offset;
   r->howto = bfd_reloc_type_lookup (abfd, link_order->u.reloc.p->reloc);
@@ -2410,10 +2403,7 @@ _bfd_generic_reloc_link_order (abfd, info, sec, link_order)
       size = bfd_get_reloc_size (r->howto);
       buf = (bfd_byte *) bfd_zmalloc (size);
       if (buf == (bfd_byte *) NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       rstat = _bfd_relocate_contents (r->howto, abfd,
                                      link_order->u.reloc.p->addend, buf);
       switch (rstat)
@@ -2464,10 +2454,7 @@ bfd_new_link_order (abfd, section)
   new = ((struct bfd_link_order *)
         bfd_alloc_by_size_t (abfd, sizeof (struct bfd_link_order)));
   if (!new)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   new->type = bfd_undefined_link_order;
   new->offset = 0;
index b18eb658675f1af4df0ef06b67be79f951d6d51c..c70f630af32beaf65272f2f5a02dfe5299612c22 100644 (file)
@@ -16,7 +16,7 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* This file describes the 32 bit Alpha NLM format.  You might think
    that an Alpha chip would use a 64 bit format, but, for some reason,
@@ -461,7 +461,7 @@ nlm_alpha_read_reloc (abfd, sym, secp, rel)
          || r_type == ALPHA_R_GPDISP
          || r_type == ALPHA_R_IGNORE)
        {
-         rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+         rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
          rel->addend = 0;
        }
       else if (r_symndx == ALPHA_RELOC_SECTION_TEXT)
@@ -478,7 +478,7 @@ nlm_alpha_read_reloc (abfd, sym, secp, rel)
       else
        {
          BFD_ASSERT (0);
-         rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+         rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
          rel->addend = 0;
        }
     }
@@ -531,7 +531,7 @@ nlm_alpha_read_reloc (abfd, sym, secp, rel)
         addend, but they do use a special code.  Put this code in the
         addend field.  */
       rel->addend = r_symndx;
-      rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+      rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
       break;
 
     case ALPHA_R_OP_STORE:
@@ -562,7 +562,7 @@ nlm_alpha_read_reloc (abfd, sym, secp, rel)
         some reason the address of this reloc type is not adjusted by
         the section vma.  We record the gp value for this object file
         here, for convenience when doing the GPDISP relocation.  */
-      rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+      rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
       rel->address = r_vaddr;
       rel->addend = gp_value;
       break;
@@ -584,7 +584,7 @@ nlm_alpha_read_reloc (abfd, sym, secp, rel)
        }
       else
        BFD_ASSERT (0);
-      rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+      rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
       break;
 
     default:
@@ -623,33 +623,29 @@ nlm_alpha_read_import (abfd, sym)
   bfd_size_type rcount;                        /* number of relocs */
   bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* temporary 32-bit value */
   unsigned char symlength;             /* length of symbol name */
+  char *name;
 
   if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
       != sizeof (symlength))
     return false;
   sym -> symbol.the_bfd = abfd;
-  sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
-  if (!sym -> symbol.name)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
-  if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
-      != symlength)
+  name = bfd_alloc (abfd, symlength + 1);
+  if (name == NULL)
+    return false;
+  if (bfd_read (name, symlength, 1, abfd) != symlength)
     return false;
+  name[symlength] = '\0';
+  sym -> symbol.name = name;
   sym -> symbol.flags = 0;
   sym -> symbol.value = 0;
-  sym -> symbol.section = &bfd_und_section;
+  sym -> symbol.section = bfd_und_section_ptr;
   if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
     return false;
   rcount = bfd_h_get_32 (abfd, temp);
   nlm_relocs = ((struct nlm_relent *)
                bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
   if (!nlm_relocs)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   sym -> relocs = nlm_relocs;
   sym -> rcnt = 0;
   while (sym -> rcnt < rcount)
@@ -693,7 +689,7 @@ nlm_alpha_write_import (abfd, sec, rel)
        r_vaddr += bfd_section_size (abfd,
                                     bfd_get_section_by_name (abfd,
                                                              NLM_CODE_NAME));
-      if (bfd_get_section (sym) == &bfd_und_section)
+      if (bfd_is_und_section (bfd_get_section (sym)))
        {
          r_extern = 1;
          r_symndx = 0;
@@ -842,7 +838,7 @@ nlm_alpha_write_external (abfd, count, sym, relocs)
 
   /* The first two relocs for each external symbol are the .lita
      address and the GP value.  */
-  r.sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+  r.sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
   r.howto = &nlm32_alpha_nw_howto;
 
   r.address = nlm_alpha_backend_data (abfd)->lita_address;
index a53c67b691c50b0388fe7286630db12cc1790fff..e1df043be437047e2e080e522c24bcc3188ce3dd 100644 (file)
@@ -18,7 +18,7 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include <string.h>            /* For strrchr and friends */
 #include "bfd.h"
@@ -114,7 +114,7 @@ nlm_object_p (abfd)
 
   /* Read in the fixed length portion of the NLM header in external format.  */
 
-  x_fxdhdr = (PTR) malloc (nlm_fixed_header_size (abfd));
+  x_fxdhdr = (PTR) malloc ((size_t) nlm_fixed_header_size (abfd));
   if (x_fxdhdr == NULL)
     {
       bfd_set_error (bfd_error_no_memory);
@@ -136,10 +136,7 @@ nlm_object_p (abfd)
   new_tdata = ((struct nlm_obj_tdata *)
               bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata)));
   if (new_tdata == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto got_no_match;
-    }
+    goto got_no_match;
 
   nlm_tdata (abfd) = new_tdata;
 
@@ -274,7 +271,7 @@ nlm_swap_variable_header_in (abfd)
   if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText,
                nlm_variable_header (abfd)->descriptionLength + 1,
                1, abfd) !=
-      nlm_variable_header (abfd)->descriptionLength + 1)
+      (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
     return (false);
 
   /* Read and convert the stackSize field. */
@@ -307,7 +304,7 @@ nlm_swap_variable_header_in (abfd)
   if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName,
                nlm_variable_header (abfd)->screenNameLength + 1,
                1, abfd) !=
-      nlm_variable_header (abfd)->screenNameLength + 1)
+      (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
     return (false);
 
   /* Read the thread name length and text members. */
@@ -320,7 +317,7 @@ nlm_swap_variable_header_in (abfd)
   if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName,
                nlm_variable_header (abfd)->threadNameLength + 1,
                1, abfd) !=
-      nlm_variable_header (abfd)->threadNameLength + 1)
+      (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
     return (false);
   return (true);
 }
@@ -344,7 +341,7 @@ nlm_swap_variable_header_out (abfd)
   if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText,
                 nlm_variable_header (abfd)->descriptionLength + 1,
                 1, abfd) !=
-      nlm_variable_header (abfd)->descriptionLength + 1)
+      (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
     return (false);
 
   /* Convert and write the stackSize field. */
@@ -379,7 +376,7 @@ nlm_swap_variable_header_out (abfd)
   if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName,
                 nlm_variable_header (abfd)->screenNameLength + 1,
                 1, abfd) !=
-      nlm_variable_header (abfd)->screenNameLength + 1)
+      (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
     return (false);
 
   /* Write the thread name length and text members. */
@@ -392,7 +389,7 @@ nlm_swap_variable_header_out (abfd)
   if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName,
                 nlm_variable_header (abfd)->threadNameLength + 1,
                 1, abfd) !=
-      nlm_variable_header (abfd)->threadNameLength + 1)
+      (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
     return (false);
   return (true);
 }
@@ -522,7 +519,8 @@ nlm_swap_auxiliary_headers_in (abfd)
          if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
                    nlm_copyright_header (abfd)->copyrightMessageLength + 1,
                        1, abfd) !=
-             nlm_copyright_header (abfd)->copyrightMessageLength + 1)
+             ((bfd_size_type)
+              nlm_copyright_header (abfd)->copyrightMessageLength + 1))
            return (false);
        }
       else if (strncmp (tempstr, "CuStHeAd", 8) == 0)
@@ -584,10 +582,7 @@ nlm_swap_auxiliary_headers_in (abfd)
              hdrLength -= 2 * NLM_TARGET_LONG_SIZE + 8;
              hdr = bfd_alloc (abfd, hdrLength);
              if (hdr == NULL)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 return false;
-               }
+               return false;
              if (bfd_read (hdr, 1, hdrLength, abfd) != hdrLength)
                return false;
            }
@@ -608,10 +603,7 @@ nlm_swap_auxiliary_headers_in (abfd)
                return false;
              contents = (bfd_byte *) bfd_alloc (abfd, dataLength);
              if (contents == NULL)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 return false;
-               }
+               return false;
              if (bfd_read (contents, 1, dataLength, abfd) != dataLength)
                return false;
              if (bfd_seek (abfd, pos, SEEK_SET) != 0)
@@ -851,7 +843,8 @@ nlm_swap_auxiliary_headers_out (abfd)
       if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
                     nlm_copyright_header (abfd)->copyrightMessageLength + 1,
                     1, abfd) !=
-         nlm_copyright_header (abfd)->copyrightMessageLength + 1)
+         ((bfd_size_type)
+          nlm_copyright_header (abfd)->copyrightMessageLength + 1))
        return false;
     }
 
@@ -1077,10 +1070,7 @@ nlm_slurp_symbol_table (abfd)
   sym = ((nlm_symbol_type *)
         bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type)));
   if (!sym)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   nlm_set_symbols (abfd, sym);
 
   /* We use the bfd's symcount directly as the control count, so that early
@@ -1097,10 +1087,7 @@ nlm_slurp_symbol_table (abfd)
       sym->symbol.the_bfd = abfd;
       sym->symbol.name = bfd_alloc (abfd, symlength + 1);
       if (!sym->symbol.name)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
          != symlength)
        return (false);
@@ -1156,10 +1143,7 @@ nlm_slurp_symbol_table (abfd)
          sym->symbol.the_bfd = abfd;
          sym->symbol.name = bfd_alloc (abfd, symlength + 1);
          if (!sym->symbol.name)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
          if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
              != symlength)
            return (false);
@@ -1180,7 +1164,7 @@ nlm_slurp_symbol_table (abfd)
            }
          else
            {
-             sym->symbol.section = &bfd_abs_section;
+             sym->symbol.section = bfd_abs_section_ptr;
            }
          sym->rcnt = 0;
          abfd->symcount++;
@@ -1248,10 +1232,7 @@ nlm_slurp_reloc_fixups (abfd)
   rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent));
   secs = (asection **) bfd_alloc (abfd, count * sizeof (asection *));
   if ((rels == NULL || secs == NULL) && count != 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   nlm_relocation_fixups (abfd) = rels;
   nlm_relocation_fixup_secs (abfd) = secs;
 
@@ -1402,7 +1383,7 @@ nlm_compute_section_file_positions (abfd)
   asection *sec;
   bfd_vma text, data, bss;
   bfd_vma text_low, data_low;
-  int text_align, data_align, other_align;
+  unsigned int text_align, data_align, other_align;
   file_ptr text_ptr, data_ptr, other_ptr;
   asection *bss_sec;
   asymbol **sym_ptr_ptr;
@@ -1704,7 +1685,8 @@ nlm_write_object_contents (abfd)
   boolean (*write_prefix_func) PARAMS ((bfd *));
   unsigned char *fixed_header = NULL;
 
-  fixed_header = (unsigned char *) malloc (nlm_fixed_header_size (abfd));
+  fixed_header = ((unsigned char *)
+                 malloc ((size_t) nlm_fixed_header_size (abfd)));
   if (fixed_header == NULL)
     {
       bfd_set_error (bfd_error_no_memory);
@@ -1779,7 +1761,7 @@ nlm_write_object_contents (abfd)
          rel = *rel_ptr_ptr;
          sym = *rel->sym_ptr_ptr;
 
-         if (bfd_get_section (sym) != &bfd_und_section)
+         if (! bfd_is_und_section (bfd_get_section (sym)))
            {
              ++internal_reloc_count;
              if ((*write_import_func) (abfd, sec, rel) == false)
@@ -1800,10 +1782,7 @@ nlm_write_object_contents (abfd)
                                        (external_reloc_count
                                         * sizeof (struct reloc_and_sec)));
   if (external_relocs == (struct reloc_and_sec *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto error_return;
-    }
+    goto error_return;
   i = 0;
   for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
     {
@@ -1822,7 +1801,7 @@ nlm_write_object_contents (abfd)
          rel = *rel_ptr_ptr;
          sym = *rel->sym_ptr_ptr;
 
-         if (bfd_get_section (sym) != &bfd_und_section)
+         if (! bfd_is_und_section (bfd_get_section (sym)))
            continue;
 
          external_relocs[i].rel = rel;
@@ -1893,7 +1872,7 @@ nlm_write_object_contents (abfd)
          sym = *sym_ptr_ptr;
 
          if ((sym->flags & (BSF_EXPORT | BSF_GLOBAL)) == 0
-             || bfd_get_section (sym) == &bfd_und_section)
+             || bfd_is_und_section (bfd_get_section (sym)))
            continue;
 
          ++c;
@@ -1978,7 +1957,7 @@ nlm_write_object_contents (abfd)
                 debugging symbol NLM does not understand at all.  */
              if ((sym->flags & (BSF_LOCAL | BSF_GLOBAL | BSF_EXPORT)) == 0
                  || (sym->flags & BSF_DEBUGGING) != 0
-                 || bfd_get_section (sym) == &bfd_und_section)
+                 || bfd_is_und_section (bfd_get_section (sym)))
                continue;
 
              ++c;
@@ -2065,7 +2044,8 @@ nlm_write_object_contents (abfd)
        goto error_return;
     }
 
-  BFD_ASSERT (bfd_tell (abfd) == nlm_optional_prefix_size (abfd));
+  BFD_ASSERT ((bfd_size_type) bfd_tell (abfd)
+             == nlm_optional_prefix_size (abfd));
 
   nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header);
   if (bfd_write (fixed_header, nlm_fixed_header_size (abfd), 1, abfd)
index 76370645c6ccf513c28726d97f37d99518b11857..71dee970abee620a8c41ad458ed93339a1dc4066 100644 (file)
@@ -118,10 +118,7 @@ oasys_slurp_symbol_table (abfd)
   data->strings = bfd_alloc (abfd, data->symbol_string_length);
 #endif
   if (!data->symbols || !data->strings)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   dest_defined = data->symbols + abfd->symcount - 1;
 
@@ -310,10 +307,7 @@ oasys_archive_p (abfd)
     oasys_module_table_type record;
 
     if (!ar || !module)
-      {
-       bfd_set_error (bfd_error_no_memory);
-       return NULL;
-      }
+      return NULL;
 
     abfd->tdata.oasys_ar_data = ar;
     ar->module = module;
@@ -343,10 +337,7 @@ oasys_archive_p (abfd)
 
            module[i].name = bfd_alloc (abfd, 33);
            if (!module[i].name)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               return NULL;
-             }
+             return NULL;
 
            memcpy (module[i].name, record_ext.mod_name, 33);
            filepos +=
@@ -372,10 +363,7 @@ oasys_archive_p (abfd)
 
            module[i].name = bfd_alloc (abfd, record.module_name_size + 1);
            if (!module[i].name)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               return NULL;
-             }
+             return NULL;
            if (bfd_read ((PTR) module[i].name, 1, record.module_name_size,
                          abfd)
                != record.module_name_size)
@@ -462,10 +450,7 @@ oasys_object_p (abfd)
              }
            buffer = bfd_alloc (abfd, 3);
            if (!buffer)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               goto fail;
-             }
+             goto fail;
            section_number = record.section.relb & RELOCATION_SECT_BITS;
            sprintf (buffer, "%u", section_number);
            s = bfd_make_section (abfd, buffer);
@@ -633,10 +618,7 @@ oasys_slurp_section_data (abfd)
              {
                per->data = (bfd_byte *) bfd_zalloc (abfd, section->_raw_size);
                if (!per->data)
-                 {
-                   bfd_set_error (bfd_error_no_memory);
-                   return false;
-                 }
+                 return false;
                per->reloc_tail_ptr = (oasys_reloc_type **) & (section->relocation);
                per->had_vma = false;
                per->initialized = true;
@@ -703,10 +685,7 @@ oasys_slurp_section_data (abfd)
                                  bfd_alloc (abfd,
                                             sizeof (oasys_reloc_type));
                                  if (!r)
-                                   {
-                                     bfd_set_error (bfd_error_no_memory);
-                                     return false;
-                                   }
+                                   return false;
                                  *(per->reloc_tail_ptr) = r;
                                  per->reloc_tail_ptr = &r->next;
                                  r->next = (oasys_reloc_type *) NULL;
@@ -750,10 +729,7 @@ oasys_slurp_section_data (abfd)
                                  bfd_alloc (abfd,
                                             sizeof (oasys_reloc_type));
                                  if (!r)
-                                   {
-                                     bfd_set_error (bfd_error_no_memory);
-                                     return false;
-                                   }
+                                   return false;
                                  *(per->reloc_tail_ptr) = r;
                                  per->reloc_tail_ptr = &r->next;
                                  r->next = (oasys_reloc_type *) NULL;
@@ -819,10 +795,7 @@ oasys_new_section_hook (abfd, newsect)
   newsect->used_by_bfd = (PTR)
     bfd_alloc (abfd, sizeof (oasys_per_section_type));
   if (!newsect->used_by_bfd)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   oasys_per_section (newsect)->data = (bfd_byte *) NULL;
   oasys_per_section (newsect)->section = newsect;
   oasys_per_section (newsect)->offset = 0;
@@ -1038,6 +1011,9 @@ oasys_write_sections (abfd)
     {
       if (!isdigit (s->name[0]))
        {
+         (*_bfd_error_handler)
+           ("%s: can not represent section `%s' in oasys",
+            bfd_get_filename (abfd), s->name);
          bfd_set_error (bfd_error_nonrepresentable_section);
          return false;
        }
@@ -1345,10 +1321,7 @@ oasys_set_section_contents (abfd, section, location, offset, count)
          oasys_per_section (section)->data =
            (bfd_byte *) (bfd_alloc (abfd, section->_cooked_size));
          if (!oasys_per_section (section)->data)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
        }
       (void) memcpy ((PTR) (oasys_per_section (section)->data + offset),
                     location,
@@ -1373,10 +1346,7 @@ oasys_make_empty_symbol (abfd)
   oasys_symbol_type *new =
   (oasys_symbol_type *) bfd_zalloc (abfd, sizeof (oasys_symbol_type));
   if (!new)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   new->symbol.the_bfd = abfd;
   return &new->symbol;
 }
index f3bc8fc3754c04b263303187ceecae459a878dbb..98db7226a97742d4f9907c4a45b7d522f9f596ab 100644 (file)
@@ -1112,8 +1112,8 @@ static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
   "Special Directory",
   "Thread Storage Directory [.tls]",
   "Load Configuration Directory",
-  "Reserved",
-  "Reserved [first thunk address on PPC]",
+  "Bound Import Directory",
+  "Import Address Table Directory",
   "Reserved",
   "Reserved",
   "Reserved"
@@ -1436,9 +1436,9 @@ pe_print_pdata(abfd, vfile)
 static boolean
 pe_print_private_bfd_data (abfd, vfile)
      bfd *abfd;
-     void *vfile;
+     PTR vfile;
 {
-  FILE *file = vfile;
+  FILE *file = (FILE *) vfile;
   int j;
   pe_data_type *pe = pe_data (abfd);
   struct internal_extra_pe_aouthdr *i = &pe->pe_opthdr;
@@ -1496,10 +1496,7 @@ pe_mkobject (abfd)
     (struct pe_tdata *) bfd_zalloc (abfd, sizeof (pe_data_type));
 
   if (abfd->tdata.pe_obj_data == 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   pe = pe_data (abfd);
 
index e0b24733809f81c40e7a724f03593be22853cd17..9d4721cbd1f8b84c558747b950d345f711d01f1e 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD backend for core files which use the ptrace_user structure
-   Copyright 1993 Free Software Foundation, Inc.
+   Copyright 1993, 1994 Free Software Foundation, Inc.
    The structure of this file is based on trad-core.c written by John Gilmore
    of Cygnus Support.
    Modified to work with the ptrace_user structure by Kevin A. Buettner.
@@ -19,15 +19,7 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-   To use this file on a particular host, configure the host with these
-   parameters in the config/h-HOST file:
-
-       HDEFINES=-DPTRACE_CORE
-       HDEPFILES=ptrace-core.o
-
-*/
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #ifdef PTRACE_CORE
 
@@ -51,7 +43,7 @@ struct trad_core_struct
     asection *stack_section;
     asection *reg_section;
     struct ptrace_user u;
-  } *rawptr;
+  };
 
 #define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
 #define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
@@ -60,20 +52,21 @@ struct trad_core_struct
 
 /* forward declarations */
 
-bfd_target *   ptrace_unix_core_file_p PARAMS ((bfd *abfd));
+const bfd_target *ptrace_unix_core_file_p PARAMS ((bfd *abfd));
 char *         ptrace_unix_core_file_failing_command PARAMS ((bfd *abfd));
 int            ptrace_unix_core_file_failing_signal PARAMS ((bfd *abfd));
 boolean                ptrace_unix_core_file_matches_executable_p
                         PARAMS ((bfd *core_bfd, bfd *exec_bfd));
 
 /* ARGSUSED */
-bfd_target *
+const bfd_target *
 ptrace_unix_core_file_p (abfd)
      bfd *abfd;
 
 {
   int val;
   struct ptrace_user u;
+  struct trad_core_struct *rawptr;
 
   val = bfd_read ((void *)&u, 1, sizeof u, abfd);
   if (val != sizeof u || u.pt_magic != _BCS_PTRACE_MAGIC 
@@ -91,10 +84,8 @@ ptrace_unix_core_file_p (abfd)
   rawptr = (struct trad_core_struct *)
                bfd_zalloc (abfd, sizeof (struct trad_core_struct));
 
-  if (rawptr == NULL) {
-    bfd_set_error (bfd_error_no_memory);
+  if (rawptr == NULL)
     return 0;
-  }
   
   abfd->tdata.trad_core_data = rawptr;
 
@@ -103,24 +94,15 @@ ptrace_unix_core_file_p (abfd)
   /* Create the sections.  This is raunchy, but bfd_close wants to free
      them separately.  */
 
-  core_stacksec(abfd) = (asection *) bfd_zmalloc (sizeof (asection));
-  if (core_stacksec (abfd) == NULL) {
-  loser:
-    bfd_set_error (bfd_error_no_memory);
-    free ((void *)rawptr);
-    return 0;
-  }
-  core_datasec (abfd) = (asection *) zalloc (sizeof (asection));
-  if (core_datasec (abfd) == NULL) {
-  loser1:
-    free ((void *)core_stacksec (abfd));
-    goto loser;
-  }
-  core_regsec (abfd) = (asection *) zalloc (sizeof (asection));
-  if (core_regsec (abfd) == NULL) {
-    free ((void *)core_datasec (abfd));
-    goto loser1;
-  }
+  core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+  if (core_stacksec (abfd) == NULL)
+    return NULL;
+  core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+  if (core_datasec (abfd) == NULL)
+    return NULL;
+  core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+  if (core_regsec (abfd) == NULL)
+    return NULL;
 
   core_stacksec (abfd)->name = ".stack";
   core_datasec (abfd)->name = ".data";
@@ -133,7 +115,7 @@ ptrace_unix_core_file_p (abfd)
 
   core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
   core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
-  core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+  core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
 
   core_datasec (abfd)->_raw_size =  u.pt_dsize;
   core_stacksec (abfd)->_raw_size = u.pt_ssize;
@@ -200,7 +182,7 @@ swap_abort()
 #define        NO_SIGNED_GET \
   ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
 
-bfd_target ptrace_core_vec =
+const bfd_target ptrace_core_vec =
   {
     "trad-core",
     bfd_target_unknown_flavour,
@@ -213,7 +195,6 @@ bfd_target ptrace_core_vec =
     0,                                                    /* symbol prefix */
     ' ',                                                  /* ar_pad_char */
     16,                                                           /* ar_max_namelen */
-    3,                                                    /* minimum alignment power */
     NO_GET, NO_SIGNED_GET, NO_PUT,     /* 64 bit data */
     NO_GET, NO_SIGNED_GET, NO_PUT,     /* 32 bit data */
     NO_GET, NO_SIGNED_GET, NO_PUT,     /* 16 bit data */
@@ -244,6 +225,7 @@ bfd_target ptrace_core_vec =
        BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
        BFD_JUMP_TABLE_WRITE (_bfd_generic),
        BFD_JUMP_TABLE_LINK (_bfd_nolink),
+       BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
 
     (PTR) 0                    /* backend_data */
 };
diff --git a/bfd/riscix.c b/bfd/riscix.c
new file mode 100644 (file)
index 0000000..8489859
--- /dev/null
@@ -0,0 +1,643 @@
+/* BFD back-end for RISC iX (Acorn, arm) binaries.
+   Copyright (C) 1994 Free Software Foundation, Inc.
+   Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
+   
+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
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+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 02111-1307, USA.  */
+
+
+/* RISC iX overloads the MAGIC field to indicate more than just the usual
+   [ZNO]MAGIC values.  Also included are squeezing information and
+   shared library usage.  */
+
+/* The following come from the man page.  */
+#define SHLIBLEN 60
+
+#define MF_IMPURE       00200
+#define MF_SQUEEZED     01000
+#define MF_USES_SL      02000
+#define MF_IS_SL        04000
+
+/* Common combinations.  */
+#define IMAGIC          (MF_IMPURE|ZMAGIC)      /* Demand load (impure text) */
+#define SPOMAGIC        (MF_USES_SL|OMAGIC)     /* OMAGIC with large header */
+                                        /* -- may contain a ref to a */
+                                        /* shared lib required by the */
+                                        /* object. */
+#define SLOMAGIC        (MF_IS_SL|OMAGIC) /* A reference to a shared library */
+                                          /* The text portion of the object */
+                                          /* contains "overflow text" from */
+                                          /* the shared library to be linked */
+                                          /* in with an object */
+#define QMAGIC          (MF_SQUEEZED|ZMAGIC)    /* Sqeezed demand paged. */
+                                          /* NOTE: This interpretation of */
+                                          /* QMAGIC seems to be at variance */
+                                          /* With that used on other */
+                                          /* architectures. */
+#define SPZMAGIC        (MF_USES_SL|ZMAGIC)     /* program which uses sl */
+#define SPQMAGIC        (MF_USES_SL|QMAGIC)     /* sqeezed ditto */
+#define SLZMAGIC        (MF_IS_SL|ZMAGIC)       /* shared lib part of prog */
+#define SLPZMAGIC       (MF_USES_SL|SLZMAGIC)   /* sl which uses another */
+
+#define N_SHARED_LIB(x) ((x).a_info & MF_USES_SL)
+
+/* Only a pure OMAGIC file has the minimal header */
+#define N_TXTOFF(x)                     \
+ ((x).a_info == OMAGIC ? 32             \
+  : (N_MAGIC(x) == ZMAGIC) ? TARGET_PAGE_SIZE  \
+  : 999)
+
+#define N_TXTADDR(x)                                                         \
+  (N_MAGIC(x) != ZMAGIC ? 0 /* object file or NMAGIC */                      \
+   /* Programs with shared libs are loaded at the first page after all the   \
+      text segments of the shared library programs.  Without looking this    \
+      up we can't know exactly what the address will be.  A reasonable guess \
+      is that a_entry will be in the first page of the executable.  */       \
+   : N_SHARED_LIB(x) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1))                      \
+   : TEXT_START_ADDR)
+
+#define N_SYMOFF(x) \
+  (N_TXTOFF (x) + (x).a_text + (x).a_data + (x).a_trsize + (x).a_drsize)
+
+#define N_STROFF(x) (N_SYMOFF (x) + (x).a_syms)
+
+#define TEXT_START_ADDR 32768
+#define TARGET_PAGE_SIZE 32768
+#define SEGMENT_SIZE TARGET_PAGE_SIZE
+#define DEFAULT_ARCH bfd_arch_arm
+
+#define MY(OP) CAT(riscix_,OP)
+#define TARGETNAME "a.out-riscix"
+#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
+                     (((x).a_info & ~006000) != OMAGIC) && \
+                     ((x).a_info != NMAGIC))
+#define N_MAGIC(x) ((x).a_info & ~07200)
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "assert.h"
+
+#define WRITE_HEADERS(abfd, execp)                                        \
+  {                                                                       \
+    bfd_size_type text_size; /* dummy vars */                             \
+    file_ptr text_end;                                                    \
+    if (adata(abfd).magic == undecided_magic)                             \
+      NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end);     \
+                                                                          \
+    execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE;        \
+    execp->a_entry = bfd_get_start_address (abfd);                        \
+                                                                          \
+    execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *                \
+                      obj_reloc_entry_size (abfd));                       \
+    execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *                \
+                      obj_reloc_entry_size (abfd));                       \
+    NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes);                   \
+                                                                          \
+    if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false;       \
+    if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)                   \
+       != EXEC_BYTES_SIZE)                                                \
+      return false;                                                       \
+    /* Now write out reloc info, followed by syms and strings */          \
+                                                                          \
+    if (bfd_get_outsymbols (abfd) != (asymbol **) NULL                    \
+       && bfd_get_symcount (abfd) != 0)                                   \
+      {                                                                           \
+       if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) != 0)  \
+         return false;                                                    \
+                                                                          \
+       if (! NAME(aout,write_syms)(abfd)) return false;                   \
+                                                                          \
+       if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) != 0) \
+         return false;                                                    \
+                                                                          \
+       if (! riscix_squirt_out_relocs (abfd, obj_textsec (abfd)))         \
+         return false;                                                    \
+       if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) != 0) \
+         return false;                                                    \
+                                                                          \
+       if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd)))       \
+         return false;                                                    \
+      }                                                                           \
+  }
+
+#include "libaout.h"
+#include "aout/aout64.h"
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26_done PARAMS ((bfd *, arelent *, asymbol *, PTR,
+                                 asection *, bfd *, char **));
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26 PARAMS ((bfd *, arelent *, asymbol *, PTR,
+                            asection *, bfd *, char **));
+
+static reloc_howto_type riscix_std_reloc_howto[] = {
+  /* 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),
+  HOWTO( 2,              0,  2,   32, false, 0, complain_overflow_bitfield,0,"32",        true, 0xffffffff,0xffffffff, false),
+  HOWTO( 3,              2,  3,   26, true, 0, complain_overflow_signed,  riscix_fix_pcrel_26 , "ARM26",      true, 0x00ffffff,0x00ffffff, false),
+  HOWTO( 4,              0,  0,   8,  true,  0, complain_overflow_signed,  0,"DISP8",     true, 0x000000ff,0x000000ff, true),
+  HOWTO( 5,              0,  1,   16, true,  0, complain_overflow_signed,  0,"DISP16",    true, 0x0000ffff,0x0000ffff, true),
+  HOWTO( 6,              0,  2,   32, true,  0, complain_overflow_signed,  0,"DISP32",    true, 0xffffffff,0xffffffff, true),
+  HOWTO( 7,              2,  3,   26, false, 0, complain_overflow_signed,  riscix_fix_pcrel_26_done, "ARM26D",true,0x00ffffff,0x00ffffff, false),
+  {-1},
+  HOWTO( 9,              0, -1,   16, false, 0, complain_overflow_bitfield,0,"NEG16",        true, 0x0000ffff,0x0000ffff, false),
+  HOWTO( 10,              0, -2,   32, false, 0, complain_overflow_bitfield,0,"NEG32",        true, 0xffffffff,0xffffffff, false)
+};
+
+#define RISCIX_TABLE_SIZE \
+  (sizeof (riscix_std_reloc_howto) / sizeof (reloc_howto_type))
+
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
+                         output_bfd, error_message)
+     bfd *abfd;
+     arelent *reloc_entry;
+     asymbol *symbol;
+     PTR data;
+     asection *input_section;
+     bfd *output_bfd;
+     char **error_message;
+{
+  /* This is dead simple at present.  */
+  return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+riscix_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
+                    output_bfd, error_message)
+     bfd *abfd;
+     arelent *reloc_entry;
+     asymbol *symbol;
+     PTR data;
+     asection *input_section;
+     bfd *output_bfd;
+     char **error_message;
+{
+  bfd_vma relocation;
+  bfd_size_type addr = reloc_entry->address;
+  long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+  bfd_reloc_status_type flag = bfd_reloc_ok;
+  
+  /* If this is an undefined symbol, return error */
+  if (symbol->section == &bfd_und_section
+      && (symbol->flags & BSF_WEAK) == 0)
+    return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
+
+  /* If the sections are different, and we are doing a partial relocation,
+     just ignore it for now.  */
+  if (symbol->section->name != input_section->name
+      && output_bfd != (bfd *)NULL)
+    return bfd_reloc_continue;
+
+  relocation = (target & 0x00ffffff) << 2;
+  relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
+  relocation += symbol->value;
+  relocation += symbol->section->output_section->vma;
+  relocation += symbol->section->output_offset;
+  relocation += reloc_entry->addend;
+  relocation -= input_section->output_section->vma;
+  relocation -= input_section->output_offset;
+  relocation -= addr;
+  if (relocation & 3)
+    return bfd_reloc_overflow;
+
+  /* Check for overflow */
+  if (relocation & 0x02000000)
+    {
+      if ((relocation & ~0x03ffffff) != ~0x03ffffff)
+       flag = bfd_reloc_overflow;
+    }
+  else if (relocation & ~0x03ffffff)
+    flag = bfd_reloc_overflow;
+
+  target &= ~0x00ffffff;
+  target |= (relocation >> 2) & 0x00ffffff;
+  bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
+
+  /* Now the ARM magic... Change the reloc type so that it is marked as done.
+     Strictly this is only necessary if we are doing a partial relocation.  */
+  reloc_entry->howto = &riscix_std_reloc_howto[7];
+  
+  return flag;
+}
+
+reloc_howto_type *
+DEFUN(riscix_reloc_type_lookup,(abfd,code),
+      bfd *abfd AND
+      bfd_reloc_code_real_type code)
+{
+#define ASTD(i,j)       case i: return &riscix_std_reloc_howto[j]
+  if (code == BFD_RELOC_CTOR)
+    switch (bfd_get_arch_info (abfd)->bits_per_address)
+      {
+      case 32:
+        code = BFD_RELOC_32;
+        break;
+      default: return (reloc_howto_type *) NULL;
+      }
+
+  switch (code)
+    {
+      ASTD (BFD_RELOC_16, 1);
+      ASTD (BFD_RELOC_32, 2);
+      ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
+      ASTD (BFD_RELOC_8_PCREL, 4);
+      ASTD (BFD_RELOC_16_PCREL, 5);
+      ASTD (BFD_RELOC_32_PCREL, 6);
+    default: return (reloc_howto_type *) NULL;
+    }
+}
+
+#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define MY_bfd_final_link _bfd_generic_final_link
+
+#define MY_bfd_reloc_type_lookup riscix_reloc_type_lookup
+#define MY_canonicalize_reloc riscix_canonicalize_reloc
+#define MY_object_p riscix_object_p
+
+static const bfd_target *riscix_callback PARAMS ((bfd *));
+
+void
+riscix_swap_std_reloc_out (abfd, g, natptr)
+     bfd *abfd;
+     arelent *g;
+     struct reloc_std_external *natptr;
+{
+  int r_index;
+  asymbol *sym = *(g->sym_ptr_ptr);
+  int r_extern;
+  int r_length;
+  int r_pcrel;
+  int r_neg = 0;       /* Negative relocs use the BASEREL bit.  */
+  asection *output_section = sym->section->output_section;
+
+  PUT_WORD(abfd, g->address, natptr->r_address);
+
+  r_length = g->howto->size ;   /* Size as a power of two */
+  if (r_length < 0)
+    {
+      r_length = -r_length;
+      r_neg = 1;
+    }
+
+  r_pcrel  = (int) g->howto->pc_relative; /* Relative to PC? */
+
+  /* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
+     relocation has been done already (Only for the 26-bit one I think)???!!!
+     */
+  
+  if (r_length == 3)
+    r_pcrel = r_pcrel ? 0 : 1;
+  
+
+#if 0
+  /* For a standard reloc, the addend is in the object file.  */
+  r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
+#endif
+
+  /* name was clobbered by aout_write_syms to be symbol index */
+
+  /* If this relocation is relative to a symbol then set the
+     r_index to the symbols index, and the r_extern bit.
+
+     Absolute symbols can come in in two ways, either as an offset
+     from the abs section, or as a symbol which has an abs value.
+     check for that here
+     */
+
+  if (bfd_is_com_section (output_section)
+      || output_section == &bfd_abs_section
+      || output_section == &bfd_und_section)
+    {
+      if (bfd_abs_section.symbol == sym)
+       {
+         /* Whoops, looked like an abs symbol, but is really an offset
+            from the abs section */
+         r_index = 0;
+         r_extern = 0;
+       }
+      else
+       {
+         /* Fill in symbol */
+         r_extern = 1;
+         r_index =  stoi((*(g->sym_ptr_ptr))->flags);
+       }
+    }
+  else
+    {
+      /* Just an ordinary section */
+      r_extern = 0;
+      r_index  = output_section->target_index;
+    }
+
+  /* now the fun stuff */
+  if (abfd->xvec->header_byteorder_big_p != false)
+    {
+      natptr->r_index[0] = r_index >> 16;
+      natptr->r_index[1] = r_index >> 8;
+      natptr->r_index[2] = r_index;
+      natptr->r_type[0] =
+       (  (r_extern ?   RELOC_STD_BITS_EXTERN_BIG: 0)
+        | (r_pcrel  ?   RELOC_STD_BITS_PCREL_BIG: 0)
+        | (r_neg    ?   RELOC_STD_BITS_BASEREL_BIG: 0)
+        | (r_length <<  RELOC_STD_BITS_LENGTH_SH_BIG));
+    }
+  else
+    {
+      natptr->r_index[2] = r_index >> 16;
+      natptr->r_index[1] = r_index >> 8;
+      natptr->r_index[0] = r_index;
+      natptr->r_type[0] =
+       (  (r_extern ?   RELOC_STD_BITS_EXTERN_LITTLE: 0)
+        | (r_pcrel  ?   RELOC_STD_BITS_PCREL_LITTLE: 0)
+        | (r_neg    ?   RELOC_STD_BITS_BASEREL_LITTLE: 0)
+        | (r_length <<  RELOC_STD_BITS_LENGTH_SH_LITTLE));
+    }
+}
+
+boolean
+riscix_squirt_out_relocs (abfd, section)
+     bfd *abfd;
+     asection *section;
+{
+  arelent **generic;
+  unsigned char *native, *natptr;
+  size_t each_size;
+  
+  unsigned int count = section->reloc_count;
+  size_t natsize;
+
+  if (count == 0) return true;
+
+  each_size = obj_reloc_entry_size (abfd);
+  natsize = each_size * count;
+  native = (unsigned char *) bfd_zalloc (abfd, natsize);
+  if (!native)
+    return false;
+
+  generic = section->orelocation;
+
+  for (natptr = native;
+       count != 0;
+       --count, natptr += each_size, ++generic)
+    riscix_swap_std_reloc_out (abfd, *generic,
+                              (struct reloc_std_external *) natptr);
+
+  if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
+    {
+      bfd_release(abfd, native);
+      return false;
+    }
+
+  bfd_release (abfd, native);
+  return true;
+}
+
+
+/*
+ * This is just like the standard aoutx.h version but we need to do our
+ * own mapping of external reloc type values to howto entries.
+ */
+long
+MY(canonicalize_reloc)(abfd, section, relptr, symbols)
+      bfd *abfd;
+      sec_ptr section;
+      arelent **relptr;
+      asymbol **symbols;
+{
+  arelent *tblptr = section->relocation;
+  unsigned int count, c;
+  extern reloc_howto_type NAME(aout,std_howto_table)[];
+
+  /* If we have already read in the relocation table, return the values. */
+  if (section->flags & SEC_CONSTRUCTOR) {
+    arelent_chain *chain = section->constructor_chain;
+
+    for (count = 0; count < section->reloc_count; count++) {
+      *relptr++ = &chain->relent;
+      chain = chain->next;
+    }
+    *relptr = 0;
+    return section->reloc_count;
+  }
+  if (tblptr && section->reloc_count) {
+    for (count = 0; count++ < section->reloc_count;)
+      *relptr++ = tblptr++;
+    *relptr = 0;
+    return section->reloc_count;
+  }
+
+  if (!NAME(aout,slurp_reloc_table)(abfd, section, symbols))
+    return -1;
+  tblptr = section->relocation;
+
+  /* fix up howto entries */
+  for (count = 0; count++ < section->reloc_count;)
+    {
+      c = tblptr->howto - NAME(aout,std_howto_table);
+      assert (c < RISCIX_TABLE_SIZE);
+      tblptr->howto = &riscix_std_reloc_howto[c];
+
+      *relptr++ = tblptr++;
+    }
+  *relptr = 0;
+  return section->reloc_count;
+}
+
+/* This is the same as NAME(aout,some_aout_object_p), but has different 
+   expansions of the macro definitions.  */
+
+const bfd_target *
+riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
+     bfd *abfd;
+     struct internal_exec *execp;
+     const bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
+{
+  struct aout_data_struct *rawptr, *oldrawptr;
+  const bfd_target *result;
+
+  rawptr = ((struct aout_data_struct  *) 
+           bfd_zalloc (abfd, sizeof (struct aout_data_struct )));
+
+  if (rawptr == NULL)
+    return 0;
+
+  oldrawptr = abfd->tdata.aout_data;
+  abfd->tdata.aout_data = rawptr;
+
+  /* Copy the contents of the old tdata struct.
+     In particular, we want the subformat, since for hpux it was set in
+     hp300hpux.c:swap_exec_header_in and will be used in
+     hp300hpux.c:callback.  */
+  if (oldrawptr != NULL)
+    *abfd->tdata.aout_data = *oldrawptr;
+
+  abfd->tdata.aout_data->a.hdr = &rawptr->e;
+  *(abfd->tdata.aout_data->a.hdr) = *execp;     /* Copy in the internal_exec
+                                                  struct */
+  execp = abfd->tdata.aout_data->a.hdr;
+
+  /* Set the file flags */
+  abfd->flags = NO_FLAGS;
+  if (execp->a_drsize || execp->a_trsize)
+    abfd->flags |= HAS_RELOC;
+  /* Setting of EXEC_P has been deferred to the bottom of this function */
+  if (execp->a_syms)
+    abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
+  if (N_DYNAMIC(*execp))
+    abfd->flags |= DYNAMIC;
+
+                                                                 
+  if ((execp->a_info & MF_SQUEEZED) != 0) /* Squeezed files aren't supported 
+                                            (yet)! */
+    {
+      bfd_set_error (bfd_error_wrong_format);
+      return NULL;
+    }
+  else if ((execp->a_info & MF_IS_SL) != 0)    /* Nor are shared libraries */
+    {
+      bfd_set_error (bfd_error_wrong_format);
+      return NULL;
+    }
+  else if (N_MAGIC (*execp) == ZMAGIC)
+    {
+      abfd->flags |= D_PAGED | WP_TEXT;
+      adata (abfd).magic = z_magic;
+    }
+  else if (N_MAGIC (*execp) == NMAGIC)
+    {
+      abfd->flags |= WP_TEXT;
+      adata (abfd).magic = n_magic;
+    }
+  else if (N_MAGIC (*execp) == OMAGIC)
+    adata (abfd).magic = o_magic;
+  else
+    {
+      /* Should have been checked with N_BADMAG before this routine
+         was called.  */
+      abort ();
+    }
+
+  bfd_get_start_address (abfd) = execp->a_entry;
+
+  obj_aout_symbols (abfd) = (aout_symbol_type *)NULL;
+  bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist);
+
+  /* The default relocation entry size is that of traditional V7 Unix.  */
+  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+
+  /* The default symbol entry size is that of traditional Unix. */
+  obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;
+
+  obj_aout_external_syms (abfd) = NULL;
+  obj_aout_external_strings (abfd) = NULL;
+  obj_aout_sym_hashes (abfd) = NULL;
+
+  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_textsec (abfd)->flags =
+    (execp->a_trsize != 0
+     ? (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_RELOC)
+     : (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS));
+  obj_datasec (abfd)->flags =
+    (execp->a_drsize != 0
+     ? (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS | SEC_RELOC)
+     : (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS));
+  obj_bsssec (abfd)->flags = SEC_ALLOC;
+
+  result = (*callback_to_real_object_p)(abfd);
+
+#if defined(MACH) || defined(STAT_FOR_EXEC)
+  /* The original heuristic doesn't work in some important cases. The
+   * a.out file has no information about the text start address. For
+   * files (like kernels) linked to non-standard addresses (ld -Ttext
+   * nnn) the entry point may not be between the default text start
+   * (obj_textsec(abfd)->vma) and (obj_textsec(abfd)->vma) + text size
+   * This is not just a mach issue. Many kernels are loaded at non
+   * standard addresses.
+   */
+  {
+    struct stat stat_buf;
+    if (abfd->iostream
+        && (fstat(fileno((FILE *) (abfd->iostream)), &stat_buf) == 0)
+        && ((stat_buf.st_mode & 0111) != 0))
+      abfd->flags |= EXEC_P;
+  }
+#else /* ! MACH */
+  /* Now that the segment addresses have been worked out, take a better
+     guess at whether the file is executable.  If the entry point
+     is within the text segment, assume it is.  (This makes files
+     executable even if their entry point address is 0, as long as
+     their text starts at zero.)
+
+     At some point we should probably break down and stat the file and
+     declare it executable if (one of) its 'x' bits are on...  */
+  if ((execp->a_entry >= obj_textsec(abfd)->vma) &&
+      (execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))
+    abfd->flags |= EXEC_P;
+#endif /* MACH */
+  if (result)
+    {
+    }
+  else
+    {
+      free (rawptr);
+      abfd->tdata.aout_data = oldrawptr;
+    }
+  return result;
+}
+
+
+static const bfd_target *
+MY(object_p) (abfd)
+     bfd *abfd;
+{
+  struct external_exec exec_bytes;      /* Raw exec header from file */
+  struct internal_exec exec;            /* Cleaned-up exec header */
+  const bfd_target *target;
+
+  if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+      != EXEC_BYTES_SIZE) {
+    if (bfd_get_error () != bfd_error_system_call)
+      bfd_set_error (bfd_error_wrong_format);
+    return 0;
+  }
+
+  exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+
+  if (N_BADMAG (exec)) return 0;
+#ifdef MACHTYPE_OK
+  if (!(MACHTYPE_OK (N_MACHTYPE (exec)))) return 0;
+#endif
+
+  NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
+
+  target = riscix_some_aout_object_p (abfd, &exec, MY(callback));
+
+  return target;
+}
+
+
+#include "aout-target.h"
index 8a788d74c4efdd77d520dbe88feb378c020cdebe..827c7fb02f84421586b33776bcf8ce4f056f81b8 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -1409,10 +1409,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
   final_types = (int **) bfd_alloc_by_size_t (abfd, sizeof (int *) * 6);
   final_type = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
   if (!final_types || !final_type)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* The field selector may require additional relocations to be 
      generated.  It's impossible to know at this moment if additional
@@ -1436,10 +1433,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
       case e_rtsel:
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
-         {
-           bfd_set_error (bfd_error_no_memory);
-           return NULL;
-         }
+         return NULL;
        if (field == e_tsel)
          *final_types[0] = R_FSEL;
        else if (field == e_ltsel)
@@ -1455,10 +1449,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
       case e_rssel:
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
-         {
-           bfd_set_error (bfd_error_no_memory);
-           return NULL;
-         }
+         return NULL;
        *final_types[0] = R_S_MODE;
        final_types[1] = final_type;
        final_types[2] = NULL;
@@ -1469,10 +1460,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
       case e_rsel:
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
-         {
-           bfd_set_error (bfd_error_no_memory);
-           return NULL;
-         }
+         return NULL;
        *final_types[0] = R_N_MODE;
        final_types[1] = final_type;
        final_types[2] = NULL;
@@ -1483,10 +1471,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
       case e_rdsel:
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
-         {
-           bfd_set_error (bfd_error_no_memory);
-           return NULL;
-         }
+         return NULL;
        *final_types[0] = R_D_MODE;
        final_types[1] = final_type;
        final_types[2] = NULL;
@@ -1497,10 +1482,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
       case e_rrsel:
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
-         {
-           bfd_set_error (bfd_error_no_memory);
-           return NULL;
-         }
+         return NULL;
        *final_types[0] = R_R_MODE;
        final_types[1] = final_type;
        final_types[2] = NULL;
@@ -1519,10 +1501,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
          final_types[2] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
          final_types[3] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
          if (!final_types[0] || !final_types[1] || !final_types[2])
-          {
-            bfd_set_error (bfd_error_no_memory);
             return NULL;
-          }
          if (field == e_fsel)
            *final_types[0] = R_FSEL;
          else if (field == e_rsel)
@@ -1577,10 +1556,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
          final_types[2] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
          final_types[3] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
          if (!final_types[0] || !final_types[1] || !final_types[2])
-          {
-            bfd_set_error (bfd_error_no_memory);
             return NULL;
-          }
          if (field == e_fsel)
            *final_types[0] = R_FSEL;
          else if (field == e_rsel)
@@ -1677,10 +1653,7 @@ som_object_setup (abfd, file_hdrp, aux_hdrp)
   obj_som_exec_data (abfd) = (struct som_exec_data *)
     bfd_zalloc (abfd, sizeof (struct som_exec_data ));
   if (obj_som_exec_data (abfd) == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* The braindamaged OSF1 linker switched exec_flags and exec_entry!
 
@@ -2092,10 +2065,7 @@ som_mkobject (abfd)
   abfd->tdata.som_data = (struct som_data_struct *)
     bfd_zalloc (abfd, sizeof (struct som_data_struct));
   if (abfd->tdata.som_data == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   return true;
 }
 
@@ -2113,11 +2083,7 @@ som_prep_headers (abfd)
   /* Make and attach a file header to the BFD.  */
   file_hdr = (struct header *) bfd_zalloc (abfd, sizeof (struct header));
   if (file_hdr == NULL)
-
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   obj_som_file_hdr (abfd) = file_hdr;
 
   if (abfd->flags & (EXEC_P | DYNAMIC))
@@ -2127,10 +2093,7 @@ som_prep_headers (abfd)
       obj_som_exec_hdr (abfd) = (struct som_exec_auxhdr *)
        bfd_zalloc (abfd, sizeof (struct som_exec_auxhdr));
       if (obj_som_exec_hdr (abfd) == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       if (abfd->flags & D_PAGED)
        file_hdr->a_magic = DEMAND_MAGIC;
@@ -2177,10 +2140,7 @@ som_prep_headers (abfd)
            = (struct space_dictionary_record *)
              bfd_zalloc (abfd, sizeof (struct space_dictionary_record));
          if (som_section_data (section)->space_dict == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
          /* Set space attributes.  Note most attributes of SOM spaces
             are set based on the subspaces it contains.  */
          som_section_data (section)->space_dict->loader_fix_index = -1;
@@ -2203,10 +2163,7 @@ som_prep_headers (abfd)
            = (struct subspace_dictionary_record *)
              bfd_zalloc (abfd, sizeof (struct subspace_dictionary_record));
          if (som_section_data (section)->subspace_dict == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
 
          /* Set subspace attributes.  Basic stuff is done here, additional
             attributes are filled in later as more information becomes
@@ -3841,12 +3798,12 @@ som_slurp_string_table (abfd)
 
   /* Allocate and read in the string table.  */
   stringtab = malloc (obj_som_stringtab_size (abfd));
-  bzero (stringtab, obj_som_stringtab_size (abfd));
   if (stringtab == NULL)
     {
       bfd_set_error (bfd_error_no_memory);
       return false;
     }
+  memset (stringtab, 0, obj_som_stringtab_size (abfd));
 
   if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0)
     return false;
@@ -3949,12 +3906,12 @@ som_slurp_symbol_table (abfd)
 
   symbase = (som_symbol_type *)
     malloc (symbol_count * sizeof (som_symbol_type));
-  bzero (symbase, symbol_count * sizeof (som_symbol_type));
   if (symbase == NULL)
     {
       bfd_set_error (bfd_error_no_memory);
       goto error_return;
     }
+  memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
 
   /* Read in the external SOM representation.  */
   buf = malloc (symbol_count * symsize);
@@ -4136,10 +4093,7 @@ som_make_empty_symbol (abfd)
   som_symbol_type *new =
   (som_symbol_type *) bfd_zalloc (abfd, sizeof (som_symbol_type));
   if (new == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return 0;
-    }
+    return 0;
   new->symbol.the_bfd = abfd;
 
   return &new->symbol;
@@ -4604,10 +4558,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
   internal_relocs = (arelent *) 
     bfd_zalloc (abfd, (num_relocs * sizeof (arelent)));
   if (internal_relocs == (arelent *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   /* Process and internalize the relocations.  */
   som_set_reloc_info (external_relocs, fixup_stream_size,
@@ -4679,10 +4630,7 @@ som_new_section_hook (abfd, newsect)
   newsect->used_by_bfd =
     (PTR) bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
   if (!newsect->used_by_bfd)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   newsect->alignment_power = 3;
 
   /* We allow more than three sections internally */
@@ -4733,10 +4681,7 @@ som_bfd_copy_private_section_data (ibfd, isection, obfd, osection)
     = (struct som_copyable_section_data_struct *)
       bfd_zalloc (obfd, sizeof (struct som_copyable_section_data_struct));
   if (som_section_data (osection)->copy_data == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   memcpy (som_section_data (osection)->copy_data,
          som_section_data (isection)->copy_data,
@@ -4766,10 +4711,7 @@ som_bfd_copy_private_bfd_data (ibfd, obfd)
   obj_som_exec_data (obfd) = (struct som_exec_data *)
     bfd_zalloc (obfd, sizeof (struct som_exec_data));
   if (obj_som_exec_data (obfd) == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   /* Now copy the data.  */
   memcpy (obj_som_exec_data (obfd), obj_som_exec_data (ibfd),
@@ -4797,10 +4739,7 @@ bfd_som_set_section_attributes (section, defined, private, sort_key, spnum)
          bfd_zalloc (section->owner,
                      sizeof (struct som_copyable_section_data_struct));
       if (som_section_data (section)->copy_data == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
     }
   som_section_data (section)->copy_data->sort_key = sort_key;
   som_section_data (section)->copy_data->is_defined = defined;
@@ -4830,10 +4769,7 @@ bfd_som_set_subsection_attributes (section, container, access,
          bfd_zalloc (section->owner,
                      sizeof (struct som_copyable_section_data_struct));
       if (som_section_data (section)->copy_data == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
     }
   som_section_data (section)->copy_data->sort_key = sort_key;
   som_section_data (section)->copy_data->access_control_bits = access;
@@ -4875,10 +4811,7 @@ bfd_som_attach_aux_hdr (abfd, type, string)
        bfd_zalloc (abfd, sizeof (struct aux_id)
                              + sizeof (unsigned int) + len + pad);
       if (!obj_som_version_hdr (abfd))
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
       obj_som_version_hdr (abfd)->header_id.length = len + pad;
       obj_som_version_hdr (abfd)->header_id.length += sizeof (int);
@@ -4896,10 +4829,7 @@ bfd_som_attach_aux_hdr (abfd, type, string)
        bfd_zalloc (abfd, sizeof (struct aux_id)
                            + sizeof (unsigned int) + len + pad);
       if (!obj_som_copyright_hdr (abfd))
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
       obj_som_copyright_hdr (abfd)->header_id.length = len + pad;
       obj_som_copyright_hdr (abfd)->header_id.length += sizeof (int);
@@ -5216,10 +5146,7 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
       /* Allocate space for the name and null terminate it too.  */
       set->name = bfd_zalloc (abfd, len + 1);
       if (!set->name)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
       if (bfd_read (set->name, 1, len, abfd) != len)
        goto error_return;
 
@@ -5255,10 +5182,7 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
          /* Allocate space for the name and null terminate it too.  */
          set->name = bfd_zalloc (abfd, len + 1);
          if (!set->name)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             goto error_return;
-           }
+           goto error_return;
 
          if (bfd_read (set->name, 1, len, abfd) != len)
            goto error_return;
@@ -5369,10 +5293,7 @@ som_slurp_armap (abfd)
                                          (ardata->symdef_count
                                           * sizeof (carsym)));
   if (!ardata->symdefs)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   /* Now fill in the canonical archive symbols.  */
   if (som_bfd_fill_in_ar_symbols (abfd, &lst_header, &ardata->symdefs)
@@ -5568,10 +5489,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
       unsigned int thislen;
 
       if (!normal)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       thislen = strlen (normal);
       if (thislen > maxname)
        extended_name_length += thislen + 1;
@@ -5978,6 +5896,8 @@ som_bfd_link_split_section (abfd, sec)
 #define som_bfd_make_debug_symbol      _bfd_nosymbols_bfd_make_debug_symbol
 #define som_read_minisymbols           _bfd_generic_read_minisymbols
 #define som_minisymbol_to_symbol       _bfd_generic_minisymbol_to_symbol
+#define som_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
 
 #define som_bfd_get_relocated_section_contents \
  bfd_generic_get_relocated_section_contents
@@ -5986,6 +5906,7 @@ som_bfd_link_split_section (abfd, sec)
 #define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define som_bfd_final_link _bfd_generic_final_link
 
+
 const bfd_target som_vec =
 {
   "som",                       /* name */
index 5ee5f179127e0d527dca86dc3d2caafd535f7e92..4b8fa4b4a5d72d01257ec5d143b08e1450cef1c4 100644 (file)
@@ -208,10 +208,7 @@ srec_mkobject (abfd)
     {
       tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
       if (tdata == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       abfd->tdata.srec_data = tdata;
       tdata->type = 1;
       tdata->head = NULL;
@@ -271,8 +268,9 @@ srec_bad_byte (abfd, lineno, c, error)
          buf[0] = c;
          buf[1] = '\0';
        }
-      fprintf (stderr, "%s:%d: Unexpected character `%s' in S-record file\n",
-              bfd_get_filename (abfd), lineno, buf);
+      (*_bfd_error_handler)
+       ("%s:%d: Unexpected character `%s' in S-record file\n",
+        bfd_get_filename (abfd), lineno, buf);
       bfd_set_error (bfd_error_bad_value);
     }
 }
@@ -289,10 +287,7 @@ srec_new_symbol (abfd, name, val)
 
   n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (struct srec_symbol));
   if (n == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   n->name = name;
   n->val = val;
@@ -765,10 +760,7 @@ srec_get_section_contents (abfd, section, location, offset, count)
       section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
       if (section->used_by_bfd == NULL
          && section->_raw_size != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       if (! srec_read_section (abfd, section, section->used_by_bfd))
        return false;
@@ -796,10 +788,7 @@ srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
   entry = ((srec_data_list_type *)
           bfd_alloc (abfd, sizeof (srec_data_list_type)));
   if (entry == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   if (bytes_to_do
       && (section->flags & SEC_ALLOC)
@@ -807,10 +796,7 @@ srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
     {
       bfd_byte *data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
       if (data == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       memcpy ((PTR) data, location, (size_t) bytes_to_do);
 
       if ((section->lma + offset + bytes_to_do - 1) <= 0xffff)
@@ -1148,10 +1134,7 @@ srec_get_symtab (abfd, alocation)
 
       csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
       if (csymbols == NULL && symcount != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       abfd->tdata.srec_data->csymbols = csymbols;
 
       for (s = abfd->tdata.srec_data->symbols, c = csymbols;
@@ -1224,6 +1207,9 @@ srec_print_symbol (ignore_abfd, afile, symbol, how)
   ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
 #define srec_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
 
+#define srec_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
+
 #define srec_set_arch_mach bfd_default_set_arch_mach
 
 #define srec_bfd_get_relocated_section_contents \
index af95a24aa3874e017c693150e1de8a0b646c3392..ffd4fdc0f5a2fdb4e95793289b634f78021379a9 100644 (file)
@@ -141,10 +141,7 @@ sunos_read_dynamic_info (abfd)
   info = ((struct sunos_dynamic_info *)
          bfd_zalloc (abfd, sizeof (struct sunos_dynamic_info)));
   if (!info)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   info->valid = false;
   info->dynsym = NULL;
   info->dynstr = NULL;
@@ -289,10 +286,7 @@ sunos_slurp_dynamic_symtab (abfd)
                                 (info->dynsym_count
                                  * EXTERNAL_NLIST_SIZE)));
       if (info->dynsym == NULL && info->dynsym_count != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       if (bfd_seek (abfd, info->dyninfo.ld_stab, SEEK_SET) != 0
          || (bfd_read ((PTR) info->dynsym, info->dynsym_count,
                        EXTERNAL_NLIST_SIZE, abfd)
@@ -312,10 +306,7 @@ sunos_slurp_dynamic_symtab (abfd)
     {
       info->dynstr = (char *) bfd_alloc (abfd, info->dyninfo.ld_symb_size);
       if (info->dynstr == NULL && info->dyninfo.ld_symb_size != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       if (bfd_seek (abfd, info->dyninfo.ld_symbols, SEEK_SET) != 0
          || (bfd_read ((PTR) info->dynstr, 1, info->dyninfo.ld_symb_size,
                        abfd)
@@ -398,10 +389,7 @@ sunos_canonicalize_dynamic_symtab (abfd, storage)
                                           (info->dynsym_count
                                            * sizeof (aout_symbol_type))));
       if (info->canonical_dynsym == NULL && info->dynsym_count != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return -1;
-       }
+       return -1;
 
       if (! aout_32_translate_symbol_table (abfd, info->canonical_dynsym,
                                            info->dynsym, info->dynsym_count,
@@ -479,10 +467,7 @@ sunos_canonicalize_dynamic_reloc (abfd, storage, syms)
                                      (info->dynrel_count
                                       * obj_reloc_entry_size (abfd)));
       if (info->dynrel == NULL && info->dynrel_count != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return -1;
-       }
+       return -1;
       if (bfd_seek (abfd, info->dyninfo.ld_rel, SEEK_SET) != 0
          || (bfd_read ((PTR) info->dynrel, info->dynrel_count,
                        obj_reloc_entry_size (abfd), abfd)
@@ -508,10 +493,7 @@ sunos_canonicalize_dynamic_reloc (abfd, storage, syms)
                                           (info->dynrel_count
                                            * sizeof (arelent))));
       if (info->canonical_dynrel == NULL && info->dynrel_count != 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return -1;
-       }
+       return -1;
       
       to = info->canonical_dynrel;
 
@@ -685,10 +667,7 @@ sunos_link_hash_newfunc (entry, table, string)
     ret = ((struct sunos_link_hash_entry *)
           bfd_hash_allocate (table, sizeof (struct sunos_link_hash_entry)));
   if (ret == (struct sunos_link_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_hash_entry *) ret;
-    }
+    return (struct bfd_hash_entry *) ret;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct sunos_link_hash_entry *)
@@ -718,10 +697,7 @@ sunos_link_hash_table_create (abfd)
   ret = ((struct sunos_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct sunos_link_hash_table)));
   if (ret == (struct sunos_link_hash_table *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_link_hash_table *) NULL;
-    }
+    return (struct bfd_link_hash_table *) NULL;
   if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
                                         sunos_link_hash_newfunc))
     {
@@ -974,10 +950,7 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp)
 
       needed = (struct bfd_link_needed_list *) bfd_alloc (abfd, sizeof (struct bfd_link_needed_list));
       if (needed == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       needed->by = abfd;
 
       /* We return the name as [-l]name[.maj][.min].  */
@@ -1007,10 +980,7 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp)
        }
       needed->name = bfd_alloc_finish (abfd);
       if (needed->name == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       needed->next = NULL;
 
@@ -1293,10 +1263,7 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr,
   s->_raw_size = dynsymcount * sizeof (struct external_nlist);
   s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
   if (s->contents == NULL && s->_raw_size != 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
       
   /* The number of buckets is just the number of symbols divided by
      four.  To compute the final size of the hash table, we must
@@ -1316,10 +1283,7 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr,
   hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
   s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc);
   if (s->contents == NULL && dynsymcount > 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   memset (s->contents, 0, hashalloc);
   for (i = 0; i < bucketcount; i++)
     PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE);
@@ -1367,10 +1331,7 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr,
     {
       s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
       if (s->contents == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       /* Fill in the first entry in the table.  */
       switch (bfd_get_arch (dynobj))
@@ -1393,10 +1354,7 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr,
     {
       s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
       if (s->contents == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
     }
   /* We use the reloc_count field to keep track of how many of the
      relocs we have output so far.  */
@@ -1406,10 +1364,7 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr,
   s = bfd_get_section_by_name (dynobj, ".got");
   s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
   if (s->contents == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   *sdynptr = bfd_get_section_by_name (dynobj, ".dynamic");
   *sneedptr = bfd_get_section_by_name (dynobj, ".need");
@@ -1753,10 +1708,7 @@ sunos_scan_ext_relocs (info, abfd, sec, relocs, rel_size)
                                            (bfd_get_symcount (abfd)
                                             * sizeof (bfd_vma)));
                  if (adata (abfd).local_got_offsets == NULL)
-                   {
-                     bfd_set_error (bfd_error_no_memory);
-                     return false;
-                   }
+                   return false;
                }
 
              if (adata (abfd).local_got_offsets[r_index] != 0)
index 331b9111fe044b45277582d0c7ffe064f029c28d..dca32f2cf384aaa3cdb51f9ff6079b0dd1de8b07 100644 (file)
@@ -530,6 +530,7 @@ extern const bfd_target m68kcoffun_vec;
 extern const bfd_target m68klynx_aout_vec;
 extern const bfd_target m68klynx_coff_vec;
 extern const bfd_target m68knetbsd_vec;
+extern const bfd_target m68k4knetbsd_vec;
 extern const bfd_target m88kbcs_vec;
 extern const bfd_target m88kmach3_vec;
 extern const bfd_target newsos3_vec;
@@ -871,10 +872,8 @@ bfd_target_list ()
   name_ptr = name_list = (CONST char **)
     bfd_zmalloc ((vec_length + 1) * sizeof (char **));
 
-  if (name_list == NULL) {
-    bfd_set_error (bfd_error_no_memory);
+  if (name_list == NULL)
     return NULL;
-  }
 
   for (target = &bfd_target_vector[0]; *target != NULL; target++)
     *(name_ptr++) = (*target)->name;
index 48d7e5cf180bacb65cc6819208b376f2c0b4a7b4..6a5b913282ffe3dbe10c8aa81848400b7715d258 100644 (file)
@@ -335,10 +335,7 @@ find_chunk (abfd, vma)
        bfd_alloc (abfd, sizeof (struct data_struct));
 
       if (!sname || !d)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return NULL;
-       }
+       return NULL;
 
       memset (d->chunk_init, 0, CHUNK_MASK + 1);
       memset (d->chunk_data, 0, CHUNK_MASK + 1);
@@ -399,10 +396,7 @@ first_phase (abfd, type, src)
          char *n = bfd_alloc (abfd, len + 1);
 
          if (!n)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             abort();          /* FIXME */
-           }
+           abort();            /* FIXME */
          memcpy (n, sym, len + 1);
          section = bfd_make_section (abfd, n);
        }
@@ -431,10 +425,7 @@ first_phase (abfd, type, src)
                char type = (*src);
 
                if (!new)
-                 {
-                   bfd_set_error (bfd_error_no_memory);
-                   abort();    /* FIXME */
-                 }
+                 abort();      /* FIXME */
                new->symbol.the_bfd = abfd;
                src++;
                abfd->symcount++;
@@ -444,10 +435,7 @@ first_phase (abfd, type, src)
                len = getsym (sym, &src);
                new->symbol.name = bfd_alloc (abfd, len + 1);
                if (!new->symbol.name)
-                 {
-                   bfd_set_error (bfd_error_no_memory);
-                   abort();    /* FIXME */
-                 }
+                 abort();      /* FIXME */
                memcpy ((char *) (new->symbol.name), sym, len + 1);
                new->symbol.section = section;
                if (type <= '4')
@@ -545,10 +533,7 @@ tekhex_mkobject (abfd)
   tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
 
   if (!tdata)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   abfd->tdata.tekhex_data = tdata;
   tdata->type = 1;
   tdata->head = (tekhex_data_list_type *) NULL;
@@ -925,10 +910,7 @@ tekhex_make_empty_symbol (abfd)
   (tekhex_symbol_type *) bfd_zalloc (abfd, sizeof (struct tekhex_symbol_struct));
 
   if (!new)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   new->symbol.the_bfd = abfd;
   new->prev = (struct tekhex_symbol_struct *) NULL;
   return &(new->symbol);
@@ -992,6 +974,9 @@ tekhex_print_symbol (ignore_abfd, filep, symbol, how)
 #define tekhex_bfd_final_link _bfd_generic_final_link
 #define tekhex_bfd_link_split_section _bfd_generic_link_split_section
 
+#define tekhex_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
+
 const bfd_target tekhex_vec =
 {
   "tekhex",                    /* name */
@@ -1006,7 +991,6 @@ const bfd_target tekhex_vec =
   0,                           /* leading underscore */
   ' ',                         /* ar_pad_char */
   16,                          /* ar_max_namelen */
-  1,                           /* minimum alignment */
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   bfd_getb16, bfd_getb_signed_16, bfd_putb16,  /* data */
index 427f6fc488ee33b2e3b9db4615a8da8cea1122c0..9d5a745cef7e2e30670d189225e0332371dbc301 100644 (file)
@@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
       asection *stack_section;
       asection *reg_section;
       struct user u;
-    } *rawptr;
+    };
 
 #define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
 #define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
@@ -66,6 +66,7 @@ trad_unix_core_file_p (abfd)
 {
   int val;
   struct user u;
+  struct trad_core_struct *rawptr;
 
 #ifdef TRAD_CORE_USER_OFFSET
   /* If defined, this macro is the file position of the user struct.  */
@@ -135,10 +136,8 @@ trad_unix_core_file_p (abfd)
      a single free() will free them both.  */
   rawptr = (struct trad_core_struct *)
                bfd_zmalloc (sizeof (struct trad_core_struct));
-  if (rawptr == NULL) {
-    bfd_set_error (bfd_error_no_memory);
+  if (rawptr == NULL)
     return 0;
-  }
   
   abfd->tdata.trad_core_data = rawptr;
 
@@ -147,24 +146,15 @@ trad_unix_core_file_p (abfd)
   /* Create the sections.  This is raunchy, but bfd_close wants to free
      them separately.  */
 
-  core_stacksec(abfd) = (asection *) bfd_zmalloc (sizeof (asection));
-  if (core_stacksec (abfd) == NULL) {
-  loser:
-    bfd_set_error (bfd_error_no_memory);
-    free ((void *)rawptr);
-    return 0;
-  }
-  core_datasec (abfd) = (asection *) bfd_zmalloc (sizeof (asection));
-  if (core_datasec (abfd) == NULL) {
-  loser1:
-    free ((void *)core_stacksec (abfd));
-    goto loser;
-  }
-  core_regsec (abfd) = (asection *) bfd_zmalloc (sizeof (asection));
-  if (core_regsec (abfd) == NULL) {
-    free ((void *)core_datasec (abfd));
-    goto loser1;
-  }
+  core_stacksec(abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+  if (core_stacksec (abfd) == NULL)
+    return NULL;
+  core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+  if (core_datasec (abfd) == NULL)
+    return NULL;
+  core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+  if (core_regsec (abfd) == NULL)
+    return NULL;
 
   core_stacksec (abfd)->name = ".stack";
   core_datasec (abfd)->name = ".data";
@@ -210,7 +200,7 @@ trad_unix_core_file_p (abfd)
      0 is at the place pointed to by u_ar0 (by setting the vma of the start
      of the section to -u_ar0).  GDB uses this info to locate the regs,
      using minor trickery to get around the offset-or-absolute-addr problem. */
-  core_regsec (abfd)->vma = 0 - (int) u.u_ar0;
+  core_regsec (abfd)->vma = 0 - (bfd_vma) u.u_ar0;
 
   core_datasec (abfd)->filepos = NBPG * UPAGES;
   core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize
@@ -290,7 +280,6 @@ const bfd_target trad_core_vec =
     0,                                                    /* symbol prefix */
     ' ',                                                  /* ar_pad_char */
     16,                                                           /* ar_max_namelen */
-    3,                                                    /* minimum alignment power */
     NO_GET, NO_SIGNED_GET, NO_PUT,     /* 64 bit data */
     NO_GET, NO_SIGNED_GET, NO_PUT,     /* 32 bit data */
     NO_GET, NO_SIGNED_GET, NO_PUT,     /* 16 bit data */
index 72bf1417703745cc138536e7001e2054176fcac5..9e5bea437a8e77bbaddc8be38f55954a110d8c4f 100644 (file)
@@ -162,10 +162,7 @@ versados_mkobject (abfd)
     {
       tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
       if (tdata == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       abfd->tdata.versados_data = tdata;
       tdata->symbols = NULL;
       VDATA (abfd)->alert = 0x12345678;
@@ -672,6 +669,9 @@ versados_get_section_contents (abfd, section, location, offset, count)
   return true;
 }
 
+#define versados_get_section_contents_in_window \
+  _bfd_generic_get_section_contents_in_window
+
 static boolean
 versados_set_section_contents (abfd, section, location, offset, bytes_to_do)
      bfd *abfd;
@@ -866,7 +866,6 @@ const bfd_target versados_vec =
   0,                           /* leading underscore */
   ' ',                         /* ar_pad_char */
   16,                          /* ar_max_namelen */
-  1,                           /* minimum alignment */
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   bfd_getb16, bfd_getb_signed_16, bfd_putb16,  /* data */
index 7fd546d40795bb17deb0727ee69713768b66ca71..b12d42734e88ab6f9516f48806a273fc4aaf48bb 100644 (file)
@@ -585,10 +585,7 @@ xcoff_link_hash_newfunc (entry, table, string)
     ret = ((struct xcoff_link_hash_entry *)
           bfd_hash_allocate (table, sizeof (struct xcoff_link_hash_entry)));
   if (ret == (struct xcoff_link_hash_entry *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_hash_entry *) ret;
-    }
+    return (struct bfd_hash_entry *) ret;
 
   /* Call the allocation method of the superclass.  */
   ret = ((struct xcoff_link_hash_entry *)
@@ -621,10 +618,7 @@ _bfd_xcoff_bfd_link_hash_table_create (abfd)
   ret = ((struct xcoff_link_hash_table *)
         bfd_alloc (abfd, sizeof (struct xcoff_link_hash_table)));
   if (ret == (struct xcoff_link_hash_table *) NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (struct bfd_link_hash_table *) NULL;
-    }
+    return (struct bfd_link_hash_table *) NULL;
   if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc))
     {
       bfd_release (abfd, ret);
@@ -1043,10 +1037,7 @@ xcoff_link_add_symbols (abfd, info)
                         (symcount
                          * sizeof (struct xcoff_link_hash_entry *))));
   if (sym_hash == NULL && symcount != 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto error_return;
-    }
+    goto error_return;
   coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash;
   memset (sym_hash, 0,
          (size_t) symcount * sizeof (struct xcoff_link_hash_entry *));
@@ -1057,10 +1048,7 @@ xcoff_link_add_symbols (abfd, info)
   csect_cache = ((asection **)
                 bfd_alloc (abfd, symcount * sizeof (asection *)));
   if (csect_cache == NULL && symcount != 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto error_return;
-    }
+    goto error_return;
   xcoff_data (abfd)->csects = csect_cache;
   memset (csect_cache, 0, (size_t) symcount * sizeof (asection *));
 
@@ -1489,17 +1477,11 @@ xcoff_link_add_symbols (abfd, info)
              ((struct coff_section_tdata *)
               bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
            if (csect->used_by_bfd == NULL)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               goto error_return;
-             }
+             goto error_return;
            coff_section_data (abfd, csect)->tdata =
              bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
            if (coff_section_data (abfd, csect)->tdata == NULL)
-             {
-               bfd_set_error (bfd_error_no_memory);
-               goto error_return;
-             }
+             goto error_return;
            xcoff_section_data (abfd, csect)->enclosing = enclosing;
            xcoff_section_data (abfd, csect)->lineno_count =
              enclosing->lineno_count;
@@ -1622,17 +1604,11 @@ xcoff_link_add_symbols (abfd, info)
            ((struct coff_section_tdata *)
             bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
          if (csect->used_by_bfd == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             goto error_return;
-           }
+           goto error_return;
          coff_section_data (abfd, csect)->tdata =
            bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
          if (coff_section_data (abfd, csect)->tdata == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             goto error_return;
-           }
+           goto error_return;
          xcoff_section_data (abfd, csect)->first_symndx = csect_index;
 
          if (first_csect == NULL)
@@ -2071,10 +2047,7 @@ xcoff_link_add_dynamic_symbols (abfd, info)
   n = ((struct xcoff_import_file *)
        bfd_alloc (abfd, sizeof (struct xcoff_import_file)));
   if (n == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto error_return;
-    }
+    goto error_return;
   n->next = NULL;
 
   /* For some reason, the path entry in the import file list for a
@@ -2344,10 +2317,7 @@ bfd_xcoff_link_record_set (output_bfd, info, harg, size)
   n = ((struct xcoff_link_size_list *)
        bfd_alloc (output_bfd, sizeof (struct xcoff_link_size_list)));
   if (n == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   n->next = xcoff_hash_table (info)->size_list;
   n->h = h;
   n->size = size;
@@ -2401,10 +2371,7 @@ bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
       h->ldsym = ((struct internal_ldsym *)
                  bfd_zalloc (output_bfd, sizeof (struct internal_ldsym)));
       if (h->ldsym == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
     }
 
   if (imppath == NULL)
@@ -2433,10 +2400,7 @@ bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
          n = ((struct xcoff_import_file *)
               bfd_alloc (output_bfd, sizeof (struct xcoff_import_file)));
          if (n == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             return false;
-           }
+           return false;
          n->next = NULL;
          n->path = imppath;
          n->file = impfile;
@@ -2764,10 +2728,7 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry,
   lsec->_raw_size = stoff + ldhdr->l_stlen;
   lsec->contents = (bfd_byte *) bfd_zalloc (output_bfd, lsec->_raw_size);
   if (lsec->contents == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto error_return;
-    }
+    goto error_return;
 
   /* Set up the header.  */
   xcoff_swap_ldhdr_out (output_bfd, ldhdr,
@@ -2818,30 +2779,21 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry,
     {
       sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
       if (sec->contents == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
     }
   sec = xcoff_hash_table (info)->toc_section;
   if (sec->_raw_size > 0)
     {
       sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
       if (sec->contents == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
     }
   sec = xcoff_hash_table (info)->descriptor_section;
   if (sec->_raw_size > 0)
     {
       sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
       if (sec->contents == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
     }
 
   /* Now that we've done garbage collection, figure out the contents
@@ -2878,10 +2830,7 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry,
       debug_index = ((unsigned long *)
                     bfd_zalloc (sub, symcount * sizeof (unsigned long)));
       if (debug_index == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
       xcoff_data (sub)->debug_indices = debug_index;
 
       /* Grab the contents of the .debug section.  We use malloc and
@@ -3131,7 +3080,6 @@ xcoff_build_ldsyms (h, p)
       if (h->ldsym == NULL)
        {
          ldinfo->failed = true;
-         bfd_set_error (bfd_error_no_memory);
          return false;
        }
     }
@@ -4704,10 +4652,7 @@ xcoff_link_input_bfd (finfo, input_bfd)
                               bfd_alloc (finfo->output_bfd,
                                          sizeof (struct xcoff_toc_rel_hash)));
                          if (n == NULL)
-                           {
-                             bfd_set_error (bfd_error_no_memory);
-                             return false;
-                           }
+                           return false;
                          si = finfo->section_info + target_index;
                          n->next = si->toc_rel_hashes;
                          n->h = h;
@@ -5375,10 +5320,7 @@ xcoff_reloc_link_order (output_bfd, finfo, output_section, link_order)
       size = bfd_get_reloc_size (howto);
       buf = (bfd_byte *) bfd_zmalloc (size);
       if (buf == NULL)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
 
       rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
       switch (rstat)
This page took 0.132225 seconds and 4 git commands to generate.