1 /* Sysroff object format dumper.
2 Copyright (C) 1994, 95, 1998 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. */
32 #include <libiberty.h>
36 #define PROGRAM_VERSION "1.0"
39 static int segmented_p
;
41 static int addrsize
= 4;
49 char *r
= xmalloc (a
* b
);
55 getCHARS (ptr
, idx
, size
, max
)
71 /* Got to work out the length of the string from self */
77 r
= xcalloc (b
+ 1, 1);
78 memcpy (r
, ptr
+ oc
, b
);
92 printf ("\n************************************************************\n");
94 for (i
= 0; i
< size
; i
+= span
)
96 for (j
= 0; j
< span
; j
++)
99 printf ("%02x ", ptr
[i
+ j
]);
104 for (j
= 0; j
< span
&& j
+ i
< size
; j
++)
107 if (c
< 32 || c
> 127)
122 size
= getc (file
) - 2;
123 fread (ptr
, 1, size
, file
);
124 sum
= code
+ size
+ 2;
125 for (i
= 0; i
< size
; i
++)
130 if ((sum
& 0xff) != 0xff)
132 printf ("SUM IS %x\n", sum
);
141 getBARRAY (ptr
, idx
, dsize
, max
)
150 int size
= ptr
[byte
++];
152 res
.data
= (unsigned char *) xmalloc (size
);
153 for (i
= 0; i
< size
; i
++)
155 res
.data
[i
] = ptr
[byte
++];
161 getINT (ptr
, idx
, size
, max
)
186 n
= (ptr
[byte
+ 0] << 8) + ptr
[byte
+ 1];
189 n
= (ptr
[byte
+ 0] << 24) + (ptr
[byte
+ 1] << 16) + (ptr
[byte
+ 2] << 8) + (ptr
[byte
+ 3]);
199 getBITS (ptr
, idx
, size
, max
)
212 return (ptr
[byte
] >> (8 - bit
- size
)) & ((1 << size
) - 1);
216 itheader (name
, code
)
220 printf ("\n%s 0x%02x\n", name
, code
);
228 for (i
= 0; i
< indent
; i
++)
246 printf ("%d (", y
->len
);
247 for (x
= 0; x
< y
->len
; x
++)
249 printf ("(%02x %c)", y
->data
[x
], isprint (y
->data
[x
]) ? y
->data
[x
] : '.');
254 #define SYSROFF_PRINT
255 #define SYSROFF_SWAP_IN
260 * FIXME: sysinfo, which generates sysroff.[ch] from sysroff.info, can't
261 * hack the special case of the tr block, which has no contents. So we
262 * implement our own functions for reading in and printing out the tr
266 #define IT_tr_CODE 0x7f
277 sysroff_print_tr_out()
279 itheader("tr", IT_tr_CODE
);
289 if ((c
& 0x7f) != type
)
300 sysroff_swap_cs_in (&dummy
);
301 sysroff_print_cs_out (&dummy
);
307 sysroff_swap_dln_in (&dummy
);
308 sysroff_print_dln_out (&dummy
);
314 sysroff_swap_hd_in (&dummy
);
315 addrsize
= dummy
.afl
;
316 sysroff_print_hd_out (&dummy
);
322 sysroff_swap_dar_in (&dummy
);
323 sysroff_print_dar_out (&dummy
);
329 sysroff_swap_dsy_in (&dummy
);
330 sysroff_print_dsy_out (&dummy
);
336 sysroff_swap_dfp_in (&dummy
);
337 sysroff_print_dfp_out (&dummy
);
343 sysroff_swap_dso_in (&dummy
);
344 sysroff_print_dso_out (&dummy
);
350 sysroff_swap_dpt_in (&dummy
);
351 sysroff_print_dpt_out (&dummy
);
357 sysroff_swap_den_in (&dummy
);
358 sysroff_print_den_out (&dummy
);
364 sysroff_swap_dbt_in (&dummy
);
365 sysroff_print_dbt_out (&dummy
);
371 sysroff_swap_dty_in (&dummy
);
372 sysroff_print_dty_out (&dummy
);
378 sysroff_swap_un_in (&dummy
);
379 sysroff_print_un_out (&dummy
);
385 sysroff_swap_sc_in (&dummy
);
386 sysroff_print_sc_out (&dummy
);
392 sysroff_swap_er_in (&dummy
);
393 sysroff_print_er_out (&dummy
);
399 sysroff_swap_ed_in (&dummy
);
400 sysroff_print_ed_out (&dummy
);
406 sysroff_swap_sh_in (&dummy
);
407 sysroff_print_sh_out (&dummy
);
413 sysroff_swap_ob_in (&dummy
);
414 sysroff_print_ob_out (&dummy
);
420 sysroff_swap_rl_in (&dummy
);
421 sysroff_print_rl_out (&dummy
);
427 sysroff_swap_du_in (&dummy
);
429 sysroff_print_du_out (&dummy
);
435 sysroff_swap_dus_in (&dummy
);
436 sysroff_print_dus_out (&dummy
);
442 sysroff_swap_dul_in (&dummy
);
443 sysroff_print_dul_out (&dummy
);
449 sysroff_swap_dss_in (&dummy
);
450 sysroff_print_dss_out (&dummy
);
456 sysroff_swap_hs_in (&dummy
);
457 sysroff_print_hs_out (&dummy
);
463 sysroff_swap_dps_in (&dummy
);
464 sysroff_print_dps_out (&dummy
);
469 sysroff_swap_tr_in ();
470 sysroff_print_tr_out ();
476 sysroff_swap_dds_in (&dummy
);
477 sysroff_print_dds_out (&dummy
);
481 printf ("GOT A %x\n", c
);
497 /* This is no longer used. */
502 while (opt (IT_un_CODE
))
506 while (getone (IT_sc_CODE
))
509 while (getone (IT_er_CODE
))
512 while (getone (IT_ed_CODE
))
521 /* This is no longer used. */
526 while (getone (IT_sh_CODE
))
528 while (getone (IT_ob_CODE
))
530 while (getone (IT_rl_CODE
))
543 printf ("WANTED %x!!\n", x
);
561 static void derived_type ();
566 tab (1, "SYMBOL INFO");
567 while (opt (IT_dsy_CODE
))
569 if (opt (IT_dty_CODE
))
582 tab (1, "DERIVED TYPE");
585 if (opt (IT_dpp_CODE
))
590 else if (opt (IT_dfp_CODE
))
595 else if (opt (IT_den_CODE
))
600 else if (opt (IT_den_CODE
))
605 else if (opt (IT_dds_CODE
))
610 else if (opt (IT_dar_CODE
))
613 else if (opt (IT_dpt_CODE
))
616 else if (opt (IT_dul_CODE
))
619 else if (opt (IT_dse_CODE
))
622 else if (opt (IT_dot_CODE
))
634 /* This is no longer used. */
639 tab (1, "PROGRAM STRUCTURE");
640 while (opt (IT_dps_CODE
))
654 /* This is no longer used. */
659 tab (1, "DEBUG LIST");
663 program_structure ();
677 tab (1, "MODULE***\n");
686 while (getone (c
) && c
!= IT_tr_CODE
);
718 show_usage (file
, status
)
722 fprintf (file
, _("Usage: %s [-hV] in-file\n"), program_name
);
729 printf (_("%s: Print a human readable interpretation of a SYSROFF object file\n"),
731 show_usage (stdout
, 0);
739 char *input_file
= NULL
;
741 static struct option long_options
[] =
743 {"help", no_argument
, 0, 'h'},
744 {"version", no_argument
, 0, 'V'},
745 {NULL
, no_argument
, 0, 0}
748 setlocale (LC_MESSAGES
, "");
749 bindtextdomain (PACKAGE
, LOCALEDIR
);
750 textdomain (PACKAGE
);
752 program_name
= av
[0];
753 xmalloc_set_program_name (program_name
);
755 while ((opt
= getopt_long (ac
, av
, "hV", long_options
, (int *) NULL
)) != EOF
)
763 printf (_("GNU %s version %s\n"), program_name
, PROGRAM_VERSION
);
769 show_usage (stderr
, 1);
774 /* The input and output files may be named on the command line. */
778 input_file
= av
[optind
];
783 fprintf (stderr
, _("%s: no input file specified\n"),
788 file
= fopen (input_file
, FOPEN_RB
);
791 fprintf (stderr
, _("%s: cannot open input file %s\n"),
792 program_name
, input_file
);
This page took 0.07309 seconds and 4 git commands to generate.