1 /* od-xcoff.c -- dump information about an xcoff object file.
2 Copyright (C) 2011-2022 Free Software Foundation, Inc.
3 Written by Tristan Gingold, Adacore.
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 3, or (at your option)
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, 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
25 #include "safe-ctype.h"
30 /* Force the support of weak symbols. */
31 #ifndef AIX_WEAK_SUPPORT
32 #define AIX_WEAK_SUPPORT 1
34 #include "coff/internal.h"
35 #include "coff/rs6000.h"
36 #include "coff/xcoff.h"
40 /* Index of the options in the options[] array. */
41 #define OPT_FILE_HEADER 0
43 #define OPT_SECTIONS 2
50 #define OPT_TRACEBACK 9
54 /* List of actions. */
55 static struct objdump_private_option options
[] =
75 xcoff_help (FILE *stream
)
79 header Display the file header\n\
80 aout Display the auxiliary header\n\
81 sections Display the section headers\n\
82 syms Display the symbols table\n\
83 relocs Display the relocation entries\n\
84 lineno Display the line number entries\n\
85 loader Display loader section\n\
86 except Display exception table\n\
87 typchk Display type-check section\n\
88 traceback Display traceback tags\n\
89 toc Display toc symbols\n\
90 ldinfo Display loader info in core files\n\
94 /* Return TRUE if ABFD is handled. */
97 xcoff_filter (bfd
*abfd
)
99 return bfd_get_flavour (abfd
) == bfd_target_xcoff_flavour
;
102 /* Translation entry type. The last entry must be {0, NULL}. */
109 /* Display the list of name (from TABLE) for FLAGS, using comma to separate
110 them. A name is displayed if FLAGS & VAL is not 0. */
113 dump_flags (const struct xlat_table
*table
, unsigned int flags
)
115 unsigned int r
= flags
;
117 const struct xlat_table
*t
;
119 for (t
= table
; t
->name
; t
++)
120 if ((flags
& t
->val
) != 0)
128 fputs (t
->name
, stdout
);
131 /* Not decoded flags. */
140 /* Display the name corresponding to VAL from TABLE, using at most
141 MAXLEN char (possibly passed with spaces). */
144 dump_value (const struct xlat_table
*table
, unsigned int val
, int maxlen
)
146 const struct xlat_table
*t
;
148 for (t
= table
; t
->name
; t
++)
151 printf ("%-*s", maxlen
, t
->name
);
154 printf ("(%*x)", maxlen
- 2, val
);
157 /* Names of f_flags. */
158 static const struct xlat_table f_flag_xlat
[] =
160 { F_RELFLG
, "no-rel" },
162 { F_LNNO
, "lineno" },
163 { F_LSYMS
, "lsyms" },
165 { F_FDPR_PROF
, "fdpr-prof" },
166 { F_FDPR_OPTI
, "fdpr-opti" },
169 { F_VARPG
, "varprg" },
171 { F_DYNLOAD
, "dynload" },
172 { F_SHROBJ
, "shrobj" },
173 { F_NONEXEC
, "nonexec" },
178 /* Names of s_flags. */
179 static const struct xlat_table s_flag_xlat
[] =
182 { STYP_DWARF
, "dwarf" },
183 { STYP_TEXT
, "text" },
184 { STYP_DATA
, "data" },
187 { STYP_EXCEPT
, "except" },
188 { STYP_INFO
, "info" },
189 { STYP_TDATA
, "tdata" },
190 { STYP_TBSS
, "tbss" },
192 { STYP_LOADER
, "loader" },
193 { STYP_DEBUG
, "debug" },
194 { STYP_TYPCHK
, "typchk" },
195 { STYP_OVRFLO
, "ovrflo" },
199 /* Names of storage class. */
200 static const struct xlat_table sc_xlat
[] =
202 #define SC_ENTRY(X) { C_##X, #X }
213 /* SC_ENTRY(STRARG), */
257 /* Names for symbol type. */
258 static const struct xlat_table smtyp_xlat
[] =
269 /* Names for storage-mapping class. */
270 static const struct xlat_table smclas_xlat
[] =
272 #define SMCLAS_ENTRY(X) { XMC_##X, #X }
290 SMCLAS_ENTRY (SV3264
),
295 /* Names for relocation type. */
296 static const struct xlat_table rtype_xlat
[] =
298 #define RTYPE_ENTRY(X) { R_##X, #X }
321 RTYPE_ENTRY (TLS_IE
),
322 RTYPE_ENTRY (TLS_LD
),
323 RTYPE_ENTRY (TLS_LE
),
331 /* Simplified section header. */
332 struct xcoff32_section
334 /* NUL terminated name. */
340 /* Offsets in file. */
345 /* Number of relocs and line numbers. */
350 /* Simplified symbol. */
354 union external_auxent aux
;
358 /* Pointer to the NUL-terminated name. */
361 /* XCOFF symbol fields. */
363 unsigned short scnum
;
364 unsigned short ntype
;
365 unsigned char sclass
;
366 unsigned char numaux
;
368 /* Buffer in case the name is local. */
377 /* Important fields to dump the file. */
381 /* From file header. */
382 unsigned short nscns
;
385 unsigned short opthdr
;
388 struct xcoff32_section
*sects
;
391 union xcoff32_symbol
*syms
;
393 unsigned int strings_size
;
396 /* Print a symbol (if possible). */
399 xcoff32_print_symbol (struct xcoff_dump
*data
, unsigned int symndx
)
401 if (data
->syms
!= NULL
402 && symndx
< data
->nsyms
403 && data
->syms
[symndx
].sym
.name
!= NULL
)
404 printf ("%s", data
->syms
[symndx
].sym
.name
);
406 printf ("%u", symndx
);
409 /* Dump the file header. */
412 dump_xcoff32_file_header (bfd
*abfd
, struct external_filehdr
*fhdr
,
413 struct xcoff_dump
*data
)
415 unsigned int timdat
= bfd_h_get_32 (abfd
, fhdr
->f_timdat
);
416 unsigned short flags
= bfd_h_get_16 (abfd
, fhdr
->f_flags
);
418 printf (_(" nbr sections: %d\n"), data
->nscns
);
419 printf (_(" time and date: 0x%08x - "), timdat
);
421 printf (_("not set\n"));
424 /* Not correct on all platforms, but works on unix. */
426 fputs (ctime (&t
), stdout
);
428 printf (_(" symbols off: 0x%08x\n"), data
->symptr
);
429 printf (_(" nbr symbols: %d\n"), data
->nsyms
);
430 printf (_(" opt hdr sz: %d\n"), data
->opthdr
);
431 printf (_(" flags: 0x%04x "), flags
);
432 dump_flags (f_flag_xlat
, flags
);
436 /* Dump the a.out header. */
439 dump_xcoff32_aout_header (bfd
*abfd
, struct xcoff_dump
*data
)
442 unsigned short magic
;
443 unsigned int sz
= data
->opthdr
;
445 printf (_("Auxiliary header:\n"));
446 if (data
->opthdr
== 0)
448 printf (_(" No aux header\n"));
451 if (data
->opthdr
> sizeof (auxhdr
))
453 printf (_("warning: optional header size too large (> %d)\n"),
454 (int)sizeof (auxhdr
));
455 sz
= sizeof (auxhdr
);
457 if (bfd_bread (&auxhdr
, sz
, abfd
) != sz
)
459 non_fatal (_("cannot read auxhdr"));
463 magic
= bfd_h_get_16 (abfd
, auxhdr
.magic
);
464 /* We don't translate these strings as they are fields name. */
465 printf (" o_mflag (magic): 0x%04x 0%04o\n", magic
, magic
);
466 printf (" o_vstamp: 0x%04x\n",
467 (unsigned short)bfd_h_get_16 (abfd
, auxhdr
.vstamp
));
468 printf (" o_tsize: 0x%08x\n",
469 (unsigned int)bfd_h_get_32 (abfd
, auxhdr
.tsize
));
470 printf (" o_dsize: 0x%08x\n",
471 (unsigned int)bfd_h_get_32 (abfd
, auxhdr
.dsize
));
472 printf (" o_entry: 0x%08x\n",
473 (unsigned int)bfd_h_get_32 (abfd
, auxhdr
.entry
));
474 printf (" o_text_start: 0x%08x\n",
475 (unsigned int)bfd_h_get_32 (abfd
, auxhdr
.text_start
));
476 printf (" o_data_start: 0x%08x\n",
477 (unsigned int)bfd_h_get_32 (abfd
, auxhdr
.data_start
));
478 if (sz
== offsetof (AOUTHDR
, o_toc
))
480 printf (" o_toc: 0x%08x\n",
481 (unsigned int)bfd_h_get_32 (abfd
, auxhdr
.o_toc
));
482 printf (" o_snentry: 0x%04x\n",
483 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_snentry
));
484 printf (" o_sntext: 0x%04x\n",
485 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_sntext
));
486 printf (" o_sndata: 0x%04x\n",
487 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_sndata
));
488 printf (" o_sntoc: 0x%04x\n",
489 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_sntoc
));
490 printf (" o_snloader: 0x%04x\n",
491 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_snloader
));
492 printf (" o_snbss: 0x%04x\n",
493 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_snbss
));
494 printf (" o_algntext: %u\n",
495 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_algntext
));
496 printf (" o_algndata: %u\n",
497 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_algndata
));
498 printf (" o_modtype: 0x%04x",
499 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_modtype
));
500 if (ISPRINT (auxhdr
.o_modtype
[0]) && ISPRINT (auxhdr
.o_modtype
[1]))
501 printf (" (%c%c)", auxhdr
.o_modtype
[0], auxhdr
.o_modtype
[1]);
503 printf (" o_cputype: 0x%04x\n",
504 (unsigned int)bfd_h_get_16 (abfd
, auxhdr
.o_cputype
));
505 printf (" o_maxstack: 0x%08x\n",
506 (unsigned int)bfd_h_get_32 (abfd
, auxhdr
.o_maxstack
));
507 printf (" o_maxdata: 0x%08x\n",
508 (unsigned int)bfd_h_get_32 (abfd
, auxhdr
.o_maxdata
));
510 printf (" o_debugger: 0x%08x\n",
511 (unsigned int)bfd_h_get_32 (abfd
, auxhdr
.o_debugger
));
515 /* Dump the sections header. */
518 dump_xcoff32_sections_header (bfd
*abfd
, struct xcoff_dump
*data
)
523 off
= sizeof (struct external_filehdr
) + data
->opthdr
;
524 printf (_("Section headers (at %u+%u=0x%08x to 0x%08x):\n"),
525 (unsigned int)sizeof (struct external_filehdr
), data
->opthdr
, off
,
526 off
+ (unsigned int)sizeof (struct external_scnhdr
) * data
->nscns
);
527 if (data
->nscns
== 0)
529 printf (_(" No section header\n"));
532 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0)
534 non_fatal (_("cannot read section header"));
537 /* We don't translate this string as it consists in fields name. */
538 printf (" # Name paddr vaddr size scnptr relptr lnnoptr nrel nlnno\n");
539 for (i
= 0; i
< data
->nscns
; i
++)
541 struct external_scnhdr scn
;
544 if (bfd_bread (&scn
, sizeof (scn
), abfd
) != sizeof (scn
))
546 non_fatal (_("cannot read section header"));
549 flags
= bfd_h_get_32 (abfd
, scn
.s_flags
);
550 printf ("%2d %-8.8s %08x %08x %08x %08x %08x %08x %-5d %-5d\n",
552 (unsigned int)bfd_h_get_32 (abfd
, scn
.s_paddr
),
553 (unsigned int)bfd_h_get_32 (abfd
, scn
.s_vaddr
),
554 (unsigned int)bfd_h_get_32 (abfd
, scn
.s_size
),
555 (unsigned int)bfd_h_get_32 (abfd
, scn
.s_scnptr
),
556 (unsigned int)bfd_h_get_32 (abfd
, scn
.s_relptr
),
557 (unsigned int)bfd_h_get_32 (abfd
, scn
.s_lnnoptr
),
558 (unsigned int)bfd_h_get_16 (abfd
, scn
.s_nreloc
),
559 (unsigned int)bfd_h_get_16 (abfd
, scn
.s_nlnno
));
560 printf (_(" Flags: %08x "), flags
);
564 /* Stripped executable ? */
567 else if (flags
& STYP_OVRFLO
)
568 printf (_("overflow - nreloc: %u, nlnno: %u\n"),
569 (unsigned int)bfd_h_get_32 (abfd
, scn
.s_paddr
),
570 (unsigned int)bfd_h_get_32 (abfd
, scn
.s_vaddr
));
573 dump_flags (s_flag_xlat
, flags
);
579 /* Read section table. */
582 xcoff32_read_sections (bfd
*abfd
, struct xcoff_dump
*data
)
586 if (bfd_seek (abfd
, sizeof (struct external_filehdr
) + data
->opthdr
,
589 non_fatal (_("cannot read section headers"));
593 data
->sects
= xmalloc (data
->nscns
* sizeof (struct xcoff32_section
));
594 for (i
= 0; i
< data
->nscns
; i
++)
596 struct external_scnhdr scn
;
597 struct xcoff32_section
*s
= &data
->sects
[i
];
599 if (bfd_bread (&scn
, sizeof (scn
), abfd
) != sizeof (scn
))
601 non_fatal (_("cannot read section header"));
606 memcpy (s
->name
, scn
.s_name
, 8);
608 s
->flags
= bfd_h_get_32 (abfd
, scn
.s_flags
);
610 s
->scnptr
= bfd_h_get_32 (abfd
, scn
.s_scnptr
);
611 s
->relptr
= bfd_h_get_32 (abfd
, scn
.s_relptr
);
612 s
->lnnoptr
= bfd_h_get_32 (abfd
, scn
.s_lnnoptr
);
614 s
->nreloc
= bfd_h_get_16 (abfd
, scn
.s_nreloc
);
615 s
->nlnno
= bfd_h_get_16 (abfd
, scn
.s_nlnno
);
617 if (s
->flags
== STYP_OVRFLO
)
619 if (s
->nreloc
> 0 && s
->nreloc
<= data
->nscns
)
620 data
->sects
[s
->nreloc
- 1].nreloc
=
621 bfd_h_get_32 (abfd
, scn
.s_paddr
);
622 if (s
->nlnno
> 0 && s
->nlnno
<= data
->nscns
)
623 data
->sects
[s
->nlnno
- 1].nlnno
=
624 bfd_h_get_32 (abfd
, scn
.s_vaddr
);
632 xcoff32_read_symbols (bfd
*abfd
, struct xcoff_dump
*data
)
638 if (data
->nsyms
== 0)
642 + data
->nsyms
* (unsigned)sizeof (struct external_syment
);
644 /* Read string table. */
645 if (bfd_seek (abfd
, stptr
, SEEK_SET
) != 0
646 || bfd_bread (&stsz_arr
, sizeof (stsz_arr
), abfd
) != sizeof (stsz_arr
))
648 non_fatal (_("cannot read strings table length"));
649 data
->strings_size
= 0;
653 data
->strings_size
= bfd_h_get_32 (abfd
, stsz_arr
);
654 if (data
->strings_size
> sizeof (stsz_arr
))
656 unsigned int remsz
= data
->strings_size
- sizeof (stsz_arr
);
658 data
->strings
= xmalloc (data
->strings_size
);
660 memcpy (data
->strings
, stsz_arr
, sizeof (stsz_arr
));
661 if (bfd_bread (data
->strings
+ sizeof (stsz_arr
), remsz
, abfd
)
664 non_fatal (_("cannot read strings table"));
670 if (bfd_seek (abfd
, data
->symptr
, SEEK_SET
) != 0)
672 non_fatal (_("cannot read symbol table"));
676 data
->syms
= (union xcoff32_symbol
*)
677 xmalloc (data
->nsyms
* sizeof (union xcoff32_symbol
));
679 for (i
= 0; i
< data
->nsyms
; i
++)
681 struct external_syment sym
;
683 union xcoff32_symbol
*s
= &data
->syms
[i
];
685 if (bfd_bread (&sym
, sizeof (sym
), abfd
) != sizeof (sym
))
687 non_fatal (_("cannot read symbol entry"));
691 s
->sym
.val
= bfd_h_get_32 (abfd
, sym
.e_value
);
692 s
->sym
.scnum
= bfd_h_get_16 (abfd
, sym
.e_scnum
);
693 s
->sym
.ntype
= bfd_h_get_16 (abfd
, sym
.e_type
);
694 s
->sym
.sclass
= bfd_h_get_8 (abfd
, sym
.e_sclass
);
695 s
->sym
.numaux
= bfd_h_get_8 (abfd
, sym
.e_numaux
);
699 memcpy (s
->sym
.raw
.name
, sym
.e
.e_name
, sizeof (sym
.e
.e_name
));
700 s
->sym
.raw
.name
[8] = 0;
701 s
->sym
.name
= s
->sym
.raw
.name
;
705 unsigned int soff
= bfd_h_get_32 (abfd
, sym
.e
.e
.e_offset
);
707 if ((s
->sym
.sclass
& DBXMASK
) == 0 && soff
< data
->strings_size
)
708 s
->sym
.name
= data
->strings
+ soff
;
712 s
->sym
.raw
.off
= soff
;
716 for (j
= 0; j
< s
->sym
.numaux
; j
++, i
++)
718 if (bfd_bread (&s
[j
+ 1].aux
,
719 sizeof (union external_auxent
), abfd
)
720 != sizeof (union external_auxent
))
722 non_fatal (_("cannot read symbol aux entry"));
731 free (data
->strings
);
732 data
->strings
= NULL
;
735 /* Dump xcoff symbols. */
738 dump_xcoff32_symbols (bfd
*abfd
, struct xcoff_dump
*data
)
744 printf (_("Symbols table (strtable at 0x%08x)"),
746 + data
->nsyms
* (unsigned)sizeof (struct external_syment
));
747 if (data
->nsyms
== 0 || data
->syms
== NULL
)
749 printf (_(":\n No symbols\n"));
753 /* Read strings table. */
754 if (data
->strings_size
== 0)
755 printf (_(" (no strings):\n"));
757 printf (_(" (strings size: %08x):\n"), data
->strings_size
);
759 /* Read debug section. */
760 debugsec
= bfd_get_section_by_name (abfd
, ".debug");
761 if (debugsec
!= NULL
)
765 size
= bfd_section_size (debugsec
);
766 debug
= (char *) xmalloc (size
);
767 bfd_get_section_contents (abfd
, debugsec
, debug
, 0, size
);
770 /* Translators: 'sc' is for storage class, 'off' for offset. */
771 printf (_(" # sc value section type aux name/off\n"));
772 for (i
= 0; i
< data
->nsyms
; i
++)
774 union xcoff32_symbol
*s
= &data
->syms
[i
];
778 dump_value (sc_xlat
, s
->sym
.sclass
, 10);
779 printf (" %08x ", s
->sym
.val
);
780 if (s
->sym
.scnum
> 0 && s
->sym
.scnum
<= data
->nscns
)
782 if (data
->sects
!= NULL
)
783 printf ("%-8s", data
->sects
[s
->sym
.scnum
- 1].name
);
785 printf ("%-8u", s
->sym
.scnum
);
788 switch ((signed short)s
->sym
.scnum
)
800 printf ("(%04x) ", s
->sym
.scnum
);
802 printf (" %04x %3u ", s
->sym
.ntype
, s
->sym
.numaux
);
803 if (s
->sym
.name
!= NULL
)
804 printf ("%s", s
->sym
.name
);
807 if ((s
->sym
.sclass
& DBXMASK
) != 0 && debug
!= NULL
)
808 printf ("%s", debug
+ s
->sym
.raw
.off
);
810 printf ("%08x", s
->sym
.raw
.off
);
814 for (j
= 0; j
< s
->sym
.numaux
; j
++, i
++)
816 union external_auxent
*aux
= &s
[j
+ 1].aux
;
818 printf (" %3u ", i
+ 1);
819 switch (s
->sym
.sclass
)
822 /* Section length, number of relocs and line number. */
823 printf (_(" scnlen: %08x nreloc: %-6u nlinno: %-6u\n"),
824 (unsigned)bfd_h_get_32 (abfd
, aux
->x_scn
.x_scnlen
),
825 (unsigned)bfd_h_get_16 (abfd
, aux
->x_scn
.x_nreloc
),
826 (unsigned)bfd_h_get_16 (abfd
, aux
->x_scn
.x_nlinno
));
829 /* Section length and number of relocs. */
830 printf (_(" scnlen: %08x nreloc: %-6u\n"),
831 (unsigned)bfd_h_get_32 (abfd
, aux
->x_scn
.x_scnlen
),
832 (unsigned)bfd_h_get_16 (abfd
, aux
->x_scn
.x_nreloc
));
837 if (j
== 0 && s
->sym
.numaux
> 1)
839 /* Function aux entry (Do not translate). */
840 printf (" exptr: %08x fsize: %08x lnnoptr: %08x endndx: %u\n",
841 (unsigned)bfd_h_get_32 (abfd
, aux
->x_fcn
.x_exptr
),
842 (unsigned)bfd_h_get_32
843 (abfd
, aux
->x_fcn
.x_fsize
),
844 (unsigned)bfd_h_get_32
845 (abfd
, aux
->x_fcn
.x_lnnoptr
),
846 (unsigned)bfd_h_get_32
847 (abfd
, aux
->x_fcn
.x_endndx
));
849 else if (j
== 1 || (j
== 0 && s
->sym
.numaux
== 1))
851 /* csect aux entry. */
855 smtyp
= bfd_h_get_8 (abfd
, aux
->x_csect
.x_smtyp
);
856 scnlen
= bfd_h_get_32 (abfd
, aux
->x_csect
.x_scnlen
);
859 printf (" scnsym: %-8u", scnlen
);
861 printf (" scnlen: %08x", scnlen
);
862 printf (" h: parm=%08x sn=%04x al: 2**%u",
863 (unsigned)bfd_h_get_32 (abfd
, aux
->x_csect
.x_parmhash
),
864 (unsigned)bfd_h_get_16 (abfd
, aux
->x_csect
.x_snhash
),
865 SMTYP_ALIGN (smtyp
));
867 dump_value (smtyp_xlat
, SMTYP_SMTYP (smtyp
), 2);
871 (unsigned)bfd_h_get_8 (abfd
, aux
->x_csect
.x_smclas
), 6);
875 /* Do not translate - generic field name. */
882 printf (" ftype: %02x ",
883 (unsigned)bfd_h_get_8 (abfd
, aux
->x_file
.x_ftype
));
884 if (aux
->x_file
.x_n
.x_fname
[0] != 0)
885 printf ("fname: %.14s", aux
->x_file
.x_n
.x_fname
);
888 off
= (unsigned)bfd_h_get_32
889 (abfd
, aux
->x_file
.x_n
.x_n
.x_offset
);
890 if (data
->strings
!= NULL
&& off
< data
->strings_size
)
891 printf (" %s", data
->strings
+ off
);
893 printf (_("offset: %08x"), off
);
900 printf (" lnno: %u\n",
901 (unsigned)bfd_h_get_16
902 (abfd
, aux
->x_sym
.x_lnno
));
905 /* Do not translate - generic field name. */
915 /* Dump xcoff relocation entries. */
918 dump_xcoff32_relocs (bfd
*abfd
, struct xcoff_dump
*data
)
922 if (data
->sects
== NULL
)
924 non_fatal (_("cannot read section headers"));
928 for (i
= 0; i
< data
->nscns
; i
++)
930 struct xcoff32_section
*sect
= &data
->sects
[i
];
931 unsigned int nrel
= sect
->nreloc
;
936 printf (_("Relocations for %s (%u)\n"), sect
->name
, nrel
);
937 if (bfd_seek (abfd
, sect
->relptr
, SEEK_SET
) != 0)
939 non_fatal (_("cannot read relocations"));
942 /* Do not translate: fields name. */
943 printf ("vaddr sgn mod sz type symndx symbol\n");
944 for (j
= 0; j
< nrel
; j
++)
946 struct external_reloc rel
;
950 if (bfd_bread (&rel
, sizeof (rel
), abfd
) != sizeof (rel
))
952 non_fatal (_("cannot read relocation entry"));
955 rsize
= bfd_h_get_8 (abfd
, rel
.r_size
);
956 printf ("%08x %c %c %-2u ",
957 (unsigned int)bfd_h_get_32 (abfd
, rel
.r_vaddr
),
958 rsize
& 0x80 ? 'S' : 'U',
959 rsize
& 0x40 ? 'm' : ' ',
961 dump_value (rtype_xlat
, bfd_h_get_8 (abfd
, rel
.r_type
), 6);
962 symndx
= bfd_h_get_32 (abfd
, rel
.r_symndx
);
963 printf ("%-6u ", symndx
);
964 xcoff32_print_symbol (data
, symndx
);
971 /* Dump xcoff line number entries. */
974 dump_xcoff32_lineno (bfd
*abfd
, struct xcoff_dump
*data
)
978 if (data
->sects
== NULL
)
980 non_fatal (_("cannot read section headers"));
984 for (i
= 0; i
< data
->nscns
; i
++)
986 struct xcoff32_section
*sect
= &data
->sects
[i
];
987 unsigned int nlnno
= sect
->nlnno
;
992 printf (_("Line numbers for %s (%u)\n"), sect
->name
, nlnno
);
993 if (bfd_seek (abfd
, sect
->lnnoptr
, SEEK_SET
) != 0)
995 non_fatal (_("cannot read line numbers"));
998 /* Line number, symbol index and physical address. */
999 printf (_("lineno symndx/paddr\n"));
1000 for (j
= 0; j
< nlnno
; j
++)
1002 struct external_lineno ln
;
1005 if (bfd_bread (&ln
, sizeof (ln
), abfd
) != sizeof (ln
))
1007 non_fatal (_("cannot read line number entry"));
1010 no
= bfd_h_get_16 (abfd
, ln
.l_lnno
);
1011 printf (" %-6u ", no
);
1014 unsigned int symndx
= bfd_h_get_32 (abfd
, ln
.l_addr
.l_symndx
);
1015 xcoff32_print_symbol (data
, symndx
);
1019 (unsigned int)bfd_h_get_32 (abfd
, ln
.l_addr
.l_paddr
));
1025 /* Dump xcoff loader section. */
1028 dump_xcoff32_loader (bfd
*abfd
)
1031 bfd_size_type size
= 0;
1032 struct external_ldhdr
*lhdr
;
1033 struct external_ldsym
*ldsym
;
1034 struct external_ldrel
*ldrel
;
1036 unsigned int version
;
1037 unsigned int ndsyms
;
1041 unsigned int impoff
;
1042 unsigned int nimpid
;
1046 loader
= bfd_get_section_by_name (abfd
, ".loader");
1050 printf (_("no .loader section in file\n"));
1053 size
= bfd_section_size (loader
);
1054 if (size
< sizeof (*lhdr
))
1056 printf (_("section .loader is too short\n"));
1060 ldr_data
= (bfd_byte
*) xmalloc (size
);
1061 bfd_get_section_contents (abfd
, loader
, ldr_data
, 0, size
);
1062 lhdr
= (struct external_ldhdr
*)ldr_data
;
1063 printf (_("Loader header:\n"));
1064 version
= bfd_h_get_32 (abfd
, lhdr
->l_version
);
1065 printf (_(" version: %u\n"), version
);
1068 printf (_(" Unhandled version\n"));
1072 ndsyms
= bfd_h_get_32 (abfd
, lhdr
->l_nsyms
);
1073 printf (_(" nbr symbols: %u\n"), ndsyms
);
1074 ndrel
= bfd_h_get_32 (abfd
, lhdr
->l_nreloc
);
1075 printf (_(" nbr relocs: %u\n"), ndrel
);
1076 /* Import string table length. */
1077 printf (_(" import strtab len: %u\n"),
1078 (unsigned) bfd_h_get_32 (abfd
, lhdr
->l_istlen
));
1079 nimpid
= bfd_h_get_32 (abfd
, lhdr
->l_nimpid
);
1080 printf (_(" nbr import files: %u\n"), nimpid
);
1081 impoff
= bfd_h_get_32 (abfd
, lhdr
->l_impoff
);
1082 printf (_(" import file off: %u\n"), impoff
);
1083 stlen
= bfd_h_get_32 (abfd
, lhdr
->l_stlen
);
1084 printf (_(" string table len: %u\n"), stlen
);
1085 stoff
= bfd_h_get_32 (abfd
, lhdr
->l_stoff
);
1086 printf (_(" string table off: %u\n"), stoff
);
1088 ldsym
= (struct external_ldsym
*)(ldr_data
+ sizeof (*lhdr
));
1089 printf (_("Dynamic symbols:\n"));
1090 /* Do not translate: field names. */
1091 printf (" # value sc IFEW ty class file pa name\n");
1092 for (i
= 0; i
< ndsyms
; i
++, ldsym
++)
1094 unsigned char smtype
;
1096 printf (_(" %4u %08x %3u "), i
,
1097 (unsigned)bfd_h_get_32 (abfd
, ldsym
->l_value
),
1098 (unsigned)bfd_h_get_16 (abfd
, ldsym
->l_scnum
));
1099 smtype
= bfd_h_get_8 (abfd
, ldsym
->l_smtype
);
1100 putchar (smtype
& 0x40 ? 'I' : ' ');
1101 putchar (smtype
& 0x20 ? 'F' : ' ');
1102 putchar (smtype
& 0x10 ? 'E' : ' ');
1103 putchar (smtype
& 0x08 ? 'W' : ' ');
1105 dump_value (smtyp_xlat
, SMTYP_SMTYP (smtype
), 2);
1108 (smclas_xlat
, (unsigned)bfd_h_get_8 (abfd
, ldsym
->l_smclas
), 6);
1109 printf (_(" %3u %3u "),
1110 (unsigned)bfd_h_get_32 (abfd
, ldsym
->l_ifile
),
1111 (unsigned)bfd_h_get_32 (abfd
, ldsym
->l_parm
));
1112 if (ldsym
->_l
._l_name
[0] != 0)
1113 printf ("%-.8s", ldsym
->_l
._l_name
);
1116 unsigned int off
= bfd_h_get_32 (abfd
, ldsym
->_l
._l_l
._l_offset
);
1118 printf (_("(bad offset: %u)"), off
);
1120 printf ("%s", ldr_data
+ stoff
+ off
);
1125 printf (_("Dynamic relocs:\n"));
1126 /* Do not translate fields name. */
1127 printf (" vaddr sec sz typ sym\n");
1128 ldrel
= (struct external_ldrel
*)(ldr_data
+ sizeof (*lhdr
)
1129 + ndsyms
* sizeof (*ldsym
));
1130 for (i
= 0; i
< ndrel
; i
++, ldrel
++)
1134 unsigned int symndx
;
1136 rsize
= bfd_h_get_8 (abfd
, ldrel
->l_rtype
+ 0);
1137 rtype
= bfd_h_get_8 (abfd
, ldrel
->l_rtype
+ 1);
1139 printf (" %08x %3u %c%c %2u ",
1140 (unsigned)bfd_h_get_32 (abfd
, ldrel
->l_vaddr
),
1141 (unsigned)bfd_h_get_16 (abfd
, ldrel
->l_rsecnm
),
1142 rsize
& 0x80 ? 'S' : 'U',
1143 rsize
& 0x40 ? 'm' : ' ',
1144 (rsize
& 0x3f) + 1);
1145 dump_value (rtype_xlat
, rtype
, 6);
1146 symndx
= bfd_h_get_32 (abfd
, ldrel
->l_symndx
);
1159 printf ("%u", symndx
- 3);
1165 printf (_("Import files:\n"));
1166 p
= (char *)ldr_data
+ impoff
;
1167 for (i
= 0; i
< nimpid
; i
++)
1172 n2
= strlen (p
+ n1
+ 1);
1173 n3
= strlen (p
+ n1
+ 1 + n2
+ 1);
1174 printf (" %2u: %s,%s,%s\n", i
,
1175 p
, p
+ n1
+ 1, p
+ n1
+ n2
+ 2);
1176 p
+= n1
+ n2
+ n3
+ 3;
1182 /* Dump xcoff exception section. */
1185 dump_xcoff32_except (bfd
*abfd
, struct xcoff_dump
*data
)
1188 bfd_size_type size
= 0;
1189 bfd_byte
*excp_data
;
1190 struct external_exceptab
*exceptab
;
1193 sec
= bfd_get_section_by_name (abfd
, ".except");
1197 printf (_("no .except section in file\n"));
1200 size
= bfd_section_size (sec
);
1201 excp_data
= (bfd_byte
*) xmalloc (size
);
1202 bfd_get_section_contents (abfd
, sec
, excp_data
, 0, size
);
1203 exceptab
= (struct external_exceptab
*)excp_data
;
1205 printf (_("Exception table:\n"));
1206 /* Do not translate fields name. */
1207 printf ("lang reason sym/addr\n");
1208 for (i
= 0; i
* sizeof (*exceptab
) < size
; i
++, exceptab
++)
1210 unsigned int reason
;
1213 addr
= bfd_get_32 (abfd
, exceptab
->e_addr
.e_paddr
);
1214 reason
= bfd_get_8 (abfd
, exceptab
->e_reason
);
1215 printf (" %02x %02x ",
1216 (unsigned) bfd_get_8 (abfd
, exceptab
->e_lang
), reason
);
1218 xcoff32_print_symbol (data
, addr
);
1220 printf ("@%08x", addr
);
1226 /* Dump xcoff type-check section. */
1229 dump_xcoff32_typchk (bfd
*abfd
)
1232 bfd_size_type size
= 0;
1236 sec
= bfd_get_section_by_name (abfd
, ".typchk");
1240 printf (_("no .typchk section in file\n"));
1243 size
= bfd_section_size (sec
);
1244 data
= (bfd_byte
*) xmalloc (size
);
1245 bfd_get_section_contents (abfd
, sec
, data
, 0, size
);
1247 printf (_("Type-check section:\n"));
1248 /* Do not translate field names. */
1249 printf ("offset len lang-id general-hash language-hash\n");
1250 for (i
= 0; i
< size
;)
1254 len
= bfd_get_16 (abfd
, data
+ i
);
1255 printf ("%08x: %-4u ", i
, len
);
1260 /* Expected format. */
1261 printf ("%04x %08x %08x\n",
1262 (unsigned) bfd_get_16 (abfd
, data
+ i
),
1263 (unsigned) bfd_get_32 (abfd
, data
+ i
+ 2),
1264 (unsigned) bfd_get_32 (abfd
, data
+ i
+ 2 + 4));
1270 for (j
= 0; j
< len
; j
++)
1274 printf (" %02x", (unsigned char)data
[i
+ j
]);
1283 /* Dump xcoff traceback tags section. */
1286 dump_xcoff32_tbtags (bfd
*abfd
,
1287 const char *text
, bfd_size_type text_size
,
1288 unsigned int text_start
, unsigned int func_start
)
1292 if (func_start
- text_start
> text_size
)
1294 printf (_(" address beyond section size\n"));
1297 for (i
= func_start
- text_start
; i
< text_size
; i
+= 4)
1298 if (bfd_get_32 (abfd
, text
+ i
) == 0)
1304 printf (_(" tags at %08x\n"), i
+ 4);
1305 if (i
+ 8 >= text_size
)
1308 tb1
= bfd_get_32 (abfd
, text
+ i
+ 4);
1309 tb2
= bfd_get_32 (abfd
, text
+ i
+ 8);
1311 printf (" version: %u, lang: %u, global_link: %u, is_eprol: %u, has_tboff: %u, int_proc: %u\n",
1318 printf (" has_ctl: %u, tocless: %u, fp_pres: %u, log_abort: %u, int_hndl: %u\n",
1324 printf (" name_pres: %u, uses_alloca: %u, cl_dis_inv: %u, saves_cr: %u, saves_lr: %u\n",
1330 printf (" stores_bc: %u, fixup: %u, fpr_saved: %-2u, spare3: %u, gpr_saved: %-2u\n",
1336 printf (" fixparms: %-3u floatparms: %-3u parm_on_stk: %u\n",
1341 if (((tb2
>> 1) & 0x7fff) != 0)
1343 unsigned int parminfo
;
1345 if (off
>= text_size
)
1347 parminfo
= bfd_get_32 (abfd
, text
+ off
);
1349 printf (" parminfo: 0x%08x\n", parminfo
);
1352 if ((tb1
>> 13) & 1)
1356 if (off
>= text_size
)
1358 tboff
= bfd_get_32 (abfd
, text
+ off
);
1360 printf (" tb_offset: 0x%08x (start=0x%08x)\n",
1361 tboff
, text_start
+ i
- tboff
);
1365 unsigned int hand_mask
;
1367 if (off
>= text_size
)
1369 hand_mask
= bfd_get_32 (abfd
, text
+ off
);
1371 printf (" hand_mask_offset: 0x%08x\n", hand_mask
);
1373 if ((tb1
>> 11) & 1)
1375 unsigned int ctl_info
;
1378 if (off
>= text_size
)
1380 ctl_info
= bfd_get_32 (abfd
, text
+ off
);
1382 printf (_(" number of CTL anchors: %u\n"), ctl_info
);
1383 for (j
= 0; j
< ctl_info
; j
++)
1385 if (off
>= text_size
)
1387 printf (" CTL[%u]: %08x\n",
1388 j
, (unsigned)bfd_get_32 (abfd
, text
+ off
));
1394 unsigned int name_len
;
1397 if (off
>= text_size
)
1399 name_len
= bfd_get_16 (abfd
, text
+ off
);
1401 printf (_(" Name (len: %u): "), name_len
);
1402 if (off
+ name_len
>= text_size
)
1404 printf (_("[truncated]\n"));
1407 for (j
= 0; j
< name_len
; j
++)
1408 if (ISPRINT (text
[off
+ j
]))
1409 putchar (text
[off
+ j
]);
1411 printf ("[%02x]", (unsigned char)text
[off
+ j
]);
1417 if (off
>= text_size
)
1419 printf (" alloca reg: %u\n",
1420 (unsigned) bfd_get_8 (abfd
, text
+ off
));
1423 printf (_(" (end of tags at %08x)\n"), text_start
+ off
);
1426 printf (_(" no tags found\n"));
1430 printf (_(" Truncated .text section\n"));
1435 dump_xcoff32_traceback (bfd
*abfd
, struct xcoff_dump
*data
)
1438 unsigned int scnum_text
= -1;
1439 unsigned int text_vma
;
1441 bfd_size_type text_size
;
1444 if (data
->syms
== NULL
|| data
->sects
== NULL
)
1447 /* Read text section. */
1448 text_sec
= bfd_get_section_by_name (abfd
, ".text");
1449 if (text_sec
== NULL
)
1451 text_vma
= bfd_section_vma (text_sec
);
1453 text_size
= bfd_section_size (text_sec
);
1454 text
= (char *) xmalloc (text_size
);
1455 bfd_get_section_contents (abfd
, text_sec
, text
, 0, text_size
);
1457 for (i
= 0; i
< data
->nscns
; i
++)
1458 if (data
->sects
[i
].flags
== STYP_TEXT
)
1463 if (scnum_text
== (unsigned int)-1)
1466 for (i
= 0; i
< data
->nsyms
; i
++)
1468 union xcoff32_symbol
*s
= &data
->syms
[i
];
1470 switch (s
->sym
.sclass
)
1475 if (s
->sym
.scnum
== scnum_text
1476 && s
->sym
.numaux
> 0)
1478 union external_auxent
*aux
= &s
[s
->sym
.numaux
].aux
;
1481 unsigned int smclas
;
1483 smtyp
= bfd_h_get_8 (abfd
, aux
->x_csect
.x_smtyp
);
1484 smclas
= bfd_h_get_8 (abfd
, aux
->x_csect
.x_smclas
);
1485 if (SMTYP_SMTYP (smtyp
) == XTY_LD
1486 && (smclas
== XMC_PR
1488 || smclas
== XMC_XO
))
1490 printf ("%08x: ", s
->sym
.val
);
1491 xcoff32_print_symbol (data
, i
);
1493 dump_xcoff32_tbtags (abfd
, text
, text_size
,
1494 text_vma
, s
->sym
.val
);
1506 /* Dump the TOC symbols. */
1509 dump_xcoff32_toc (bfd
*abfd
, struct xcoff_dump
*data
)
1512 unsigned int nbr_ent
;
1515 printf (_("TOC:\n"));
1517 if (data
->syms
== NULL
)
1523 for (i
= 0; i
< data
->nsyms
; i
++)
1525 union xcoff32_symbol
*s
= &data
->syms
[i
];
1527 switch (s
->sym
.sclass
)
1532 if (s
->sym
.numaux
> 0)
1534 union external_auxent
*aux
= &s
[s
->sym
.numaux
].aux
;
1535 unsigned int smclas
;
1536 unsigned int ent_sz
;
1538 smclas
= bfd_h_get_8 (abfd
, aux
->x_csect
.x_smclas
);
1539 if (smclas
== XMC_TC
1541 || smclas
== XMC_TC0
)
1543 ent_sz
= bfd_h_get_32 (abfd
, aux
->x_scn
.x_scnlen
);
1544 printf ("%08x %08x ",
1545 s
->sym
.val
, ent_sz
);
1546 xcoff32_print_symbol (data
, i
);
1558 printf (_("Nbr entries: %-8u Size: %08x (%u)\n"),
1559 nbr_ent
, size
, size
);
1562 /* Handle an rs6000 xcoff file. */
1565 dump_xcoff32 (bfd
*abfd
, struct external_filehdr
*fhdr
)
1567 struct xcoff_dump data
;
1569 data
.nscns
= bfd_h_get_16 (abfd
, fhdr
->f_nscns
);
1570 data
.symptr
= bfd_h_get_32 (abfd
, fhdr
->f_symptr
);
1571 data
.nsyms
= bfd_h_get_32 (abfd
, fhdr
->f_nsyms
);
1572 data
.opthdr
= bfd_h_get_16 (abfd
, fhdr
->f_opthdr
);
1575 data
.strings
= NULL
;
1576 data
.strings_size
= 0;
1578 if (options
[OPT_FILE_HEADER
].selected
)
1579 dump_xcoff32_file_header (abfd
, fhdr
, &data
);
1581 if (options
[OPT_AOUT
].selected
)
1582 dump_xcoff32_aout_header (abfd
, &data
);
1584 if (options
[OPT_SYMS
].selected
1585 || options
[OPT_RELOCS
].selected
1586 || options
[OPT_LINENO
].selected
1587 || options
[OPT_TRACEBACK
].selected
)
1588 xcoff32_read_sections (abfd
, &data
);
1590 if (options
[OPT_SECTIONS
].selected
)
1591 dump_xcoff32_sections_header (abfd
, &data
);
1593 if (options
[OPT_SYMS
].selected
1594 || options
[OPT_RELOCS
].selected
1595 || options
[OPT_LINENO
].selected
1596 || options
[OPT_EXCEPT
].selected
1597 || options
[OPT_TRACEBACK
].selected
1598 || options
[OPT_TOC
].selected
)
1599 xcoff32_read_symbols (abfd
, &data
);
1601 if (options
[OPT_SYMS
].selected
)
1602 dump_xcoff32_symbols (abfd
, &data
);
1604 if (options
[OPT_RELOCS
].selected
)
1605 dump_xcoff32_relocs (abfd
, &data
);
1607 if (options
[OPT_LINENO
].selected
)
1608 dump_xcoff32_lineno (abfd
, &data
);
1610 if (options
[OPT_LOADER
].selected
)
1611 dump_xcoff32_loader (abfd
);
1613 if (options
[OPT_EXCEPT
].selected
)
1614 dump_xcoff32_except (abfd
, &data
);
1616 if (options
[OPT_TYPCHK
].selected
)
1617 dump_xcoff32_typchk (abfd
);
1619 if (options
[OPT_TRACEBACK
].selected
)
1620 dump_xcoff32_traceback (abfd
, &data
);
1622 if (options
[OPT_TOC
].selected
)
1623 dump_xcoff32_toc (abfd
, &data
);
1626 free (data
.strings
);
1630 /* Dump ABFD (according to the options[] array). */
1633 xcoff_dump_obj (bfd
*abfd
)
1635 struct external_filehdr fhdr
;
1636 unsigned short magic
;
1638 /* Read file header. */
1639 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0
1640 || bfd_bread (&fhdr
, sizeof (fhdr
), abfd
) != sizeof (fhdr
))
1642 non_fatal (_("cannot read header"));
1646 /* Decoding. We don't use the bfd/coff function to get all the fields. */
1647 magic
= bfd_h_get_16 (abfd
, fhdr
.f_magic
);
1648 if (options
[OPT_FILE_HEADER
].selected
)
1650 printf (_("File header:\n"));
1651 printf (_(" magic: 0x%04x (0%04o) "), magic
, magic
);
1655 printf (_("(WRMAGIC: writable text segments)"));
1658 printf (_("(ROMAGIC: readonly sharablee text segments)"));
1661 printf (_("(TOCMAGIC: readonly text segments and TOC)"));
1664 printf (_("unknown magic"));
1669 if (magic
== U802ROMAGIC
|| magic
== U802WRMAGIC
|| magic
== U802TOCMAGIC
)
1670 dump_xcoff32 (abfd
, &fhdr
);
1672 printf (_(" Unhandled magic\n"));
1675 /* Handle an AIX dumpx core file. */
1678 dump_dumpx_core (bfd
*abfd
, struct external_core_dumpx
*hdr
)
1680 if (options
[OPT_FILE_HEADER
].selected
)
1682 printf (" signal: %u\n",
1683 (unsigned) bfd_h_get_8 (abfd
, hdr
->c_signo
));
1684 printf (" flags: 0x%02x\n",
1685 (unsigned) bfd_h_get_8 (abfd
, hdr
->c_flag
));
1686 printf (" entries: %u\n",
1687 (unsigned) bfd_h_get_16 (abfd
, hdr
->c_entries
));
1689 printf (" fdsinfox: offset: 0x%08" BFD_VMA_FMT
"x\n",
1690 bfd_h_get_64 (abfd
, hdr
->c_fdsinfox
));
1691 printf (" loader: offset: 0x%08" BFD_VMA_FMT
"x, "
1692 "size: 0x%" BFD_VMA_FMT
"x\n",
1693 bfd_h_get_64 (abfd
, hdr
->c_loader
),
1694 bfd_h_get_64 (abfd
, hdr
->c_lsize
));
1695 printf (" thr: offset: 0x%08" BFD_VMA_FMT
"x, nbr: %u\n",
1696 bfd_h_get_64 (abfd
, hdr
->c_thr
),
1697 (unsigned) bfd_h_get_32 (abfd
, hdr
->c_n_thr
));
1698 printf (" segregions: offset: 0x%08" BFD_VMA_FMT
"x, "
1699 "nbr: %" BFD_VMA_FMT
"u\n",
1700 bfd_h_get_64 (abfd
, hdr
->c_segregion
),
1701 bfd_h_get_64 (abfd
, hdr
->c_segs
));
1702 printf (" stack: offset: 0x%08" BFD_VMA_FMT
"x, "
1703 "org: 0x%" BFD_VMA_FMT
"x, "
1704 "size: 0x%" BFD_VMA_FMT
"x\n",
1705 bfd_h_get_64 (abfd
, hdr
->c_stack
),
1706 bfd_h_get_64 (abfd
, hdr
->c_stackorg
),
1707 bfd_h_get_64 (abfd
, hdr
->c_size
));
1708 printf (" data: offset: 0x%08" BFD_VMA_FMT
"x, "
1709 "org: 0x%" BFD_VMA_FMT
"x, "
1710 "size: 0x%" BFD_VMA_FMT
"x\n",
1711 bfd_h_get_64 (abfd
, hdr
->c_data
),
1712 bfd_h_get_64 (abfd
, hdr
->c_dataorg
),
1713 bfd_h_get_64 (abfd
, hdr
->c_datasize
));
1714 printf (" sdata: org: 0x%" BFD_VMA_FMT
"x, "
1715 "size: 0x%" BFD_VMA_FMT
"x\n",
1716 bfd_h_get_64 (abfd
, hdr
->c_sdorg
),
1717 bfd_h_get_64 (abfd
, hdr
->c_sdsize
));
1718 printf (" vmmregions: offset: 0x%" BFD_VMA_FMT
"x, "
1719 "num: 0x%" BFD_VMA_FMT
"x\n",
1720 bfd_h_get_64 (abfd
, hdr
->c_vmm
),
1721 bfd_h_get_64 (abfd
, hdr
->c_vmmregions
));
1722 printf (" impl: 0x%08x\n",
1723 (unsigned) bfd_h_get_32 (abfd
, hdr
->c_impl
));
1724 printf (" cprs: 0x%" BFD_VMA_FMT
"x\n",
1725 bfd_h_get_64 (abfd
, hdr
->c_cprs
));
1728 if (options
[OPT_LDINFO
].selected
)
1731 file_ptr off
= (file_ptr
) bfd_h_get_64 (abfd
, hdr
->c_loader
);
1732 bfd_size_type len
= (bfd_size_type
) bfd_h_get_64 (abfd
, hdr
->c_lsize
);
1735 ldr
= xmalloc (len
);
1736 if (bfd_seek (abfd
, off
, SEEK_SET
) != 0
1737 || bfd_bread (ldr
, len
, abfd
) != len
)
1738 non_fatal (_("cannot read loader info table"));
1745 printf (" next core off textorg textsize dataorg datasize\n");
1749 struct external_ld_info32
*l
= (struct external_ld_info32
*)p
;
1753 next
= bfd_h_get_32 (abfd
, l
->ldinfo_next
);
1754 printf (" %08x %08x %08x %08x %08x %08x\n",
1756 (unsigned) bfd_h_get_32 (abfd
, l
->core_offset
),
1757 (unsigned) bfd_h_get_32 (abfd
, l
->ldinfo_textorg
),
1758 (unsigned) bfd_h_get_32 (abfd
, l
->ldinfo_textsize
),
1759 (unsigned) bfd_h_get_32 (abfd
, l
->ldinfo_dataorg
),
1760 (unsigned) bfd_h_get_32 (abfd
, l
->ldinfo_datasize
));
1761 n1
= strlen ((char *) l
->ldinfo_filename
);
1763 l
->ldinfo_filename
, l
->ldinfo_filename
+ n1
+ 1);
1771 "ldinfo dump not supported in 32 bits environments\n"));
1776 /* Dump a core file. */
1779 xcoff_dump_core (bfd
*abfd
)
1781 struct external_core_dumpx hdr
;
1782 unsigned int version
;
1784 /* Read file header. */
1785 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0
1786 || bfd_bread (&hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
1788 non_fatal (_("cannot core read header"));
1792 version
= bfd_h_get_32 (abfd
, hdr
.c_version
);
1793 if (options
[OPT_FILE_HEADER
].selected
)
1795 printf (_("Core header:\n"));
1796 printf (_(" version: 0x%08x "), version
);
1799 case CORE_DUMPX_VERSION
:
1800 printf (_("(dumpx format - aix4.3 / 32 bits)"));
1802 case CORE_DUMPXX_VERSION
:
1803 printf (_("(dumpxx format - aix5.0 / 64 bits)"));
1806 printf (_("unknown format"));
1811 if (version
== CORE_DUMPX_VERSION
)
1812 dump_dumpx_core (abfd
, &hdr
);
1814 printf (_(" Unhandled magic\n"));
1817 /* Dump an XCOFF file. */
1820 xcoff_dump (bfd
*abfd
)
1822 /* We rely on BFD to decide if the file is a core file. Note that core
1823 files are only supported on native environment by BFD. */
1824 switch (bfd_get_format (abfd
))
1827 xcoff_dump_core (abfd
);
1830 xcoff_dump_obj (abfd
);
1835 /* Vector for xcoff. */
1837 const struct objdump_private_desc objdump_private_desc_xcoff
=