#include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
+#include <fcntl.h>
#include <errno.h>
-#include <a.out.h>
#include "config.h"
+#ifdef index
+#undef index
+#undef rindex
+#endif
+#ifndef CROSS_COMPILE
+#include <a.out.h>
+#else
+#include "symconst.h"
+#define LANGUAGE_C
+#include "sym.h"
+#include "filehdr.h"
+#define ST_RFDESCAPE 0xfff
+#endif
+
+#ifndef MIPS_IS_STAB
+/* Macros for mips-tfile.c to encapsulate stabs in ECOFF, and for
+ and mips-tdump.c to print them out. This is used on the Alpha,
+ which does not include mips.h.
+
+ These must match the corresponding definitions in gdb/mipsread.c.
+ Unfortunately, gcc and gdb do not currently share any directories. */
+
+#define CODE_MASK 0x8F300
+#define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
+#define MIPS_MARK_STAB(code) ((code)+CODE_MASK)
+#define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK)
+#endif
+
#ifdef __STDC__
typedef void *PTR_T;
typedef const void *CPTR_T;
#define __proto(x) x
#else
-#ifdef _STDIO_H_ /* Ultrix 4.0 */
+#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 *PTR_T; /* Ultrix 3.1 */
typedef char *CPTR_T;
#endif
#define uint unsigned int
#define ulong unsigned long
+
/* Do 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
#define ptrdiff_t int
\f
-/* Redefination of of storage classes as an enumeration for better
+/* Redefinition of of storage classes as an enumeration for better
debugging. */
#ifndef stStaParam
st_Local = stLocal, /* local variable */
st_Label = stLabel, /* label */
st_Proc = stProc, /* " " Procedure */
- st_Block = stBlock, /* beginnning of block */
+ st_Block = stBlock, /* beginning of block */
st_End = stEnd, /* end (of anything) */
st_Member = stMember, /* member (of anything - struct/union/enum */
st_Typedef = stTypedef, /* type definition */
st_Str = stStr, /* string */
st_Number = stNumber, /* pure number (ie. 4 NOR 2+2) */
st_Expr = stExpr, /* 2+2 vs. 4 */
- st_Type = stType, /* post-coersion SER */
+ st_Type = stType, /* post-coercion SER */
st_Max = stMax /* max type+1 */
} st_t;
int want_line = 0; /* print line numbers */
int want_rfd = 0; /* print relative file desc's */
int want_scope = 0; /* print scopes for every symbol */
+int tfile = 0; /* no global header file */
int tfile_fd; /* file descriptor of .T file */
off_t tfile_offset; /* current offset in .T file */
scope_t *cur_scope = 0; /* list of active scopes */
LINER *lines; /* line numbers */
DNR *dense_nums; /* dense numbers */
OPTR *opt_symbols; /* optimization symbols */
-AUXU *aux_symbols; /* Auxilary symbols */
+AUXU *aux_symbols; /* Auxiliary symbols */
char *aux_used; /* map of which aux syms are used */
FDR *file_desc; /* file tables */
ulong *rfile_desc; /* relative file tables */
char *lang_to_string __proto((lang_t));
char *type_to_string __proto((AUXU *, int));
-/* Library routines with prototypes. */
-#if !defined(NO_LIB_PROTOTYPE) && !defined(_OSF_SOURCE) && !defined(_STDIO_H_)
-extern void perror __proto((const char *));
-extern char *strcpy __proto((char *, const char *));
-extern int strlen __proto((const char *));
-extern int open __proto((const char *, int, ...));
-#endif
-
-extern int read __proto((int, PTR_T, size_t));
-extern int write __proto((int, CPTR_T, size_t));
-extern int close __proto((int));
-extern off_t lseek __proto((int, off_t, int));
+#ifndef __alpha
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));
-extern void exit __proto((int));
+#endif
extern char *ctime __proto((time_t *));
-extern int getopt __proto((int, char **, const char *));
extern char *optarg;
extern int optind;
{
/*
* Snarf up any array bounds in the correct order. Arrays
- * store 5 succesive words in the aux. table:
+ * store 5 successive words in the aux. table:
* word 0 RNDXR to type of the bounds (ie, int)
* word 1 Current file descriptor index
* word 2 low bound
printf(" %-*s %11s %11s %11s\n", width, "====", "======", "======", "=====\n");
printf(" %-*s %11ld %11d %11d [%d]\n", width, "Line numbers",
- sym_ptr->cbLineOffset, sym_ptr->cbLine, sym_ptr->cbLine, sym_ptr->ilineMax);
+ (long)sym_ptr->cbLineOffset,
+ (long)sym_ptr->cbLine,
+ (long)sym_ptr->cbLine,
+ (int)sym_ptr->ilineMax);
printf(" %-*s %11ld %11d %11d\n", width, "Dense numbers",
- sym_ptr->cbDnOffset, sym_ptr->idnMax, sym_ptr->idnMax * sizeof (DNR));
+ (long)sym_ptr->cbDnOffset,
+ (long)sym_ptr->idnMax,
+ (long)(sym_ptr->idnMax * sizeof (DNR)));
printf(" %-*s %11ld %11d %11d\n", width, "Procedures Tables",
- sym_ptr->cbPdOffset, sym_ptr->ipdMax, sym_ptr->ipdMax * sizeof (PDR));
+ (long)sym_ptr->cbPdOffset,
+ (long)sym_ptr->ipdMax,
+ (long)(sym_ptr->ipdMax * sizeof (PDR)));
printf(" %-*s %11ld %11d %11d\n", width, "Local Symbols",
- sym_ptr->cbSymOffset, sym_ptr->isymMax, sym_ptr->isymMax * sizeof (SYMR));
+ (long)sym_ptr->cbSymOffset,
+ (long)sym_ptr->isymMax,
+ (long)(sym_ptr->isymMax * sizeof (SYMR)));
printf(" %-*s %11ld %11d %11d\n", width, "Optimization Symbols",
- sym_ptr->cbOptOffset, sym_ptr->ioptMax, sym_ptr->ioptMax * sizeof (OPTR));
+ (long)sym_ptr->cbOptOffset,
+ (long)sym_ptr->ioptMax,
+ (long)(sym_ptr->ioptMax * sizeof (OPTR)));
- printf(" %-*s %11ld %11d %11d\n", width, "Auxilary Symbols",
- sym_ptr->cbAuxOffset, sym_ptr->iauxMax, sym_ptr->iauxMax * sizeof (AUXU));
+ printf(" %-*s %11ld %11d %11d\n", width, "Auxiliary Symbols",
+ (long)sym_ptr->cbAuxOffset,
+ (long)sym_ptr->iauxMax,
+ (long)(sym_ptr->iauxMax * sizeof (AUXU)));
printf(" %-*s %11ld %11d %11d\n", width, "Local Strings",
- sym_ptr->cbSsOffset, sym_ptr->issMax, sym_ptr->issMax);
+ (long)sym_ptr->cbSsOffset,
+ (long)sym_ptr->issMax,
+ (long)sym_ptr->issMax);
printf(" %-*s %11ld %11d %11d\n", width, "External Strings",
- sym_ptr->cbSsExtOffset, sym_ptr->issExtMax, sym_ptr->issExtMax);
+ (long)sym_ptr->cbSsExtOffset,
+ (long)sym_ptr->issExtMax,
+ (long)sym_ptr->issExtMax);
printf(" %-*s %11ld %11d %11d\n", width, "File Tables",
- sym_ptr->cbFdOffset, sym_ptr->ifdMax, sym_ptr->ifdMax * sizeof (FDR));
+ (long)sym_ptr->cbFdOffset,
+ (long)sym_ptr->ifdMax,
+ (long)(sym_ptr->ifdMax * sizeof (FDR)));
printf(" %-*s %11ld %11d %11d\n", width, "Relative Files",
- sym_ptr->cbRfdOffset, sym_ptr->crfd, sym_ptr->crfd * sizeof (ulong));
+ (long)sym_ptr->cbRfdOffset,
+ (long)sym_ptr->crfd,
+ (long)(sym_ptr->crfd * sizeof (ulong)));
printf(" %-*s %11ld %11d %11d\n", width, "External Symbols",
- sym_ptr->cbExtOffset, sym_ptr->iextMax, sym_ptr->iextMax * sizeof (EXTR));
+ (long)sym_ptr->cbExtOffset,
+ (long)sym_ptr->iextMax,
+ (long)(sym_ptr->iextMax * sizeof (EXTR)));
}
\f
(ulong) fdp->crfd,
(ulong) fdp->rfdBase);
- rfd_ptr = rfile_desc + fdp->rfdBase * sizeof (ulong);
+ rfd_ptr = rfile_desc + fdp->rfdBase;
for (i = 0; i < fdp->crfd; i++)
{
printf ("\t#%-5ld %11ld, 0x%08lx\n", i, *rfd_ptr, *rfd_ptr);
short magic;
off_t sym_hdr_offset = 0;
- /* Determine if this is a .T file (which has no file header), or some
- sort of object file (which does have a file header) via the magic
- number. */
(void) read_seek ((PTR_T) &magic, sizeof (magic), (off_t)0, "Magic number");
- if (magic == MIPSELMAGIC || magic == MIPSEBMAGIC)
+ if (!tfile)
{
+ /* Print out the global header, since this is not a T-file. */
+
(void) read_seek ((PTR_T) &global_hdr, sizeof (global_hdr), (off_t)0,
"Global file header");
aux_symbols = (AUXU *) read_seek ((PTR_T)0,
sym_hdr.iauxMax * sizeof (AUXU),
sym_hdr.cbAuxOffset,
- "Auxilary symbols");
+ "Auxiliary symbols");
if (sym_hdr.iauxMax > 0)
{
/*
* Process arguments
*/
- while ((opt = getopt (argc, argv, "alrs")) != EOF)
+ while ((opt = getopt (argc, argv, "alrst")) != EOF)
switch (opt)
{
default: errors++; break;
case 'l': want_line++; break; /* print line numbers */
case 'r': want_rfd++; break; /* print relative fd's */
case 's': want_scope++; break; /* print scope info */
+ case 't': tfile++; break; /* this is a tfile (without header), and not a .o */
}
if (errors || optind != argc - 1)
{
fprintf (stderr, "Calling Sequence:\n");
- fprintf (stderr, "\t%0 [-alrs] <object-or-T-file>\n", argv[0]);
+ fprintf (stderr, "\t%0 [-alrst] <object-or-T-file>\n", argv[0]);
fprintf (stderr, "\n");
fprintf (stderr, "switches:\n");
fprintf (stderr, "\t-a Print out auxiliary table.\n");
fprintf (stderr, "\t-l Print out line numbers.\n");
fprintf (stderr, "\t-r Print out relative file descriptors.\n");
fprintf (stderr, "\t-s Print out the current scopes for an item.\n");
+ fprintf (stderr, "\t-t Assume there is no global header (ie, a T-file).\n");
return 1;
}