* srconv.c (wr_tr): Write out handcrafted tr block.
[deliverable/binutils-gdb.git] / bfd / hp300hpux.c
index d73ab1ab7bacc7838abc0d90e0320c4ba591db9d..24cc881bac6d76449148d4a4b769bd53e8a55796 100644 (file)
@@ -134,6 +134,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #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_final_link_callback unused
 #define MY_bfd_final_link _bfd_generic_final_link
 
 /* Until and unless we convert the slurp_reloc and slurp_symtab
@@ -146,6 +147,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #define MY_callback MY(callback)
 
+#define MY_exec_hdr_flags 0x2
+
 #define NAME_swap_exec_header_in NAME(hp300hpux_32_,swap_exec_header_in)
 
 #define HP_SYMTYPE_UNDEFINED   0x00
@@ -179,6 +182,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #define NAME(x,y) CAT3(hp300hpux,_32_,y)
 #define ARCH_SIZE 32
+
+/* aoutx.h requires definitions for BMAGIC and QMAGIC.  */
+#define BMAGIC 0415
+#define QMAGIC 0314
+
 #include "aoutx.h"
 
 /* Since the hpux symbol table has nlist elements interspersed with
@@ -263,7 +271,7 @@ MY (write_object_contents) (abfd)
 #endif
 
   if (adata (abfd).magic == undecided_magic)
-    NAME (aout, adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
+    NAME (aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
   execp->a_syms = 0;
 
   execp->a_entry = bfd_get_start_address (abfd);
@@ -274,17 +282,19 @@ MY (write_object_contents) (abfd)
                     obj_reloc_entry_size (abfd));
 
   N_SET_MACHTYPE (*execp, 0xc);
-  N_SET_FLAGS (*execp, 0x2);
+  N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
 
-  NAME (aout, swap_exec_header_out) (abfd, execp, &exec_bytes);
+  NAME (aout,swap_exec_header_out) (abfd, execp, &exec_bytes);
 
   /* update fields not covered by default swap_exec_header_out */
 
   /* 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.  */
@@ -302,13 +312,13 @@ MY (write_object_contents) (abfd)
 
   if (bfd_get_symcount (abfd) != 0)
     {
-      bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false);
-
-      if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
+      if (bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false) != 0)
        return false;
-      bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false);
-
-      if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
+      if (!NAME (aout,squirt_out_relocs) (abfd, obj_textsec (abfd)))
+       return 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;
     }
 
@@ -388,7 +398,7 @@ DESCRIPTION
 */
 
 void
-  NAME (aout, swap_exec_header_in) (abfd, raw_bytes, execp)
+NAME (aout,swap_exec_header_in) (abfd, raw_bytes, execp)
      bfd *abfd;
      struct external_exec *raw_bytes;
      struct internal_exec *execp;
@@ -503,8 +513,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;
@@ -560,7 +570,7 @@ MY (slurp_symbol_table) (abfd)
 
        cache_save = *cache_ptr;
        convert_sym_type (sym_pointer, cache_ptr, abfd);
-       if (!translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd))
+       if (!translate_from_native_sym_flags (abfd, cache_ptr))
          return false;
 
        /********************************************************/
@@ -606,8 +616,7 @@ MY (slurp_symbol_table) (abfd)
            strings += length + 10;
            cache_ptr2->type &= ~HP_SECONDARY_SYMBOL;   /* clear secondary */
            convert_sym_type (sym_pointer, cache_ptr2, abfd);
-           if (!translate_from_native_sym_flags (sym_pointer, cache_ptr2,
-                                                 abfd))
+           if (!translate_from_native_sym_flags (abfd, cache_ptr2))
              return false;
          }
 
@@ -739,7 +748,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;
@@ -747,7 +757,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);
@@ -755,7 +765,7 @@ doit:
     }
 
   relocs = (PTR) bfd_alloc (abfd, reloc_size);
-  if (!relocs)
+  if (!relocs && reloc_size != 0)
     {
       bfd_release (abfd, reloc_cache);
       goto nomem;
@@ -860,8 +870,6 @@ MY (canonicalize_reloc) (abfd, section, relptr, symbols)
   else
     {
       tblptr = section->relocation;
-      if (!tblptr)
-       return -1;
 
       for (count = 0; count++ < section->reloc_count;)
        {
This page took 0.026703 seconds and 4 git commands to generate.