1 /* Sysroff object format dumper.
2 Copyright 1994, 1995, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 /* Written by Steve Chamberlain <sac@cygnus.com>.
25 This program reads a SYSROFF object file and prints it in an
26 almost human readable form to stdout. */
30 #include "safe-ctype.h"
33 #include "libiberty.h"
38 static int segmented_p
;
40 static int addrsize
= 4;
43 static void dh
PARAMS ((unsigned char *, int));
44 static void itheader
PARAMS ((char *, int));
45 static void p
PARAMS ((void));
46 static void tabout
PARAMS ((void));
47 static void pbarray
PARAMS ((barray
*));
48 static int getone
PARAMS ((int));
49 static int opt
PARAMS ((int));
50 static void must
PARAMS ((int));
51 static void tab
PARAMS ((int, char *));
52 static void dump_symbol_info
PARAMS ((void));
53 static void derived_type
PARAMS ((void));
54 static void module
PARAMS ((void));
55 static void show_usage
PARAMS ((FILE *, int));
57 extern char *getCHARS
PARAMS ((unsigned char *, int *, int, int));
58 extern int fillup
PARAMS ((char *));
59 extern barray getBARRAY
PARAMS ((unsigned char *, int *, int, int));
60 extern int getINT
PARAMS ((unsigned char *, int *, int, int));
61 extern int getBITS
PARAMS ((char *, int *, int, int));
62 extern void sysroff_swap_tr_in
PARAMS ((void));
63 extern void sysroff_print_tr_out
PARAMS ((void));
64 extern int main
PARAMS ((int, char **));
67 getCHARS (ptr
, idx
, size
, max
)
82 /* Got to work out the length of the string from self. */
88 r
= xcalloc (b
+ 1, 1);
89 memcpy (r
, ptr
+ oc
, b
);
104 printf ("\n************************************************************\n");
106 for (i
= 0; i
< size
; i
+= span
)
108 for (j
= 0; j
< span
; j
++)
111 printf ("%02x ", ptr
[i
+ j
]);
116 for (j
= 0; j
< span
&& j
+ i
< size
; j
++)
120 if (c
< 32 || c
> 127)
137 size
= getc (file
) - 2;
138 fread (ptr
, 1, size
, file
);
139 sum
= code
+ size
+ 2;
141 for (i
= 0; i
< size
; i
++)
144 if ((sum
& 0xff) != 0xff)
145 printf ("SUM IS %x\n", sum
);
154 getBARRAY (ptr
, idx
, dsize
, max
)
157 int dsize ATTRIBUTE_UNUSED
;
158 int max ATTRIBUTE_UNUSED
;
163 int size
= ptr
[byte
++];
166 res
.data
= (unsigned char *) xmalloc (size
);
168 for (i
= 0; i
< size
; i
++)
169 res
.data
[i
] = ptr
[byte
++];
175 getINT (ptr
, idx
, size
, max
)
201 n
= (ptr
[byte
+ 0] << 8) + ptr
[byte
+ 1];
204 n
= (ptr
[byte
+ 0] << 24) + (ptr
[byte
+ 1] << 16) + (ptr
[byte
+ 2] << 8) + (ptr
[byte
+ 3]);
215 getBITS (ptr
, idx
, size
, max
)
228 return (ptr
[byte
] >> (8 - bit
- size
)) & ((1 << size
) - 1);
232 itheader (name
, code
)
236 printf ("\n%s 0x%02x\n", name
, code
);
246 for (i
= 0; i
< indent
; i
++)
264 printf ("%d (", y
->len
);
266 for (x
= 0; x
< y
->len
; x
++)
267 printf ("(%02x %c)", y
->data
[x
],
268 ISPRINT (y
->data
[x
]) ? y
->data
[x
] : '.');
273 #define SYSROFF_PRINT
274 #define SYSROFF_SWAP_IN
278 /* FIXME: sysinfo, which generates sysroff.[ch] from sysroff.info, can't
279 hack the special case of the tr block, which has no contents. So we
280 implement our own functions for reading in and printing out the tr
283 #define IT_tr_CODE 0x7f
290 memset (raw
, 0, 255);
295 sysroff_print_tr_out()
297 itheader ("tr", IT_tr_CODE
);
308 if ((c
& 0x7f) != type
)
319 sysroff_swap_cs_in (&dummy
);
320 sysroff_print_cs_out (&dummy
);
327 sysroff_swap_dln_in (&dummy
);
328 sysroff_print_dln_out (&dummy
);
335 sysroff_swap_hd_in (&dummy
);
336 addrsize
= dummy
.afl
;
337 sysroff_print_hd_out (&dummy
);
344 sysroff_swap_dar_in (&dummy
);
345 sysroff_print_dar_out (&dummy
);
352 sysroff_swap_dsy_in (&dummy
);
353 sysroff_print_dsy_out (&dummy
);
360 sysroff_swap_dfp_in (&dummy
);
361 sysroff_print_dfp_out (&dummy
);
368 sysroff_swap_dso_in (&dummy
);
369 sysroff_print_dso_out (&dummy
);
376 sysroff_swap_dpt_in (&dummy
);
377 sysroff_print_dpt_out (&dummy
);
384 sysroff_swap_den_in (&dummy
);
385 sysroff_print_den_out (&dummy
);
392 sysroff_swap_dbt_in (&dummy
);
393 sysroff_print_dbt_out (&dummy
);
400 sysroff_swap_dty_in (&dummy
);
401 sysroff_print_dty_out (&dummy
);
408 sysroff_swap_un_in (&dummy
);
409 sysroff_print_un_out (&dummy
);
416 sysroff_swap_sc_in (&dummy
);
417 sysroff_print_sc_out (&dummy
);
424 sysroff_swap_er_in (&dummy
);
425 sysroff_print_er_out (&dummy
);
432 sysroff_swap_ed_in (&dummy
);
433 sysroff_print_ed_out (&dummy
);
440 sysroff_swap_sh_in (&dummy
);
441 sysroff_print_sh_out (&dummy
);
448 sysroff_swap_ob_in (&dummy
);
449 sysroff_print_ob_out (&dummy
);
456 sysroff_swap_rl_in (&dummy
);
457 sysroff_print_rl_out (&dummy
);
464 sysroff_swap_du_in (&dummy
);
466 sysroff_print_du_out (&dummy
);
473 sysroff_swap_dus_in (&dummy
);
474 sysroff_print_dus_out (&dummy
);
481 sysroff_swap_dul_in (&dummy
);
482 sysroff_print_dul_out (&dummy
);
489 sysroff_swap_dss_in (&dummy
);
490 sysroff_print_dss_out (&dummy
);
497 sysroff_swap_hs_in (&dummy
);
498 sysroff_print_hs_out (&dummy
);
505 sysroff_swap_dps_in (&dummy
);
506 sysroff_print_dps_out (&dummy
);
511 sysroff_swap_tr_in ();
512 sysroff_print_tr_out ();
519 sysroff_swap_dds_in (&dummy
);
520 sysroff_print_dds_out (&dummy
);
525 printf ("GOT A %x\n", c
);
542 /* This is no longer used. */
547 while (opt (IT_un_CODE
))
551 while (getone (IT_sc_CODE
))
554 while (getone (IT_er_CODE
))
557 while (getone (IT_ed_CODE
))
566 /* This is no longer used. */
571 while (getone (IT_sh_CODE
))
573 while (getone (IT_ob_CODE
))
575 while (getone (IT_rl_CODE
))
587 printf ("WANTED %x!!\n", x
);
608 tab (1, "SYMBOL INFO");
610 while (opt (IT_dsy_CODE
))
612 if (opt (IT_dty_CODE
))
626 tab (1, "DERIVED TYPE");
630 if (opt (IT_dpp_CODE
))
635 else if (opt (IT_dfp_CODE
))
640 else if (opt (IT_den_CODE
))
645 else if (opt (IT_den_CODE
))
650 else if (opt (IT_dds_CODE
))
655 else if (opt (IT_dar_CODE
))
658 else if (opt (IT_dpt_CODE
))
661 else if (opt (IT_dul_CODE
))
664 else if (opt (IT_dse_CODE
))
667 else if (opt (IT_dot_CODE
))
679 /* This is no longer used. */
684 tab (1, "PROGRAM STRUCTURE");
685 while (opt (IT_dps_CODE
))
699 /* This is no longer used. */
704 tab (1, "DEBUG LIST");
708 program_structure ();
722 tab (1, "MODULE***\n");
731 while (getone (c
) && c
!= IT_tr_CODE
);
763 show_usage (file
, status
)
767 fprintf (file
, _("Usage: %s [option(s)] in-file\n"), program_name
);
768 fprintf (file
, _("Print a human readable interpretation of a SYSROFF object file\n"));
769 fprintf (file
, _(" The options are:\n\
770 -h --help Display this information\n\
771 -v --version Print the program's version number\n"));
774 fprintf (file
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
783 char *input_file
= NULL
;
785 static struct option long_options
[] =
787 {"help", no_argument
, 0, 'h'},
788 {"version", no_argument
, 0, 'V'},
789 {NULL
, no_argument
, 0, 0}
792 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
793 setlocale (LC_MESSAGES
, "");
795 #if defined (HAVE_SETLOCALE)
796 setlocale (LC_CTYPE
, "");
798 bindtextdomain (PACKAGE
, LOCALEDIR
);
799 textdomain (PACKAGE
);
801 program_name
= av
[0];
802 xmalloc_set_program_name (program_name
);
804 while ((opt
= getopt_long (ac
, av
, "HhVv", long_options
, (int *) NULL
)) != EOF
)
810 show_usage (stdout
, 0);
814 print_version ("sysdump");
820 show_usage (stderr
, 1);
825 /* The input and output files may be named on the command line. */
828 input_file
= av
[optind
];
831 fatal (_("no input file specified"));
833 file
= fopen (input_file
, FOPEN_RB
);
836 fatal (_("cannot open input file %s"), input_file
);
This page took 0.04541 seconds and 4 git commands to generate.