1 /* readelf.c -- display contents of an ELF format file
2 Copyright (C) 1998, 1999 Free Software Foundation, Inc.
4 Originally developed by Eric Youngdale <eric@andante.jic.com>
5 Modifications by Nick Clifton <nickc@cygnus.com>
7 This file is part of GNU Binutils.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
32 #include "elf/common.h"
33 #include "elf/external.h"
34 #include "elf/internal.h"
35 #include "elf/dwarf2.h"
37 /* The following headers use the elf/reloc-macros.h file to
38 automatically generate relocation recognition functions
39 such as elf_mips_reloc_type() */
41 #define RELOC_MACROS_GEN_FUNC
47 #include "elf/alpha.h"
50 #include "elf/sparc.h"
55 #include "elf/mn10200.h"
56 #include "elf/mn10300.h"
64 #ifdef ANSI_PROTOTYPES
70 char * program_name
= "readelf";
71 unsigned int dynamic_addr
;
72 unsigned int dynamic_size
;
73 unsigned int rela_addr
;
74 unsigned int rela_size
;
75 char * dynamic_strings
;
77 Elf_Internal_Sym
* dynamic_symbols
;
78 Elf_Internal_Syminfo
* dynamic_syminfo
;
79 unsigned long dynamic_syminfo_offset
;
80 unsigned int dynamic_syminfo_nent
;
81 char program_interpreter
[64];
82 int dynamic_info
[DT_JMPREL
+ 1];
85 Elf_Internal_Ehdr elf_header
;
86 Elf_Internal_Shdr
* section_headers
;
87 Elf_Internal_Dyn
* dynamic_segment
;
101 int do_debug_abbrevs
;
103 int do_debug_pubnames
;
104 int do_debug_aranges
;
107 static unsigned long (* byte_get
) PARAMS ((unsigned char *, int));
109 /* XXX - An arbitary constant, limiting the number of sections
110 for whcih we can display information. */
111 #define NUM_DUMP_SECTS 100
112 char dump_sects
[NUM_DUMP_SECTS
];
114 #define HEX_DUMP (1 << 0)
115 #define DISASS_DUMP (1 << 1)
116 #define DEBUG_DUMP (1 << 2)
118 /* Forward declarations for dumb compilers. */
119 static const char * get_mips_dynamic_type
PARAMS ((unsigned long type
));
120 static const char * get_dynamic_type
PARAMS ((unsigned long type
));
121 static int dump_relocations
PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Sym
*, char *));
122 static char * get_file_type
PARAMS ((unsigned e_type
));
123 static char * get_machine_name
PARAMS ((unsigned e_machine
));
124 static char * get_machine_data
PARAMS ((unsigned e_data
));
125 static char * get_machine_flags
PARAMS ((unsigned, unsigned e_machine
));
126 static const char * get_mips_segment_type
PARAMS ((unsigned long type
));
127 static const char * get_segment_type
PARAMS ((unsigned long p_type
));
128 static const char * get_mips_section_type_name
PARAMS ((unsigned int sh_type
));
129 static const char * get_section_type_name
PARAMS ((unsigned int sh_type
));
130 static char * get_symbol_binding
PARAMS ((unsigned int binding
));
131 static char * get_symbol_type
PARAMS ((unsigned int type
));
132 static void usage
PARAMS ((void));
133 static void parse_args
PARAMS ((int argc
, char ** argv
));
134 static int process_file_header
PARAMS ((void));
135 static int process_program_headers
PARAMS ((FILE *));
136 static int process_section_headers
PARAMS ((FILE *));
137 static void dynamic_segment_mips_val
PARAMS ((Elf_Internal_Dyn
*entry
));
138 static int process_dynamic_segment
PARAMS ((FILE *));
139 static int process_symbol_table
PARAMS ((FILE *));
140 static int process_section_contents
PARAMS ((FILE *));
141 static void process_file
PARAMS ((char * file_name
));
142 static int process_relocs
PARAMS ((FILE *));
143 static int process_version_sections
PARAMS ((FILE *));
144 static char * get_ver_flags
PARAMS ((unsigned int flags
));
145 static char * get_symbol_index_type
PARAMS ((unsigned int type
));
146 static int get_section_headers
PARAMS ((FILE * file
));
147 static int get_file_header
PARAMS ((FILE * file
));
148 static Elf_Internal_Sym
* get_elf_symbols
PARAMS ((FILE * file
, unsigned long offset
, unsigned long number
));
149 static int * get_dynamic_data
PARAMS ((FILE * file
, unsigned int number
));
150 static int disassemble_section
PARAMS ((Elf32_Internal_Shdr
*, FILE *));
151 static int dump_section
PARAMS ((Elf32_Internal_Shdr
*, FILE *));
152 static int display_debug_section
PARAMS ((Elf32_Internal_Shdr
*, FILE *));
153 static int display_debug_info
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
154 static int display_debug_not_supported
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
155 static int display_debug_lines
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
156 static int display_debug_abbrev
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
157 static int display_debug_aranges
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
158 static unsigned char * process_abbrev_section
PARAMS ((unsigned char *, unsigned char *));
159 static unsigned long read_leb128
PARAMS ((unsigned char *, int *, int));
160 static int process_extended_line_op
PARAMS ((unsigned char *, long *));
161 static char * get_TAG_name
PARAMS ((unsigned long));
162 static char * get_AT_name
PARAMS ((unsigned long));
163 static char * get_FORM_name
PARAMS ((unsigned long));
164 static void free_abbrevs
PARAMS ((void));
165 static void add_abbrev
PARAMS ((unsigned long, unsigned long, int));
166 static void add_abbrev_attr
PARAMS ((unsigned long, unsigned long));
167 static unsigned char * read_and_display_attr
PARAMS ((unsigned long, unsigned long, unsigned char *, unsigned long));
168 static unsigned char * display_block
PARAMS ((unsigned char *, unsigned long));
170 typedef int Elf32_Word
;
172 #define SECTION_NAME(X) (string_table + (X)->sh_name)
174 #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
176 #define BYTE_GET(field) byte_get (field, sizeof (field))
178 #define NUM_ELEM(array) (sizeof (array) / sizeof ((array)[0]))
180 #define GET_DATA_ALLOC(offset, size, var, type, reason) \
181 if (fseek (file, offset, SEEK_SET)) \
183 error (_("Unable to seek to start of %s at %x\n"), reason, offset); \
187 var = (type) malloc (size); \
191 error (_("Out of memory allocating %d bytes for %s\n"), size, reason); \
195 if (fread (var, size, 1, file) != 1) \
197 error (_("Unable to read in %d bytes of %s\n"), size, reason); \
204 #define GET_DATA(offset, var, reason) \
205 if (fseek (file, offset, SEEK_SET)) \
207 error (_("Unable to seek to %x for %s\n"), offset, reason); \
210 else if (fread (& var, sizeof (var), 1, file) != 1) \
212 error (_("Unable to read data at %x for %s\n"), offset, reason); \
216 #ifdef ANSI_PROTOTYPES
218 error (const char * message
, ...)
222 fprintf (stderr
, _("%s: Error: "), program_name
);
223 va_start (args
, message
);
224 vfprintf (stderr
, message
, args
);
230 warn (const char * message
, ...)
234 fprintf (stderr
, _("%s: Warning: "), program_name
);
235 va_start (args
, message
);
236 vfprintf (stderr
, message
, args
);
248 fprintf (stderr
, _("%s: Error: "), program_name
);
250 message
= va_arg (args
, char *);
251 vfprintf (stderr
, message
, args
);
263 fprintf (stderr
, _("%s: Warning: "), program_name
);
265 message
= va_arg (args
, char *);
266 vfprintf (stderr
, message
, args
);
272 static unsigned long int
273 byte_get_little_endian (field
, size
)
274 unsigned char * field
;
283 return ((unsigned int) (field
[0]))
284 | (((unsigned int) (field
[1])) << 8);
287 return ((unsigned long) (field
[0]))
288 | (((unsigned long) (field
[1])) << 8)
289 | (((unsigned long) (field
[2])) << 16)
290 | (((unsigned long) (field
[3])) << 24);
293 error (_("Unhandled data length: %d\n"), size
);
298 static unsigned long int
299 byte_get_big_endian (field
, size
)
300 unsigned char * field
;
309 return ((unsigned int) (field
[1])) | (((int) (field
[0])) << 8);
312 return ((unsigned long) (field
[3]))
313 | (((unsigned long) (field
[2])) << 8)
314 | (((unsigned long) (field
[1])) << 16)
315 | (((unsigned long) (field
[0])) << 24);
318 error (_("Unhandled data length: %d\n"), size
);
324 /* Display the contents of the relocation data
325 found at the specified offset. */
327 dump_relocations (file
, rel_offset
, rel_size
, symtab
, strtab
)
329 unsigned long rel_offset
;
330 unsigned long rel_size
;
331 Elf_Internal_Sym
* symtab
;
336 Elf_Internal_Rel
* rels
;
337 Elf_Internal_Rela
* relas
;
340 /* Compute number of relocations and read them in. */
341 switch (elf_header
.e_machine
)
351 Elf32_External_Rel
* erels
;
353 GET_DATA_ALLOC (rel_offset
, rel_size
, erels
,
354 Elf32_External_Rel
*, "relocs");
356 rel_size
= rel_size
/ sizeof (Elf32_External_Rel
);
358 rels
= (Elf_Internal_Rel
*) malloc (rel_size
*
359 sizeof (Elf_Internal_Rel
));
361 for (i
= 0; i
< rel_size
; i
++)
363 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
364 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
370 relas
= (Elf_Internal_Rela
*) rels
;
379 case EM_CYGNUS_MN10200
:
380 case EM_CYGNUS_MN10300
:
385 Elf32_External_Rela
* erelas
;
387 GET_DATA_ALLOC (rel_offset
, rel_size
, erelas
,
388 Elf32_External_Rela
*, "relocs");
390 rel_size
= rel_size
/ sizeof (Elf32_External_Rela
);
392 relas
= (Elf_Internal_Rela
*) malloc (rel_size
*
393 sizeof (Elf_Internal_Rela
));
395 for (i
= 0; i
< rel_size
; i
++)
397 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
398 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
399 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
405 rels
= (Elf_Internal_Rel
*) relas
;
410 warn (_("Don't know about relocations on this machine architecture\n"));
416 (_(" Offset Info Type Symbol's Value Symbol's Name Addend\n"));
419 (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
421 for (i
= 0; i
< rel_size
; i
++)
424 unsigned long offset
;
430 offset
= relas
[i
].r_offset
;
431 info
= relas
[i
].r_info
;
435 offset
= rels
[i
].r_offset
;
436 info
= rels
[i
].r_info
;
439 printf (" %8.8lx %5.5lx ", offset
, info
);
441 switch (elf_header
.e_machine
)
448 rtype
= elf_m32r_reloc_type (ELF32_R_TYPE (info
));
453 rtype
= elf_i386_reloc_type (ELF32_R_TYPE (info
));
457 rtype
= elf_m68k_reloc_type (ELF32_R_TYPE (info
));
461 rtype
= elf_sparc_reloc_type (ELF32_R_TYPE (info
));
465 rtype
= v850_reloc_type (ELF32_R_TYPE (info
));
469 rtype
= elf_d10v_reloc_type (ELF32_R_TYPE (info
));
473 rtype
= elf_d30v_reloc_type (ELF32_R_TYPE (info
));
477 rtype
= elf_sh_reloc_type (ELF32_R_TYPE (info
));
480 case EM_CYGNUS_MN10300
:
481 rtype
= elf_mn10300_reloc_type (ELF32_R_TYPE (info
));
484 case EM_CYGNUS_MN10200
:
485 rtype
= elf_mn10200_reloc_type (ELF32_R_TYPE (info
));
489 rtype
= elf_fr30_reloc_type (ELF32_R_TYPE (info
));
493 rtype
= elf_ppc_reloc_type (ELF32_R_TYPE (info
));
498 rtype
= elf_mips_reloc_type (ELF32_R_TYPE (info
));
502 rtype
= elf_alpha_reloc_type (ELF32_R_TYPE (info
));
506 rtype
= elf_arm_reloc_type (ELF32_R_TYPE (info
));
510 rtype
= elf_arc_reloc_type (ELF32_R_TYPE (info
));
514 rtype
= elf32_hppa_reloc_type (ELF32_R_TYPE (info
));
519 printf (_("unrecognised: %-7x"), ELF32_R_TYPE (info
));
521 printf ("%-21.21s", rtype
);
523 symtab_index
= ELF32_R_SYM (info
);
525 if (symtab_index
&& symtab
!= NULL
)
527 Elf_Internal_Sym
* psym
;
529 psym
= symtab
+ symtab_index
;
531 printf (" %08lx ", (unsigned long) psym
->st_value
);
533 if (psym
->st_name
== 0)
535 SECTION_NAME (section_headers
+ psym
->st_shndx
));
536 else if (strtab
== NULL
)
537 printf (_("<string table index %3d>"), psym
->st_name
);
539 printf ("%-25.25s", strtab
+ psym
->st_name
);
542 printf (" + %lx", (unsigned long) relas
[i
].r_addend
);
554 get_mips_dynamic_type (type
)
559 case DT_MIPS_RLD_VERSION
: return "MIPS_RLD_VERSION";
560 case DT_MIPS_TIME_STAMP
: return "MIPS_TIME_STAMP";
561 case DT_MIPS_ICHECKSUM
: return "MIPS_ICHECKSUM";
562 case DT_MIPS_IVERSION
: return "MIPS_IVERSION";
563 case DT_MIPS_FLAGS
: return "MIPS_FLAGS";
564 case DT_MIPS_BASE_ADDRESS
: return "MIPS_BASE_ADDRESS";
565 case DT_MIPS_MSYM
: return "MIPS_MSYM";
566 case DT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
567 case DT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
568 case DT_MIPS_LOCAL_GOTNO
: return "MIPS_LOCAL_GOTNO";
569 case DT_MIPS_CONFLICTNO
: return "MIPS_CONFLICTNO";
570 case DT_MIPS_LIBLISTNO
: return "MIPS_LIBLISTNO";
571 case DT_MIPS_SYMTABNO
: return "MIPS_SYMTABNO";
572 case DT_MIPS_UNREFEXTNO
: return "MIPS_UNREFEXTNO";
573 case DT_MIPS_GOTSYM
: return "MIPS_GOTSYM";
574 case DT_MIPS_HIPAGENO
: return "MIPS_HIPAGENO";
575 case DT_MIPS_RLD_MAP
: return "MIPS_RLD_MAP";
576 case DT_MIPS_DELTA_CLASS
: return "MIPS_DELTA_CLASS";
577 case DT_MIPS_DELTA_CLASS_NO
: return "MIPS_DELTA_CLASS_NO";
578 case DT_MIPS_DELTA_INSTANCE
: return "MIPS_DELTA_INSTANCE";
579 case DT_MIPS_DELTA_INSTANCE_NO
: return "MIPS_DELTA_INSTANCE_NO";
580 case DT_MIPS_DELTA_RELOC
: return "MIPS_DELTA_RELOC";
581 case DT_MIPS_DELTA_RELOC_NO
: return "MIPS_DELTA_RELOC_NO";
582 case DT_MIPS_DELTA_SYM
: return "MIPS_DELTA_SYM";
583 case DT_MIPS_DELTA_SYM_NO
: return "MIPS_DELTA_SYM_NO";
584 case DT_MIPS_DELTA_CLASSSYM
: return "MIPS_DELTA_CLASSSYM";
585 case DT_MIPS_DELTA_CLASSSYM_NO
: return "MIPS_DELTA_CLASSSYM_NO";
586 case DT_MIPS_CXX_FLAGS
: return "MIPS_CXX_FLAGS";
587 case DT_MIPS_PIXIE_INIT
: return "MIPS_PIXIE_INIT";
588 case DT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
589 case DT_MIPS_LOCALPAGE_GOTIDX
: return "MIPS_LOCALPAGE_GOTIDX";
590 case DT_MIPS_LOCAL_GOTIDX
: return "MIPS_LOCAL_GOTIDX";
591 case DT_MIPS_HIDDEN_GOTIDX
: return "MIPS_HIDDEN_GOTIDX";
592 case DT_MIPS_PROTECTED_GOTIDX
: return "MIPS_PROTECTED_GOTIDX";
593 case DT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
594 case DT_MIPS_INTERFACE
: return "MIPS_INTERFACE";
595 case DT_MIPS_DYNSTR_ALIGN
: return "MIPS_DYNSTR_ALIGN";
596 case DT_MIPS_INTERFACE_SIZE
: return "MIPS_INTERFACE_SIZE";
597 case DT_MIPS_RLD_TEXT_RESOLVE_ADDR
: return "MIPS_RLD_TEXT_RESOLVE_ADDR";
598 case DT_MIPS_PERF_SUFFIX
: return "MIPS_PERF_SUFFIX";
599 case DT_MIPS_COMPACT_SIZE
: return "MIPS_COMPACT_SIZE";
600 case DT_MIPS_GP_VALUE
: return "MIPS_GP_VALUE";
601 case DT_MIPS_AUX_DYNAMIC
: return "MIPS_AUX_DYNAMIC";
608 get_dynamic_type (type
)
611 static char buff
[32];
615 case DT_NULL
: return "NULL";
616 case DT_NEEDED
: return "NEEDED";
617 case DT_PLTRELSZ
: return "PLTRELSZ";
618 case DT_PLTGOT
: return "PLTGOT";
619 case DT_HASH
: return "HASH";
620 case DT_STRTAB
: return "STRTAB";
621 case DT_SYMTAB
: return "SYMTAB";
622 case DT_RELA
: return "RELA";
623 case DT_RELASZ
: return "RELASZ";
624 case DT_RELAENT
: return "RELAENT";
625 case DT_STRSZ
: return "STRSZ";
626 case DT_SYMENT
: return "SYMENT";
627 case DT_INIT
: return "INIT";
628 case DT_FINI
: return "FINI";
629 case DT_SONAME
: return "SONAME";
630 case DT_RPATH
: return "RPATH";
631 case DT_SYMBOLIC
: return "SYMBOLIC";
632 case DT_REL
: return "REL";
633 case DT_RELSZ
: return "RELSZ";
634 case DT_RELENT
: return "RELENT";
635 case DT_PLTREL
: return "PLTREL";
636 case DT_DEBUG
: return "DEBUG";
637 case DT_TEXTREL
: return "TEXTREL";
638 case DT_JMPREL
: return "JMPREL";
639 case DT_VERDEF
: return "VERDEF";
640 case DT_VERDEFNUM
: return "VERDEFNUM";
641 case DT_VERNEED
: return "VERNEED";
642 case DT_VERNEEDNUM
: return "VERNEEDNUM";
643 case DT_VERSYM
: return "VERSYN";
644 case DT_AUXILIARY
: return "AUXILARY";
645 case DT_FILTER
: return "FILTER";
646 case DT_POSFLAG_1
: return "POSFLAG_1";
647 case DT_SYMINSZ
: return "SYMINSZ";
648 case DT_SYMINENT
: return "SYMINENT";
649 case DT_SYMINFO
: return "SYMINFO";
650 case DT_RELACOUNT
: return "RELACOUNT";
651 case DT_RELCOUNT
: return "RELCOUNT";
652 case DT_FLAGS_1
: return "FLAGS_1";
653 case DT_USED
: return "USED";
656 if ((type
>= DT_LOPROC
) && (type
<= DT_HIPROC
))
658 const char *result
= NULL
;
659 switch (elf_header
.e_machine
)
663 result
= get_mips_dynamic_type (type
);
668 sprintf (buff
, _("Processor Specific"), type
);
674 sprintf (buff
, _("<unknown>: %x"), type
);
680 get_file_type (e_type
)
683 static char buff
[32];
687 case ET_NONE
: return _("NONE (None)");
688 case ET_REL
: return _("REL (Relocatable file)");
689 case ET_EXEC
: return _("EXEC (Executable file)");
690 case ET_DYN
: return _("DYN (Shared object file)");
691 case ET_CORE
: return _("CORE (Core file)");
694 if ((e_type
>= ET_LOPROC
) && (e_type
<= ET_HIPROC
))
695 sprintf (buff
, _("Processor Specific: (%x)"), e_type
);
697 sprintf (buff
, _("<unknown>: %x"), e_type
);
703 get_machine_name (e_machine
)
706 static char buff
[32];
710 case EM_NONE
: return _("None");
711 case EM_M32
: return "WE32100";
712 case EM_SPARC
: return "Sparc";
713 case EM_386
: return "Intel 80386";
714 case EM_68K
: return "MC68000";
715 case EM_88K
: return "MC88000";
716 case EM_486
: return "Intel 80486";
717 case EM_860
: return "Intel 80860";
718 case EM_MIPS
: return "MIPS R3000 big-endian";
719 case EM_S370
: return "Amdahl";
720 case EM_MIPS_RS4_BE
: return "MIPS R4000 big-endian";
721 case EM_OLD_SPARCV9
: return "Sparc v9 (old)";
722 case EM_PARISC
: return "HPPA";
723 case EM_PPC_OLD
: return "Power PC (old)";
724 case EM_SPARC32PLUS
: return "Sparc v8+" ;
725 case EM_960
: return "Intel 90860";
726 case EM_PPC
: return "PowerPC";
727 case EM_V800
: return "NEC V800";
728 case EM_FR20
: return "Fujitsu FR20";
729 case EM_RH32
: return "TRW RH32";
730 case EM_MMA
: return "Fujitsu MMA";
731 case EM_ARM
: return "ARM";
732 case EM_OLD_ALPHA
: return "Digital Alpha (old)";
733 case EM_SH
: return "Hitachi SH";
734 case EM_SPARCV9
: return "Sparc v9";
735 case EM_ALPHA
: return "Alpha";
736 case EM_CYGNUS_D10V
: return "d10v";
737 case EM_CYGNUS_D30V
: return "d30v";
738 case EM_CYGNUS_ARC
: return "Arc";
739 case EM_CYGNUS_M32R
: return "M32r";
740 case EM_CYGNUS_V850
: return "v850";
741 case EM_CYGNUS_MN10300
: return "mn10300";
742 case EM_CYGNUS_MN10200
: return "mn10200";
743 case EM_CYGNUS_FR30
: return "FR30";
746 sprintf (buff
, _("<unknown>: %x"), e_machine
);
752 get_machine_flags (e_flags
, e_machine
)
756 static char buf
[1024];
767 if (e_flags
& EF_PPC_EMB
)
768 strcat (buf
, ", emb");
770 if (e_flags
& EF_PPC_RELOCATABLE
)
771 strcat (buf
, ", relocatable");
773 if (e_flags
& EF_PPC_RELOCATABLE_LIB
)
774 strcat (buf
, ", relocatable-lib");
778 switch (e_flags
& EF_V850_ARCH
)
781 strcat (buf
, ", v850e");
784 strcat (buf
, ", v850ea");
787 strcat (buf
, ", v850");
790 strcat (buf
, ", unknown v850 architecture variant");
796 if ((e_flags
& EF_M32R_ARCH
) == E_M32R_ARCH
)
797 strcat (buf
, ", m32r");
799 /* start-sanitize-m32rx */
801 if ((e_flags
& EF_M32R_ARCH
) == E_M32RX_ARCH
)
802 strcat (buf
, ", m32rx");
804 /* end-sanitize-m32rx */
809 if (e_flags
& EF_MIPS_NOREORDER
)
810 strcat (buf
, ", noreorder");
812 if (e_flags
& EF_MIPS_PIC
)
813 strcat (buf
, ", pic");
815 if (e_flags
& EF_MIPS_CPIC
)
816 strcat (buf
, ", cpic");
818 if (e_flags
& EF_MIPS_ABI2
)
819 strcat (buf
, ", abi2");
821 if ((e_flags
& EF_MIPS_ARCH
) == E_MIPS_ARCH_1
)
822 strcat (buf
, ", mips1");
824 if ((e_flags
& EF_MIPS_ARCH
) == E_MIPS_ARCH_2
)
825 strcat (buf
, ", mips2");
827 if ((e_flags
& EF_MIPS_ARCH
) == E_MIPS_ARCH_3
)
828 strcat (buf
, ", mips3");
830 if ((e_flags
& EF_MIPS_ARCH
) == E_MIPS_ARCH_4
)
831 strcat (buf
, ", mips4");
840 get_machine_data (e_data
)
843 static char buff
[32];
847 case ELFDATA2LSB
: return _("ELFDATA2LSB (little endian)");
848 case ELFDATA2MSB
: return _("ELFDATA2MSB (big endian)");
850 sprintf (buff
, _("<unknown>: %x"), e_data
);
856 get_mips_segment_type (type
)
861 case PT_MIPS_REGINFO
:
865 case PT_MIPS_OPTIONS
:
875 get_segment_type (p_type
)
876 unsigned long p_type
;
878 static char buff
[32];
882 case PT_NULL
: return "NULL";
883 case PT_LOAD
: return "LOAD";
884 case PT_DYNAMIC
: return "DYNAMIC";
885 case PT_INTERP
: return "INTERP";
886 case PT_NOTE
: return "NOTE";
887 case PT_SHLIB
: return "SHLIB";
888 case PT_PHDR
: return "PHDR";
891 if ((p_type
>= PT_LOPROC
) && (p_type
<= PT_HIPROC
))
894 switch (elf_header
.e_machine
)
898 result
= get_mips_segment_type (p_type
);
906 sprintf (buff
, "LOPROC+%d", p_type
- PT_LOPROC
);
913 sprintf (buff
, _("<unknown>: %x"), p_type
);
920 get_mips_section_type_name (sh_type
)
921 unsigned int sh_type
;
925 case SHT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
926 case SHT_MIPS_MSYM
: return "MIPS_MSYM";
927 case SHT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
928 case SHT_MIPS_GPTAB
: return "MIPS_GPTAB";
929 case SHT_MIPS_UCODE
: return "MIPS_UCODE";
930 case SHT_MIPS_DEBUG
: return "MIPS_DEBUG";
931 case SHT_MIPS_REGINFO
: return "MIPS_REGINFO";
932 case SHT_MIPS_PACKAGE
: return "MIPS_PACKAGE";
933 case SHT_MIPS_PACKSYM
: return "MIPS_PACKSYM";
934 case SHT_MIPS_RELD
: return "MIPS_RELD";
935 case SHT_MIPS_IFACE
: return "MIPS_IFACE";
936 case SHT_MIPS_CONTENT
: return "MIPS_CONTENT";
937 case SHT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
938 case SHT_MIPS_SHDR
: return "MIPS_SHDR";
939 case SHT_MIPS_FDESC
: return "MIPS_FDESC";
940 case SHT_MIPS_EXTSYM
: return "MIPS_EXTSYM";
941 case SHT_MIPS_DENSE
: return "MIPS_DENSE";
942 case SHT_MIPS_PDESC
: return "MIPS_PDESC";
943 case SHT_MIPS_LOCSYM
: return "MIPS_LOCSYM";
944 case SHT_MIPS_AUXSYM
: return "MIPS_AUXSYM";
945 case SHT_MIPS_OPTSYM
: return "MIPS_OPTSYM";
946 case SHT_MIPS_LOCSTR
: return "MIPS_LOCSTR";
947 case SHT_MIPS_LINE
: return "MIPS_LINE";
948 case SHT_MIPS_RFDESC
: return "MIPS_RFDESC";
949 case SHT_MIPS_DELTASYM
: return "MIPS_DELTASYM";
950 case SHT_MIPS_DELTAINST
: return "MIPS_DELTAINST";
951 case SHT_MIPS_DELTACLASS
: return "MIPS_DELTACLASS";
952 case SHT_MIPS_DWARF
: return "MIPS_DWARF";
953 case SHT_MIPS_DELTADECL
: return "MIPS_DELTADECL";
954 case SHT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
955 case SHT_MIPS_EVENTS
: return "MIPS_EVENTS";
956 case SHT_MIPS_TRANSLATE
: return "MIPS_TRANSLATE";
957 case SHT_MIPS_PIXIE
: return "MIPS_PIXIE";
958 case SHT_MIPS_XLATE
: return "MIPS_XLATE";
959 case SHT_MIPS_XLATE_DEBUG
: return "MIPS_XLATE_DEBUG";
960 case SHT_MIPS_WHIRL
: return "MIPS_WHIRL";
961 case SHT_MIPS_EH_REGION
: return "MIPS_EH_REGION";
962 case SHT_MIPS_XLATE_OLD
: return "MIPS_XLATE_OLD";
963 case SHT_MIPS_PDR_EXCEPTION
: return "MIPS_PDR_EXCEPTION";
971 get_section_type_name (sh_type
)
972 unsigned int sh_type
;
974 static char buff
[32];
978 case SHT_NULL
: return "NULL";
979 case SHT_PROGBITS
: return "PROGBITS";
980 case SHT_SYMTAB
: return "SYMTAB";
981 case SHT_STRTAB
: return "STRTAB";
982 case SHT_RELA
: return "RELA";
983 case SHT_HASH
: return "HASH";
984 case SHT_DYNAMIC
: return "DYNAMIC";
985 case SHT_NOTE
: return "NOTE";
986 case SHT_NOBITS
: return "NOBITS";
987 case SHT_REL
: return "REL";
988 case SHT_SHLIB
: return "SHLIB";
989 case SHT_DYNSYM
: return "DYNSYM";
990 case SHT_GNU_verdef
: return "VERDEF";
991 case SHT_GNU_verneed
: return "VERNEED";
992 case SHT_GNU_versym
: return "VERSYM";
993 case 0x6ffffff0: return "VERSYM";
994 case 0x6ffffffc: return "VERDEF";
995 case 0x7ffffffd: return "AUXILIARY";
996 case 0x7fffffff: return "FILTER";
999 if ((sh_type
>= SHT_LOPROC
) && (sh_type
<= SHT_HIPROC
))
1003 switch (elf_header
.e_machine
)
1006 case EM_MIPS_RS4_BE
:
1007 result
= get_mips_section_type_name (sh_type
);
1016 sprintf (buff
, _("SHT_LOPROC+%d"), sh_type
- SHT_LOPROC
);
1021 else if ((sh_type
>= SHT_LOUSER
) && (sh_type
<= SHT_HIUSER
))
1022 sprintf (buff
, _("SHT_LOUSER+%d"), sh_type
- SHT_LOUSER
);
1024 sprintf (buff
, _("<unknown>: %x"), sh_type
);
1029 struct option options
[] =
1031 {"all", no_argument
, 0, 'a'},
1032 {"file-header", no_argument
, 0, 'h'},
1033 {"program-headers", no_argument
, 0, 'l'},
1034 {"headers", no_argument
, 0, 'e'},
1035 {"histogram", no_argument
, & do_histogram
, 1},
1036 {"segments", no_argument
, 0, 'l'},
1037 {"sections", no_argument
, 0, 'S'},
1038 {"section-headers", no_argument
, 0, 'S'},
1039 {"symbols", no_argument
, 0, 's'},
1040 {"syms", no_argument
, 0, 's'},
1041 {"relocs", no_argument
, 0, 'r'},
1042 {"dynamic", no_argument
, 0, 'd'},
1043 {"version-info", no_argument
, 0, 'V'},
1044 {"use-dynamic", no_argument
, 0, 'D'},
1045 {"hex-dump", required_argument
, 0, 'x'},
1046 {"debug-dump", optional_argument
, 0, 'w'},
1047 #ifdef SUPPORT_DISASSEMBLY
1048 {"instruction-dump", required_argument
, 0, 'i'},
1051 {"version", no_argument
, 0, 'v'},
1052 {"help", no_argument
, 0, 'H'},
1053 {0, no_argument
, 0, 0}
1059 fprintf (stdout
, _("Usage: readelf {options} elf-file(s)\n"));
1060 fprintf (stdout
, _(" Options are:\n"));
1061 fprintf (stdout
, _(" -a or --all Equivalent to: -h -l -S -s -r -d -V --histogram\n"));
1062 fprintf (stdout
, _(" -h or --file-header Display the ELF file header\n"));
1063 fprintf (stdout
, _(" -l or --program-headers or --segments\n"));
1064 fprintf (stdout
, _(" Display the program headers\n"));
1065 fprintf (stdout
, _(" -S or --section-headers or --sections\n"));
1066 fprintf (stdout
, _(" Display the sections' header\n"));
1067 fprintf (stdout
, _(" -e or --headers Equivalent to: -h -l -S\n"));
1068 fprintf (stdout
, _(" -s or --syms or --symbols Display the symbol table\n"));
1069 fprintf (stdout
, _(" -r or --relocs Display the relocations (if present)\n"));
1070 fprintf (stdout
, _(" -d or --dynamic Display the dynamic segment (if present)\n"));
1071 fprintf (stdout
, _(" -V or --version-info Display the version sections (if present)\n"));
1072 fprintf (stdout
, _(" -D or --use-dynamic Use the dynamic section info when displaying symbols\n"));
1073 fprintf (stdout
, _(" -x <number> or --hex-dump=<number>\n"));
1074 fprintf (stdout
, _(" Dump the contents of section <number>\n"));
1075 fprintf (stdout
, _(" -w[liapr] or --debug-dump[=line,=info,=abbrev,=pubnames,=ranges]\n"));
1076 fprintf (stdout
, _(" Display the contents of DWARF2 debug sections\n"));
1077 #ifdef SUPPORT_DISASSEMBLY
1078 fprintf (stdout
, _(" -i <number> or --instruction-dump=<number>\n"));
1079 fprintf (stdout
, _(" Disassemble the contents of section <number>\n"));
1081 fprintf (stdout
, _(" --histogram Display histogram of bucket list lengths\n"));
1082 fprintf (stdout
, _(" -v or --version Display the version number of readelf\n"));
1083 fprintf (stdout
, _(" -H or --help Display this information\n"));
1084 fprintf (stdout
, _("Report bugs to bug-gnu-utils@gnu.org\n"));
1090 parse_args (argc
, argv
)
1099 while ((c
= getopt_long
1100 (argc
, argv
, "ersahldSDw::x:i:vV", options
, NULL
)) != EOF
)
1130 do_using_dynamic
++;
1152 section
= strtoul (optarg
, & cp
, 0);
1153 if (! * cp
&& section
>= 0 && section
< NUM_DUMP_SECTS
)
1155 dump_sects
[section
] |= HEX_DUMP
;
1175 do_debug_abbrevs
= 1;
1185 do_debug_pubnames
= 1;
1190 do_debug_aranges
= 1;
1194 warn (_("Unrecognised debug option '%s'\n"), optarg
);
1199 #ifdef SUPPORT_DISASSEMBLY
1202 section
= strtoul (optarg
, & cp
, 0);
1203 if (! * cp
&& section
>= 0 && section
< NUM_DUMP_SECTS
)
1205 dump_sects
[section
] |= DISASS_DUMP
;
1211 print_version (program_name
);
1218 /* xgettext:c-format */
1219 error (_("Invalid option '-%c'\n"), c
);
1226 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_sections
1227 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
1228 && !do_histogram
&& !do_debugging
)
1232 warn (_("Nothing to do.\n"));
1237 /* Decode the data held in 'elf_header'. */
1239 process_file_header ()
1241 if ( elf_header
.e_ident
[EI_MAG0
] != ELFMAG0
1242 || elf_header
.e_ident
[EI_MAG1
] != ELFMAG1
1243 || elf_header
.e_ident
[EI_MAG2
] != ELFMAG2
1244 || elf_header
.e_ident
[EI_MAG3
] != ELFMAG3
)
1247 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
1251 binary_class
= elf_header
.e_ident
[EI_CLASS
];
1252 if (binary_class
!= ELFCLASS32
)
1254 error (_("Not a 32 bit ELF file\n"));
1262 printf (_("ELF Header:\n"));
1263 printf (_(" Magic: "));
1264 for (i
= 0; i
< EI_NIDENT
; i
++)
1265 printf ("%2.2x ", elf_header
.e_ident
[i
]);
1267 printf (_(" Type: %s\n"),
1268 get_file_type (elf_header
.e_type
));
1269 printf (_(" Machine: %s\n"),
1270 get_machine_name (elf_header
.e_machine
));
1271 printf (_(" Version: 0x%lx\n"),
1272 (unsigned long) elf_header
.e_version
);
1273 printf (_(" Data: %s\n"),
1274 get_machine_data (elf_header
.e_ident
[EI_DATA
]));
1275 printf (_(" Entry point address: 0x%lx\n"),
1276 (unsigned long) elf_header
.e_entry
);
1277 printf (_(" Start of program headers: %ld (bytes into file)\n"),
1278 (long) elf_header
.e_phoff
);
1279 printf (_(" Start of section headers: %ld (bytes into file)\n"),
1280 (long) elf_header
.e_shoff
);
1281 printf (_(" Flags: 0x%lx%s\n"),
1282 (unsigned long) elf_header
.e_flags
,
1283 get_machine_flags (elf_header
.e_flags
, elf_header
.e_machine
));
1284 printf (_(" Size of this header: %ld (bytes)\n"),
1285 (long) elf_header
.e_ehsize
);
1286 printf (_(" Size of program headers: %ld (bytes)\n"),
1287 (long) elf_header
.e_phentsize
);
1288 printf (_(" Number of program headers: %ld\n"),
1289 (long) elf_header
.e_phnum
);
1290 printf (_(" Size of section headers: %ld (bytes)\n"),
1291 (long) elf_header
.e_shentsize
);
1292 printf (_(" Number of section headers: %ld\n"),
1293 (long) elf_header
.e_shnum
);
1294 printf (_(" Section header string table index: %ld\n"),
1295 (long) elf_header
.e_shstrndx
);
1303 process_program_headers (file
)
1306 Elf32_External_Phdr
* phdrs
;
1307 Elf32_Internal_Phdr
* program_headers
;
1308 Elf32_Internal_Phdr
* segment
;
1311 if (elf_header
.e_phnum
== 0)
1314 printf (_("\nThere are no program headers in this file.\n"));
1318 if (do_segments
&& !do_header
)
1320 printf (_("\nElf file is %s\n"), get_file_type (elf_header
.e_type
));
1321 printf (_("Entry point 0x%lx\n"), (unsigned long) elf_header
.e_entry
);
1322 printf (_("There are %d program headers, starting at offset %lx:\n"),
1323 elf_header
.e_phnum
, (unsigned long) elf_header
.e_phoff
);
1326 GET_DATA_ALLOC (elf_header
.e_phoff
,
1327 elf_header
.e_phentsize
* elf_header
.e_phnum
,
1328 phdrs
, Elf32_External_Phdr
*, "program headers");
1330 program_headers
= (Elf32_Internal_Phdr
*) malloc
1331 (elf_header
.e_phnum
* sizeof (Elf32_Internal_Phdr
));
1333 if (program_headers
== NULL
)
1335 error (_("Out of memory\n"));
1339 for (i
= 0, segment
= program_headers
;
1340 i
< elf_header
.e_phnum
;
1343 segment
->p_type
= BYTE_GET (phdrs
[i
].p_type
);
1344 segment
->p_offset
= BYTE_GET (phdrs
[i
].p_offset
);
1345 segment
->p_vaddr
= BYTE_GET (phdrs
[i
].p_vaddr
);
1346 segment
->p_paddr
= BYTE_GET (phdrs
[i
].p_paddr
);
1347 segment
->p_filesz
= BYTE_GET (phdrs
[i
].p_filesz
);
1348 segment
->p_memsz
= BYTE_GET (phdrs
[i
].p_memsz
);
1349 segment
->p_flags
= BYTE_GET (phdrs
[i
].p_flags
);
1350 segment
->p_align
= BYTE_GET (phdrs
[i
].p_align
);
1358 (_("\nProgram Header%s:\n"), elf_header
.e_phnum
> 1 ? "s" : "");
1360 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
1366 for (i
= 0, segment
= program_headers
;
1367 i
< elf_header
.e_phnum
;
1372 printf (" %-11.11s ", get_segment_type (segment
->p_type
));
1373 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
1374 printf ("0x%8.8lx ", (unsigned long) segment
->p_vaddr
);
1375 printf ("0x%8.8lx ", (unsigned long) segment
->p_paddr
);
1376 printf ("0x%5.5lx ", (unsigned long) segment
->p_filesz
);
1377 printf ("0x%5.5lx ", (unsigned long) segment
->p_memsz
);
1379 (segment
->p_flags
& PF_R
? 'R' : ' '),
1380 (segment
->p_flags
& PF_W
? 'W' : ' '),
1381 (segment
->p_flags
& PF_X
? 'E' : ' '));
1382 printf ("%#lx", (unsigned long) segment
->p_align
);
1385 switch (segment
->p_type
)
1389 loadaddr
= (segment
->p_vaddr
& 0xfffff000)
1390 - (segment
->p_offset
& 0xfffff000);
1395 error (_("more than one dynamic segment\n"));
1397 dynamic_addr
= segment
->p_offset
;
1398 dynamic_size
= segment
->p_filesz
;
1402 if (fseek (file
, segment
->p_offset
, SEEK_SET
))
1403 error (_("Unable to find program interpreter name\n"));
1406 program_interpreter
[0] = 0;
1407 fscanf (file
, "%63s", program_interpreter
);
1410 printf (_("\n [Requesting program interpreter: %s]"),
1411 program_interpreter
);
1417 putc ('\n', stdout
);
1426 if (do_segments
&& section_headers
!= NULL
)
1428 printf (_("\n Section to Segment mapping:\n"));
1429 printf (_(" Segment Sections...\n"));
1431 assert (string_table
!= NULL
);
1433 for (i
= 0; i
< elf_header
.e_phnum
; i
++)
1436 Elf32_Internal_Shdr
* section
;
1438 segment
= program_headers
+ i
;
1439 section
= section_headers
;
1441 printf (" %2.2d ", i
);
1443 for (j
= 0; j
< elf_header
.e_shnum
; j
++, section
++)
1445 if (section
->sh_size
> 0
1446 /* Compare allocated sections by VMA, unallocated
1447 sections by file offset. */
1448 && (section
->sh_flags
& SHF_ALLOC
1449 ? (section
->sh_addr
>= segment
->p_vaddr
1450 && section
->sh_addr
+ section
->sh_size
1451 <= segment
->p_vaddr
+ segment
->p_memsz
)
1452 : (section
->sh_offset
>= segment
->p_offset
1453 && (section
->sh_offset
+ section
->sh_size
1454 <= segment
->p_offset
+ segment
->p_filesz
))))
1455 printf ("%s ", SECTION_NAME (section
));
1462 free (program_headers
);
1469 get_section_headers (file
)
1472 Elf32_External_Shdr
* shdrs
;
1473 Elf32_Internal_Shdr
* internal
;
1476 GET_DATA_ALLOC (elf_header
.e_shoff
,
1477 elf_header
.e_shentsize
* elf_header
.e_shnum
,
1478 shdrs
, Elf32_External_Shdr
*, "section headers");
1480 section_headers
= (Elf32_Internal_Shdr
*) malloc
1481 (elf_header
.e_shnum
* sizeof (Elf32_Internal_Shdr
));
1483 if (section_headers
== NULL
)
1485 error (_("Out of memory\n"));
1489 for (i
= 0, internal
= section_headers
;
1490 i
< elf_header
.e_shnum
;
1493 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
1494 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
1495 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
1496 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
1497 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
1498 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
1499 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
1500 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
1501 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
1502 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
1510 static Elf_Internal_Sym
*
1511 get_elf_symbols (file
, offset
, number
)
1513 unsigned long offset
;
1514 unsigned long number
;
1516 Elf32_External_Sym
* esyms
;
1517 Elf_Internal_Sym
* isyms
;
1518 Elf_Internal_Sym
* psym
;
1521 GET_DATA_ALLOC (offset
, number
* sizeof (Elf32_External_Sym
),
1522 esyms
, Elf32_External_Sym
*, "symbols");
1524 isyms
= (Elf_Internal_Sym
*) malloc (number
* sizeof (Elf_Internal_Sym
));
1528 error (_("Out of memory\n"));
1534 for (j
= 0, psym
= isyms
;
1538 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
1539 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
1540 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
1541 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
1542 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
1543 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
1552 process_section_headers (file
)
1555 Elf32_Internal_Shdr
* section
;
1558 section_headers
= NULL
;
1560 if (elf_header
.e_shnum
== 0)
1563 printf (_("\nThere are no sections in this file.\n"));
1568 if (do_sections
&& !do_header
)
1569 printf (_("There are %d section headers, starting at offset %x:\n"),
1570 elf_header
.e_shnum
, elf_header
.e_shoff
);
1572 if (! get_section_headers (file
))
1575 /* Read in the string table, so that we have names to display. */
1576 section
= section_headers
+ elf_header
.e_shstrndx
;
1578 if (section
->sh_size
!= 0)
1580 unsigned long string_table_offset
;
1582 string_table_offset
= section
->sh_offset
;
1584 GET_DATA_ALLOC (section
->sh_offset
, section
->sh_size
,
1585 string_table
, char *, "string table");
1588 /* Scan the sections for the dynamic symbol table
1589 and dynamic string table and debug sections. */
1590 dynamic_symbols
= NULL
;
1591 dynamic_strings
= NULL
;
1592 dynamic_syminfo
= NULL
;
1593 for (i
= 0, section
= section_headers
;
1594 i
< elf_header
.e_shnum
;
1597 char * name
= SECTION_NAME (section
);
1599 if (section
->sh_type
== SHT_DYNSYM
)
1601 if (dynamic_symbols
!= NULL
)
1603 error (_("File contains multiple dynamic symbol tables\n"));
1607 dynamic_symbols
= get_elf_symbols
1608 (file
, section
->sh_offset
,
1609 section
->sh_size
/ section
->sh_entsize
);
1611 else if (section
->sh_type
== SHT_STRTAB
1612 && strcmp (name
, ".dynstr") == 0)
1614 if (dynamic_strings
!= NULL
)
1616 error (_("File contains multiple dynamic string tables\n"));
1620 GET_DATA_ALLOC (section
->sh_offset
, section
->sh_size
,
1621 dynamic_strings
, char *, "dynamic strings");
1623 else if ((do_debugging
|| do_debug_info
|| do_debug_abbrevs
1624 || do_debug_lines
|| do_debug_pubnames
|| do_debug_aranges
)
1625 && strncmp (name
, ".debug_", 7) == 0)
1630 || (do_debug_info
&& (strcmp (name
, "info") == 0))
1631 || (do_debug_abbrevs
&& (strcmp (name
, "abbrev") == 0))
1632 || (do_debug_lines
&& (strcmp (name
, "line") == 0))
1633 || (do_debug_pubnames
&& (strcmp (name
, "pubnames") == 0))
1634 || (do_debug_aranges
&& (strcmp (name
, "aranges") == 0))
1636 dump_sects
[i
] |= DEBUG_DUMP
;
1643 printf (_("\nSection Header%s:\n"), elf_header
.e_shnum
> 1 ? "s" : "");
1645 (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
1647 for (i
= 0, section
= section_headers
;
1648 i
< elf_header
.e_shnum
;
1651 printf (" [%2d] %-17.17s %-15.15s ",
1653 SECTION_NAME (section
),
1654 get_section_type_name (section
->sh_type
));
1656 printf ( "%8.8lx %6.6lx %6.6lx %2.2lx",
1657 (unsigned long) section
->sh_addr
,
1658 (unsigned long) section
->sh_offset
,
1659 (unsigned long) section
->sh_size
,
1660 (unsigned long) section
->sh_entsize
);
1662 printf (" %c%c%c %2ld %3lx %ld\n",
1663 (section
->sh_flags
& SHF_WRITE
? 'W' : ' '),
1664 (section
->sh_flags
& SHF_ALLOC
? 'A' : ' '),
1665 (section
->sh_flags
& SHF_EXECINSTR
? 'X' : ' '),
1666 (unsigned long) section
->sh_link
,
1667 (unsigned long) section
->sh_info
,
1668 (unsigned long) section
->sh_addralign
);
1674 /* Process the reloc section. */
1676 process_relocs (file
)
1679 unsigned long rel_size
;
1680 unsigned long rel_offset
;
1686 if (do_using_dynamic
)
1691 if (dynamic_info
[DT_REL
])
1693 rel_offset
= dynamic_info
[DT_REL
];
1694 rel_size
= dynamic_info
[DT_RELSZ
];
1696 else if (dynamic_info
[DT_RELA
])
1698 rel_offset
= dynamic_info
[DT_RELA
];
1699 rel_size
= dynamic_info
[DT_RELASZ
];
1701 else if (dynamic_info
[DT_JMPREL
])
1703 rel_offset
= dynamic_info
[DT_JMPREL
];
1704 rel_size
= dynamic_info
[DT_PLTRELSZ
];
1710 (_("\nRelocation section at offset 0x%x contains %d bytes:\n"),
1711 rel_offset
, rel_size
);
1713 dump_relocations (file
, rel_offset
- loadaddr
, rel_size
,
1714 dynamic_symbols
, dynamic_strings
);
1717 printf (_("\nThere are no dynamic relocations in this file.\n"));
1721 Elf32_Internal_Shdr
* section
;
1725 for (i
= 0, section
= section_headers
;
1726 i
< elf_header
.e_shnum
;
1729 if ( section
->sh_type
!= SHT_RELA
1730 && section
->sh_type
!= SHT_REL
)
1733 rel_offset
= section
->sh_offset
;
1734 rel_size
= section
->sh_size
;
1738 Elf32_Internal_Shdr
* strsec
;
1739 Elf32_Internal_Shdr
* symsec
;
1740 Elf_Internal_Sym
* symtab
;
1743 printf (_("\nRelocation section "));
1745 if (string_table
== NULL
)
1746 printf ("%d", section
->sh_name
);
1748 printf ("'%s'", SECTION_NAME (section
));
1750 printf (_(" at offset 0x%x contains %d entries:\n"),
1751 rel_offset
, rel_size
/ section
->sh_entsize
);
1753 symsec
= section_headers
+ section
->sh_link
;
1755 symtab
= get_elf_symbols (file
, symsec
->sh_offset
,
1756 symsec
->sh_size
/ symsec
->sh_entsize
);
1761 strsec
= section_headers
+ symsec
->sh_link
;
1763 GET_DATA_ALLOC (strsec
->sh_offset
, strsec
->sh_size
, strtab
,
1764 char *, "string table");
1766 dump_relocations (file
, rel_offset
, rel_size
, symtab
, strtab
);
1776 printf (_("\nThere are no relocations in this file.\n"));
1784 dynamic_segment_mips_val (entry
)
1785 Elf_Internal_Dyn
*entry
;
1788 switch (entry
->d_tag
)
1791 if (entry
->d_un
.d_val
== 0)
1795 static const char *opts
[] =
1797 "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT",
1798 "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS",
1799 "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD",
1800 "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF",
1805 for (cnt
= 0; cnt
< sizeof (opts
) / sizeof (opts
[0]); ++cnt
)
1806 if (entry
->d_un
.d_val
& (1 << cnt
))
1808 printf ("%s%s", first
? "" : " ", opts
[cnt
]);
1815 case DT_MIPS_IVERSION
:
1816 if (dynamic_strings
!= NULL
)
1817 printf ("Interface Version: %s\n",
1818 dynamic_strings
+ entry
->d_un
.d_val
);
1820 printf ("%#ld\n", (long) entry
->d_un
.d_ptr
);
1823 case DT_MIPS_TIME_STAMP
:
1826 time_t time
= entry
->d_un
.d_val
;
1827 strftime (timebuf
, 20, "%Y-%m-%dT%H:%M:%S", gmtime (&time
));
1828 printf ("Time Stamp: %s\n", timebuf
);
1832 case DT_MIPS_RLD_VERSION
:
1833 case DT_MIPS_LOCAL_GOTNO
:
1834 case DT_MIPS_CONFLICTNO
:
1835 case DT_MIPS_LIBLISTNO
:
1836 case DT_MIPS_SYMTABNO
:
1837 case DT_MIPS_UNREFEXTNO
:
1838 case DT_MIPS_HIPAGENO
:
1839 case DT_MIPS_DELTA_CLASS_NO
:
1840 case DT_MIPS_DELTA_INSTANCE_NO
:
1841 case DT_MIPS_DELTA_RELOC_NO
:
1842 case DT_MIPS_DELTA_SYM_NO
:
1843 case DT_MIPS_DELTA_CLASSSYM_NO
:
1844 case DT_MIPS_COMPACT_SIZE
:
1845 printf ("%#ld\n", (long) entry
->d_un
.d_ptr
);
1849 printf ("%#lx\n", (long) entry
->d_un
.d_ptr
);
1853 /* Parse the dynamic segment */
1855 process_dynamic_segment (file
)
1858 Elf_Internal_Dyn
* entry
;
1859 Elf32_External_Dyn
* edyn
;
1862 if (dynamic_size
== 0)
1865 printf (_("\nThere is no dynamic segment in this file.\n"));
1870 GET_DATA_ALLOC (dynamic_addr
, dynamic_size
,
1871 edyn
, Elf32_External_Dyn
*, "dynamic segment");
1873 /* SGI's ELF has more than one section in the DYNAMIC segment. Determine
1874 how large .dynamic is now. We can do this even before the byte
1875 swapping since the DT_NULL tag is recognizable. */
1877 while (*(Elf32_Word
*) edyn
[dynamic_size
++].d_tag
!= DT_NULL
)
1880 dynamic_segment
= (Elf_Internal_Dyn
*)
1881 malloc (dynamic_size
* sizeof (Elf_Internal_Dyn
));
1883 if (dynamic_segment
== NULL
)
1885 error (_("Out of memory\n"));
1890 for (i
= 0, entry
= dynamic_segment
;
1894 entry
->d_tag
= BYTE_GET (edyn
[i
].d_tag
);
1895 entry
->d_un
.d_val
= BYTE_GET (edyn
[i
].d_un
.d_val
);
1900 /* Find the appropriate symbol table. */
1901 if (dynamic_symbols
== NULL
)
1903 for (i
= 0, entry
= dynamic_segment
;
1907 unsigned long offset
;
1910 if (entry
->d_tag
!= DT_SYMTAB
)
1913 dynamic_info
[DT_SYMTAB
] = entry
->d_un
.d_val
;
1915 /* Since we do not know how big the symbol table is,
1916 we default to reading in the entire file (!) and
1917 processing that. This is overkill, I know, but it
1920 offset
= entry
->d_un
.d_val
- loadaddr
;
1922 if (fseek (file
, 0, SEEK_END
))
1923 error (_("Unable to seek to end of file!"));
1925 num_syms
= (ftell (file
) - offset
) / sizeof (Elf32_External_Sym
);
1929 error (_("Unable to determine the number of symbols to load\n"));
1933 dynamic_symbols
= get_elf_symbols (file
, offset
, num_syms
);
1937 /* Similarly find a string table. */
1938 if (dynamic_strings
== NULL
)
1940 for (i
= 0, entry
= dynamic_segment
;
1944 unsigned long offset
;
1947 if (entry
->d_tag
!= DT_STRTAB
)
1950 dynamic_info
[DT_STRTAB
] = entry
->d_un
.d_val
;
1952 /* Since we do not know how big the string table is,
1953 we default to reading in the entire file (!) and
1954 processing that. This is overkill, I know, but it
1957 offset
= entry
->d_un
.d_val
- loadaddr
;
1958 if (fseek (file
, 0, SEEK_END
))
1959 error (_("Unable to seek to end of file\n"));
1960 str_tab_len
= ftell (file
) - offset
;
1962 if (str_tab_len
< 1)
1965 (_("Unable to determine the length of the dynamic string table\n"));
1969 GET_DATA_ALLOC (offset
, str_tab_len
, dynamic_strings
, char *,
1970 "dynamic string table");
1976 /* And find the syminfo section if available. */
1977 if (dynamic_syminfo
== NULL
)
1979 unsigned int syminsz
= 0;
1981 for (i
= 0, entry
= dynamic_segment
;
1985 if (entry
->d_tag
== DT_SYMINENT
)
1986 assert (sizeof (Elf_External_Syminfo
) == entry
->d_un
.d_val
);
1987 else if (entry
->d_tag
== DT_SYMINSZ
)
1988 syminsz
= entry
->d_un
.d_val
;
1989 else if (entry
->d_tag
== DT_SYMINFO
)
1990 dynamic_syminfo_offset
= entry
->d_un
.d_val
- loadaddr
;
1993 if (dynamic_syminfo_offset
!= 0 && syminsz
!= 0)
1995 Elf_External_Syminfo
*extsyminfo
;
1996 Elf_Internal_Syminfo
*syminfo
;
1998 /* There is a syminfo section. Read the data. */
1999 GET_DATA_ALLOC (dynamic_syminfo_offset
, syminsz
, extsyminfo
,
2000 Elf_External_Syminfo
*, "symbol information");
2002 dynamic_syminfo
= (Elf_Internal_Syminfo
*) malloc (syminsz
);
2003 if (dynamic_syminfo
== NULL
)
2005 error (_("Out of memory\n"));
2009 dynamic_syminfo_nent
= syminsz
/ sizeof (Elf_External_Syminfo
);
2010 for (i
= 0, syminfo
= dynamic_syminfo
; i
< dynamic_syminfo_nent
;
2013 syminfo
->si_boundto
= BYTE_GET (extsyminfo
[i
].si_boundto
);
2014 syminfo
->si_flags
= BYTE_GET (extsyminfo
[i
].si_flags
);
2021 if (do_dynamic
&& dynamic_addr
)
2022 printf (_("\nDynamic segment at offset 0x%x contains %d entries:\n"),
2023 dynamic_addr
, dynamic_size
);
2025 printf (_(" Tag Type Name/Value\n"));
2027 for (i
= 0, entry
= dynamic_segment
;
2032 printf (_(" 0x%-8.8lx (%s)%*s"),
2033 (unsigned long) entry
->d_tag
,
2034 get_dynamic_type (entry
->d_tag
),
2035 27 - strlen (get_dynamic_type (entry
->d_tag
)),
2038 switch (entry
->d_tag
)
2044 if (entry
->d_tag
== DT_AUXILIARY
)
2045 printf (_("Auxiliary library"));
2047 printf (_("Filter library"));
2049 if (dynamic_strings
)
2050 printf (": [%s]\n", dynamic_strings
+ entry
->d_un
.d_val
);
2052 printf (": %#lx\n", (long) entry
->d_un
.d_val
);
2059 printf (_("Flags:"));
2060 if (entry
->d_un
.d_val
== 0)
2061 printf (_(" None\n"));
2064 if (entry
->d_un
.d_val
& DF_P1_LAZYLOAD
)
2065 printf (" LAZYLOAD");
2066 if (entry
->d_un
.d_val
& DF_P1_LAZYLOAD
)
2067 printf (" GROUPPERM");
2076 printf (_("Flags:"));
2077 if (entry
->d_un
.d_val
== 0)
2078 printf (_(" None\n"));
2081 if (entry
->d_un
.d_val
& DF_1_NOW
)
2083 if (entry
->d_un
.d_val
& DF_1_GLOBAL
)
2085 if (entry
->d_un
.d_val
& DF_1_GROUP
)
2087 if (entry
->d_un
.d_val
& DF_1_NODELETE
)
2088 printf (" NODELETE");
2089 if (entry
->d_un
.d_val
& DF_1_LOADFLTR
)
2090 printf (" LOADFLTR");
2091 if (entry
->d_un
.d_val
& DF_1_INITFIRST
)
2092 printf (" INITFIRST");
2093 if (entry
->d_un
.d_val
& DF_1_NOOPEN
)
2095 if (entry
->d_un
.d_val
& DF_1_ORIGIN
)
2097 if (entry
->d_un
.d_val
& DF_1_DIRECT
)
2099 if (entry
->d_un
.d_val
& DF_1_TRANS
)
2101 if (entry
->d_un
.d_val
& DF_1_INTERPOSE
)
2102 printf (" INTERPOSE");
2109 puts (get_dynamic_type (entry
->d_un
.d_val
));
2128 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
2134 if (dynamic_strings
== NULL
)
2137 name
= dynamic_strings
+ entry
->d_un
.d_val
;
2141 switch (entry
->d_tag
)
2144 printf (_("Shared library: [%s]"), name
);
2146 if (strcmp (name
, program_interpreter
))
2149 printf (_(" program interpreter\n"));
2153 printf (_("Library soname: [%s]\n"), name
);
2157 printf (_("Library rpath: [%s]\n"), name
);
2161 printf ("%#lx\n", (long) entry
->d_un
.d_val
);
2165 printf ("%#lx\n", (long) entry
->d_un
.d_val
);
2177 printf ("%ld (bytes)\n", entry
->d_un
.d_val
);
2185 printf ("%ld\n", entry
->d_un
.d_val
);
2196 if (dynamic_strings
== NULL
)
2199 name
= dynamic_strings
+ entry
->d_un
.d_val
;
2205 switch (entry
->d_tag
)
2208 printf (_("Not needed object: [%s]\n"), name
);
2212 printf ("%#lx\n", (long) entry
->d_un
.d_val
);
2216 printf ("%#lx\n", (long) entry
->d_un
.d_val
);
2221 if ((entry
->d_tag
>= DT_VERSYM
) && (entry
->d_tag
<= DT_VERNEEDNUM
))
2223 version_info
[DT_VERSIONTAGIDX (entry
->d_tag
)] =
2227 printf ("%#lx\n", (long) entry
->d_un
.d_ptr
);
2230 switch (elf_header
.e_machine
)
2233 case EM_MIPS_RS4_BE
:
2234 dynamic_segment_mips_val (entry
);
2238 printf ("%#lx\n", (long) entry
->d_un
.d_ptr
);
2248 get_ver_flags (flags
)
2251 static char buff
[32];
2258 if (flags
& VER_FLG_BASE
)
2259 strcat (buff
, "BASE ");
2261 if (flags
& VER_FLG_WEAK
)
2263 if (flags
& VER_FLG_BASE
)
2264 strcat (buff
, "| ");
2266 strcat (buff
, "WEAK ");
2269 if (flags
& ~(VER_FLG_BASE
| VER_FLG_WEAK
))
2270 strcat (buff
, "| <unknown>");
2275 /* Display the contents of the version sections. */
2277 process_version_sections (file
)
2280 Elf32_Internal_Shdr
* section
;
2287 for (i
= 0, section
= section_headers
;
2288 i
< elf_header
.e_shnum
;
2291 switch (section
->sh_type
)
2293 case SHT_GNU_verdef
:
2295 Elf_External_Verdef
* edefs
;
2302 (_("\nVersion definition section '%s' contains %d entries:\n"),
2303 SECTION_NAME (section
), section
->sh_info
);
2305 printf (_(" Addr: %#08x Offset: %#08x Link: %x (%s)\n"),
2306 section
->sh_addr
, section
->sh_offset
, section
->sh_link
,
2307 SECTION_NAME (section_headers
+ section
->sh_link
));
2309 GET_DATA_ALLOC (section
->sh_offset
, section
->sh_size
,
2310 edefs
, Elf_External_Verdef
*,
2311 "version definition section");
2313 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++ cnt
)
2316 Elf_External_Verdef
* edef
;
2317 Elf_Internal_Verdef ent
;
2318 Elf_External_Verdaux
* eaux
;
2319 Elf_Internal_Verdaux aux
;
2323 vstart
= ((char *) edefs
) + idx
;
2325 edef
= (Elf_External_Verdef
*) vstart
;
2327 ent
.vd_version
= BYTE_GET (edef
->vd_version
);
2328 ent
.vd_flags
= BYTE_GET (edef
->vd_flags
);
2329 ent
.vd_ndx
= BYTE_GET (edef
->vd_ndx
);
2330 ent
.vd_cnt
= BYTE_GET (edef
->vd_cnt
);
2331 ent
.vd_hash
= BYTE_GET (edef
->vd_hash
);
2332 ent
.vd_aux
= BYTE_GET (edef
->vd_aux
);
2333 ent
.vd_next
= BYTE_GET (edef
->vd_next
);
2335 printf (_(" %#06x: Rev: %d Flags: %s"),
2336 idx
, ent
.vd_version
, get_ver_flags (ent
.vd_flags
));
2338 printf (_(" Index: %ld Cnt: %ld "),
2339 ent
.vd_ndx
, ent
.vd_cnt
);
2341 vstart
+= ent
.vd_aux
;
2343 eaux
= (Elf_External_Verdaux
*) vstart
;
2345 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
2346 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
2348 if (dynamic_strings
)
2349 printf (_("Name: %s\n"), dynamic_strings
+ aux
.vda_name
);
2351 printf (_("Name index: %ld\n"), aux
.vda_name
);
2353 isum
= idx
+ ent
.vd_aux
;
2355 for (j
= 1; j
< ent
.vd_cnt
; j
++)
2357 isum
+= aux
.vda_next
;
2358 vstart
+= aux
.vda_next
;
2360 eaux
= (Elf_External_Verdaux
*) vstart
;
2362 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
2363 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
2365 if (dynamic_strings
)
2366 printf (_(" %#06x: Parent %d: %s\n"),
2367 isum
, j
, dynamic_strings
+ aux
.vda_name
);
2369 printf (_(" %#06x: Parent %d, name index: %ld\n"),
2370 isum
, j
, aux
.vda_name
);
2380 case SHT_GNU_verneed
:
2382 Elf_External_Verneed
* eneed
;
2388 printf (_("\nVersion needs section '%s' contains %d entries:\n"),
2389 SECTION_NAME (section
), section
->sh_info
);
2392 (_(" Addr: %#08x Offset: %#08x Link to section: %d (%s)\n"),
2393 section
->sh_addr
, section
->sh_offset
, section
->sh_link
,
2394 SECTION_NAME (section_headers
+ section
->sh_link
));
2396 GET_DATA_ALLOC (section
->sh_offset
, section
->sh_size
,
2397 eneed
, Elf_External_Verneed
*,
2398 "version need section");
2400 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
2402 Elf_External_Verneed
* entry
;
2403 Elf_Internal_Verneed ent
;
2408 vstart
= ((char *) eneed
) + idx
;
2410 entry
= (Elf_External_Verneed
*) vstart
;
2412 ent
.vn_version
= BYTE_GET (entry
->vn_version
);
2413 ent
.vn_cnt
= BYTE_GET (entry
->vn_cnt
);
2414 ent
.vn_file
= BYTE_GET (entry
->vn_file
);
2415 ent
.vn_aux
= BYTE_GET (entry
->vn_aux
);
2416 ent
.vn_next
= BYTE_GET (entry
->vn_next
);
2418 printf (_(" %#06x: Version: %d"), idx
, ent
.vn_version
);
2420 if (dynamic_strings
)
2421 printf (_(" File: %s"), dynamic_strings
+ ent
.vn_file
);
2423 printf (_(" File: %lx"), ent
.vn_file
);
2425 printf (_(" Cnt: %d\n"), ent
.vn_cnt
);
2427 vstart
+= ent
.vn_aux
;
2429 for (j
= 0, isum
= idx
+ ent
.vn_aux
; j
< ent
.vn_cnt
; ++j
)
2431 Elf_External_Vernaux
* eaux
;
2432 Elf_Internal_Vernaux aux
;
2434 eaux
= (Elf_External_Vernaux
*) vstart
;
2436 aux
.vna_hash
= BYTE_GET (eaux
->vna_hash
);
2437 aux
.vna_flags
= BYTE_GET (eaux
->vna_flags
);
2438 aux
.vna_other
= BYTE_GET (eaux
->vna_other
);
2439 aux
.vna_name
= BYTE_GET (eaux
->vna_name
);
2440 aux
.vna_next
= BYTE_GET (eaux
->vna_next
);
2442 if (dynamic_strings
)
2443 printf (_(" %#06x: Name: %s"),
2444 isum
, dynamic_strings
+ aux
.vna_name
);
2446 printf (_(" %#06x: Name index: %lx"),
2447 isum
, aux
.vna_name
);
2449 printf (_(" Flags: %s Version: %d\n"),
2450 get_ver_flags (aux
.vna_flags
), aux
.vna_other
);
2452 isum
+= aux
.vna_next
;
2453 vstart
+= aux
.vna_next
;
2463 case SHT_GNU_versym
:
2465 Elf32_Internal_Shdr
* link_section
;
2468 unsigned char * edata
;
2469 unsigned short * data
;
2471 Elf_Internal_Sym
* symbols
;
2472 Elf32_Internal_Shdr
* string_sec
;
2474 link_section
= section_headers
+ section
->sh_link
;
2475 total
= section
->sh_size
/ section
->sh_entsize
;
2479 symbols
= get_elf_symbols
2480 (file
, link_section
->sh_offset
,
2481 link_section
->sh_size
/ link_section
->sh_entsize
);
2483 string_sec
= section_headers
+ link_section
->sh_link
;
2485 GET_DATA_ALLOC (string_sec
->sh_offset
, string_sec
->sh_size
,
2486 strtab
, char *, "version string table");
2488 printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
2489 SECTION_NAME (section
), total
);
2491 printf (_(" Addr: %#08x Offset: %#08x Link: %x (%s)\n"),
2492 section
->sh_addr
, section
->sh_offset
, section
->sh_link
,
2493 SECTION_NAME (link_section
));
2495 GET_DATA_ALLOC (version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)]
2497 total
* sizeof (short), edata
,
2498 char *, "version symbol data");
2500 data
= (unsigned short *) malloc (total
* sizeof (short));
2502 for (cnt
= total
; cnt
--;)
2503 data
[cnt
] = byte_get (edata
+ cnt
* sizeof (short),
2508 for (cnt
= 0; cnt
< total
; cnt
+= 4)
2512 printf (" %03x:", cnt
);
2514 for (j
= 0; (j
< 4) && (cnt
+ j
) < total
; ++j
)
2515 switch (data
[cnt
+ j
])
2518 fputs (_(" 0 (*local*) "), stdout
);
2522 fputs (_(" 1 (*global*) "), stdout
);
2526 nn
= printf ("%4x%c", data
[cnt
+ j
] & 0x7fff,
2527 data
[cnt
+ j
] & 0x8000 ? 'h' : ' ');
2529 if (symbols
[cnt
+ j
].st_shndx
< SHN_LORESERVE
2530 && section_headers
[symbols
[cnt
+ j
].st_shndx
].sh_type
2533 /* We must test both. */
2534 Elf_Internal_Verneed ivn
;
2535 unsigned long offset
;
2537 offset
= version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
2542 Elf_External_Verneed evn
;
2543 Elf_External_Vernaux evna
;
2544 Elf_Internal_Vernaux ivna
;
2545 unsigned long vna_off
;
2547 GET_DATA (offset
, evn
, "version need");
2549 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
2550 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
2552 vna_off
= offset
+ ivn
.vn_aux
;
2556 GET_DATA (vna_off
, evna
,
2557 "version need aux (1)");
2559 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
2560 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
2562 vna_off
+= ivna
.vna_next
;
2564 while (ivna
.vna_other
!= data
[cnt
+ j
]
2565 && ivna
.vna_next
!= 0);
2567 if (ivna
.vna_other
== data
[cnt
+ j
])
2569 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
2571 nn
+= printf ("(%s%-*s",
2572 strtab
+ ivna
.vna_name
,
2578 else if (ivn
.vn_next
== 0)
2580 if (data
[cnt
+ j
] != 0x8001)
2582 Elf_Internal_Verdef ivd
;
2583 Elf_External_Verdef evd
;
2585 offset
= version_info
2586 [DT_VERSIONTAGIDX (DT_VERDEF
)]
2591 GET_DATA (offset
, evd
,
2592 "version definition");
2594 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
2595 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
2597 offset
+= ivd
.vd_next
;
2600 != (data
[cnt
+ j
] & 0x7fff)
2601 && ivd
.vd_next
!= 0);
2604 == (data
[cnt
+ j
] & 0x7fff))
2606 Elf_External_Verdaux evda
;
2607 Elf_Internal_Verdaux ivda
;
2609 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
2611 GET_DATA (offset
+ ivd
.vd_aux
, evda
,
2612 "version definition aux");
2615 BYTE_GET (evda
.vda_name
);
2619 strtab
+ ivda
.vda_name
,
2630 offset
+= ivn
.vn_next
;
2632 while (ivn
.vn_next
);
2634 else if (symbols
[cnt
+ j
].st_shndx
== SHN_UNDEF
)
2636 Elf_Internal_Verneed ivn
;
2637 unsigned long offset
;
2639 offset
= version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
2644 Elf_Internal_Vernaux ivna
;
2645 Elf_External_Verneed evn
;
2646 Elf_External_Vernaux evna
;
2647 unsigned long a_off
;
2649 GET_DATA (offset
, evn
, "version need");
2651 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
2652 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
2654 a_off
= offset
+ ivn
.vn_aux
;
2658 GET_DATA (a_off
, evna
,
2659 "version need aux (2)");
2661 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
2662 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
2664 a_off
+= ivna
.vna_next
;
2666 while (ivna
.vna_other
!= data
[cnt
+ j
]
2667 && ivna
.vna_next
!= 0);
2669 if (ivna
.vna_other
== data
[cnt
+ j
])
2671 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
2673 nn
+= printf ("(%s%-*s",
2674 strtab
+ ivna
.vna_name
,
2681 offset
+= ivn
.vn_next
;
2683 while (ivn
.vn_next
);
2685 else if (data
[cnt
+ j
] != 0x8001)
2687 Elf_Internal_Verdef ivd
;
2688 Elf_External_Verdef evd
;
2689 unsigned long offset
;
2691 offset
= version_info
2692 [DT_VERSIONTAGIDX (DT_VERDEF
)] - loadaddr
;
2696 GET_DATA (offset
, evd
, "version def");
2698 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
2699 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
2701 offset
+= ivd
.vd_next
;
2703 while (ivd
.vd_ndx
!= (data
[cnt
+ j
] & 0x7fff)
2704 && ivd
.vd_next
!= 0);
2706 if (ivd
.vd_ndx
== (data
[cnt
+ j
] & 0x7fff))
2708 Elf_External_Verdaux evda
;
2709 Elf_Internal_Verdaux ivda
;
2711 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
2713 GET_DATA (offset
- ivd
.vd_next
+ ivd
.vd_aux
,
2714 evda
, "version def aux");
2716 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
2718 nn
+= printf ("(%s%-*s",
2719 strtab
+ ivda
.vda_name
,
2727 printf ("%*c", 18 - nn
, ' ');
2745 printf (_("\nNo version information found in this file.\n"));
2751 get_symbol_binding (binding
)
2752 unsigned int binding
;
2754 static char buff
[32];
2758 case STB_LOCAL
: return _("LOCAL");
2759 case STB_GLOBAL
: return _("GLOBAL");
2760 case STB_WEAK
: return _("WEAK");
2762 if (binding
>= STB_LOPROC
&& binding
<= STB_HIPROC
)
2763 sprintf (buff
, _("<processor specific>: %d"), binding
);
2765 sprintf (buff
, _("<unknown>: %d"), binding
);
2771 get_symbol_type (type
)
2774 static char buff
[32];
2778 case STT_NOTYPE
: return _("NOTYPE");
2779 case STT_OBJECT
: return _("OBJECT");
2780 case STT_FUNC
: return _("FUNC");
2781 case STT_SECTION
: return _("SECTION");
2782 case STT_FILE
: return _("FILE");
2784 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
2785 sprintf (buff
, _("<processor specific>: %d"), type
);
2787 sprintf (buff
, _("<unknown>: %d"), type
);
2793 get_symbol_index_type (type
)
2798 case SHN_UNDEF
: return "UND";
2799 case SHN_ABS
: return "ABS";
2800 case SHN_COMMON
: return "COM";
2802 if (type
>= SHN_LOPROC
&& type
<= SHN_HIPROC
)
2804 else if (type
>= SHN_LORESERVE
&& type
<= SHN_HIRESERVE
)
2808 static char buff
[32];
2810 sprintf (buff
, "%3d", type
);
2818 get_dynamic_data (file
, number
)
2820 unsigned int number
;
2825 e_data
= (char *) malloc (number
* 4);
2829 error (_("Out of memory\n"));
2833 if (fread (e_data
, 4, number
, file
) != number
)
2835 error (_("Unable to read in dynamic data\n"));
2839 i_data
= (int *) malloc (number
* sizeof (* i_data
));
2843 error (_("Out of memory\n"));
2849 i_data
[number
] = byte_get (e_data
+ number
* 4, 4);
2856 /* Dump the symbol table */
2858 process_symbol_table (file
)
2861 Elf32_Internal_Shdr
* section
;
2866 int * buckets
= NULL
;
2867 int * chains
= NULL
;
2869 if (! do_syms
&& !do_histogram
)
2872 if (dynamic_info
[DT_HASH
] && ((do_using_dynamic
&& dynamic_strings
!= NULL
)
2875 if (fseek (file
, dynamic_info
[DT_HASH
] - loadaddr
, SEEK_SET
))
2877 error (_("Unable to seek to start of dynamic information"));
2881 if (fread (& nb
, sizeof (nb
), 1, file
) != 1)
2883 error (_("Failed to read in number of buckets\n"));
2887 if (fread (& nc
, sizeof (nc
), 1, file
) != 1)
2889 error (_("Failed to read in number of chains\n"));
2893 nbuckets
= byte_get (nb
, 4);
2894 nchains
= byte_get (nc
, 4);
2896 buckets
= get_dynamic_data (file
, nbuckets
);
2897 chains
= get_dynamic_data (file
, nchains
);
2899 if (buckets
== NULL
|| chains
== NULL
)
2904 && dynamic_info
[DT_HASH
] && do_using_dynamic
&& dynamic_strings
!= NULL
)
2909 printf (_("\nSymbol table for image:\n"));
2910 printf (_(" Num Buc: Value Size Type Bind Ot Ndx Name\n"));
2912 for (hn
= 0; hn
< nbuckets
; hn
++)
2917 for (si
= buckets
[hn
]; si
; si
= chains
[si
])
2919 Elf_Internal_Sym
* psym
;
2921 psym
= dynamic_symbols
+ si
;
2923 printf (" %3d %3d: %8lx %5ld %6s %6s %2d ",
2925 (unsigned long) psym
->st_value
,
2926 (unsigned long) psym
->st_size
,
2927 get_symbol_type (ELF_ST_TYPE (psym
->st_info
)),
2928 get_symbol_binding (ELF_ST_BIND (psym
->st_info
)),
2931 printf ("%3.3s", get_symbol_index_type (psym
->st_shndx
));
2933 printf (" %s\n", dynamic_strings
+ psym
->st_name
);
2937 else if (do_syms
&& !do_using_dynamic
)
2941 for (i
= 0, section
= section_headers
;
2942 i
< elf_header
.e_shnum
;
2947 Elf_Internal_Sym
* symtab
;
2948 Elf_Internal_Sym
* psym
;
2951 if ( section
->sh_type
!= SHT_SYMTAB
2952 && section
->sh_type
!= SHT_DYNSYM
)
2955 printf (_("\nSymbol table '%s' contains %d entries:\n"),
2956 SECTION_NAME (section
),
2957 section
->sh_size
/ section
->sh_entsize
);
2958 fputs (_(" Num: Value Size Type Bind Ot Ndx Name\n"),
2961 symtab
= get_elf_symbols (file
, section
->sh_offset
,
2962 section
->sh_size
/ section
->sh_entsize
);
2966 if (section
->sh_link
== elf_header
.e_shstrndx
)
2967 strtab
= string_table
;
2970 Elf32_Internal_Shdr
* string_sec
;
2972 string_sec
= section_headers
+ section
->sh_link
;
2974 GET_DATA_ALLOC (string_sec
->sh_offset
, string_sec
->sh_size
,
2975 strtab
, char *, "string table");
2978 for (si
= 0, psym
= symtab
;
2979 si
< section
->sh_size
/ section
->sh_entsize
;
2982 printf (" %3d: %8lx %5ld %-7s %-6s %2d ",
2984 (unsigned long) psym
->st_value
,
2985 (unsigned long) psym
->st_size
,
2986 get_symbol_type (ELF_ST_TYPE (psym
->st_info
)),
2987 get_symbol_binding (ELF_ST_BIND (psym
->st_info
)),
2990 if (psym
->st_shndx
== 0)
2991 fputs (" UND", stdout
);
2992 else if ((psym
->st_shndx
& 0xffff) == 0xfff1)
2993 fputs (" ABS", stdout
);
2994 else if ((psym
->st_shndx
& 0xffff) == 0xfff2)
2995 fputs (" COM", stdout
);
2997 printf ("%4x", psym
->st_shndx
);
2999 printf (" %s", strtab
+ psym
->st_name
);
3001 if (section
->sh_type
== SHT_DYNSYM
&&
3002 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] != 0)
3004 unsigned char data
[2];
3005 unsigned short vers_data
;
3006 unsigned long offset
;
3010 offset
= version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)]
3013 GET_DATA (offset
+ si
* sizeof (vers_data
), data
,
3016 vers_data
= byte_get (data
, 2);
3018 is_nobits
= psym
->st_shndx
< SHN_LORESERVE
?
3019 (section_headers
[psym
->st_shndx
].sh_type
== SHT_NOBITS
)
3022 check_def
= (psym
->st_shndx
!= SHN_UNDEF
);
3024 if ((vers_data
& 0x8000) || vers_data
> 1)
3026 if (is_nobits
|| ! check_def
)
3028 Elf_External_Verneed evn
;
3029 Elf_Internal_Verneed ivn
;
3030 Elf_Internal_Vernaux ivna
;
3032 /* We must test both. */
3033 offset
= version_info
3034 [DT_VERSIONTAGIDX (DT_VERNEED
)] - loadaddr
;
3036 GET_DATA (offset
, evn
, "version need");
3038 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
3039 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
3043 unsigned long vna_off
;
3045 vna_off
= offset
+ ivn
.vn_aux
;
3049 Elf_External_Vernaux evna
;
3051 GET_DATA (vna_off
, evna
,
3052 "version need aux (3)");
3054 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
3055 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
3056 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
3058 vna_off
+= ivna
.vna_next
;
3060 while (ivna
.vna_other
!= vers_data
3061 && ivna
.vna_next
!= 0);
3063 if (ivna
.vna_other
== vers_data
)
3066 offset
+= ivn
.vn_next
;
3068 while (ivn
.vn_next
!= 0);
3070 if (ivna
.vna_other
== vers_data
)
3073 strtab
+ ivna
.vna_name
, ivna
.vna_other
);
3076 else if (! is_nobits
)
3077 error (_("bad dynamic symbol"));
3084 if (vers_data
!= 0x8001)
3086 Elf_Internal_Verdef ivd
;
3087 Elf_Internal_Verdaux ivda
;
3088 Elf_External_Verdaux evda
;
3089 unsigned long offset
;
3092 version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)]
3097 Elf_External_Verdef evd
;
3099 GET_DATA (offset
, evd
, "version def");
3101 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
3102 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
3103 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
3105 offset
+= ivd
.vd_next
;
3107 while (ivd
.vd_ndx
!= (vers_data
& 0x7fff)
3108 && ivd
.vd_next
!= 0);
3110 offset
-= ivd
.vd_next
;
3111 offset
+= ivd
.vd_aux
;
3113 GET_DATA (offset
, evda
, "version def aux");
3115 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
3117 if (psym
->st_name
!= ivda
.vda_name
)
3118 printf ((vers_data
& 0x8000)
3120 strtab
+ ivda
.vda_name
);
3130 if (strtab
!= string_table
)
3136 (_("\nDynamic symbol information is not available for displaying symbols.\n"));
3138 if (do_histogram
&& buckets
!= NULL
)
3145 int nzero_counts
= 0;
3148 printf (_("\nHistogram for bucket list length (total of %d buckets):\n"),
3150 printf (_(" Length Number %% of total Coverage\n"));
3152 lengths
= (int *) calloc (nbuckets
, sizeof (int));
3153 if (lengths
== NULL
)
3155 error (_("Out of memory"));
3158 for (hn
= 0; hn
< nbuckets
; ++hn
)
3163 for (si
= buckets
[hn
]; si
; si
= chains
[si
])
3166 if (maxlength
< ++lengths
[hn
])
3171 counts
= (int *) calloc (maxlength
+ 1, sizeof (int));
3174 error (_("Out of memory"));
3178 for (hn
= 0; hn
< nbuckets
; ++hn
)
3179 ++counts
[lengths
[hn
]];
3181 printf (" 0 %-10d (%5.1f%%)\n",
3182 counts
[0], (counts
[0] * 100.0) / nbuckets
);
3183 for (si
= 1; si
<= maxlength
; ++si
)
3185 nzero_counts
+= counts
[si
] * si
;
3186 printf ("%7d %-10d (%5.1f%%) %5.1f%%\n",
3187 si
, counts
[si
], (counts
[si
] * 100.0) / nbuckets
,
3188 (nzero_counts
* 100.0) / nsyms
);
3195 if (buckets
!= NULL
)
3205 process_syminfo (file
)
3210 if (dynamic_syminfo
== NULL
3212 /* No syminfo, this is ok. */
3215 /* There better should be a dynamic symbol section. */
3216 if (dynamic_symbols
== NULL
|| dynamic_strings
== NULL
)
3220 printf (_("\nDynamic info segment at offset 0x%x contains %d entries:\n"),
3221 dynamic_syminfo_offset
, dynamic_syminfo_nent
);
3223 printf (_(" Num: Name BoundTo Flags\n"));
3224 for (i
= 0; i
< dynamic_syminfo_nent
; ++i
)
3226 unsigned short int flags
= dynamic_syminfo
[i
].si_flags
;
3228 printf ("%4d: %-30s ", i
,
3229 dynamic_strings
+ dynamic_symbols
[i
].st_name
);
3231 switch (dynamic_syminfo
[i
].si_boundto
)
3233 case SYMINFO_BT_SELF
:
3234 fputs ("SELF ", stdout
);
3236 case SYMINFO_BT_PARENT
:
3237 fputs ("PARENT ", stdout
);
3240 if (dynamic_syminfo
[i
].si_boundto
> 0
3241 && dynamic_syminfo
[i
].si_boundto
< dynamic_size
)
3244 + dynamic_segment
[dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
);
3246 printf ("%-10d ", dynamic_syminfo
[i
].si_boundto
);
3250 if (flags
& SYMINFO_FLG_DIRECT
)
3252 if (flags
& SYMINFO_FLG_PASSTHRU
)
3253 printf (" PASSTHRU");
3254 if (flags
& SYMINFO_FLG_COPY
)
3256 if (flags
& SYMINFO_FLG_LAZYLOAD
)
3257 printf (" LAZYLOAD");
3265 #ifdef SUPPORT_DISASSEMBLY
3267 disassemble_section (section
, file
)
3268 Elf32_Internal_Shdr
* section
;
3271 printf (_("\nAssembly dump of section %s\n"),
3272 SECTION_NAME (section
));
3274 /* XXX -- to be done --- XXX */
3281 dump_section (section
, file
)
3282 Elf32_Internal_Shdr
* section
;
3287 unsigned char * data
;
3290 bytes
= section
->sh_size
;
3294 printf (_("\nSection '%s' has no data to dump.\n"),
3295 SECTION_NAME (section
));
3299 printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section
));
3301 addr
= section
->sh_addr
;
3303 GET_DATA_ALLOC (section
->sh_offset
, bytes
, start
, char *,
3314 lbytes
= (bytes
> 16 ? 16 : bytes
);
3316 printf (" 0x%8.8x ", addr
);
3318 switch (elf_header
.e_ident
[EI_DATA
])
3321 for (j
= 15; j
>= 0; j
--)
3324 printf ("%2.2x", data
[j
]);
3334 for (j
= 0; j
< 16; j
++)
3337 printf ("%2.2x", data
[j
]);
3347 for (j
= 0; j
< lbytes
; j
++)
3350 if (k
>= ' ' && k
< 0x80)
3369 static unsigned long int
3370 read_leb128 (data
, length_return
, sign
)
3371 unsigned char * data
;
3372 int * length_return
;
3375 unsigned long int result
= 0;
3376 unsigned int num_read
= 0;
3385 result
|= (byte
& 0x7f) << shift
;
3390 while (byte
& 0x80);
3392 * length_return
= num_read
;
3394 if (sign
&& (shift
< 32) && (byte
& 0x40))
3395 result
|= -1 << shift
;
3402 process_extended_line_op (data
, address
)
3403 unsigned char * data
;
3406 unsigned char op_code
;
3409 unsigned char * orig_data
= data
;
3411 length
= read_leb128 (data
, & bytes_read
, 0);
3413 length
+= bytes_read
;
3415 op_code
= * data
++;
3419 case DW_LNE_end_sequence
:
3420 printf (_(" End Sequence\n\n"));
3423 case DW_LNE_set_address
:
3424 /* XXX - assumption here that address size is 4! */
3425 * address
= byte_get (data
, 4);
3426 printf (_(" Set Address to %lx\n"), * address
);
3429 case DW_LNE_define_file
:
3430 printf (_(" Define File: %s"), data
);
3431 data
+= strlen (data
) + 1;
3432 printf (_(" Dir: %d"), read_leb128 (data
, & bytes_read
, 0));
3434 printf (_(" Time: %d"), read_leb128 (data
, & bytes_read
, 0));
3436 printf (_(" Size: %d"), read_leb128 (data
, & bytes_read
, 0));
3440 warn (_("Unknown extended line op: %d of length %d\n"),
3441 op_code
, length
- bytes_read
);
3450 display_debug_lines (section
, start
, file
)
3451 Elf32_Internal_Shdr
* section
;
3452 unsigned char * start
;
3455 DWARF2_External_LineInfo
* external
;
3456 DWARF2_Internal_LineInfo info
;
3457 unsigned char * standard_opcodes
;
3459 unsigned char * data
= start
;
3460 unsigned char * end
= start
+ section
->sh_size
;
3461 unsigned long address
;
3466 printf (_("\nDump of debug contents of section %s:\n\n"),
3467 SECTION_NAME (section
));
3469 external
= (DWARF2_External_LineInfo
*) start
;
3471 /* Check the length of the block. */
3472 info
.li_length
= BYTE_GET (external
->li_length
);
3473 if (info
.li_length
> section
->sh_size
)
3476 (_("The line info appears to be corrupt - the section is too small\n"));
3480 /* Check its version number. */
3481 info
.li_version
= BYTE_GET (external
->li_version
);
3482 if (info
.li_version
!= 2)
3484 warn (_("Only DWARF version 2 line info is currently supported.\n"));
3488 info
.li_prologue_length
= BYTE_GET (external
->li_prologue_length
);
3489 info
.li_min_insn_length
= BYTE_GET (external
->li_min_insn_length
);
3490 info
.li_default_is_stmt
= BYTE_GET (external
->li_default_is_stmt
);
3491 info
.li_line_base
= BYTE_GET (external
->li_line_base
);
3492 info
.li_line_range
= BYTE_GET (external
->li_line_range
);
3493 info
.li_opcode_base
= BYTE_GET (external
->li_opcode_base
);
3495 /* Sign extend the line base field. */
3496 info
.li_line_base
<<= 24;
3497 info
.li_line_base
>>= 24;
3499 printf (_(" Length: %d\n"), info
.li_length
);
3500 printf (_(" DWARF Version: %d\n"), info
.li_version
);
3501 printf (_(" Prolgue Length: %d\n"), info
.li_prologue_length
);
3502 printf (_(" Minimum Instruction Length: %d\n"), info
.li_min_insn_length
);
3503 printf (_(" Initial value of 'is_stmt': %d\n"), info
.li_default_is_stmt
);
3504 printf (_(" Line Base: %d\n"), info
.li_line_base
);
3505 printf (_(" Line Range: %d\n"), info
.li_line_range
);
3506 printf (_(" Opcode Base: %d\n"), info
.li_opcode_base
);
3508 /* Display the contents of the Opcodes table. */
3509 standard_opcodes
= start
+ sizeof (* external
);
3511 printf (_("\n Opcodes:\n"));
3513 for (i
= 1; i
< info
.li_opcode_base
; i
++)
3514 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
]);
3517 /* Display the contents of the Directory table. */
3518 data
= standard_opcodes
+ info
.li_opcode_base
- 1;
3521 printf (_("\n The Directory Table is empty\n"));
3524 printf (_("\n The Directory Table:\n"));
3528 printf (_(" %s\n"), data
);
3530 data
+= strlen (data
) + 1;
3534 /* Skip the NUL at the end of the table. */
3537 /* Display the contents of the File Name table. */
3539 printf (_("\n The File Name Table is empty\n"));
3542 printf (_("\n The File Name Table:\n"));
3543 printf (_(" Name\t\tDir\tTime\tSize\n"));
3549 printf (_(" %s"), data
);
3551 data
+= strlen (data
) + 1;
3553 printf (_("\t%lu"), read_leb128 (data
, & bytes_read
, 0));
3555 printf (_("\t%lu"), read_leb128 (data
, & bytes_read
, 0));
3557 printf (_("\t%lu\n"), read_leb128 (data
, & bytes_read
, 0));
3562 /* Skip the NUL at the end of the table. */
3565 /* Now display the statements: */
3566 printf (_("\n Line Number Statements:\n"));
3570 is_stmt
= info
.li_default_is_stmt
;
3574 unsigned char op_code
;
3578 op_code
= * data
++;
3582 case DW_LNS_extended_op
:
3583 data
+= process_extended_line_op (data
, & address
);
3587 printf (_(" Copy\n"));
3590 case DW_LNS_advance_pc
:
3591 adv
= info
.li_min_insn_length
* read_leb128 (data
, & bytes_read
, 0);
3594 printf (_(" Advance PC by %x to %x\n"), adv
, address
);
3597 case DW_LNS_advance_line
:
3598 adv
= read_leb128 (data
, & bytes_read
, 0);
3601 printf (_(" Advance Line by %d to %d\n"), adv
, line
);
3604 case DW_LNS_set_file
:
3605 adv
= read_leb128 (data
, & bytes_read
, 0);
3607 printf (_(" Set File Name to entry %d in the File Name Table\n"),
3611 case DW_LNS_set_column
:
3612 adv
= read_leb128 (data
, & bytes_read
, 0);
3614 printf (_(" Set column to %d\n"), adv
);
3617 case DW_LNS_negate_stmt
:
3618 printf (_(" Set is_stmt to %d\n"), is_stmt
);
3621 case DW_LNS_set_basic_block
:
3622 printf (_(" Set basic block\n"));
3625 case DW_LNS_const_add_pc
:
3626 adv
= (255 - info
.li_opcode_base
) / info
.li_line_range
;
3628 printf (_(" Advance PC by constant %d to %x\n"), adv
, address
);
3631 case DW_LNS_fixed_advance_pc
:
3632 adv
= byte_get (data
, 2);
3635 printf (_(" Advance PC by fixed size amount %d to %x\n"),
3640 op_code
-= info
.li_opcode_base
;
3641 address
+= (op_code
/ info
.li_line_range
) * info
.li_min_insn_length
,
3642 line
+= (op_code
% info
.li_line_range
) + info
.li_line_base
;
3644 (_(" Increase by %d, setting address to %lx and line to %d:\n"),
3645 op_code
, address
, line
);
3655 display_debug_pubnames (section
, start
, file
)
3656 Elf32_Internal_Shdr
* section
;
3657 unsigned char * start
;
3660 DWARF2_External_PubNames
* external
;
3661 DWARF2_Internal_PubNames pubnames
;
3662 unsigned char * end
;
3664 end
= start
+ section
->sh_size
;
3666 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
3670 unsigned char * data
;
3671 unsigned long offset
;
3673 external
= (DWARF2_External_PubNames
*) start
;
3675 pubnames
.pn_length
= BYTE_GET (external
->pn_length
);
3676 pubnames
.pn_version
= BYTE_GET (external
->pn_version
);
3677 pubnames
.pn_offset
= BYTE_GET (external
->pn_offset
);
3678 pubnames
.pn_size
= BYTE_GET (external
->pn_size
);
3680 data
= start
+ sizeof (* external
);
3681 start
+= pubnames
.pn_length
+ sizeof (external
->pn_length
);
3683 if (pubnames
.pn_version
!= 2)
3685 warn (_("Only DWARF 2 pubnames are currently supported"));
3689 printf (_(" Length: %d\n"),
3690 pubnames
.pn_length
);
3691 printf (_(" Version: %d\n"),
3692 pubnames
.pn_version
);
3693 printf (_(" Offset into .debug_info section: %d\n"),
3694 pubnames
.pn_offset
);
3695 printf (_(" Size of area in .debug_info section: %d\n"),
3698 printf (_("\n Offset\tName\n"));
3702 offset
= byte_get (data
, 4);
3707 printf (" %d\t\t%s\n", offset
, data
);
3708 data
+= strlen (data
) + 1;
3711 while (offset
!= 0);
3724 case DW_TAG_padding
: return "DW_TAG_padding";
3725 case DW_TAG_array_type
: return "DW_TAG_array_type";
3726 case DW_TAG_class_type
: return "DW_TAG_class_type";
3727 case DW_TAG_entry_point
: return "DW_TAG_entry_point";
3728 case DW_TAG_enumeration_type
: return "DW_TAG_enumeration_type";
3729 case DW_TAG_formal_parameter
: return "DW_TAG_formal_parameter";
3730 case DW_TAG_imported_declaration
: return "DW_TAG_imported_declaration";
3731 case DW_TAG_label
: return "DW_TAG_label";
3732 case DW_TAG_lexical_block
: return "DW_TAG_lexical_block";
3733 case DW_TAG_member
: return "DW_TAG_member";
3734 case DW_TAG_pointer_type
: return "DW_TAG_pointer_type";
3735 case DW_TAG_reference_type
: return "DW_TAG_reference_type";
3736 case DW_TAG_compile_unit
: return "DW_TAG_compile_unit";
3737 case DW_TAG_string_type
: return "DW_TAG_string_type";
3738 case DW_TAG_structure_type
: return "DW_TAG_structure_type";
3739 case DW_TAG_subroutine_type
: return "DW_TAG_subroutine_type";
3740 case DW_TAG_typedef
: return "DW_TAG_typedef";
3741 case DW_TAG_union_type
: return "DW_TAG_union_type";
3742 case DW_TAG_unspecified_parameters
: return "DW_TAG_unspecified_parameters";
3743 case DW_TAG_variant
: return "DW_TAG_variant";
3744 case DW_TAG_common_block
: return "DW_TAG_common_block";
3745 case DW_TAG_common_inclusion
: return "DW_TAG_common_inclusion";
3746 case DW_TAG_inheritance
: return "DW_TAG_inheritance";
3747 case DW_TAG_inlined_subroutine
: return "DW_TAG_inlined_subroutine";
3748 case DW_TAG_module
: return "DW_TAG_module";
3749 case DW_TAG_ptr_to_member_type
: return "DW_TAG_ptr_to_member_type";
3750 case DW_TAG_set_type
: return "DW_TAG_set_type";
3751 case DW_TAG_subrange_type
: return "DW_TAG_subrange_type";
3752 case DW_TAG_with_stmt
: return "DW_TAG_with_stmt";
3753 case DW_TAG_access_declaration
: return "DW_TAG_access_declaration";
3754 case DW_TAG_base_type
: return "DW_TAG_base_type";
3755 case DW_TAG_catch_block
: return "DW_TAG_catch_block";
3756 case DW_TAG_const_type
: return "DW_TAG_const_type";
3757 case DW_TAG_constant
: return "DW_TAG_constant";
3758 case DW_TAG_enumerator
: return "DW_TAG_enumerator";
3759 case DW_TAG_file_type
: return "DW_TAG_file_type";
3760 case DW_TAG_friend
: return "DW_TAG_friend";
3761 case DW_TAG_namelist
: return "DW_TAG_namelist";
3762 case DW_TAG_namelist_item
: return "DW_TAG_namelist_item";
3763 case DW_TAG_packed_type
: return "DW_TAG_packed_type";
3764 case DW_TAG_subprogram
: return "DW_TAG_subprogram";
3765 case DW_TAG_template_type_param
: return "DW_TAG_template_type_param";
3766 case DW_TAG_template_value_param
: return "DW_TAG_template_value_param";
3767 case DW_TAG_thrown_type
: return "DW_TAG_thrown_type";
3768 case DW_TAG_try_block
: return "DW_TAG_try_block";
3769 case DW_TAG_variant_part
: return "DW_TAG_variant_part";
3770 case DW_TAG_variable
: return "DW_TAG_variable";
3771 case DW_TAG_volatile_type
: return "DW_TAG_volatile_type";
3772 case DW_TAG_MIPS_loop
: return "DW_TAG_MIPS_loop";
3773 case DW_TAG_format_label
: return "DW_TAG_format_label";
3774 case DW_TAG_function_template
: return "DW_TAG_function_template";
3775 case DW_TAG_class_template
: return "DW_TAG_class_template";
3778 static char buffer
[100];
3780 sprintf (buffer
, _("Unknown TAG value: %x"), tag
);
3787 get_AT_name (attribute
)
3788 unsigned long attribute
;
3792 case DW_AT_sibling
: return "DW_AT_sibling";
3793 case DW_AT_location
: return "DW_AT_location";
3794 case DW_AT_name
: return "DW_AT_name";
3795 case DW_AT_ordering
: return "DW_AT_ordering";
3796 case DW_AT_subscr_data
: return "DW_AT_subscr_data";
3797 case DW_AT_byte_size
: return "DW_AT_byte_size";
3798 case DW_AT_bit_offset
: return "DW_AT_bit_offset";
3799 case DW_AT_bit_size
: return "DW_AT_bit_size";
3800 case DW_AT_element_list
: return "DW_AT_element_list";
3801 case DW_AT_stmt_list
: return "DW_AT_stmt_list";
3802 case DW_AT_low_pc
: return "DW_AT_low_pc";
3803 case DW_AT_high_pc
: return "DW_AT_high_pc";
3804 case DW_AT_language
: return "DW_AT_language";
3805 case DW_AT_member
: return "DW_AT_member";
3806 case DW_AT_discr
: return "DW_AT_discr";
3807 case DW_AT_discr_value
: return "DW_AT_discr_value";
3808 case DW_AT_visibility
: return "DW_AT_visibility";
3809 case DW_AT_import
: return "DW_AT_import";
3810 case DW_AT_string_length
: return "DW_AT_string_length";
3811 case DW_AT_common_reference
: return "DW_AT_common_reference";
3812 case DW_AT_comp_dir
: return "DW_AT_comp_dir";
3813 case DW_AT_const_value
: return "DW_AT_const_value";
3814 case DW_AT_containing_type
: return "DW_AT_containing_type";
3815 case DW_AT_default_value
: return "DW_AT_default_value";
3816 case DW_AT_inline
: return "DW_AT_inline";
3817 case DW_AT_is_optional
: return "DW_AT_is_optional";
3818 case DW_AT_lower_bound
: return "DW_AT_lower_bound";
3819 case DW_AT_producer
: return "DW_AT_producer";
3820 case DW_AT_prototyped
: return "DW_AT_prototyped";
3821 case DW_AT_return_addr
: return "DW_AT_return_addr";
3822 case DW_AT_start_scope
: return "DW_AT_start_scope";
3823 case DW_AT_stride_size
: return "DW_AT_stride_size";
3824 case DW_AT_upper_bound
: return "DW_AT_upper_bound";
3825 case DW_AT_abstract_origin
: return "DW_AT_abstract_origin";
3826 case DW_AT_accessibility
: return "DW_AT_accessibility";
3827 case DW_AT_address_class
: return "DW_AT_address_class";
3828 case DW_AT_artificial
: return "DW_AT_artificial";
3829 case DW_AT_base_types
: return "DW_AT_base_types";
3830 case DW_AT_calling_convention
: return "DW_AT_calling_convention";
3831 case DW_AT_count
: return "DW_AT_count";
3832 case DW_AT_data_member_location
: return "DW_AT_data_member_location";
3833 case DW_AT_decl_column
: return "DW_AT_decl_column";
3834 case DW_AT_decl_file
: return "DW_AT_decl_file";
3835 case DW_AT_decl_line
: return "DW_AT_decl_line";
3836 case DW_AT_declaration
: return "DW_AT_declaration";
3837 case DW_AT_discr_list
: return "DW_AT_discr_list";
3838 case DW_AT_encoding
: return "DW_AT_encoding";
3839 case DW_AT_external
: return "DW_AT_external";
3840 case DW_AT_frame_base
: return "DW_AT_frame_base";
3841 case DW_AT_friend
: return "DW_AT_friend";
3842 case DW_AT_identifier_case
: return "DW_AT_identifier_case";
3843 case DW_AT_macro_info
: return "DW_AT_macro_info";
3844 case DW_AT_namelist_items
: return "DW_AT_namelist_items";
3845 case DW_AT_priority
: return "DW_AT_priority";
3846 case DW_AT_segment
: return "DW_AT_segment";
3847 case DW_AT_specification
: return "DW_AT_specification";
3848 case DW_AT_static_link
: return "DW_AT_static_link";
3849 case DW_AT_type
: return "DW_AT_type";
3850 case DW_AT_use_location
: return "DW_AT_use_location";
3851 case DW_AT_variable_parameter
: return "DW_AT_variable_parameter";
3852 case DW_AT_virtuality
: return "DW_AT_virtuality";
3853 case DW_AT_vtable_elem_location
: return "DW_AT_vtable_elem_location";
3854 case DW_AT_MIPS_fde
: return "DW_AT_MIPS_fde";
3855 case DW_AT_MIPS_loop_begin
: return "DW_AT_MIPS_loop_begin";
3856 case DW_AT_MIPS_tail_loop_begin
: return "DW_AT_MIPS_tail_loop_begin";
3857 case DW_AT_MIPS_epilog_begin
: return "DW_AT_MIPS_epilog_begin";
3858 case DW_AT_MIPS_loop_unroll_factor
: return "DW_AT_MIPS_loop_unroll_factor";
3859 case DW_AT_MIPS_software_pipeline_depth
: return "DW_AT_MIPS_software_pipeline_depth";
3860 case DW_AT_MIPS_linkage_name
: return "DW_AT_MIPS_linkage_name";
3861 case DW_AT_MIPS_stride
: return "DW_AT_MIPS_stride";
3862 case DW_AT_MIPS_abstract_name
: return "DW_AT_MIPS_abstract_name";
3863 case DW_AT_MIPS_clone_origin
: return "DW_AT_MIPS_clone_origin";
3864 case DW_AT_MIPS_has_inlines
: return "DW_AT_MIPS_has_inlines";
3865 case DW_AT_sf_names
: return "DW_AT_sf_names";
3866 case DW_AT_src_info
: return "DW_AT_src_info";
3867 case DW_AT_mac_info
: return "DW_AT_mac_info";
3868 case DW_AT_src_coords
: return "DW_AT_src_coords";
3869 case DW_AT_body_begin
: return "DW_AT_body_begin";
3870 case DW_AT_body_end
: return "DW_AT_body_end";
3873 static char buffer
[100];
3875 sprintf (buffer
, _("Unknown AT value: %x"), attribute
);
3882 get_FORM_name (form
)
3887 case DW_FORM_addr
: return "DW_FORM_addr";
3888 case DW_FORM_block2
: return "DW_FORM_block2";
3889 case DW_FORM_block4
: return "DW_FORM_block4";
3890 case DW_FORM_data2
: return "DW_FORM_data2";
3891 case DW_FORM_data4
: return "DW_FORM_data4";
3892 case DW_FORM_data8
: return "DW_FORM_data8";
3893 case DW_FORM_string
: return "DW_FORM_string";
3894 case DW_FORM_block
: return "DW_FORM_block";
3895 case DW_FORM_block1
: return "DW_FORM_block1";
3896 case DW_FORM_data1
: return "DW_FORM_data1";
3897 case DW_FORM_flag
: return "DW_FORM_flag";
3898 case DW_FORM_sdata
: return "DW_FORM_sdata";
3899 case DW_FORM_strp
: return "DW_FORM_strp";
3900 case DW_FORM_udata
: return "DW_FORM_udata";
3901 case DW_FORM_ref_addr
: return "DW_FORM_ref_addr";
3902 case DW_FORM_ref1
: return "DW_FORM_ref1";
3903 case DW_FORM_ref2
: return "DW_FORM_ref2";
3904 case DW_FORM_ref4
: return "DW_FORM_ref4";
3905 case DW_FORM_ref8
: return "DW_FORM_ref8";
3906 case DW_FORM_ref_udata
: return "DW_FORM_ref_udata";
3907 case DW_FORM_indirect
: return "DW_FORM_indirect";
3910 static char buffer
[100];
3912 sprintf (buffer
, _("Unknown FORM value: %x"), form
);
3918 /* FIXME: There are better and more effiecint ways to handle
3919 these structures. For now though, I just want something that
3920 is simple to implement. */
3921 typedef struct abbrev_attr
3923 unsigned long attribute
;
3925 struct abbrev_attr
* next
;
3929 typedef struct abbrev_entry
3931 unsigned long entry
;
3934 struct abbrev_attr
* first_attr
;
3935 struct abbrev_attr
* last_attr
;
3936 struct abbrev_entry
* next
;
3940 static abbrev_entry
* first_abbrev
= NULL
;
3941 static abbrev_entry
* last_abbrev
= NULL
;
3944 free_abbrevs
PARAMS ((void))
3946 abbrev_entry
* abbrev
;
3948 for (abbrev
= first_abbrev
; abbrev
;)
3950 abbrev_entry
* next
= abbrev
->next
;
3953 for (attr
= abbrev
->first_attr
; attr
;)
3955 abbrev_attr
* next
= attr
->next
;
3965 last_abbrev
= first_abbrev
= NULL
;
3969 add_abbrev (number
, tag
, children
)
3970 unsigned long number
;
3974 abbrev_entry
* entry
;
3976 entry
= (abbrev_entry
*) malloc (sizeof (* entry
));
3982 entry
->entry
= number
;
3984 entry
->children
= children
;
3985 entry
->first_attr
= NULL
;
3986 entry
->last_attr
= NULL
;
3989 if (first_abbrev
== NULL
)
3990 first_abbrev
= entry
;
3992 last_abbrev
->next
= entry
;
3994 last_abbrev
= entry
;
3998 add_abbrev_attr (attribute
, form
)
3999 unsigned long attribute
;
4004 attr
= (abbrev_attr
*) malloc (sizeof (* attr
));
4010 attr
->attribute
= attribute
;
4014 if (last_abbrev
->first_attr
== NULL
)
4015 last_abbrev
->first_attr
= attr
;
4017 last_abbrev
->last_attr
->next
= attr
;
4019 last_abbrev
->last_attr
= attr
;
4022 /* Processes the (partial) contents of a .debug_abbrev section.
4023 Returns NULL if the end of the section was encountered.
4024 Returns the address after the last byte read if the end of
4025 an abbreviation set was found. */
4027 static unsigned char *
4028 process_abbrev_section (start
, end
)
4029 unsigned char * start
;
4030 unsigned char * end
;
4032 if (first_abbrev
!= NULL
)
4038 unsigned long entry
;
4040 unsigned long attribute
;
4043 entry
= read_leb128 (start
, & bytes_read
, 0);
4044 start
+= bytes_read
;
4049 tag
= read_leb128 (start
, & bytes_read
, 0);
4050 start
+= bytes_read
;
4052 children
= * start
++;
4054 add_abbrev (entry
, tag
, children
);
4060 attribute
= read_leb128 (start
, & bytes_read
, 0);
4061 start
+= bytes_read
;
4063 form
= read_leb128 (start
, & bytes_read
, 0);
4064 start
+= bytes_read
;
4067 add_abbrev_attr (attribute
, form
);
4069 while (attribute
!= 0);
4077 display_debug_abbrev (section
, start
, file
)
4078 Elf32_Internal_Shdr
* section
;
4079 unsigned char * start
;
4082 abbrev_entry
* entry
;
4083 unsigned char * end
= start
+ section
->sh_size
;
4085 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
4089 start
= process_abbrev_section (start
, end
);
4091 printf (_(" Number TAG\n"));
4093 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
4097 printf (_(" %d %s [%s]\n"),
4099 get_TAG_name (entry
->tag
),
4100 entry
->children
? _("has children") : _("no children"));
4102 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
4104 printf (_(" %-18s %s\n"),
4105 get_AT_name (attr
->attribute
),
4106 get_FORM_name (attr
->form
));
4118 static unsigned char *
4119 display_block (data
, length
)
4120 unsigned char * data
;
4121 unsigned long length
;
4123 printf (_(" %d byte block: "), length
);
4126 printf ("%x ", byte_get (data
++, 1));
4131 static unsigned char *
4132 read_and_display_attr (attribute
, form
, data
, pointer_size
)
4133 unsigned long attribute
;
4135 unsigned char * data
;
4136 unsigned long pointer_size
;
4138 unsigned long uvalue
;
4141 printf (" %-18s:", get_AT_name (attribute
));
4145 case DW_FORM_ref_addr
:
4147 uvalue
= byte_get (data
, pointer_size
);
4148 printf (" %x", uvalue
);
4149 data
+= pointer_size
;
4155 uvalue
= byte_get (data
++, 1);
4156 printf (" %x", uvalue
);
4161 uvalue
= byte_get (data
, 2);
4163 printf (" %x", uvalue
);
4168 uvalue
= byte_get (data
, 4);
4170 printf (" %x", uvalue
);
4175 uvalue
= byte_get (data
, 4);
4176 printf (" %x", uvalue
);
4177 printf (" %x", byte_get (data
+ 4, 4));
4181 case DW_FORM_string
:
4182 printf (" %s", data
);
4183 data
+= strlen (data
) + 1;
4187 uvalue
= read_leb128 (data
, & bytes_read
, 1);
4189 printf (" %ld", (long) uvalue
);
4192 case DW_FORM_ref_udata
:
4194 uvalue
= read_leb128 (data
, & bytes_read
, 0);
4196 printf (" %lx", uvalue
);
4200 uvalue
= read_leb128 (data
, & bytes_read
, 0);
4201 data
= display_block (data
+ bytes_read
, uvalue
);
4202 uvalue
= * (data
- uvalue
);
4205 case DW_FORM_block1
:
4206 uvalue
= byte_get (data
++, 1);
4207 data
= display_block (data
, uvalue
);
4208 uvalue
= * (data
- uvalue
);
4211 case DW_FORM_block2
:
4212 uvalue
= byte_get (data
, 2);
4213 data
= display_block (data
+ 2, uvalue
);
4214 uvalue
= * (data
- uvalue
);
4217 case DW_FORM_block4
:
4218 uvalue
= byte_get (data
, 4);
4219 data
= display_block (data
+ 4, uvalue
);
4220 uvalue
= * (data
- uvalue
);
4224 case DW_FORM_indirect
:
4225 warn (_("Unable to handle FORM: %d"), form
);
4229 warn (_("Unrecognised form: %d"), form
);
4233 /* For some attributes we can display futher information. */
4242 case DW_INL_not_inlined
: printf (_("(not inlined)")); break;
4243 case DW_INL_inlined
: printf (_("(inlined)")); break;
4244 case DW_INL_declared_not_inlined
: printf (_("(declared as inline but ignored)")); break;
4245 case DW_INL_declared_inlined
: printf (_("(declared as inline and implemented)")); break;
4246 defailt
: printf (_(" (Unknown inline attribute value: %x)"), uvalue
); break;
4250 case DW_AT_frame_base
:
4251 if (uvalue
>= DW_OP_reg0
&& uvalue
<= DW_OP_reg31
)
4252 printf ("(reg %d)", uvalue
- DW_OP_reg0
);
4255 case DW_AT_language
:
4258 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
4259 case DW_LANG_C89
: printf ("(ANSI C)"); break;
4260 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
4261 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
4262 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
4263 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
4264 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
4265 case DW_LANG_Ada83
: printf ("(Ada)"); break;
4266 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
4267 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
4268 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
4269 default: printf ("(Unknown: %x)", uvalue
); break;
4273 case DW_AT_encoding
:
4276 case DW_ATE_void
: printf ("(void)"); break;
4277 case DW_ATE_address
: printf ("(machine address)"); break;
4278 case DW_ATE_boolean
: printf ("(boolean)"); break;
4279 case DW_ATE_complex_float
: printf ("(complex float)"); break;
4280 case DW_ATE_float
: printf ("(float)"); break;
4281 case DW_ATE_signed
: printf ("(signed)"); break;
4282 case DW_ATE_signed_char
: printf ("(signed char)"); break;
4283 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
4284 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
4286 if (uvalue
>= DW_ATE_lo_user
4287 && uvalue
<= DW_ATE_hi_user
)
4288 printf ("(user defined type)");
4290 printf ("(unknown type)");
4303 display_debug_info (section
, start
, file
)
4304 Elf32_Internal_Shdr
* section
;
4305 unsigned char * start
;
4308 unsigned char * end
= start
+ section
->sh_size
;
4310 printf (_("The section %s contains:\n\n"), SECTION_NAME (section
));
4314 DWARF2_External_CompUnit
* external
;
4315 DWARF2_Internal_CompUnit compunit
;
4316 unsigned char * tags
;
4319 external
= (DWARF2_External_CompUnit
*) start
;
4321 compunit
.cu_length
= BYTE_GET (external
->cu_length
);
4322 compunit
.cu_version
= BYTE_GET (external
->cu_version
);
4323 compunit
.cu_abbrev_offset
= BYTE_GET (external
->cu_abbrev_offset
);
4324 compunit
.cu_pointer_size
= BYTE_GET (external
->cu_pointer_size
);
4326 tags
= start
+ sizeof (* external
);
4327 start
+= compunit
.cu_length
+ sizeof (external
->cu_length
);
4329 if (compunit
.cu_version
!= 2)
4331 warn (_("Only version 2 DWARF debug information is currently supported.\n"));
4335 printf (_(" Compilation Unit:\n"));
4336 printf (_(" Length: %d\n"), compunit
.cu_length
);
4337 printf (_(" Version: %d\n"), compunit
.cu_version
);
4338 printf (_(" Abbrev Offset: %d\n"), compunit
.cu_abbrev_offset
);
4339 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
4341 if (first_abbrev
!= NULL
)
4344 /* Read in the abbrevs used by this compilation unit. */
4347 Elf32_Internal_Shdr
* sec
;
4348 unsigned char * begin
;
4350 /* Locate the .debug_abbrev section and process it. */
4351 for (i
= 0, sec
= section_headers
;
4352 i
< elf_header
.e_shnum
;
4354 if (strcmp (SECTION_NAME (sec
), ".debug_abbrev") == 0)
4357 if (i
== -1 || sec
->sh_size
== 0)
4359 warn (_("Unable to locate .debug_abbrev section!\n"));
4363 GET_DATA_ALLOC (sec
->sh_offset
, sec
->sh_size
, begin
, char *,
4364 "debug_abbrev section data");
4366 process_abbrev_section (begin
+ compunit
.cu_abbrev_offset
,
4367 begin
+ sec
->sh_size
);
4372 while (tags
< start
)
4376 abbrev_entry
* entry
;
4379 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
4382 if (abbrev_number
== 0)
4385 /* Scan through the abbreviation list until we reach the
4387 for (entry
= first_abbrev
;
4388 entry
&& entry
->entry
!= abbrev_number
;
4389 entry
= entry
->next
)
4394 warn (_("Unable to locate entry %d in the abbreviation table\n"),
4399 printf (_(" Abbrev Number: %d (%s)\n"),
4401 get_TAG_name (entry
->tag
));
4403 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
4404 tags
= read_and_display_attr (attr
->attribute
,
4407 compunit
.cu_pointer_size
);
4417 display_debug_aranges (section
, start
, file
)
4418 Elf32_Internal_Shdr
* section
;
4419 unsigned char * start
;
4422 unsigned char * end
= start
+ section
->sh_size
;
4424 printf (_("The section %s contains:\n\n"), SECTION_NAME (section
));
4428 DWARF2_External_ARange
* external
;
4429 DWARF2_Internal_ARange arange
;
4430 unsigned char * ranges
;
4432 unsigned long length
;
4433 unsigned long address
;
4435 external
= (DWARF2_External_ARange
*) start
;
4437 arange
.ar_length
= BYTE_GET (external
->ar_length
);
4438 arange
.ar_version
= BYTE_GET (external
->ar_version
);
4439 arange
.ar_info_offset
= BYTE_GET (external
->ar_info_offset
);
4440 arange
.ar_pointer_size
= BYTE_GET (external
->ar_pointer_size
);
4441 arange
.ar_segment_size
= BYTE_GET (external
->ar_segment_size
);
4443 printf (_(" Length: %d\n"), arange
.ar_length
);
4444 printf (_(" Version: %d\n"), arange
.ar_version
);
4445 printf (_(" Offset into .debug_info: %x\n"), arange
.ar_info_offset
);
4446 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
4447 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
4449 printf (_("\n Address Length\n"));
4451 ranges
= start
+ sizeof (* external
);
4455 address
= byte_get (ranges
, arange
.ar_pointer_size
);
4460 ranges
+= arange
.ar_pointer_size
;
4462 length
= byte_get (ranges
, arange
.ar_pointer_size
);
4464 ranges
+= arange
.ar_pointer_size
;
4466 printf (" %8.8x %d\n", address
, length
);
4469 start
+= arange
.ar_length
+ sizeof (external
->ar_length
);
4479 display_debug_not_supported (section
, start
, file
)
4480 Elf32_Internal_Shdr
* section
;
4481 unsigned char * start
;
4484 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
4485 SECTION_NAME (section
));
4490 /* A structure containing the name of a debug section and a pointer
4491 to a function that can decode it. */
4495 int (* display
) PARAMS((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
4499 { ".debug_info", display_debug_info
},
4500 { ".debug_abbrev", display_debug_abbrev
},
4501 { ".debug_line", display_debug_lines
},
4502 { ".debug_aranges", display_debug_aranges
},
4503 { ".debug_pubnames", display_debug_pubnames
},
4504 { ".debug_macinfo", display_debug_not_supported
},
4505 { ".debug_frame", display_debug_not_supported
},
4506 { ".debug_loc", display_debug_not_supported
},
4507 { ".debug_str", display_debug_not_supported
}
4511 display_debug_section (section
, file
)
4512 Elf32_Internal_Shdr
* section
;
4515 char * name
= SECTION_NAME (section
);
4516 bfd_size_type length
;
4517 unsigned char * start
;
4520 length
= section
->sh_size
;
4523 printf (_("\nSection '%s' has no debugging data.\n"), name
);
4527 GET_DATA_ALLOC (section
->sh_offset
, length
, start
, char *,
4528 "debug section data");
4530 /* See if we know how to display the contents of this section. */
4531 for (i
= NUM_ELEM (debug_displays
); i
--;)
4532 if (strcmp (debug_displays
[i
].name
, name
) == 0)
4534 debug_displays
[i
].display (section
, start
, file
);
4539 printf (_("Unrecognised debug section: %s\n"), name
);
4543 /* If we loaded in the abbrev section at some point,
4544 we must release it here. */
4545 if (first_abbrev
!= NULL
)
4552 process_section_contents (file
)
4555 Elf32_Internal_Shdr
* section
;
4561 for (i
= 0, section
= section_headers
;
4562 i
< elf_header
.e_shnum
4563 && i
< NUM_DUMP_SECTS
;
4566 #ifdef SUPPORT_DISASSEMBLY
4567 if (dump_sects
[i
] & DISASS_DUMP
)
4568 disassemble_section (section
, file
);
4570 if (dump_sects
[i
] & HEX_DUMP
)
4571 dump_section (section
, file
);
4573 if (dump_sects
[i
] & DEBUG_DUMP
)
4574 display_debug_section (section
, file
);
4581 process_mips_fpe_exception (mask
)
4587 if (mask
& OEX_FPU_INEX
)
4588 fputs ("INEX", stdout
), first
= 0;
4589 if (mask
& OEX_FPU_UFLO
)
4590 printf ("%sUFLO", first
? "" : "|"), first
= 0;
4591 if (mask
& OEX_FPU_OFLO
)
4592 printf ("%sOFLO", first
? "" : "|"), first
= 0;
4593 if (mask
& OEX_FPU_DIV0
)
4594 printf ("%sDIV0", first
? "" : "|"), first
= 0;
4595 if (mask
& OEX_FPU_INVAL
)
4596 printf ("%sINVAL", first
? "" : "|");
4599 fputs ("0", stdout
);
4603 process_mips_specific (file
)
4606 Elf_Internal_Dyn
*entry
;
4607 size_t liblist_offset
= 0;
4608 size_t liblistno
= 0;
4609 size_t conflictsno
= 0;
4610 size_t options_offset
= 0;
4611 size_t conflicts_offset
= 0;
4613 /* We have a lot of special sections. Thanks SGI! */
4614 if (dynamic_segment
== NULL
)
4615 /* No information available. */
4618 for (entry
= dynamic_segment
; entry
->d_tag
!= DT_NULL
; ++entry
)
4619 switch (entry
->d_tag
)
4621 case DT_MIPS_LIBLIST
:
4622 liblist_offset
= entry
->d_un
.d_val
- loadaddr
;
4624 case DT_MIPS_LIBLISTNO
:
4625 liblistno
= entry
->d_un
.d_val
;
4627 case DT_MIPS_OPTIONS
:
4628 options_offset
= entry
->d_un
.d_val
- loadaddr
;
4630 case DT_MIPS_CONFLICT
:
4631 conflicts_offset
= entry
->d_un
.d_val
- loadaddr
;
4633 case DT_MIPS_CONFLICTNO
:
4634 conflictsno
= entry
->d_un
.d_val
;
4640 if (liblist_offset
!= 0 && liblistno
!= 0 && do_dynamic
)
4642 Elf32_External_Lib
*elib
;
4645 GET_DATA_ALLOC (liblist_offset
, liblistno
* sizeof (Elf32_External_Lib
),
4646 elib
, Elf32_External_Lib
*, "liblist");
4648 printf ("\nSection '.liblist' contains %d entries:\n", liblistno
);
4649 fputs (" Library Time Stamp Checksum Version Flags\n",
4652 for (cnt
= 0; cnt
< liblistno
; ++cnt
)
4658 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
4659 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
4660 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
4661 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
4662 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
4664 strftime (timebuf
, 20, "%Y-%m-%dT%H:%M:%S", gmtime (&time
));
4666 printf ("%3d: %-20s %s %#10lx %-7ld", cnt
,
4667 dynamic_strings
+ liblist
.l_name
, timebuf
,
4668 liblist
.l_checksum
, liblist
.l_version
);
4670 if (liblist
.l_flags
== 0)
4680 { " EXACT_MATCH", LL_EXACT_MATCH
},
4681 { " IGNORE_INT_VER", LL_IGNORE_INT_VER
},
4682 { " REQUIRE_MINOR", LL_REQUIRE_MINOR
},
4683 { " EXPORTS", LL_EXPORTS
},
4684 { " DELAY_LOAD", LL_DELAY_LOAD
},
4685 { " DELTA", LL_DELTA
}
4687 int flags
= liblist
.l_flags
;
4691 fcnt
< sizeof (l_flags_vals
) / sizeof (l_flags_vals
[0]);
4693 if ((flags
& l_flags_vals
[fcnt
].bit
) != 0)
4695 fputs (l_flags_vals
[fcnt
].name
, stdout
);
4696 flags
^= l_flags_vals
[fcnt
].bit
;
4699 printf (" %#lx", flags
);
4708 if (options_offset
!= 0)
4710 Elf_External_Options
*eopt
;
4711 Elf_Internal_Shdr
*sect
= section_headers
;
4712 Elf_Internal_Options
*iopt
;
4713 Elf_Internal_Options
*option
;
4717 /* Find the section header so that we get the size. */
4718 while (sect
->sh_type
!= SHT_MIPS_OPTIONS
)
4721 GET_DATA_ALLOC (options_offset
, sect
->sh_size
, eopt
,
4722 Elf_External_Options
*, "options");
4724 iopt
= (Elf_Internal_Options
*) malloc ((sect
->sh_size
/ sizeof (eopt
))
4728 error (_("Out of memory"));
4734 while (offset
< sect
->sh_size
)
4736 Elf_External_Options
*eoption
;
4738 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
4740 option
->kind
= BYTE_GET (eoption
->kind
);
4741 option
->size
= BYTE_GET (eoption
->size
);
4742 option
->section
= BYTE_GET (eoption
->section
);
4743 option
->info
= BYTE_GET (eoption
->info
);
4745 offset
+= option
->size
;
4750 printf (_("\nSection '%s' contains %d entries:\n"),
4751 string_table
+ sect
->sh_name
, cnt
);
4758 switch (option
->kind
)
4761 /* This shouldn't happen. */
4762 printf (" NULL %d %x", option
->section
, option
->info
);
4765 printf (" REGINFO ");
4766 if (elf_header
.e_machine
== EM_MIPS
)
4769 Elf32_External_RegInfo
*ereg
;
4770 Elf32_RegInfo reginfo
;
4772 ereg
= (Elf32_External_RegInfo
*) (option
+ 1);
4773 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
4774 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
4775 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
4776 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
4777 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
4778 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
4780 printf ("GPR %08lx GP %ld\n",
4781 reginfo
.ri_gprmask
, reginfo
.ri_gp_value
);
4782 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
4783 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
4784 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
4789 Elf64_External_RegInfo
*ereg
;
4790 Elf64_Internal_RegInfo reginfo
;
4792 ereg
= (Elf64_External_RegInfo
*) (option
+ 1);
4793 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
4794 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
4795 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
4796 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
4797 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
4798 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
4800 printf ("GPR %08lx GP %ld\n",
4801 reginfo
.ri_gprmask
, reginfo
.ri_gp_value
);
4802 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
4803 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
4804 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
4808 case ODK_EXCEPTIONS
:
4809 fputs (" EXCEPTIONS fpe_min(", stdout
);
4810 process_mips_fpe_exception (option
->info
& OEX_FPU_MIN
);
4811 fputs (") fpe_max(", stdout
);
4812 process_mips_fpe_exception ((option
->info
& OEX_FPU_MAX
) >> 8);
4813 fputs (")", stdout
);
4815 if (option
->info
& OEX_PAGE0
)
4816 fputs (" PAGE0", stdout
);
4817 if (option
->info
& OEX_SMM
)
4818 fputs (" SMM", stdout
);
4819 if (option
->info
& OEX_FPDBUG
)
4820 fputs (" FPDBUG", stdout
);
4821 if (option
->info
& OEX_DISMISS
)
4822 fputs (" DISMISS", stdout
);
4825 fputs (" PAD ", stdout
);
4826 if (option
->info
& OPAD_PREFIX
)
4827 fputs (" PREFIX", stdout
);
4828 if (option
->info
& OPAD_POSTFIX
)
4829 fputs (" POSTFIX", stdout
);
4830 if (option
->info
& OPAD_SYMBOL
)
4831 fputs (" SYMBOL", stdout
);
4834 fputs (" HWPATCH ", stdout
);
4835 if (option
->info
& OHW_R4KEOP
)
4836 fputs (" R4KEOP", stdout
);
4837 if (option
->info
& OHW_R8KPFETCH
)
4838 fputs (" R8KPFETCH", stdout
);
4839 if (option
->info
& OHW_R5KEOP
)
4840 fputs (" R5KEOP", stdout
);
4841 if (option
->info
& OHW_R5KCVTL
)
4842 fputs (" R5KCVTL", stdout
);
4845 fputs (" FILL ", stdout
);
4846 /* XXX Print content of info word? */
4849 fputs (" TAGS ", stdout
);
4850 /* XXX Print content of info word? */
4853 fputs (" HWAND ", stdout
);
4854 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
4855 fputs (" R4KEOP_CHECKED", stdout
);
4856 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
4857 fputs (" R4KEOP_CLEAN", stdout
);
4860 fputs (" HWOR ", stdout
);
4861 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
4862 fputs (" R4KEOP_CHECKED", stdout
);
4863 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
4864 fputs (" R4KEOP_CLEAN", stdout
);
4867 printf (" GP_GROUP %#06x self-contained %#06x",
4868 option
->info
& OGP_GROUP
,
4869 (option
->info
& OGP_SELF
) >> 16);
4872 printf (" IDENT %#06x self-contained %#06x",
4873 option
->info
& OGP_GROUP
,
4874 (option
->info
& OGP_SELF
) >> 16);
4877 /* This shouldn't happen. */
4878 printf (" %3d ??? %d %x",
4879 option
->kind
, option
->section
, option
->info
);
4883 len
= sizeof (*eopt
);
4884 while (len
< option
->size
)
4885 if (((char *) option
)[len
] >= ' '
4886 && ((char *) option
)[len
] < 0x7f)
4887 printf ("%c", ((char *) option
)[len
++]);
4889 printf ("\\%03o", ((char *) option
)[len
++]);
4891 fputs ("\n", stdout
);
4898 if (conflicts_offset
!= 0 && conflictsno
!= 0)
4900 Elf32_External_Conflict
*econf32
;
4901 Elf64_External_Conflict
*econf64
;
4902 Elf32_Conflict
*iconf
;
4905 if (dynamic_symbols
== NULL
)
4907 error (_("conflict list with without table"));
4911 iconf
= (Elf32_Conflict
*) malloc (conflictsno
* sizeof (*iconf
));
4914 error (_("Out of memory"));
4918 if (binary_class
== ELFCLASS32
)
4920 GET_DATA_ALLOC (conflicts_offset
, conflictsno
* sizeof (*econf32
),
4921 econf32
, Elf32_External_Conflict
*, "conflict");
4923 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
4924 iconf
[cnt
] = BYTE_GET (econf32
[cnt
]);
4928 GET_DATA_ALLOC (conflicts_offset
, conflictsno
* sizeof (*econf64
),
4929 econf64
, Elf64_External_Conflict
*, "conflict");
4931 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
4932 iconf
[cnt
] = BYTE_GET (econf64
[cnt
]);
4935 printf (_("\nSection '.conflict' contains %d entries:\n"), conflictsno
);
4936 puts (_(" Num: Index Value Name"));
4938 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
4940 Elf_Internal_Sym
*psym
= &dynamic_symbols
[iconf
[cnt
]];
4942 printf ("%5u: %8u %#10x %s\n",
4943 cnt
, iconf
[cnt
], (unsigned long) psym
->st_value
,
4944 dynamic_strings
+ psym
->st_name
);
4955 process_arch_specific (file
)
4958 switch (elf_header
.e_machine
)
4961 case EM_MIPS_RS4_BE
:
4962 return process_mips_specific (file
);
4971 get_file_header (file
)
4974 Elf32_External_Ehdr ehdr
;
4976 if (fread (& ehdr
, sizeof (ehdr
), 1, file
) != 1)
4979 memcpy (elf_header
.e_ident
, ehdr
.e_ident
, EI_NIDENT
);
4981 if (elf_header
.e_ident
[EI_DATA
] == ELFDATA2LSB
)
4982 byte_get
= byte_get_little_endian
;
4984 byte_get
= byte_get_big_endian
;
4986 elf_header
.e_entry
= BYTE_GET (ehdr
.e_entry
);
4987 elf_header
.e_phoff
= BYTE_GET (ehdr
.e_phoff
);
4988 elf_header
.e_shoff
= BYTE_GET (ehdr
.e_shoff
);
4989 elf_header
.e_version
= BYTE_GET (ehdr
.e_version
);
4990 elf_header
.e_flags
= BYTE_GET (ehdr
.e_flags
);
4991 elf_header
.e_type
= BYTE_GET (ehdr
.e_type
);
4992 elf_header
.e_machine
= BYTE_GET (ehdr
.e_machine
);
4993 elf_header
.e_ehsize
= BYTE_GET (ehdr
.e_ehsize
);
4994 elf_header
.e_phentsize
= BYTE_GET (ehdr
.e_phentsize
);
4995 elf_header
.e_phnum
= BYTE_GET (ehdr
.e_phnum
);
4996 elf_header
.e_shentsize
= BYTE_GET (ehdr
.e_shentsize
);
4997 elf_header
.e_shnum
= BYTE_GET (ehdr
.e_shnum
);
4998 elf_header
.e_shstrndx
= BYTE_GET (ehdr
.e_shstrndx
);
5004 process_file (file_name
)
5008 struct stat statbuf
;
5011 if (stat (file_name
, & statbuf
) < 0)
5013 error (_("Cannot stat input file %s.\n"), file_name
);
5017 file
= fopen (file_name
, "rb");
5020 error (_("Input file %s not found.\n"), file_name
);
5024 if (! get_file_header (file
))
5026 error (_("%s: Failed to read file header\n"), file_name
);
5031 /* Initialise per file variables. */
5032 for (i
= NUM_ELEM (version_info
); i
--;)
5033 version_info
[i
] = 0;
5035 for (i
= NUM_ELEM (dynamic_info
); i
--;)
5036 dynamic_info
[i
] = 0;
5038 /* Process the file. */
5040 printf (_("\nFile: %s\n"), file_name
);
5042 if (! process_file_header ())
5048 process_section_headers (file
);
5050 process_program_headers (file
);
5052 process_dynamic_segment (file
);
5054 process_relocs (file
);
5056 process_symbol_table (file
);
5058 process_syminfo (file
);
5060 process_version_sections (file
);
5062 process_section_contents (file
);
5064 process_arch_specific (file
);
5068 if (section_headers
)
5070 free (section_headers
);
5071 section_headers
= NULL
;
5076 free (string_table
);
5077 string_table
= NULL
;
5080 if (dynamic_strings
)
5082 free (dynamic_strings
);
5083 dynamic_strings
= NULL
;
5086 if (dynamic_symbols
)
5088 free (dynamic_symbols
);
5089 dynamic_symbols
= NULL
;
5092 if (dynamic_syminfo
)
5094 free (dynamic_syminfo
);
5095 dynamic_syminfo
= NULL
;
5099 #ifdef SUPPORT_DISASSEMBLY
5100 /* Needed by the i386 disassembler. For extra credit, someone could
5101 fix this so that we insert symbolic addresses here, esp for GOT/PLT
5105 print_address (unsigned int addr
, FILE * outfile
)
5107 fprintf (outfile
,"0x%8.8x", addr
);
5110 /* Needed by the i386 disassembler. */
5112 db_task_printsym (unsigned int addr
)
5114 print_address (addr
, stderr
);
5123 parse_args (argc
, argv
);
5125 if (optind
< (argc
- 1))
5128 while (optind
< argc
)
5129 process_file (argv
[optind
++]);