daily update
[deliverable/binutils-gdb.git] / bfd / som.c
index 0ea13532546743c03ebf0ec103617b388b86bb30..cf4af77229ed76133f98471d53690b02e3084704 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
 
 #include "libbfd.h"
 #include "som.h"
+#include "safe-ctype.h"
 
 #include <sys/param.h>
 #include <signal.h>
 #include <machine/reg.h>
 #include <sys/file.h>
-#include <ctype.h>
 
 /* Magic not defined in standard HP-UX header files until 8.0 */
 
@@ -1814,6 +1814,8 @@ som_object_setup (abfd, file_hdrp, aux_hdrp, current_offset)
       obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_flags;
     }
 
+  obj_som_exec_data (abfd)->version_id = file_hdrp->version_id;
+
   bfd_default_set_arch_mach (abfd, bfd_arch_hppa, pa10);
   bfd_get_symcount (abfd) = file_hdrp->symbol_total;
 
@@ -1849,7 +1851,8 @@ setup_sections (abfd, file_hdr, current_offset)
   char *space_strings;
   unsigned int space_index, i;
   unsigned int total_subspaces = 0;
-  asection **subspace_sections, *section;
+  asection **subspace_sections = NULL;
+  asection *section;
   bfd_size_type amt;
 
   /* First, read in space names.  */
@@ -2320,9 +2323,6 @@ som_prep_headers (abfd)
   else
     file_hdr->a_magic = RELOC_MAGIC;
 
-  /* Only new format SOM is supported.  */
-  file_hdr->version_id = NEW_VERSION_ID;
-
   /* These fields are optional, and embedding timestamps is not always
      a wise thing to do, it makes comparing objects during a multi-stage
      bootstrap difficult.  */
@@ -2961,7 +2961,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
                  break;
 
                case R_END_TRY:
-                 /* The end of a exception handling region.  The reloc's
+                 /* The end of an exception handling region.  The reloc's
                     addend contains the offset of the exception handling
                     code.  */
                  if (bfd_reloc->addend == 0)
@@ -3155,7 +3155,7 @@ static boolean
 som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
                          compilation_unit)
      bfd *abfd;
-     file_ptr current_offset;
+     unsigned long current_offset;
      asymbol **syms;
      unsigned int num_syms;
      unsigned int *string_sizep;
@@ -3189,7 +3189,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
 
   /* Seek to the start of the space strings in preparation for writing
      them out.  */
-  if (bfd_seek (abfd, current_offset, SEEK_SET) != 0)
+  if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0)
     return false;
 
   if (compilation_unit)
@@ -3688,6 +3688,14 @@ som_finish_writing (abfd)
   unsigned int total_reloc_size;
   bfd_size_type amt;
 
+  /* We must set up the version identifier here as objcopy/strip copy
+     private BFD data too late for us to handle this in som_begin_writing.  */
+  if (obj_som_exec_data (abfd)
+      && obj_som_exec_data (abfd)->version_id)
+    obj_som_file_hdr (abfd)->version_id = obj_som_exec_data (abfd)->version_id;
+  else
+    obj_som_file_hdr (abfd)->version_id = NEW_VERSION_ID;
+
   /* Next is the symbol table.  These are fixed length records.
 
      Count the number of symbols to determine how much room is needed
@@ -4672,13 +4680,13 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count)
              c = *cp++;
 
              /* If this is a variable, push it on the stack.  */
-             if (isupper (c))
+             if (ISUPPER (c))
                push (var (c));
 
              /* If this is a lower case letter, then it represents
                 additional data from the fixup stream to be pushed onto
                 the stack.  */
-             else if (islower (c))
+             else if (ISLOWER (c))
                {
                  int bits = (c - 'a') * 8;
                  for (v = 0; c > 'a'; --c)
@@ -4689,10 +4697,10 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count)
                }
 
              /* A decimal constant.  Push it on the stack.  */
-             else if (isdigit (c))
+             else if (ISDIGIT (c))
                {
                  v = c - '0';
-                 while (isdigit (*cp))
+                 while (ISDIGIT (*cp))
                    v = (v * 10) + (*cp++ - '0');
                  push (v);
                }
@@ -5438,7 +5446,7 @@ som_decode_symclass (symbol)
   else
     return '?';
   if (symbol->flags & BSF_GLOBAL)
-    c = toupper (c);
+    c = TOUPPER (c);
   return c;
 }
 
This page took 0.027153 seconds and 4 git commands to generate.