contain debugging information specified by the GNU compiler
in the form of comments (the mips assembler does not support
assembly access to debug information).
- Contributed by: Michael Meissner, meissner@osf.org
- Copyright (C) 1991 Free Software Foundation, Inc.
-
+ Copyright (C) 1991, 1993, 1994. 1995 Free Software Foundation, Inc.
+ Contributed by Michael Meissner, meissner@osf.org
+
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
\f
/* Here is a brief description of the MIPS ECOFF symbol table. The
*/
\f
-#include <stdio.h>
-#include "gvarargs.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
#include "config.h"
+#include <stdio.h>
#ifndef __SABER__
#define saber_stop()
typedef void *PTR_T;
typedef const void *CPTR_T;
#define __proto(x) x
+#ifndef VPROTO
+#define PVPROTO(ARGS) ARGS
+#define VPROTO(ARGS) ARGS
+#define VA_START(va_list,var) va_start(va_list,var)
+#endif
#else
#if defined(_STDIO_H_) || defined(__STDIO_H__) /* Ultrix 4.0, SGI */
#define __proto(x) ()
#define const
+#ifndef VPROTO
+#define PVPROTO(ARGS) ()
+#define VPROTO(ARGS) (va_alist) va_dcl
+#define VA_START(va_list,var) va_start(va_list)
+#endif
#endif
/* Do to size_t being defined in sys/types.h and different
the fact that including stddef.h gets you GCC's version
instead of the standard one it's not worth it to fix it. */
+#if defined(__OSF1__) || defined(__OSF__) || defined(__osf__)
+#define Size_t long unsigned int
+#else
#define Size_t unsigned int
-#define Ptrdiff_t int
+#endif
+#define Ptrdiff_t long
/* The following might be called from obstack or malloc,
so they can't be static. */
extern PTR_T xrealloc __proto((PTR_T, Size_t));
extern void xfree __proto((PTR_T));
-extern void fatal(); /* can't use prototypes here */
-extern void error();
+#ifdef HAVE_VPRINTF
+extern void fatal PVPROTO((const char *format, ...));
+extern void error PVPROTO((const char *format, ...));
+#else
+/* We must not provide any prototype here, even if ANSI C. */
+extern void fatal __proto(());
+extern void error __proto(());
+#endif
\f
#ifndef MIPS_DEBUGGING_INFO
#else /* MIPS_DEBUGGING defined */
\f
+/* The local and global symbols have a field index, so undo any defines
+ of index -> strchr and rindex -> strrchr. */
+
+#undef rindex
+#undef index
#include <sys/types.h>
-#include <a.out.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/stat.h>
+#ifndef CROSS_COMPILE
+#include <a.out.h>
+#else
+#include "mips/a.out.h"
+#endif /* CROSS_COMPILE */
+
#if defined (USG) || defined (NO_STAB_H)
#include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
#else
};
\f
-#define WORD_ALIGN(x) (((x) + 3) & ~3)
+#define WORD_ALIGN(x) (((x) + (sizeof (long) - 1)) & ~ (sizeof (long) - 1))
#define DWORD_ALIGN(x) (((x) + 7) & ~7)
struct forward *forward_ref; /* list of forward references */
bt_t basic_type; /* bt_Struct, bt_Union, or bt_Enum */
symint_t ifd; /* file # tag defined in */
- symint_t index; /* index within file's local symbols */
+ symint_t indx; /* index within file's local symbols */
} tag_t;
struct shash *next; /* next hash value */
char *string; /* string we are hashing */
symint_t len; /* string length */
- symint_t index; /* index within string table */
+ symint_t indx; /* index within string table */
EXTR *esym_ptr; /* global symbol pointer */
SYMR *sym_ptr; /* local symbol pointer */
SYMR *end_ptr; /* symbol pointer to end block */
typedef struct thash {
struct thash *next; /* next hash value */
AUXU type; /* type we are hashing */
- symint_t index; /* index within string table */
+ symint_t indx; /* index within string table */
} thash_t;
langC, /* lang: language for this file */
1, /* fMerge: whether this file can be merged */
0, /* fReadin: true if read in (not just created) */
-#if BYTES_BIG_ENDIAN
+#ifdef HOST_WORDS_BIG_ENDIAN
1, /* fBigendian: if 1, compiled on big endian machine */
#else
0, /* fBigendian: if 1, compiled on big endian machine */
#define CHECK(num,max,str) \
(((unsigned long)num > (unsigned long)max) ? out_of_bounds (num, max, str, __LINE__) : 0)
-#define ORIG_LINENUM(index) (CHECK ((index), orig_sym_hdr.cbLine, "line#"), (index) + orig_linenum)
-#define ORIG_DENSE(index) (CHECK ((index), orig_sym_hdr.idnMax, "dense"), (index) + orig_dense)
-#define ORIG_PROCS(index) (CHECK ((index), orig_sym_hdr.ipdMax, "procs"), (index) + orig_procs)
-#define ORIG_FILES(index) (CHECK ((index), orig_sym_hdr.ifdMax, "funcs"), (index) + orig_files)
-#define ORIG_LSYMS(index) (CHECK ((index), orig_sym_hdr.isymMax, "lsyms"), (index) + orig_local_syms)
-#define ORIG_LSTRS(index) (CHECK ((index), orig_sym_hdr.issMax, "lstrs"), (index) + orig_local_strs)
-#define ORIG_ESYMS(index) (CHECK ((index), orig_sym_hdr.iextMax, "esyms"), (index) + orig_ext_syms)
-#define ORIG_ESTRS(index) (CHECK ((index), orig_sym_hdr.issExtMax, "estrs"), (index) + orig_ext_strs)
-#define ORIG_OPT(index) (CHECK ((index), orig_sym_hdr.ioptMax, "opt"), (index) + orig_opt_syms)
-#define ORIG_AUX(index) (CHECK ((index), orig_sym_hdr.iauxMax, "aux"), (index) + orig_aux_syms)
-#define ORIG_RFDS(index) (CHECK ((index), orig_sym_hdr.crfd, "rfds"), (index) + orig_rfds)
+#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)
+#define ORIG_PROCS(indx) (CHECK ((indx), orig_sym_hdr.ipdMax, "procs"), (indx) + orig_procs)
+#define ORIG_FILES(indx) (CHECK ((indx), orig_sym_hdr.ifdMax, "funcs"), (indx) + orig_files)
+#define ORIG_LSYMS(indx) (CHECK ((indx), orig_sym_hdr.isymMax, "lsyms"), (indx) + orig_local_syms)
+#define ORIG_LSTRS(indx) (CHECK ((indx), orig_sym_hdr.issMax, "lstrs"), (indx) + orig_local_strs)
+#define ORIG_ESYMS(indx) (CHECK ((indx), orig_sym_hdr.iextMax, "esyms"), (indx) + orig_ext_syms)
+#define ORIG_ESTRS(indx) (CHECK ((indx), orig_sym_hdr.issExtMax, "estrs"), (indx) + orig_ext_strs)
+#define ORIG_OPT(indx) (CHECK ((indx), orig_sym_hdr.ioptMax, "opt"), (indx) + orig_opt_syms)
+#define ORIG_AUX(indx) (CHECK ((indx), orig_sym_hdr.iauxMax, "aux"), (indx) + orig_aux_syms)
+#define ORIG_RFDS(indx) (CHECK ((indx), orig_sym_hdr.crfd, "rfds"), (indx) + orig_rfds)
/* Various other statics. */
static HDRR symbolic_header; /* symbolic header */
STATIC void free_tag __proto((tag_t *));
STATIC void free_thead __proto((thead_t *));
+STATIC char *local_index __proto((const char *, int));
+STATIC char *local_rindex __proto((const char *, int));
+
+#ifndef __alpha
extern char *sbrk __proto((int));
-extern PTR_T malloc __proto((Size_t));
-extern PTR_T calloc __proto((Size_t, Size_t));
-extern PTR_T realloc __proto((PTR_T, Size_t));
extern void free __proto((PTR_T));
+#endif
extern char *mktemp __proto((char *));
extern long strtol __proto((const char *, char **, int));
extern int optind;
extern int opterr;
extern char *version_string;
+#ifndef NO_SYS_SIGLIST
+#ifndef DONT_DECLARE_SYS_SIGLIST
extern char *sys_siglist[NSIG + 1];
+#endif
+#endif
#ifndef SEEK_SET /* Symbolic constants for the "fseek" function: */
#define SEEK_SET 0 /* Set file pointer to offset */
hash_tbl[hi] = hash_ptr;
hash_ptr->len = len;
- hash_ptr->index = vp->num_allocated;
- hash_ptr->string = p =
- & vp->last->datum->byte[ vp->objects_last_page ];
+ hash_ptr->indx = vp->num_allocated;
+ hash_ptr->string = p = & vp->last->datum->byte[ vp->objects_last_page ];
vp->objects_last_page += len+1;
vp->num_allocated += len+1;
if (ret_hash != (shash_t **)0)
*ret_hash = hash_ptr;
- return hash_ptr->index;
+ return hash_ptr->indx;
}
\f
psym->iss = pscope->lsym->iss; /* blk end gets same name */
if (begin_type == st_File || begin_type == st_Block)
- pscope->lsym->index = ret+1; /* block begin gets next sym # */
+ pscope->lsym->index = ret+1; /* block begin gets next sym # */
/* Functions push two or more aux words as follows:
1st word: index+1 of the end symbol
if (last_func_eptr)
{
last_func_eptr->ifd = cur_file_ptr->file_index;
- last_func_eptr->asym.index = type;
+
+ /* The index for an external st_Proc symbol is the index
+ of the st_Proc symbol in the local symbol table. */
+ last_func_eptr->asym.index = psym->index;
}
}
}
if (hash_ptr != (thash_t *)0 && state == hash_yes)
- return hash_ptr->index;
+ return hash_ptr->indx;
if (hash_ptr == (thash_t *)0)
{
hash_ptr = allocate_thash ();
hash_ptr->next = hash_tbl[hi];
hash_ptr->type = aux;
- hash_ptr->index = vp->num_allocated;
+ hash_ptr->indx = vp->num_allocated;
hash_tbl[hi] = hash_ptr;
}
}
|| t->basic_type == bt_Enum)
{
register symint_t file_index = t->tag_ptr->ifd;
- register symint_t sym_index = t->tag_ptr->index;
+ register symint_t sym_index = t->tag_ptr->indx;
if (t->unknown_tag)
{
: (t->sizes[i] * 8) / t->dimensions[i]);
};
- /* NOTE: Mips documentation claism that the bitfield width goes here.
+ /* NOTE: Mips documentation claims that the bitfield width goes here.
But it needs to be emitted earlier. */
return ret;
/* Add a tag to the tag table (unless it already exists). */
STATIC tag_t *
-get_tag (tag_start, tag_end_p1, index, basic_type)
+get_tag (tag_start, tag_end_p1, indx, basic_type)
const char *tag_start; /* 1st byte of tag name */
const char *tag_end_p1; /* 1st byte after tag name */
- symint_t index; /* index of tag start block */
+ symint_t indx; /* index of tag start block */
bt_t basic_type; /* bt_Struct, bt_Union, or bt_Enum */
{
shash_t *hash_ptr;
&& hash_ptr->tag_ptr != (tag_t *)0)
{
tag_ptr = hash_ptr->tag_ptr;
- if (index != indexNil)
+ if (indx != indexNil)
{
tag_ptr->basic_type = basic_type;
tag_ptr->ifd = cur_file_ptr->file_index;
- tag_ptr->index = index;
+ tag_ptr->indx = indx;
}
return tag_ptr;
}
tag_ptr->hash_ptr = hash_ptr;
tag_ptr->same_name = hash_ptr->tag_ptr;
tag_ptr->basic_type = basic_type;
- tag_ptr->index = index;
- tag_ptr->ifd = (index == indexNil) ? -1 : cur_file_ptr->file_index;
+ tag_ptr->indx = indx;
+ tag_ptr->ifd = (indx == indexNil) ? -1 : cur_file_ptr->file_index;
tag_ptr->same_block = cur_tag_head->first_tag;
cur_tag_head->first_tag = tag_ptr;
\f
/* Read a line from standard input, and return the start of the buffer
(which is grows if the line is too big). We split lines at the
- semi-colon, and return each logical line indpendently. */
+ semi-colon, and return each logical line independently. */
STATIC char *
read_line __proto((void))
EXTR *eptr = (EXTR *)0; /* ext. sym equivalent to def*/
int is_function = 0; /* != 0 if function */
symint_t value = 0;
- symint_t index = cur_file_ptr->void_type;
+ symint_t indx = cur_file_ptr->void_type;
int error_line = 0;
symint_t arg_number;
symint_t temp_array[ N_TQ ];
/* Search for the end of the name being defined. */
- for (name_end_p1 = name_start; (ch = *name_end_p1) != ';'; name_end_p1++)
+ /* Allow spaces and such in names for G++ templates, which produce stabs
+ that look like:
+
+ #.def SMANIP<long unsigned int>; .scl 10; .type 0x8; .size 8; .endef */
+
+ for (name_end_p1 = name_start; (ch = *name_end_p1) != ';' && ch != '\0'; name_end_p1++)
+ ;
+
+ if (ch == '\0')
{
- if (ch == '\0' || isspace (ch))
- {
- error_line = __LINE__;
- saber_stop ();
- goto bomb_out;
- }
+ error_line = __LINE__;
+ saber_stop ();
+ goto bomb_out;
}
/* Parse the remaining subdirectives now. */
}
if (!arg_was_number)
- for (arg_end_p1 = arg_start+1; (ch = *arg_end_p1) != ';'; arg_end_p1++)
- {
- if (ch == '\0' || isspace (ch))
- {
- error_line = __LINE__;
- saber_stop ();
- goto bomb_out;
- }
- }
+ {
+ /* Allow spaces and such in names for G++ templates. */
+ for (arg_end_p1 = arg_start+1;
+ (ch = *arg_end_p1) != ';' && ch != '\0';
+ arg_end_p1++)
+ ;
+ if (ch == '\0')
+ {
+ error_line = __LINE__;
+ saber_stop ();
+ goto bomb_out;
+ }
+ }
/* Classify the directives now. */
len = dir_end_p1 - dir_start;
t.num_sizes = i + 1;
for ( i--; i >= 0; i-- )
- t.sizes[ i ] = t.sizes[ i+1 ] / t.dimensions[ i+1 ];
+ {
+ if (t.dimensions[ i+1 ])
+ t.sizes[ i ] = t.sizes[ i+1 ] / t.dimensions[ i+1 ];
+ else
+ t.sizes[ i ] = t.sizes[ i+1 ];
+ }
}
}
else if (symbol_type == st_Member && t.num_sizes - t.extra_sizes == 1)
- { /* Is this a bitfield? This is indicated by a structure memeber
+ { /* Is this a bitfield? This is indicated by a structure member
having a size field that isn't an array. */
t.bitfield = 1;
type word in the aux. symbol table. */
if (symbol_type == st_Block || symbol_type == st_End)
- index = 0;
+ indx = 0;
else if (inside_enumeration)
- index = cur_file_ptr->void_type;
+ indx = cur_file_ptr->void_type;
else
{
return;
}
- index = add_aux_sym_tir (&t,
- hash_yes,
- &cur_file_ptr->thash_head[0]);
+ indx = add_aux_sym_tir (&t,
+ hash_yes,
+ &cur_file_ptr->thash_head[0]);
}
&& (eptr->asym.index == indexNil || cur_proc_ptr == (PDR *)0))
{
eptr->ifd = cur_file_ptr->file_index;
- eptr->asym.index = index;
+ eptr->asym.index = indx;
}
/* Members of structures and unions that aren't bitfields, need
to adjust the value from a byte offset to a bit offset.
Members of enumerations do not have the value adjusted, and
- can be distinguished by index == indexNil. For enumerations,
+ can be distinguished by indx == indexNil. For enumerations,
update the maximum enumeration value. */
case st_Member:
symint_t isym = add_local_symbol (name_start, name_end_p1,
symbol_type, storage_class,
value,
- index);
+ indx);
/* deal with struct, union, and enum tags. */
if (symbol_type == st_Block)
(void) strtol (start, &p, 0);
if (start == p
- || (start_name = strchr (p, '"')) == (char *)0
- || (end_name_p1 = strrchr (++start_name, '"')) == (char *)0)
+ || (start_name = local_index (p, '"')) == (char *)0
+ || (end_name_p1 = local_rindex (++start_name, '"')) == (char *)0)
{
- error ("Illegal .file directive");
+ error ("Invalid .file directive");
return;
}
{
if (!stabs_seen)
{
- /* Add a dummy @stabs dymbol. */
+ /* Add a dummy @stabs symbol. */
stabs_seen = 1;
(void) add_local_symbol (stabs_symbol,
stabs_symbol + sizeof (stabs_symbol),
/* Read code from stabs. */
if (!isdigit (*rest))
{
- error ("Illegal .stabs/.stabn directive, code is non-numeric");
+ error ("Invalid .stabs/.stabn directive, code is non-numeric");
return;
}
if (code == (int)N_SLINE)
{
- SYMR *sym_ptr;
+ SYMR *sym_ptr, dummy_symr;
shash_t *shash_ptr;
/* Skip ,0, */
if (p[0] != ',' || p[1] != '0' || p[2] != ',' || !isdigit (p[3]))
{
- error ("Illegal line number .stabs/.stabn directive");
+ error ("Invalid line number .stabs/.stabn directive");
return;
}
code = strtol (p+3, &p, 0);
ch = *++p;
- if (code <= 0 || p[-1] != ',' || isdigit (ch) || !IS_ASM_IDENT (ch))
+ if (p[-1] != ',' || isdigit (ch) || !IS_ASM_IDENT (ch))
+ {
+ error ("Invalid line number .stabs/.stabn directive");
+ return;
+ }
+
+ dummy_symr.index = code;
+ if (dummy_symr.index != code)
{
- error ("Illegal line number .stabs/.stabn directive");
+ error ("Line number (%d) 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 ("Illegal .stabs/.stabn directive, value not found");
+ error ("Invalid .stabs/.stabn directive, value not found");
return;
}
if ((st_t) sym_ptr->st != st_Label)
{
- error ("Illegal line number .stabs/.stabn directive");
+ error ("Invalid line number .stabs/.stabn directive");
return;
}
}
else
{
- /* Skip ,0,0, */
- if (p[0] != ',' || p[1] != '0' || p[2] != ',' || p[3] != '0' || p[4] != ',')
- {
- error ("Illegal .stabs/.stabn directive, mandatory 0 isn't");
- return;
- }
-
- p += 5;
+ /* Skip ,<num>,<num>, */
+ if (*p++ != ',')
+ goto failure;
+ for (; isdigit (*p); p++)
+ ;
+ if (*p++ != ',')
+ goto failure;
+ for (; isdigit (*p); p++)
+ ;
+ if (*p++ != ',')
+ goto failure;
ch = *p;
if (!IS_ASM_IDENT (ch) && ch != '-')
{
- error ("Illegal .stabs/.stabn directive, bad character");
+ failure:
+ error ("Invalid .stabs/.stabn directive, bad character");
return;
}
value = strtol (p, &p, 0);
if (*p != '\n')
{
- error ("Illegal .stabs/.stabn directive, stuff after numeric value");
+ error ("Invalid .stabs/.stabn directive, stuff after numeric value");
return;
}
}
else if (!IS_ASM_IDENT (ch))
{
- error ("Illegal .stabs/.stabn directive, bad character");
+ error ("Invalid .stabs/.stabn directive, bad character");
return;
}
else
{
SYMR *sym_ptr;
- shash_t *shash_ptr = hash_string (p,
- strlen (p) - 1,
- &orig_str_hash[0],
- (symint_t *)0);
+ shash_t *shash_ptr;
+ const char *start, *end_p1;
+
+ start = p;
+ if ((end_p1 = strchr (start, '+')) == (char *)0)
+ {
+ if ((end_p1 = strchr (start, '-')) == (char *)0)
+ end_p1 = start + strlen(start) - 1;
+ }
+
+ shash_ptr = hash_string (start,
+ end_p1 - start,
+ &orig_str_hash[0],
+ (symint_t *)0);
if (shash_ptr == (shash_t *)0
|| (sym_ptr = shash_ptr->sym_ptr) == (SYMR *)0)
{
- error ("Illegal .stabs/.stabn directive, value not found");
- return;
+ shash_ptr = hash_string (start,
+ end_p1 - start,
+ &ext_str_hash[0],
+ (symint_t *)0);
+
+ if (shash_ptr == (shash_t *)0
+ || shash_ptr->esym_ptr == (EXTR *)0)
+ {
+ error ("Invalid .stabs/.stabn directive, value not found");
+ return;
+ }
+ else
+ sym_ptr = &(shash_ptr->esym_ptr->asym);
}
/* Traditionally, N_LBRAC and N_RBRAC are *not* relocated. */
st = (st_t) sym_ptr->st;
}
value = sym_ptr->value;
+
+ ch = *end_p1++;
+ if (ch != '\n')
+ {
+ if (((!isdigit (*end_p1)) && (*end_p1 != '-'))
+ || ((ch != '+') && (ch != '-')))
+ {
+ error ("Invalid .stabs/.stabn directive, badly formed value");
+ return;
+ }
+ if (ch == '+')
+ value += strtol (end_p1, &p, 0);
+ else if (ch == '-')
+ value -= strtol (end_p1, &p, 0);
+
+ if (*p != '\n')
+ {
+ error ("Invalid .stabs/.stabn directive, stuff after numeric value");
+ return;
+ }
+ }
}
code = MIPS_MARK_STAB(code);
}
parse_stabs (start)
const char *start; /* start of directive */
{
- const char *end = strchr (start+1, '"');
+ const char *end = local_index (start+1, '"');
if (*start != '"' || end == (const char *)0 || end[1] != ',')
{
- error ("Illegal .stabs directive, no string");
+ error ("Invalid .stabs directive, no string");
return;
}
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;
+
cur_file_ptr = file_ptr;
+
+ /* Copy st_Static symbols from the original local symbol table if
+ they did not get added to the new local symbol table.
+ This happens with stabs-in-ecoff or if the source file is
+ compiled without debugging. */
+ sym_start = ORIG_LSYMS (fd_ptr->isymBase);
+ sym_end_p1 = sym_start + fd_ptr->csym;
+ for (sym = sym_start; sym < sym_end_p1; sym++)
+ {
+ 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;
+
+ /* Ignore internal labels. */
+ if (str[0] == '$' && str[1] == 'L')
+ continue;
+ hash_ptr = hash_string (str,
+ (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);
+ }
+ }
+ }
(void) add_local_symbol ((const char *)0, (const char *)0,
st_End, sc_Text,
(symint_t)0,
symbolic_header.issMax += file_ptr->fdr.cbSs;
}
+#ifndef ALIGN_SYMTABLE_OFFSET
+#define ALIGN_SYMTABLE_OFFSET(OFFSET) (OFFSET)
+#endif
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
i = WORD_ALIGN (symbolic_header.cbLine); /* line numbers */
if (i > 0)
{
symbolic_header.cbLineOffset = file_offset;
file_offset += i;
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = symbolic_header.ioptMax; /* optimization symbols */
{
symbolic_header.cbOptOffset = file_offset;
file_offset += i * sizeof (OPTR);
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = symbolic_header.idnMax; /* dense numbers */
{
symbolic_header.cbDnOffset = file_offset;
file_offset += i * sizeof (DNR);
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = symbolic_header.ipdMax; /* procedure tables */
{
symbolic_header.cbPdOffset = file_offset;
file_offset += i * sizeof (PDR);
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = symbolic_header.isymMax; /* local symbols */
{
symbolic_header.cbSymOffset = file_offset;
file_offset += i * sizeof (SYMR);
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = symbolic_header.iauxMax; /* aux syms. */
{
symbolic_header.cbAuxOffset = file_offset;
file_offset += i * sizeof (TIR);
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = WORD_ALIGN (symbolic_header.issMax); /* local strings */
{
symbolic_header.cbSsOffset = file_offset;
file_offset += i;
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = WORD_ALIGN (symbolic_header.issExtMax); /* external strings */
{
symbolic_header.cbSsExtOffset = file_offset;
file_offset += i;
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = symbolic_header.ifdMax; /* file tables */
{
symbolic_header.cbFdOffset = file_offset;
file_offset += i * sizeof (FDR);
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = symbolic_header.crfd; /* relative file descriptors */
{
symbolic_header.cbRfdOffset = file_offset;
file_offset += i * sizeof (symint_t);
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
i = symbolic_header.iextMax; /* external symbols */
{
symbolic_header.cbExtOffset = file_offset;
file_offset += i * sizeof (EXTR);
+ file_offset = ALIGN_SYMTABLE_OFFSET (file_offset);
}
}
&& orig_files->caux == 0)
{
char *filename = orig_local_strs + (orig_files->issBase + orig_files->rss);
- char *suffix = strrchr (filename, '.');
+ char *suffix = local_rindex (filename, '.');
if (suffix != (char *)0 && strcmp (suffix, ".s") == 0)
delete_ifd = 1;
orig_str_hash[hash_index] = shash_ptr;
shash_ptr->len = len;
- shash_ptr->index = indexNil;
+ shash_ptr->indx = indexNil;
shash_ptr->string = str;
shash_ptr->sym_ptr = sym;
}
char *argv[];
{
int iflag = 0;
- char *p = strrchr (argv[0], '/');
+ char *p = local_rindex (argv[0], '/');
char *num_end;
int option;
int i;
int signum;
{
(void) signal (signum, SIG_DFL); /* just in case... */
+#ifdef NO_SYS_SIGLIST
+ fatal ("caught signal");
+#else
fatal (sys_siglist[signum]);
+#endif
}
/* Print a fatal error message. NAME is the text.
ORIG_xxx macros, but the function never returns. */
static int
-out_of_bounds (index, max, str, prog_line)
- symint_t index; /* index that is out of bounds */
+out_of_bounds (indx, max, str, prog_line)
+ symint_t indx; /* index that is out of bounds */
symint_t max; /* maximum index */
const char *str; /* string to print out */
int prog_line; /* line number within mips-tfile.c */
{
- if (index < max) /* just in case */
+ if (indx < max) /* just in case */
return 0;
fprintf (stderr, "%s, %s:%ld index %u is out of bounds for %s, max is %u, mips-tfile.c line# %d\n",
- progname, input_name, line_number, index, str, max, prog_line);
+ progname, input_name, line_number, indx, str, max, prog_line);
exit (1);
return 0; /* turn off warning messages */
}
-#endif /* MIPS_DEBUGGING_INFO *?
+#endif /* MIPS_DEBUGGING_INFO */
\f
+#ifdef HAVE_VPRINTF
+
/* Output an error message and exit */
/*VARARGS*/
void
-fatal (va_alist)
- va_dcl
+fatal VPROTO((const char *format, ...))
{
- va_list ap;
+#ifndef __STDC__
char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char*);
+#endif
if (line_number > 0)
fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number);
else
fprintf (stderr, "%s:", progname);
- va_start(ap);
- format = va_arg (ap, char *);
vfprintf (stderr, format, ap);
va_end (ap);
fprintf (stderr, "\n");
/*VARARGS*/
void
-error (va_alist)
- va_dcl
+error VPROTO((const char *format, ...))
{
- va_list ap;
+#ifndef __STDC__
char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char*);
+#endif
if (line_number > 0)
fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number);
else
fprintf (stderr, "%s:", progname);
- va_start(ap);
- format = va_arg (ap, char *);
vfprintf (stderr, format, ap);
fprintf (stderr, "\n");
if (line_number > 0)
saber_stop ();
}
+#else /* not HAVE_VPRINTF */
+
+void
+fatal (msg, arg1, arg2)
+ char *msg, *arg1, *arg2;
+{
+ error (msg, arg1, arg2);
+ exit (1);
+}
+
+void
+error (msg, arg1, arg2)
+ char *msg, *arg1, *arg2;
+{
+ fprintf (stderr, "%s: ", progname);
+ fprintf (stderr, msg, arg1, arg2);
+ fprintf (stderr, "\n");
+}
+
+#endif /* not HAVE_VPRINTF */
+
/* More 'friendly' abort that prints the line and file.
config.h can #define abort fancy_abort if you like that sort of thing. */
free (ptr);
}
+
+\f
+/* Define our own index/rindex, since the local and global symbol
+ structures as defined by MIPS has an 'index' field. */
+
+STATIC char *
+local_index (str, sentinel)
+ const char *str;
+ int sentinel;
+{
+ int ch;
+
+ for ( ; (ch = *str) != sentinel; str++)
+ {
+ if (ch == '\0')
+ return (char *)0;
+ }
+
+ return (char *)str;
+}
+
+STATIC char *
+local_rindex (str, sentinel)
+ const char *str;
+ int sentinel;
+{
+ int ch;
+ const char *ret = (const char *)0;
+
+ for ( ; (ch = *str) != '\0'; str++)
+ {
+ if (ch == sentinel)
+ ret = str;
+ }
+
+ return (char *)ret;
+}