1 /* Sysroff object format dumper.
2 Copyright (C) 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* Written by Steve Chamberlain <sac@cygnus.com>.
23 This program reads a SYSROFF object file and prints it in an
24 almost human readable form to stdout. */
27 #include <libiberty.h>
32 #define PROGRAM_VERSION "1.0"
35 static int segmented_p
;
39 static char *xcalloc(a
,b
)
43 char *r
= xmalloc(a
,b
);
49 getCHARS (ptr
, idx
, size
, max
)
65 /* Got to work out the length of the string from self */
71 r
= calloc (b
+ 1, 1);
72 memcpy (r
, ptr
+ oc
, b
);
85 printf ("\n************************************************************\n");
87 for (i
= 0; i
< size
; i
+= span
)
89 for (j
= 0; j
< span
&& j
+ i
< size
; j
++)
91 printf ("%02x ", ptr
[i
+ j
]);
96 for (i
= 0; i
< size
; i
+= span
)
98 for (j
= 0; j
< span
&& j
+ i
< size
; j
++)
101 if (c
< 32 || c
> 127)
116 size
= getc (file
) - 2;
117 fread (ptr
, 1, size
, file
);
118 sum
= code
+ size
+ 2;
119 for (i
= 0; i
< size
; i
++)
124 if ((sum
& 0xff) != 0xff)
126 printf ("SUM IS %x\n", sum
);
135 getBARRAY (ptr
, idx
, dsize
, max
)
144 int size
= ptr
[byte
++];
146 res
.data
= (unsigned char *)xmalloc (size
);
147 for (i
= 0; i
< size
; i
++)
149 res
.data
[i
] = ptr
[byte
++];
157 getINT (ptr
, idx
, size
, max
)
182 n
= (ptr
[byte
+ 0] << 8) + ptr
[byte
+ 1];
185 n
= (ptr
[byte
+ 0] << 24) + (ptr
[byte
+ 1] << 16) + (ptr
[byte
+ 2] << 8) + (ptr
[byte
+ 3]);
195 getBITS (ptr
, idx
, size
)
205 return (ptr
[byte
] >> (8 - bit
- size
)) & ((1 << size
) - 1);
210 itheader (name
, code
)
214 printf ("\n%s 0x%02x\n", name
, code
);
221 for (i
= 0; i
< indent
; i
++)
239 printf ("%d (", y
->len
);
240 for (x
= 0; x
< y
->len
; x
++)
242 printf ("(%02x %c)", y
->data
[x
], isprint (y
->data
[x
]) ? y
->data
[x
] : '.');
247 #define SYSROFF_PRINT
248 #define SYSROFF_SWAP_IN
260 if ((c
& 0x7f) != type
)
271 sysroff_swap_cs_in (&dummy
);
272 sysroff_print_cs_out (&dummy
);
278 sysroff_swap_dln_in (&dummy
);
279 sysroff_print_dln_out (&dummy
);
285 sysroff_swap_hd_in (&dummy
);
286 sysroff_print_hd_out (&dummy
);
292 sysroff_swap_dar_in (&dummy
);
293 sysroff_print_dar_out (&dummy
);
299 sysroff_swap_dsy_in (&dummy
);
300 sysroff_print_dsy_out (&dummy
);
306 sysroff_swap_dfp_in (&dummy
);
307 sysroff_print_dfp_out (&dummy
);
313 sysroff_swap_dso_in (&dummy
);
314 sysroff_print_dso_out (&dummy
);
320 sysroff_swap_dpt_in (&dummy
);
321 sysroff_print_dpt_out (&dummy
);
327 sysroff_swap_den_in (&dummy
);
328 sysroff_print_den_out (&dummy
);
334 sysroff_swap_dbt_in (&dummy
);
335 sysroff_print_dbt_out (&dummy
);
341 sysroff_swap_dty_in (&dummy
);
342 sysroff_print_dty_out (&dummy
);
348 sysroff_swap_un_in (&dummy
);
349 sysroff_print_un_out (&dummy
);
355 sysroff_swap_sc_in (&dummy
);
356 sysroff_print_sc_out (&dummy
);
362 sysroff_swap_er_in (&dummy
);
363 sysroff_print_er_out (&dummy
);
369 sysroff_swap_ed_in (&dummy
);
370 sysroff_print_ed_out (&dummy
);
376 sysroff_swap_sh_in (&dummy
);
377 sysroff_print_sh_out (&dummy
);
383 sysroff_swap_ob_in (&dummy
);
384 sysroff_print_ob_out (&dummy
);
390 sysroff_swap_rl_in (&dummy
);
391 sysroff_print_rl_out (&dummy
);
397 sysroff_swap_du_in (&dummy
);
399 sysroff_print_du_out (&dummy
);
405 sysroff_swap_dus_in (&dummy
);
406 sysroff_print_dus_out (&dummy
);
412 sysroff_swap_dul_in (&dummy
);
413 sysroff_print_dul_out (&dummy
);
419 sysroff_swap_dss_in (&dummy
);
420 sysroff_print_dss_out (&dummy
);
425 sysroff_swap_hs_in (&dummy
);
426 sysroff_print_hs_out (&dummy
);
433 sysroff_swap_dps_in (&dummy
);
434 sysroff_print_dps_out (&dummy
);
442 sysroff_swap_tr_in (&dummy
);
443 sysroff_print_tr_out (&dummy
);
449 sysroff_swap_dds_in (&dummy
);
450 sysroff_print_dds_out (&dummy
);
455 printf ("GOT A %x\n", c
);
473 if (opt (IT_un_CODE
))
475 while (getone (IT_sc_CODE
))
480 while (getone (IT_er_CODE
))
484 while (getone (IT_ed_CODE
))
494 while (getone (IT_ob_CODE
))
496 while (getone (IT_rl_CODE
))
506 printf ("WANTED %x!!\n", x
);
523 static void derived_type ();
528 tab (1, "SYMBOL INFO");
529 while (opt (IT_dsy_CODE
))
531 if (opt (IT_dty_CODE
))
544 tab (1, "DERIVED TYPE");
547 if (opt (IT_dpp_CODE
))
552 else if (opt (IT_dfp_CODE
))
557 else if (opt (IT_den_CODE
))
562 else if (opt (IT_den_CODE
))
567 else if (opt (IT_dds_CODE
))
572 else if (opt (IT_dar_CODE
))
575 else if (opt (IT_dpt_CODE
))
578 else if (opt (IT_dul_CODE
))
581 else if (opt (IT_dse_CODE
))
584 else if (opt (IT_dot_CODE
))
597 tab (1, "PROGRAM STRUCTURE");
598 while (opt (IT_dps_CODE
))
609 tab (1, "DEBUG LIST");
611 while (getone (IT_dus_CODE
))
613 while (opt (IT_dfl_CODE
))
615 while (getone (IT_dus_CODE
))
618 program_structure ();
620 getone (IT_dln_CODE
);
630 tab (1, "MODULE***\n");
636 while (!opt (IT_tr_CODE
) && c
< 10)
663 show_usage (file
, status
)
667 fprintf (file
, "Usage: %s [-hV] in-file\n", program_name
);
674 printf ("%s: Print a human readable interpretation of a SYSROFF object file\n",
676 show_usage (stdout
, 0);
685 char *input_file
= NULL
;
687 static struct option long_options
[] =
689 { "help", no_argument
, 0, 'h' },
690 { "version", no_argument
, 0, 'V' },
691 { NULL
, no_argument
, 0, 0 }
694 program_name
= av
[0];
695 xmalloc_set_program_name (program_name
);
697 while ((opt
= getopt_long (ac
, av
, "hV", long_options
,
707 printf ("GNU %s version %s\n", program_name
, PROGRAM_VERSION
);
713 show_usage (stderr
, 1);
718 /* The input and output files may be named on the command line. */
722 input_file
= av
[optind
];
727 fprintf (stderr
,"%s: no input file specified\n",
732 file
= fopen (input_file
, "r");
735 fprintf (stderr
,"%s: cannot open input file %s\n",
736 program_name
, input_file
);
This page took 0.045874 seconds and 4 git commands to generate.