1 /* Sysroff object format dumper.
2 Copyright (C) 1994-2021 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 derived_type (void);
44 getCHARS (unsigned char *ptr
, int *idx
, int size
, int max
)
51 return _("*undefined*");
55 /* PR 17512: file: 13caced2. */
57 return _("*corrupt*");
58 /* Got to work out the length of the string from self. */
64 r
= xcalloc (b
+ 1, 1);
65 memcpy (r
, ptr
+ oc
, b
);
72 dh (unsigned char *ptr
, int size
)
78 printf ("\n************************************************************\n");
80 for (i
= 0; i
< size
; i
+= span
)
82 for (j
= 0; j
< span
; j
++)
85 printf ("%02x ", ptr
[i
+ j
]);
90 for (j
= 0; j
< span
&& j
+ i
< size
; j
++)
94 if (c
< 32 || c
> 127)
104 fillup (unsigned char *ptr
)
116 if (fread (ptr
, size
, 1, file
) != 1)
119 sum
= code
+ size
+ 2;
121 for (i
= 0; i
< size
; i
++)
124 if ((sum
& 0xff) != 0xff)
125 printf (_("SUM IS %x\n"), sum
);
134 getBARRAY (unsigned char *ptr
, int *idx
, int dsize ATTRIBUTE_UNUSED
, int max
)
145 res
.data
= (unsigned char *) xmalloc (size
);
147 for (i
= 0; i
< size
; i
++)
148 res
.data
[i
] = byte
< max
? ptr
[byte
++] : 0;
154 getINT (unsigned char *ptr
, int *idx
, int size
, int max
)
161 /* PR 17512: file: id:000001,src:000002,op:flip1,pos:45. */
162 /* Prevent infinite loops re-reading beyond the end of the buffer. */
163 fatal (_("ICE: getINT: Out of buffer space"));
181 n
= (ptr
[byte
+ 0] << 8) + ptr
[byte
+ 1];
184 n
= (((unsigned) ptr
[byte
+ 0] << 24) + (ptr
[byte
+ 1] << 16)
185 + (ptr
[byte
+ 2] << 8) + (ptr
[byte
+ 3]));
188 fatal (_("Unsupported read size: %d"), size
);
196 getBITS (unsigned char *ptr
, int *idx
, int size
, int max
)
206 return (ptr
[byte
] >> (8 - bit
- size
)) & ((1 << size
) - 1);
210 itheader (char *name
, int icode
)
212 printf ("\n%s 0x%02x\n", name
, icode
);
222 for (i
= 0; i
< indent
; i
++)
239 printf ("%d (", y
->len
);
241 for (x
= 0; x
< y
->len
; x
++)
242 printf ("(%02x %c)", y
->data
[x
],
243 ISPRINT (y
->data
[x
]) ? y
->data
[x
] : '.');
248 #define SYSROFF_PRINT
249 #define SYSROFF_SWAP_IN
253 /* FIXME: sysinfo, which generates sysroff.[ch] from sysroff.info, can't
254 hack the special case of the tr block, which has no contents. So we
255 implement our own functions for reading in and printing out the tr
258 #define IT_tr_CODE 0x7f
261 sysroff_swap_tr_in (void)
263 unsigned char raw
[255];
265 memset (raw
, 0, 255);
270 sysroff_print_tr_out (void)
272 itheader ("tr", IT_tr_CODE
);
282 if ((c
& 0x7f) != type
)
293 sysroff_swap_cs_in (&dummy
);
294 sysroff_print_cs_out (&dummy
);
301 sysroff_swap_dln_in (&dummy
);
302 sysroff_print_dln_out (&dummy
);
309 sysroff_swap_hd_in (&dummy
);
310 addrsize
= dummy
.afl
;
311 sysroff_print_hd_out (&dummy
);
318 sysroff_swap_dar_in (&dummy
);
319 sysroff_print_dar_out (&dummy
);
326 sysroff_swap_dsy_in (&dummy
);
327 sysroff_print_dsy_out (&dummy
);
334 sysroff_swap_dfp_in (&dummy
);
335 sysroff_print_dfp_out (&dummy
);
342 sysroff_swap_dso_in (&dummy
);
343 sysroff_print_dso_out (&dummy
);
350 sysroff_swap_dpt_in (&dummy
);
351 sysroff_print_dpt_out (&dummy
);
358 sysroff_swap_den_in (&dummy
);
359 sysroff_print_den_out (&dummy
);
366 sysroff_swap_dbt_in (&dummy
);
367 sysroff_print_dbt_out (&dummy
);
374 sysroff_swap_dty_in (&dummy
);
375 sysroff_print_dty_out (&dummy
);
382 sysroff_swap_un_in (&dummy
);
383 sysroff_print_un_out (&dummy
);
390 sysroff_swap_sc_in (&dummy
);
391 sysroff_print_sc_out (&dummy
);
398 sysroff_swap_er_in (&dummy
);
399 sysroff_print_er_out (&dummy
);
406 sysroff_swap_ed_in (&dummy
);
407 sysroff_print_ed_out (&dummy
);
414 sysroff_swap_sh_in (&dummy
);
415 sysroff_print_sh_out (&dummy
);
422 sysroff_swap_ob_in (&dummy
);
423 sysroff_print_ob_out (&dummy
);
430 sysroff_swap_rl_in (&dummy
);
431 sysroff_print_rl_out (&dummy
);
438 sysroff_swap_du_in (&dummy
);
440 sysroff_print_du_out (&dummy
);
447 sysroff_swap_dus_in (&dummy
);
448 sysroff_print_dus_out (&dummy
);
455 sysroff_swap_dul_in (&dummy
);
456 sysroff_print_dul_out (&dummy
);
463 sysroff_swap_dss_in (&dummy
);
464 sysroff_print_dss_out (&dummy
);
471 sysroff_swap_hs_in (&dummy
);
472 sysroff_print_hs_out (&dummy
);
479 sysroff_swap_dps_in (&dummy
);
480 sysroff_print_dps_out (&dummy
);
485 sysroff_swap_tr_in ();
486 sysroff_print_tr_out ();
493 sysroff_swap_dds_in (&dummy
);
494 sysroff_print_dds_out (&dummy
);
499 printf (_("GOT A %x\n"), c
);
517 printf (_("WANTED %x!!\n"), x
);
533 dump_symbol_info (void)
535 tab (1, _("SYMBOL INFO"));
537 while (opt (IT_dsy_CODE
))
539 if (opt (IT_dty_CODE
))
553 tab (1, _("DERIVED TYPE"));
557 if (opt (IT_dpp_CODE
))
562 else if (opt (IT_dfp_CODE
))
567 else if (opt (IT_den_CODE
))
572 else if (opt (IT_den_CODE
))
577 else if (opt (IT_dds_CODE
))
582 else if (opt (IT_dar_CODE
))
585 else if (opt (IT_dpt_CODE
))
588 else if (opt (IT_dul_CODE
))
591 else if (opt (IT_dse_CODE
))
594 else if (opt (IT_dot_CODE
))
610 tab (1, _("MODULE***\n"));
621 while (getone (c
) && c
!= IT_tr_CODE
);
639 ATTRIBUTE_NORETURN
static void
640 show_usage (FILE *ffile
, int status
)
642 fprintf (ffile
, _("Usage: %s [option(s)] in-file\n"), program_name
);
643 fprintf (ffile
, _("Print a human readable interpretation of a SYSROFF object file\n"));
644 fprintf (ffile
, _(" The options are:\n\
645 -h --help Display this information\n\
646 -v --version Print the program's version number\n"));
648 if (REPORT_BUGS_TO
[0] && status
== 0)
649 fprintf (ffile
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
654 main (int ac
, char **av
)
656 char *input_file
= NULL
;
658 static struct option long_options
[] =
660 {"help", no_argument
, 0, 'h'},
661 {"version", no_argument
, 0, 'V'},
662 {NULL
, no_argument
, 0, 0}
665 #ifdef HAVE_LC_MESSAGES
666 setlocale (LC_MESSAGES
, "");
668 setlocale (LC_CTYPE
, "");
669 bindtextdomain (PACKAGE
, LOCALEDIR
);
670 textdomain (PACKAGE
);
672 program_name
= av
[0];
673 xmalloc_set_program_name (program_name
);
674 bfd_set_error_program_name (program_name
);
676 expandargv (&ac
, &av
);
678 while ((option
= getopt_long (ac
, av
, "HhVv", long_options
, (int *) NULL
)) != EOF
)
684 show_usage (stdout
, 0);
688 print_version ("sysdump");
694 show_usage (stderr
, 1);
699 /* The input and output files may be named on the command line. */
702 input_file
= av
[optind
];
705 fatal (_("no input file specified"));
707 file
= fopen (input_file
, FOPEN_RB
);
710 fatal (_("cannot open input file %s"), input_file
);
This page took 0.043852 seconds and 4 git commands to generate.