/* vms.c -- Write out a VAX/VMS object file
- Copyright (C) 1987, 88, 92, 94, 95, 97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1987, 88, 92, 94, 95, 97, 98, 2000
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#include "subsegs.h"
#include "obstack.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*/
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().
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)
*/
{0, 0, 0},
}; /* obj_pseudo_table */
-
/* Routine to perform RESOLVE_SYMBOL_REDEFINITION(). */
int
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."
return;
}
-
void
obj_read_begin_hook ()
{
return;
}
-
void
obj_crawl_symbol_chain (headers)
object_headers *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);
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);
/****** VMS OBJECT FILE HACKING ROUTINES *******/
-
/* Create the VMS object file. */
static void
Current_Object_Record_Type = -1;
}
-
/* Flush the object record buffer to the object file. */
static void
if (Object_Record_Offset == 0)
return;
-#ifndef VMS /* For cross-assembly purposes. */
+#ifndef VMS /* For cross-assembly purposes. */
{
char RecLen[2];
Object_Record_Offset = 0;
}
-
/* Declare a particular type of object file record. */
static void
Current_Object_Record_Type = Type;
}
-
/* Close the VMS Object file. */
static void
/* 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;
/****** Text Information and Relocation routines ******/
-
/* Stack Psect base followed by signed, varying-sized offset.
Common to several object records. */
#undef Sta_P
}
-
/* Store immediate data in current Psect. */
static void
Flush_VMS_Object_Record_Buffer ();
}
-
/* Make a data reference. */
static void
Flush_VMS_Object_Record_Buffer ();
}
-
/* Make a debugger reference to a struct, union or enum. */
static void
Flush_VMS_Object_Record_Buffer ();
}
-
/* Make a debugger reference to partially define a struct, union or enum. */
static void
/****** Traceback Information routines ******/
-
/* Write the Traceback Module Begin record. */
static void
VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_TBT);
}
-
/* Write the Traceback Module End record. */
static void
VMS_Store_Immediate_Data (Local, 2, OBJ_S_C_TBT);
}
-
/* Write a Traceback Routine Begin record. */
static void
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
VMS_Store_Immediate_Data (Local, 7, OBJ_S_C_TBT);
}
-
/* Write a Traceback Block Begin record. */
static void
VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_DBG);
}
-
/* Write a Traceback Block End record. */
static void
/* 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.
{
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". */
/****** 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. */
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. */
* 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.
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
return pnt;
}
-
/* Search symbol list for type number dbx_type.
Return a pointer to struct. */
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
}
#endif
-
static void
fpush (value, size)
int value, size;
}
}
-
/* This routine generates the array descriptor for a given array. */
static void
}
}
-
/* 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
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
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
Lpnt = 0;
}
-
/* "novel length" type doesn't work for simple atomic types */
#define USE_BITSTRING_DESCRIPTOR(t) ((t)->advanced == BASIC)
#undef SETUP_BASIC_TYPES
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
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
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. */
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
return;
}
-
/* Simpler interfaces into VMS_stab_parse(). */
static void
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
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
return 0; /* no forward refences found */
}
-
/* Used to check a single element of a structure on the final pass. */
static int
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
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
}
}
-
static void
Define_Local_Symbols (s0P, s2P, Current_Routine, Text_Psect)
symbolS *s0P, *s2P;
} /* 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
}
#endif /* not VMS */
-
/* Write the MHD (Module Header) records. */
static void
Flush_VMS_Object_Record_Buffer ();
}
-
/* Write the EOM (End Of Module) record. */
static void
*/
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
*/
#define GLOBALSYMBOL_BIT 0x10000
#define GLOBALVALUE_BIT 0x20000
-
static void
VMS_Modify_Psect_Attributes (Name, Attribute_Pointer)
const char *Name;
#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
/*
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:
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. */
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 */
#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
return;
}
-
/* Perform data segment fixups. */
static void
}
}
-
/* Construct and output the debug symbol table. */
static void
if (data_siz > 0)
synthesize_data_segment (data_siz, text_siz, data_frag_root);
-
/******* Global Symbol Directory *******/
/*
vsp->Psect_Index = Data_Psect;
}
-
if (Ctors_Symbols != 0)
{
char *ps_name = "$ctors";
vms_fixup_xtors_section (Dtors_Symbols, Dtors_Psect);
}
-
/******* Debugger Symbol Table Records *******/
vms_build_DST (text_siz);
-
/******* Wrap things up *******/
/*
*/
Close_VMS_Object_File ();
}
-
-/* end of obj-vms.c */