]> Git Repo - binutils.git/blobdiff - bfd/hp300hpux.c
* elf32-i386.c (elf_i386_size_dynamic_sections): Add DT_DEBUG to
[binutils.git] / bfd / hp300hpux.c
index 5be01e30c246105341e9ad6ac473ad147eddfe2c..496f754e1b23222dc38d0394a3578ea2f803c924 100644 (file)
@@ -119,7 +119,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define DEFAULT_ARCH bfd_arch_m68k
 
 #define MY_get_section_contents aout_32_get_section_contents
-#define MY_close_and_cleanup aout_32_close_and_cleanup
 #define MY_slurp_armap bfd_slurp_bsd_armap_f2
 
 /***********************************************/
@@ -137,6 +136,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define MY_bfd_final_link _bfd_generic_final_link
 
+/* Until and unless we convert the slurp_reloc and slurp_symtab
+   routines in this file, we can not use the default aout
+   free_cached_info routine which assumes that the relocs and symtabs
+   were allocated using malloc.  */
+#define MY_bfd_free_cached_info bfd_true
+
 #define hp300hpux_write_syms aout_32_write_syms
 
 #define MY_callback MY(callback)
@@ -278,8 +283,10 @@ MY (write_object_contents) (abfd)
   /* this is really the sym table size but we store it in drelocs */
   bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);
 
-  bfd_seek (abfd, 0L, false);
-  bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd);
+  if (bfd_seek (abfd, 0L, false) != 0
+      || (bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+         != EXEC_BYTES_SIZE))
+    return false;
 
   /* Write out the symbols, and then the relocs.  We must write out
        the symbols first so that we know the symbol indices.  */
@@ -297,12 +304,12 @@ MY (write_object_contents) (abfd)
 
   if (bfd_get_symcount (abfd) != 0)
     {
-      bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false);
-
+      if (bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false) != 0)
+       return false;
       if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
        return false;
-      bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false);
-
+      if (bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false) != 0)
+       return false;
       if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
        return false;
     }
@@ -498,8 +505,8 @@ MY (slurp_symbol_table) (abfd)
       return false;
     }
   syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
-  bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
-  if (bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
+  if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
+      || bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
     {
       bfd_release (abfd, syms);
       return false;
@@ -734,7 +741,8 @@ MY (slurp_reloc_table) (abfd, asect, symbols)
   return false;
 
 doit:
-  bfd_seek (abfd, asect->rel_filepos, SEEK_SET);
+  if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
+    return false;
   each_size = obj_reloc_entry_size (abfd);
 
   count = reloc_size / each_size;
@@ -742,7 +750,7 @@ doit:
 
   reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t) (count * sizeof
                                                        (arelent)));
-  if (!reloc_cache)
+  if (!reloc_cache && count != 0)
     {
     nomem:
       bfd_set_error (bfd_error_no_memory);
@@ -750,7 +758,7 @@ doit:
     }
 
   relocs = (PTR) bfd_alloc (abfd, reloc_size);
-  if (!relocs)
+  if (!relocs && reloc_size != 0)
     {
       bfd_release (abfd, reloc_cache);
       goto nomem;
@@ -786,14 +794,14 @@ doit:
 /* call aout_32 versions if the input file was generated by gcc         */
 /************************************************************************/
 
-unsigned int aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location));
-unsigned int aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd));
+long aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location));
+long aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd));
 
-unsigned int aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section,
-                                                arelent ** relptr,
-                                                asymbol ** symbols));
+long aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section,
+                                        arelent ** relptr,
+                                        asymbol ** symbols));
 
-unsigned int
+long
 MY (get_symtab) (abfd, location)
      bfd *abfd;
      asymbol **location;
@@ -805,7 +813,7 @@ MY (get_symtab) (abfd, location)
     return aout_32_get_symtab (abfd, location);
 
   if (!MY (slurp_symbol_table) (abfd))
-    return 0;
+    return -1;
 
   for (symbase = obj_aout_symbols (abfd); counter++ < bfd_get_symcount (abfd);)
     *(location++) = (asymbol *) (symbase++);
@@ -813,14 +821,14 @@ MY (get_symtab) (abfd, location)
   return bfd_get_symcount (abfd);
 }
 
-unsigned int
+long
 MY (get_symtab_upper_bound) (abfd)
      bfd *abfd;
 {
   if (obj_aout_subformat (abfd) == gnu_encap_format)
     return aout_32_get_symtab_upper_bound (abfd);
   if (!MY (slurp_symbol_table) (abfd))
-    return 0;
+    return -1;
 
   return (bfd_get_symcount (abfd) + 1) * (sizeof (aout_symbol_type *));
 }
@@ -828,7 +836,7 @@ MY (get_symtab_upper_bound) (abfd)
 
 
 
-unsigned int
+long
 MY (canonicalize_reloc) (abfd, section, relptr, symbols)
      bfd *abfd;
      sec_ptr section;
@@ -841,7 +849,7 @@ MY (canonicalize_reloc) (abfd, section, relptr, symbols)
     return aout_32_canonicalize_reloc (abfd, section, relptr, symbols);
 
   if (!(tblptr || MY (slurp_reloc_table) (abfd, section, symbols)))
-    return 0;
+    return -1;
 
   if (section->flags & SEC_CONSTRUCTOR)
     {
@@ -855,8 +863,6 @@ MY (canonicalize_reloc) (abfd, section, relptr, symbols)
   else
     {
       tblptr = section->relocation;
-      if (!tblptr)
-       return 0;
 
       for (count = 0; count++ < section->reloc_count;)
        {
This page took 0.030044 seconds and 4 git commands to generate.