1 /* Sysroff object format dumper.
2 Copyright 1994, 1995, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 /* Written by Steve Chamberlain <sac@cygnus.com>.
24 This program reads a SYSROFF object file and prints it in an
25 almost human readable form to stdout. */
29 #include "safe-ctype.h"
32 #include <libiberty.h>
36 #define PROGRAM_VERSION "1.0"
39 static int segmented_p
;
41 static int addrsize
= 4;
44 static void dh
PARAMS ((unsigned char *, int));
45 static void itheader
PARAMS ((char *, int));
46 static void p
PARAMS ((void));
47 static void tabout
PARAMS ((void));
48 static void pbarray
PARAMS ((barray
*));
49 static int getone
PARAMS ((int));
50 static int opt
PARAMS ((int));
51 static void must
PARAMS ((int));
52 static void tab
PARAMS ((int, char *));
53 static void dump_symbol_info
PARAMS ((void));
54 static void derived_type
PARAMS ((void));
55 static void module
PARAMS ((void));
56 static void show_usage
PARAMS ((FILE *, int));
57 static void show_help
PARAMS ((void));
59 extern char *getCHARS
PARAMS ((unsigned char *, int *, int, int));
60 extern int fillup
PARAMS ((char *));
61 extern barray getBARRAY
PARAMS ((unsigned char *, int *, int, int));
62 extern int getINT
PARAMS ((unsigned char *, int *, int, int));
63 extern int getBITS
PARAMS ((char *, int *, int, int));
64 extern void sysroff_swap_tr_in
PARAMS ((void));
65 extern void sysroff_print_tr_out
PARAMS ((void));
66 extern int main
PARAMS ((int, char **));
69 getCHARS (ptr
, idx
, size
, max
)
85 /* Got to work out the length of the string from self */
91 r
= xcalloc (b
+ 1, 1);
92 memcpy (r
, ptr
+ oc
, b
);
106 printf ("\n************************************************************\n");
108 for (i
= 0; i
< size
; i
+= span
)
110 for (j
= 0; j
< span
; j
++)
113 printf ("%02x ", ptr
[i
+ j
]);
118 for (j
= 0; j
< span
&& j
+ i
< size
; j
++)
121 if (c
< 32 || c
> 127)
136 size
= getc (file
) - 2;
137 fread (ptr
, 1, size
, file
);
138 sum
= code
+ size
+ 2;
139 for (i
= 0; i
< size
; i
++)
144 if ((sum
& 0xff) != 0xff)
146 printf ("SUM IS %x\n", sum
);
155 getBARRAY (ptr
, idx
, dsize
, max
)
158 int dsize ATTRIBUTE_UNUSED
;
159 int max ATTRIBUTE_UNUSED
;
164 int size
= ptr
[byte
++];
166 res
.data
= (unsigned char *) xmalloc (size
);
167 for (i
= 0; i
< size
; i
++)
169 res
.data
[i
] = ptr
[byte
++];
175 getINT (ptr
, idx
, size
, max
)
200 n
= (ptr
[byte
+ 0] << 8) + ptr
[byte
+ 1];
203 n
= (ptr
[byte
+ 0] << 24) + (ptr
[byte
+ 1] << 16) + (ptr
[byte
+ 2] << 8) + (ptr
[byte
+ 3]);
213 getBITS (ptr
, idx
, size
, max
)
226 return (ptr
[byte
] >> (8 - bit
- size
)) & ((1 << size
) - 1);
230 itheader (name
, code
)
234 printf ("\n%s 0x%02x\n", name
, code
);
242 for (i
= 0; i
< indent
; i
++)
260 printf ("%d (", y
->len
);
261 for (x
= 0; x
< y
->len
; x
++)
263 printf ("(%02x %c)", y
->data
[x
],
264 ISPRINT (y
->data
[x
]) ? y
->data
[x
] : '.');
269 #define SYSROFF_PRINT
270 #define SYSROFF_SWAP_IN
275 * FIXME: sysinfo, which generates sysroff.[ch] from sysroff.info, can't
276 * hack the special case of the tr block, which has no contents. So we
277 * implement our own functions for reading in and printing out the tr
281 #define IT_tr_CODE 0x7f
292 sysroff_print_tr_out()
294 itheader("tr", IT_tr_CODE
);
304 if ((c
& 0x7f) != type
)
315 sysroff_swap_cs_in (&dummy
);
316 sysroff_print_cs_out (&dummy
);
322 sysroff_swap_dln_in (&dummy
);
323 sysroff_print_dln_out (&dummy
);
329 sysroff_swap_hd_in (&dummy
);
330 addrsize
= dummy
.afl
;
331 sysroff_print_hd_out (&dummy
);
337 sysroff_swap_dar_in (&dummy
);
338 sysroff_print_dar_out (&dummy
);
344 sysroff_swap_dsy_in (&dummy
);
345 sysroff_print_dsy_out (&dummy
);
351 sysroff_swap_dfp_in (&dummy
);
352 sysroff_print_dfp_out (&dummy
);
358 sysroff_swap_dso_in (&dummy
);
359 sysroff_print_dso_out (&dummy
);
365 sysroff_swap_dpt_in (&dummy
);
366 sysroff_print_dpt_out (&dummy
);
372 sysroff_swap_den_in (&dummy
);
373 sysroff_print_den_out (&dummy
);
379 sysroff_swap_dbt_in (&dummy
);
380 sysroff_print_dbt_out (&dummy
);
386 sysroff_swap_dty_in (&dummy
);
387 sysroff_print_dty_out (&dummy
);
393 sysroff_swap_un_in (&dummy
);
394 sysroff_print_un_out (&dummy
);
400 sysroff_swap_sc_in (&dummy
);
401 sysroff_print_sc_out (&dummy
);
407 sysroff_swap_er_in (&dummy
);
408 sysroff_print_er_out (&dummy
);
414 sysroff_swap_ed_in (&dummy
);
415 sysroff_print_ed_out (&dummy
);
421 sysroff_swap_sh_in (&dummy
);
422 sysroff_print_sh_out (&dummy
);
428 sysroff_swap_ob_in (&dummy
);
429 sysroff_print_ob_out (&dummy
);
435 sysroff_swap_rl_in (&dummy
);
436 sysroff_print_rl_out (&dummy
);
442 sysroff_swap_du_in (&dummy
);
444 sysroff_print_du_out (&dummy
);
450 sysroff_swap_dus_in (&dummy
);
451 sysroff_print_dus_out (&dummy
);
457 sysroff_swap_dul_in (&dummy
);
458 sysroff_print_dul_out (&dummy
);
464 sysroff_swap_dss_in (&dummy
);
465 sysroff_print_dss_out (&dummy
);
471 sysroff_swap_hs_in (&dummy
);
472 sysroff_print_hs_out (&dummy
);
478 sysroff_swap_dps_in (&dummy
);
479 sysroff_print_dps_out (&dummy
);
484 sysroff_swap_tr_in ();
485 sysroff_print_tr_out ();
491 sysroff_swap_dds_in (&dummy
);
492 sysroff_print_dds_out (&dummy
);
496 printf ("GOT A %x\n", c
);
512 /* This is no longer used. */
517 while (opt (IT_un_CODE
))
521 while (getone (IT_sc_CODE
))
524 while (getone (IT_er_CODE
))
527 while (getone (IT_ed_CODE
))
536 /* This is no longer used. */
541 while (getone (IT_sh_CODE
))
543 while (getone (IT_ob_CODE
))
545 while (getone (IT_rl_CODE
))
558 printf ("WANTED %x!!\n", x
);
579 tab (1, "SYMBOL INFO");
580 while (opt (IT_dsy_CODE
))
582 if (opt (IT_dty_CODE
))
595 tab (1, "DERIVED TYPE");
598 if (opt (IT_dpp_CODE
))
603 else if (opt (IT_dfp_CODE
))
608 else if (opt (IT_den_CODE
))
613 else if (opt (IT_den_CODE
))
618 else if (opt (IT_dds_CODE
))
623 else if (opt (IT_dar_CODE
))
626 else if (opt (IT_dpt_CODE
))
629 else if (opt (IT_dul_CODE
))
632 else if (opt (IT_dse_CODE
))
635 else if (opt (IT_dot_CODE
))
647 /* This is no longer used. */
652 tab (1, "PROGRAM STRUCTURE");
653 while (opt (IT_dps_CODE
))
667 /* This is no longer used. */
672 tab (1, "DEBUG LIST");
676 program_structure ();
690 tab (1, "MODULE***\n");
699 while (getone (c
) && c
!= IT_tr_CODE
);
731 show_usage (file
, status
)
735 fprintf (file
, _("Usage: %s [-hV] in-file\n"), program_name
);
742 printf (_("%s: Print a human readable interpretation of a SYSROFF object file\n"),
744 show_usage (stdout
, 0);
752 char *input_file
= NULL
;
754 static struct option long_options
[] =
756 {"help", no_argument
, 0, 'h'},
757 {"version", no_argument
, 0, 'V'},
758 {NULL
, no_argument
, 0, 0}
761 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
762 setlocale (LC_MESSAGES
, "");
764 #if defined (HAVE_SETLOCALE)
765 setlocale (LC_CTYPE
, "");
767 bindtextdomain (PACKAGE
, LOCALEDIR
);
768 textdomain (PACKAGE
);
770 program_name
= av
[0];
771 xmalloc_set_program_name (program_name
);
773 while ((opt
= getopt_long (ac
, av
, "hV", long_options
, (int *) NULL
)) != EOF
)
781 printf (_("GNU %s version %s\n"), program_name
, PROGRAM_VERSION
);
787 show_usage (stderr
, 1);
792 /* The input and output files may be named on the command line. */
796 input_file
= av
[optind
];
801 fatal (_("no input file specified"));
804 file
= fopen (input_file
, FOPEN_RB
);
807 fatal (_("cannot open input file %s"), input_file
);
This page took 0.047627 seconds and 4 git commands to generate.