Sun Feb 27 15:22:36 1994 Stan Shebs (shebs@andros.cygnus.com)
[deliverable/binutils-gdb.git] / bfd / som.c
index 758f3065bd0eb3353fc8008eeb56c3bd4546836f..df78f00c1c850b1866247903e331b9ce3723197b 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -1362,10 +1362,7 @@ hppa_som_reloc (abfd, reloc_entry, symbol_in, data,
 }
 
 /* Given a generic HPPA relocation type, the instruction format,
-   and a field selector, return an appropriate SOM reloation.
-
-   FIXME.  Need to handle %RR, %LR and the like as field selectors.
-   These will need to generate multiple SOM relocations.  */ 
+   and a field selector, return one or more appropriate SOM relocations.  */
 
 int **
 hppa_som_gen_reloc_type (abfd, base_type, format, field)
@@ -1380,7 +1377,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
   final_type = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
   if (!final_types || !final_type)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return NULL;
     }
 
@@ -1407,7 +1404,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
          {
-           bfd_error = no_memory;
+           bfd_set_error (bfd_error_no_memory);
            return NULL;
          }
        if (field == e_tsel)
@@ -1426,7 +1423,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
          {
-           bfd_error = no_memory;
+           bfd_set_error (bfd_error_no_memory);
            return NULL;
          }
        *final_types[0] = R_S_MODE;
@@ -1440,7 +1437,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
          {
-           bfd_error = no_memory;
+           bfd_set_error (bfd_error_no_memory);
            return NULL;
          }
        *final_types[0] = R_N_MODE;
@@ -1454,7 +1451,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
          {
-           bfd_error = no_memory;
+           bfd_set_error (bfd_error_no_memory);
            return NULL;
          }
        *final_types[0] = R_D_MODE;
@@ -1468,7 +1465,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
        final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
        if (!final_types[0])
          {
-           bfd_error = no_memory;
+           bfd_set_error (bfd_error_no_memory);
            return NULL;
          }
        *final_types[0] = R_R_MODE;
@@ -1604,7 +1601,7 @@ make_unique_section (abfd, name, num)
   newname = bfd_alloc (abfd, strlen (sect->name) + 1);
   if (!newname)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return NULL;
     }
   strcpy (newname, sect->name);
@@ -1809,13 +1806,13 @@ som_object_p (abfd)
 
   if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return 0;
     }
 
   if (!_PA_RISC_ID (file_hdr.system_id))
     {
-      bfd_error = wrong_format;
+      bfd_set_error (bfd_error_wrong_format);
       return 0;
     }
 
@@ -1839,14 +1836,14 @@ som_object_p (abfd)
 #endif
       break;
     default:
-      bfd_error = wrong_format;
+      bfd_set_error (bfd_error_wrong_format);
       return 0;
     }
 
   if (file_hdr.version_id != VERSION_ID
       && file_hdr.version_id != NEW_VERSION_ID)
     {
-      bfd_error = wrong_format;
+      bfd_set_error (bfd_error_wrong_format);
       return 0;
     }
 
@@ -1858,7 +1855,7 @@ som_object_p (abfd)
     {
       if (bfd_read ((PTR) & aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE)
        {
-         bfd_error = wrong_format;
+         bfd_set_error (bfd_error_wrong_format);
          return 0;
        }
     }
@@ -1866,7 +1863,7 @@ som_object_p (abfd)
   if (!setup_sections (abfd, &file_hdr))
     {
       /* setup_sections does not bubble up a bfd error code.  */
-      bfd_error = bad_value;
+      bfd_set_error (bfd_error_bad_value);
       return 0;
     }
 
@@ -1885,7 +1882,7 @@ som_mkobject (abfd)
     bfd_zalloc (abfd, sizeof (struct som_data_struct));
   if (abfd->tdata.som_data == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   obj_som_file_hdr (abfd)
@@ -1893,7 +1890,7 @@ som_mkobject (abfd)
   if (obj_som_file_hdr (abfd) == NULL)
 
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   return true;
@@ -1912,7 +1909,7 @@ som_prep_headers (abfd)
 
   /* FIXME.  This should really be conditional based on whether or not
      PA1.1 instructions/registers have been used.  */
-  file_hdr->system_id = HP9000S800_ID;
+  file_hdr->system_id = CPU_PA_RISC1_0;
 
   /* FIXME.  Only correct for building relocatable objects.  */
   if (abfd->flags & EXEC_P)
@@ -1938,8 +1935,6 @@ som_prep_headers (abfd)
       file_hdr->entry_offset = 0;
     }
   
-  /* FIXME.  I do not know if we ever need to put anything other
-     than zero in this field.  */
   file_hdr->presumed_dp = 0;
 
   /* Now iterate over the sections translating information from
@@ -2217,7 +2212,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
             stream.  */
          if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) != 0)
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
 
@@ -2248,15 +2243,15 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
                 then dump the current buffer contents now.  Also reinitialize
                 the relocation queue. 
 
-                FIXME.  We assume here that no BFD relocation will expand
-                to more than 100 bytes of SOM relocations.  This should (?!?)
-                be quite safe.  */
+                No single BFD relocation could ever translate into more
+                than 100 bytes of SOM relocations (20bytes is probably the
+                upper limit, but leave lots of space for growth).  */
              if (p - tmp_space + 100 > SOM_TMP_BUFSIZE)
                {
                  if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
                      != p - tmp_space)
                    {
-                     bfd_error = system_call_error;
+                     bfd_set_error (bfd_error_system_call);
                      return false;
                    }
                  p = tmp_space;
@@ -2426,7 +2421,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
          if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
              != p - tmp_space)
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
          p = tmp_space;
@@ -2463,7 +2458,7 @@ som_write_space_strings (abfd, current_offset, string_sizep)
      them out.  */
   if (bfd_seek (abfd, current_offset, SEEK_SET) != 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -2490,7 +2485,7 @@ som_write_space_strings (abfd, current_offset, string_sizep)
          if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
              != p - tmp_space) 
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
          /* Reset to beginning of the buffer space.  */
@@ -2527,7 +2522,7 @@ som_write_space_strings (abfd, current_offset, string_sizep)
      contained in a partial block.  */
   if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd) != p - tmp_space)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
   *string_sizep = strings_size;
@@ -2558,7 +2553,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep)
      them out.  */
   if (bfd_seek (abfd, current_offset, SEEK_SET) != 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -2573,7 +2568,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep)
          if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
              != p - tmp_space)
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
          /* Reset to beginning of the buffer space.  */
@@ -2608,7 +2603,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep)
   /* Scribble out any partial block.  */
   if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd) != p - tmp_space)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -2662,7 +2657,7 @@ som_begin_writing (abfd)
       current_offset += len;
       if (bfd_write ((PTR) obj_som_version_hdr (abfd), len, 1, abfd) != len)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
 
@@ -2673,7 +2668,7 @@ som_begin_writing (abfd)
       if (bfd_write ((PTR) obj_som_version_hdr (abfd)->user_string,
                     len, 1, abfd) != len)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
     }
@@ -2690,7 +2685,7 @@ som_begin_writing (abfd)
       current_offset += len;
       if (bfd_write ((PTR) obj_som_copyright_hdr (abfd), len, 1, abfd) != len)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
 
@@ -2701,7 +2696,7 @@ som_begin_writing (abfd)
       if (bfd_write ((PTR) obj_som_copyright_hdr (abfd)->copyright,
                     len, 1, abfd) != len)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
     }
@@ -2978,7 +2973,7 @@ som_write_headers (abfd)
                         sizeof (struct subspace_dictionary_record), 1, abfd)
              != sizeof (struct subspace_dictionary_record))
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
        }
@@ -3037,7 +3032,7 @@ som_write_headers (abfd)
                         sizeof (struct subspace_dictionary_record), 1, abfd)
              != sizeof (struct subspace_dictionary_record))
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
        }
@@ -3066,7 +3061,7 @@ som_write_headers (abfd)
                     sizeof (struct space_dictionary_record), 1, abfd)
          != sizeof (struct space_dictionary_record))
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
 
@@ -3081,7 +3076,7 @@ som_write_headers (abfd)
                 sizeof (struct header), 1, abfd)
       != sizeof (struct header))
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
   return true;
@@ -3195,7 +3190,8 @@ som_bfd_derive_misc_symbol_info (abfd, sym, info)
      for undefined or common symbols, but the HP linker will
      choke if it's not set to some "reasonable" value.  We
      use zero as a reasonable value.  */
-  if (sym->section == &bfd_com_section || sym->section == &bfd_und_section)
+  if (sym->section == &bfd_com_section || sym->section == &bfd_und_section
+      || sym->section == &bfd_abs_section)
     info->symbol_info = 0;
   /* For all other symbols, the symbol_info field contains the 
      subspace index of the space this symbol is contained in.  */
@@ -3250,13 +3246,13 @@ som_build_and_write_symbol_table (abfd)
      scribble out the symbol table.  */
   if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
   if (bfd_write ((PTR) som_symtab, symtab_size, 1, abfd) != symtab_size)
     {
-      bfd_error  = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
   return true; 
@@ -3307,20 +3303,20 @@ som_slurp_string_table (abfd)
   stringtab = bfd_zalloc (abfd, obj_som_stringtab_size (abfd));
   if (stringtab == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
   if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
   
   if (bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd)
       != obj_som_stringtab_size (abfd))
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -3339,7 +3335,7 @@ som_get_symtab_upper_bound (abfd)
   if (!som_slurp_symbol_table (abfd))
     return 0;
 
-  return (bfd_get_symcount (abfd) + 1) * (sizeof (som_symbol_type *));
+  return (bfd_get_symcount (abfd) + 1) * (sizeof (asymbol *));
 }
 
 /* Convert from a SOM subspace index to a BFD section.  */
@@ -3375,13 +3371,9 @@ som_slurp_symbol_table (abfd)
   if (obj_som_symtab (abfd) != NULL)
     return true;
 
-  /* Sanity checking.  Make sure there are some symbols and that 
-     we can read the string table too.  */
+  /* Special case.  This is *not* an error.  */
   if (symbol_count == 0)
-    {
-      bfd_error = no_symbols;
-      return false;
-    }
+    return true;
 
   if (!som_slurp_string_table (abfd))
     return false;
@@ -3392,7 +3384,7 @@ som_slurp_symbol_table (abfd)
     bfd_zalloc (abfd, symbol_count * sizeof (som_symbol_type));
   if (symbase == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -3400,18 +3392,18 @@ som_slurp_symbol_table (abfd)
   buf = alloca (symbol_count * symsize);
   if (buf == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) < 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
   if (bfd_read (buf, symbol_count * symsize, 1, abfd) 
       != symbol_count * symsize)
     {
-      bfd_error = no_symbols;
+      bfd_set_error (bfd_error_no_symbols);
       return (false);
     }
 
@@ -3559,7 +3551,7 @@ som_make_empty_symbol (abfd)
   (som_symbol_type *) bfd_zalloc (abfd, sizeof (som_symbol_type));
   if (new == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return 0;
     }
   new->symbol.the_bfd = abfd;
@@ -3861,7 +3853,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
       external_relocs = (char *) bfd_zalloc (abfd, fixup_stream_size);
       if (external_relocs == (char *) NULL)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return false;
        }
       /* Read in the external forms. */
@@ -3870,13 +3862,13 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
                    SEEK_SET)
          != 0)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
       if (bfd_read (external_relocs, 1, fixup_stream_size, abfd)
          != fixup_stream_size)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
       /* Let callers know how many relocations found.
@@ -3903,7 +3895,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
                                            num_relocs * sizeof (arelent));
   if (internal_relocs == (arelent *) NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -3977,7 +3969,7 @@ som_new_section_hook (abfd, newsect)
     (PTR) bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
   if (!newsect->used_by_bfd)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   newsect->alignment_power = 3;
@@ -4078,7 +4070,7 @@ bfd_som_attach_aux_hdr (abfd, type, string)
                              + sizeof (unsigned int) + len + pad);
       if (!obj_som_version_hdr (abfd))
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          abort();              /* FIXME */
        }
       obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
@@ -4099,7 +4091,7 @@ bfd_som_attach_aux_hdr (abfd, type, string)
                            + sizeof (unsigned int) + len + pad);
       if (!obj_som_copyright_hdr (abfd))
        {
-         bfd_error = no_error;
+         bfd_set_error (bfd_error_no_error);
          abort();              /* FIXME */
        }
       obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
@@ -4142,13 +4134,13 @@ som_set_section_contents (abfd, section, location, offset, count)
   offset += som_section_data (section)->subspace_dict.file_loc_init_value; 
   if (bfd_seek (abfd, offset, SEEK_SET) == -1)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
   if (bfd_write ((PTR) location, 1, count, abfd) != count)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
   return true;
@@ -4259,7 +4251,8 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
      symindex *count;
 {
   unsigned int i;
-  unsigned int hash_table[lst_header->hash_size];
+  unsigned int *hash_table =
+    (unsigned int *) alloca (lst_header->hash_size * sizeof (unsigned int));
   file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
 
   /* Don't forget to initialize the counter!  */
@@ -4270,7 +4263,7 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
   if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
       != lst_header->hash_size * 4)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4287,7 +4280,7 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
       /* Seek to the first symbol in this hash chain.  */
       if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
 
@@ -4295,7 +4288,7 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
       if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
          != sizeof (lst_symbol))
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
       (*count)++;
@@ -4308,7 +4301,7 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
          if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
              < 0)
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
 
@@ -4316,7 +4309,7 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
          if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
              != sizeof (lst_symbol))
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
          (*count)++;
@@ -4336,8 +4329,11 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
 {
   unsigned int i, len;
   carsym *set = syms[0];
-  unsigned int hash_table[lst_header->hash_size];
-  struct som_entry som_dict[lst_header->module_count];
+  unsigned int *hash_table =
+    (unsigned int *) alloca (lst_header->hash_size * sizeof (unsigned int));
+  struct som_entry *som_dict =
+    (struct som_entry *) alloca (lst_header->module_count
+                                * sizeof (struct som_entry));
   file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
 
   /* Read in the hash table.  The has table is an array of 32bit file offsets
@@ -4345,7 +4341,7 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
   if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
       != lst_header->hash_size * 4)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4353,7 +4349,7 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
      in the carsym's filepos field.  */
   if (bfd_seek (abfd, lst_filepos + lst_header->dir_loc, SEEK_SET) < 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4361,7 +4357,7 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
                sizeof (struct som_entry), abfd)
       != lst_header->module_count * sizeof (struct som_entry))
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4377,14 +4373,14 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
       /* Seek to and read the first symbol on the chain.  */
       if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
 
       if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
          != sizeof (lst_symbol))
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
 
@@ -4398,13 +4394,13 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
       if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
                            + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
 
       if (bfd_read (&len, 1, 4, abfd) != 4)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
 
@@ -4412,12 +4408,12 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
       set->name = bfd_zalloc (abfd, len + 1);
       if (!set->name)
        {
-         bfd_error = no_memory;
+         bfd_set_error (bfd_error_no_memory);
          return false;
        }
       if (bfd_read (set->name, 1, len, abfd) != len)
        {
-         bfd_error = system_call_error;
+         bfd_set_error (bfd_error_system_call);
          return false;
        }
       set->name[len] = 0;
@@ -4437,14 +4433,14 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
          if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
              < 0)
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
 
          if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
              != sizeof (lst_symbol))
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
 
@@ -4452,13 +4448,13 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
          if (bfd_seek (abfd, lst_filepos + lst_header->string_loc 
                                + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
 
          if (bfd_read (&len, 1, 4, abfd) != 4)
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
 
@@ -4466,12 +4462,12 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
          set->name = bfd_zalloc (abfd, len + 1);
          if (!set->name)
            {
-             bfd_error = no_memory;
+             bfd_set_error (bfd_error_no_memory);
              return false;
            }
          if (bfd_read (set->name, 1, len, abfd) != len)
            {
-             bfd_error = system_call_error;
+             bfd_set_error (bfd_error_system_call);
              return false;
            }
          set->name[len] = 0;
@@ -4510,7 +4506,7 @@ som_slurp_armap (abfd)
 
   if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) < 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4525,13 +4521,13 @@ som_slurp_armap (abfd)
   if (bfd_read ((PTR) &ar_header, 1, sizeof (struct ar_hdr), abfd)
       != sizeof (struct ar_hdr))
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
   if (strncmp (ar_header.ar_fmag, ARFMAG, 2))
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
       return NULL;
     }
 
@@ -4540,7 +4536,7 @@ som_slurp_armap (abfd)
   parsed_size = strtol (ar_header.ar_size, NULL, 10);
   if (errno != 0)
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
       return NULL;
     }
 
@@ -4552,14 +4548,14 @@ som_slurp_armap (abfd)
   if (bfd_read ((PTR) & lst_header, 1, sizeof (struct lst_header), abfd)
       != sizeof (struct lst_header))
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
   /* Sanity check.  */
   if (lst_header.a_magic != LIBMAGIC)
     {
-      bfd_error = malformed_archive;
+      bfd_set_error (bfd_error_malformed_archive);
       return NULL;
     }
 
@@ -4572,7 +4568,7 @@ som_slurp_armap (abfd)
   if (bfd_seek (abfd, ardata->first_file_filepos - parsed_size 
                        + sizeof (struct lst_header), SEEK_SET) < 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4583,7 +4579,7 @@ som_slurp_armap (abfd)
                                           * sizeof (carsym)));
   if (!ardata->symdefs)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -4617,7 +4613,7 @@ som_bfd_prep_for_ar_write (abfd, num_syms, stringsize)
   while (curr_bfd != NULL)
     {
       unsigned int curr_count, i;
-      asymbol *sym;
+      som_symbol_type *sym;
 
       /* Make sure the symbol table has been read, then snag a pointer
         to it.  It's a little slimey to grab the symbols via obj_som_symtab,
@@ -4625,7 +4621,7 @@ som_bfd_prep_for_ar_write (abfd, num_syms, stringsize)
       if (som_slurp_symbol_table (curr_bfd) == false)
        return false;
 
-      sym = (asymbol *)obj_som_symtab (curr_bfd);
+      sym = obj_som_symtab (curr_bfd);
       curr_count = bfd_get_symcount (curr_bfd);
 
       /* Examine each symbol to determine if it belongs in the
@@ -4635,7 +4631,7 @@ som_bfd_prep_for_ar_write (abfd, num_syms, stringsize)
          struct som_misc_symbol_info info;
 
          /* Derive SOM information from the BFD symbol.  */
-         som_bfd_derive_misc_symbol_info (curr_bfd, sym, &info);
+         som_bfd_derive_misc_symbol_info (curr_bfd, &sym->symbol, &info);
 
          /* Should we include this symbol?  */
          if (info.symbol_type == ST_NULL
@@ -4649,13 +4645,13 @@ som_bfd_prep_for_ar_write (abfd, num_syms, stringsize)
            continue;
 
          /* Do no include undefined symbols.  */
-         if (sym->section == &bfd_und_section)
+         if (sym->symbol.section == &bfd_und_section)
            continue;
 
          /* Bump the various counters, being careful to honor
             alignment considerations in the string table.  */
          (*num_syms)++;
-         *stringsize = *stringsize + strlen (sym->name) + 5;
+         *stringsize = *stringsize + strlen (sym->symbol.name) + 5;
          while (*stringsize % 4)
            (*stringsize)++;
        }
@@ -4694,9 +4690,14 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
   char *strings, *p;
   struct lst_symbol_record *lst_syms, *curr_lst_sym;
   bfd *curr_bfd = abfd->archive_head;
-  unsigned int hash_table[lst.hash_size];
-  struct som_entry som_dict[lst.module_count];
-  struct lst_symbol_record *last_hash_entry[lst.hash_size];
+  unsigned int *hash_table =
+    (unsigned int *) alloca (lst.hash_size * sizeof (unsigned int));
+  struct som_entry *som_dict =
+    (struct som_entry *) alloca (lst.module_count
+                                * sizeof (struct som_entry));
+  struct lst_symbol_record **last_hash_entry =
+    ((struct lst_symbol_record **)
+     alloca (lst.hash_size * sizeof (struct lst_symbol_record *)));
   unsigned int curr_som_offset, som_index;
 
   /* Lots of fields are file positions relative to the start
@@ -4729,7 +4730,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
   while (curr_bfd != NULL)
     {
       unsigned int curr_count, i;
-      asymbol *sym;
+      som_symbol_type *sym;
 
       /* Make sure the symbol table has been read, then snag a pointer
         to it.  It's a little slimey to grab the symbols via obj_som_symtab,
@@ -4737,7 +4738,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
       if (som_slurp_symbol_table (curr_bfd) == false)
        return false;
 
-      sym = (asymbol *)obj_som_symtab (curr_bfd);
+      sym = obj_som_symtab (curr_bfd);
       curr_count = bfd_get_symcount (curr_bfd);
 
       for (i = 0; i < curr_count; i++, sym++)
@@ -4745,7 +4746,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
          struct som_misc_symbol_info info;
 
          /* Derive SOM information from the BFD symbol.  */
-         som_bfd_derive_misc_symbol_info (curr_bfd, sym, &info);
+         som_bfd_derive_misc_symbol_info (curr_bfd, &sym->symbol, &info);
 
          /* Should we include this symbol?  */
          if (info.symbol_type == ST_NULL
@@ -4759,7 +4760,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
            continue;
 
          /* Do no include undefined symbols.  */
-         if (sym->section == &bfd_und_section)
+         if (sym->symbol.section == &bfd_und_section)
            continue;
 
          /* If this is the first symbol from this SOM, then update
@@ -4779,7 +4780,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
          curr_lst_sym->must_qualify = 0;
          curr_lst_sym->initially_frozen = 0;
          curr_lst_sym->memory_resident = 0;
-         curr_lst_sym->is_common = (sym->section == &bfd_com_section);
+         curr_lst_sym->is_common = (sym->symbol.section == &bfd_com_section);
          curr_lst_sym->dup_common = 0;
          curr_lst_sym->xleast = 0;
          curr_lst_sym->arg_reloc = info.arg_reloc;
@@ -4790,7 +4791,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
          curr_lst_sym->symbol_descriptor = 0;
          curr_lst_sym->reserved = 0;
          curr_lst_sym->som_index = som_index;
-         curr_lst_sym->symbol_key = som_bfd_ar_symbol_hash (sym);
+         curr_lst_sym->symbol_key = som_bfd_ar_symbol_hash (&sym->symbol);
          curr_lst_sym->next_entry = 0;
 
          /* Insert into the hash table.  */
@@ -4824,10 +4825,10 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
 
 
          /* Update the string table.  */
-         bfd_put_32 (abfd, strlen (sym->name), p);
+         bfd_put_32 (abfd, strlen (sym->symbol.name), p);
          p += 4;
-         strcpy (p, sym->name);
-         p += strlen (sym->name) + 1;
+         strcpy (p, sym->symbol.name);
+         p += strlen (sym->symbol.name) + 1;
          while ((int)p % 4)
            {
              bfd_put_8 (abfd, 0, p);
@@ -4849,7 +4850,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
   if (bfd_write ((PTR) hash_table, lst.hash_size, 4, abfd)
       != lst.hash_size * 4)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4858,7 +4859,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
                 sizeof (struct som_entry), abfd)
       != lst.module_count * sizeof (struct som_entry))
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4866,14 +4867,14 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
   if (bfd_write ((PTR) lst_syms, nsyms, sizeof (struct lst_symbol_record), abfd)
       != nsyms * sizeof (struct lst_symbol_record))
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
   /* And finally the strings.  */
   if (bfd_write ((PTR) strings, string_size, 1, abfd) != string_size)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4898,7 +4899,7 @@ som_write_armap (abfd)
   /* We'll use this for the archive's date and mode later.  */
   if (stat (abfd->filename, &statbuf) != 0)
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
   /* Fudge factor.  */
@@ -4984,7 +4985,7 @@ som_write_armap (abfd)
   if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
       != sizeof (struct ar_hdr))
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
@@ -4992,7 +4993,7 @@ som_write_armap (abfd)
   if (bfd_write ((PTR) &lst, 1, sizeof (struct lst_header), abfd)
       != sizeof (struct lst_header))
     {
-      bfd_error = system_call_error;
+      bfd_set_error (bfd_error_system_call);
       return false;
     }
 
This page took 0.037868 seconds and 4 git commands to generate.