1 /* Sysroff object format dumper.
2 Copyright (C) 1994-2014 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 3 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., 51 Franklin Street - Fifth Floor, 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"
30 #include "libiberty.h"
36 static int segmented_p
;
38 static int addrsize
= 4;
41 static void dh (unsigned char *, int);
42 static void itheader (char *, int);
44 static void tabout (void);
45 static void pbarray (barray
*);
46 static int getone (int);
48 static void must (int);
49 static void tab (int, char *);
50 static void dump_symbol_info (void);
51 static void derived_type (void);
52 static void module (void);
53 static void show_usage (FILE *, int);
55 extern int main (int, char **);
58 getCHARS (unsigned char *ptr
, int *idx
, int size
, int max
)
65 return _("*undefined*");
69 /* Got to work out the length of the string from self. */
75 r
= xcalloc (b
+ 1, 1);
76 memcpy (r
, ptr
+ oc
, b
);
83 dh (unsigned char *ptr
, int size
)
89 printf ("\n************************************************************\n");
91 for (i
= 0; i
< size
; i
+= span
)
93 for (j
= 0; j
< span
; j
++)
96 printf ("%02x ", ptr
[i
+ j
]);
101 for (j
= 0; j
< span
&& j
+ i
< size
; j
++)
105 if (c
< 32 || c
> 127)
115 fillup (unsigned char *ptr
)
127 if (fread (ptr
, size
, 1, file
) != 1)
130 sum
= code
+ size
+ 2;
132 for (i
= 0; i
< size
; i
++)
135 if ((sum
& 0xff) != 0xff)
136 printf (_("SUM IS %x\n"), sum
);
145 getBARRAY (unsigned char *ptr
, int *idx
, int dsize ATTRIBUTE_UNUSED
,
146 int max ATTRIBUTE_UNUSED
)
151 int size
= ptr
[byte
++];
154 res
.data
= (unsigned char *) xmalloc (size
);
156 for (i
= 0; i
< size
; i
++)
157 res
.data
[i
] = ptr
[byte
++];
163 getINT (unsigned char *ptr
, int *idx
, int size
, int max
)
185 n
= (ptr
[byte
+ 0] << 8) + ptr
[byte
+ 1];
188 n
= (ptr
[byte
+ 0] << 24) + (ptr
[byte
+ 1] << 16) + (ptr
[byte
+ 2] << 8) + (ptr
[byte
+ 3]);
199 getBITS (unsigned char *ptr
, int *idx
, int size
, int max
)
209 return (ptr
[byte
] >> (8 - bit
- size
)) & ((1 << size
) - 1);
213 itheader (char *name
, int icode
)
215 printf ("\n%s 0x%02x\n", name
, icode
);
225 for (i
= 0; i
< indent
; i
++)
242 printf ("%d (", y
->len
);
244 for (x
= 0; x
< y
->len
; x
++)
245 printf ("(%02x %c)", y
->data
[x
],
246 ISPRINT (y
->data
[x
]) ? y
->data
[x
] : '.');
251 #define SYSROFF_PRINT
252 #define SYSROFF_SWAP_IN
256 /* FIXME: sysinfo, which generates sysroff.[ch] from sysroff.info, can't
257 hack the special case of the tr block, which has no contents. So we
258 implement our own functions for reading in and printing out the tr
261 #define IT_tr_CODE 0x7f
264 sysroff_swap_tr_in (void)
266 unsigned char raw
[255];
268 memset (raw
, 0, 255);
273 sysroff_print_tr_out (void)
275 itheader ("tr", IT_tr_CODE
);
285 if ((c
& 0x7f) != type
)
296 sysroff_swap_cs_in (&dummy
);
297 sysroff_print_cs_out (&dummy
);
304 sysroff_swap_dln_in (&dummy
);
305 sysroff_print_dln_out (&dummy
);
312 sysroff_swap_hd_in (&dummy
);
313 addrsize
= dummy
.afl
;
314 sysroff_print_hd_out (&dummy
);
321 sysroff_swap_dar_in (&dummy
);
322 sysroff_print_dar_out (&dummy
);
329 sysroff_swap_dsy_in (&dummy
);
330 sysroff_print_dsy_out (&dummy
);
337 sysroff_swap_dfp_in (&dummy
);
338 sysroff_print_dfp_out (&dummy
);
345 sysroff_swap_dso_in (&dummy
);
346 sysroff_print_dso_out (&dummy
);
353 sysroff_swap_dpt_in (&dummy
);
354 sysroff_print_dpt_out (&dummy
);
361 sysroff_swap_den_in (&dummy
);
362 sysroff_print_den_out (&dummy
);
369 sysroff_swap_dbt_in (&dummy
);
370 sysroff_print_dbt_out (&dummy
);
377 sysroff_swap_dty_in (&dummy
);
378 sysroff_print_dty_out (&dummy
);
385 sysroff_swap_un_in (&dummy
);
386 sysroff_print_un_out (&dummy
);
393 sysroff_swap_sc_in (&dummy
);
394 sysroff_print_sc_out (&dummy
);
401 sysroff_swap_er_in (&dummy
);
402 sysroff_print_er_out (&dummy
);
409 sysroff_swap_ed_in (&dummy
);
410 sysroff_print_ed_out (&dummy
);
417 sysroff_swap_sh_in (&dummy
);
418 sysroff_print_sh_out (&dummy
);
425 sysroff_swap_ob_in (&dummy
);
426 sysroff_print_ob_out (&dummy
);
433 sysroff_swap_rl_in (&dummy
);
434 sysroff_print_rl_out (&dummy
);
441 sysroff_swap_du_in (&dummy
);
443 sysroff_print_du_out (&dummy
);
450 sysroff_swap_dus_in (&dummy
);
451 sysroff_print_dus_out (&dummy
);
458 sysroff_swap_dul_in (&dummy
);
459 sysroff_print_dul_out (&dummy
);
466 sysroff_swap_dss_in (&dummy
);
467 sysroff_print_dss_out (&dummy
);
474 sysroff_swap_hs_in (&dummy
);
475 sysroff_print_hs_out (&dummy
);
482 sysroff_swap_dps_in (&dummy
);
483 sysroff_print_dps_out (&dummy
);
488 sysroff_swap_tr_in ();
489 sysroff_print_tr_out ();
496 sysroff_swap_dds_in (&dummy
);
497 sysroff_print_dds_out (&dummy
);
502 printf (_("GOT A %x\n"), c
);
520 printf (_("WANTED %x!!\n"), x
);
536 dump_symbol_info (void)
538 tab (1, _("SYMBOL INFO"));
540 while (opt (IT_dsy_CODE
))
542 if (opt (IT_dty_CODE
))
556 tab (1, _("DERIVED TYPE"));
560 if (opt (IT_dpp_CODE
))
565 else if (opt (IT_dfp_CODE
))
570 else if (opt (IT_den_CODE
))
575 else if (opt (IT_den_CODE
))
580 else if (opt (IT_dds_CODE
))
585 else if (opt (IT_dar_CODE
))
588 else if (opt (IT_dpt_CODE
))
591 else if (opt (IT_dul_CODE
))
594 else if (opt (IT_dse_CODE
))
597 else if (opt (IT_dot_CODE
))
613 tab (1, _("MODULE***\n"));
622 while (getone (c
) && c
!= IT_tr_CODE
);
643 show_usage (FILE *ffile
, int status
)
645 fprintf (ffile
, _("Usage: %s [option(s)] in-file\n"), program_name
);
646 fprintf (ffile
, _("Print a human readable interpretation of a SYSROFF object file\n"));
647 fprintf (ffile
, _(" The options are:\n\
648 -h --help Display this information\n\
649 -v --version Print the program's version number\n"));
651 if (REPORT_BUGS_TO
[0] && status
== 0)
652 fprintf (ffile
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
657 main (int ac
, char **av
)
659 char *input_file
= NULL
;
661 static struct option long_options
[] =
663 {"help", no_argument
, 0, 'h'},
664 {"version", no_argument
, 0, 'V'},
665 {NULL
, no_argument
, 0, 0}
668 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
669 setlocale (LC_MESSAGES
, "");
671 #if defined (HAVE_SETLOCALE)
672 setlocale (LC_CTYPE
, "");
674 bindtextdomain (PACKAGE
, LOCALEDIR
);
675 textdomain (PACKAGE
);
677 program_name
= av
[0];
678 xmalloc_set_program_name (program_name
);
680 expandargv (&ac
, &av
);
682 while ((option
= getopt_long (ac
, av
, "HhVv", long_options
, (int *) NULL
)) != EOF
)
688 show_usage (stdout
, 0);
692 print_version ("sysdump");
698 show_usage (stderr
, 1);
703 /* The input and output files may be named on the command line. */
706 input_file
= av
[optind
];
709 fatal (_("no input file specified"));
711 file
= fopen (input_file
, FOPEN_RB
);
714 fatal (_("cannot open input file %s"), input_file
);
This page took 0.070676 seconds and 4 git commands to generate.