* dw2gencfi.c (cfi_pseudo_table): Add cfi_gnu_window_save.
[binutils-gdb.git] / gas / config / obj-vms.c
index 76785856b481a2b85d6d98d49097b698955d7c48..91498925b358af0a0c840fa3460a0ccadfc18747 100644 (file)
@@ -1,5 +1,6 @@
 /* vms.c -- Write out a VAX/VMS object file
-   Copyright (C) 1987, 1988, 1992, 1994, 1995 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.
 
@@ -14,8 +15,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GAS; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+along with GAS; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
 
 /* Written by David L. Kashtan */
 /* Modified by Eric Youngdale to write VMS debug records for program
@@ -26,13 +28,15 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307
 
 #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*/
@@ -79,6 +83,8 @@ struct VMS_Symbol
 };
 
 struct VMS_Symbol *VMS_Symbols = 0;
+struct VMS_Symbol *Ctors_Symbols = 0;
+struct VMS_Symbol *Dtors_Symbols = 0;
 
 /* We need this to keep track of the various input files, so that we can
  * give the debugger the correct source line.
@@ -99,14 +105,13 @@ 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().
  */
 enum ps_type
 {
-  ps_TEXT, ps_DATA, ps_COMMON, ps_CONST
+  ps_TEXT, ps_DATA, ps_COMMON, ps_CONST, ps_CTORS, ps_DTORS
 };
 
 /*
@@ -151,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];
 
 /*
@@ -189,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
@@ -250,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)
@@ -341,83 +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_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
@@ -443,7 +514,6 @@ const pseudo_typeS obj_pseudo_table[] =
   {0, 0, 0},
 };                             /* obj_pseudo_table */
 
-
 /* Routine to perform RESOLVE_SYMBOL_REDEFINITION().  */
 
 int
@@ -457,7 +527,7 @@ vms_resolve_symbol_redef (sym)
   if (SEGMENT_TO_SYMBOL_TYPE ((int) now_seg) == (N_UNDF | N_EXT)
       && frag_now_fix () == 0)
     {
-      as_warn ("compiler emitted zero-size common symbol `%s' already defined",
+      as_warn (_("compiler emitted zero-size common symbol `%s' already defined"),
               S_GET_NAME (sym));
       return 1;
     }
@@ -467,7 +537,7 @@ vms_resolve_symbol_redef (sym)
    */
   if (S_IS_EXTERNAL (sym) && S_IS_DEFINED (sym) && S_GET_VALUE (sym) == 0)
     {
-      as_warn ("compiler redefined zero-size common symbol `%s'",
+      as_warn (_("compiler redefined zero-size common symbol `%s'"),
               S_GET_NAME (sym));
       sym->sy_frag  = frag_now;
       S_SET_OTHER (sym, const_flag);
@@ -480,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."
@@ -514,14 +583,12 @@ symbolS *symbolP;
   return;
 }
 
-
 void
 obj_read_begin_hook ()
 {
   return;
 }
 
-
 void
 obj_crawl_symbol_chain (headers)
      object_headers *headers;
@@ -530,7 +597,7 @@ 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);
@@ -553,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. */
+             as_bad (_("Local symbol %s never defined"), S_GET_NAME (symbolP));
+           }                   /* oops.  */
 
          /* Unhook it from the chain.  */
          *symbolPP = symbol_next (symbolP);
@@ -575,27 +642,30 @@ 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",
-                             "mbc=16", "deq=64", "fop=tef", "shr=nil");
-#endif /* eunice */
+                             "ctx=bin", "mbc=16", "deq=64", "fop=tef",
+                             "shr=nil");
+#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);
+    as_fatal (_("Couldn't create VMS object file \"%s\""), out_file_name);
   /* Initialize object file hacking variables.  */
   Object_Record_Offset = 0;
   Current_Object_Record_Type = -1;
 }
 
-
 /* Flush the object record buffer to the object file.  */
 
 static void
@@ -605,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];
 
@@ -615,7 +685,7 @@ Flush_VMS_Object_Record_Buffer ()
        When cross-assembling, we must write it explicitly.  */
     md_number_to_chars (RecLen, Object_Record_Offset, 2);
     if (write (VMS_Object_File_FD, RecLen, 2) != 2)
-      error ("I/O error writing VMS object file (length prefix)");
+      error (_("I/O error writing VMS object file (length prefix)"));
     /* We also need to force the actual record to be an even number of
        bytes.  For native output, that's automatic; when cross-assembling,
        pad with a NUL byte if length is odd.  Do so _after_ writing the
@@ -627,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)
-    error ("I/O error writing VMS object file");
+  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
@@ -651,7 +720,6 @@ Set_VMS_Object_File_Record (Type)
   Current_Object_Record_Type = Type;
 }
 
-
 /* Close the VMS Object file.  */
 
 static void
@@ -660,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;
@@ -684,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.  */
 
@@ -704,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);
@@ -731,7 +798,6 @@ vms_tir_stack_psect (Psect_Index, Offset, Force)
 #undef Sta_P
 }
 
-
 /* Store immediate data in current Psect.  */
 
 static void
@@ -768,7 +834,6 @@ VMS_Store_Immediate_Data (Pointer, Size, Record_Type)
     Flush_VMS_Object_Record_Buffer ();
 }
 
-
 /* Make a data reference.  */
 
 static void
@@ -791,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
@@ -812,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
@@ -849,7 +912,6 @@ VMS_Set_Struct (Struct_Index)
 
  /****** Traceback Information routines ******/
 
-
 /* Write the Traceback Module Begin record.  */
 
 static void
@@ -883,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
@@ -898,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
@@ -944,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
@@ -959,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);
 
@@ -1001,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
@@ -1045,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
@@ -1232,7 +1289,7 @@ VMS_TBT_Source_File (Filename, ID_Number)
   Status = sys$open (&fab);
   if (!(Status & 1))
     {
-      as_tsktsk ("Couldn't find source file \"%s\", status=%%X%x",
+      as_tsktsk (_("Couldn't find source file \"%s\", status=%%X%x"),
                 Filename, Status);
       return 0;
     }
@@ -1276,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.
@@ -1297,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".  */
@@ -1340,12 +1396,12 @@ VMS_TBT_Source_Lines (ID_Number, Starting_Line_Number, Number_Of_Lines)
 }
 \f
 
+ /****** 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.  */
 
-/*
- * 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.
- */
 static struct input_file *
 find_file (sp)
      symbolS *sp;
@@ -1387,62 +1443,59 @@ find_file (sp)
   fpnt->same_file_fpnt = same_file;
   return fpnt;
 }
-\f
-/*
- * The following functions and definitions are used to generate object records
- * that will describe program variables to the VMS debugger.
- *
- * This file contains many of the routines needed to output debugging info into
- * the object file that the VMS debugger needs to understand symbols.  These
- * routines are called very late in the assembly process, and thus we can be
- * fairly lax about changing things, since the GSD and the TIR sections have
- * already been output.
- */
 
+/* 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.  */
 
-/* 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.
- */
 static char *
 cvt_integer (str, rtn)
      char *str;
      int *rtn;
 {
-  int ival, neg;
-  neg = *str == '-' ? ++str, -1 : 1;
-  ival = 0;
-  while ((*str <= '9') && (*str >= '0'))
+  int ival = 0, sgn = 1;
+
+  if (*str == '-')
+    sgn = -1,  ++str;
+  while (*str >= '0' && *str <= '9')
     ival = 10 * ival + *str++ - '0';
-  *rtn = neg * ival;
+  *rtn = sgn * ival;
   return str;
 }
+\f
 
-/* 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
+/*
+ * The following functions and definitions are used to generate object
+ * records that will describe program variables to the VMS debugger.
  *
- * We also use this to strip the PsectAttribute hack from the name before we
- * write a debugger record */
+ * This file contains many of the routines needed to output debugging info
+ * into the object file that the VMS debugger needs to understand symbols.
+ * These routines are called very late in the assembly process, and thus
+ * we can be fairly lax about changing things, since the GSD and the TIR
+ * 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.
+
+   We also use this to strip the PsectAttribute hack from the name before we
+   write a debugger record.  */
 
 static char *
 fix_name (pnt)
      char *pnt;
 {
   char *pnt1;
-  /*
-   *   Kill any leading "_"
-   */
+
+  /* Kill any leading "_".  */
   if (*pnt == '_')
     pnt++;
-  /*
-   *   Is there a Psect Attribute to skip??
-   */
+
+  /* Is there a Psect Attribute to skip??  */
   if (HAS_PSECT_ATTRIBUTES (pnt))
     {
-      /*
-       *       Yes: Skip it
-       */
+      /* Yes: Skip it.  */
       pnt += PSECT_ATTRIBUTES_STRING_LENGTH;
       while (*pnt)
        {
@@ -1454,21 +1507,21 @@ fix_name (pnt)
          pnt++;
        }
     }
-/* Here we fix the .this -> $this conversion */
+
+  /* Here we fix the .this -> $this conversion.  */
   for (pnt1 = pnt; *pnt1 != 0; pnt1++)
-    {
-      if (*pnt1 == '.')
-       *pnt1 = '$';
-    }
+    if (*pnt1 == '.')
+      *pnt1 = '$';
+
   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
* name.  If it finds a 0, then it knows that this structure def is in the
- * outermost level, and thus symbol_name points to the symbol name.
- */
  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
  name.  If it finds a 0, then it knows that this structure def is in the
+   outermost level, and thus symbol_name points to the symbol name.  */
+
 static char *
 get_struct_name (str)
      char *str;
@@ -1491,7 +1544,9 @@ get_struct_name (str)
   return pnt;
 }
 
-/* search symbol list for type number dbx_type.  Return a pointer to struct */
+/* Search symbol list for type number dbx_type.
+   Return a pointer to struct.  */
+
 static struct VMS_DBG_Symbol *
 find_symbol (dbx_type)
      int dbx_type;
@@ -1510,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
@@ -1547,7 +1601,6 @@ push (value, size1)
 }
 #endif
 
-
 static void
 fpush (value, size)
      int value, size;
@@ -1586,7 +1639,8 @@ rpush (value, size)
     }
 }
 
-/* this routine generates the array descriptor for a given array */
+/* This routine generates the array descriptor for a given array.  */
+
 static void
 array_suffix (spnt2)
      struct VMS_DBG_Symbol *spnt2;
@@ -1601,7 +1655,7 @@ array_suffix (spnt2)
   while (spnt->advanced != ARRAY)
     {
       spnt = find_symbol (spnt->type2);
-      if (spnt == (struct VMS_DBG_Symbol *) NULL)
+      if (!spnt)
        return;
     }
   spnt1 = spnt;
@@ -1641,11 +1695,11 @@ 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
- * finally defined, then we can go back and plug in the correct address.
-*/
+/* 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
+   finally defined, then we can go back and plug in the correct address.  */
+
 static void
 new_forward_ref (dbx_type)
      int dbx_type;
@@ -1663,12 +1717,12 @@ 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 this
- *way since we must periodically write length bytes, and it is easiest if we know
- *the value when it is time to write it.
- */
+/* 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
+   this way since we must periodically write length bytes, and it is easiest
+   if we know the value when it is time to write it.  */
+
 static int
 gen1 (spnt, array_suffix_len)
      struct VMS_DBG_Symbol *spnt;
@@ -1733,7 +1787,7 @@ gen1 (spnt, array_suffix_len)
          spnt1 = find_symbol (spnt1->type2);
          if (!spnt1)
            {
-             as_tsktsk ("debugger forward reference error, dbx type %d",
+             as_tsktsk (_("debugger forward reference error, dbx type %d"),
                         spnt->type2);
              return 0;
            }
@@ -1768,11 +1822,11 @@ gen1 (spnt, array_suffix_len)
 }
 
 /* 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
* then it puts the icing on at the end.  It then dumps whatever is needed
- * to get a complete descriptor (i.e. struct reference, array suffix ).
- */
  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
  then it puts the icing on at the end.  It then dumps whatever is needed
+   to get a complete descriptor (i.e. struct reference, array suffix).  */
+
 static void
 generate_suffix (spnt, dbx_type)
      struct VMS_DBG_Symbol *spnt;
@@ -1804,12 +1858,11 @@ generate_suffix (spnt, dbx_type)
   rpush (DST_K_TYPSPEC, 1);
   total_len += 4;
   rpush (total_len, 1);
-/* if the variable descriptor overflows the record, output a descriptor for
- * a pointer to void.
- */
+  /* If the variable descriptor overflows the record, output a descriptor
+     for a pointer to void.  */
   if ((total_len >= MAX_DEBUG_RECORD) || overflow)
     {
-      as_warn ("Variable descriptor %d too complicated.  Defined as `void *'.",
+      as_warn (_("Variable descriptor %d too complicated.  Defined as `void *'."),
                spnt->dbx_type);
       VMS_Store_Immediate_Data (pvoid, 6, OBJ_S_C_DBG);
       return;
@@ -1818,17 +1871,16 @@ generate_suffix (spnt, dbx_type)
   while (Lpnt < MAX_DEBUG_RECORD - 1)
     Local[i++] = Local[++Lpnt];
   Lpnt = i;
-/* we use this for a reference to a structure that has already been defined */
+  /* we use this for reference to structure that has already been defined */
   if (struct_number > 0)
     {
       VMS_Store_Immediate_Data (Local, Lpnt, OBJ_S_C_DBG);
       Lpnt = 0;
       VMS_Store_Struct (struct_number);
     }
-/* We use this for a forward reference to a structure that has yet to be
- * defined.  We store four bytes of zero to make room for the actual address
- * once it is known.
- */
+  /* We use this for a forward reference to a structure that has yet to
+     be defined.  We store four bytes of zero to make room for the actual
+     address once it is known.  */
   if (struct_number < 0)
     {
       struct_number = -struct_number;
@@ -1852,6 +1904,8 @@ generate_suffix (spnt, dbx_type)
 #define USE_BITSTRING_DESCRIPTOR(t) ((t)->advanced == BASIC)
 #undef SETUP_BASIC_TYPES
 
+/* This routine generates a type description for a bitfield.  */
+
 static void
 bitfield_suffix (spnt, width)
      struct VMS_DBG_Symbol *spnt;
@@ -1876,9 +1930,10 @@ bitfield_suffix (spnt, width)
    an indirect reference.  It makes bitfield_suffix() easier by avoiding
    the need to use a forward reference for the first occurrence of each
    type used in a bitfield.  */
+
 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
@@ -1926,10 +1981,10 @@ setup_basic_type (spnt)
 }
 
 /* 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
- * be either a variable (Offset < 0) or a parameter (Offset > 0).
- */
  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
+   be either a variable (Offset < 0) or a parameter (Offset > 0).  */
+
 static void
 VMS_DBG_record (spnt, Psect, Offset, Name)
      struct VMS_DBG_Symbol *spnt;
@@ -1970,24 +2025,23 @@ 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
- */
+   for the debugger of local symbols and function parameters.  */
+
 static void
 VMS_local_stab_Parse (sp)
      symbolS *sp;
 {
+  struct VMS_DBG_Symbol *spnt;
   char *pnt;
   char *pnt1;
   char *str;
-  struct VMS_DBG_Symbol *spnt;
   int dbx_type;
 
   dbx_type = 0;
   str = S_GET_NAME (sp);
   pnt = (char *) strchr (str, ':');
-  if (pnt == (char *) NULL)
+  if (!pnt)
     return;                    /* no colon present */
   pnt1 = pnt++;                        /* save this for later, and skip colon */
   if (*pnt == 'c')
@@ -2000,9 +2054,10 @@ VMS_local_stab_Parse (sp)
  * this function to see if this parameter is assigned to a register.
  */
   {
+    symbolS *sp1;
     char *str1;
     char *pnt2;
-    symbolS *sp1;
+
     if (*pnt == 'p')
       {
        for (sp1 = symbol_next (sp); sp1; sp1 = symbol_next (sp1))
@@ -2011,8 +2066,9 @@ VMS_local_stab_Parse (sp)
              continue;
            if (S_GET_RAW_TYPE (sp1) == N_FUN)
              {
-               char * pnt3=(char*) strchr (S_GET_NAME (sp1), ':') + 1;
-               if (*pnt3 == 'F' || *pnt3 == 'f') break;
+               pnt2 = (char *) strchr (S_GET_NAME (sp1), ':') + 1;
+               if (*pnt2 == 'F' || *pnt2 == 'f')
+                 break;
              }
            if (S_GET_RAW_TYPE (sp1) != N_RSYM)
              continue;
@@ -2025,14 +2081,13 @@ VMS_local_stab_Parse (sp)
                pnt2++;
                str1++;
              }
-           if ((*str1 != ':') || (*pnt2 != ':'))
-             continue;
-           return;             /* they are the same!  lets skip this one */
+           if (*str1 == ':' && *pnt2 == ':')
+             return;   /* They are the same!  Let's skip this one.  */
          }                     /* for */
-/* first find the dbx symbol type from list, and then find VMS type */
        pnt++;                  /* skip p in case no register */
       }                        /* if */
   }                            /* p block */
+
   pnt = cvt_integer (pnt, &dbx_type);
   spnt = find_symbol (dbx_type);
   if (!spnt)
@@ -2043,17 +2098,17 @@ 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 versions
- * of the compiler, const symbols are
* treated differently, in that if they are global they are written into the
- * text psect.  The global symbol entry for such a const is actually written
- * as a program entry point (Yuk!!), so if we cannot find a symbol in the list
- * of psects, we must search the entry points as well.  static consts are even
- * harder, since they are never assigned a memory address.  The compiler passes
- * a stab to tell us the value, but I am not sure what to do with it.
- */
+/* 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
+   versions of the compiler, const symbols are treated differently, in
  that if they are global they are written into the text psect.  The
+   global symbol entry for such a const is actually written as a program
+   entry point (Yuk!!), so if we cannot find a symbol in the list of
+   psects, we must search the entry points as well.  static consts are
+   even harder, since they are never assigned a memory address.  The
+   compiler passes a stab to tell us the value, but I am not sure what
  to do with it.  */
 
 static void
 VMS_stab_parse (sp, expected_type, type1, type2, Text_Psect)
@@ -2072,7 +2127,7 @@ VMS_stab_parse (sp, expected_type, type1, type2, Text_Psect)
   dbx_type = 0;
   str = S_GET_NAME (sp);
   pnt = (char *) strchr (str, ':');
-  if (pnt == (char *) NULL)
+  if (!pnt)
     return;                    /* no colon present */
   pnt1 = pnt;                  /* save this for later*/
   pnt++;
@@ -2080,33 +2135,33 @@ VMS_stab_parse (sp, expected_type, type1, type2, Text_Psect)
     {
       pnt = cvt_integer (pnt + 1, &dbx_type);
       spnt = find_symbol (dbx_type);
-      if (spnt == (struct VMS_DBG_Symbol *) NULL)
+      if (!spnt)
        return;         /*Dunno what this is*/
-/* now we need to search the symbol table to find the psect and offset for
- * this variable.
- */
+      /*
+       * Now we need to search the symbol table to find the psect and
+       * offset for this variable.
+       */
       *pnt1 = '\0';
       vsp = VMS_Symbols;
-      while (vsp != (struct VMS_Symbol *) NULL)
+      while (vsp)
        {
          pnt = S_GET_NAME (vsp->Symbol);
-         if (pnt != (char *) NULL)
-           if (*pnt++ == '_')
-/* make sure name is the same, and make sure correct symbol type */
-             if ((strlen (pnt) == strlen (str)) && (strcmp (pnt, str) == 0)
-                 && ((S_GET_RAW_TYPE (vsp->Symbol) == type1) ||
-                     (S_GET_RAW_TYPE (vsp->Symbol) == type2)))
-               break;
+         if (pnt && *pnt++ == '_'
+             /* make sure name is the same and symbol type matches */
+             && strcmp (pnt, str) == 0
+             && (S_GET_RAW_TYPE (vsp->Symbol) == type1
+                 || S_GET_RAW_TYPE (vsp->Symbol) == type2))
+           break;
          vsp = vsp->Next;
        }
-      if (vsp != (struct VMS_Symbol *) NULL)
+      if (vsp)
        {
          VMS_DBG_record (spnt, vsp->Psect_Index, vsp->Psect_Offset, str);
          *pnt1 = ':';          /* and restore the string */
          return;
        }
-/* the symbol was not in the symbol list, but it may be an "entry point"
-   if it was a constant */
+      /* The symbol was not in the symbol list, but it may be an
+         "entry point" if it was a constant.  */
       for (sp1 = symbol_rootP; sp1; sp1 = symbol_next (sp1))
        {
          /*
@@ -2121,14 +2176,14 @@ VMS_stab_parse (sp, expected_type, type1, type2, Text_Psect)
            {
              if (!gave_compiler_message && expected_type == 'G')
                {
-                 static const char long_const_msg[] = "\
+                 char *long_const_msg = _("\
 ***Warning - the assembly code generated by the compiler has placed \n\
  global constant(s) in the text psect.  These will not be available to \n\
  other modules, since this is not the correct way to handle this. You \n\
  have two options: 1) get a patched compiler that does not put global \n\
  constants in the text psect, or 2) remove the 'const' keyword from \n\
  definitions of global variables in your source module(s).  Don't say \n\
- I didn't warn you! \n";
+ I didn't warn you! \n");
 
                  as_tsktsk (long_const_msg);
                  gave_compiler_message = 1;
@@ -2138,9 +2193,10 @@ VMS_stab_parse (sp, expected_type, type1, type2, Text_Psect)
                              S_GET_VALUE (sp1),
                              str);
              *pnt1 = ':';
-             *S_GET_NAME (sp1) = 'L';
-             /* fool assembler to not output this
-              * as a routine in the TBT */
+             /* fool assembler to not output this as a routine in the TBT */
+             pnt1 = S_GET_NAME (sp1);
+             *pnt1 = 'L';
+             S_SET_NAME (sp1, pnt1);
              return;
            }
        }
@@ -2149,6 +2205,8 @@ VMS_stab_parse (sp, expected_type, type1, type2, Text_Psect)
   return;
 }
 
+/* Simpler interfaces into VMS_stab_parse().  */
+
 static void
 VMS_GSYM_Parse (sp, Text_Psect)
      symbolS *sp;
@@ -2157,7 +2215,6 @@ VMS_GSYM_Parse (sp, Text_Psect)
   VMS_stab_parse (sp, 'G', (N_UNDF | N_EXT), (N_DATA | N_EXT), Text_Psect);
 }
 
-
 static void
 VMS_LCSYM_Parse (sp, Text_Psect)
      symbolS *sp;
@@ -2174,30 +2231,30 @@ 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
+   is in scope.  I am still not completely comfortable with this but
+   as I learn more, I seem to get a better handle on what is going on.
+   Caveat Emptor.  */
 
-/* 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 is in scope.  I am still not
- * completely comfortable with this but as I learn more, I seem to get a better
- * handle on what is going on.
- * Caveat Emptor.
- */
 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;
+  struct VMS_DBG_Symbol *spnt;
   char *pnt;
   char *pnt1;
   char *str;
   int dbx_type;
-  struct VMS_DBG_Symbol *spnt;
   int len;
   int i = 0;
   int bcnt = 0;
   int Min_Offset = -1;         /* min PC of validity */
   int Max_Offset = 0;          /* max PC of validity */
-  symbolS *symbolP;
 
   for (symbolP = sp; symbolP; symbolP = symbol_next (symbolP))
     {
@@ -2219,48 +2276,45 @@ VMS_RSYM_Parse (sp, Current_Routine, Text_Psect)
        break;
       if (S_GET_RAW_TYPE (symbolP) == N_FUN)
        {
-         pnt=(char*) strchr (S_GET_NAME (symbolP), ':') + 1;
+         pnt = (char *) strchr (S_GET_NAME (symbolP), ':') + 1;
          if (*pnt == 'F' || *pnt == 'f') break;
        }
     }
 
-/* Check to see that the addresses were defined.  If not, then there were no
- * brackets in the function, and we must try to search for the next function.
- * Since functions can be in any order, we should search all of the symbol
* list to find the correct ending address.  */
+  /* Check to see that the addresses were defined.  If not, then there
+     were no brackets in the function, and we must try to search for
+     the next function.  Since functions can be in any order, we should
    search all of the symbol list to find the correct ending address.  */
   if (Min_Offset == -1)
     {
       int Max_Source_Offset;
       int This_Offset;
+
       Min_Offset = S_GET_VALUE (sp);
+      Max_Source_Offset = Min_Offset;  /* just in case no N_SLINEs found */
       for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
-       {
-         /*
-          *    Dispatch on STAB type
-          */
-         switch (S_GET_RAW_TYPE (symbolP))
-           {
-           case N_TEXT | N_EXT:
-             This_Offset = S_GET_VALUE (symbolP);
-             if ((This_Offset > Min_Offset) && (This_Offset < Max_Offset))
-               Max_Offset = This_Offset;
-             break;
-           case N_SLINE:
-             This_Offset = S_GET_VALUE (symbolP);
-             if (This_Offset > Max_Source_Offset)
-               Max_Source_Offset = This_Offset;
-             break;
-           }
-       }
-/* if this is the last routine, then we use the PC of the last source line
- * as a marker of the max PC for which this reg is valid */
+       switch (S_GET_RAW_TYPE (symbolP))
+         {
+         case N_TEXT | N_EXT:
+           This_Offset = S_GET_VALUE (symbolP);
+           if (This_Offset > Min_Offset && This_Offset < Max_Offset)
+             Max_Offset = This_Offset;
+           break;
+         case N_SLINE:
+           This_Offset = S_GET_VALUE (symbolP);
+           if (This_Offset > Max_Source_Offset)
+             Max_Source_Offset = This_Offset;
+           break;
+         }
+      /* If this is the last routine, then we use the PC of the last source
+         line as a marker of the max PC for which this reg is valid.  */
       if (Max_Offset == 0x7fffffff)
        Max_Offset = Max_Source_Offset;
     }
+
   dbx_type = 0;
   str = S_GET_NAME (sp);
-  pnt = (char *) strchr (str, ':');
-  if (pnt == (char *) NULL)
+  if ((pnt = (char *) strchr (str, ':')) == 0)
     return;                    /* no colon present */
   pnt1 = pnt;                  /* save this for later*/
   pnt++;
@@ -2299,18 +2353,18 @@ 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
- * they are.  All others we can handle with a normal forward reference.
- */
+/* 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
+   they are.  All others we can handle with a normal forward reference.  */
+
 static int
 forward_reference (pnt)
      char *pnt;
 {
+  struct VMS_DBG_Symbol *spnt, *spnt1;
   int i;
-  struct VMS_DBG_Symbol *spnt;
-  struct VMS_DBG_Symbol *spnt1;
+
   pnt = cvt_integer (pnt + 1, &i);
   if (*pnt == ';')
     return 0;                  /* no forward references */
@@ -2319,26 +2373,20 @@ forward_reference (pnt)
       pnt = (char *) strchr (pnt, ':');
       pnt = cvt_integer (pnt + 1, &i);
       spnt = find_symbol (i);
-      if (spnt) {
-       while (spnt->advanced == POINTER || spnt->advanced == ARRAY)
+      while (spnt && (spnt->advanced == POINTER || spnt->advanced == ARRAY))
        {
-         i = spnt->type2;
          spnt1 = find_symbol (spnt->type2);
-         if ((spnt->advanced == ARRAY) &&
-             (spnt1 == (struct VMS_DBG_Symbol *) NULL))
+         if (spnt->advanced == ARRAY && !spnt1)
            return 1;
-         if (spnt1 == (struct VMS_DBG_Symbol *) NULL)
-           break;
          spnt = spnt1;
        }
-      }
       pnt = cvt_integer (pnt + 1, &i);
       pnt = cvt_integer (pnt + 1, &i);
-  } while (*++pnt != ';');
+    } while (*++pnt != ';');
   return 0;                    /* no forward refences found */
 }
 
-/* Used to check a single element of a structure on the final pass*/
+/* Used to check a single element of a structure on the final pass.  */
 
 static int
 final_forward_reference (spnt)
@@ -2349,28 +2397,30 @@ final_forward_reference (spnt)
   while (spnt && (spnt->advanced == POINTER || spnt->advanced == ARRAY))
     {
       spnt1 = find_symbol (spnt->type2);
-      if (spnt->advanced == ARRAY && !spnt1) return 1;
+      if (spnt->advanced == ARRAY && !spnt1)
+       return 1;
       spnt = spnt1;
     }
   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 info for the
- * debugger that describes the struct/union/enum, so that further references
- * to these data types will be by number
- *     We have to process pointers right away, since there can be references
- * to them later in the same stabs directive.  We cannot have forward
- * references to pointers, (but we can have a forward reference to a pointer to
- * a structure/enum/union) and this is why we process them immediately.
- * After we process the pointer, then we search for defs that are nested even
- * deeper.
- * 8/15/92: We have to process arrays right away too, because there can
- * be multiple references to identical array types in one structure
- * definition, and only the first one has the definition.  (We tend to
- * parse from the back going forward.
- */
+/* 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
+   info for the debugger that describes the struct/union/enum, so that
+   further references to these data types will be by number
+
+   We have to process pointers right away, since there can be references
+   to them later in the same stabs directive.  We cannot have forward
+   references to pointers, (but we can have a forward reference to a
+   pointer to a structure/enum/union) and this is why we process them
+   immediately.  After we process the pointer, then we search for defs
+   that are nested even deeper.
+
+   8/15/92: We have to process arrays right away too, because there can
+   be multiple references to identical array types in one structure
+   definition, and only the first one has the definition.  */
+
 static int
 VMS_typedef_parse (str)
      char *str;
@@ -2385,13 +2435,12 @@ VMS_typedef_parse (str)
   struct VMS_DBG_Symbol *spnt;
   struct VMS_DBG_Symbol *spnt1;
 
-/* check for any nested def's */
+  /* check for any nested def's */
   pnt = (char *) strchr (str + 1, '=');
-  if ((pnt != (char *) NULL) && (*(str + 1) != '*')
-    && (str[1] != 'a' || str[2] != 'r'))
-    if (VMS_typedef_parse (pnt) == 1)
-      return 1;
-/* now find dbx_type of entry */
+  if (pnt && str[1] != '*' && (str[1] != 'a' || str[2] != 'r')
+      && VMS_typedef_parse (pnt) == 1)
+    return 1;
+  /* now find dbx_type of entry */
   pnt = str - 1;
   if (*pnt == 'c')
     {                          /* check for static constants */
@@ -2403,7 +2452,7 @@ VMS_typedef_parse (str)
   pnt++;                       /* and get back to the number */
   cvt_integer (pnt, &i1);
   spnt = find_symbol (i1);
-/* first we see if this has been defined already, due to a forward reference*/
+  /* first see if this has been defined already, due to forward reference */
   if (!spnt)
     {
       i2 = SYMTYP_HASH (i1);
@@ -2414,15 +2463,13 @@ VMS_typedef_parse (str)
       spnt->type2 = spnt->VMS_type = spnt->data_size = 0;
       spnt->index_min = spnt->index_max = spnt->struc_numb = 0;
     }
-/* for structs and unions, do a partial parse, otherwise we sometimes get
- * circular definitions that are impossible to resolve. We read enough info
- * so that any reference to this type has enough info to be resolved
- */
+  /*
+   * For structs and unions, do a partial parse, otherwise we sometimes get
+   * circular definitions that are impossible to resolve.  We read enough
+   * info so that any reference to this type has enough info to be resolved.
+   */
   pnt = str + 1;               /* point to character past equal sign */
-  if ((*pnt == 'u') || (*pnt == 's'))
-    {
-    }
-  if ((*pnt <= '9') && (*pnt >= '0'))
+  if (*pnt >= '0' && *pnt <= '9')
     {
       if (type_check ("void"))
        {                       /* this is the void symbol */
@@ -2444,11 +2491,11 @@ VMS_typedef_parse (str)
          strcpy (str, pnt1);
          return 0;
        }
-      as_tsktsk ("debugginer output: %d is an unknown untyped variable.",
+      as_tsktsk (_("debugginer output: %d is an unknown untyped variable."),
                 spnt->dbx_type);
       return 1;                        /* do not know what this is */
     }
-/* now define this module*/
+
   pnt = str + 1;               /* point to character past equal sign */
   switch (*pnt)
     {
@@ -2662,7 +2709,7 @@ VMS_typedef_parse (str)
              /* check if this is a forward reference */
              if (final_pass && final_forward_reference (spnt1))
                {
-                 as_tsktsk ("debugger output: structure element `%s' has undefined type",
+                 as_tsktsk (_("debugger output: structure element `%s' has undefined type"),
                           pnt2);
                  continue;
                }
@@ -2773,12 +2820,12 @@ VMS_typedef_parse (str)
     default:
       spnt->advanced = UNKNOWN;
       spnt->VMS_type = 0;
-      as_tsktsk ("debugger output: %d is an unknown type of variable.",
+      as_tsktsk (_("debugger output: %d is an unknown type of variable."),
                 spnt->dbx_type);
       return 1;                        /* unable to decipher */
     }
-/* this removes the evidence of the definition so that the outer levels of
-parsing do not have to worry about it */
+  /* This removes the evidence of the definition so that the outer levels
+     of parsing do not have to worry about it.  */
   pnt = str;
   while (*pnt1 != '\0')
     *pnt++ = *pnt1++;
@@ -2786,18 +2833,15 @@ parsing do not have to worry about it */
   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
+   types, and these cannot be resolved until we have completed the parse.
+
+   Also check and see if we are using continuation stabs, if we are, then
+   paste together the entire contents of the stab before we pass it to
+   VMS_typedef_parse.  */
 
-/*
- * 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 types, and these cannot be resolved until we have completed
- * the parse.
- *
- * Also check and see if we are using continuation stabs, if we are, then
- * paste together the entire contents of the stab before we pass it to 
- * VMS_typedef_parse.
- */
 static void
 VMS_LSYM_Parse ()
 {
@@ -2855,7 +2899,7 @@ VMS_LSYM_Parse ()
                      tlen += strlen (str);
                      parse_buffer = (char *) xmalloc (tlen + 1);
                      strcpy (parse_buffer, S_GET_NAME (sp));
-                     pnt2 = parse_buffer + strlen(parse_buffer) - 1;
+                     pnt2 = parse_buffer + strlen (parse_buffer) - 1;
                      *pnt2 = '\0';
                      spnext = sp;
                      do {
@@ -2864,19 +2908,18 @@ VMS_LSYM_Parse ()
                        strcat (pnt2, str);
                        pnt2 +=  strlen (str) - 1;
                        *str = '\0';  /* Erase this string  */
+                    /* S_SET_NAME (spnext, str); */
                        if (*pnt2 != '?') break;
                        *pnt2 = '\0';
-                     } while (1 == 1);
+                     } while (1);
                      str = parse_buffer;
                      symbol_name = str;
                    }
-                 pnt = (char *) strchr (str, ':');
-                 if (pnt != (char *) NULL)
+                 if ((pnt = (char *) strchr (str, ':')) != 0)
                    {
                      *pnt = '\0';
                      pnt1 = pnt + 1;
-                     pnt2 = (char *) strchr (pnt1, '=');
-                     if (pnt2 != (char *) NULL)
+                     if ((pnt2 = (char *) strchr (pnt1, '=')) != 0)
                        incomplete += VMS_typedef_parse (pnt2);
                      if (parse_buffer)
                        {
@@ -2884,9 +2927,10 @@ VMS_LSYM_Parse ()
                              contain name:nn.  If it does not, then we
                              are in real trouble.  Anyway, this is always
                              shorter than the original line.  */
-                         strcpy (S_GET_NAME (sp), parse_buffer);
-                         free (parse_buffer);
-                         parse_buffer = 0;
+                         pnt2 = S_GET_NAME (sp);
+                         strcpy (pnt2, parse_buffer);
+                      /* S_SET_NAME (sp, pnt2); */
+                         free (parse_buffer),  parse_buffer = 0;
                        }
                      *pnt = ':';       /* put back colon to restore dbx_type */
                    }
@@ -2895,30 +2939,32 @@ VMS_LSYM_Parse ()
            }                   /* if */
        }                       /*for*/
       pass++;
-/* Make one last pass, if needed, and define whatever we can that is left */
+      /*
+       * Make one last pass, if needed, and define whatever we can
+       * that is left.
+       */
       if (final_pass == 0 && incomplete == incom1)
-        {
-          final_pass = 1;
-         incom1 ++;  /* Force one last pass through */
+       {
+         final_pass = 1;
+         incom1++;     /* Force one last pass through */
        }
-  } while ((incomplete != 0) && (incomplete != incom1));
+  } while (incomplete != 0 && incomplete != incom1);
   /* repeat until all refs resolved if possible */
-/*     if (pass > 1) printf (" Required %d passes\n", pass);*/
+/*     if (pass > 1) printf (" Required %d passes\n", pass); */
   if (incomplete != 0)
     {
-      as_tsktsk ("debugger output: Unable to resolve %d circular references.",
+      as_tsktsk (_("debugger output: Unable to resolve %d circular references."),
                 incomplete);
     }
   fpnt = f_ref_root;
   symbol_name = "\0";
-  while (fpnt != (struct forward_ref *) NULL)
+  while (fpnt)
     {
       if (fpnt->resolved != 'Y')
        {
-         if (find_symbol (fpnt->dbx_type) !=
-             (struct VMS_DBG_Symbol *) NULL)
+         if (find_symbol (fpnt->dbx_type))
            {
-             as_tsktsk ("debugger forward reference error, dbx type %d",
+             as_tsktsk (_("debugger forward reference error, dbx type %d"),
                         fpnt->dbx_type);
              break;
            }
@@ -2970,12 +3016,10 @@ Define_Local_Symbols (s0P, s2P, Current_Routine, Text_Psect)
     }                          /* for */
 }
 
-\f
-/* 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 of which scope
- * we are currently in.
- */
+/* 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
+   of which scope we are currently in.  */
 
 static symbolS *
 Define_Routine (s0P, Level, Current_Routine, Text_Psect)
@@ -3056,7 +3100,6 @@ get_VMS_time_on_unix (Now)
 }
 #endif /* not VMS */
 
-
 /* Write the MHD (Module Header) records.  */
 
 static void
@@ -3101,7 +3144,7 @@ Write_VMS_MHD_Records ()
          cp++;
          continue;
        }
-      *cp1++ = islower (*cp) ? toupper (*cp++) : *cp++;
+      *cp1++ = TOUPPER (*cp++);
     }
   *cp1 = '\0';
 
@@ -3112,7 +3155,7 @@ Write_VMS_MHD_Records ()
   if (strlen (Module_Name) > 31)
     {
       if (flag_hash_long_names)
-       as_tsktsk ("Module name truncated: %s\n", Module_Name);
+       as_tsktsk (_("Module name truncated: %s\n"), Module_Name);
       Module_Name[31] = '\0';
     }
   PUT_COUNTED_STRING (Module_Name);
@@ -3155,7 +3198,7 @@ Write_VMS_MHD_Records ()
       cp = "GNU AS  V";
       while (*cp)
        PUT_CHAR (*cp++);
-      cp = GAS_VERSION;
+      cp = VERSION;
     }
   while (*cp >= ' ')
     PUT_CHAR (*cp++);
@@ -3163,7 +3206,6 @@ Write_VMS_MHD_Records ()
   Flush_VMS_Object_Record_Buffer ();
 }
 
-
 /* Write the EOM (End Of Module) record.  */
 
 static void
@@ -3179,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
    */
@@ -3285,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;
        }
@@ -3329,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)
@@ -3344,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;
                }
            }
@@ -3391,7 +3433,7 @@ VMS_Case_Hack_Symbol (In, Out)
    */
   *Out = 0;
   if (truncate == 1 && flag_hash_long_names && flag_show_after_trunc)
-    as_tsktsk ("Symbol %s replaced by %s\n", old_name, new_name);
+    as_tsktsk (_("Symbol %s replaced by %s\n"), old_name, new_name);
 }
 \f
 
@@ -3401,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;
@@ -3509,7 +3550,8 @@ 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
 
 /*
  *     Define a global symbol (or possibly a local one).
@@ -3555,12 +3597,18 @@ VMS_Global_Symbol_Spec (Name, Psect_Number, Psect_Offset, Flags)
     }
   else
     {
+      int sym_flags;
+
       /*
        *       Definition
        *[ assert (LSY_S_M_DEF == GSY_S_M_DEF && LSY_S_M_REL == GSY_S_M_REL); ]
        */
-      PUT_SHORT (((Flags & GBLSYM_VAL) == 0) ?
-                 GSY_S_M_DEF | GSY_S_M_REL : GSY_S_M_DEF);
+      sym_flags = GSY_S_M_DEF;
+      if (Flags & GBLSYM_WEAK)
+       sym_flags |= GSY_S_M_WEAK;
+      if ((Flags & GBLSYM_VAL) == 0)
+       sym_flags |= GSY_S_M_REL;
+      PUT_SHORT (sym_flags);
       if ((Flags & GBLSYM_LCL) != 0)   /* local symbols have extra field */
        PUT_SHORT (Current_Environment);
       /*
@@ -3640,27 +3688,35 @@ 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,SHR,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_SHR|GPS_S_M_RD|GPS_S_M_WRT);
+                         |GPS_S_M_RD|GPS_S_M_WRT);
       break;
     case ps_CONST:
-      /* Const data psects are:  PIC,OVR,REL,GBL,SHR,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_SHR|GPS_S_M_RD);
+                         |GPS_S_M_RD);
+      break;
+    case ps_CTORS:
+      /* 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.  */
+      Psect_Attributes = (GPS_S_M_PIC|GPS_S_M_REL|GPS_S_M_GBL|GPS_S_M_RD);
       break;
     default:
       /* impossible */
-      error ("Unknown VMS psect type (%ld)", (long) Type);
+      error (_("Unknown VMS psect type (%ld)"), (long) Type);
       break;
     }
   /*
@@ -3701,7 +3757,7 @@ VMS_Psect_Spec (Name, Size, Type, vsp)
          /* In this case we still generate the psect */
          break;
        default:
-         as_fatal ("Globalsymbol attribute for symbol %s was unexpected.",
+         as_fatal (_("Globalsymbol attribute for symbol %s was unexpected."),
                    Name);
          break;
        }                       /* switch */
@@ -3774,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.  */
 
@@ -3851,8 +3906,8 @@ VMS_Emit_Globalvalues (text_siz, data_siz, Data_Segment)
            case N_DATA | N_EXT:
              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 + 
+               error (_("Invalid data type for globalvalue"));
+             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 */
@@ -3863,7 +3918,7 @@ VMS_Emit_Globalvalues (text_siz, data_siz, Data_Segment)
                                      GBLSYM_DEF|GBLSYM_VAL);
              break;
            default:
-             as_warn ("Invalid globalvalue of %s", stripped_name);
+             as_warn (_("Invalid globalvalue of %s"), stripped_name);
              break;
            }                   /* switch */
        }                       /* if */
@@ -4185,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;
 {
@@ -4213,7 +4268,7 @@ VMS_Fix_Indirect_Reference (Text_Psect, Offset, fragP, text_frag_root)
        *       If we couldn't find the frag, things are BAD!!
        */
       if (fragP == 0)
-       error ("Couldn't find fixup fragment when checking for indirect reference");
+       error (_("Couldn't find fixup fragment when checking for indirect reference"));
     }
   /*
    *   Check for indirect PC relative addressing mode
@@ -4479,6 +4534,12 @@ struct vms_obj_state {
   /* Psect index for uninitialized static variables.  */
   int  bss_psect;
 
+  /* Psect index for static constructors.  */
+  int  ctors_psect;
+
+  /* Psect index for static destructors.  */
+  int  dtors_psect;
+
   /* Number of bytes used for local symbol data.  */
   int  local_initd_data_size;
 
@@ -4491,18 +4552,21 @@ struct vms_obj_state {
 #define Text_Psect             vms_obj_state.text_psect
 #define Data_Psect             vms_obj_state.data_psect
 #define Bss_Psect              vms_obj_state.bss_psect
+#define Ctors_Psect            vms_obj_state.ctors_psect
+#define Dtors_Psect            vms_obj_state.dtors_psect
 #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
 \f
 
 /* Perform text segment fixups.  */
 
 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;
 {
@@ -4547,14 +4611,14 @@ vms_fixup_text_section (text_siz, text_frag_root, data_frag_root)
          /* They need to be in the same segment.  */
          if (S_GET_RAW_TYPE (fixP->fx_subsy) !=
              S_GET_RAW_TYPE (fixP->fx_addsy))
-           error ("Fixup data addsy and subsy don't have the same type");
+           error (_("Fixup data addsy and subsy don't have the same type"));
          /* And they need to be in one that we can check the psect on.  */
          if ((S_GET_TYPE (fixP->fx_addsy) != N_DATA) &&
                    (S_GET_TYPE (fixP->fx_addsy) != N_TEXT))
-           error ("Fixup data addsy and subsy don't have an appropriate type");
+           error (_("Fixup data addsy and subsy don't have an appropriate type"));
          /* This had better not be PC relative!  */
          if (fixP->fx_pcrel)
-           error ("Fixup data is erroneously \"pcrel\"");
+           error (_("Fixup data is erroneously \"pcrel\""));
          /* Subtract their values to get the difference.  */
          dif = S_GET_VALUE (fixP->fx_addsy) - S_GET_VALUE (fixP->fx_subsy);
          md_number_to_chars (Local, (valueT)dif, fixP->fx_size);
@@ -4570,11 +4634,11 @@ vms_fixup_text_section (text_siz, text_frag_root, data_frag_root)
            }           /* if fx_subsy && fx_addsy */
       /* Size will HAVE to be "long".  */
       if (fixP->fx_size != 4)
-       error ("Fixup datum is not a longword");
+       error (_("Fixup datum is not a longword"));
       /* Symbol must be "added" (if it is ever
         subtracted we can fix this assumption).  */
       if (fixP->fx_addsy == 0)
-       error ("Fixup datum is not \"fixP->fx_addsy\"");
+       error (_("Fixup datum is not \"fixP->fx_addsy\""));
       /* Store the symbol value in a PIC fashion.  */
       VMS_Store_PIC_Symbol_Reference (fixP->fx_addsy,
                                      fixP->fx_offset,
@@ -4599,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;
@@ -4630,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;
@@ -4689,14 +4754,14 @@ vms_fixup_data_section (data_siz, text_siz)
              /* They need to be in the same segment.  */
              if (S_GET_RAW_TYPE (fixP->fx_subsy) !=
                  S_GET_RAW_TYPE (fixP->fx_addsy))
-               error ("Fixup data addsy and subsy don't have the same type");
+               error (_("Fixup data addsy and subsy don't have the same type"));
              /* And they need to be in one that we can check the psect on.  */
              if ((S_GET_TYPE (fixP->fx_addsy) != N_DATA) &&
                  (S_GET_TYPE (fixP->fx_addsy) != N_TEXT))
-               error ("Fixup data addsy and subsy don't have an appropriate type");
+               error (_("Fixup data addsy and subsy don't have an appropriate type"));
              /* This had better not be PC relative!  */
              if (fixP->fx_pcrel)
-               error ("Fixup data is erroneously \"pcrel\"");
+               error (_("Fixup data is erroneously \"pcrel\""));
              /* Subtract their values to get the difference.  */
              dif = S_GET_VALUE (fixP->fx_addsy) - S_GET_VALUE (fixP->fx_subsy);
              md_number_to_chars (Local, (valueT)dif, fixP->fx_size);
@@ -4715,11 +4780,11 @@ vms_fixup_data_section (data_siz, text_siz)
                }
          /* Size will HAVE to be "long".  */
          if (fixP->fx_size != 4)
-           error ("Fixup datum is not a longword");
+           error (_("Fixup datum is not a longword"));
          /* Symbol must be "added" (if it is ever
             subtracted we can fix this assumption).  */
          if (fixP->fx_addsy == 0)
-           error ("Fixup datum is not \"fixP->fx_addsy\"");
+           error (_("Fixup datum is not \"fixP->fx_addsy\""));
          /* Store the symbol value in a PIC fashion.  */
          VMS_Store_PIC_Symbol_Reference (fixP->fx_addsy,
                                          fixP->fx_offset,
@@ -4734,6 +4799,34 @@ vms_fixup_data_section (data_siz, text_siz)
 
     }                  /* data fix loop */
 }
+
+/* Perform ctors/dtors segment fixups.  */
+
+static void
+vms_fixup_xtors_section (symbols, sect_no)
+       struct VMS_Symbol *symbols;
+       int sect_no ATTRIBUTE_UNUSED;
+{
+  register struct VMS_Symbol *vsp;
+
+  /* Run through all the symbols and store the data.  */
+  for (vsp = symbols; vsp; vsp = vsp->Next)
+    {
+      register symbolS *sp;
+
+      /* Set relocation base.  */
+      VMS_Set_Psect (vsp->Psect_Index, vsp->Psect_Offset, OBJ_S_C_TIR);
+
+      sp = vsp->Symbol;
+      /* Stack the Psect base with its offset.  */
+      VMS_Set_Data (Text_Psect, S_GET_VALUE (sp), OBJ_S_C_TIR, 0);
+    }
+  /* Flush the buffer if it is more than 75% full.  */
+  if (Object_Record_Offset > (sizeof (Object_Record_Buffer) * 3 / 4))
+    Flush_VMS_Object_Record_Buffer ();
+
+  return;
+}
 \f
 
 /* Define symbols for the linker.  */
@@ -4747,23 +4840,25 @@ global_symbol_directory (text_siz, data_siz)
   register struct VMS_Symbol *vsp;
   int Globalref, define_as_global_symbol;
 
-#ifndef gxx_bug_fixed
-  /*
-   * The g++ compiler does not write out external references to vtables
-   * correctly.  Check for this and holler if we see it happening.
-   * If that compiler bug is ever fixed we can remove this.
-   * (Jun'95:  gcc 2.7.0's cc1plus still exhibits this behavior.)
-   */
+#if 0
+  /* The g++ compiler does not write out external references to
+     vtables correctly.  Check for this and holler if we see it
+     happening.  If that compiler bug is ever fixed we can remove
+     this.
+
+     (Jun'95: gcc 2.7.0's cc1plus still exhibits this behavior.)
+
+     This was reportedly fixed as of June 2, 1998.   */
+
   for (sp = symbol_rootP; sp; sp = symbol_next (sp))
     if (S_GET_RAW_TYPE (sp) == N_UNDF && IS_GXX_VTABLE (sp))
       {
        S_SET_TYPE (sp, N_UNDF | N_EXT);
        S_SET_OTHER (sp, 1);
-       as_warn ("g++ wrote an extern reference to `%s' as a routine.\n%s",
-                S_GET_NAME (sp),
-                "I will fix it, but I hope that it was not really a routine.");
+       as_warn (_("g++ wrote an extern reference to `%s' as a routine.\nI will fix it, but I hope that it was note really a routine."),
+                S_GET_NAME (sp));
       }
-#endif /* gxx_bug_fixed */
+#endif
 
   /*
    * Now scan the symbols and emit the appropriate GSD records
@@ -4870,33 +4965,65 @@ global_symbol_directory (text_siz, data_siz)
        /* Global Text definition.  */
        case N_TEXT | N_EXT:
          {
-           unsigned short Entry_Mask;
-
-           /* Get the entry mask.  */
-           fragP = sp->sy_frag;
-           /* First frag might be empty if we're generating listings.
-              So skip empty rs_fill frags.  */
-           while (fragP && fragP->fr_type == rs_fill && fragP->fr_fix == 0)
-             fragP = fragP->fr_next;
-
-           /* If first frag doesn't contain the data, what do we do?
-              If it's possibly smaller than two bytes, that would
-              imply that the entry mask is not stored where we're
-              expecting it.
-
-              If you can find a test case that triggers this, report
-              it (and tell me what the entry mask field ought to be),
-              and I'll try to fix it.  KR */
-           if (fragP->fr_fix < 2)
-             abort ();
-
-           Entry_Mask = (fragP->fr_literal[0] & 0x00ff) |
-                        ((fragP->fr_literal[1] & 0x00ff) << 8);
-           /* Define the procedure entry point.  */
-           VMS_Procedure_Entry_Pt (S_GET_NAME (sp),
+
+           if (IS_GXX_XTOR (sp))
+             {
+               vsp = (struct VMS_Symbol *) xmalloc (sizeof *vsp);
+               vsp->Symbol = sp;
+               vsp->Size = XTOR_SIZE;
+               sp->sy_obj = vsp;
+               switch ((S_GET_NAME (sp))[10])
+                 {
+                   case 'I':
+                     vsp->Psect_Index = Ctors_Psect;
+                     vsp->Psect_Offset = (Ctors_Symbols==0)?0:(Ctors_Symbols->Psect_Offset+XTOR_SIZE);
+                     vsp->Next = Ctors_Symbols;
+                     Ctors_Symbols = vsp;
+                     break;
+                   case 'D':
+                     vsp->Psect_Index = Dtors_Psect;
+                     vsp->Psect_Offset = (Dtors_Symbols==0)?0:(Dtors_Symbols->Psect_Offset+XTOR_SIZE);
+                     vsp->Next = Dtors_Symbols;
+                     Dtors_Symbols = vsp;
+                     break;
+                   case 'G':
+                     as_warn (_("Can't handle global xtors symbols yet."));
+                     break;
+                   default:
+                     as_warn (_("Unknown %s"), S_GET_NAME (sp));
+                     break;
+                 }
+             }
+           else
+             {
+               unsigned short Entry_Mask;
+
+               /* Get the entry mask.  */
+               fragP = sp->sy_frag;
+               /* First frag might be empty if we're generating listings.
+                  So skip empty rs_fill frags.  */
+               while (fragP && fragP->fr_type == rs_fill && fragP->fr_fix == 0)
+                 fragP = fragP->fr_next;
+
+               /* If first frag doesn't contain the data, what do we do?
+                  If it's possibly smaller than two bytes, that would
+                  imply that the entry mask is not stored where we're
+                  expecting it.
+
+                  If you can find a test case that triggers this, report
+                  it (and tell me what the entry mask field ought to be),
+                  and I'll try to fix it.  KR */
+               if (fragP->fr_fix < 2)
+                 abort ();
+
+               Entry_Mask = (fragP->fr_literal[0] & 0x00ff) |
+                            ((fragP->fr_literal[1] & 0x00ff) << 8);
+               /* Define the procedure entry point.  */
+               VMS_Procedure_Entry_Pt (S_GET_NAME (sp),
                                    Text_Psect,
                                    S_GET_VALUE (sp),
                                    Entry_Mask);
+             }
            break;
          }
 
@@ -4948,7 +5075,7 @@ global_symbol_directory (text_siz, data_siz)
          /*
           *    Error otherwise.
           */
-         as_tsktsk ("unhandled stab type %d", S_GET_TYPE (sp));
+         as_tsktsk (_("unhandled stab type %d"), S_GET_TYPE (sp));
          break;
        }
 
@@ -4975,7 +5102,7 @@ local_symbols_DST (s0P, Current_Routine)
   char *s0P_name, *pnt0, *pnt1;
 
   s0P_name = S_GET_NAME (s0P);
-  if (*++s0P_name != '_')
+  if (*s0P_name++ != '_')
     return;
 
   for (s1P = Current_Routine; s1P; s1P = symbol_next (s1P))
@@ -5002,7 +5129,6 @@ local_symbols_DST (s0P, Current_Routine)
     }
 }
 
-
 /* Construct and output the debug symbol table.  */
 
 static void
@@ -5301,6 +5427,8 @@ vms_write_object_file (text_siz, data_siz, bss_siz, text_frag_root,
   Text_Psect = -1;             /* Text Psect Index   */
   Data_Psect = -2;             /* Data Psect Index   JF: Was -1 */
   Bss_Psect = -3;              /* Bss Psect Index    JF: Was -1 */
+  Ctors_Psect = -4;            /* Ctors Psect Index  */
+  Dtors_Psect = -5;            /* Dtors Psect Index  */
   /* Initialize other state variables.  */
   Data_Segment = 0;
   Local_Initd_Data_Size = 0;
@@ -5324,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  *******/
 
   /*
@@ -5368,6 +5495,29 @@ 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";
+      Ctors_Psect = Psect_Number++;
+      VMS_Psect_Spec (ps_name, Ctors_Symbols->Psect_Offset + XTOR_SIZE,
+                     ps_CTORS, 0);
+      VMS_Global_Symbol_Spec (ps_name, Ctors_Psect,
+                                 0, GBLSYM_DEF|GBLSYM_WEAK);
+      for (vsp = Ctors_Symbols; vsp; vsp = vsp->Next)
+       vsp->Psect_Index = Ctors_Psect;
+    }
+
+  if (Dtors_Symbols != 0)
+    {
+      char *ps_name = "$dtors";
+      Dtors_Psect = Psect_Number++;
+      VMS_Psect_Spec (ps_name, Dtors_Symbols->Psect_Offset + XTOR_SIZE,
+                     ps_DTORS, 0);
+      VMS_Global_Symbol_Spec (ps_name, Dtors_Psect,
+                                 0, GBLSYM_DEF|GBLSYM_WEAK);
+      for (vsp = Dtors_Symbols; vsp; vsp = vsp->Next)
+       vsp->Psect_Index = Dtors_Psect;
+    }
 
   /*******  Text Information and Relocation Records  *******/
 
@@ -5385,12 +5535,20 @@ vms_write_object_file (text_siz, data_siz, bss_siz, text_frag_root,
       free (Data_Segment),  Data_Segment = 0;
     }
 
+  if (Ctors_Symbols != 0)
+    {
+      vms_fixup_xtors_section (Ctors_Symbols, Ctors_Psect);
+    }
+
+  if (Dtors_Symbols != 0)
+    {
+      vms_fixup_xtors_section (Dtors_Symbols, Dtors_Psect);
+    }
 
   /*******  Debugger Symbol Table Records  *******/
 
   vms_build_DST (text_siz);
 
-
   /*******  Wrap things up  *******/
 
   /*
@@ -5406,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 */