Commit 45a647be by Kaveh R. Ghazi Committed by Kaveh Ghazi

mips-tfile.c: Cast arg to PTR when specifier is HOST_PTR_PRINTF.

	* mips-tfile.c: Cast arg to PTR when specifier is HOST_PTR_PRINTF.
	(__proto, PTR_T, CPTR_T): Delete, use PARAMS/PTR instead.
	(local_index, local_rindex): Delete, use strchr/strrchr instead.
	(copy_object): Fix format specifier vs argument mismatch.

	* mips-tdump.c: Make local functions static.
	(rindex): Don't #undef.
	(__proto, PTR_T, CPTR_T): Delete, use PARAMS/PTR instead.
	(fatal, fancy_abort): Delete.
	(read_seek): Avoid signed/unsigned compare.

From-SVN: r40391
parent c7ca5912
2001-03-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* mips-tfile.c: Cast arg to PTR when specifier is HOST_PTR_PRINTF.
(__proto, PTR_T, CPTR_T): Delete, use PARAMS/PTR instead.
(local_index, local_rindex): Delete, use strchr/strrchr instead.
(copy_object): Fix format specifier vs argument mismatch.
* mips-tdump.c: Make local functions static.
(rindex): Don't #undef.
(__proto, PTR_T, CPTR_T): Delete, use PARAMS/PTR instead.
(fatal, fancy_abort): Delete.
(read_seek): Avoid signed/unsigned compare.
Sun Mar 11 17:01:41 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> Sun Mar 11 17:01:41 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* combine.c (try_combine): Fix error in change to try original * combine.c (try_combine): Fix error in change to try original
......
...@@ -25,7 +25,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -25,7 +25,6 @@ Boston, MA 02111-1307, USA. */
#include "system.h" #include "system.h"
#ifdef index #ifdef index
#undef index #undef index
#undef rindex
#endif #endif
#ifndef CROSS_COMPILE #ifndef CROSS_COMPILE
#include <a.out.h> #include <a.out.h>
...@@ -47,34 +46,11 @@ Boston, MA 02111-1307, USA. */ ...@@ -47,34 +46,11 @@ Boston, MA 02111-1307, USA. */
#define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK) #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK)
#endif #endif
#define __proto(x) PARAMS(x)
typedef PTR PTR_T;
typedef const PTR_T CPTR_T;
#define uchar unsigned char #define uchar unsigned char
#define ushort unsigned short #define ushort unsigned short
#define uint unsigned int #define uint unsigned int
#define ulong unsigned long #define ulong unsigned long
void fatal PARAMS ((const char *)) ATTRIBUTE_NORETURN;
void fancy_abort PARAMS ((void)) ATTRIBUTE_NORETURN;
void
fatal (s)
const char *s;
{
fprintf (stderr, "%s\n", s);
exit (FATAL_EXIT_CODE);
}
/* 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. */
#define size_t uint
#define ptrdiff_t int
/* Redefinition of storage classes as an enumeration for better /* Redefinition of storage classes as an enumeration for better
debugging. */ debugging. */
...@@ -250,19 +226,19 @@ ulong *rfile_desc; /* relative file tables */ ...@@ -250,19 +226,19 @@ ulong *rfile_desc; /* relative file tables */
PDR *proc_desc; /* procedure tables */ PDR *proc_desc; /* procedure tables */
/* Forward reference for functions. */ /* Forward reference for functions. */
PTR_T read_seek __proto((PTR_T, size_t, off_t, const char *)); static PTR read_seek PARAMS ((PTR, size_t, off_t, const char *));
void read_tfile __proto((void)); static void read_tfile PARAMS ((void));
void print_global_hdr __proto((struct filehdr *)); static void print_global_hdr PARAMS ((struct filehdr *));
void print_sym_hdr __proto((HDRR *)); static void print_sym_hdr PARAMS ((HDRR *));
void print_file_desc __proto((FDR *, int)); static void print_file_desc PARAMS ((FDR *, int));
void print_symbol __proto((SYMR *, int, char *, AUXU *, int, FDR *)); static void print_symbol PARAMS ((SYMR *, int, const char *, AUXU *, int, FDR *));
void print_aux __proto((AUXU, int, int)); static void print_aux PARAMS ((AUXU, int, int));
void emit_aggregate __proto((char *, AUXU, AUXU, const char *, FDR *)); static void emit_aggregate PARAMS ((char *, AUXU, AUXU, const char *, FDR *));
const char *st_to_string __proto((st_t)); static const char *st_to_string PARAMS ((st_t));
const char *sc_to_string __proto((sc_t)); static const char *sc_to_string PARAMS ((sc_t));
const char *glevel_to_string __proto((glevel_t)); static const char *glevel_to_string PARAMS ((glevel_t));
const char *lang_to_string __proto((lang_t)); static const char *lang_to_string PARAMS ((lang_t));
const char *type_to_string __proto((AUXU *, int, FDR *)); static const char *type_to_string PARAMS ((AUXU *, int, FDR *));
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
...@@ -279,9 +255,9 @@ struct {short code; char string[10];} stab_names[] = { ...@@ -279,9 +255,9 @@ struct {short code; char string[10];} stab_names[] = {
/* Read some bytes at a specified location, and return a pointer. */ /* Read some bytes at a specified location, and return a pointer. */
PTR_T static PTR
read_seek (ptr, size, offset, context) read_seek (ptr, size, offset, context)
PTR_T ptr; /* pointer to buffer or NULL */ PTR ptr; /* pointer to buffer or NULL */
size_t size; /* # bytes to read */ size_t size; /* # bytes to read */
off_t offset; /* offset to read at */ off_t offset; /* offset to read at */
const char *context; /* context for error message */ const char *context; /* context for error message */
...@@ -291,15 +267,17 @@ read_seek (ptr, size, offset, context) ...@@ -291,15 +267,17 @@ read_seek (ptr, size, offset, context)
if (size == 0) /* nothing to read */ if (size == 0) /* nothing to read */
return ptr; return ptr;
if ((ptr == (PTR_T) 0 && (ptr = xmalloc (size)) == (PTR_T) 0) if (!ptr)
|| (tfile_offset != offset && lseek (tfile_fd, offset, 0) == -1) ptr = xmalloc (size);
if ((tfile_offset != offset && lseek (tfile_fd, offset, 0) == -1)
|| (read_size = read (tfile_fd, ptr, size)) < 0) || (read_size = read (tfile_fd, ptr, size)) < 0)
{ {
perror (context); perror (context);
exit (1); exit (1);
} }
if (read_size != size) if (read_size != (long) size)
{ {
fprintf (stderr, "%s: read %ld bytes, expected %ld bytes\n", fprintf (stderr, "%s: read %ld bytes, expected %ld bytes\n",
context, read_size, (long) size); context, read_size, (long) size);
...@@ -313,7 +291,7 @@ read_seek (ptr, size, offset, context) ...@@ -313,7 +291,7 @@ read_seek (ptr, size, offset, context)
/* Convert language code to string format. */ /* Convert language code to string format. */
const char * static const char *
lang_to_string (lang) lang_to_string (lang)
lang_t lang; lang_t lang;
{ {
...@@ -336,7 +314,7 @@ lang_to_string (lang) ...@@ -336,7 +314,7 @@ lang_to_string (lang)
/* Convert storage class to string. */ /* Convert storage class to string. */
const char * static const char *
sc_to_string(storage_class) sc_to_string(storage_class)
sc_t storage_class; sc_t storage_class;
{ {
...@@ -374,7 +352,7 @@ sc_to_string(storage_class) ...@@ -374,7 +352,7 @@ sc_to_string(storage_class)
/* Convert symbol type to string. */ /* Convert symbol type to string. */
const char * static const char *
st_to_string(symbol_type) st_to_string(symbol_type)
st_t symbol_type; st_t symbol_type;
{ {
...@@ -415,7 +393,7 @@ st_to_string(symbol_type) ...@@ -415,7 +393,7 @@ st_to_string(symbol_type)
/* Convert debug level to string. */ /* Convert debug level to string. */
const char * static const char *
glevel_to_string (g_level) glevel_to_string (g_level)
glevel_t g_level; glevel_t g_level;
{ {
...@@ -433,7 +411,7 @@ glevel_to_string (g_level) ...@@ -433,7 +411,7 @@ glevel_to_string (g_level)
/* Convert the type information to string format. */ /* Convert the type information to string format. */
const char * static const char *
type_to_string (aux_ptr, index, fdp) type_to_string (aux_ptr, index, fdp)
AUXU *aux_ptr; AUXU *aux_ptr;
int index; int index;
...@@ -746,7 +724,7 @@ type_to_string (aux_ptr, index, fdp) ...@@ -746,7 +724,7 @@ type_to_string (aux_ptr, index, fdp)
/* Print out the global file header for object files. */ /* Print out the global file header for object files. */
void static void
print_global_hdr (ptr) print_global_hdr (ptr)
struct filehdr *ptr; struct filehdr *ptr;
{ {
...@@ -801,7 +779,7 @@ print_global_hdr (ptr) ...@@ -801,7 +779,7 @@ print_global_hdr (ptr)
/* Print out the symbolic header. */ /* Print out the symbolic header. */
void static void
print_sym_hdr (sym_ptr) print_sym_hdr (sym_ptr)
HDRR *sym_ptr; HDRR *sym_ptr;
{ {
...@@ -875,11 +853,11 @@ print_sym_hdr (sym_ptr) ...@@ -875,11 +853,11 @@ print_sym_hdr (sym_ptr)
/* Print out a symbol. */ /* Print out a symbol. */
void static void
print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp) print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp)
SYMR *sym_ptr; SYMR *sym_ptr;
int number; int number;
char *strbase; const char *strbase;
AUXU *aux_base; AUXU *aux_base;
int ifd; int ifd;
FDR *fdp; FDR *fdp;
...@@ -1054,7 +1032,7 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp) ...@@ -1054,7 +1032,7 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp)
/* Print out a word from the aux. table in various formats. */ /* Print out a word from the aux. table in various formats. */
void static void
print_aux (u, auxi, used) print_aux (u, auxi, used)
AUXU u; AUXU u;
int auxi; int auxi;
...@@ -1080,7 +1058,7 @@ print_aux (u, auxi, used) ...@@ -1080,7 +1058,7 @@ print_aux (u, auxi, used)
/* Write aggregate information to a string. */ /* Write aggregate information to a string. */
void static void
emit_aggregate (string, u, u2, which, fdp) emit_aggregate (string, u, u2, which, fdp)
char *string; char *string;
AUXU u; AUXU u;
...@@ -1120,7 +1098,7 @@ emit_aggregate (string, u, u2, which, fdp) ...@@ -1120,7 +1098,7 @@ emit_aggregate (string, u, u2, which, fdp)
/* Print out information about a file descriptor, and the symbols, /* Print out information about a file descriptor, and the symbols,
procedures, and line numbers within it. */ procedures, and line numbers within it. */
void static void
print_file_desc (fdp, number) print_file_desc (fdp, number)
FDR *fdp; FDR *fdp;
int number; int number;
...@@ -1348,18 +1326,18 @@ print_file_desc (fdp, number) ...@@ -1348,18 +1326,18 @@ print_file_desc (fdp, number)
/* Read in the portions of the .T file that we will print out. */ /* Read in the portions of the .T file that we will print out. */
void static void
read_tfile __proto((void)) read_tfile ()
{ {
short magic; short magic;
off_t sym_hdr_offset = 0; off_t sym_hdr_offset = 0;
(void) read_seek ((PTR_T) &magic, sizeof (magic), (off_t) 0, "Magic number"); (void) read_seek ((PTR) &magic, sizeof (magic), (off_t) 0, "Magic number");
if (!tfile) if (!tfile)
{ {
/* Print out the global header, since this is not a T-file. */ /* 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, (void) read_seek ((PTR) &global_hdr, sizeof (global_hdr), (off_t) 0,
"Global file header"); "Global file header");
print_global_hdr (&global_hdr); print_global_hdr (&global_hdr);
...@@ -1373,39 +1351,39 @@ read_tfile __proto((void)) ...@@ -1373,39 +1351,39 @@ read_tfile __proto((void))
sym_hdr_offset = global_hdr.f_symptr; sym_hdr_offset = global_hdr.f_symptr;
} }
(void) read_seek ((PTR_T) &sym_hdr, (void) read_seek ((PTR) &sym_hdr,
sizeof (sym_hdr), sizeof (sym_hdr),
sym_hdr_offset, sym_hdr_offset,
"Symbolic header"); "Symbolic header");
print_sym_hdr (&sym_hdr); print_sym_hdr (&sym_hdr);
lines = (LINER *) read_seek ((PTR_T) 0, lines = (LINER *) read_seek (NULL_PTR,
sym_hdr.cbLine, sym_hdr.cbLine,
sym_hdr.cbLineOffset, sym_hdr.cbLineOffset,
"Line numbers"); "Line numbers");
dense_nums = (DNR *) read_seek ((PTR_T) 0, dense_nums = (DNR *) read_seek (NULL_PTR,
sym_hdr.idnMax * sizeof (DNR), sym_hdr.idnMax * sizeof (DNR),
sym_hdr.cbDnOffset, sym_hdr.cbDnOffset,
"Dense numbers"); "Dense numbers");
proc_desc = (PDR *) read_seek ((PTR_T) 0, proc_desc = (PDR *) read_seek (NULL_PTR,
sym_hdr.ipdMax * sizeof (PDR), sym_hdr.ipdMax * sizeof (PDR),
sym_hdr.cbPdOffset, sym_hdr.cbPdOffset,
"Procedure tables"); "Procedure tables");
l_symbols = (SYMR *) read_seek ((PTR_T) 0, l_symbols = (SYMR *) read_seek (NULL_PTR,
sym_hdr.isymMax * sizeof (SYMR), sym_hdr.isymMax * sizeof (SYMR),
sym_hdr.cbSymOffset, sym_hdr.cbSymOffset,
"Local symbols"); "Local symbols");
opt_symbols = (OPTR *) read_seek ((PTR_T) 0, opt_symbols = (OPTR *) read_seek (NULL_PTR,
sym_hdr.ioptMax * sizeof (OPTR), sym_hdr.ioptMax * sizeof (OPTR),
sym_hdr.cbOptOffset, sym_hdr.cbOptOffset,
"Optimization symbols"); "Optimization symbols");
aux_symbols = (AUXU *) read_seek ((PTR_T) 0, aux_symbols = (AUXU *) read_seek (NULL_PTR,
sym_hdr.iauxMax * sizeof (AUXU), sym_hdr.iauxMax * sizeof (AUXU),
sym_hdr.cbAuxOffset, sym_hdr.cbAuxOffset,
"Auxiliary symbols"); "Auxiliary symbols");
...@@ -1413,27 +1391,27 @@ read_tfile __proto((void)) ...@@ -1413,27 +1391,27 @@ read_tfile __proto((void))
if (sym_hdr.iauxMax > 0) if (sym_hdr.iauxMax > 0)
aux_used = xcalloc (sym_hdr.iauxMax, 1); aux_used = xcalloc (sym_hdr.iauxMax, 1);
l_strings = (char *) read_seek ((PTR_T) 0, l_strings = (char *) read_seek (NULL_PTR,
sym_hdr.issMax, sym_hdr.issMax,
sym_hdr.cbSsOffset, sym_hdr.cbSsOffset,
"Local string table"); "Local string table");
e_strings = (char *) read_seek ((PTR_T) 0, e_strings = (char *) read_seek (NULL_PTR,
sym_hdr.issExtMax, sym_hdr.issExtMax,
sym_hdr.cbSsExtOffset, sym_hdr.cbSsExtOffset,
"External string table"); "External string table");
file_desc = (FDR *) read_seek ((PTR_T) 0, file_desc = (FDR *) read_seek (NULL_PTR,
sym_hdr.ifdMax * sizeof (FDR), sym_hdr.ifdMax * sizeof (FDR),
sym_hdr.cbFdOffset, sym_hdr.cbFdOffset,
"File tables"); "File tables");
rfile_desc = (ulong *) read_seek ((PTR_T) 0, rfile_desc = (ulong *) read_seek (NULL_PTR,
sym_hdr.crfd * sizeof (ulong), sym_hdr.crfd * sizeof (ulong),
sym_hdr.cbRfdOffset, sym_hdr.cbRfdOffset,
"Relative file tables"); "Relative file tables");
e_symbols = (EXTR *) read_seek ((PTR_T) 0, e_symbols = (EXTR *) read_seek (NULL_PTR,
sym_hdr.iextMax * sizeof (EXTR), sym_hdr.iextMax * sizeof (EXTR),
sym_hdr.cbExtOffset, sym_hdr.cbExtOffset,
"External symbols"); "External symbols");
...@@ -1568,11 +1546,3 @@ main (argc, argv) ...@@ -1568,11 +1546,3 @@ main (argc, argv)
return 0; return 0;
} }
void
fancy_abort ()
{
fprintf (stderr, "mips-tdump internal error");
exit (1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment