*** empty log message ***
[deliverable/binutils-gdb.git] / bfd / ieee.c
index 005581bf5febdd429733cc242903659da66ae783..9a29fc46b0404cc5a7c409ce5ab24ac2e8e60ba8 100644 (file)
@@ -37,40 +37,43 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
    standard requires. */
 
 static void
-DEFUN (ieee_write_byte, (abfd, byte),
-       bfd * abfd AND
-       bfd_byte byte)
+ieee_write_byte (abfd, byte)
+     bfd *abfd;
+     bfd_byte byte;
 {
-  bfd_write ((PTR) & byte, 1, 1, abfd);
+  if (bfd_write ((PTR) & byte, 1, 1, abfd) != 1)
+    abort ();
 }
 
 static void
-DEFUN (ieee_write_twobyte, (abfd, twobyte),
-       bfd * abfd AND
-       int twobyte)
+ieee_write_twobyte (abfd, twobyte)
+     bfd *abfd;
+     int twobyte;
 {
   bfd_byte b[2];
   b[1] = twobyte & 0xff;
   b[0] = twobyte >> 8;
-  bfd_write ((PTR) & b[0], 1, 2, abfd);
+  if (bfd_write ((PTR) & b[0], 1, 2, abfd) != 2)
+    abort ();
 }
 
 static void
-DEFUN (ieee_write_2bytes, (abfd, bytes),
-       bfd * abfd AND
-       int bytes)
+ieee_write_2bytes (abfd, bytes)
+     bfd *abfd;
+     int bytes;
 {
   bfd_byte buffer[2];
   buffer[0] = bytes >> 8;
   buffer[1] = bytes & 0xff;
 
-  bfd_write ((PTR) buffer, 1, 2, abfd);
+  if (bfd_write ((PTR) buffer, 1, 2, abfd) != 2)
+    abort ();
 }
 
 static void
-DEFUN (ieee_write_int, (abfd, value),
-       bfd * abfd AND
-       bfd_vma value)
+ieee_write_int (abfd, value)
+     bfd *abfd;
+     bfd_vma value;
 {
   if (((unsigned) value) <= 127)
     {
@@ -113,9 +116,9 @@ DEFUN (ieee_write_int, (abfd, value),
 }
 
 static void
-DEFUN (ieee_write_id, (abfd, id),
-       bfd * abfd AND
-       CONST char *id)
+ieee_write_id (abfd, id)
+     bfd *abfd;
+     CONST char *id;
 {
   size_t length = strlen (id);
   if (length <= 127)
@@ -137,7 +140,8 @@ DEFUN (ieee_write_id, (abfd, id),
     {
       BFD_FAIL ();
     }
-  bfd_write ((PTR) id, 1, length, abfd);
+  if (bfd_write ((PTR) id, 1, length, abfd) != length)
+    abort ();
 }
 \f
 
@@ -151,8 +155,8 @@ standard requires:
 #define this_byte_and_next(ieee) (*((ieee)->input_p++))
 
 static unsigned short
-DEFUN (read_2bytes, (ieee),
-       common_header_type * ieee)
+read_2bytes (ieee)
+     common_header_type *ieee;
 {
   unsigned char c1 = this_byte_and_next (ieee);
   unsigned char c2 = this_byte_and_next (ieee);
@@ -160,10 +164,10 @@ DEFUN (read_2bytes, (ieee),
 }
 
 static void
-DEFUN (bfd_get_string, (ieee, string, length),
-       common_header_type * ieee AND
-       char *string AND
-       size_t length)
+bfd_get_string (ieee, string, length)
+     common_header_type *ieee;
+     char *string;
+     size_t length;
 {
   size_t i;
   for (i = 0; i < length; i++)
@@ -173,8 +177,8 @@ DEFUN (bfd_get_string, (ieee, string, length),
 }
 
 static char *
-DEFUN (read_id, (ieee),
-       common_header_type * ieee)
+read_id (ieee)
+     common_header_type *ieee;
 {
   size_t length;
   char *string;
@@ -198,7 +202,7 @@ DEFUN (read_id, (ieee),
   string = bfd_alloc (ieee->abfd, length + 1);
   if (!string)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return NULL;
     }
   bfd_get_string (ieee, string, length);
@@ -207,12 +211,12 @@ DEFUN (read_id, (ieee),
 }
 
 static void
-DEFUN (ieee_write_expression, (abfd, value, symbol, pcrel, index),
-       bfd * abfd AND
-       bfd_vma value AND
-       asymbol * symbol AND
-       boolean pcrel AND
-       unsigned int index)
+ieee_write_expression (abfd, value, symbol, pcrel, index)
+     bfd *abfd;
+     bfd_vma value;
+     asymbol *symbol;
+     boolean pcrel;
+     unsigned int index;
 {
   unsigned int term_count = 0;
 
@@ -289,9 +293,9 @@ DEFUN (ieee_write_expression, (abfd, value, symbol, pcrel, index),
 writes any integer into the buffer supplied and always takes 5 bytes
 */
 static void
-DEFUN (ieee_write_int5, (buffer, value),
-       bfd_byte * buffer AND
-       bfd_vma value)
+ieee_write_int5 (buffer, value)
+     bfd_byte *buffer;
+     bfd_vma value;
 {
   buffer[0] = (bfd_byte) ieee_number_repeat_4_enum;
   buffer[1] = (value >> 24) & 0xff;
@@ -301,19 +305,20 @@ DEFUN (ieee_write_int5, (buffer, value),
 }
 
 static void
-DEFUN (ieee_write_int5_out, (abfd, value),
-       bfd * abfd AND
-       bfd_vma value)
+ieee_write_int5_out (abfd, value)
+     bfd *abfd;
+     bfd_vma value;
 {
   bfd_byte b[5];
   ieee_write_int5 (b, value);
-  bfd_write ((PTR) b, 1, 5, abfd);
+  if (bfd_write ((PTR) b, 1, 5, abfd) != 5)
+    abort ();
 }
 
 static boolean
-DEFUN (parse_int, (ieee, value_ptr),
-       common_header_type * ieee AND
-       bfd_vma * value_ptr)
+parse_int (ieee, value_ptr)
+     common_header_type *ieee;
+     bfd_vma *value_ptr;
 {
   int value = this_byte (ieee);
   int result;
@@ -340,9 +345,9 @@ DEFUN (parse_int, (ieee, value_ptr),
 }
 
 static int
-DEFUN (parse_i, (ieee, ok),
-       common_header_type * ieee AND
-       boolean * ok)
+parse_i (ieee, ok)
+     common_header_type *ieee;
+     boolean *ok;
 {
   bfd_vma x;
   *ok = parse_int (ieee, &x);
@@ -350,8 +355,8 @@ DEFUN (parse_i, (ieee, ok),
 }
 
 static bfd_vma
-DEFUN (must_parse_int, (ieee),
-       common_header_type * ieee)
+must_parse_int (ieee)
+     common_header_type *ieee;
 {
   bfd_vma result;
   BFD_ASSERT (parse_int (ieee, &result) == true);
@@ -396,13 +401,13 @@ static ieee_symbol_index_type NOSYMBOL =
 
 
 static void
-DEFUN (parse_expression, (ieee, value, symbol, pcrel, extra, section),
-       ieee_data_type * ieee AND
-       bfd_vma * value AND
-       ieee_symbol_index_type * symbol AND
-       boolean * pcrel AND
-       unsigned int *extra AND
-       asection ** section)
+parse_expression (ieee, value, symbol, pcrel, extra, section)
+     ieee_data_type *ieee;
+     bfd_vma *value;
+     ieee_symbol_index_type *symbol;
+     boolean *pcrel;
+     unsigned int *extra;
+     asection **section;
 
 {
 #define POS sp[1]
@@ -542,22 +547,22 @@ static unsigned int last_index;
 static char last_type;         /* is the index for an X or a D */
 
 static ieee_symbol_type *
-DEFUN (get_symbol, (abfd,
-                   ieee,
-                   last_symbol,
-                   symbol_count,
-                   pptr,
-                   max_index,
-                   this_type
-       ),
-       bfd * abfd AND
-       ieee_data_type * ieee AND
-       ieee_symbol_type * last_symbol AND
-       unsigned int *symbol_count AND
-       ieee_symbol_type *** pptr AND
-       unsigned int *max_index AND
-       char this_type
+get_symbol (abfd,
+           ieee,
+           last_symbol,
+           symbol_count,
+           pptr,
+           max_index,
+           this_type
 )
+     bfd *abfd;
+     ieee_data_type *ieee;
+     ieee_symbol_type *last_symbol;
+     unsigned int *symbol_count;
+     ieee_symbol_type ***pptr;
+     unsigned int *max_index;
+     char this_type
+      ;
 {
   /* Need a new symbol */
   unsigned int new_index = must_parse_int (&(ieee->h));
@@ -567,7 +572,7 @@ DEFUN (get_symbol, (abfd,
                                                 sizeof (ieee_symbol_type));
       if (!new_symbol)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return NULL;
        }
 
@@ -586,9 +591,9 @@ DEFUN (get_symbol, (abfd,
   return last_symbol;
 }
 
-static void
-DEFUN (ieee_slurp_external_symbols, (abfd),
-       bfd * abfd)
+static boolean
+ieee_slurp_external_symbols (abfd)
+     bfd *abfd;
 {
   ieee_data_type *ieee = IEEE_DATA (abfd);
   file_ptr offset = ieee->w.r.external_part;
@@ -613,7 +618,8 @@ DEFUN (ieee_slurp_external_symbols, (abfd),
          symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
                               &prev_symbols_ptr,
                               &ieee->external_symbol_max_index, 'D');
-
+         if (symbol == NULL)
+           return false;
 
          symbol->symbol.the_bfd = abfd;
          symbol->symbol.name = read_id (&(ieee->h));
@@ -626,7 +632,8 @@ DEFUN (ieee_slurp_external_symbols, (abfd),
          symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
                               &prev_symbols_ptr,
                               &ieee->external_symbol_max_index, 'D');
-
+         if (symbol == NULL)
+           return false;
 
          BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index);
 
@@ -710,7 +717,8 @@ DEFUN (ieee_slurp_external_symbols, (abfd),
          symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
                               &prev_reference_ptr,
                               &ieee->external_reference_max_index, 'X');
-
+         if (symbol == NULL)
+           return false;
 
          symbol->symbol.the_bfd = abfd;
          symbol->symbol.name = read_id (&(ieee->h));
@@ -760,24 +768,29 @@ DEFUN (ieee_slurp_external_symbols, (abfd),
 
   *prev_symbols_ptr = (ieee_symbol_type *) NULL;
   *prev_reference_ptr = (ieee_symbol_type *) NULL;
+
+  return true;
 }
 
-static void
-DEFUN (ieee_slurp_symbol_table, (abfd),
-       bfd * abfd)
+static boolean
+ieee_slurp_symbol_table (abfd)
+     bfd *abfd;
 {
   if (IEEE_DATA (abfd)->read_symbols == false)
     {
-      ieee_slurp_external_symbols (abfd);
+      if (! ieee_slurp_external_symbols (abfd))
+       return false;
       IEEE_DATA (abfd)->read_symbols = true;
     }
+  return true;
 }
 
-unsigned int
-DEFUN (ieee_get_symtab_upper_bound, (abfd),
-       bfd * abfd)
+long
+ieee_get_symtab_upper_bound (abfd)
+     bfd *abfd;
 {
-  ieee_slurp_symbol_table (abfd);
+  if (! ieee_slurp_symbol_table (abfd))
+    return -1;
 
   return (abfd->symcount != 0) ?
     (abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0;
@@ -788,12 +801,12 @@ Move from our internal lists to the canon table, and insert in
 symbol index order
 */
 
-extern bfd_target ieee_vec;
+extern const bfd_target ieee_vec;
 
-unsigned int
-DEFUN (ieee_get_symtab, (abfd, location),
-       bfd * abfd AND
-       asymbol ** location)
+long
+ieee_get_symtab (abfd, location)
+     bfd *abfd;
+     asymbol **location;
 {
   ieee_symbol_type *symp;
   static bfd dummy_bfd;
@@ -805,7 +818,8 @@ DEFUN (ieee_get_symtab, (abfd, location),
     {
       ieee_data_type *ieee = IEEE_DATA (abfd);
       dummy_bfd.xvec = &ieee_vec;
-      ieee_slurp_symbol_table (abfd);
+      if (! ieee_slurp_symbol_table (abfd))
+       return -1;
 
       if (ieee->symbol_table_full == false)
        {
@@ -848,10 +862,10 @@ DEFUN (ieee_get_symtab, (abfd, location),
 }
 
 static asection *
-DEFUN (get_section_entry, (abfd, ieee, index),
-       bfd * abfd AND
-       ieee_data_type * ieee AND
-       unsigned int index)
+get_section_entry (abfd, ieee, index)
+     bfd *abfd;
+     ieee_data_type *ieee;
+     unsigned int index;
 {
   if (ieee->section_table[index] == (asection *) NULL)
     {
@@ -860,7 +874,7 @@ DEFUN (get_section_entry, (abfd, ieee, index),
 
       if (!tmp)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return NULL;
        }
       sprintf (tmp, " fsec%4d", index);
@@ -874,8 +888,8 @@ DEFUN (get_section_entry, (abfd, ieee, index),
 }
 
 static void
-DEFUN (ieee_slurp_sections, (abfd),
-       bfd * abfd)
+ieee_slurp_sections (abfd)
+     bfd *abfd;
 {
   ieee_data_type *ieee = IEEE_DATA (abfd);
   file_ptr offset = ieee->w.r.section_part;
@@ -1038,9 +1052,9 @@ DEFUN (ieee_slurp_sections, (abfd),
 *  archive stuff
 */
 
-bfd_target *
-DEFUN (ieee_archive_p, (abfd),
-       bfd * abfd)
+const bfd_target *
+ieee_archive_p (abfd)
+     bfd *abfd;
 {
   char *library;
   boolean loop;
@@ -1054,11 +1068,13 @@ DEFUN (ieee_archive_p, (abfd),
   abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type));
   if (!abfd->tdata.ieee_ar_data)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return NULL;
     }
   ieee = IEEE_AR_DATA (abfd);
 
+  /* FIXME: Check return value.  I'm not sure whether it needs to read
+     the entire buffer or not.  */
   bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
 
   ieee->h.first_byte = buffer;
@@ -1069,7 +1085,7 @@ DEFUN (ieee_archive_p, (abfd),
   if (this_byte (&(ieee->h)) != Module_Beginning)
     {
       abfd->tdata.ieee_ar_data = save;
-      return (bfd_target *) NULL;
+      return (const bfd_target *) NULL;
     }
 
   next_byte (&(ieee->h));
@@ -1078,7 +1094,7 @@ DEFUN (ieee_archive_p, (abfd),
     {
       bfd_release (abfd, ieee);
       abfd->tdata.ieee_ar_data = save;
-      return (bfd_target *) NULL;
+      return (const bfd_target *) NULL;
     }
   /* Throw away the filename */
   read_id (&(ieee->h));
@@ -1087,8 +1103,8 @@ DEFUN (ieee_archive_p, (abfd),
 
   if (!obstack_begin (&ob, 128))
     {
-      bfd_error = no_memory;
-      return (bfd_target *) NULL;
+      bfd_set_error (bfd_error_no_memory);
+      return (const bfd_target *) NULL;
     }
 
   ieee->element_count = 0;
@@ -1119,7 +1135,10 @@ DEFUN (ieee_archive_p, (abfd),
            {
              /* Past half way, reseek and reprime */
              buffer_offset += ieee_pos (abfd);
-             bfd_seek (abfd, buffer_offset, SEEK_SET);
+             if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0)
+               return NULL;
+             /* FIXME: Check return value.  I'm not sure whether it
+                needs to read the entire buffer or not.  */
              bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
              ieee->h.first_byte = buffer;
              ieee->h.input_p = buffer;
@@ -1132,8 +1151,8 @@ DEFUN (ieee_archive_p, (abfd),
   ieee->elements = (ieee_ar_obstack_type *) obstack_finish (&ob);
   if (!ieee->elements)
     {
-      bfd_error = no_memory;
-      return (bfd_target *) NULL;
+      bfd_set_error (bfd_error_no_memory);
+      return (const bfd_target *) NULL;
     }
 
   /* Now scan the area again, and replace BB offsets with file */
@@ -1141,7 +1160,10 @@ DEFUN (ieee_archive_p, (abfd),
 
   for (i = 2; i < ieee->element_count; i++)
     {
-      bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET);
+      if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0)
+       return NULL;
+      /* FIXME: Check return value.  I'm not sure whether it needs to
+        read the entire buffer or not.  */
       bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
       ieee->h.first_byte = buffer;
       ieee->h.input_p = buffer;
@@ -1165,16 +1187,16 @@ DEFUN (ieee_archive_p, (abfd),
 }
 
 static boolean
-DEFUN (ieee_mkobject, (abfd),
-       bfd * abfd)
+ieee_mkobject (abfd)
+     bfd *abfd;
 {
   abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, sizeof (ieee_data_type));
   return abfd->tdata.ieee_data ? true : false;
 }
 
-bfd_target *
-DEFUN (ieee_object_p, (abfd),
-       bfd * abfd)
+const bfd_target *
+ieee_object_p (abfd)
+     bfd *abfd;
 {
   char *processor;
   unsigned int part;
@@ -1186,13 +1208,16 @@ DEFUN (ieee_object_p, (abfd),
   ieee_mkobject (abfd);
 
   ieee = IEEE_DATA (abfd);
-  bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
+  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+    goto fail;
   /* Read the first few bytes in to see if it makes sense */
+  /* FIXME: Check return value.  I'm not sure whether it needs to read
+     the entire buffer or not.  */
   bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
 
   ieee->h.input_p = buffer;
   if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
-    goto fail;
+    goto got_wrong_format;
 
   ieee->read_symbols = false;
   ieee->read_data = false;
@@ -1206,7 +1231,7 @@ DEFUN (ieee_object_p, (abfd),
 
   processor = ieee->mb.processor = read_id (&(ieee->h));
   if (strcmp (processor, "LIBRARY") == 0)
-    goto fail;
+    goto got_wrong_format;
   ieee->mb.module_name = read_id (&(ieee->h));
   if (abfd->filename == (CONST char *) NULL)
     {
@@ -1217,7 +1242,7 @@ DEFUN (ieee_object_p, (abfd),
   {
     bfd_arch_info_type *arch = bfd_scan_arch (processor);
     if (arch == 0)
-      goto fail;
+      goto got_wrong_format;
     abfd->arch_info = arch;
   }
 
@@ -1270,25 +1295,30 @@ DEFUN (ieee_object_p, (abfd),
                                                                + 50);
   if (!IEEE_DATA (abfd)->h.first_byte)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       goto fail;
     }
-  bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
+  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
+     the entire buffer or not.  */
   bfd_read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1, ieee->w.r.me_record + 50, abfd);
 
   ieee_slurp_sections (abfd);
   return abfd->xvec;
+got_wrong_format:
+  bfd_set_error (bfd_error_wrong_format);
 fail:
   (void) bfd_release (abfd, ieee);
   abfd->tdata.ieee_data = save;
-  return (bfd_target *) NULL;
+  return (const bfd_target *) NULL;
 }
 
 void
-DEFUN (ieee_get_symbol_info, (ignore_abfd, symbol, ret),
-       bfd * ignore_abfd AND
-       asymbol * symbol AND
-       symbol_info * ret)
+ieee_get_symbol_info (ignore_abfd, symbol, ret)
+     bfd *ignore_abfd;
+     asymbol *symbol;
+     symbol_info *ret;
 {
   bfd_symbol_info (symbol, ret);
   if (symbol->name[0] == ' ')
@@ -1298,11 +1328,11 @@ DEFUN (ieee_get_symbol_info, (ignore_abfd, symbol, ret),
 }
 
 void
-DEFUN (ieee_print_symbol, (ignore_abfd, afile, symbol, how),
-       bfd * ignore_abfd AND
-       PTR afile AND
-       asymbol * symbol AND
-       bfd_print_symbol_type how)
+ieee_print_symbol (ignore_abfd, afile, symbol, how)
+     bfd *ignore_abfd;
+     PTR afile;
+     asymbol *symbol;
+     bfd_print_symbol_type how;
 {
   FILE *file = (FILE *) afile;
 
@@ -1344,11 +1374,11 @@ DEFUN (ieee_print_symbol, (ignore_abfd, afile, symbol, how),
 }
 
 static boolean
-DEFUN (do_one, (ieee, current_map, location_ptr, s),
-       ieee_data_type * ieee AND
-       ieee_per_section_type * current_map AND
-       unsigned char *location_ptr AND
-       asection * s)
+do_one (ieee, current_map, location_ptr, s)
+     ieee_data_type *ieee;
+     ieee_per_section_type *current_map;
+     unsigned char *location_ptr;
+     asection *s;
 {
   switch (this_byte (&(ieee->h)))
     {
@@ -1389,7 +1419,7 @@ DEFUN (do_one, (ieee, current_map, location_ptr, s),
                                                 sizeof (ieee_reloc_type));
                  if (!r)
                    {
-                     bfd_error = no_memory;
+                     bfd_set_error (bfd_error_no_memory);
                      return false;
                    }
 
@@ -1540,8 +1570,8 @@ DEFUN (do_one, (ieee, current_map, location_ptr, s),
 
 /* Read in all the section data and relocation stuff too */
 static boolean
-DEFUN (ieee_slurp_section_data, (abfd),
-       bfd * abfd)
+ieee_slurp_section_data (abfd)
+     bfd *abfd;
 {
   bfd_byte *location_ptr = (bfd_byte *) NULL;
   ieee_data_type *ieee = IEEE_DATA (abfd);
@@ -1563,7 +1593,7 @@ DEFUN (ieee_slurp_section_data, (abfd),
       per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size);
       if (!per->data)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return false;
        }
       /*SUPPRESS 68*/
@@ -1668,15 +1698,15 @@ DEFUN (ieee_slurp_section_data, (abfd),
 }
 
 boolean
-DEFUN (ieee_new_section_hook, (abfd, newsect),
-       bfd * abfd AND
-       asection * newsect)
+ieee_new_section_hook (abfd, newsect)
+     bfd *abfd;
+     asection *newsect;
 {
   newsect->used_by_bfd = (PTR)
     bfd_alloc (abfd, sizeof (ieee_per_section_type));
   if (!newsect->used_by_bfd)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   ieee_per_section (newsect)->data = (bfd_byte *) NULL;
@@ -1684,22 +1714,23 @@ DEFUN (ieee_new_section_hook, (abfd, newsect),
   return true;
 }
 
-unsigned int
-DEFUN (ieee_get_reloc_upper_bound, (abfd, asect),
-       bfd * abfd AND
-       sec_ptr asect)
+long
+ieee_get_reloc_upper_bound (abfd, asect)
+     bfd *abfd;
+     sec_ptr asect;
 {
-  ieee_slurp_section_data (abfd);
+  if (! ieee_slurp_section_data (abfd))
+    return -1;
   return (asect->reloc_count + 1) * sizeof (arelent *);
 }
 
 static boolean
-DEFUN (ieee_get_section_contents, (abfd, section, location, offset, count),
-       bfd * abfd AND
-       sec_ptr section AND
-       PTR location AND
-       file_ptr offset AND
-       bfd_size_type count)
+ieee_get_section_contents (abfd, section, location, offset, count)
+     bfd *abfd;
+     sec_ptr section;
+     PTR location;
+     file_ptr offset;
+     bfd_size_type count;
 {
   ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;
   ieee_slurp_section_data (abfd);
@@ -1707,12 +1738,12 @@ DEFUN (ieee_get_section_contents, (abfd, section, location, offset, count),
   return true;
 }
 
-unsigned int
-DEFUN (ieee_canonicalize_reloc, (abfd, section, relptr, symbols),
-       bfd * abfd AND
-       sec_ptr section AND
-       arelent ** relptr AND
-       asymbol ** symbols)
+long
+ieee_canonicalize_reloc (abfd, section, relptr, symbols)
+     bfd *abfd;
+     sec_ptr section;
+     arelent **relptr;
+     asymbol **symbols;
 {
 /*  ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
   ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation);
@@ -1743,9 +1774,9 @@ DEFUN (ieee_canonicalize_reloc, (abfd, section, relptr, symbols),
 }
 
 static int
-DEFUN (comp, (ap, bp),
-       CONST PTR ap AND
-       CONST PTR bp)
+comp (ap, bp)
+     CONST PTR ap;
+     CONST PTR bp;
 {
   arelent *a = *((arelent **) ap);
   arelent *b = *((arelent **) bp);
@@ -1757,8 +1788,8 @@ Write the section headers
 */
 
 static void
-DEFUN (ieee_write_section_part, (abfd),
-       bfd * abfd)
+ieee_write_section_part (abfd)
+     bfd *abfd;
 {
   ieee_data_type *ieee = IEEE_DATA (abfd);
   asection *s;
@@ -1831,9 +1862,9 @@ DEFUN (ieee_write_section_part, (abfd),
 
 
 static boolean
-DEFUN (do_with_relocs, (abfd, s),
-       bfd * abfd AND
-       asection * s)
+do_with_relocs (abfd, s)
+     bfd *abfd;
+     asection *s;
 {
   unsigned int relocs_to_go = s->reloc_count;
 
@@ -1875,10 +1906,12 @@ DEFUN (do_with_relocs, (abfd, s),
              ieee_write_byte (abfd, ieee_load_constant_bytes_enum);
              /* Output a stream of bytes */
              ieee_write_int (abfd, run);
-             bfd_write ((PTR) (stream + current_byte_index),
-                        1,
-                        run,
-                        abfd);
+             if (bfd_write ((PTR) (stream + current_byte_index),
+                            1,
+                            run,
+                            abfd)
+                 != run)
+               return false;
              current_byte_index += run;
            }
        }
@@ -1898,7 +1931,7 @@ DEFUN (do_with_relocs, (abfd, s),
          stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));
          if (!stream)
            {
-             bfd_error = no_memory;
+             bfd_set_error (bfd_error_no_memory);
              return false;
            }
          memset ((PTR) stream, 0, s->_raw_size);
@@ -1924,10 +1957,12 @@ DEFUN (do_with_relocs, (abfd, s),
            {
              /* Output a stream of bytes */
              ieee_write_int (abfd, run);
-             bfd_write ((PTR) (stream + current_byte_index),
-                        1,
-                        run,
-                        abfd);
+             if (bfd_write ((PTR) (stream + current_byte_index),
+                            1,
+                            run,
+                            abfd)
+                 != run)
+               return false;
              current_byte_index += run;
            }
          /* Output any relocations here */
@@ -2007,9 +2042,9 @@ be clever about how we write. We block items up into a max of 127
 bytes */
 
 static void
-DEFUN (do_as_repeat, (abfd, s),
-       bfd * abfd AND
-       asection * s)
+do_as_repeat (abfd, s)
+     bfd *abfd;
+     asection *s;
 {
   if (s->_raw_size)
     {
@@ -2029,9 +2064,9 @@ DEFUN (do_as_repeat, (abfd, s),
 }
 
 static void
-DEFUN (do_without_relocs, (abfd, s),
-       bfd * abfd AND
-       asection * s)
+do_without_relocs (abfd, s)
+     bfd *abfd;
+     asection *s;
 {
   bfd_byte *stream = ieee_per_section (s)->data;
 
@@ -2066,16 +2101,21 @@ static bfd *input_bfd;
 static bfd *output_bfd;
 static int output_buffer;
 
-static void 
+static void
 fill ()
 {
+  /* FIXME: Check return value.  I'm not sure whether it needs to read
+     the entire buffer or not.  */
   bfd_read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd);
   input_ptr = input_ptr_start;
 }
-static void 
+static void
 flush ()
 {
-  bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start, output_bfd);
+  if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start,
+                output_bfd)
+      != output_ptr - output_ptr_start)
+    abort ();
   output_ptr = output_ptr_start;
   output_buffer++;
 }
@@ -2084,7 +2124,7 @@ flush ()
 #define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); }
 #define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end)  flush(); }
 
-static void 
+static void
 write_int (value)
      int value;
 {
@@ -2128,7 +2168,7 @@ write_int (value)
     }
 }
 
-static void 
+static void
 copy_id ()
 {
   int length = THIS ();
@@ -2144,7 +2184,7 @@ copy_id ()
 }
 
 #define VAR(x) ((x | 0x80))
-static void 
+static void
 copy_expression ()
 {
   int stack[10];
@@ -2261,8 +2301,8 @@ struct output_buffer_struct
 };
 
 static void
-DEFUN (fill_int, (buf),
-       struct output_buffer_struct *buf)
+fill_int (buf)
+     struct output_buffer_struct *buf;
 {
   if (buf->buffer == output_buffer)
     {
@@ -2276,8 +2316,8 @@ DEFUN (fill_int, (buf),
 }
 
 static void
-DEFUN (drop_int, (buf),
-       struct output_buffer_struct *buf)
+drop_int (buf)
+     struct output_buffer_struct *buf;
 {
   int type = THIS ();
   int ch;
@@ -2311,7 +2351,7 @@ DEFUN (drop_int, (buf),
   OUT (0);
 }
 
-static void 
+static void
 copy_int ()
 {
   int type = THIS ();
@@ -2351,7 +2391,7 @@ static void copy_till_end ();
 #define INTn(q) copy_int()
 #define EXPn(q) copy_expression()
 
-static void 
+static void
 f1_record ()
 {
   int ch;
@@ -2452,7 +2492,7 @@ f1_record ()
 
 }
 
-static void 
+static void
 f0_record ()
 {
   /* Attribute record */
@@ -2462,7 +2502,7 @@ f0_record ()
   ID;
 }
 
-static void 
+static void
 copy_till_end ()
 {
   int ch = THIS ();
@@ -2500,7 +2540,7 @@ copy_till_end ()
 
 }
 
-static void 
+static void
 f2_record ()
 {
   NEXT ();
@@ -2514,7 +2554,7 @@ f2_record ()
 
 
 static void block ();
-static void 
+static void
 f8_record ()
 {
   int ch;
@@ -2658,7 +2698,7 @@ f8_record ()
     }
 }
 
-static void 
+static void
 e2_record ()
 {
   OUT (0xe2);
@@ -2669,8 +2709,8 @@ e2_record ()
   EXP;
 }
 
-static void 
-DEFUN_VOID (block)
+static void
+block ()
 {
   int ch;
   while (1)
@@ -2711,9 +2751,9 @@ DEFUN_VOID (block)
 */
 
 static void
-DEFUN (relocate_debug, (output, input),
-       bfd * output AND
-       bfd * input)
+relocate_debug (output, input)
+     bfd *output;
+     bfd *input;
 {
 #define IBS 400
 #define OBS 400
@@ -2722,6 +2762,8 @@ DEFUN (relocate_debug, (output, input),
   input_ptr_start = input_ptr = input_buffer;
   input_ptr_end = input_buffer + IBS;
   input_bfd = input;
+  /* FIXME: Check return value.  I'm not sure whether it needs to read
+     the entire buffer or not.  */
   bfd_read ((PTR) input_ptr_start, 1, IBS, input);
   block ();
 }
@@ -2733,8 +2775,8 @@ DEFUN (relocate_debug, (output, input),
 */
 
 static void
-DEFUN (ieee_write_debug_part, (abfd),
-       bfd * abfd)
+ieee_write_debug_part (abfd)
+     bfd *abfd;
 {
   ieee_data_type *ieee = IEEE_DATA (abfd);
   bfd_chain_type *chain = ieee->chain_root;
@@ -2801,7 +2843,10 @@ DEFUN (ieee_write_debug_part, (abfd),
          ieee_data_type *entry_ieee = IEEE_DATA (entry);
          if (entry_ieee->w.r.debug_information_part)
            {
-             bfd_seek (entry, entry_ieee->w.r.debug_information_part, SEEK_SET);
+             if (bfd_seek (entry, entry_ieee->w.r.debug_information_part,
+                           SEEK_SET)
+                 != 0)
+               abort ();
              relocate_debug (abfd, entry);
            }
 
@@ -2822,8 +2867,8 @@ DEFUN (ieee_write_debug_part, (abfd),
 
 /* write the data in an ieee way */
 static void
-DEFUN (ieee_write_data_part, (abfd),
-       bfd * abfd)
+ieee_write_data_part (abfd)
+     bfd *abfd;
 {
   asection *s;
   ieee_data_type *ieee = IEEE_DATA (abfd);
@@ -2845,8 +2890,8 @@ DEFUN (ieee_write_data_part, (abfd),
 
 
 static boolean
-DEFUN (init_for_output, (abfd),
-       bfd * abfd)
+init_for_output (abfd)
+     bfd *abfd;
 {
   asection *s;
   for (s = abfd->sections; s != (asection *) NULL; s = s->next)
@@ -2856,7 +2901,7 @@ DEFUN (init_for_output, (abfd),
          ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size));
          if (!ieee_per_section (s)->data)
            {
-             bfd_error = no_memory;
+             bfd_set_error (bfd_error_no_memory);
              return false;
            }
        }
@@ -2870,12 +2915,12 @@ DEFUN (init_for_output, (abfd),
 * not a byte image, but a record stream.
 */
 boolean
-DEFUN (ieee_set_section_contents, (abfd, section, location, offset, count),
-       bfd * abfd AND
-       sec_ptr section AND
-       PTR location AND
-       file_ptr offset AND
-       bfd_size_type count)
+ieee_set_section_contents (abfd, section, location, offset, count)
+     bfd *abfd;
+     sec_ptr section;
+     PTR location;
+     file_ptr offset;
+     bfd_size_type count;
 {
   if (ieee_per_section (section)->data == (bfd_byte *) NULL)
     {
@@ -2895,8 +2940,8 @@ to index them as well. When we write them out we turn their symbol
 values into indexes from the right base.
 */
 static void
-DEFUN (ieee_write_external_part, (abfd),
-       bfd * abfd)
+ieee_write_external_part (abfd)
+     bfd *abfd;
 {
   asymbol **q;
   ieee_data_type *ieee = IEEE_DATA (abfd);
@@ -3017,8 +3062,8 @@ static CONST unsigned char envi[] =
 
 static
 void
-DEFUN (ieee_write_me_part, (abfd),
-       bfd * abfd)
+ieee_write_me_part (abfd)
+     bfd *abfd;
 {
   ieee_data_type *ieee = IEEE_DATA (abfd);
   ieee->w.r.trailer_part = bfd_tell (abfd);
@@ -3039,14 +3084,15 @@ DEFUN (ieee_write_me_part, (abfd),
 }
 
 boolean
-DEFUN (ieee_write_object_contents, (abfd),
-       bfd * abfd)
+ieee_write_object_contents (abfd)
+     bfd *abfd;
 {
   ieee_data_type *ieee = IEEE_DATA (abfd);
   unsigned int i;
   file_ptr old;
   /* Fast forward over the header area */
-  bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
+  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+    return false;
   ieee_write_byte (abfd, ieee_module_beginning_enum);
 
   ieee_write_id (abfd, bfd_printable_name (abfd));
@@ -3062,17 +3108,20 @@ DEFUN (ieee_write_object_contents, (abfd),
                   (bfd_byte) (bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd)));
 
   old = bfd_tell (abfd);
-  bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR);
+  if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0)
+    return false;
 
   ieee->w.r.extension_record = bfd_tell (abfd);
-  bfd_write ((char *) exten, 1, sizeof (exten), abfd);
+  if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten))
+    return false;
   if (abfd->flags & EXEC_P)
     ieee_write_byte (abfd, 0x1);/* Absolute */
   else
     ieee_write_byte (abfd, 0x2);/* Relocateable */
 
   ieee->w.r.environmental_record = bfd_tell (abfd);
-  bfd_write ((char *) envi, 1, sizeof (envi), abfd);
+  if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi))
+    return false;
   output_bfd = abfd;
   flush ();
 
@@ -3108,7 +3157,8 @@ DEFUN (ieee_write_object_contents, (abfd),
 
 
   /* Generate the header */
-  bfd_seek (abfd, old, SEEK_SET);
+  if (bfd_seek (abfd, old, SEEK_SET) != 0)
+    return false;
 
   for (i = 0; i < N_W_VARIABLES; i++)
     {
@@ -3128,15 +3178,15 @@ function exits.  We read the strings into a buffer large enough to
 hold them all plus all the cached symbol entries. */
 
 asymbol *
-DEFUN (ieee_make_empty_symbol, (abfd),
-       bfd * abfd)
+ieee_make_empty_symbol (abfd)
+     bfd *abfd;
 {
 
   ieee_symbol_type *new =
   (ieee_symbol_type *) bfd_zmalloc (sizeof (ieee_symbol_type));
   if (!new)
     {
-      bfd_error = no_error;
+      bfd_set_error (bfd_error_no_error);
       return NULL;
     }
   new->symbol.the_bfd = abfd;
@@ -3144,9 +3194,9 @@ DEFUN (ieee_make_empty_symbol, (abfd),
 }
 
 static bfd *
-DEFUN (ieee_openr_next_archived_file, (arch, prev),
-       bfd * arch AND
-       bfd * prev)
+ieee_openr_next_archived_file (arch, prev)
+     bfd *arch;
+     bfd *prev;
 {
   ieee_ar_data_type *ar = IEEE_AR_DATA (arch);
   /* take the next one from the arch state, or reset */
@@ -3173,7 +3223,7 @@ DEFUN (ieee_openr_next_archived_file, (arch, prev),
        }
       else
        {
-         bfd_error = no_more_archived_files;
+         bfd_set_error (bfd_error_no_more_archived_files);
          return (bfd *) NULL;
        }
 
@@ -3207,7 +3257,7 @@ ieee_generic_stat_arch_elt (abfd, buf)
   ieee_ar_data_type *ar = abfd->my_archive->tdata.ieee_ar_data;
   if (ar == (ieee_ar_data_type *) NULL)
     {
-      bfd_error = invalid_operation;
+      bfd_set_error (bfd_error_invalid_operation);
       return -1;
     }
   else
@@ -3219,24 +3269,27 @@ ieee_generic_stat_arch_elt (abfd, buf)
 }
 
 static int
-DEFUN (ieee_sizeof_headers, (abfd, x),
-       bfd * abfd AND
-       boolean x)
+ieee_sizeof_headers (abfd, x)
+     bfd *abfd;
+     boolean x;
 {
   return 0;
 }
 
 
+/* The debug info routines are never used.  */
+#if 0
+
 static void
-DEFUN (ieee_bfd_debug_info_start, (abfd),
-       bfd * abfd)
+ieee_bfd_debug_info_start (abfd)
+     bfd *abfd;
 {
 
 }
 
 static void
-DEFUN (ieee_bfd_debug_info_end, (abfd),
-       bfd * abfd)
+ieee_bfd_debug_info_end (abfd)
+     bfd *abfd;
 {
 
 }
@@ -3246,9 +3299,9 @@ DEFUN (ieee_bfd_debug_info_end, (abfd),
    be ready to output it at close time
    */
 static void
-DEFUN (ieee_bfd_debug_info_accumulate, (abfd, section),
-       bfd * abfd AND
-       asection * section)
+ieee_bfd_debug_info_accumulate (abfd, section)
+     bfd *abfd;
+     asection *section;
 {
   ieee_data_type *ieee = IEEE_DATA (section->owner);
   ieee_data_type *output_ieee = IEEE_DATA (abfd);
@@ -3270,8 +3323,8 @@ DEFUN (ieee_bfd_debug_info_accumulate, (abfd, section),
     bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, sizeof (bfd_chain_type));
     if (!n)
       {
-       bfd_error = no_memory;
-       abort();                /* FIXME */
+       bfd_set_error (bfd_error_no_memory);
+       abort ();               /* FIXME */
       }
     n->this = section->owner;
     n->next = (bfd_chain_type *) NULL;
@@ -3289,30 +3342,36 @@ DEFUN (ieee_bfd_debug_info_accumulate, (abfd, section),
   }
 }
 
+#endif
+
+#define        ieee_close_and_cleanup _bfd_generic_close_and_cleanup
+#define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
 
-#define FOO PROTO
-#define ieee_core_file_failing_command (char *(*)())(bfd_nullvoidptr)
-#define ieee_core_file_failing_signal (int (*)())bfd_0
-#define ieee_core_file_matches_executable_p ( FOO(boolean, (*),(bfd *, bfd *)))bfd_false
 #define ieee_slurp_armap bfd_true
 #define ieee_slurp_extended_name_table bfd_true
-#define ieee_truncate_arname (void (*)())bfd_nullvoidptr
-#define ieee_write_armap  (FOO( boolean, (*),(bfd *, unsigned int, struct orl *, unsigned int, int))) bfd_nullvoidptr
-#define ieee_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
-#define        ieee_close_and_cleanup          bfd_generic_close_and_cleanup
-#define ieee_set_arch_mach bfd_default_set_arch_mach
-#define ieee_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
+#define ieee_truncate_arname bfd_dont_truncate_arname
+#define ieee_write_armap \
+  ((boolean (*) \
+    PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
+   bfd_true)
+
+#define ieee_bfd_is_local_label bfd_generic_is_local_label
+#define ieee_get_lineno _bfd_nosymbols_get_lineno
+#define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
+
+#define ieee_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
+
+#define ieee_set_arch_mach _bfd_generic_set_arch_mach
+
+#define ieee_bfd_get_relocated_section_contents \
+  bfd_generic_get_relocated_section_contents
 #define ieee_bfd_relax_section bfd_generic_relax_section
-#define ieee_bfd_reloc_type_lookup \
-  ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
-#define ieee_bfd_make_debug_symbol \
-  ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
 #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
 #define ieee_bfd_final_link _bfd_generic_final_link
 
 /*SUPPRESS 460 */
-bfd_target ieee_vec =
+const bfd_target ieee_vec =
 {
   "ieee",                      /* name */
   bfd_target_ieee_flavour,
@@ -3351,6 +3410,16 @@ bfd_target ieee_vec =
     _bfd_write_archive_contents,
     bfd_false,
   },
-  JUMP_TABLE (ieee),
+
+  BFD_JUMP_TABLE_GENERIC (ieee),
+  BFD_JUMP_TABLE_COPY (_bfd_generic),
+  BFD_JUMP_TABLE_CORE (_bfd_nocore),
+  BFD_JUMP_TABLE_ARCHIVE (ieee),
+  BFD_JUMP_TABLE_SYMBOLS (ieee),
+  BFD_JUMP_TABLE_RELOCS (ieee),
+  BFD_JUMP_TABLE_WRITE (ieee),
+  BFD_JUMP_TABLE_LINK (ieee),
+  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
   (PTR) 0
 };
This page took 0.039555 seconds and 4 git commands to generate.