contain debugging information specified by the GNU compiler
in the form of comments (the mips assembler does not support
assembly access to debug information).
- Copyright (C) 1991, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright (C) 1991, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
+ 2002, 2003 Free Software Foundation, Inc.
Contributed by Michael Meissner (meissner@cygnus.com).
This file is part of GCC.
#include "config.h"
#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
#include "version.h"
#include "intl.h"
#define saber_stop()
#endif
+/* Include getopt.h for the sake of getopt_long. */
+#include "getopt.h"
+
#ifndef __LINE__
#define __LINE__ 0
#endif
#endif
#define IS_ASM_IDENT(ch) \
- (ISALNUM (ch) || (ch) == '_' || (ch) == '.' || (ch) == '$')
+ (ISIDNUM (ch) || (ch) == '.' || (ch) == '$')
\f
/* Redefinition of storage classes as an enumeration for better
pages. On systems with a BSD malloc that define USE_MALLOC, the
MAX_CLUSTER_PAGES should be 1 less than a power of two, since malloc
adds its overhead, and rounds up to the next power of 2. Pages are
- linked together via a linked list.
-
- If PAGE_SIZE is > 4096, the string length in the shash_t structure
- can't be represented (assuming there are strings > 4096 bytes). */
+ linked together via a linked list. */
#ifndef PAGE_SIZE
-#define PAGE_SIZE 4096 /* size of varray pages */
+#define PAGE_SIZE 32768 /* size of varray pages */
#endif
-#define PAGE_USIZE ((Size_t)PAGE_SIZE)
+#define PAGE_USIZE ((Size_t) PAGE_SIZE)
#ifndef MAX_CLUSTER_PAGES /* # pages to get from system */
OBJECTS_PER_PAGE (type), /* objects_last_page */ \
}
+#define INITIALIZE_VARRAY(x,type) \
+do { \
+ (x)->object_size = sizeof (type); \
+ (x)->objects_per_page = OBJECTS_PER_PAGE (type); \
+ (x)->objects_last_page = OBJECTS_PER_PAGE (type); \
+} while (0)
+
/* Master type for indexes within the symbol table. */
typedef unsigned long symint_t;
} efdr_t;
/* Pre-initialized extended file structure. */
-static efdr_t init_file =
-{
- { /* FDR structure */
-#ifdef __alpha
- 0, /* adr: memory address of beginning of file */
- 0, /* cbLineOffset: byte offset from header for this file ln's */
- 0, /* cbLine: size of lines for this file */
- 0, /* cbSs: number of bytes in the ss */
- 0, /* rss: file name (of source, if known) */
- 0, /* issBase: file's string space */
- 0, /* isymBase: beginning of symbols */
- 0, /* csym: count file's of symbols */
- 0, /* ilineBase: file's line symbols */
- 0, /* cline: count of file's line symbols */
- 0, /* ioptBase: file's optimization entries */
- 0, /* copt: count of file's optimization entries */
- 0, /* ipdFirst: start of procedures for this file */
- 0, /* cpd: count of procedures for this file */
- 0, /* iauxBase: file's auxiliary entries */
- 0, /* caux: count of file's auxiliary entries */
- 0, /* rfdBase: index into the file indirect table */
- 0, /* crfd: count file indirect entries */
- langC, /* lang: language for this file */
- 1, /* fMerge: whether this file can be merged */
- 0, /* fReadin: true if read in (not just created) */
-#ifdef HOST_WORDS_BIG_ENDIAN
- 1, /* fBigendian: if 1, compiled on big endian machine */
-#else
- 0, /* fBigendian: if 1, compiled on big endian machine */
-#endif
- 0, /* fTrim: whether the symbol table was trimmed */
- GLEVEL_2, /* glevel: level this file was compiled with */
- 0, /* reserved: reserved for future use */
-#else
- 0, /* adr: memory address of beginning of file */
- 0, /* rss: file name (of source, if known) */
- 0, /* issBase: file's string space */
- 0, /* cbSs: number of bytes in the ss */
- 0, /* isymBase: beginning of symbols */
- 0, /* csym: count file's of symbols */
- 0, /* ilineBase: file's line symbols */
- 0, /* cline: count of file's line symbols */
- 0, /* ioptBase: file's optimization entries */
- 0, /* copt: count of file's optimization entries */
- 0, /* ipdFirst: start of procedures for this file */
- 0, /* cpd: count of procedures for this file */
- 0, /* iauxBase: file's auxiliary entries */
- 0, /* caux: count of file's auxiliary entries */
- 0, /* rfdBase: index into the file indirect table */
- 0, /* crfd: count file indirect entries */
- langC, /* lang: language for this file */
- 1, /* fMerge: whether this file can be merged */
- 0, /* fReadin: true if read in (not just created) */
-#ifdef HOST_WORDS_BIG_ENDIAN
- 1, /* fBigendian: if 1, compiled on big endian machine */
-#else
- 0, /* fBigendian: if 1, compiled on big endian machine */
-#endif
- GLEVEL_2, /* glevel: level this file was compiled with */
- 0, /* reserved: reserved for future use */
- 0, /* cbLineOffset: byte offset from header for this file ln's */
- 0, /* cbLine: size of lines for this file */
-#endif
- },
-
- (FDR *) 0, /* orig_fdr: original file header pointer */
- (char *) 0, /* name: pointer to filename */
- 0, /* name_len: length of filename */
- 0, /* void_type: ptr to aux node for void type */
- 0, /* int_type: ptr to aux node for int type */
- (scope_t *) 0, /* cur_scope: current scope being processed */
- 0, /* file_index: current file # */
- 0, /* nested_scopes: # nested scopes */
- INIT_VARRAY (char), /* strings: local string varray */
- INIT_VARRAY (SYMR), /* symbols: local symbols varray */
- INIT_VARRAY (PDR), /* procs: procedure varray */
- INIT_VARRAY (AUXU), /* aux_syms: auxiliary symbols varray */
-
- (struct efdr *) 0, /* next_file: next file structure */
-
- (shash_t **) 0, /* shash_head: string hash table */
- { 0 }, /* thash_head: type hash table */
-};
-
+static int init_file_initialized = 0;
+static efdr_t init_file;
static efdr_t *first_file; /* first file descriptor */
static efdr_t **last_file_ptr = &first_file; /* file descriptor tail */
Maybe this will be fixed in 2.10 or 2.20 of the MIPS compiler
suite, but for now go with what works. */
-static bt_t map_coff_types[ (int)T_MAX ] = {
+static const bt_t map_coff_types[ (int) T_MAX ] = {
bt_Nil, /* T_NULL */
bt_Nil, /* T_ARG */
bt_Char, /* T_CHAR */
};
/* Convert COFF storage class to ECOFF storage class. */
-static sc_t map_coff_storage[ (int)C_MAX ] = {
+static const sc_t map_coff_storage[ (int) C_MAX ] = {
sc_Nil, /* 0: C_NULL */
sc_Abs, /* 1: C_AUTO auto var */
sc_Undefined, /* 2: C_EXT external */
};
/* Convert COFF storage class to ECOFF symbol type. */
-static st_t map_coff_sym_type[ (int)C_MAX ] = {
+static const st_t map_coff_sym_type[ (int) C_MAX ] = {
st_Nil, /* 0: C_NULL */
st_Local, /* 1: C_AUTO auto var */
st_Global, /* 2: C_EXT external */
};
/* Map COFF derived types to ECOFF type qualifiers. */
-static tq_t map_coff_derived_type[ (int)DT_MAX ] = {
+static const tq_t map_coff_derived_type[ (int) DT_MAX ] = {
tq_Nil, /* 0: DT_NON no more qualifiers */
tq_Ptr, /* 1: DT_PTR pointer */
tq_Proc, /* 2: DT_FCN function */
/* Keep track of different sized allocation requests. */
-static alloc_info_t alloc_counts[ (int)alloc_type_last ];
+static alloc_info_t alloc_counts[ (int) alloc_type_last ];
\f
/* Pointers and such to the original symbol table that is read in. */
/* Macros to convert an index into a given object within the original
symbol table. */
#define CHECK(num,max,str) \
- (((unsigned long)num > (unsigned long)max) ? out_of_bounds (num, max, str, __LINE__) : 0)
+ (((unsigned long) num > (unsigned long) max) ? out_of_bounds (num, max, str, __LINE__) : 0)
#define ORIG_LINENUM(indx) (CHECK ((indx), orig_sym_hdr.cbLine, "line#"), (indx) + orig_linenum)
#define ORIG_DENSE(indx) (CHECK ((indx), orig_sym_hdr.idnMax, "dense"), (indx) + orig_dense)
static SYMR *cur_oproc_end = (SYMR *) 0; /* original proc. sym end info */
static PDR *cur_oproc_ptr = (PDR *) 0; /* current original procedure*/
static thead_t *cur_tag_head = (thead_t *) 0;/* current tag head */
-static long file_offset = 0; /* current file offset */
-static long max_file_offset = 0; /* maximum file offset */
+static unsigned long file_offset = 0; /* current file offset */
+static unsigned long max_file_offset = 0; /* maximum file offset */
static FILE *object_stream = (FILE *) 0; /* file desc. to output .o */
static FILE *obj_in_stream = (FILE *) 0; /* file desc. to input .o */
static char *progname = (char *) 0; /* program name for errors */
static long line_number = 0; /* current input line number */
static int debug = 0; /* trace functions */
static int version = 0; /* print version # */
+static int verbose = 0;
static int had_errors = 0; /* != 0 if errors were found */
static int rename_output = 0; /* != 0 if rename output file*/
static int delete_input = 0; /* != 0 if delete input after done */
#define STABS_SYMBOL "@stabs"
#endif
-static char stabs_symbol[] = STABS_SYMBOL;
+static const char stabs_symbol[] = STABS_SYMBOL;
\f
/* Forward reference for functions. See the definition for more details. */
STATIC void add_procedure PARAMS ((const char *,
const char *));
+STATIC void initialize_init_file PARAMS ((void));
+
STATIC void add_file PARAMS ((const char *,
const char *));
do...... */
typedef struct _pseudo_ops {
- const char *name; /* pseudo-op in ascii */
- int len; /* length of name to compare */
- void (*func) PARAMS ((const char *)); /* function to handle line */
+ const char *const name; /* pseudo-op in ascii */
+ const int len; /* length of name to compare */
+ void (*const func) PARAMS ((const char *)); /* function to handle line */
} pseudo_ops_t;
-static pseudo_ops_t pseudo_ops[] = {
+static const pseudo_ops_t pseudo_ops[] = {
{ "#.def", sizeof("#.def")-1, parse_def },
{ "#.begin", sizeof("#.begin")-1, parse_begin },
{ "#.bend", sizeof("#.bend")-1, parse_bend },
};
\f
+/* Command line options for getopt_long. */
+
+static const struct option options[] =
+{
+ { "version", 0, 0, 'V' },
+ { "verbose", 0, 0, 'v' },
+ { 0, 0, 0, 0 }
+};
+\f
/* Add a page to a varray object. */
STATIC void
#endif
new_links->datum = allocate_page ();
- alloc_counts[ (int)alloc_type_varray ].total_alloc++;
- alloc_counts[ (int)alloc_type_varray ].total_pages++;
+ alloc_counts[ (int) alloc_type_varray ].total_alloc++;
+ alloc_counts[ (int) alloc_type_varray ].total_pages++;
new_links->start_index = vp->num_allocated;
vp->objects_last_page = 0;
shash_t **hash_tbl; /* hash table */
symint_t *ret_hash_index; /* ptr to store hash index */
{
- register unsigned long hi;
- register Ptrdiff_t i;
- register shash_t *ptr;
- register int first_ch = *text;
+ unsigned long hi;
+ Ptrdiff_t i;
+ shash_t *ptr;
+ int first_ch = *text;
hi = hash_len;
for (i = 0; i < hash_len; i++)
const char *end_p1; /* 1st byte after string */
shash_t **ret_hash; /* return hash pointer */
{
- register Ptrdiff_t len = end_p1 - start;
- register shash_t *hash_ptr;
+ Ptrdiff_t len = end_p1 - start;
+ shash_t *hash_ptr;
symint_t hi;
if (len >= (Ptrdiff_t) PAGE_USIZE)
- fatal ("String too big (%ld bytes)", (long) len);
+ fatal ("string too big (%ld bytes)", (long) len);
hash_ptr = hash_string (start, len, hash_tbl, &hi);
if (hash_ptr == (shash_t *) 0)
{
- register char *p;
+ char *p;
if (vp->objects_last_page + len >= (long) PAGE_USIZE)
{
symint_t value; /* value of symbol */
symint_t indx; /* index to local/aux. syms */
{
- register symint_t ret;
- register SYMR *psym;
- register scope_t *pscope;
- register thead_t *ptag_head;
- register tag_t *ptag;
- register tag_t *ptag_next;
- register varray_t *vp = &cur_file_ptr->symbols;
- register int scope_delta = 0;
+ symint_t ret;
+ SYMR *psym;
+ scope_t *pscope;
+ thead_t *ptag_head;
+ tag_t *ptag;
+ tag_t *ptag_next;
+ varray_t *vp = &cur_file_ptr->symbols;
+ int scope_delta = 0;
shash_t *hash_ptr = (shash_t *) 0;
if (vp->objects_last_page == vp->objects_per_page)
ret = vp->num_allocated++;
- if (MIPS_IS_STAB(psym))
+ if (MIPS_IS_STAB (psym))
return ret;
/* Save the symbol within the hash table if this is a static
case st_End:
pscope = cur_file_ptr->cur_scope;
- if (pscope == (scope_t *)0)
+ if (pscope == (scope_t *) 0)
error ("internal error, too many st_End's");
else
{
const char *str_start; /* first byte in string */
const char *str_end_p1; /* first byte after string */
- register EXTR *psym;
- register varray_t *vp = &ext_symbols;
+ EXTR *psym;
+ varray_t *vp = &ext_symbols;
shash_t *hash_ptr = (shash_t *) 0;
str_start = ORIG_ESTRS (esym->asym.iss);
- str_end_p1 = str_start + strlen(str_start);
+ str_end_p1 = str_start + strlen (str_start);
if (debug > 1)
{
add_aux_sym_symint (aux_word)
symint_t aux_word; /* auxiliary information word */
{
- register AUXU *aux_ptr;
- register efdr_t *file_ptr = cur_file_ptr;
- register varray_t *vp = &file_ptr->aux_syms;
+ AUXU *aux_ptr;
+ efdr_t *file_ptr = cur_file_ptr;
+ varray_t *vp = &file_ptr->aux_syms;
if (vp->objects_last_page == vp->objects_per_page)
add_varray_page (vp);
int file_index;
symint_t sym_index;
{
- register AUXU *aux_ptr;
- register efdr_t *file_ptr = cur_file_ptr;
- register varray_t *vp = &file_ptr->aux_syms;
+ AUXU *aux_ptr;
+ efdr_t *file_ptr = cur_file_ptr;
+ varray_t *vp = &file_ptr->aux_syms;
if (vp->objects_last_page == vp->objects_per_page)
add_varray_page (vp);
hash_state_t state; /* whether to hash type or not */
thash_t **hash_tbl; /* pointer to hash table to use */
{
- register AUXU *aux_ptr;
- register efdr_t *file_ptr = cur_file_ptr;
- register varray_t *vp = &file_ptr->aux_syms;
+ AUXU *aux_ptr;
+ efdr_t *file_ptr = cur_file_ptr;
+ varray_t *vp = &file_ptr->aux_syms;
static AUXU init_aux;
symint_t ret;
int i;
if (state != hash_no)
{
- register thash_t *hash_ptr;
- register symint_t hi;
+ thash_t *hash_ptr;
+ symint_t hi;
hi = aux.isym & ((1 << HASHBITS) - 1);
hi %= THASH_SIZE;
for an enum bitfield. */
if (t->bitfield)
- (void) add_aux_sym_symint ((symint_t)t->sizes[t->num_sizes-1]);
+ (void) add_aux_sym_symint ((symint_t) t->sizes[t->num_sizes-1]);
/* Add tag information if needed. Structure, union, and enum
|| t->basic_type == bt_Union
|| t->basic_type == bt_Enum)
{
- register symint_t file_index = t->tag_ptr->ifd;
- register symint_t sym_index = t->tag_ptr->indx;
+ symint_t file_index = t->tag_ptr->ifd;
+ symint_t sym_index = t->tag_ptr->indx;
if (t->unknown_tag)
{
}
else
{
- register forward_t *forward_ref = allocate_forward ();
+ forward_t *forward_ref = allocate_forward ();
forward_ref->type_ptr = aux_ptr;
forward_ref->next = t->tag_ptr->forward_ref;
const char *func_start; /* 1st byte of func name */
const char *func_end_p1; /* 1st byte after func name */
{
- register PDR *new_proc_ptr;
- register efdr_t *file_ptr = cur_file_ptr;
- register varray_t *vp = &file_ptr->procs;
- register symint_t value = 0;
- register st_t proc_type = st_Proc;
- register shash_t *shash_ptr = hash_string (func_start,
- func_end_p1 - func_start,
- &orig_str_hash[0],
- (symint_t *) 0);
+ PDR *new_proc_ptr;
+ efdr_t *file_ptr = cur_file_ptr;
+ varray_t *vp = &file_ptr->procs;
+ symint_t value = 0;
+ st_t proc_type = st_Proc;
+ shash_t *shash_ptr = hash_string (func_start,
+ func_end_p1 - func_start,
+ &orig_str_hash[0],
+ (symint_t *) 0);
if (debug)
fputc ('\n', stderr);
cur_oproc_ptr = (PDR *) 0;
if (shash_ptr != (shash_t *) 0)
{
- register PDR *old_proc_ptr = shash_ptr->proc_ptr;
- register SYMR *sym_ptr = shash_ptr->sym_ptr;
+ PDR *old_proc_ptr = shash_ptr->proc_ptr;
+ SYMR *sym_ptr = shash_ptr->sym_ptr;
if (old_proc_ptr != (PDR *) 0
&& sym_ptr != (SYMR *) 0
- && ((st_t)sym_ptr->st == st_Proc || (st_t)sym_ptr->st == st_StaticProc))
+ && ((st_t) sym_ptr->st == st_Proc || (st_t) sym_ptr->st == st_StaticProc))
{
cur_oproc_begin = sym_ptr;
cur_oproc_end = shash_ptr->end_ptr;
value = sym_ptr->value;
cur_oproc_ptr = old_proc_ptr;
- proc_type = (st_t)sym_ptr->st;
+ proc_type = (st_t) sym_ptr->st;
*new_proc_ptr = *old_proc_ptr; /* initialize */
}
}
if (cur_oproc_ptr == (PDR *) 0)
- error ("Did not find a PDR block for %.*s",
+ error ("did not find a PDR block for %.*s",
(int) (func_end_p1 - func_start), func_start);
/* Determine the start of symbols. */
}
\f
+/* Initialize the init_file structure. */
+
+STATIC void
+initialize_init_file ()
+{
+ memset ((void*) &init_file, 0, sizeof (init_file));
+
+ init_file.fdr.lang = langC;
+ init_file.fdr.fMerge = 1;
+ init_file.fdr.glevel = GLEVEL_2;
+
+#ifdef HOST_WORDS_BIG_ENDIAN
+ init_file.fdr.fBigendian = 1;
+#endif
+
+ INITIALIZE_VARRAY (&init_file.strings, char);
+ INITIALIZE_VARRAY (&init_file.symbols, SYMR);
+ INITIALIZE_VARRAY (&init_file.procs, PDR);
+ INITIALIZE_VARRAY (&init_file.aux_syms, AUXU);
+
+ init_file_initialized = 1;
+}
+
/* Add a new filename, and set up all of the file relative
virtual arrays (strings, symbols, aux syms, etc.). Record
where the current file structure lives. */
{
static char zero_bytes[2] = { '\0', '\0' };
- register Ptrdiff_t len = file_end_p1 - file_start;
- register int first_ch = *file_start;
- register efdr_t *file_ptr;
+ Ptrdiff_t len = file_end_p1 - file_start;
+ int first_ch = *file_start;
+ efdr_t *file_ptr;
if (debug)
fprintf (stderr, "\tfile\t%.*s\n", (int) len, file_start);
if (file_desc.objects_last_page == file_desc.objects_per_page)
add_varray_page (&file_desc);
+ if (! init_file_initialized)
+ initialize_init_file ();
+
file_ptr = cur_file_ptr
= &file_desc.last->datum->file[ file_desc.objects_last_page++ ];
*file_ptr = init_file;
(shash_t **) 0);
if (file_end_p1 - file_start > (long) PAGE_USIZE-2)
- fatal ("Filename goes over one page boundary.");
+ fatal ("filename goes over one page boundary");
/* Push the start of the filename. We assume that the filename
will be stored at string offset 1. */
char *input_ptr; /* start of the bytes */
Size_t nitems; /* # items to move */
{
- register Size_t move_items;
- register Size_t move_bytes;
- register char *ptr;
+ Size_t move_items;
+ Size_t move_bytes;
+ char *ptr;
while (nitems > 0)
{
/* Convert storage class to string. */
STATIC const char *
-sc_to_string(storage_class)
+sc_to_string (storage_class)
sc_t storage_class;
{
- switch(storage_class)
+ switch (storage_class)
{
case sc_Nil: return "Nil,";
case sc_Text: return "Text,";
/* Convert symbol type to string. */
STATIC const char *
-st_to_string(symbol_type)
+st_to_string (symbol_type)
st_t symbol_type;
{
- switch(symbol_type)
+ switch (symbol_type)
{
case st_Nil: return "Nil,";
case st_Global: return "Global,";
read_line ()
{
static int line_split_p = 0;
- register int string_p = 0;
- register int comment_p = 0;
- register int ch;
- register char *ptr;
+ int string_p = 0;
+ int comment_p = 0;
+ int ch;
+ char *ptr;
if (cur_line_start == (char *) 0)
{ /* allocate initial page */
{
if (++cur_line_nbytes >= cur_line_alloc-1)
{
- register int num_pages = cur_line_alloc / PAGE_SIZE;
- register char *old_buffer = cur_line_start;
+ int num_pages = cur_line_alloc / PAGE_SIZE;
+ char *old_buffer = cur_line_start;
cur_line_alloc += PAGE_SIZE;
cur_line_start = (char *) allocate_multiple_pages (num_pages+1);
}
else if (ch == '\0')
- error ("Null character found in input");
+ error ("null character found in input");
else if (!comment_p)
{
if (hash_ptr == (shash_t *) 0)
{
- error ("Label %.*s not found for #.begin",
+ error ("label %.*s not found for #.begin",
(int) (end_p1 - start), start);
return;
}
if (cur_oproc_begin == (SYMR *) 0)
{
- error ("Procedure table %.*s not found for #.begin",
+ error ("procedure table %.*s not found for #.begin",
(int) (end_p1 - start), start);
return;
}
if (hash_ptr == (shash_t *) 0)
{
- error ("Label %.*s not found for #.bend", (int) (end_p1 - start), start);
+ error ("label %.*s not found for #.bend", (int) (end_p1 - start), start);
return;
}
if (cur_oproc_begin == (SYMR *) 0)
{
- error ("Procedure table %.*s not found for #.bend",
+ error ("procedure table %.*s not found for #.bend",
(int) (end_p1 - start), start);
return;
}
(void) add_local_symbol ((const char *) 0, (const char *) 0,
st_End, sc_Text,
- (symint_t)hash_ptr->sym_ptr->value - cur_oproc_begin->value,
+ (symint_t) hash_ptr->sym_ptr->value - cur_oproc_begin->value,
(symint_t) 0);
}
{
int ch2;
arg_number = strtol (arg_start, (char **) &arg_end_p1, 0);
- if (arg_end_p1 != arg_start || (ch2 = *arg_end_p1 != ';') || ch2 != ',')
+ if (arg_end_p1 != arg_start || ((ch2 = *arg_end_p1) != ';') || ch2 != ',')
arg_was_number++;
}
{
int ch2;
arg_number = strtol (arg_start, (char **) &arg_end_p1, 0);
- if (arg_end_p1 != arg_start || (ch2 = *arg_end_p1 != ';') || ch2 != ',')
+ if (arg_end_p1 != arg_start || ((ch2 = *arg_end_p1) != ';') || ch2 != ',')
arg_was_number++;
if (t_ptr == &temp_array[0])
{
int ch2;
arg_number = strtol (arg_start, (char **) &arg_end_p1, 0);
- if (arg_end_p1 != arg_start || (ch2 = *arg_end_p1 != ';') || ch2 != ',')
+ if (arg_end_p1 != arg_start || ((ch2 = *arg_end_p1) != ';') || ch2 != ',')
arg_was_number++;
if (t_ptr == &temp_array[0])
tq_t *tq_ptr = &t.type_qualifiers[0];
t.orig_type = (coff_type_t) (arg_number & N_BTMASK);
- t.basic_type = map_coff_types [(int)t.orig_type];
+ t.basic_type = map_coff_types [(int) t.orig_type];
for (i = N_TQ-1; i >= 0; i--)
{
int dt = (arg_number >> ((i * N_TQ_SHIFT) + N_BT_SHIFT)
& N_TMASK);
- if (dt != (int)DT_NON)
+ if (dt != (int) DT_NON)
*tq_ptr++ = map_coff_derived_type [dt];
}
{
if (tag_start == (char *) 0)
{
- error ("No tag specified for %.*s",
+ error ("no tag specified for %.*s",
(int) (name_end_p1 - name_start),
name_start);
return;
}
- t.tag_ptr = get_tag (tag_start, tag_end_p1, (symint_t)indexNil,
+ t.tag_ptr = get_tag (tag_start, tag_end_p1, (symint_t) indexNil,
t.basic_type);
}
for which the external symbol table is fine enough. */
if (eptr == (EXTR *) 0
- || eptr->asym.st == (int)st_Nil
+ || eptr->asym.st == (int) st_Nil
|| cur_proc_ptr != (PDR *) 0)
{
symint_t isym = add_local_symbol (name_start, name_end_p1,
parse_end (start)
const char *start; /* start of directive */
{
- register const char *start_func, *end_func_p1;
- register int ch;
- register symint_t value;
- register FDR *orig_fdr;
+ const char *start_func, *end_func_p1;
+ int ch;
+ symint_t value;
+ FDR *orig_fdr;
if (cur_file_ptr == (efdr_t *) 0)
{
orig_fdr = cur_file_ptr->orig_fdr;
value = 0;
- if (orig_fdr != (FDR *)0 && cur_oproc_end != (SYMR *) 0)
+ if (orig_fdr != (FDR *) 0 && cur_oproc_end != (SYMR *) 0)
value = cur_oproc_end->value;
else
- error ("Cannot find .end block for %.*s",
+ error ("cannot find .end block for %.*s",
(int) (end_func_p1 - start_func), start_func);
(void) add_local_symbol (start_func, end_func_p1,
parse_ent (start)
const char *start; /* start of directive */
{
- register const char *start_func, *end_func_p1;
- register int ch;
+ const char *start_func, *end_func_p1;
+ int ch;
if (cur_file_ptr == (efdr_t *) 0)
{
const char *start; /* start of directive */
{
char *p;
- register char *start_name, *end_name_p1;
+ char *start_name, *end_name_p1;
(void) strtol (start, &p, 0);
if (start == p
|| (start_name = strchr (p, '"')) == (char *) 0
|| (end_name_p1 = strrchr (++start_name, '"')) == (char *) 0)
{
- error ("Invalid .file directive");
+ error ("invalid .file directive");
return;
}
if (cur_proc_ptr != (PDR *) 0)
{
- error ("No way to handle .file within .ent/.end section");
+ error ("no way to handle .file within .ent/.end section");
return;
}
stabs_seen = 1;
(void) add_local_symbol (stabs_symbol,
stabs_symbol + sizeof (stabs_symbol),
- stNil, scInfo, -1, MIPS_MARK_STAB(0));
+ stNil, scInfo, -1, MIPS_MARK_STAB (0));
}
}
/* Read code from stabs. */
if (!ISDIGIT (*rest))
{
- error ("Invalid .stabs/.stabn directive, code is non-numeric");
+ error ("invalid .stabs/.stabn directive, code is non-numeric");
return;
}
address. The symbol type is st_Label, which should be different from
the other stabs, so that gdb can recognize it. */
- if (code == (int)N_SLINE)
+ if (code == (int) N_SLINE)
{
SYMR *sym_ptr, dummy_symr;
shash_t *shash_ptr;
/* Skip ,0, */
if (p[0] != ',' || p[1] != '0' || p[2] != ',' || !ISDIGIT (p[3]))
{
- error ("Invalid line number .stabs/.stabn directive");
+ error ("invalid line number .stabs/.stabn directive");
return;
}
ch = *++p;
if (p[-1] != ',' || ISDIGIT (ch) || !IS_ASM_IDENT (ch))
{
- error ("Invalid line number .stabs/.stabn directive");
+ error ("invalid line number .stabs/.stabn directive");
return;
}
dummy_symr.index = code;
if (dummy_symr.index != code)
{
- error ("Line number (%lu) for .stabs/.stabn directive cannot fit in index field (20 bits)",
+ error ("line number (%lu) for .stabs/.stabn directive cannot fit in index field (20 bits)",
code);
return;
if (shash_ptr == (shash_t *) 0
|| (sym_ptr = shash_ptr->sym_ptr) == (SYMR *) 0)
{
- error ("Invalid .stabs/.stabn directive, value not found");
+ error ("invalid .stabs/.stabn directive, value not found");
return;
}
if ((st_t) sym_ptr->st != st_Label)
{
- error ("Invalid line number .stabs/.stabn directive");
+ error ("invalid line number .stabs/.stabn directive");
return;
}
if (!IS_ASM_IDENT (ch) && ch != '-')
{
failure:
- error ("Invalid .stabs/.stabn directive, bad character");
+ error ("invalid .stabs/.stabn directive, bad character");
return;
}
value = strtol (p, &p, 0);
if (*p != '\n')
{
- error ("Invalid .stabs/.stabn directive, stuff after numeric value");
+ error ("invalid .stabs/.stabn directive, stuff after numeric value");
return;
}
}
else if (!IS_ASM_IDENT (ch))
{
- error ("Invalid .stabs/.stabn directive, bad character");
+ error ("invalid .stabs/.stabn directive, bad character");
return;
}
else
if ((end_p1 = strchr (start, '+')) == (char *) 0)
{
if ((end_p1 = strchr (start, '-')) == (char *) 0)
- end_p1 = start + strlen(start) - 1;
+ end_p1 = start + strlen (start) - 1;
}
shash_ptr = hash_string (start,
if (shash_ptr == (shash_t *) 0
|| shash_ptr->esym_ptr == (EXTR *) 0)
{
- error ("Invalid .stabs/.stabn directive, value not found");
+ error ("invalid .stabs/.stabn directive, value not found");
return;
}
else
if (((!ISDIGIT (*end_p1)) && (*end_p1 != '-'))
|| ((ch != '+') && (ch != '-')))
{
- error ("Invalid .stabs/.stabn directive, badly formed value");
+ error ("invalid .stabs/.stabn directive, badly formed value");
return;
}
if (ch == '+')
if (*p != '\n')
{
- error ("Invalid .stabs/.stabn directive, stuff after numeric value");
+ error ("invalid .stabs/.stabn directive, stuff after numeric value");
return;
}
}
}
- code = MIPS_MARK_STAB(code);
+ code = MIPS_MARK_STAB (code);
}
(void) add_local_symbol (string_start, string_end, st, sc, value, code);
if (*start != '"' || end == (const char *) 0 || end[1] != ',')
{
- error ("Invalid .stabs directive, no string");
+ error ("invalid .stabs directive, no string");
return;
}
STATIC void
parse_input ()
{
- register char *p;
- register Size_t i;
- register thead_t *ptag_head;
- register tag_t *ptag;
- register tag_t *ptag_next;
+ char *p;
+ Size_t i;
+ thead_t *ptag_head;
+ tag_t *ptag;
+ tag_t *ptag_next;
if (debug)
fprintf (stderr, "\tinput\n");
STATIC void
update_headers ()
{
- register symint_t i;
- register efdr_t *file_ptr;
+ symint_t i;
+ efdr_t *file_ptr;
/* Set up the symbolic header. */
file_offset = sizeof (symbolic_header) + orig_file_header.f_symptr;
file_ptr != (efdr_t *) 0;
file_ptr = file_ptr->next_file)
{
- register SYMR *sym_start;
- register SYMR *sym;
- register SYMR *sym_end_p1;
- register FDR *fd_ptr = file_ptr->orig_fdr;
+ SYMR *sym_start;
+ SYMR *sym;
+ SYMR *sym_end_p1;
+ FDR *fd_ptr = file_ptr->orig_fdr;
cur_file_ptr = file_ptr;
sym_end_p1 = sym_start + fd_ptr->csym;
for (sym = sym_start; sym < sym_end_p1; sym++)
{
- if ((st_t)sym->st == st_Static)
+ if ((st_t) sym->st == st_Static)
{
- register char *str = ORIG_LSTRS (fd_ptr->issBase + sym->iss);
- register Size_t len = strlen (str);
- register shash_t *hash_ptr;
+ char *str = ORIG_LSTRS (fd_ptr->issBase + sym->iss);
+ Size_t len = strlen (str);
+ shash_t *hash_ptr;
/* Ignore internal labels. */
if (str[0] == '$' && str[1] == 'L')
continue;
hash_ptr = hash_string (str,
- (Ptrdiff_t)len,
+ (Ptrdiff_t) len,
&file_ptr->shash_head[0],
(symint_t *) 0);
if (hash_ptr == (shash_t *) 0)
{
(void) add_local_symbol (str, str + len,
- (st_t)sym->st, (sc_t)sym->sc,
- (symint_t)sym->value,
- (symint_t)indexNil);
+ (st_t) sym->st, (sc_t) sym->sc,
+ (symint_t) sym->value,
+ (symint_t) indexNil);
}
}
}
(unsigned long) offset, vp->num_allocated * vp->object_size, str);
}
- if (file_offset != offset
- && fseek (object_stream, (long)offset, SEEK_SET) < 0)
+ if (file_offset != (unsigned long) offset
+ && fseek (object_stream, (long) offset, SEEK_SET) < 0)
pfatal_with_name (object_name);
for (ptr = vp->first; ptr != (vlinks_t *) 0; ptr = ptr->next)
pfatal_with_name (object_name);
else if (sys_write != num_write)
- fatal ("Wrote %d bytes to %s, system returned %d",
+ fatal ("wrote %d bytes to %s, system returned %d",
num_write,
object_name,
sys_write);
pfatal_with_name (object_name);
else if (sys_write != sizeof (symbolic_header))
- fatal ("Wrote %d bytes to %s, system returned %d",
+ fatal ("wrote %d bytes to %s, system returned %d",
(int) sizeof (symbolic_header),
object_name,
sys_write);
{
long sys_write;
- if (file_offset != symbolic_header.cbLineOffset
+ if (file_offset != (unsigned long) symbolic_header.cbLineOffset
&& fseek (object_stream, symbolic_header.cbLineOffset, SEEK_SET) != 0)
pfatal_with_name (object_name);
pfatal_with_name (object_name);
else if (sys_write != symbolic_header.cbLine)
- fatal ("Wrote %ld bytes to %s, system returned %ld",
+ fatal ("wrote %ld bytes to %s, system returned %ld",
(long) symbolic_header.cbLine,
object_name,
sys_write);
long sys_write;
long num_write = symbolic_header.ioptMax * sizeof (OPTR);
- if (file_offset != symbolic_header.cbOptOffset
+ if (file_offset != (unsigned long) symbolic_header.cbOptOffset
&& fseek (object_stream, symbolic_header.cbOptOffset, SEEK_SET) != 0)
pfatal_with_name (object_name);
pfatal_with_name (object_name);
else if (sys_write != num_write)
- fatal ("Wrote %ld bytes to %s, system returned %ld",
+ fatal ("wrote %ld bytes to %s, system returned %ld",
num_write,
object_name,
sys_write);
}
if (symbolic_header.idnMax > 0) /* dense numbers */
- write_varray (&dense_num, (off_t)symbolic_header.cbDnOffset, "Dense numbers");
+ write_varray (&dense_num, (off_t) symbolic_header.cbDnOffset, "Dense numbers");
if (symbolic_header.ipdMax > 0) /* procedure tables */
{
if (symbolic_header.ifdMax > 0) /* file tables */
{
offset = symbolic_header.cbFdOffset;
- if (file_offset != offset
- && fseek (object_stream, (long)offset, SEEK_SET) < 0)
+ if (file_offset != (unsigned long) offset
+ && fseek (object_stream, (long) offset, SEEK_SET) < 0)
pfatal_with_name (object_name);
file_offset = offset;
pfatal_with_name (object_name);
else if (sys_write != sizeof (FDR))
- fatal ("Wrote %d bytes to %s, system returned %d",
+ fatal ("wrote %d bytes to %s, system returned %d",
(int) sizeof (FDR),
object_name,
sys_write);
long sys_write;
symint_t num_write = symbolic_header.crfd * sizeof (symint_t);
- if (file_offset != symbolic_header.cbRfdOffset
+ if (file_offset != (unsigned long) symbolic_header.cbRfdOffset
&& fseek (object_stream, symbolic_header.cbRfdOffset, SEEK_SET) != 0)
pfatal_with_name (object_name);
if (sys_write <= 0)
pfatal_with_name (object_name);
- else if (sys_write != (long)num_write)
- fatal ("Wrote %lu bytes to %s, system returned %ld",
+ else if (sys_write != (long) num_write)
+ fatal ("wrote %lu bytes to %s, system returned %ld",
num_write,
object_name,
sys_write);
}
if (symbolic_header.issExtMax > 0) /* external symbols */
- write_varray (&ext_symbols, (off_t)symbolic_header.cbExtOffset, "External symbols");
+ write_varray (&ext_symbols, (off_t) symbolic_header.cbExtOffset, "External symbols");
if (fclose (object_stream) != 0)
pfatal_with_name (object_name);
/* If we need to seek, and the distance is nearby, just do some reads,
to speed things up. */
- if (file_offset != offset)
+ if (file_offset != (unsigned long) offset)
{
symint_t difference = offset - file_offset;
if (sys_read <= 0)
pfatal_with_name (obj_in_name);
- if ((symint_t)sys_read != difference)
- fatal ("Wanted to read %lu bytes from %s, system returned %ld",
+ if ((symint_t) sys_read != difference)
+ fatal ("wanted to read %lu bytes from %s, system returned %ld",
(unsigned long) size,
obj_in_name,
sys_read);
pfatal_with_name (obj_in_name);
if (sys_read != (long) size)
- fatal ("Wanted to read %lu bytes from %s, system returned %ld",
+ fatal ("wanted to read %lu bytes from %s, system returned %ld",
(unsigned long) size,
obj_in_name,
sys_read);
copy_object ()
{
char buffer[ PAGE_SIZE ];
- register int sys_read;
- register int remaining;
- register int num_write;
- register int sys_write;
- register int fd, es;
- register int delete_ifd = 0;
- register int *remap_file_number;
+ int sys_read;
+ int remaining;
+ int num_write;
+ int sys_write;
+ int fd, es;
+ int delete_ifd = 0;
+ int *remap_file_number;
struct stat stat_buf;
if (debug)
return; /* create a .T file sans file header */
else if (sys_read < (int) sizeof (struct filehdr))
- fatal ("Wanted to read %d bytes from %s, system returned %d",
+ fatal ("wanted to read %d bytes from %s, system returned %d",
(int) sizeof (struct filehdr),
obj_in_name,
sys_read);
pfatal_with_name (object_name);
else if (sys_read < (int) sizeof (struct filehdr))
- fatal ("Wanted to read %d bytes from %s, system returned %d",
+ fatal ("wanted to read %d bytes from %s, system returned %d",
(int) sizeof (struct filehdr),
obj_in_name,
sys_read);
file_offset = orig_file_header.f_symptr + sizeof (struct filehdr);
if (orig_sym_hdr.cbLine > 0) /* line numbers */
- orig_linenum = (char *) read_seek ((Size_t)orig_sym_hdr.cbLine,
+ orig_linenum = (char *) read_seek ((Size_t) orig_sym_hdr.cbLine,
orig_sym_hdr.cbLineOffset,
"Line numbers");
if (orig_sym_hdr.ipdMax > 0) /* procedure tables */
- orig_procs = (PDR *) read_seek ((Size_t)orig_sym_hdr.ipdMax * sizeof (PDR),
+ orig_procs = (PDR *) read_seek ((Size_t) orig_sym_hdr.ipdMax * sizeof (PDR),
orig_sym_hdr.cbPdOffset,
"Procedure tables");
if (orig_sym_hdr.isymMax > 0) /* local symbols */
- orig_local_syms = (SYMR *) read_seek ((Size_t)orig_sym_hdr.isymMax * sizeof (SYMR),
+ orig_local_syms = (SYMR *) read_seek ((Size_t) orig_sym_hdr.isymMax * sizeof (SYMR),
orig_sym_hdr.cbSymOffset,
"Local symbols");
if (orig_sym_hdr.iauxMax > 0) /* aux symbols */
- orig_aux_syms = (AUXU *) read_seek ((Size_t)orig_sym_hdr.iauxMax * sizeof (AUXU),
+ orig_aux_syms = (AUXU *) read_seek ((Size_t) orig_sym_hdr.iauxMax * sizeof (AUXU),
orig_sym_hdr.cbAuxOffset,
"Aux. symbols");
if (orig_sym_hdr.issMax > 0) /* local strings */
- orig_local_strs = (char *) read_seek ((Size_t)orig_sym_hdr.issMax,
+ orig_local_strs = (char *) read_seek ((Size_t) orig_sym_hdr.issMax,
orig_sym_hdr.cbSsOffset,
"Local strings");
if (orig_sym_hdr.issExtMax > 0) /* external strings */
- orig_ext_strs = (char *) read_seek ((Size_t)orig_sym_hdr.issExtMax,
+ orig_ext_strs = (char *) read_seek ((Size_t) orig_sym_hdr.issExtMax,
orig_sym_hdr.cbSsExtOffset,
"External strings");
if (orig_sym_hdr.ifdMax > 0) /* file tables */
- orig_files = (FDR *) read_seek ((Size_t)orig_sym_hdr.ifdMax * sizeof (FDR),
+ orig_files = (FDR *) read_seek ((Size_t) orig_sym_hdr.ifdMax * sizeof (FDR),
orig_sym_hdr.cbFdOffset,
"File tables");
if (orig_sym_hdr.crfd > 0) /* relative file descriptors */
- orig_rfds = (symint_t *) read_seek ((Size_t)orig_sym_hdr.crfd * sizeof (symint_t),
+ orig_rfds = (symint_t *) read_seek ((Size_t) orig_sym_hdr.crfd * sizeof (symint_t),
orig_sym_hdr.cbRfdOffset,
"Relative file descriptors");
if (orig_sym_hdr.issExtMax > 0) /* external symbols */
- orig_ext_syms = (EXTR *) read_seek ((Size_t)orig_sym_hdr.iextMax * sizeof (EXTR),
+ orig_ext_syms = (EXTR *) read_seek ((Size_t) orig_sym_hdr.iextMax * sizeof (EXTR),
orig_sym_hdr.cbExtOffset,
"External symbols");
if (orig_sym_hdr.idnMax > 0) /* dense numbers */
{
- orig_dense = (DNR *) read_seek ((Size_t)orig_sym_hdr.idnMax * sizeof (DNR),
+ orig_dense = (DNR *) read_seek ((Size_t) orig_sym_hdr.idnMax * sizeof (DNR),
orig_sym_hdr.cbDnOffset,
"Dense numbers");
- add_bytes (&dense_num, (char *) orig_dense, (Size_t)orig_sym_hdr.idnMax);
+ add_bytes (&dense_num, (char *) orig_dense, (Size_t) orig_sym_hdr.idnMax);
}
if (orig_sym_hdr.ioptMax > 0) /* opt symbols */
- orig_opt_syms = (OPTR *) read_seek ((Size_t)orig_sym_hdr.ioptMax * sizeof (OPTR),
+ orig_opt_syms = (OPTR *) read_seek ((Size_t) orig_sym_hdr.ioptMax * sizeof (OPTR),
orig_sym_hdr.cbOptOffset,
"Optimizer symbols");
/* Abort if the symbol table is not last. */
- if (max_file_offset != stat_buf.st_size)
- fatal ("Symbol table is not last (symbol table ends at %ld, .o ends at %ld",
+ if (max_file_offset != (unsigned long) stat_buf.st_size)
+ fatal ("symbol table is not last (symbol table ends at %ld, .o ends at %ld",
max_file_offset,
(long) stat_buf.st_size);
for (fd = delete_ifd; fd < orig_sym_hdr.ifdMax; fd++)
{
- register FDR *fd_ptr = ORIG_FILES (fd);
- register char *filename = ORIG_LSTRS (fd_ptr->issBase + fd_ptr->rss);
+ FDR *fd_ptr = ORIG_FILES (fd);
+ char *filename = ORIG_LSTRS (fd_ptr->issBase + fd_ptr->rss);
/* file support itself. */
add_file (filename, filename + strlen (filename));
for (es = 0; es < orig_sym_hdr.iextMax; es++)
{
- register EXTR *eptr = orig_ext_syms + es;
- register unsigned ifd = eptr->ifd;
+ EXTR *eptr = orig_ext_syms + es;
+ int ifd = eptr->ifd;
(void) add_ext_symbol (eptr, ((long) ifd < orig_sym_hdr.ifdMax)
? remap_file_number[ ifd ] : ifd );
for (fd = delete_ifd; fd < orig_sym_hdr.ifdMax; fd++)
{
- register FDR *fd_ptr = ORIG_FILES (fd);
- register char *filename = ORIG_LSTRS (fd_ptr->issBase + fd_ptr->rss);
- register SYMR *sym_start;
- register SYMR *sym;
- register SYMR *sym_end_p1;
- register PDR *proc_start;
- register PDR *proc;
- register PDR *proc_end_p1;
+ FDR *fd_ptr = ORIG_FILES (fd);
+ char *filename = ORIG_LSTRS (fd_ptr->issBase + fd_ptr->rss);
+ SYMR *sym_start;
+ SYMR *sym;
+ SYMR *sym_end_p1;
+ PDR *proc_start;
+ PDR *proc;
+ PDR *proc_end_p1;
/* file support itself. */
add_file (filename, filename + strlen (filename));
case st_StaticProc:
{
auto symint_t hash_index;
- register char *str = ORIG_LSTRS (fd_ptr->issBase + sym->iss);
- register Size_t len = strlen (str);
- register shash_t *shash_ptr = hash_string (str,
- (Ptrdiff_t)len,
- &orig_str_hash[0],
- &hash_index);
+ char *str = ORIG_LSTRS (fd_ptr->issBase + sym->iss);
+ Size_t len = strlen (str);
+ shash_t *shash_ptr = hash_string (str,
+ (Ptrdiff_t) len,
+ &orig_str_hash[0],
+ &hash_index);
if (shash_ptr != (shash_t *) 0)
error ("internal error, %s is already in original symbol table", str);
case st_End:
if ((sc_t) sym->sc == sc_Text)
{
- register char *str = ORIG_LSTRS (fd_ptr->issBase + sym->iss);
+ char *str = ORIG_LSTRS (fd_ptr->issBase + sym->iss);
if (*str != '\0')
{
- register Size_t len = strlen (str);
- register shash_t *shash_ptr = hash_string (str,
- (Ptrdiff_t)len,
- &orig_str_hash[0],
- (symint_t *) 0);
+ Size_t len = strlen (str);
+ shash_t *shash_ptr = hash_string (str,
+ (Ptrdiff_t) len,
+ &orig_str_hash[0],
+ (symint_t *) 0);
if (shash_ptr != (shash_t *) 0)
shash_ptr->end_ptr = sym;
proc_end_p1 = proc_start + fd_ptr->cpd;
for (proc = proc_start; proc < proc_end_p1; proc++)
{
- register SYMR *proc_sym = ORIG_LSYMS (fd_ptr->isymBase + proc->isym);
- register char *str = ORIG_LSTRS (fd_ptr->issBase + proc_sym->iss);
- register Size_t len = strlen (str);
- register shash_t *shash_ptr = hash_string (str,
- (Ptrdiff_t)len,
- &orig_str_hash[0],
- (symint_t *) 0);
+ SYMR *proc_sym = ORIG_LSYMS (fd_ptr->isymBase + proc->isym);
+ char *str = ORIG_LSTRS (fd_ptr->issBase + proc_sym->iss);
+ Size_t len = strlen (str);
+ shash_t *shash_ptr = hash_string (str,
+ (Ptrdiff_t) len,
+ &orig_str_hash[0],
+ (symint_t *) 0);
if (shash_ptr == (shash_t *) 0)
error ("internal error, function %s is not in original symbol table", str);
pfatal_with_name (obj_in_name);
else if (sys_read != num_write)
- fatal ("Wanted to read %d bytes from %s, system returned %d",
+ fatal ("wanted to read %d bytes from %s, system returned %d",
num_write,
obj_in_name,
sys_read);
pfatal_with_name (object_name);
else if (sys_write != num_write)
- fatal ("Wrote %d bytes to %s, system returned %d",
+ fatal ("wrote %d bytes to %s, system returned %d",
num_write,
object_name,
sys_write);
#if !defined(__SABER__) && !defined(lint)
if (sizeof (efdr_t) > PAGE_USIZE)
- fatal ("Efdr_t has a sizeof %d bytes, when it should be less than %d",
+ fatal ("efdr_t has a sizeof %d bytes, when it should be less than %d",
(int) sizeof (efdr_t),
(int) PAGE_USIZE);
if (sizeof (page_t) != PAGE_USIZE)
- fatal ("Page_t has a sizeof %d bytes, when it should be %d",
+ fatal ("page_t has a sizeof %d bytes, when it should be %d",
(int) sizeof (page_t),
(int) PAGE_USIZE);
void_type_info = type_info_init;
void_type_info.basic_type = bt_Void;
- while ((option = getopt (argc, argv, "d:i:I:o:v")) != EOF)
+ while ((option = getopt_long (argc, argv, "d:i:I:o:v", options, NULL)) != -1)
switch (option)
{
default:
case 'd':
debug = strtol (optarg, &num_end, 0);
- if ((unsigned)debug > 4 || num_end == optarg)
+ if ((unsigned) debug > 4 || num_end == optarg)
had_errors++;
break;
break;
case 'v':
+ verbose++;
+ break;
+
+ case 'V':
version++;
break;
}
+ if (version)
+ {
+ printf (_("mips-tfile (GCC) %s\n"), version_string);
+ fputs (_("Copyright (C) 2003 Free Software Foundation, Inc.\n"), stdout);
+ fputs (_("This is free software; see the source for copying conditions. There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
+ stdout);
+ exit (0);
+ }
+
if (obj_in_name == (char *) 0 && optind <= argc - 2)
obj_in_name = argv[--argc];
/* If there is an output name, but no input name use
the same file for both, deleting the name between
opening it for input and opening it for output. */
- if (obj_in_name == (char *) 0 && object_name != (char *)0)
+ if (obj_in_name == (char *) 0 && object_name != (char *) 0)
{
obj_in_name = object_name;
delete_input = 1;
}
- if (object_name == (char *) 0 || had_errors || optind != argc - 1)
+ if (optind != argc - 1)
+ had_errors++;
+
+ if (verbose || had_errors)
+ {
+ fprintf (stderr, _("mips-tfile (GCC) %s"), version_string);
+#ifdef TARGET_VERSION
+ TARGET_VERSION;
+#endif
+ fputc ('\n', stderr);
+ }
+
+ if (object_name == (char *) 0 || had_errors)
{
fprintf (stderr, _("Calling Sequence:\n"));
fprintf (stderr, _("\tmips-tfile [-d <num>] [-v] [-i <o-in-file>] -o <o-out-file> <s-file> (or)\n"));
return 1;
}
-
- if (version)
- {
- fprintf (stderr, _("mips-tfile version %s"), version_string);
-#ifdef TARGET_VERSION
- TARGET_VERSION;
-#endif
- fputc ('\n', stderr);
- }
-
if (obj_in_name == (char *) 0)
obj_in_name = object_name;
fatal ("wrote %d bytes to %s, expected to write %d", len2, obj_in_name, len);
}
- free_multiple_pages ((page_t *)buffer, 4);
+ free_multiple_pages ((page_t *) buffer, 4);
if (len < 0)
pfatal_with_name (object_name);
if (debug)
{
fprintf (stderr, "\n\tAllocation summary:\n\n");
- for (i = (int)alloc_type_none; i < (int)alloc_type_last; i++)
+ for (i = (int) alloc_type_none; i < (int) alloc_type_last; i++)
if (alloc_counts[i].total_alloc)
{
fprintf (stderr,
int signum;
{
(void) signal (signum, SIG_DFL); /* just in case... */
- fatal ("%s", strsignal(signum));
+ fatal ("%s", strsignal (signum));
}
/* Print a fatal error message. NAME is the text.
allocate_cluster (npages)
Size_t npages;
{
- register page_t *value = (page_t *) xcalloc (npages, PAGE_USIZE);
+ page_t *value = (page_t *) xcalloc (npages, PAGE_USIZE);
if (debug > 3)
fprintf (stderr, "\talloc\tnpages = %d, value = 0x%.8x\n", npages, value);
allocate_cluster (npages)
Size_t npages;
{
- register page_t *ptr = (page_t *) sbrk (0); /* current sbreak */
+ page_t *ptr = (page_t *) sbrk (0); /* current sbreak */
unsigned long offset = ((unsigned long) ptr) & (PAGE_SIZE - 1);
if (offset != 0) /* align to a page boundary */
if (sbrk (PAGE_USIZE - offset) == (char *)-1)
pfatal_with_name ("allocate_cluster");
- ptr = (page_t *) (((char *)ptr) + PAGE_SIZE - offset);
+ ptr = (page_t *) (((char *) ptr) + PAGE_SIZE - offset);
}
- if (sbrk (npages * PAGE_USIZE) == (char *)-1)
+ if (sbrk (npages * PAGE_USIZE) == (char *) -1)
pfatal_with_name ("allocate_cluster");
if (debug > 3)
STATIC scope_t *
allocate_scope ()
{
- register scope_t *ptr;
+ scope_t *ptr;
static scope_t initial_scope;
#ifndef MALLOC_CHECK
- ptr = alloc_counts[ (int)alloc_type_scope ].free_list.f_scope;
+ ptr = alloc_counts[ (int) alloc_type_scope ].free_list.f_scope;
if (ptr != (scope_t *) 0)
- alloc_counts[ (int)alloc_type_scope ].free_list.f_scope = ptr->free;
+ alloc_counts[ (int) alloc_type_scope ].free_list.f_scope = ptr->free;
else
{
- register int unallocated = alloc_counts[ (int)alloc_type_scope ].unallocated;
- register page_t *cur_page = alloc_counts[ (int)alloc_type_scope ].cur_page;
+ int unallocated = alloc_counts[ (int) alloc_type_scope ].unallocated;
+ page_t *cur_page = alloc_counts[ (int) alloc_type_scope ].cur_page;
if (unallocated == 0)
{
unallocated = PAGE_SIZE / sizeof (scope_t);
- alloc_counts[ (int)alloc_type_scope ].cur_page = cur_page = allocate_page ();
- alloc_counts[ (int)alloc_type_scope ].total_pages++;
+ alloc_counts[ (int) alloc_type_scope ].cur_page = cur_page = allocate_page ();
+ alloc_counts[ (int) alloc_type_scope ].total_pages++;
}
ptr = &cur_page->scope[ --unallocated ];
- alloc_counts[ (int)alloc_type_scope ].unallocated = unallocated;
+ alloc_counts[ (int) alloc_type_scope ].unallocated = unallocated;
}
#else
#endif
- alloc_counts[ (int)alloc_type_scope ].total_alloc++;
+ alloc_counts[ (int) alloc_type_scope ].total_alloc++;
*ptr = initial_scope;
return ptr;
}
free_scope (ptr)
scope_t *ptr;
{
- alloc_counts[ (int)alloc_type_scope ].total_free++;
+ alloc_counts[ (int) alloc_type_scope ].total_free++;
#ifndef MALLOC_CHECK
- ptr->free = alloc_counts[ (int)alloc_type_scope ].free_list.f_scope;
- alloc_counts[ (int)alloc_type_scope ].free_list.f_scope = ptr;
+ ptr->free = alloc_counts[ (int) alloc_type_scope ].free_list.f_scope;
+ alloc_counts[ (int) alloc_type_scope ].free_list.f_scope = ptr;
#else
free ((PTR) ptr);
STATIC vlinks_t *
allocate_vlinks ()
{
- register vlinks_t *ptr;
+ vlinks_t *ptr;
static vlinks_t initial_vlinks;
#ifndef MALLOC_CHECK
- register int unallocated = alloc_counts[ (int)alloc_type_vlinks ].unallocated;
- register page_t *cur_page = alloc_counts[ (int)alloc_type_vlinks ].cur_page;
+ int unallocated = alloc_counts[ (int) alloc_type_vlinks ].unallocated;
+ page_t *cur_page = alloc_counts[ (int) alloc_type_vlinks ].cur_page;
if (unallocated == 0)
{
unallocated = PAGE_SIZE / sizeof (vlinks_t);
- alloc_counts[ (int)alloc_type_vlinks ].cur_page = cur_page = allocate_page ();
- alloc_counts[ (int)alloc_type_vlinks ].total_pages++;
+ alloc_counts[ (int) alloc_type_vlinks ].cur_page = cur_page = allocate_page ();
+ alloc_counts[ (int) alloc_type_vlinks ].total_pages++;
}
ptr = &cur_page->vlinks[ --unallocated ];
- alloc_counts[ (int)alloc_type_vlinks ].unallocated = unallocated;
+ alloc_counts[ (int) alloc_type_vlinks ].unallocated = unallocated;
#else
ptr = (vlinks_t *) xmalloc (sizeof (vlinks_t));
#endif
- alloc_counts[ (int)alloc_type_vlinks ].total_alloc++;
+ alloc_counts[ (int) alloc_type_vlinks ].total_alloc++;
*ptr = initial_vlinks;
return ptr;
}
STATIC shash_t *
allocate_shash ()
{
- register shash_t *ptr;
+ shash_t *ptr;
static shash_t initial_shash;
#ifndef MALLOC_CHECK
- register int unallocated = alloc_counts[ (int)alloc_type_shash ].unallocated;
- register page_t *cur_page = alloc_counts[ (int)alloc_type_shash ].cur_page;
+ int unallocated = alloc_counts[ (int) alloc_type_shash ].unallocated;
+ page_t *cur_page = alloc_counts[ (int) alloc_type_shash ].cur_page;
if (unallocated == 0)
{
unallocated = PAGE_SIZE / sizeof (shash_t);
- alloc_counts[ (int)alloc_type_shash ].cur_page = cur_page = allocate_page ();
- alloc_counts[ (int)alloc_type_shash ].total_pages++;
+ alloc_counts[ (int) alloc_type_shash ].cur_page = cur_page = allocate_page ();
+ alloc_counts[ (int) alloc_type_shash ].total_pages++;
}
ptr = &cur_page->shash[ --unallocated ];
- alloc_counts[ (int)alloc_type_shash ].unallocated = unallocated;
+ alloc_counts[ (int) alloc_type_shash ].unallocated = unallocated;
#else
ptr = (shash_t *) xmalloc (sizeof (shash_t));
#endif
- alloc_counts[ (int)alloc_type_shash ].total_alloc++;
+ alloc_counts[ (int) alloc_type_shash ].total_alloc++;
*ptr = initial_shash;
return ptr;
}
STATIC thash_t *
allocate_thash ()
{
- register thash_t *ptr;
+ thash_t *ptr;
static thash_t initial_thash;
#ifndef MALLOC_CHECK
- register int unallocated = alloc_counts[ (int)alloc_type_thash ].unallocated;
- register page_t *cur_page = alloc_counts[ (int)alloc_type_thash ].cur_page;
+ int unallocated = alloc_counts[ (int) alloc_type_thash ].unallocated;
+ page_t *cur_page = alloc_counts[ (int) alloc_type_thash ].cur_page;
if (unallocated == 0)
{
unallocated = PAGE_SIZE / sizeof (thash_t);
- alloc_counts[ (int)alloc_type_thash ].cur_page = cur_page = allocate_page ();
- alloc_counts[ (int)alloc_type_thash ].total_pages++;
+ alloc_counts[ (int) alloc_type_thash ].cur_page = cur_page = allocate_page ();
+ alloc_counts[ (int) alloc_type_thash ].total_pages++;
}
ptr = &cur_page->thash[ --unallocated ];
- alloc_counts[ (int)alloc_type_thash ].unallocated = unallocated;
+ alloc_counts[ (int) alloc_type_thash ].unallocated = unallocated;
#else
ptr = (thash_t *) xmalloc (sizeof (thash_t));
#endif
- alloc_counts[ (int)alloc_type_thash ].total_alloc++;
+ alloc_counts[ (int) alloc_type_thash ].total_alloc++;
*ptr = initial_thash;
return ptr;
}
STATIC tag_t *
allocate_tag ()
{
- register tag_t *ptr;
+ tag_t *ptr;
static tag_t initial_tag;
#ifndef MALLOC_CHECK
- ptr = alloc_counts[ (int)alloc_type_tag ].free_list.f_tag;
+ ptr = alloc_counts[ (int) alloc_type_tag ].free_list.f_tag;
if (ptr != (tag_t *) 0)
- alloc_counts[ (int)alloc_type_tag ].free_list.f_tag = ptr->free;
+ alloc_counts[ (int) alloc_type_tag ].free_list.f_tag = ptr->free;
else
{
- register int unallocated = alloc_counts[ (int)alloc_type_tag ].unallocated;
- register page_t *cur_page = alloc_counts[ (int)alloc_type_tag ].cur_page;
+ int unallocated = alloc_counts[ (int) alloc_type_tag ].unallocated;
+ page_t *cur_page = alloc_counts[ (int) alloc_type_tag ].cur_page;
if (unallocated == 0)
{
unallocated = PAGE_SIZE / sizeof (tag_t);
- alloc_counts[ (int)alloc_type_tag ].cur_page = cur_page = allocate_page ();
- alloc_counts[ (int)alloc_type_tag ].total_pages++;
+ alloc_counts[ (int) alloc_type_tag ].cur_page = cur_page = allocate_page ();
+ alloc_counts[ (int) alloc_type_tag ].total_pages++;
}
ptr = &cur_page->tag[ --unallocated ];
- alloc_counts[ (int)alloc_type_tag ].unallocated = unallocated;
+ alloc_counts[ (int) alloc_type_tag ].unallocated = unallocated;
}
#else
#endif
- alloc_counts[ (int)alloc_type_tag ].total_alloc++;
+ alloc_counts[ (int) alloc_type_tag ].total_alloc++;
*ptr = initial_tag;
return ptr;
}
free_tag (ptr)
tag_t *ptr;
{
- alloc_counts[ (int)alloc_type_tag ].total_free++;
+ alloc_counts[ (int) alloc_type_tag ].total_free++;
#ifndef MALLOC_CHECK
- ptr->free = alloc_counts[ (int)alloc_type_tag ].free_list.f_tag;
- alloc_counts[ (int)alloc_type_tag ].free_list.f_tag = ptr;
+ ptr->free = alloc_counts[ (int) alloc_type_tag ].free_list.f_tag;
+ alloc_counts[ (int) alloc_type_tag ].free_list.f_tag = ptr;
#else
free ((PTR) ptr);
STATIC forward_t *
allocate_forward ()
{
- register forward_t *ptr;
+ forward_t *ptr;
static forward_t initial_forward;
#ifndef MALLOC_CHECK
- ptr = alloc_counts[ (int)alloc_type_forward ].free_list.f_forward;
+ ptr = alloc_counts[ (int) alloc_type_forward ].free_list.f_forward;
if (ptr != (forward_t *) 0)
- alloc_counts[ (int)alloc_type_forward ].free_list.f_forward = ptr->free;
+ alloc_counts[ (int) alloc_type_forward ].free_list.f_forward = ptr->free;
else
{
- register int unallocated = alloc_counts[ (int)alloc_type_forward ].unallocated;
- register page_t *cur_page = alloc_counts[ (int)alloc_type_forward ].cur_page;
+ int unallocated = alloc_counts[ (int) alloc_type_forward ].unallocated;
+ page_t *cur_page = alloc_counts[ (int) alloc_type_forward ].cur_page;
if (unallocated == 0)
{
unallocated = PAGE_SIZE / sizeof (forward_t);
- alloc_counts[ (int)alloc_type_forward ].cur_page = cur_page = allocate_page ();
- alloc_counts[ (int)alloc_type_forward ].total_pages++;
+ alloc_counts[ (int) alloc_type_forward ].cur_page = cur_page = allocate_page ();
+ alloc_counts[ (int) alloc_type_forward ].total_pages++;
}
ptr = &cur_page->forward[ --unallocated ];
- alloc_counts[ (int)alloc_type_forward ].unallocated = unallocated;
+ alloc_counts[ (int) alloc_type_forward ].unallocated = unallocated;
}
#else
#endif
- alloc_counts[ (int)alloc_type_forward ].total_alloc++;
+ alloc_counts[ (int) alloc_type_forward ].total_alloc++;
*ptr = initial_forward;
return ptr;
}
free_forward (ptr)
forward_t *ptr;
{
- alloc_counts[ (int)alloc_type_forward ].total_free++;
+ alloc_counts[ (int) alloc_type_forward ].total_free++;
#ifndef MALLOC_CHECK
- ptr->free = alloc_counts[ (int)alloc_type_forward ].free_list.f_forward;
- alloc_counts[ (int)alloc_type_forward ].free_list.f_forward = ptr;
+ ptr->free = alloc_counts[ (int) alloc_type_forward ].free_list.f_forward;
+ alloc_counts[ (int) alloc_type_forward ].free_list.f_forward = ptr;
#else
free ((PTR) ptr);
STATIC thead_t *
allocate_thead ()
{
- register thead_t *ptr;
+ thead_t *ptr;
static thead_t initial_thead;
#ifndef MALLOC_CHECK
- ptr = alloc_counts[ (int)alloc_type_thead ].free_list.f_thead;
+ ptr = alloc_counts[ (int) alloc_type_thead ].free_list.f_thead;
if (ptr != (thead_t *) 0)
- alloc_counts[ (int)alloc_type_thead ].free_list.f_thead = ptr->free;
+ alloc_counts[ (int) alloc_type_thead ].free_list.f_thead = ptr->free;
else
{
- register int unallocated = alloc_counts[ (int)alloc_type_thead ].unallocated;
- register page_t *cur_page = alloc_counts[ (int)alloc_type_thead ].cur_page;
+ int unallocated = alloc_counts[ (int) alloc_type_thead ].unallocated;
+ page_t *cur_page = alloc_counts[ (int) alloc_type_thead ].cur_page;
if (unallocated == 0)
{
unallocated = PAGE_SIZE / sizeof (thead_t);
- alloc_counts[ (int)alloc_type_thead ].cur_page = cur_page = allocate_page ();
- alloc_counts[ (int)alloc_type_thead ].total_pages++;
+ alloc_counts[ (int) alloc_type_thead ].cur_page = cur_page = allocate_page ();
+ alloc_counts[ (int) alloc_type_thead ].total_pages++;
}
ptr = &cur_page->thead[ --unallocated ];
- alloc_counts[ (int)alloc_type_thead ].unallocated = unallocated;
+ alloc_counts[ (int) alloc_type_thead ].unallocated = unallocated;
}
#else
#endif
- alloc_counts[ (int)alloc_type_thead ].total_alloc++;
+ alloc_counts[ (int) alloc_type_thead ].total_alloc++;
*ptr = initial_thead;
return ptr;
}
free_thead (ptr)
thead_t *ptr;
{
- alloc_counts[ (int)alloc_type_thead ].total_free++;
+ alloc_counts[ (int) alloc_type_thead ].total_free++;
#ifndef MALLOC_CHECK
- ptr->free = (thead_t *) alloc_counts[ (int)alloc_type_thead ].free_list.f_thead;
- alloc_counts[ (int)alloc_type_thead ].free_list.f_thead = ptr;
+ ptr->free = (thead_t *) alloc_counts[ (int) alloc_type_thead ].free_list.f_thead;
+ alloc_counts[ (int) alloc_type_thead ].free_list.f_thead = ptr;
#else
free ((PTR) ptr);
\f
/* Output an error message and exit */
-/*VARARGS*/
void
-fatal VPARAMS ((const char *format, ...))
+fatal (const char *format, ...)
{
- VA_OPEN (ap, format);
- VA_FIXEDARG (ap, const char *, format);
+ va_list ap;
+
+ va_start (ap, format);
if (line_number > 0)
fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number);
fprintf (stderr, "%s:", progname);
vfprintf (stderr, format, ap);
- VA_CLOSE (ap);
+ va_end (ap);
fprintf (stderr, "\n");
if (line_number > 0)
fprintf (stderr, "line:\t%s\n", cur_line_start);
exit (1);
}
-/*VARARGS*/
void
-error VPARAMS ((const char *format, ...))
+error (const char *format, ...)
{
- VA_OPEN (ap, format);
- VA_FIXEDARG (ap, char *, format);
+ va_list ap;
+
+ va_start (ap, format);
if (line_number > 0)
fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number);
fprintf (stderr, "line:\t%s\n", cur_line_start);
had_errors++;
- VA_CLOSE (ap);
+ va_end (ap);
saber_stop ();
}
void
fancy_abort ()
{
- fatal ("Internal abort.");
+ fatal ("internal abort");
}
\f