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, 93, 94, 95, 97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1993, 1994, 1995, 1997, 1998,
+ 1999, 2000 Free Software Foundation, Inc.
Contributed by Michael Meissner (meissner@cygnus.com).
This file is part of GNU CC.
\f
#include "config.h"
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include "system.h"
+#include "version.h"
+#include "intl.h"
#ifndef __SABER__
#define saber_stop()
#define __LINE__ 0
#endif
-#ifdef __STDC__
-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 */
-typedef void *PTR_T;
-typedef void *CPTR_T;
-
-#else
-typedef char *PTR_T; /* Ultrix 3.1 */
-typedef char *CPTR_T;
-#endif
+#define __proto(x) PARAMS(x)
+typedef PTR PTR_T;
+typedef const PTR_T CPTR_T;
-#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
+/* Due to size_t being defined in sys/types.h and different
in stddef.h, we have to do this by hand..... Note, these
types are correct for MIPS based systems, and may not be
correct for other systems. Ultrix 4.0 and Silicon Graphics
so they can't be static. */
extern void pfatal_with_name
- __proto((char *));
-extern void fancy_abort __proto((void));
- void botch __proto((const char *));
-extern PTR_T xmalloc __proto((Size_t));
-extern PTR_T xcalloc __proto((Size_t, Size_t));
-extern PTR_T xrealloc __proto((PTR_T, Size_t));
-extern void xfree __proto((PTR_T));
-
-#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
+ __proto((const char *)) ATTRIBUTE_NORETURN;
+extern void fancy_abort __proto((void)) ATTRIBUTE_NORETURN;
+ void botch __proto((const char *)) ATTRIBUTE_NORETURN;
+extern void fatal PARAMS ((const char *format, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
+extern void error PARAMS ((const char *format, ...)) ATTRIBUTE_PRINTF_1;
\f
#ifndef MIPS_DEBUGGING_INFO
static int cur_line_start;
static int debug;
static int had_errors;
-static char *progname;
-static char *input_name;
+static const char *progname;
+static const char *input_name;
int
main ()
#undef index
#include <signal.h>
-#include <sys/stat.h>
#ifndef CROSS_COMPILE
#include <a.out.h>
#include "mips/a.out.h"
#endif /* CROSS_COMPILE */
-#if defined (USG) || defined (NO_STAB_H)
+#if defined (USG) || !defined (HAVE_STAB_H)
#include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
#else
#include <stab.h> /* On BSD, use the system's stab.h. */
grow linearly, and which are written in the object file as sequential
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 it's overhead, and rounds up to the next power of 2. Pages are
+ 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
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, /* 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 */
/* Structure holding allocation information for small sized structures. */
typedef struct alloc_info {
- char *alloc_name; /* name of this allocation type (must be first) */
+ const char *alloc_name; /* name of this allocation type (must be first) */
page_t *cur_page; /* current page being allocated from */
small_free_t free_list; /* current free list if any */
int unallocated; /* number of elements unallocated on page */
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 char *input_name = "stdin"; /* name of input file */
+static const char *input_name = "stdin"; /* name of input file */
static char *object_name = (char *) 0; /* tmp. name of object file */
static char *obj_in_name = (char *) 0; /* name of input object file */
static char *cur_line_start = (char *) 0; /* current line read in */
STATIC void write_varray __proto((varray_t *, off_t, const char *));
STATIC void write_object __proto((void));
-STATIC char *st_to_string __proto((st_t));
-STATIC char *sc_to_string __proto((sc_t));
+STATIC const char *st_to_string __proto((st_t));
+STATIC const char *sc_to_string __proto((sc_t));
STATIC char *read_line __proto((void));
STATIC void parse_input __proto((void));
STATIC void mark_stabs __proto((const char *));
STATIC page_t *read_seek __proto((Size_t, off_t, const char *));
STATIC void copy_object __proto((void));
-STATIC void catch_signal __proto((int));
+STATIC void catch_signal __proto((int)) ATTRIBUTE_NORETURN;
STATIC page_t *allocate_page __proto((void));
STATIC page_t *allocate_multiple_pages
extern char *optarg;
extern int optind;
extern int opterr;
-extern char *version_string;
-#ifndef NO_SYS_SIGLIST
-#ifndef SYS_SIGLIST_DECLARED
-extern char *sys_siglist[NSIG + 1];
-#endif
-#endif
-
\f
/* List of assembler pseudo ops and beginning sequences that need
special actions. Someday, this should be a hash table, and such,
*ret_hash_index = hi;
for (ptr = hash_tbl[hi]; ptr != (shash_t *) 0; ptr = ptr->next)
- if (hash_len == ptr->len
+ if ((symint_t) hash_len == ptr->len
&& first_ch == ptr->string[0]
&& memcmp ((CPTR_T) text, (CPTR_T) ptr->string, hash_len) == 0)
break;
register shash_t *hash_ptr;
symint_t hi;
- if (len >= PAGE_USIZE)
+ if (len >= (Ptrdiff_t) PAGE_USIZE)
fatal ("String too big (%ld bytes)", (long) len);
hash_ptr = hash_string (start, len, hash_tbl, &hi);
{
register char *p;
- if (vp->objects_last_page + len >= PAGE_USIZE)
+ if (vp->objects_last_page + len >= (long) PAGE_USIZE)
{
vp->num_allocated
= ((vp->num_allocated + PAGE_USIZE - 1) / PAGE_USIZE) * PAGE_USIZE;
&& (debug > 2 || type == st_Block || type == st_End
|| type == st_Proc || type == st_StaticProc))
{
- char *sc_str = sc_to_string (storage);
- char *st_str = st_to_string (type);
+ const char *sc_str = sc_to_string (storage);
+ const char *st_str = st_to_string (type);
int depth = cur_file_ptr->nested_scopes + (scope_delta < 0);
fprintf (stderr,
value, depth, sc_str);
if (str_start && str_end_p1 - str_start > 0)
- fprintf (stderr, " st= %-11s name= %.*s\n", st_str, str_end_p1 - str_start, str_start);
+ fprintf (stderr, " st= %-11s name= %.*s\n",
+ st_str, (int) (str_end_p1 - str_start), str_start);
else
{
Size_t len = strlen (st_str);
- fprintf (stderr, " st= %.*s\n", len-1, st_str);
+ fprintf (stderr, " st= %.*s\n", (int) (len-1), st_str);
}
}
if (debug > 1)
{
- char *sc_str = sc_to_string (storage);
- char *st_str = st_to_string (type);
+ const char *sc_str = sc_to_string (storage);
+ const char *st_str = st_to_string (type);
fprintf (stderr,
"\tesym\tv= %10ld, ifd= %2d, sc= %-12s",
value, ifd, sc_str);
if (str_start && str_end_p1 - str_start > 0)
- fprintf (stderr, " st= %-11s name= %.*s\n", st_str, str_end_p1 - str_start, str_start);
+ fprintf (stderr, " st= %-11s name= %.*s\n",
+ st_str, (int) (str_end_p1 - str_start), str_start);
else
fprintf (stderr, " st= %s\n", st_str);
}
tag_ptr->same_name = hash_ptr->tag_ptr;
tag_ptr->basic_type = basic_type;
tag_ptr->indx = indx;
- tag_ptr->ifd = (indx == indexNil) ? -1 : cur_file_ptr->file_index;
+ tag_ptr->ifd = (indx == indexNil
+ ? (symint_t) -1 : cur_file_ptr->file_index);
tag_ptr->same_block = cur_tag_head->first_tag;
cur_tag_head->first_tag = tag_ptr;
if (debug > 1)
{
- char *agg_type = "{unknown aggregate type}";
+ const char *agg_type = "{unknown aggregate type}";
switch (ptag->basic_type)
{
case bt_Struct: agg_type = "struct"; break;
default: break;
}
- fprintf (stderr, "unknown %s %.*s found\n", agg_type,
- hash_ptr->len, name_start);
+ fprintf (stderr, "unknown %s %.*s found\n",
+ agg_type, (int) hash_ptr->len, name_start);
}
sym_index = add_local_symbol (name_start,
}
if (cur_oproc_ptr == (PDR *) 0)
- error ("Did not find a PDR block for %.*s", func_end_p1 - func_start, func_start);
+ error ("Did not find a PDR block for %.*s",
+ (int) (func_end_p1 - func_start), func_start);
/* Determine the start of symbols. */
new_proc_ptr->isym = file_ptr->symbols.num_allocated;
register efdr_t *file_ptr;
if (debug)
- fprintf (stderr, "\tfile\t%.*s\n", len, file_start);
+ fprintf (stderr, "\tfile\t%.*s\n", (int) len, file_start);
/* See if the file has already been created. */
for (file_ptr = first_file;
&zero_bytes[0],
(shash_t **) 0);
- if (file_end_p1 - file_start > PAGE_USIZE-2)
+ if (file_end_p1 - file_start > (long) PAGE_USIZE-2)
fatal ("Filename goes over one page boundary.");
/* Push the start of the filename. We assume that the filename
\f
/* Convert storage class to string. */
-STATIC char *
+STATIC const char *
sc_to_string(storage_class)
sc_t storage_class;
{
\f
/* Convert symbol type to string. */
-STATIC char *
+STATIC const char *
st_to_string(symbol_type)
st_t symbol_type;
{
if (hash_ptr == (shash_t *) 0)
{
- error ("Label %.*s not found for #.begin", end_p1 - start, start);
+ 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", end_p1 - start, start);
+ 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", 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", end_p1 - start, start);
+ error ("Procedure table %.*s not found for #.bend",
+ (int) (end_p1 - start), start);
return;
}
&& eptr == (EXTR *) 0)
{
fprintf (stderr, "warning, %.*s not found in original or external symbol tables, value defaults to 0\n",
- arg_end_p1 - arg_start,
+ (int) (arg_end_p1 - arg_start),
arg_start);
value = 0;
}
if (diff)
{
- for (j = (sizeof (t.sizes) / sizeof (t.sizes[0])) - 1; j >= 0; j--)
+ for (j = ARRAY_SIZE (t.sizes) - 1; j >= 0; j--)
t.sizes[ j ] = ((j-diff) >= 0) ? t.sizes[ j-diff ] : 0;
t.num_sizes = i + 1;
if (tag_start == (char *) 0)
{
error ("No tag specified for %.*s",
- name_end_p1 - name_start,
+ (int) (name_end_p1 - name_start),
name_start);
return;
}
}
/* Get the function name, skipping whitespace. */
- for (start_func = start; ISSPACE (*start_func); start_func++)
+ for (start_func = start; ISSPACE ((unsigned char)*start_func); start_func++)
;
ch = *start_func;
value = cur_oproc_end->value;
else
- error ("Cannot find .end block for %.*s", end_func_p1 - start_func, start_func);
+ error ("Cannot find .end block for %.*s",
+ (int) (end_func_p1 - start_func), start_func);
(void) add_local_symbol (start_func, end_func_p1,
st_End, sc_Text,
return;
}
- for (start_func = start; ISSPACE (*start_func); start_func++)
+ for (start_func = start; ISSPACE ((unsigned char)*start_func); start_func++)
;
ch = *start_func;
static void
mark_stabs (start)
- const char *start; /* Start of directive (ignored) */
+ const char *start ATTRIBUTE_UNUSED; /* Start of directive (ignored) */
{
if (!stabs_seen)
{
dummy_symr.index = code;
if (dummy_symr.index != code)
{
- error ("Line number (%d) 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;
parse_input __proto((void))
{
register char *p;
- register int i;
+ register Size_t i;
register thead_t *ptag_head;
register tag_t *ptag;
register tag_t *ptag_next;
while ((p = read_line ()) != (char *) 0)
{
/* Skip leading blanks */
- while (ISSPACE (*p))
+ while (ISSPACE ((unsigned char)*p))
p++;
/* See if it's a directive we handle. If so, dispatch handler. */
- for (i = 0; i < sizeof (pseudo_ops) / sizeof (pseudo_ops[0]); i++)
+ for (i = 0; i < ARRAY_SIZE (pseudo_ops); i++)
if (memcmp (p, pseudo_ops[i].name, pseudo_ops[i].len) == 0
- && ISSPACE (p[pseudo_ops[i].len]))
+ && ISSPACE ((unsigned char)(p[pseudo_ops[i].len])))
{
p += pseudo_ops[i].len; /* skip to first argument */
- while (ISSPACE (*p))
+ while (ISSPACE ((unsigned char)*p))
p++;
(*pseudo_ops[i].func)( p );
return;
if (debug)
- fprintf (stderr, "\twarray\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
- vp, offset, vp->num_allocated * vp->object_size, str);
-
+ {
+ fputs ("\twarray\tvp = ", stderr);
+ fprintf (stderr, HOST_PTR_PRINTF, vp);
+ fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+ (unsigned long) offset, vp->num_allocated * vp->object_size, str);
+ }
+
if (file_offset != offset
&& fseek (object_stream, (long)offset, SEEK_SET) < 0)
pfatal_with_name (object_name);
off_t offset;
if (debug)
- fprintf (stderr, "\n\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
- (PTR_T *) &symbolic_header, 0, sizeof (symbolic_header),
- "symbolic header");
+ {
+ fputs ("\n\twrite\tvp = ", stderr);
+ fprintf (stderr, HOST_PTR_PRINTF, (PTR_T *) &symbolic_header);
+ fprintf (stderr, ", offset = %7u, size = %7lu, %s\n",
+ 0, (unsigned long) sizeof (symbolic_header), "symbolic header");
+ }
sys_write = fwrite ((PTR_T) &symbolic_header,
1,
else if (sys_write != sizeof (symbolic_header))
fatal ("Wrote %d bytes to %s, system returned %d",
- sizeof (symbolic_header),
+ (int) sizeof (symbolic_header),
object_name,
sys_write);
pfatal_with_name (object_name);
if (debug)
- fprintf (stderr, "\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
- (PTR_T *) &orig_linenum, symbolic_header.cbLineOffset,
- symbolic_header.cbLine, "Line numbers");
+ {
+ fputs ("\twrite\tvp = ", stderr);
+ fprintf (stderr, HOST_PTR_PRINTF, (PTR_T *) &orig_linenum);
+ fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+ (long) symbolic_header.cbLineOffset,
+ (long) symbolic_header.cbLine, "Line numbers");
+ }
sys_write = fwrite ((PTR_T) orig_linenum,
1,
pfatal_with_name (object_name);
else if (sys_write != symbolic_header.cbLine)
- fatal ("Wrote %d bytes to %s, system returned %d",
- symbolic_header.cbLine,
+ fatal ("Wrote %ld bytes to %s, system returned %ld",
+ (long) symbolic_header.cbLine,
object_name,
sys_write);
pfatal_with_name (object_name);
if (debug)
- fprintf (stderr, "\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
- (PTR_T *) &orig_opt_syms, symbolic_header.cbOptOffset,
- num_write, "Optimizer symbols");
+ {
+ fputs ("\twrite\tvp = ", stderr);
+ fprintf (stderr, HOST_PTR_PRINTF, (PTR_T *) &orig_opt_syms);
+ fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+ (long) symbolic_header.cbOptOffset,
+ num_write, "Optimizer symbols");
+ }
sys_write = fwrite ((PTR_T) orig_opt_syms,
1,
pfatal_with_name (object_name);
else if (sys_write != num_write)
- fatal ("Wrote %d bytes to %s, system returned %d",
+ fatal ("Wrote %ld bytes to %s, system returned %ld",
num_write,
object_name,
sys_write);
file_ptr = file_ptr->next_file)
{
if (debug)
- fprintf (stderr, "\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
- (PTR_T *) &file_ptr->fdr, file_offset, sizeof (FDR), "File header");
+ {
+ fputs ("\twrite\tvp = ", stderr);
+ fprintf (stderr, HOST_PTR_PRINTF, (PTR_T *) &file_ptr->fdr);
+ fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+ file_offset, (unsigned long) sizeof (FDR),
+ "File header");
+ }
sys_write = fwrite (&file_ptr->fdr,
1,
else if (sys_write != sizeof (FDR))
fatal ("Wrote %d bytes to %s, system returned %d",
- sizeof (FDR),
+ (int) sizeof (FDR),
object_name,
sys_write);
pfatal_with_name (object_name);
if (debug)
- fprintf (stderr, "\twrite\tvp = 0x%.8x, offset = %7u, size = %7u, %s\n",
- (PTR_T *) &orig_rfds, symbolic_header.cbRfdOffset,
- num_write, "Relative file descriptors");
+ {
+ fputs ("\twrite\tvp = ", stderr);
+ fprintf (stderr, HOST_PTR_PRINTF, (PTR_T *) &orig_rfds);
+ fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
+ (long) symbolic_header.cbRfdOffset,
+ num_write, "Relative file descriptors");
+ }
sys_write = fwrite (orig_rfds,
1,
if (sys_write <= 0)
pfatal_with_name (object_name);
- else if (sys_write != num_write)
- fatal ("Wrote %d bytes to %s, system returned %d",
+ else if (sys_write != (long)num_write)
+ fatal ("Wrote %lu bytes to %s, system returned %ld",
num_write,
object_name,
sys_write);
return (page_t *) 0;
if (debug)
- fprintf (stderr, "\trseek\tsize = %7u, offset = %7u, currently at %7u, %s\n",
- size, offset, file_offset, str);
+ fprintf (stderr,
+ "\trseek\tsize = %7lu, offset = %7lu, currently at %7lu, %s\n",
+ (unsigned long) size, (unsigned long) offset, file_offset, str);
#ifndef MALLOC_CHECK
ptr = allocate_multiple_pages ((size + PAGE_USIZE - 1) / PAGE_USIZE);
if (sys_read <= 0)
pfatal_with_name (obj_in_name);
- if (sys_read != difference)
- fatal ("Wanted to read %d bytes from %s, system returned %d",
- size,
+ 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);
}
if (sys_read <= 0)
pfatal_with_name (obj_in_name);
- if (sys_read != size)
- fatal ("Wanted to read %d bytes from %s, system returned %d",
- size,
+ if (sys_read != (long) size)
+ fatal ("Wanted to read %lu bytes from %s, system returned %ld",
+ (unsigned long) size,
obj_in_name,
sys_read);
else if (sys_read == 0 && feof (obj_in_stream))
return; /* create a .T file sans file header */
- else if (sys_read < sizeof (struct filehdr))
+ else if (sys_read < (int) sizeof (struct filehdr))
fatal ("Wanted to read %d bytes from %s, system returned %d",
- sizeof (struct filehdr),
+ (int) sizeof (struct filehdr),
obj_in_name,
sys_read);
if (orig_file_header.f_nsyms != sizeof (HDRR))
fatal ("%s symbolic header wrong size (%d bytes, should be %d)",
- input_name, orig_file_header.f_nsyms, sizeof (HDRR));
+ input_name, orig_file_header.f_nsyms, (int) sizeof (HDRR));
/* Read in the current symbolic header. */
if (sys_read < 0)
pfatal_with_name (object_name);
- else if (sys_read < sizeof (struct filehdr))
+ else if (sys_read < (int) sizeof (struct filehdr))
fatal ("Wanted to read %d bytes from %s, system returned %d",
- sizeof (struct filehdr),
+ (int) sizeof (struct filehdr),
obj_in_name,
sys_read);
(st_t) eptr->asym.st,
(sc_t) eptr->asym.sc,
eptr->asym.value,
- (symint_t) ((eptr->asym.index == indexNil) ? indexNil : 0),
- (ifd < orig_sym_hdr.ifdMax) ? remap_file_number[ ifd ] : ifd);
+ (eptr->asym.index == indexNil
+ ? (symint_t) indexNil : 0),
+ ((long) ifd < orig_sym_hdr.ifdMax
+ ? remap_file_number[ifd] : (int) ifd));
}
remaining > 0;
remaining -= num_write)
{
- num_write = (remaining <= sizeof (buffer)) ? remaining : sizeof (buffer);
+ num_write
+ = (remaining <= (int) sizeof (buffer))
+ ? remaining : (int) sizeof (buffer);
sys_read = fread ((PTR_T) buffer, 1, num_write, obj_in_stream);
if (sys_read <= 0)
pfatal_with_name (obj_in_name);
\f
/* Ye olde main program. */
+extern int main PARAMS ((int, char **));
+
int
main (argc, argv)
int argc;
- char *argv[];
+ char **argv;
{
int iflag = 0;
char *p = local_rindex (argv[0], '/');
#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",
- sizeof (efdr_t),
- PAGE_USIZE);
+ (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",
- sizeof (page_t),
- PAGE_USIZE);
+ (int) sizeof (page_t),
+ (int) PAGE_USIZE);
#endif
if (object_name == (char *) 0 || had_errors || optind != argc - 1)
{
- fprintf (stderr, "Calling Sequence:\n");
- fprintf (stderr, "\tmips-tfile [-d <num>] [-v] [-i <o-in-file>] -o <o-out-file> <s-file> (or)\n");
- fprintf (stderr, "\tmips-tfile [-d <num>] [-v] [-I <o-in-file>] -o <o-out-file> <s-file> (or)\n");
- fprintf (stderr, "\tmips-tfile [-d <num>] [-v] <s-file> <o-in-file> <o-out-file>\n");
+ fprintf (stderr, _("Calling Sequence:\n"));
+ fprintf (stderr, _("\tmips-tfile [-d <num>] [-v] [-i <o-in-file>] -o <o-out-file> <s-file> (or)\n"));
+ fprintf (stderr, _("\tmips-tfile [-d <num>] [-v] [-I <o-in-file>] -o <o-out-file> <s-file> (or)\n"));
+ fprintf (stderr, _("\tmips-tfile [-d <num>] [-v] <s-file> <o-in-file> <o-out-file>\n"));
fprintf (stderr, "\n");
- fprintf (stderr, "Debug levels are:\n");
- fprintf (stderr, " 1\tGeneral debug + trace functions/blocks.\n");
- fprintf (stderr, " 2\tDebug level 1 + trace externals.\n");
- fprintf (stderr, " 3\tDebug level 2 + trace all symbols.\n");
- fprintf (stderr, " 4\tDebug level 3 + trace memory allocations.\n");
+ fprintf (stderr, _("Debug levels are:\n"));
+ fprintf (stderr, _(" 1\tGeneral debug + trace functions/blocks.\n"));
+ fprintf (stderr, _(" 2\tDebug level 1 + trace externals.\n"));
+ fprintf (stderr, _(" 3\tDebug level 2 + trace all symbols.\n"));
+ fprintf (stderr, _(" 4\tDebug level 3 + trace memory allocations.\n"));
return 1;
}
if (version)
{
- fprintf (stderr, "mips-tfile version %s", version_string);
+ fprintf (stderr, _("mips-tfile version %s"), version_string);
#ifdef TARGET_VERSION
TARGET_VERSION;
#endif
int signum;
{
(void) signal (signum, SIG_DFL); /* just in case... */
-#ifdef NO_SYS_SIGLIST
- fatal ("caught signal");
-#else
- fatal (sys_siglist[signum]);
-#endif
+ fatal ("%s", strsignal(signum));
}
/* Print a fatal error message. NAME is the text.
void
pfatal_with_name (msg)
- char *msg;
+ const char *msg;
{
int save_errno = errno; /* just in case.... */
if (line_number > 0)
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",
+ fprintf (stderr, "%s, %s:%ld index %lu is out of bounds for %s, max is %lu, mips-tfile.c line# %d\n",
progname, input_name, line_number, indx, str, max, prog_line);
exit (1);
\f
/* Allocate a cluster of pages. USE_MALLOC says that malloc does not
- like sbrk's behind it's back (or sbrk isn't available). If we use
+ like sbrk's behind its back (or sbrk isn't available). If we use
sbrk, we assume it gives us zeroed pages. */
#ifndef MALLOC_CHECK
allocate_cluster (npages)
Size_t npages;
{
- register page_t *value = (page_t *) calloc (npages, PAGE_USIZE);
-
- if (value == 0)
- fatal ("Virtual memory exhausted.");
+ register page_t *value = (page_t *) xcalloc (npages, PAGE_USIZE);
if (debug > 3)
fprintf (stderr, "\talloc\tnpages = %d, value = 0x%.8x\n", npages, value);
pfatal_with_name ("allocate_cluster");
if (debug > 3)
- fprintf (stderr, "\talloc\tnpages = %d, value = 0x%.8x\n", npages, ptr);
+ {
+ fprintf (stderr, "\talloc\tnpages = %lu, value = ",
+ (unsigned long) npages);
+ fprintf (stderr, HOST_PTR_PRINTF, ptr);
+ fputs ("\n", stderr);
+ }
return ptr;
}
alloc_counts[ (int)alloc_type_scope ].free_list.f_scope = ptr;
#else
- xfree ((PTR_T) ptr);
+ free ((PTR_T) ptr);
#endif
}
alloc_counts[ (int)alloc_type_tag ].free_list.f_tag = ptr;
#else
- xfree ((PTR_T) ptr);
+ free ((PTR_T) ptr);
#endif
}
alloc_counts[ (int)alloc_type_forward ].free_list.f_forward = ptr;
#else
- xfree ((PTR_T) ptr);
+ free ((PTR_T) ptr);
#endif
}
alloc_counts[ (int)alloc_type_thead ].free_list.f_thead = ptr;
#else
- xfree ((PTR_T) ptr);
+ free ((PTR_T) ptr);
#endif
}
#endif /* MIPS_DEBUGGING_INFO */
\f
-#ifdef HAVE_VPRINTF
-
/* Output an error message and exit */
/*VARARGS*/
void
-fatal VPROTO((const char *format, ...))
+fatal VPARAMS ((const char *format, ...))
{
-#ifndef __STDC__
- char *format;
+#ifndef ANSI_PROTOTYPES
+ const char *format;
#endif
va_list ap;
VA_START (ap, format);
-#ifndef __STDC__
- format = va_arg (ap, char *);
+#ifndef ANSI_PROTOTYPES
+ format = va_arg (ap, const char *);
#endif
if (line_number > 0)
/*VARARGS*/
void
-error VPROTO((const char *format, ...))
+error VPARAMS ((const char *format, ...))
{
-#ifndef __STDC__
+#ifndef ANSI_PROTOTYPES
char *format;
#endif
va_list ap;
VA_START (ap, format);
-#ifndef __STDC__
+#ifndef ANSI_PROTOTYPES
format = va_arg (ap, char *);
#endif
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. */
botch (s)
const char *s;
{
- fatal (s);
-}
-
-/* Same as `malloc' but report error if no memory available. */
-
-PTR_T
-xmalloc (size)
- Size_t size;
-{
- register PTR_T value = malloc (size);
- if (value == 0)
- fatal ("Virtual memory exhausted.");
-
- if (debug > 3)
- fprintf (stderr, "\tmalloc\tptr = 0x%.8x, size = %10u\n", value, size);
-
- return value;
-}
-
-/* Same as `calloc' but report error if no memory available. */
-
-PTR_T
-xcalloc (size1, size2)
- Size_t size1, size2;
-{
- register PTR_T value = calloc (size1, size2);
- if (value == 0)
- fatal ("Virtual memory exhausted.");
-
- if (debug > 3)
- fprintf (stderr, "\tcalloc\tptr = 0x%.8x, size1 = %10u, size2 = %10u [%u]\n",
- value, size1, size2, size1+size2);
-
- return value;
-}
-
-/* Same as `realloc' but report error if no memory available. */
-
-PTR_T
-xrealloc (ptr, size)
- PTR_T ptr;
- Size_t size;
-{
- register PTR_T result = realloc (ptr, size);
- if (!result)
- fatal ("Virtual memory exhausted.");
-
- if (debug > 3)
- fprintf (stderr, "\trealloc\tptr = 0x%.8x, size = %10u, orig = 0x%.8x\n",
- result, size, ptr);
-
- return result;
-}
-
-void
-xfree (ptr)
- PTR_T ptr;
-{
- if (debug > 3)
- fprintf (stderr, "\tfree\tptr = 0x%.8x\n", ptr);
-
- free (ptr);
+ fatal ("%s", s);
}
\f