* dw2gencfi.c (cfi_pseudo_table): Add cfi_gnu_window_save.
[binutils-gdb.git] / gas / config / obj-vms.c
index 0f08f8eb3f323ed42bdd6e755e7390c0cbadf5e1..91498925b358af0a0c840fa3460a0ccadfc18747 100644 (file)
@@ -1,5 +1,6 @@
 /* vms.c -- Write out a VAX/VMS object file
-   Copyright (C) 1987, 88, 92, 94, 95, 97, 1998 Free Software Foundation, Inc.
+   Copyright 1987, 1988, 1992, 1993, 1994, 1995, 1997, 1998, 2000, 2001, 2002
+   Free Software Foundation, Inc.
 
 This file is part of GAS, the GNU Assembler.
 
@@ -27,13 +28,15 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include "as.h"
 #include "config.h"
+#include "safe-ctype.h"
 #include "subsegs.h"
 #include "obstack.h"
+#include <fcntl.h>
 
-/* What we do if there is a goof. */
+/* What we do if there is a goof.  */
 #define error as_fatal
 
-#ifdef VMS                     /* These are of no use if we are cross assembling. */
+#ifdef VMS                     /* These are of no use if we are cross assembling.  */
 #include <fab.h>               /* Define File Access Block       */
 #include <nam.h>               /* Define NAM Block               */
 #include <xab.h>               /* Define XAB - all different types*/
@@ -102,7 +105,6 @@ struct input_file
 
 static struct input_file *file_root = (struct input_file *) NULL;
 
-
 /*
  * Styles of PSECTS (program sections) that we generate; just shorthand
  * to avoid lists of section attributes.  Used by VMS_Psect_Spec().
@@ -154,7 +156,7 @@ struct VMS_DBG_Symbol
 };
 
 #define SYMTYPLST_SIZE (1<<4)  /* 16; must be power of two */
-#define SYMTYP_HASH(x) ((unsigned)(x) & (SYMTYPLST_SIZE-1))
+#define SYMTYP_HASH(x) ((unsigned) (x) & (SYMTYPLST_SIZE-1))
 struct VMS_DBG_Symbol *VMS_Symbol_type_list[SYMTYPLST_SIZE];
 
 /*
@@ -192,7 +194,7 @@ static const char *symbol_name;
  * whole thing each time.
  */
 
-static structure_count = 0;
+static int structure_count = 0;
 
 /* This variable is used to indicate that we are making the last attempt to
    parse the stabs, and that we should define as much as we can, and ignore
@@ -253,24 +255,23 @@ static int total_len;             /* used to calculate the total length of variable
                                descriptor plus array descriptor - used for len byte*/
 
 /* Flag if we have told user about finding global constants in the text
-   section. */
+   section.  */
 static int gave_compiler_message = 0;
 
-
 /*
  *     Global data (Object records limited to 512 bytes by VAX-11 "C" runtime)
  */
-static int VMS_Object_File_FD; /* File Descriptor for object file */
+static int VMS_Object_File_FD;         /* File Descriptor for object file */
 static char Object_Record_Buffer[512]; /* Buffer for object file records  */
-static int Object_Record_Offset;/* Offset to end of data          */
+static size_t Object_Record_Offset;    /* Offset to end of data           */
 static int Current_Object_Record_Type; /* Type of record in above         */
 
 /*
  *     Macros for moving data around.  Must work on big-endian systems.
  */
 #ifdef VMS  /* These are more efficient for VMS->VMS systems */
-#define COPY_LONG(dest,val)    ( *(long *)(dest) = (val) )
-#define COPY_SHORT(dest,val)   ( *(short *)(dest) = (val) )
+#define COPY_LONG(dest,val)    ( *(long *) (dest) = (val) )
+#define COPY_SHORT(dest,val)   ( *(short *) (dest) = (val) )
 #else
 #define COPY_LONG(dest,val)    md_number_to_chars ((dest), (val), 4)
 #define COPY_SHORT(dest,val)   md_number_to_chars ((dest), (val), 2)
@@ -344,84 +345,150 @@ const segT N_TYPE_seg[N_TYPE + 2] =
 
 /* Local support routines which return a value.  */
 
-static struct input_file *find_file PARAMS ((symbolS *));
-static struct VMS_DBG_Symbol *find_symbol PARAMS ((int));
-static symbolS *Define_Routine PARAMS ((symbolS *,int,symbolS *,int));
-
-static char *cvt_integer PARAMS ((char *,int *));
-static char *fix_name PARAMS ((char *));
-static char *get_struct_name PARAMS ((char *));
-
-static offsetT VMS_Initialized_Data_Size PARAMS ((symbolS *,unsigned));
-
-static int VMS_TBT_Source_File PARAMS ((char *,int));
-static int gen1 PARAMS ((struct VMS_DBG_Symbol *,int));
-static int forward_reference PARAMS ((char *));
-static int final_forward_reference PARAMS ((struct VMS_DBG_Symbol *));
-static int VMS_typedef_parse PARAMS ((char *));
-static int hash_string PARAMS ((const char *));
-static int VMS_Psect_Spec PARAMS ((const char *,int,enum ps_type,
-                                  struct VMS_Symbol *));
+static struct input_file *find_file
+  PARAMS ((symbolS *));
+static struct VMS_DBG_Symbol *find_symbol
+  PARAMS ((int));
+static symbolS *Define_Routine
+  PARAMS ((symbolS *, int, symbolS *, int));
+
+static char *cvt_integer
+  PARAMS ((char *, int *));
+static char *fix_name
+  PARAMS ((char *));
+static char *get_struct_name
+  PARAMS ((char *));
+
+static offsetT VMS_Initialized_Data_Size
+  PARAMS ((symbolS *, unsigned));
+
+static int VMS_TBT_Source_File
+  PARAMS ((char *, int));
+static int gen1
+  PARAMS ((struct VMS_DBG_Symbol *, int));
+static int forward_reference
+  PARAMS ((char *));
+static int final_forward_reference
+  PARAMS ((struct VMS_DBG_Symbol *));
+static int VMS_typedef_parse
+  PARAMS ((char *));
+static int hash_string
+  PARAMS ((const char *));
+static int VMS_Psect_Spec
+  PARAMS ((const char *, int, enum ps_type, struct VMS_Symbol *));
 
 /* Local support routines which don't directly return any value.  */
 
-static void s_const PARAMS ((int));
-static void Create_VMS_Object_File PARAMS ((void));
-static void Flush_VMS_Object_Record_Buffer PARAMS ((void));
-static void Set_VMS_Object_File_Record PARAMS ((int));
-static void Close_VMS_Object_File PARAMS ((void));
-static void vms_tir_stack_psect PARAMS ((int,int,int));
-static void VMS_Store_Immediate_Data PARAMS ((const char *,int,int));
-static void VMS_Set_Data PARAMS ((int,int,int,int));
-static void VMS_Store_Struct PARAMS ((int));
-static void VMS_Def_Struct PARAMS ((int));
-static void VMS_Set_Struct PARAMS ((int));
-static void VMS_TBT_Module_Begin PARAMS ((void));
-static void VMS_TBT_Module_End PARAMS ((void));
-static void VMS_TBT_Routine_Begin PARAMS ((symbolS *,int));
-static void VMS_TBT_Routine_End PARAMS ((int,symbolS *));
-static void VMS_TBT_Block_Begin PARAMS ((symbolS *,int,char *));
-static void VMS_TBT_Block_End PARAMS ((valueT));
-static void VMS_TBT_Line_PC_Correlation PARAMS ((int,int,int,int));
-static void VMS_TBT_Source_Lines PARAMS ((int,int,int));
-static void fpush PARAMS ((int,int));
-static void rpush PARAMS ((int,int));
-static void array_suffix PARAMS ((struct VMS_DBG_Symbol *));
-static void new_forward_ref PARAMS ((int));
-static void generate_suffix PARAMS ((struct VMS_DBG_Symbol *,int));
-static void bitfield_suffix PARAMS ((struct VMS_DBG_Symbol *,int));
-static void setup_basic_type PARAMS ((struct VMS_DBG_Symbol *));
-static void VMS_DBG_record PARAMS ((struct VMS_DBG_Symbol *,int,int,char *));
-static void VMS_local_stab_Parse PARAMS ((symbolS *));
-static void VMS_stab_parse PARAMS ((symbolS *,int,int,int,int));
-static void VMS_GSYM_Parse PARAMS ((symbolS *,int));
-static void VMS_LCSYM_Parse PARAMS ((symbolS *,int));
-static void VMS_STSYM_Parse PARAMS ((symbolS *,int));
-static void VMS_RSYM_Parse PARAMS ((symbolS *,symbolS *,int));
-static void VMS_LSYM_Parse PARAMS ((void));
-static void Define_Local_Symbols PARAMS ((symbolS *,symbolS *,symbolS *,int));
-static void Write_VMS_MHD_Records PARAMS ((void));
-static void Write_VMS_EOM_Record PARAMS ((int,valueT));
-static void VMS_Case_Hack_Symbol PARAMS ((const char *,char *));
-static void VMS_Modify_Psect_Attributes PARAMS ((const char *,int *));
-static void VMS_Global_Symbol_Spec PARAMS ((const char *,int,int,int));
-static void VMS_Local_Environment_Setup PARAMS ((const char *));
-static void VMS_Emit_Globalvalues PARAMS ((unsigned,unsigned,char *));
-static void VMS_Procedure_Entry_Pt PARAMS ((char *,int,int,int));
-static void VMS_Set_Psect PARAMS ((int,int,int));
-static void VMS_Store_Repeated_Data PARAMS ((int,char *,int,int));
-static void VMS_Store_PIC_Symbol_Reference PARAMS ((symbolS *,int,
-                                                   int,int,int,int));
-static void VMS_Fix_Indirect_Reference PARAMS ((int,int,fragS *,fragS *));
+static void s_const
+  PARAMS ((int));
+static void Create_VMS_Object_File
+  PARAMS ((void));
+static void Flush_VMS_Object_Record_Buffer
+  PARAMS ((void));
+static void Set_VMS_Object_File_Record
+  PARAMS ((int));
+static void Close_VMS_Object_File
+  PARAMS ((void));
+static void vms_tir_stack_psect
+  PARAMS ((int, int, int));
+static void VMS_Store_Immediate_Data
+  PARAMS ((const char *, int, int));
+static void VMS_Set_Data
+  PARAMS ((int, int, int, int));
+static void VMS_Store_Struct
+  PARAMS ((int));
+static void VMS_Def_Struct
+  PARAMS ((int));
+static void VMS_Set_Struct
+  PARAMS ((int));
+static void VMS_TBT_Module_Begin
+  PARAMS ((void));
+static void VMS_TBT_Module_End
+  PARAMS ((void));
+static void VMS_TBT_Routine_Begin
+  PARAMS ((symbolS *, int));
+static void VMS_TBT_Routine_End
+  PARAMS ((int, symbolS *));
+static void VMS_TBT_Block_Begin
+  PARAMS ((symbolS *, int, char *));
+static void VMS_TBT_Block_End
+  PARAMS ((valueT));
+static void VMS_TBT_Line_PC_Correlation
+  PARAMS ((int, int, int, int));
+static void VMS_TBT_Source_Lines
+  PARAMS ((int, int, int));
+static void fpush
+  PARAMS ((int, int));
+static void rpush
+  PARAMS ((int, int));
+static void array_suffix
+  PARAMS ((struct VMS_DBG_Symbol *));
+static void new_forward_ref
+  PARAMS ((int));
+static void generate_suffix
+  PARAMS ((struct VMS_DBG_Symbol *, int));
+static void bitfield_suffix
+  PARAMS ((struct VMS_DBG_Symbol *, int));
+static void setup_basic_type
+  PARAMS ((struct VMS_DBG_Symbol *));
+static void VMS_DBG_record
+  PARAMS ((struct VMS_DBG_Symbol *, int, int, char *));
+static void VMS_local_stab_Parse
+  PARAMS ((symbolS *));
+static void VMS_stab_parse
+  PARAMS ((symbolS *, int, int, int, int));
+static void VMS_GSYM_Parse
+  PARAMS ((symbolS *, int));
+static void VMS_LCSYM_Parse
+  PARAMS ((symbolS *, int));
+static void VMS_STSYM_Parse
+  PARAMS ((symbolS *, int));
+static void VMS_RSYM_Parse
+  PARAMS ((symbolS *, symbolS *, int));
+static void VMS_LSYM_Parse
+  PARAMS ((void));
+static void Define_Local_Symbols
+  PARAMS ((symbolS *, symbolS *, symbolS *, int));
+static void Write_VMS_MHD_Records
+  PARAMS ((void));
+static void Write_VMS_EOM_Record
+  PARAMS ((int, valueT));
+static void VMS_Case_Hack_Symbol
+  PARAMS ((const char *, char *));
+static void VMS_Modify_Psect_Attributes
+  PARAMS ((const char *, int *));
+static void VMS_Global_Symbol_Spec
+  PARAMS ((const char *, int, int, int));
+static void VMS_Local_Environment_Setup
+  PARAMS ((const char *));
+static void VMS_Emit_Globalvalues
+  PARAMS ((unsigned, unsigned, char *));
+static void VMS_Procedure_Entry_Pt
+  PARAMS ((char *, int, int, int));
+static void VMS_Set_Psect
+  PARAMS ((int, int, int));
+static void VMS_Store_Repeated_Data
+  PARAMS ((int, char *, int, int));
+static void VMS_Store_PIC_Symbol_Reference
+  PARAMS ((symbolS *, int, int, int, int, int));
+static void VMS_Fix_Indirect_Reference
+  PARAMS ((int, addressT, fragS *, fragS *));
 
 /* Support code which used to be inline within vms_write_object_file.  */
-static void vms_fixup_text_section PARAMS ((unsigned,struct frag *,struct frag *));
-static void synthesize_data_segment PARAMS ((unsigned,unsigned,struct frag *));
-static void vms_fixup_data_section PARAMS ((unsigned,unsigned));
-static void global_symbol_directory PARAMS ((unsigned,unsigned));
-static void local_symbols_DST PARAMS ((symbolS *,symbolS *));
-static void vms_build_DST PARAMS ((unsigned));
-static void vms_fixup_xtors_section PARAMS ((struct VMS_Symbol *, int));
+static void vms_fixup_text_section
+  PARAMS ((unsigned, struct frag *, struct frag *));
+static void synthesize_data_segment
+  PARAMS ((unsigned, unsigned, struct frag *));
+static void vms_fixup_data_section
+  PARAMS ((unsigned, unsigned));
+static void global_symbol_directory
+  PARAMS ((unsigned, unsigned));
+static void local_symbols_DST
+  PARAMS ((symbolS *, symbolS *));
+static void vms_build_DST
+  PARAMS ((unsigned));
+static void vms_fixup_xtors_section
+  PARAMS ((struct VMS_Symbol *, int));
 \f
 
 /* The following code defines the special types of pseudo-ops that we
@@ -447,7 +514,6 @@ const pseudo_typeS obj_pseudo_table[] =
   {0, 0, 0},
 };                             /* obj_pseudo_table */
 
-
 /* Routine to perform RESOLVE_SYMBOL_REDEFINITION().  */
 
 int
@@ -484,7 +550,6 @@ vms_resolve_symbol_redef (sym)
   return 0;
 }
 
-
 /* `tc_frob_label' handler for colon(symbols.c), used to examine the
    dummy label(s) gcc inserts at the beginning of each file it generates.
    gcc 1.x put "gcc_compiled."; gcc 2.x (as of 2.7) puts "gcc2_compiled."
@@ -518,14 +583,12 @@ symbolS *symbolP;
   return;
 }
 
-
 void
 obj_read_begin_hook ()
 {
   return;
 }
 
-
 void
 obj_crawl_symbol_chain (headers)
      object_headers *headers;
@@ -534,10 +597,10 @@ obj_crawl_symbol_chain (headers)
   symbolS **symbolPP;
   int symbol_number = 0;
 
-  symbolPP = &symbol_rootP;    /* -> last symbol chain link. */
+  symbolPP = &symbol_rootP;    /* -> last symbol chain link.  */
   while ((symbolP = *symbolPP) != NULL)
     {
-      resolve_symbol_value (symbolP, 1);
+      resolve_symbol_value (symbolP);
 
      /* OK, here is how we decide which symbols go out into the
        brave new symtab.  Symbols that do are:
@@ -557,14 +620,14 @@ obj_crawl_symbol_chain (headers)
        {
          symbolP->sy_number = symbol_number++;
          symbolP->sy_name_offset = 0;
-         symbolPP = &(symbol_next (symbolP));
+         symbolPP = &symbolP->sy_next;
        }
       else
        {
          if (S_IS_EXTERNAL (symbolP) || !S_IS_DEFINED (symbolP))
            {
              as_bad (_("Local symbol %s never defined"), S_GET_NAME (symbolP));
-           }                   /* oops. */
+           }                   /* oops.  */
 
          /* Unhook it from the chain.  */
          *symbolPP = symbol_next (symbolP);
@@ -579,19 +642,22 @@ obj_crawl_symbol_chain (headers)
 
  /****** VMS OBJECT FILE HACKING ROUTINES *******/
 
-
 /* Create the VMS object file.  */
 
 static void
 Create_VMS_Object_File ()
 {
-#if    defined(eunice) || !defined(VMS)
+#ifdef eunice
   VMS_Object_File_FD = creat (out_file_name, 0777, "var");
-#else  /* eunice */
+#else
+#ifndef VMS
+  VMS_Object_File_FD = creat (out_file_name, 0777);
+#else  /* VMS */
   VMS_Object_File_FD = creat (out_file_name, 0, "rfm=var",
                              "ctx=bin", "mbc=16", "deq=64", "fop=tef",
                              "shr=nil");
-#endif /* eunice */
+#endif /* !VMS */
+#endif /* !eunice */
   /* Deal with errors.  */
   if (VMS_Object_File_FD < 0)
     as_fatal (_("Couldn't create VMS object file \"%s\""), out_file_name);
@@ -600,7 +666,6 @@ Create_VMS_Object_File ()
   Current_Object_Record_Type = -1;
 }
 
-
 /* Flush the object record buffer to the object file.  */
 
 static void
@@ -610,7 +675,7 @@ Flush_VMS_Object_Record_Buffer ()
   if (Object_Record_Offset == 0)
     return;
 
-#ifndef VMS                    /* For cross-assembly purposes. */
+#ifndef VMS                    /* For cross-assembly purposes.  */
   {
     char RecLen[2];
 
@@ -632,15 +697,14 @@ Flush_VMS_Object_Record_Buffer ()
 #endif /* not VMS */
 
   /* Write the data to the file.  */
-  if (write (VMS_Object_File_FD, Object_Record_Buffer, Object_Record_Offset)
-      != Object_Record_Offset)
+  if ((size_t) write (VMS_Object_File_FD, Object_Record_Buffer,
+                     Object_Record_Offset) != Object_Record_Offset)
     error (_("I/O error writing VMS object file"));
 
   /* The buffer is now empty.  */
   Object_Record_Offset = 0;
 }
 
-
 /* Declare a particular type of object file record.  */
 
 static void
@@ -656,7 +720,6 @@ Set_VMS_Object_File_Record (Type)
   Current_Object_Record_Type = Type;
 }
 
-
 /* Close the VMS Object file.  */
 
 static void
@@ -665,7 +728,7 @@ Close_VMS_Object_File ()
   /* Flush (should never be necessary) and reset saved record-type context.  */
   Set_VMS_Object_File_Record (-1);
 
-#ifndef VMS                    /* For cross-assembly purposes. */
+#ifndef VMS                    /* For cross-assembly purposes.  */
   {
     char RecLen[2];
     int minus_one = -1;
@@ -689,7 +752,6 @@ Close_VMS_Object_File ()
 
  /****** Text Information and Relocation routines ******/
 
-
 /* Stack Psect base followed by signed, varying-sized offset.
    Common to several object records.  */
 
@@ -709,15 +771,15 @@ vms_tir_stack_psect (Psect_Index, Offset, Force)
   switch (Sta_P(psect_width,offset_width))
     {
       case Sta_P(1,1): PUT_CHAR (TIR_S_C_STA_PB);
-                       PUT_CHAR ((char)(unsigned char) Psect_Index);
+                       PUT_CHAR ((char) (unsigned char) Psect_Index);
                        PUT_CHAR ((char) Offset);
                        break;
       case Sta_P(1,2): PUT_CHAR (TIR_S_C_STA_PW);
-                       PUT_CHAR ((char)(unsigned char) Psect_Index);
+                       PUT_CHAR ((char) (unsigned char) Psect_Index);
                        PUT_SHORT (Offset);
                        break;
       case Sta_P(1,4): PUT_CHAR (TIR_S_C_STA_PL);
-                       PUT_CHAR ((char)(unsigned char) Psect_Index);
+                       PUT_CHAR ((char) (unsigned char) Psect_Index);
                        PUT_LONG (Offset);
                        break;
       case Sta_P(2,1): PUT_CHAR (TIR_S_C_STA_WPB);
@@ -736,7 +798,6 @@ vms_tir_stack_psect (Psect_Index, Offset, Force)
 #undef Sta_P
 }
 
-
 /* Store immediate data in current Psect.  */
 
 static void
@@ -773,7 +834,6 @@ VMS_Store_Immediate_Data (Pointer, Size, Record_Type)
     Flush_VMS_Object_Record_Buffer ();
 }
 
-
 /* Make a data reference.  */
 
 static void
@@ -796,7 +856,6 @@ VMS_Set_Data (Psect_Index, Offset, Record_Type, Force)
     Flush_VMS_Object_Record_Buffer ();
 }
 
-
 /* Make a debugger reference to a struct, union or enum.  */
 
 static void
@@ -817,7 +876,6 @@ VMS_Store_Struct (Struct_Index)
     Flush_VMS_Object_Record_Buffer ();
 }
 
-
 /* Make a debugger reference to partially define a struct, union or enum.  */
 
 static void
@@ -854,7 +912,6 @@ VMS_Set_Struct (Struct_Index)
 
  /****** Traceback Information routines ******/
 
-
 /* Write the Traceback Module Begin record.  */
 
 static void
@@ -888,7 +945,6 @@ VMS_TBT_Module_Begin ()
   VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_TBT);
 }
 
-
 /* Write the Traceback Module End record.  */
 
 static void
@@ -903,7 +959,6 @@ VMS_TBT_Module_End ()
   VMS_Store_Immediate_Data (Local, 2, OBJ_S_C_TBT);
 }
 
-
 /* Write a Traceback Routine Begin record.  */
 
 static void
@@ -949,7 +1004,6 @@ VMS_TBT_Routine_Begin (symbolP, Psect)
   VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_TBT);
 }
 
-
 /* Write a Traceback Routine End record.
 
    We *must* search the symbol table to find the next routine, since the
@@ -964,7 +1018,7 @@ VMS_TBT_Routine_End (Max_Size, sp)
      symbolS *sp;
 {
   symbolS *symbolP;
-  int Size = 0x7fffffff;
+  unsigned long Size = 0x7fffffff;
   char Local[16];
   valueT sym_value, sp_value = S_GET_VALUE (sp);
 
@@ -1006,7 +1060,6 @@ VMS_TBT_Routine_End (Max_Size, sp)
   VMS_Store_Immediate_Data (Local, 7, OBJ_S_C_TBT);
 }
 
-
 /* Write a Traceback Block Begin record.  */
 
 static void
@@ -1050,7 +1103,6 @@ VMS_TBT_Block_Begin (symbolP, Psect, Name)
   VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_DBG);
 }
 
-
 /* Write a Traceback Block End record.  */
 
 static void
@@ -1281,13 +1333,12 @@ VMS_TBT_Source_File (Filename, ID_Number)
   /* Library module name (none).  */
   *cp++ = 0;
   /* Now that size is known, fill it in and write out the record.  */
-  Local[4] = cp - &Local[5];           /* source file declaration size */ 
+  Local[4] = cp - &Local[5];           /* source file declaration size */
   Local[0] = cp - &Local[1];           /* TBT record size */
   VMS_Store_Immediate_Data (Local, cp - Local, OBJ_S_C_TBT);
   return 1;
 }
 
-
 /* Traceback information is described in terms of lines from compiler
    listing files, not lines from source files.  We need to set up the
    correlation between listing line numbers and source line numbers.
@@ -1302,7 +1353,7 @@ VMS_TBT_Source_Lines (ID_Number, Starting_Line_Number, Number_Of_Lines)
 {
   char *cp;
   int chunk_limit;
-  char Local[128];     /* room enough to describe 1310700 lines... */
+  char Local[128];     /* room enough to describe 1310700 lines...  */
 
   cp = &Local[1];      /* Put size in Local[0] later.  */
   *cp++ = DST_S_C_SOURCE;              /* DST type is "source file".  */
@@ -1347,7 +1398,6 @@ VMS_TBT_Source_Lines (ID_Number, Starting_Line_Number, Number_Of_Lines)
 
  /****** Debugger Information support routines ******/
 
-
 /* This routine locates a file in the list of files.  If an entry does
    not exist, one is created.  For include files, a new entry is always
    created such that inline functions can be properly debugged.  */
@@ -1394,7 +1444,6 @@ find_file (sp)
   return fpnt;
 }
 
-
 /* This routine converts a number string into an integer, and stops when
    it sees an invalid character.  The return value is the address of the
    character just past the last character read.  No error is generated.  */
@@ -1426,7 +1475,6 @@ cvt_integer (str, rtn)
  * sections have already been output.
  */
 
-
 /* This routine fixes the names that are generated by C++, ".this" is a good
    example.  The period does not work for the debugger, since it looks like
    the syntax for a structure element, and thus it gets mightily confused.
@@ -1468,7 +1516,6 @@ fix_name (pnt)
   return pnt;
 }
 
-
 /* When defining a structure, this routine is called to find the name of
    the actual structure.  It is assumed that str points to the equal sign
    in the definition, and it moves backward until it finds the start of the
@@ -1497,7 +1544,6 @@ get_struct_name (str)
   return pnt;
 }
 
-
 /* Search symbol list for type number dbx_type.
    Return a pointer to struct.  */
 
@@ -1519,7 +1565,6 @@ find_symbol (dbx_type)
   return find_symbol (spnt->type2);
 }
 
-
 #if 0          /* obsolete */
 /* this routine puts info into either Local or Asuffix, depending on the sign
  * of size.  The reason is that it is easier to build the variable descriptor
@@ -1556,7 +1601,6 @@ push (value, size1)
 }
 #endif
 
-
 static void
 fpush (value, size)
      int value, size;
@@ -1595,7 +1639,6 @@ rpush (value, size)
     }
 }
 
-
 /* This routine generates the array descriptor for a given array.  */
 
 static void
@@ -1652,7 +1695,6 @@ array_suffix (spnt2)
     }
 }
 
-
 /* This routine generates the start of a variable descriptor based upon
    a struct/union/enum that has yet to be defined.  We define this spot as
    a new location, and save four bytes for the address.  When the struct is
@@ -1675,7 +1717,6 @@ new_forward_ref (dbx_type)
   struct_number = -fpnt->struc_numb;
 }
 
-
 /* This routine generates the variable descriptor used to describe non-basic
    variables.  It calls itself recursively until it gets to the bottom of it
    all, and then builds the descriptor backwards.  It is easiest to do it
@@ -1780,7 +1821,6 @@ gen1 (spnt, array_suffix_len)
   return 0;
 }
 
-
 /* This generates a suffix for a variable.  If it is not a defined type yet,
    then dbx_type contains the type we are expecting so we can generate a
    forward reference.  This calls gen1 to build most of the descriptor, and
@@ -1860,7 +1900,6 @@ generate_suffix (spnt, dbx_type)
   Lpnt = 0;
 }
 
-
        /* "novel length" type doesn't work for simple atomic types */
 #define USE_BITSTRING_DESCRIPTOR(t) ((t)->advanced == BASIC)
 #undef SETUP_BASIC_TYPES
@@ -1887,7 +1926,6 @@ bitfield_suffix (spnt, width)
   VMS_Store_Struct (spnt->struc_numb); /* output 4 more bytes */
 }
 
-
 /* Formally define a builtin type, so that it can serve as the target of
    an indirect reference.  It makes bitfield_suffix() easier by avoiding
    the need to use a forward reference for the first occurrence of each
@@ -1895,7 +1933,7 @@ bitfield_suffix (spnt, width)
 
 static void
 setup_basic_type (spnt)
-     struct VMS_DBG_Symbol *spnt;
+     struct VMS_DBG_Symbol *spnt ATTRIBUTE_UNUSED;
 {
 #ifdef SETUP_BASIC_TYPES
   /* This would be very useful if "novel length" fields actually worked
@@ -1942,7 +1980,6 @@ setup_basic_type (spnt)
   return;
 }
 
-
 /* This routine generates a symbol definition for a C symbol for the debugger.
    It takes a psect and offset for global symbols; if psect < 0, then this is
    a local variable and the offset is relative to FP.  In this case it can
@@ -1988,7 +2025,6 @@ VMS_DBG_record (spnt, Psect, Offset, Name)
     generate_suffix (spnt, 0);
 }
 
-
 /* This routine parses the stabs entries in order to make the definition
    for the debugger of local symbols and function parameters.  */
 
@@ -2046,7 +2082,7 @@ VMS_local_stab_Parse (sp)
                str1++;
              }
            if (*str1 == ':' && *pnt2 == ':')
-             return;   /* they are the same!  lets skip this one */
+             return;   /* They are the same!  Let's skip this one.  */
          }                     /* for */
        pnt++;                  /* skip p in case no register */
       }                        /* if */
@@ -2062,7 +2098,6 @@ VMS_local_stab_Parse (sp)
   return;
 }
 
-
 /* This routine parses a stabs entry to find the information required
    to define a variable.  It is used for global and static variables.
    Basically we need to know the address of the symbol.  With older
@@ -2170,7 +2205,6 @@ VMS_stab_parse (sp, expected_type, type1, type2, Text_Psect)
   return;
 }
 
-
 /* Simpler interfaces into VMS_stab_parse().  */
 
 static void
@@ -2197,7 +2231,6 @@ VMS_STSYM_Parse (sp, Text_Psect)
   VMS_stab_parse (sp, 'S', N_DATA, -1, Text_Psect);
 }
 
-
 /* For register symbols, we must figure out what range of addresses
    within the psect are valid.  We will use the brackets in the stab
    directives to give us guidance as to the PC range that this variable
@@ -2207,7 +2240,8 @@ VMS_STSYM_Parse (sp, Text_Psect)
 
 static void
 VMS_RSYM_Parse (sp, Current_Routine, Text_Psect)
-     symbolS *sp, *Current_Routine;
+     symbolS *sp;
+     symbolS *Current_Routine ATTRIBUTE_UNUSED;
      int Text_Psect;
 {
   symbolS *symbolP;
@@ -2319,7 +2353,6 @@ VMS_RSYM_Parse (sp, Current_Routine, Text_Psect)
     generate_suffix (spnt, 0);
 }
 
-
 /* This function examines a structure definition, checking all of the elements
    to make sure that all of them are fully defined.  The only thing that we
    kick out are arrays of undefined structs, since we do not know how big
@@ -2353,7 +2386,6 @@ forward_reference (pnt)
   return 0;                    /* no forward refences found */
 }
 
-
 /* Used to check a single element of a structure on the final pass.  */
 
 static int
@@ -2372,7 +2404,6 @@ final_forward_reference (spnt)
   return 0;    /* no forward refences found */
 }
 
-
 /* This routine parses the stabs directives to find any definitions of dbx
    type numbers.  It makes a note of all of them, creating a structure
    element of VMS_DBG_Symbol that describes it.  This also generates the
@@ -2802,7 +2833,6 @@ VMS_typedef_parse (str)
   return 0;
 }
 
-
 /* This is the root routine that parses the stabs entries for definitions.
    it calls VMS_typedef_parse, which can in turn call itself.  We need to
    be careful, since sometimes there are forward references to other symbol
@@ -2947,7 +2977,6 @@ VMS_LSYM_Parse ()
     }
 }
 
-
 static void
 Define_Local_Symbols (s0P, s2P, Current_Routine, Text_Psect)
      symbolS *s0P, *s2P;
@@ -2987,7 +3016,6 @@ Define_Local_Symbols (s0P, s2P, Current_Routine, Text_Psect)
     }                          /* for */
 }
 
-
 /* This function crawls the symbol chain searching for local symbols that
    need to be described to the debugger.  When we enter a new scope with
    a "{", it creates a new "block", which helps the debugger keep track
@@ -3072,7 +3100,6 @@ get_VMS_time_on_unix (Now)
 }
 #endif /* not VMS */
 
-
 /* Write the MHD (Module Header) records.  */
 
 static void
@@ -3117,7 +3144,7 @@ Write_VMS_MHD_Records ()
          cp++;
          continue;
        }
-      *cp1++ = islower (*cp) ? toupper (*cp++) : *cp++;
+      *cp1++ = TOUPPER (*cp++);
     }
   *cp1 = '\0';
 
@@ -3179,7 +3206,6 @@ Write_VMS_MHD_Records ()
   Flush_VMS_Object_Record_Buffer ();
 }
 
-
 /* Write the EOM (End Of Module) record.  */
 
 static void
@@ -3195,7 +3221,7 @@ Write_VMS_EOM_Record (Psect, Offset)
    */
   Set_VMS_Object_File_Record (OBJ_S_C_EOM);
   PUT_CHAR (OBJ_S_C_EOM);      /* Record type.  */
-  PUT_CHAR (0);                        /* Error severity level (we ignore it). */
+  PUT_CHAR (0);                        /* Error severity level (we ignore it).  */
   /*
    *   Store the entry point, if it exists
    */
@@ -3301,20 +3327,20 @@ VMS_Case_Hack_Symbol (In, Out)
       switch (vms_name_mapping)
        {
        case 0:
-         if (isupper (*In)) {
+         if (ISUPPER (*In)) {
            *Out++ = *In++;
            Case_Hack_Bits |= 1;
          } else {
-           *Out++ = islower (*In) ? toupper (*In++) : *In++;
+           *Out++ = TOUPPER (*In++);
          }
          break;
        case 3: *Out++ = *In++;
          break;
        case 2:
-         if (islower (*In)) {
+         if (ISLOWER (*In)) {
            *Out++ = *In++;
          } else {
-           *Out++ = isupper (*In) ? tolower (*In++) : *In++;
+           *Out++ = TOLOWER (*In++);
          }
          break;
        }
@@ -3345,7 +3371,7 @@ VMS_Case_Hack_Symbol (In, Out)
           *            and ensure that they are lowercase
           */
          for (i = 0; (In[i] != 0) && (i < 8); i++)
-           if (isupper (In[i]) && !Saw_Dollar && !flag_no_hash_mixed_case)
+           if (ISUPPER (In[i]) && !Saw_Dollar && !flag_no_hash_mixed_case)
              break;
 
          if (In[i] == 0)
@@ -3360,11 +3386,11 @@ VMS_Case_Hack_Symbol (In, Out)
              i = 8;
              while ((--i >= 0) && (*In))
                switch (vms_name_mapping){
-               case 0: *Out++ = islower (*In) ? toupper (*In++) : *In++;
+               case 0: *Out++ = TOUPPER (*In++);
                  break;
                case 3: *Out++ = *In++;
                  break;
-               case 2: *Out++ = isupper (*In) ? tolower (*In++) : *In++;
+               case 2: *Out++ = TOLOWER (*In++);
                  break;
                }
            }
@@ -3417,7 +3443,6 @@ VMS_Case_Hack_Symbol (In, Out)
 #define GLOBALSYMBOL_BIT       0x10000
 #define GLOBALVALUE_BIT                0x20000
 
-
 static void
 VMS_Modify_Psect_Attributes (Name, Attribute_Pointer)
      const char *Name;
@@ -3525,7 +3550,7 @@ VMS_Modify_Psect_Attributes (Name, Attribute_Pointer)
 #define GBLSYM_REF 0
 #define GBLSYM_DEF 1
 #define GBLSYM_VAL 2
-#define GBLSYM_LCL 4   /* not GBL after all... */
+#define GBLSYM_LCL 4   /* not GBL after all...  */
 #define GBLSYM_WEAK 8
 
 /*
@@ -3663,30 +3688,30 @@ VMS_Psect_Spec (Name, Size, Type, vsp)
   switch (Type)
     {
     case ps_TEXT:
-      /* Text psects are PIC,noOVR,REL,noGBL,SHR,EXE,RD,noWRT. */
+      /* Text psects are PIC,noOVR,REL,noGBL,SHR,EXE,RD,noWRT.  */
       Psect_Attributes = (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_SHR|GPS_S_M_EXE
                          |GPS_S_M_RD);
       break;
     case ps_DATA:
-      /* Data psects are PIC,noOVR,REL,noGBL,noSHR,noEXE,RD,WRT. */
+      /* Data psects are PIC,noOVR,REL,noGBL,noSHR,noEXE,RD,WRT.  */
       Psect_Attributes = (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_RD|GPS_S_M_WRT);
       break;
     case ps_COMMON:
-      /* Common block psects are:  PIC,OVR,REL,GBL,noSHR,noEXE,RD,WRT. */
+      /* Common block psects are:  PIC,OVR,REL,GBL,noSHR,noEXE,RD,WRT.  */
       Psect_Attributes = (GPS_S_M_PIC|GPS_S_M_OVR|GPS_S_M_REL|GPS_S_M_GBL
                          |GPS_S_M_RD|GPS_S_M_WRT);
       break;
     case ps_CONST:
-      /* Const data psects are:  PIC,OVR,REL,GBL,noSHR,noEXE,RD,noWRT. */
+      /* Const data psects are:  PIC,OVR,REL,GBL,noSHR,noEXE,RD,noWRT.  */
       Psect_Attributes = (GPS_S_M_PIC|GPS_S_M_OVR|GPS_S_M_REL|GPS_S_M_GBL
                          |GPS_S_M_RD);
       break;
     case ps_CTORS:
-      /* Ctor psects are PIC,noOVR,REL,GBL,noSHR,noEXE,RD,noWRT. */
+      /* Ctor psects are PIC,noOVR,REL,GBL,noSHR,noEXE,RD,noWRT.  */
       Psect_Attributes = (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_GBL|GPS_S_M_RD);
       break;
     case ps_DTORS:
-      /* Dtor psects are PIC,noOVR,REL,GBL,noSHR,noEXE,RD,noWRT. */
+      /* Dtor psects are PIC,noOVR,REL,GBL,noSHR,noEXE,RD,noWRT.  */
       Psect_Attributes = (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_GBL|GPS_S_M_RD);
       break;
     default:
@@ -3805,7 +3830,6 @@ VMS_Initialized_Data_Size (s0P, End_Of_Data)
   return (offsetT) (nearest_val - s0P_val);
 }
 
-
 /* Check symbol names for the Psect hack with a globalvalue, and then
    generate globalvalues for those that have it.  */
 
@@ -3883,7 +3907,7 @@ VMS_Emit_Globalvalues (text_siz, data_siz, Data_Segment)
              Size = VMS_Initialized_Data_Size (sp, text_siz + data_siz);
              if (Size > 4)
                error (_("Invalid data type for globalvalue"));
-             globalvalue = md_chars_to_number (Data_Segment + 
+             globalvalue = md_chars_to_number (Data_Segment +
                     S_GET_VALUE (sp) - text_siz , Size);
              /* Three times for good luck.  The linker seems to get confused
                 if there are fewer than three */
@@ -4216,7 +4240,7 @@ VMS_Store_PIC_Symbol_Reference (Symbol, Offset, PC_Relative,
 static void
 VMS_Fix_Indirect_Reference (Text_Psect, Offset, fragP, text_frag_root)
      int Text_Psect;
-     int Offset;
+     addressT Offset;
      register fragS *fragP;
      fragS *text_frag_root;
 {
@@ -4533,7 +4557,6 @@ struct vms_obj_state {
 #define Local_Initd_Data_Size  vms_obj_state.local_initd_data_size
 #define Data_Segment           vms_obj_state.data_segment
 
-
 #define IS_GXX_VTABLE(symP) (strncmp (S_GET_NAME (symP), "__vt.", 5) == 0)
 #define IS_GXX_XTOR(symP) (strncmp (S_GET_NAME (symP), "__GLOBAL_.", 10) == 0)
 #define XTOR_SIZE 4
@@ -4543,7 +4566,7 @@ struct vms_obj_state {
 
 static void
 vms_fixup_text_section (text_siz, text_frag_root, data_frag_root)
-     unsigned text_siz;
+     unsigned text_siz ATTRIBUTE_UNUSED;
      struct frag *text_frag_root;
      struct frag *data_frag_root;
 {
@@ -4640,7 +4663,8 @@ vms_fixup_text_section (text_siz, text_frag_root, data_frag_root)
 
 static void
 synthesize_data_segment (data_siz, text_siz, data_frag_root)
-     unsigned data_siz, text_siz;
+     unsigned data_siz;
+     unsigned text_siz;
      struct frag *data_frag_root;
 {
   register fragS *fragP;
@@ -4671,12 +4695,12 @@ synthesize_data_segment (data_siz, text_siz, data_frag_root)
   return;
 }
 
-
 /* Perform data segment fixups.  */
 
 static void
 vms_fixup_data_section (data_siz, text_siz)
-     unsigned data_siz, text_siz;
+     unsigned int data_siz ATTRIBUTE_UNUSED;
+     unsigned int text_siz;
 {
   register struct VMS_Symbol *vsp;
   register struct fix *fixP;
@@ -4781,7 +4805,7 @@ vms_fixup_data_section (data_siz, text_siz)
 static void
 vms_fixup_xtors_section (symbols, sect_no)
        struct VMS_Symbol *symbols;
-       int sect_no;
+       int sect_no ATTRIBUTE_UNUSED;
 {
   register struct VMS_Symbol *vsp;
 
@@ -5105,7 +5129,6 @@ local_symbols_DST (s0P, Current_Routine)
     }
 }
 
-
 /* Construct and output the debug symbol table.  */
 
 static void
@@ -5429,7 +5452,6 @@ vms_write_object_file (text_siz, data_siz, bss_siz, text_frag_root,
   if (data_siz > 0)
     synthesize_data_segment (data_siz, text_siz, data_frag_root);
 
-
   /*******  Global Symbol Directory  *******/
 
   /*
@@ -5473,7 +5495,6 @@ vms_write_object_file (text_siz, data_siz, bss_siz, text_frag_root,
          vsp->Psect_Index = Data_Psect;
     }
 
-
   if (Ctors_Symbols != 0)
     {
       char *ps_name = "$ctors";
@@ -5524,12 +5545,10 @@ vms_write_object_file (text_siz, data_siz, bss_siz, text_frag_root,
       vms_fixup_xtors_section (Dtors_Symbols, Dtors_Psect);
     }
 
-
   /*******  Debugger Symbol Table Records  *******/
 
   vms_build_DST (text_siz);
 
-
   /*******  Wrap things up  *******/
 
   /*
@@ -5545,5 +5564,3 @@ vms_write_object_file (text_siz, data_siz, bss_siz, text_frag_root,
    */
   Close_VMS_Object_File ();
 }
-
-/* end of obj-vms.c */