1 /* readelf.c -- display contents of an ELF format file
2 Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4 Originally developed by Eric Youngdale <eric@andante.jic.com>
5 Modifications by Nick Clifton <nickc@redhat.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
26 #include <sys/types.h>
32 /* Define BFD64 here, even if our default architecture is 32 bit ELF
33 as this will allow us to read in and parse 64bit and 32bit ELF files.
34 Only do this if we belive that the compiler can support a 64 bit
35 data type. For now we only rely on GCC being able to do this. */
41 #include "elf/common.h"
42 #include "elf/external.h"
43 #include "elf/internal.h"
44 #include "elf/dwarf2.h"
46 /* The following headers use the elf/reloc-macros.h file to
47 automatically generate relocation recognition functions
48 such as elf_mips_reloc_type() */
50 #define RELOC_MACROS_GEN_FUNC
56 #include "elf/alpha.h"
59 #include "elf/sparc.h"
64 #include "elf/mn10200.h"
65 #include "elf/mn10300.h"
70 #include "elf/mcore.h"
78 #include "elf/x86-64.h"
80 #include "elf/xstormy16.h"
85 char * program_name
= "readelf";
86 unsigned int dynamic_addr
;
87 bfd_size_type dynamic_size
;
88 unsigned int rela_addr
;
89 unsigned int rela_size
;
90 char * dynamic_strings
;
92 unsigned long string_table_length
;
93 unsigned long num_dynamic_syms
;
94 Elf_Internal_Sym
* dynamic_symbols
;
95 Elf_Internal_Syminfo
* dynamic_syminfo
;
96 unsigned long dynamic_syminfo_offset
;
97 unsigned int dynamic_syminfo_nent
;
98 char program_interpreter
[64];
99 int dynamic_info
[DT_JMPREL
+ 1];
100 int version_info
[16];
102 Elf_Internal_Ehdr elf_header
;
103 Elf_Internal_Shdr
* section_headers
;
104 Elf_Internal_Dyn
* dynamic_segment
;
105 Elf_Internal_Shdr
* symtab_shndx_hdr
;
113 int do_using_dynamic
;
121 int do_debug_abbrevs
;
123 int do_debug_pubnames
;
124 int do_debug_aranges
;
126 int do_debug_frames_interp
;
127 int do_debug_macinfo
;
133 /* A dynamic array of flags indicating which sections require dumping. */
134 char * dump_sects
= NULL
;
135 unsigned int num_dump_sects
= 0;
137 #define HEX_DUMP (1 << 0)
138 #define DISASS_DUMP (1 << 1)
139 #define DEBUG_DUMP (1 << 2)
141 /* How to rpint a vma value. */
142 typedef enum print_mode
154 /* Forward declarations for dumb compilers. */
155 static void print_vma
PARAMS ((bfd_vma
, print_mode
));
156 static void print_symbol
PARAMS ((int, char *));
157 static bfd_vma (* byte_get
) PARAMS ((unsigned char *, int));
158 static bfd_vma byte_get_little_endian
PARAMS ((unsigned char *, int));
159 static bfd_vma byte_get_big_endian
PARAMS ((unsigned char *, int));
160 static const char * get_mips_dynamic_type
PARAMS ((unsigned long));
161 static const char * get_sparc64_dynamic_type
PARAMS ((unsigned long));
162 static const char * get_ppc64_dynamic_type
PARAMS ((unsigned long));
163 static const char * get_parisc_dynamic_type
PARAMS ((unsigned long));
164 static const char * get_dynamic_type
PARAMS ((unsigned long));
165 static int slurp_rela_relocs
PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Rela
**, unsigned long *));
166 static int slurp_rel_relocs
PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Rel
**, unsigned long *));
167 static int dump_relocations
PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Sym
*, unsigned long, char *, int));
168 static char * get_file_type
PARAMS ((unsigned));
169 static char * get_machine_name
PARAMS ((unsigned));
170 static void decode_ARM_machine_flags
PARAMS ((unsigned, char []));
171 static char * get_machine_flags
PARAMS ((unsigned, unsigned));
172 static const char * get_mips_segment_type
PARAMS ((unsigned long));
173 static const char * get_parisc_segment_type
PARAMS ((unsigned long));
174 static const char * get_ia64_segment_type
PARAMS ((unsigned long));
175 static const char * get_segment_type
PARAMS ((unsigned long));
176 static const char * get_mips_section_type_name
PARAMS ((unsigned int));
177 static const char * get_parisc_section_type_name
PARAMS ((unsigned int));
178 static const char * get_ia64_section_type_name
PARAMS ((unsigned int));
179 static const char * get_section_type_name
PARAMS ((unsigned int));
180 static const char * get_symbol_binding
PARAMS ((unsigned int));
181 static const char * get_symbol_type
PARAMS ((unsigned int));
182 static const char * get_symbol_visibility
PARAMS ((unsigned int));
183 static const char * get_symbol_index_type
PARAMS ((unsigned int));
184 static const char * get_dynamic_flags
PARAMS ((bfd_vma
));
185 static void usage
PARAMS ((void));
186 static void parse_args
PARAMS ((int, char **));
187 static int process_file_header
PARAMS ((void));
188 static int process_program_headers
PARAMS ((FILE *));
189 static int process_section_headers
PARAMS ((FILE *));
190 static int process_unwind
PARAMS ((FILE *));
191 static void dynamic_segment_mips_val
PARAMS ((Elf_Internal_Dyn
*));
192 static void dynamic_segment_parisc_val
PARAMS ((Elf_Internal_Dyn
*));
193 static int process_dynamic_segment
PARAMS ((FILE *));
194 static int process_symbol_table
PARAMS ((FILE *));
195 static int process_syminfo
PARAMS ((FILE *));
196 static int process_section_contents
PARAMS ((FILE *));
197 static void process_mips_fpe_exception
PARAMS ((int));
198 static int process_mips_specific
PARAMS ((FILE *));
199 static int process_file
PARAMS ((char *));
200 static int process_relocs
PARAMS ((FILE *));
201 static int process_version_sections
PARAMS ((FILE *));
202 static char * get_ver_flags
PARAMS ((unsigned int));
203 static int get_32bit_section_headers
PARAMS ((FILE *, unsigned int));
204 static int get_64bit_section_headers
PARAMS ((FILE *, unsigned int));
205 static int get_32bit_program_headers
PARAMS ((FILE *, Elf_Internal_Phdr
*));
206 static int get_64bit_program_headers
PARAMS ((FILE *, Elf_Internal_Phdr
*));
207 static int get_file_header
PARAMS ((FILE *));
208 static Elf_Internal_Sym
* get_32bit_elf_symbols
PARAMS ((FILE *, Elf_Internal_Shdr
*));
209 static Elf_Internal_Sym
* get_64bit_elf_symbols
PARAMS ((FILE *, Elf_Internal_Shdr
*));
210 static const char * get_elf_section_flags
PARAMS ((bfd_vma
));
211 static int * get_dynamic_data
PARAMS ((FILE *, unsigned int));
212 static int get_32bit_dynamic_segment
PARAMS ((FILE *));
213 static int get_64bit_dynamic_segment
PARAMS ((FILE *));
214 #ifdef SUPPORT_DISASSEMBLY
215 static int disassemble_section
PARAMS ((Elf32_Internal_Shdr
*, FILE *));
217 static int dump_section
PARAMS ((Elf32_Internal_Shdr
*, FILE *));
218 static int display_debug_section
PARAMS ((Elf32_Internal_Shdr
*, FILE *));
219 static int display_debug_info
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
220 static int display_debug_not_supported
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
221 static int prescan_debug_info
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
222 static int display_debug_lines
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
223 static int display_debug_pubnames
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
224 static int display_debug_abbrev
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
225 static int display_debug_aranges
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
226 static int display_debug_frames
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
227 static int display_debug_macinfo
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
228 static int display_debug_str
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
229 static unsigned char * process_abbrev_section
PARAMS ((unsigned char *, unsigned char *));
230 static void load_debug_str
PARAMS ((FILE *));
231 static void free_debug_str
PARAMS ((void));
232 static const char * fetch_indirect_string
PARAMS ((unsigned long));
233 static unsigned long read_leb128
PARAMS ((unsigned char *, int *, int));
234 static int process_extended_line_op
PARAMS ((unsigned char *, int, int));
235 static void reset_state_machine
PARAMS ((int));
236 static char * get_TAG_name
PARAMS ((unsigned long));
237 static char * get_AT_name
PARAMS ((unsigned long));
238 static char * get_FORM_name
PARAMS ((unsigned long));
239 static void free_abbrevs
PARAMS ((void));
240 static void add_abbrev
PARAMS ((unsigned long, unsigned long, int));
241 static void add_abbrev_attr
PARAMS ((unsigned long, unsigned long));
242 static unsigned char * read_and_display_attr
PARAMS ((unsigned long, unsigned long, unsigned char *, unsigned long, unsigned long));
243 static unsigned char * read_and_display_attr_value
PARAMS ((unsigned long, unsigned long, unsigned char *, unsigned long, unsigned long));
244 static unsigned char * display_block
PARAMS ((unsigned char *, unsigned long));
245 static void decode_location_expression
PARAMS ((unsigned char *, unsigned int, unsigned long));
246 static void request_dump
PARAMS ((unsigned int, int));
247 static const char * get_elf_class
PARAMS ((unsigned int));
248 static const char * get_data_encoding
PARAMS ((unsigned int));
249 static const char * get_osabi_name
PARAMS ((unsigned int));
250 static int guess_is_rela
PARAMS ((unsigned long));
251 static const char * get_note_type
PARAMS ((unsigned int));
252 static const char * get_netbsd_elfcore_note_type
PARAMS ((unsigned int));
253 static int process_note
PARAMS ((Elf32_Internal_Note
*));
254 static int process_corefile_note_segment
PARAMS ((FILE *, bfd_vma
, bfd_vma
));
255 static int process_corefile_note_segments
PARAMS ((FILE *));
256 static int process_corefile_contents
PARAMS ((FILE *));
257 static int process_arch_specific
PARAMS ((FILE *));
259 typedef int Elf32_Word
;
267 #define SECTION_NAME(X) ((X) == NULL ? "<none>" : \
268 ((X)->sh_name >= string_table_length \
269 ? "<corrupt>" : string_table + (X)->sh_name))
271 /* Given st_shndx I, map to section_headers index. */
272 #define SECTION_HEADER_INDEX(I) \
273 ((I) < SHN_LORESERVE \
275 : ((I) <= SHN_HIRESERVE \
277 : (I) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))
279 /* Reverse of the above. */
280 #define SECTION_HEADER_NUM(N) \
281 ((N) < SHN_LORESERVE \
283 : (N) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))
285 #define SECTION_HEADER(I) (section_headers + SECTION_HEADER_INDEX (I))
287 #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
289 #define BYTE_GET(field) byte_get (field, sizeof (field))
291 /* If we can support a 64 bit data type then BFD64 should be defined
292 and sizeof (bfd_vma) == 8. In this case when translating from an
293 external 8 byte field to an internal field, we can assume that the
294 internal field is also 8 bytes wide and so we can extract all the data.
295 If, however, BFD64 is not defined, then we must assume that the
296 internal data structure only has 4 byte wide fields that are the
297 equivalent of the 8 byte wide external counterparts, and so we must
298 truncate the data. */
300 #define BYTE_GET8(field) byte_get (field, -8)
302 #define BYTE_GET8(field) byte_get (field, 8)
305 #define NUM_ELEM(array) (sizeof (array) / sizeof ((array)[0]))
307 #define GET_ELF_SYMBOLS(file, section) \
308 (is_32bit_elf ? get_32bit_elf_symbols (file, section) \
309 : get_64bit_elf_symbols (file, section))
313 error
VPARAMS ((const char *message
, ...))
315 VA_OPEN (args
, message
);
316 VA_FIXEDARG (args
, const char *, message
);
318 fprintf (stderr
, _("%s: Error: "), program_name
);
319 vfprintf (stderr
, message
, args
);
324 warn
VPARAMS ((const char *message
, ...))
326 VA_OPEN (args
, message
);
327 VA_FIXEDARG (args
, const char *, message
);
329 fprintf (stderr
, _("%s: Warning: "), program_name
);
330 vfprintf (stderr
, message
, args
);
334 static PTR get_data
PARAMS ((PTR
, FILE *, long, size_t, const char *));
337 get_data (var
, file
, offset
, size
, reason
)
349 if (fseek (file
, offset
, SEEK_SET
))
351 error (_("Unable to seek to %x for %s\n"), offset
, reason
);
358 mvar
= (PTR
) malloc (size
);
362 error (_("Out of memory allocating %d bytes for %s\n"),
368 if (fread (mvar
, size
, 1, file
) != 1)
370 error (_("Unable to read in %d bytes of %s\n"), size
, reason
);
380 byte_get_little_endian (field
, size
)
381 unsigned char * field
;
390 return ((unsigned int) (field
[0]))
391 | (((unsigned int) (field
[1])) << 8);
395 /* We want to extract data from an 8 byte wide field and
396 place it into a 4 byte wide field. Since this is a little
397 endian source we can juts use the 4 byte extraction code. */
401 return ((unsigned long) (field
[0]))
402 | (((unsigned long) (field
[1])) << 8)
403 | (((unsigned long) (field
[2])) << 16)
404 | (((unsigned long) (field
[3])) << 24);
409 /* This is a special case, generated by the BYTE_GET8 macro.
410 It means that we are loading an 8 byte value from a field
411 in an external structure into an 8 byte value in a field
412 in an internal strcuture. */
413 return ((bfd_vma
) (field
[0]))
414 | (((bfd_vma
) (field
[1])) << 8)
415 | (((bfd_vma
) (field
[2])) << 16)
416 | (((bfd_vma
) (field
[3])) << 24)
417 | (((bfd_vma
) (field
[4])) << 32)
418 | (((bfd_vma
) (field
[5])) << 40)
419 | (((bfd_vma
) (field
[6])) << 48)
420 | (((bfd_vma
) (field
[7])) << 56);
423 error (_("Unhandled data length: %d\n"), size
);
428 /* Print a VMA value. */
430 print_vma (vma
, mode
)
440 case FULL_HEX
: printf ("0x"); /* drop through */
441 case LONG_HEX
: printf ("%8.8lx", (unsigned long) vma
); break;
442 case PREFIX_HEX
: printf ("0x"); /* drop through */
443 case HEX
: printf ("%lx", (unsigned long) vma
); break;
444 case DEC
: printf ("%ld", (unsigned long) vma
); break;
445 case DEC_5
: printf ("%5ld", (long) vma
); break;
446 case UNSIGNED
: printf ("%lu", (unsigned long) vma
); break;
467 #if BFD_HOST_64BIT_LONG
470 if (_bfd_int64_high (vma
))
471 printf ("%lx%8.8lx", _bfd_int64_high (vma
), _bfd_int64_low (vma
));
473 printf ("%lx", _bfd_int64_low (vma
));
478 #if BFD_HOST_64BIT_LONG
481 if (_bfd_int64_high (vma
))
483 printf ("++%ld", _bfd_int64_low (vma
));
485 printf ("%ld", _bfd_int64_low (vma
));
490 #if BFD_HOST_64BIT_LONG
491 printf ("%5ld", vma
);
493 if (_bfd_int64_high (vma
))
495 printf ("++%ld", _bfd_int64_low (vma
));
497 printf ("%5ld", _bfd_int64_low (vma
));
502 #if BFD_HOST_64BIT_LONG
505 if (_bfd_int64_high (vma
))
507 printf ("++%lu", _bfd_int64_low (vma
));
509 printf ("%lu", _bfd_int64_low (vma
));
517 /* Display a symbol on stdout. If do_wide is not true then
518 format the symbol to be at most WIDTH characters,
519 truhncating as necessary. If WIDTH is negative then
520 format the string to be exactly - WIDTH characters,
521 truncating or padding as necessary. */
524 print_symbol (width
, symbol
)
531 printf ("%-*.*s", width
, width
, symbol
);
533 printf ("%-.*s", width
, symbol
);
537 byte_get_big_endian (field
, size
)
538 unsigned char * field
;
547 return ((unsigned int) (field
[1])) | (((int) (field
[0])) << 8);
550 return ((unsigned long) (field
[3]))
551 | (((unsigned long) (field
[2])) << 8)
552 | (((unsigned long) (field
[1])) << 16)
553 | (((unsigned long) (field
[0])) << 24);
557 /* Although we are extracing data from an 8 byte wide field, we
558 are returning only 4 bytes of data. */
559 return ((unsigned long) (field
[7]))
560 | (((unsigned long) (field
[6])) << 8)
561 | (((unsigned long) (field
[5])) << 16)
562 | (((unsigned long) (field
[4])) << 24);
566 /* This is a special case, generated by the BYTE_GET8 macro.
567 It means that we are loading an 8 byte value from a field
568 in an external structure into an 8 byte value in a field
569 in an internal strcuture. */
570 return ((bfd_vma
) (field
[7]))
571 | (((bfd_vma
) (field
[6])) << 8)
572 | (((bfd_vma
) (field
[5])) << 16)
573 | (((bfd_vma
) (field
[4])) << 24)
574 | (((bfd_vma
) (field
[3])) << 32)
575 | (((bfd_vma
) (field
[2])) << 40)
576 | (((bfd_vma
) (field
[1])) << 48)
577 | (((bfd_vma
) (field
[0])) << 56);
581 error (_("Unhandled data length: %d\n"), size
);
586 /* Guess the relocation size commonly used by the specific machines. */
589 guess_is_rela (e_machine
)
590 unsigned long e_machine
;
594 /* Targets that use REL relocations. */
607 /* Targets that use RELA relocations. */
622 case EM_CYGNUS_MN10200
:
624 case EM_CYGNUS_MN10300
:
661 warn (_("Don't know about relocations on this machine architecture\n"));
667 slurp_rela_relocs (file
, rel_offset
, rel_size
, relasp
, nrelasp
)
669 unsigned long rel_offset
;
670 unsigned long rel_size
;
671 Elf_Internal_Rela
**relasp
;
672 unsigned long *nrelasp
;
674 Elf_Internal_Rela
*relas
;
675 unsigned long nrelas
;
680 Elf32_External_Rela
* erelas
;
682 erelas
= (Elf32_External_Rela
*) get_data (NULL
, file
, rel_offset
,
683 rel_size
, _("relocs"));
687 nrelas
= rel_size
/ sizeof (Elf32_External_Rela
);
689 relas
= (Elf_Internal_Rela
*)
690 malloc (nrelas
* sizeof (Elf_Internal_Rela
));
694 error(_("out of memory parsing relocs"));
698 for (i
= 0; i
< nrelas
; i
++)
700 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
701 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
702 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
709 Elf64_External_Rela
* erelas
;
711 erelas
= (Elf64_External_Rela
*) get_data (NULL
, file
, rel_offset
,
712 rel_size
, _("relocs"));
716 nrelas
= rel_size
/ sizeof (Elf64_External_Rela
);
718 relas
= (Elf_Internal_Rela
*)
719 malloc (nrelas
* sizeof (Elf_Internal_Rela
));
723 error(_("out of memory parsing relocs"));
727 for (i
= 0; i
< nrelas
; i
++)
729 relas
[i
].r_offset
= BYTE_GET8 (erelas
[i
].r_offset
);
730 relas
[i
].r_info
= BYTE_GET8 (erelas
[i
].r_info
);
731 relas
[i
].r_addend
= BYTE_GET8 (erelas
[i
].r_addend
);
742 slurp_rel_relocs (file
, rel_offset
, rel_size
, relsp
, nrelsp
)
744 unsigned long rel_offset
;
745 unsigned long rel_size
;
746 Elf_Internal_Rel
**relsp
;
747 unsigned long *nrelsp
;
749 Elf_Internal_Rel
*rels
;
755 Elf32_External_Rel
* erels
;
757 erels
= (Elf32_External_Rel
*) get_data (NULL
, file
, rel_offset
,
758 rel_size
, _("relocs"));
762 nrels
= rel_size
/ sizeof (Elf32_External_Rel
);
764 rels
= (Elf_Internal_Rel
*) malloc (nrels
* sizeof (Elf_Internal_Rel
));
768 error(_("out of memory parsing relocs"));
772 for (i
= 0; i
< nrels
; i
++)
774 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
775 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
782 Elf64_External_Rel
* erels
;
784 erels
= (Elf64_External_Rel
*) get_data (NULL
, file
, rel_offset
,
785 rel_size
, _("relocs"));
789 nrels
= rel_size
/ sizeof (Elf64_External_Rel
);
791 rels
= (Elf_Internal_Rel
*) malloc (nrels
* sizeof (Elf_Internal_Rel
));
795 error(_("out of memory parsing relocs"));
799 for (i
= 0; i
< nrels
; i
++)
801 rels
[i
].r_offset
= BYTE_GET8 (erels
[i
].r_offset
);
802 rels
[i
].r_info
= BYTE_GET8 (erels
[i
].r_info
);
812 /* Display the contents of the relocation data found at the specified offset. */
814 dump_relocations (file
, rel_offset
, rel_size
, symtab
, nsyms
, strtab
, is_rela
)
816 unsigned long rel_offset
;
817 unsigned long rel_size
;
818 Elf_Internal_Sym
* symtab
;
824 Elf_Internal_Rel
* rels
;
825 Elf_Internal_Rela
* relas
;
828 if (is_rela
== UNKNOWN
)
829 is_rela
= guess_is_rela (elf_header
.e_machine
);
833 if (!slurp_rela_relocs (file
, rel_offset
, rel_size
, &relas
, &rel_size
))
838 if (!slurp_rel_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
846 (_(" Offset Info Type Symbol's Value Symbol's Name Addend\n"));
849 (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
855 (_(" Offset Info Type Symbol's Value Symbol's Name Addend\n"));
858 (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
861 for (i
= 0; i
< rel_size
; i
++)
866 bfd_vma symtab_index
;
871 offset
= relas
[i
].r_offset
;
872 info
= relas
[i
].r_info
;
876 offset
= rels
[i
].r_offset
;
877 info
= rels
[i
].r_info
;
882 type
= ELF32_R_TYPE (info
);
883 symtab_index
= ELF32_R_SYM (info
);
887 if (elf_header
.e_machine
== EM_SPARCV9
)
888 type
= ELF64_R_TYPE_ID (info
);
890 type
= ELF64_R_TYPE (info
);
891 /* The #ifdef BFD64 below is to prevent a compile time warning.
892 We know that if we do not have a 64 bit data type that we
893 will never execute this code anyway. */
895 symtab_index
= ELF64_R_SYM (info
);
901 #ifdef _bfd_int64_low
902 printf ("%8.8lx %8.8lx ", _bfd_int64_low (offset
), _bfd_int64_low (info
));
904 printf ("%8.8lx %8.8lx ", offset
, info
);
909 #ifdef _bfd_int64_low
910 printf ("%8.8lx%8.8lx %8.8lx%8.8lx ",
911 _bfd_int64_high (offset
),
912 _bfd_int64_low (offset
),
913 _bfd_int64_high (info
),
914 _bfd_int64_low (info
));
916 printf ("%16.16lx %16.16lx ", offset
, info
);
920 switch (elf_header
.e_machine
)
928 rtype
= elf_m32r_reloc_type (type
);
933 rtype
= elf_i386_reloc_type (type
);
937 rtype
= elf_m68k_reloc_type (type
);
941 rtype
= elf_i960_reloc_type (type
);
946 rtype
= elf_avr_reloc_type (type
);
953 rtype
= elf_sparc_reloc_type (type
);
958 rtype
= v850_reloc_type (type
);
963 rtype
= elf_d10v_reloc_type (type
);
968 rtype
= elf_d30v_reloc_type (type
);
972 rtype
= elf_sh_reloc_type (type
);
976 case EM_CYGNUS_MN10300
:
977 rtype
= elf_mn10300_reloc_type (type
);
981 case EM_CYGNUS_MN10200
:
982 rtype
= elf_mn10200_reloc_type (type
);
987 rtype
= elf_fr30_reloc_type (type
);
991 rtype
= elf_mcore_reloc_type (type
);
995 rtype
= elf_mmix_reloc_type (type
);
1000 rtype
= elf_ppc_reloc_type (type
);
1004 case EM_MIPS_RS3_LE
:
1005 rtype
= elf_mips_reloc_type (type
);
1009 rtype
= elf_alpha_reloc_type (type
);
1013 rtype
= elf_arm_reloc_type (type
);
1017 rtype
= elf_arc_reloc_type (type
);
1021 rtype
= elf_hppa_reloc_type (type
);
1027 rtype
= elf_h8_reloc_type (type
);
1032 rtype
= elf_pj_reloc_type (type
);
1035 rtype
= elf_ia64_reloc_type (type
);
1039 rtype
= elf_cris_reloc_type (type
);
1043 rtype
= elf_i860_reloc_type (type
);
1047 rtype
= elf_x86_64_reloc_type (type
);
1052 rtype
= elf_s390_reloc_type (type
);
1056 rtype
= elf_xstormy16_reloc_type (type
);
1061 #ifdef _bfd_int64_low
1062 printf (_("unrecognised: %-7lx"), _bfd_int64_low (type
));
1064 printf (_("unrecognised: %-7lx"), type
);
1067 printf ("%-21.21s", rtype
);
1071 if (symtab
== NULL
|| symtab_index
>= nsyms
)
1072 printf (" bad symbol index: %08lx", (unsigned long) symtab_index
);
1075 Elf_Internal_Sym
* psym
;
1077 psym
= symtab
+ symtab_index
;
1080 print_vma (psym
->st_value
, LONG_HEX
);
1083 if (psym
->st_name
== 0)
1084 print_symbol (-25, SECTION_NAME (section_headers
+ psym
->st_shndx
));
1085 else if (strtab
== NULL
)
1086 printf (_("<string table index %3ld>"), psym
->st_name
);
1088 print_symbol (-25, strtab
+ psym
->st_name
);
1091 printf (" + %lx", (unsigned long) relas
[i
].r_addend
);
1096 printf ("%*c", is_32bit_elf
? 34 : 26, ' ');
1097 print_vma (relas
[i
].r_addend
, LONG_HEX
);
1100 if (elf_header
.e_machine
== EM_SPARCV9
1101 && !strcmp (rtype
, "R_SPARC_OLO10"))
1102 printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (info
));
1116 get_mips_dynamic_type (type
)
1121 case DT_MIPS_RLD_VERSION
: return "MIPS_RLD_VERSION";
1122 case DT_MIPS_TIME_STAMP
: return "MIPS_TIME_STAMP";
1123 case DT_MIPS_ICHECKSUM
: return "MIPS_ICHECKSUM";
1124 case DT_MIPS_IVERSION
: return "MIPS_IVERSION";
1125 case DT_MIPS_FLAGS
: return "MIPS_FLAGS";
1126 case DT_MIPS_BASE_ADDRESS
: return "MIPS_BASE_ADDRESS";
1127 case DT_MIPS_MSYM
: return "MIPS_MSYM";
1128 case DT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
1129 case DT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
1130 case DT_MIPS_LOCAL_GOTNO
: return "MIPS_LOCAL_GOTNO";
1131 case DT_MIPS_CONFLICTNO
: return "MIPS_CONFLICTNO";
1132 case DT_MIPS_LIBLISTNO
: return "MIPS_LIBLISTNO";
1133 case DT_MIPS_SYMTABNO
: return "MIPS_SYMTABNO";
1134 case DT_MIPS_UNREFEXTNO
: return "MIPS_UNREFEXTNO";
1135 case DT_MIPS_GOTSYM
: return "MIPS_GOTSYM";
1136 case DT_MIPS_HIPAGENO
: return "MIPS_HIPAGENO";
1137 case DT_MIPS_RLD_MAP
: return "MIPS_RLD_MAP";
1138 case DT_MIPS_DELTA_CLASS
: return "MIPS_DELTA_CLASS";
1139 case DT_MIPS_DELTA_CLASS_NO
: return "MIPS_DELTA_CLASS_NO";
1140 case DT_MIPS_DELTA_INSTANCE
: return "MIPS_DELTA_INSTANCE";
1141 case DT_MIPS_DELTA_INSTANCE_NO
: return "MIPS_DELTA_INSTANCE_NO";
1142 case DT_MIPS_DELTA_RELOC
: return "MIPS_DELTA_RELOC";
1143 case DT_MIPS_DELTA_RELOC_NO
: return "MIPS_DELTA_RELOC_NO";
1144 case DT_MIPS_DELTA_SYM
: return "MIPS_DELTA_SYM";
1145 case DT_MIPS_DELTA_SYM_NO
: return "MIPS_DELTA_SYM_NO";
1146 case DT_MIPS_DELTA_CLASSSYM
: return "MIPS_DELTA_CLASSSYM";
1147 case DT_MIPS_DELTA_CLASSSYM_NO
: return "MIPS_DELTA_CLASSSYM_NO";
1148 case DT_MIPS_CXX_FLAGS
: return "MIPS_CXX_FLAGS";
1149 case DT_MIPS_PIXIE_INIT
: return "MIPS_PIXIE_INIT";
1150 case DT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
1151 case DT_MIPS_LOCALPAGE_GOTIDX
: return "MIPS_LOCALPAGE_GOTIDX";
1152 case DT_MIPS_LOCAL_GOTIDX
: return "MIPS_LOCAL_GOTIDX";
1153 case DT_MIPS_HIDDEN_GOTIDX
: return "MIPS_HIDDEN_GOTIDX";
1154 case DT_MIPS_PROTECTED_GOTIDX
: return "MIPS_PROTECTED_GOTIDX";
1155 case DT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
1156 case DT_MIPS_INTERFACE
: return "MIPS_INTERFACE";
1157 case DT_MIPS_DYNSTR_ALIGN
: return "MIPS_DYNSTR_ALIGN";
1158 case DT_MIPS_INTERFACE_SIZE
: return "MIPS_INTERFACE_SIZE";
1159 case DT_MIPS_RLD_TEXT_RESOLVE_ADDR
: return "MIPS_RLD_TEXT_RESOLVE_ADDR";
1160 case DT_MIPS_PERF_SUFFIX
: return "MIPS_PERF_SUFFIX";
1161 case DT_MIPS_COMPACT_SIZE
: return "MIPS_COMPACT_SIZE";
1162 case DT_MIPS_GP_VALUE
: return "MIPS_GP_VALUE";
1163 case DT_MIPS_AUX_DYNAMIC
: return "MIPS_AUX_DYNAMIC";
1170 get_sparc64_dynamic_type (type
)
1175 case DT_SPARC_REGISTER
: return "SPARC_REGISTER";
1182 get_ppc64_dynamic_type (type
)
1187 case DT_PPC64_GLINK
: return "PPC64_GLINK";
1194 get_parisc_dynamic_type (type
)
1199 case DT_HP_LOAD_MAP
: return "HP_LOAD_MAP";
1200 case DT_HP_DLD_FLAGS
: return "HP_DLD_FLAGS";
1201 case DT_HP_DLD_HOOK
: return "HP_DLD_HOOK";
1202 case DT_HP_UX10_INIT
: return "HP_UX10_INIT";
1203 case DT_HP_UX10_INITSZ
: return "HP_UX10_INITSZ";
1204 case DT_HP_PREINIT
: return "HP_PREINIT";
1205 case DT_HP_PREINITSZ
: return "HP_PREINITSZ";
1206 case DT_HP_NEEDED
: return "HP_NEEDED";
1207 case DT_HP_TIME_STAMP
: return "HP_TIME_STAMP";
1208 case DT_HP_CHECKSUM
: return "HP_CHECKSUM";
1209 case DT_HP_GST_SIZE
: return "HP_GST_SIZE";
1210 case DT_HP_GST_VERSION
: return "HP_GST_VERSION";
1211 case DT_HP_GST_HASHVAL
: return "HP_GST_HASHVAL";
1218 get_dynamic_type (type
)
1221 static char buff
[32];
1225 case DT_NULL
: return "NULL";
1226 case DT_NEEDED
: return "NEEDED";
1227 case DT_PLTRELSZ
: return "PLTRELSZ";
1228 case DT_PLTGOT
: return "PLTGOT";
1229 case DT_HASH
: return "HASH";
1230 case DT_STRTAB
: return "STRTAB";
1231 case DT_SYMTAB
: return "SYMTAB";
1232 case DT_RELA
: return "RELA";
1233 case DT_RELASZ
: return "RELASZ";
1234 case DT_RELAENT
: return "RELAENT";
1235 case DT_STRSZ
: return "STRSZ";
1236 case DT_SYMENT
: return "SYMENT";
1237 case DT_INIT
: return "INIT";
1238 case DT_FINI
: return "FINI";
1239 case DT_SONAME
: return "SONAME";
1240 case DT_RPATH
: return "RPATH";
1241 case DT_SYMBOLIC
: return "SYMBOLIC";
1242 case DT_REL
: return "REL";
1243 case DT_RELSZ
: return "RELSZ";
1244 case DT_RELENT
: return "RELENT";
1245 case DT_PLTREL
: return "PLTREL";
1246 case DT_DEBUG
: return "DEBUG";
1247 case DT_TEXTREL
: return "TEXTREL";
1248 case DT_JMPREL
: return "JMPREL";
1249 case DT_BIND_NOW
: return "BIND_NOW";
1250 case DT_INIT_ARRAY
: return "INIT_ARRAY";
1251 case DT_FINI_ARRAY
: return "FINI_ARRAY";
1252 case DT_INIT_ARRAYSZ
: return "INIT_ARRAYSZ";
1253 case DT_FINI_ARRAYSZ
: return "FINI_ARRAYSZ";
1254 case DT_RUNPATH
: return "RUNPATH";
1255 case DT_FLAGS
: return "FLAGS";
1257 case DT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
1258 case DT_PREINIT_ARRAYSZ
: return "PREINIT_ARRAYSZ";
1260 case DT_CHECKSUM
: return "CHECKSUM";
1261 case DT_PLTPADSZ
: return "PLTPADSZ";
1262 case DT_MOVEENT
: return "MOVEENT";
1263 case DT_MOVESZ
: return "MOVESZ";
1264 case DT_FEATURE
: return "FEATURE";
1265 case DT_POSFLAG_1
: return "POSFLAG_1";
1266 case DT_SYMINSZ
: return "SYMINSZ";
1267 case DT_SYMINENT
: return "SYMINENT"; /* aka VALRNGHI */
1269 case DT_ADDRRNGLO
: return "ADDRRNGLO";
1270 case DT_CONFIG
: return "CONFIG";
1271 case DT_DEPAUDIT
: return "DEPAUDIT";
1272 case DT_AUDIT
: return "AUDIT";
1273 case DT_PLTPAD
: return "PLTPAD";
1274 case DT_MOVETAB
: return "MOVETAB";
1275 case DT_SYMINFO
: return "SYMINFO"; /* aka ADDRRNGHI */
1277 case DT_VERSYM
: return "VERSYM";
1279 case DT_RELACOUNT
: return "RELACOUNT";
1280 case DT_RELCOUNT
: return "RELCOUNT";
1281 case DT_FLAGS_1
: return "FLAGS_1";
1282 case DT_VERDEF
: return "VERDEF";
1283 case DT_VERDEFNUM
: return "VERDEFNUM";
1284 case DT_VERNEED
: return "VERNEED";
1285 case DT_VERNEEDNUM
: return "VERNEEDNUM";
1287 case DT_AUXILIARY
: return "AUXILIARY";
1288 case DT_USED
: return "USED";
1289 case DT_FILTER
: return "FILTER";
1292 if ((type
>= DT_LOPROC
) && (type
<= DT_HIPROC
))
1294 const char * result
;
1296 switch (elf_header
.e_machine
)
1299 case EM_MIPS_RS3_LE
:
1300 result
= get_mips_dynamic_type (type
);
1303 result
= get_sparc64_dynamic_type (type
);
1306 result
= get_ppc64_dynamic_type (type
);
1316 sprintf (buff
, _("Processor Specific: %lx"), type
);
1318 else if ((type
>= DT_LOOS
) && (type
<= DT_HIOS
))
1320 const char * result
;
1322 switch (elf_header
.e_machine
)
1325 result
= get_parisc_dynamic_type (type
);
1335 sprintf (buff
, _("Operating System specific: %lx"), type
);
1338 sprintf (buff
, _("<unknown>: %lx"), type
);
1345 get_file_type (e_type
)
1348 static char buff
[32];
1352 case ET_NONE
: return _("NONE (None)");
1353 case ET_REL
: return _("REL (Relocatable file)");
1354 case ET_EXEC
: return _("EXEC (Executable file)");
1355 case ET_DYN
: return _("DYN (Shared object file)");
1356 case ET_CORE
: return _("CORE (Core file)");
1359 if ((e_type
>= ET_LOPROC
) && (e_type
<= ET_HIPROC
))
1360 sprintf (buff
, _("Processor Specific: (%x)"), e_type
);
1361 else if ((e_type
>= ET_LOOS
) && (e_type
<= ET_HIOS
))
1362 sprintf (buff
, _("OS Specific: (%x)"), e_type
);
1364 sprintf (buff
, _("<unknown>: %x"), e_type
);
1370 get_machine_name (e_machine
)
1373 static char buff
[64]; /* XXX */
1377 case EM_NONE
: return _("None");
1378 case EM_M32
: return "WE32100";
1379 case EM_SPARC
: return "Sparc";
1380 case EM_386
: return "Intel 80386";
1381 case EM_68K
: return "MC68000";
1382 case EM_88K
: return "MC88000";
1383 case EM_486
: return "Intel 80486";
1384 case EM_860
: return "Intel 80860";
1385 case EM_MIPS
: return "MIPS R3000";
1386 case EM_S370
: return "IBM System/370";
1387 case EM_MIPS_RS3_LE
: return "MIPS R4000 big-endian";
1388 case EM_OLD_SPARCV9
: return "Sparc v9 (old)";
1389 case EM_PARISC
: return "HPPA";
1390 case EM_PPC_OLD
: return "Power PC (old)";
1391 case EM_SPARC32PLUS
: return "Sparc v8+" ;
1392 case EM_960
: return "Intel 90860";
1393 case EM_PPC
: return "PowerPC";
1394 case EM_PPC64
: return "PowerPC64";
1395 case EM_V800
: return "NEC V800";
1396 case EM_FR20
: return "Fujitsu FR20";
1397 case EM_RH32
: return "TRW RH32";
1398 case EM_MCORE
: return "MCORE";
1399 case EM_ARM
: return "ARM";
1400 case EM_OLD_ALPHA
: return "Digital Alpha (old)";
1401 case EM_SH
: return "Hitachi SH";
1402 case EM_SPARCV9
: return "Sparc v9";
1403 case EM_TRICORE
: return "Siemens Tricore";
1404 case EM_ARC
: return "ARC";
1405 case EM_H8_300
: return "Hitachi H8/300";
1406 case EM_H8_300H
: return "Hitachi H8/300H";
1407 case EM_H8S
: return "Hitachi H8S";
1408 case EM_H8_500
: return "Hitachi H8/500";
1409 case EM_IA_64
: return "Intel IA-64";
1410 case EM_MIPS_X
: return "Stanford MIPS-X";
1411 case EM_COLDFIRE
: return "Motorola Coldfire";
1412 case EM_68HC12
: return "Motorola M68HC12";
1413 case EM_ALPHA
: return "Alpha";
1414 case EM_CYGNUS_D10V
:
1415 case EM_D10V
: return "d10v";
1416 case EM_CYGNUS_D30V
:
1417 case EM_D30V
: return "d30v";
1418 case EM_CYGNUS_M32R
:
1419 case EM_M32R
: return "Mitsubishi M32r";
1420 case EM_CYGNUS_V850
:
1421 case EM_V850
: return "NEC v850";
1422 case EM_CYGNUS_MN10300
:
1423 case EM_MN10300
: return "mn10300";
1424 case EM_CYGNUS_MN10200
:
1425 case EM_MN10200
: return "mn10200";
1426 case EM_CYGNUS_FR30
:
1427 case EM_FR30
: return "Fujitsu FR30";
1429 case EM_PJ
: return "picoJava";
1430 case EM_MMA
: return "Fujitsu Multimedia Accelerator";
1431 case EM_PCP
: return "Siemens PCP";
1432 case EM_NCPU
: return "Sony nCPU embedded RISC processor";
1433 case EM_NDR1
: return "Denso NDR1 microprocesspr";
1434 case EM_STARCORE
: return "Motorola Star*Core processor";
1435 case EM_ME16
: return "Toyota ME16 processor";
1436 case EM_ST100
: return "STMicroelectronics ST100 processor";
1437 case EM_TINYJ
: return "Advanced Logic Corp. TinyJ embedded processor";
1438 case EM_FX66
: return "Siemens FX66 microcontroller";
1439 case EM_ST9PLUS
: return "STMicroelectronics ST9+ 8/16 bit microcontroller";
1440 case EM_ST7
: return "STMicroelectronics ST7 8-bit microcontroller";
1441 case EM_68HC16
: return "Motorola MC68HC16 Microcontroller";
1442 case EM_68HC11
: return "Motorola MC68HC11 Microcontroller";
1443 case EM_68HC08
: return "Motorola MC68HC08 Microcontroller";
1444 case EM_68HC05
: return "Motorola MC68HC05 Microcontroller";
1445 case EM_SVX
: return "Silicon Graphics SVx";
1446 case EM_ST19
: return "STMicroelectronics ST19 8-bit microcontroller";
1447 case EM_VAX
: return "Digital VAX";
1449 case EM_AVR
: return "Atmel AVR 8-bit microcontroller";
1450 case EM_CRIS
: return "Axis Communications 32-bit embedded processor";
1451 case EM_JAVELIN
: return "Infineon Technologies 32-bit embedded cpu";
1452 case EM_FIREPATH
: return "Element 14 64-bit DSP processor";
1453 case EM_ZSP
: return "LSI Logic's 16-bit DSP processor";
1454 case EM_MMIX
: return "Donald Knuth's educational 64-bit processor";
1455 case EM_HUANY
: return "Harvard Universitys's machine-independent object format";
1456 case EM_PRISM
: return "SiTera Prism";
1457 case EM_X86_64
: return "Advanced Micro Devices X86-64";
1459 case EM_S390
: return "IBM S/390";
1460 case EM_XSTORMY16
: return "Sanyo Xstormy16 CPU core";
1462 sprintf (buff
, _("<unknown>: %x"), e_machine
);
1468 decode_ARM_machine_flags (e_flags
, buf
)
1475 eabi
= EF_ARM_EABI_VERSION (e_flags
);
1476 e_flags
&= ~ EF_ARM_EABIMASK
;
1478 /* Handle "generic" ARM flags. */
1479 if (e_flags
& EF_ARM_RELEXEC
)
1481 strcat (buf
, ", relocatable executable");
1482 e_flags
&= ~ EF_ARM_RELEXEC
;
1485 if (e_flags
& EF_ARM_HASENTRY
)
1487 strcat (buf
, ", has entry point");
1488 e_flags
&= ~ EF_ARM_HASENTRY
;
1491 /* Now handle EABI specific flags. */
1495 strcat (buf
, ", <unrecognised EABI>");
1500 case EF_ARM_EABI_VER1
:
1501 strcat (buf
, ", Version1 EABI");
1506 /* Process flags one bit at a time. */
1507 flag
= e_flags
& - e_flags
;
1512 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1513 strcat (buf
, ", sorted symbol tables");
1523 case EF_ARM_EABI_VER2
:
1524 strcat (buf
, ", Version2 EABI");
1529 /* Process flags one bit at a time. */
1530 flag
= e_flags
& - e_flags
;
1535 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1536 strcat (buf
, ", sorted symbol tables");
1539 case EF_ARM_DYNSYMSUSESEGIDX
:
1540 strcat (buf
, ", dynamic symbols use segment index");
1543 case EF_ARM_MAPSYMSFIRST
:
1544 strcat (buf
, ", mapping symbols precede others");
1554 case EF_ARM_EABI_UNKNOWN
:
1555 strcat (buf
, ", GNU EABI");
1560 /* Process flags one bit at a time. */
1561 flag
= e_flags
& - e_flags
;
1566 case EF_ARM_INTERWORK
:
1567 strcat (buf
, ", interworking enabled");
1570 case EF_ARM_APCS_26
:
1571 strcat (buf
, ", uses APCS/26");
1574 case EF_ARM_APCS_FLOAT
:
1575 strcat (buf
, ", uses APCS/float");
1579 strcat (buf
, ", position independent");
1583 strcat (buf
, ", 8 bit structure alignment");
1586 case EF_ARM_NEW_ABI
:
1587 strcat (buf
, ", uses new ABI");
1590 case EF_ARM_OLD_ABI
:
1591 strcat (buf
, ", uses old ABI");
1594 case EF_ARM_SOFT_FLOAT
:
1595 strcat (buf
, ", software FP");
1606 strcat (buf
,", <unknown>");
1610 get_machine_flags (e_flags
, e_machine
)
1614 static char buf
[1024];
1626 decode_ARM_machine_flags (e_flags
, buf
);
1630 if (e_flags
& EF_CPU32
)
1631 strcat (buf
, ", cpu32");
1635 if (e_flags
& EF_PPC_EMB
)
1636 strcat (buf
, ", emb");
1638 if (e_flags
& EF_PPC_RELOCATABLE
)
1639 strcat (buf
, ", relocatable");
1641 if (e_flags
& EF_PPC_RELOCATABLE_LIB
)
1642 strcat (buf
, ", relocatable-lib");
1646 case EM_CYGNUS_V850
:
1647 switch (e_flags
& EF_V850_ARCH
)
1650 strcat (buf
, ", v850e");
1653 strcat (buf
, ", v850ea");
1656 strcat (buf
, ", v850");
1659 strcat (buf
, ", unknown v850 architecture variant");
1665 case EM_CYGNUS_M32R
:
1666 if ((e_flags
& EF_M32R_ARCH
) == E_M32R_ARCH
)
1667 strcat (buf
, ", m32r");
1672 case EM_MIPS_RS3_LE
:
1673 if (e_flags
& EF_MIPS_NOREORDER
)
1674 strcat (buf
, ", noreorder");
1676 if (e_flags
& EF_MIPS_PIC
)
1677 strcat (buf
, ", pic");
1679 if (e_flags
& EF_MIPS_CPIC
)
1680 strcat (buf
, ", cpic");
1682 if (e_flags
& EF_MIPS_UCODE
)
1683 strcat (buf
, ", ugen_reserved");
1685 if (e_flags
& EF_MIPS_ABI2
)
1686 strcat (buf
, ", abi2");
1688 if (e_flags
& EF_MIPS_OPTIONS_FIRST
)
1689 strcat (buf
, ", odk first");
1691 if (e_flags
& EF_MIPS_32BITMODE
)
1692 strcat (buf
, ", 32bitmode");
1694 switch ((e_flags
& EF_MIPS_MACH
))
1696 case E_MIPS_MACH_3900
: strcat (buf
, ", 3900"); break;
1697 case E_MIPS_MACH_4010
: strcat (buf
, ", 4010"); break;
1698 case E_MIPS_MACH_4100
: strcat (buf
, ", 4100"); break;
1699 case E_MIPS_MACH_4650
: strcat (buf
, ", 4650"); break;
1700 case E_MIPS_MACH_4111
: strcat (buf
, ", 4111"); break;
1701 case E_MIPS_MACH_SB1
: strcat (buf
, ", sb1"); break;
1703 /* We simply ignore the field in this case to avoid confusion:
1704 MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
1707 default: strcat (buf
, ", unknown CPU"); break;
1710 switch ((e_flags
& EF_MIPS_ABI
))
1712 case E_MIPS_ABI_O32
: strcat (buf
, ", o32"); break;
1713 case E_MIPS_ABI_O64
: strcat (buf
, ", o64"); break;
1714 case E_MIPS_ABI_EABI32
: strcat (buf
, ", eabi32"); break;
1715 case E_MIPS_ABI_EABI64
: strcat (buf
, ", eabi64"); break;
1717 /* We simply ignore the field in this case to avoid confusion:
1718 MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension.
1719 This means it is likely to be an o32 file, but not for
1722 default: strcat (buf
, ", unknown ABI"); break;
1725 if (e_flags
& EF_MIPS_ARCH_ASE_MDMX
)
1726 strcat (buf
, ", mdmx");
1728 if (e_flags
& EF_MIPS_ARCH_ASE_M16
)
1729 strcat (buf
, ", mips16");
1731 switch ((e_flags
& EF_MIPS_ARCH
))
1733 case E_MIPS_ARCH_1
: strcat (buf
, ", mips1"); break;
1734 case E_MIPS_ARCH_2
: strcat (buf
, ", mips2"); break;
1735 case E_MIPS_ARCH_3
: strcat (buf
, ", mips3"); break;
1736 case E_MIPS_ARCH_4
: strcat (buf
, ", mips4"); break;
1737 case E_MIPS_ARCH_5
: strcat (buf
, ", mips5"); break;
1738 case E_MIPS_ARCH_32
: strcat (buf
, ", mips32"); break;
1739 case E_MIPS_ARCH_64
: strcat (buf
, ", mips64"); break;
1740 default: strcat (buf
, ", unknown ISA"); break;
1746 if (e_flags
& EF_SPARC_32PLUS
)
1747 strcat (buf
, ", v8+");
1749 if (e_flags
& EF_SPARC_SUN_US1
)
1750 strcat (buf
, ", ultrasparcI");
1752 if (e_flags
& EF_SPARC_SUN_US3
)
1753 strcat (buf
, ", ultrasparcIII");
1755 if (e_flags
& EF_SPARC_HAL_R1
)
1756 strcat (buf
, ", halr1");
1758 if (e_flags
& EF_SPARC_LEDATA
)
1759 strcat (buf
, ", ledata");
1761 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_TSO
)
1762 strcat (buf
, ", tso");
1764 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_PSO
)
1765 strcat (buf
, ", pso");
1767 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_RMO
)
1768 strcat (buf
, ", rmo");
1772 switch (e_flags
& EF_PARISC_ARCH
)
1774 case EFA_PARISC_1_0
:
1775 strcpy (buf
, ", PA-RISC 1.0");
1777 case EFA_PARISC_1_1
:
1778 strcpy (buf
, ", PA-RISC 1.1");
1780 case EFA_PARISC_2_0
:
1781 strcpy (buf
, ", PA-RISC 2.0");
1786 if (e_flags
& EF_PARISC_TRAPNIL
)
1787 strcat (buf
, ", trapnil");
1788 if (e_flags
& EF_PARISC_EXT
)
1789 strcat (buf
, ", ext");
1790 if (e_flags
& EF_PARISC_LSB
)
1791 strcat (buf
, ", lsb");
1792 if (e_flags
& EF_PARISC_WIDE
)
1793 strcat (buf
, ", wide");
1794 if (e_flags
& EF_PARISC_NO_KABP
)
1795 strcat (buf
, ", no kabp");
1796 if (e_flags
& EF_PARISC_LAZYSWAP
)
1797 strcat (buf
, ", lazyswap");
1802 if ((e_flags
& EF_PICOJAVA_NEWCALLS
) == EF_PICOJAVA_NEWCALLS
)
1803 strcat (buf
, ", new calling convention");
1805 if ((e_flags
& EF_PICOJAVA_GNUCALLS
) == EF_PICOJAVA_GNUCALLS
)
1806 strcat (buf
, ", gnu calling convention");
1810 if ((e_flags
& EF_IA_64_ABI64
))
1811 strcat (buf
, ", 64-bit");
1813 strcat (buf
, ", 32-bit");
1814 if ((e_flags
& EF_IA_64_REDUCEDFP
))
1815 strcat (buf
, ", reduced fp model");
1816 if ((e_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
))
1817 strcat (buf
, ", no function descriptors, constant gp");
1818 else if ((e_flags
& EF_IA_64_CONS_GP
))
1819 strcat (buf
, ", constant gp");
1820 if ((e_flags
& EF_IA_64_ABSOLUTE
))
1821 strcat (buf
, ", absolute");
1830 get_mips_segment_type (type
)
1835 case PT_MIPS_REGINFO
:
1837 case PT_MIPS_RTPROC
:
1839 case PT_MIPS_OPTIONS
:
1849 get_parisc_segment_type (type
)
1854 case PT_HP_TLS
: return "HP_TLS";
1855 case PT_HP_CORE_NONE
: return "HP_CORE_NONE";
1856 case PT_HP_CORE_VERSION
: return "HP_CORE_VERSION";
1857 case PT_HP_CORE_KERNEL
: return "HP_CORE_KERNEL";
1858 case PT_HP_CORE_COMM
: return "HP_CORE_COMM";
1859 case PT_HP_CORE_PROC
: return "HP_CORE_PROC";
1860 case PT_HP_CORE_LOADABLE
: return "HP_CORE_LOADABLE";
1861 case PT_HP_CORE_STACK
: return "HP_CORE_STACK";
1862 case PT_HP_CORE_SHM
: return "HP_CORE_SHM";
1863 case PT_HP_CORE_MMF
: return "HP_CORE_MMF";
1864 case PT_HP_PARALLEL
: return "HP_PARALLEL";
1865 case PT_HP_FASTBIND
: return "HP_FASTBIND";
1866 case PT_PARISC_ARCHEXT
: return "PARISC_ARCHEXT";
1867 case PT_PARISC_UNWIND
: return "PARISC_UNWIND";
1876 get_ia64_segment_type (type
)
1881 case PT_IA_64_ARCHEXT
: return "IA_64_ARCHEXT";
1882 case PT_IA_64_UNWIND
: return "IA_64_UNWIND";
1883 case PT_HP_TLS
: return "HP_TLS";
1884 case PT_IA_64_HP_OPT_ANOT
: return "HP_OPT_ANNOT";
1885 case PT_IA_64_HP_HSL_ANOT
: return "HP_HSL_ANNOT";
1886 case PT_IA_64_HP_STACK
: return "HP_STACK";
1895 get_segment_type (p_type
)
1896 unsigned long p_type
;
1898 static char buff
[32];
1902 case PT_NULL
: return "NULL";
1903 case PT_LOAD
: return "LOAD";
1904 case PT_DYNAMIC
: return "DYNAMIC";
1905 case PT_INTERP
: return "INTERP";
1906 case PT_NOTE
: return "NOTE";
1907 case PT_SHLIB
: return "SHLIB";
1908 case PT_PHDR
: return "PHDR";
1910 case PT_GNU_EH_FRAME
:
1911 return "GNU_EH_FRAME";
1914 if ((p_type
>= PT_LOPROC
) && (p_type
<= PT_HIPROC
))
1916 const char * result
;
1918 switch (elf_header
.e_machine
)
1921 case EM_MIPS_RS3_LE
:
1922 result
= get_mips_segment_type (p_type
);
1925 result
= get_parisc_segment_type (p_type
);
1928 result
= get_ia64_segment_type (p_type
);
1938 sprintf (buff
, "LOPROC+%lx", p_type
- PT_LOPROC
);
1940 else if ((p_type
>= PT_LOOS
) && (p_type
<= PT_HIOS
))
1942 const char * result
;
1944 switch (elf_header
.e_machine
)
1947 result
= get_parisc_segment_type (p_type
);
1950 result
= get_ia64_segment_type (p_type
);
1960 sprintf (buff
, "LOOS+%lx", p_type
- PT_LOOS
);
1963 sprintf (buff
, _("<unknown>: %lx"), p_type
);
1970 get_mips_section_type_name (sh_type
)
1971 unsigned int sh_type
;
1975 case SHT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
1976 case SHT_MIPS_MSYM
: return "MIPS_MSYM";
1977 case SHT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
1978 case SHT_MIPS_GPTAB
: return "MIPS_GPTAB";
1979 case SHT_MIPS_UCODE
: return "MIPS_UCODE";
1980 case SHT_MIPS_DEBUG
: return "MIPS_DEBUG";
1981 case SHT_MIPS_REGINFO
: return "MIPS_REGINFO";
1982 case SHT_MIPS_PACKAGE
: return "MIPS_PACKAGE";
1983 case SHT_MIPS_PACKSYM
: return "MIPS_PACKSYM";
1984 case SHT_MIPS_RELD
: return "MIPS_RELD";
1985 case SHT_MIPS_IFACE
: return "MIPS_IFACE";
1986 case SHT_MIPS_CONTENT
: return "MIPS_CONTENT";
1987 case SHT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
1988 case SHT_MIPS_SHDR
: return "MIPS_SHDR";
1989 case SHT_MIPS_FDESC
: return "MIPS_FDESC";
1990 case SHT_MIPS_EXTSYM
: return "MIPS_EXTSYM";
1991 case SHT_MIPS_DENSE
: return "MIPS_DENSE";
1992 case SHT_MIPS_PDESC
: return "MIPS_PDESC";
1993 case SHT_MIPS_LOCSYM
: return "MIPS_LOCSYM";
1994 case SHT_MIPS_AUXSYM
: return "MIPS_AUXSYM";
1995 case SHT_MIPS_OPTSYM
: return "MIPS_OPTSYM";
1996 case SHT_MIPS_LOCSTR
: return "MIPS_LOCSTR";
1997 case SHT_MIPS_LINE
: return "MIPS_LINE";
1998 case SHT_MIPS_RFDESC
: return "MIPS_RFDESC";
1999 case SHT_MIPS_DELTASYM
: return "MIPS_DELTASYM";
2000 case SHT_MIPS_DELTAINST
: return "MIPS_DELTAINST";
2001 case SHT_MIPS_DELTACLASS
: return "MIPS_DELTACLASS";
2002 case SHT_MIPS_DWARF
: return "MIPS_DWARF";
2003 case SHT_MIPS_DELTADECL
: return "MIPS_DELTADECL";
2004 case SHT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
2005 case SHT_MIPS_EVENTS
: return "MIPS_EVENTS";
2006 case SHT_MIPS_TRANSLATE
: return "MIPS_TRANSLATE";
2007 case SHT_MIPS_PIXIE
: return "MIPS_PIXIE";
2008 case SHT_MIPS_XLATE
: return "MIPS_XLATE";
2009 case SHT_MIPS_XLATE_DEBUG
: return "MIPS_XLATE_DEBUG";
2010 case SHT_MIPS_WHIRL
: return "MIPS_WHIRL";
2011 case SHT_MIPS_EH_REGION
: return "MIPS_EH_REGION";
2012 case SHT_MIPS_XLATE_OLD
: return "MIPS_XLATE_OLD";
2013 case SHT_MIPS_PDR_EXCEPTION
: return "MIPS_PDR_EXCEPTION";
2021 get_parisc_section_type_name (sh_type
)
2022 unsigned int sh_type
;
2026 case SHT_PARISC_EXT
: return "PARISC_EXT";
2027 case SHT_PARISC_UNWIND
: return "PARISC_UNWIND";
2028 case SHT_PARISC_DOC
: return "PARISC_DOC";
2036 get_ia64_section_type_name (sh_type
)
2037 unsigned int sh_type
;
2041 case SHT_IA_64_EXT
: return "IA_64_EXT";
2042 case SHT_IA_64_UNWIND
: return "IA_64_UNWIND";
2050 get_section_type_name (sh_type
)
2051 unsigned int sh_type
;
2053 static char buff
[32];
2057 case SHT_NULL
: return "NULL";
2058 case SHT_PROGBITS
: return "PROGBITS";
2059 case SHT_SYMTAB
: return "SYMTAB";
2060 case SHT_STRTAB
: return "STRTAB";
2061 case SHT_RELA
: return "RELA";
2062 case SHT_HASH
: return "HASH";
2063 case SHT_DYNAMIC
: return "DYNAMIC";
2064 case SHT_NOTE
: return "NOTE";
2065 case SHT_NOBITS
: return "NOBITS";
2066 case SHT_REL
: return "REL";
2067 case SHT_SHLIB
: return "SHLIB";
2068 case SHT_DYNSYM
: return "DYNSYM";
2069 case SHT_INIT_ARRAY
: return "INIT_ARRAY";
2070 case SHT_FINI_ARRAY
: return "FINI_ARRAY";
2071 case SHT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
2072 case SHT_GROUP
: return "GROUP";
2073 case SHT_SYMTAB_SHNDX
: return "SYMTAB SECTION INDICIES";
2074 case SHT_GNU_verdef
: return "VERDEF";
2075 case SHT_GNU_verneed
: return "VERNEED";
2076 case SHT_GNU_versym
: return "VERSYM";
2077 case 0x6ffffff0: return "VERSYM";
2078 case 0x6ffffffc: return "VERDEF";
2079 case 0x7ffffffd: return "AUXILIARY";
2080 case 0x7fffffff: return "FILTER";
2083 if ((sh_type
>= SHT_LOPROC
) && (sh_type
<= SHT_HIPROC
))
2085 const char * result
;
2087 switch (elf_header
.e_machine
)
2090 case EM_MIPS_RS3_LE
:
2091 result
= get_mips_section_type_name (sh_type
);
2094 result
= get_parisc_section_type_name (sh_type
);
2097 result
= get_ia64_section_type_name (sh_type
);
2107 sprintf (buff
, "LOPROC+%x", sh_type
- SHT_LOPROC
);
2109 else if ((sh_type
>= SHT_LOOS
) && (sh_type
<= SHT_HIOS
))
2110 sprintf (buff
, "LOOS+%x", sh_type
- SHT_LOOS
);
2111 else if ((sh_type
>= SHT_LOUSER
) && (sh_type
<= SHT_HIUSER
))
2112 sprintf (buff
, "LOUSER+%x", sh_type
- SHT_LOUSER
);
2114 sprintf (buff
, _("<unknown>: %x"), sh_type
);
2120 struct option options
[] =
2122 {"all", no_argument
, 0, 'a'},
2123 {"file-header", no_argument
, 0, 'h'},
2124 {"program-headers", no_argument
, 0, 'l'},
2125 {"headers", no_argument
, 0, 'e'},
2126 {"histogram", no_argument
, 0, 'I'},
2127 {"segments", no_argument
, 0, 'l'},
2128 {"sections", no_argument
, 0, 'S'},
2129 {"section-headers", no_argument
, 0, 'S'},
2130 {"symbols", no_argument
, 0, 's'},
2131 {"syms", no_argument
, 0, 's'},
2132 {"relocs", no_argument
, 0, 'r'},
2133 {"notes", no_argument
, 0, 'n'},
2134 {"dynamic", no_argument
, 0, 'd'},
2135 {"arch-specific", no_argument
, 0, 'A'},
2136 {"version-info", no_argument
, 0, 'V'},
2137 {"use-dynamic", no_argument
, 0, 'D'},
2138 {"hex-dump", required_argument
, 0, 'x'},
2139 {"debug-dump", optional_argument
, 0, 'w'},
2140 {"unwind", no_argument
, 0, 'u'},
2141 #ifdef SUPPORT_DISASSEMBLY
2142 {"instruction-dump", required_argument
, 0, 'i'},
2145 {"version", no_argument
, 0, 'v'},
2146 {"wide", no_argument
, 0, 'W'},
2147 {"help", no_argument
, 0, 'H'},
2148 {0, no_argument
, 0, 0}
2154 fprintf (stdout
, _("Usage: readelf {options} elf-file(s)\n"));
2155 fprintf (stdout
, _(" Options are:\n"));
2156 fprintf (stdout
, _(" -a or --all Equivalent to: -h -l -S -s -r -d -V -A -I\n"));
2157 fprintf (stdout
, _(" -h or --file-header Display the ELF file header\n"));
2158 fprintf (stdout
, _(" -l or --program-headers or --segments\n"));
2159 fprintf (stdout
, _(" Display the program headers\n"));
2160 fprintf (stdout
, _(" -S or --section-headers or --sections\n"));
2161 fprintf (stdout
, _(" Display the sections' header\n"));
2162 fprintf (stdout
, _(" -e or --headers Equivalent to: -h -l -S\n"));
2163 fprintf (stdout
, _(" -s or --syms or --symbols Display the symbol table\n"));
2164 fprintf (stdout
, _(" -n or --notes Display the core notes (if present)\n"));
2165 fprintf (stdout
, _(" -r or --relocs Display the relocations (if present)\n"));
2166 fprintf (stdout
, _(" -u or --unwind Display the unwind info (if present)\n"));
2167 fprintf (stdout
, _(" -d or --dynamic Display the dynamic segment (if present)\n"));
2168 fprintf (stdout
, _(" -V or --version-info Display the version sections (if present)\n"));
2169 fprintf (stdout
, _(" -A or --arch-specific Display architecture specific information (if any).\n"));
2170 fprintf (stdout
, _(" -D or --use-dynamic Use the dynamic section info when displaying symbols\n"));
2171 fprintf (stdout
, _(" -x <number> or --hex-dump=<number>\n"));
2172 fprintf (stdout
, _(" Dump the contents of section <number>\n"));
2173 fprintf (stdout
, _(" -w[liaprmfs] or --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=str]\n"));
2174 fprintf (stdout
, _(" Display the contents of DWARF2 debug sections\n"));
2175 #ifdef SUPPORT_DISASSEMBLY
2176 fprintf (stdout
, _(" -i <number> or --instruction-dump=<number>\n"));
2177 fprintf (stdout
, _(" Disassemble the contents of section <number>\n"));
2179 fprintf (stdout
, _(" -I or --histogram Display histogram of bucket list lengths\n"));
2180 fprintf (stdout
, _(" -v or --version Display the version number of readelf\n"));
2181 fprintf (stdout
, _(" -W or --wide Don't split lines or truncate symbols to fit into 80 columns\n"));
2182 fprintf (stdout
, _(" -H or --help Display this information\n"));
2183 fprintf (stdout
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
2189 request_dump (section
, type
)
2190 unsigned int section
;
2193 if (section
>= num_dump_sects
)
2195 char * new_dump_sects
;
2197 new_dump_sects
= (char *) calloc (section
+ 1, 1);
2199 if (new_dump_sects
== NULL
)
2200 error (_("Out of memory allocating dump request table."));
2203 /* Copy current flag settings. */
2204 memcpy (new_dump_sects
, dump_sects
, num_dump_sects
);
2208 dump_sects
= new_dump_sects
;
2209 num_dump_sects
= section
+ 1;
2214 dump_sects
[section
] |= type
;
2220 parse_args (argc
, argv
)
2229 while ((c
= getopt_long
2230 (argc
, argv
, "ersuahnldSDAIw::x:i:vVW", options
, NULL
)) != EOF
)
2266 do_using_dynamic
++;
2297 section
= strtoul (optarg
, & cp
, 0);
2298 if (! * cp
&& section
>= 0)
2300 request_dump (section
, HEX_DUMP
);
2310 unsigned int index
= 0;
2314 while (optarg
[index
])
2315 switch (optarg
[index
++])
2324 do_debug_abbrevs
= 1;
2334 do_debug_pubnames
= 1;
2339 do_debug_aranges
= 1;
2343 do_debug_frames_interp
= 1;
2345 do_debug_frames
= 1;
2350 do_debug_macinfo
= 1;
2359 warn (_("Unrecognised debug option '%s'\n"), optarg
);
2364 #ifdef SUPPORT_DISASSEMBLY
2367 section
= strtoul (optarg
, & cp
, 0);
2368 if (! * cp
&& section
>= 0)
2370 request_dump (section
, DISASS_DUMP
);
2376 print_version (program_name
);
2386 /* xgettext:c-format */
2387 error (_("Invalid option '-%c'\n"), c
);
2394 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
2395 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
2396 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
)
2400 warn (_("Nothing to do.\n"));
2406 get_elf_class (elf_class
)
2407 unsigned int elf_class
;
2409 static char buff
[32];
2413 case ELFCLASSNONE
: return _("none");
2414 case ELFCLASS32
: return "ELF32";
2415 case ELFCLASS64
: return "ELF64";
2417 sprintf (buff
, _("<unknown: %x>"), elf_class
);
2423 get_data_encoding (encoding
)
2424 unsigned int encoding
;
2426 static char buff
[32];
2430 case ELFDATANONE
: return _("none");
2431 case ELFDATA2LSB
: return _("2's complement, little endian");
2432 case ELFDATA2MSB
: return _("2's complement, big endian");
2434 sprintf (buff
, _("<unknown: %x>"), encoding
);
2440 get_osabi_name (osabi
)
2443 static char buff
[32];
2447 case ELFOSABI_NONE
: return "UNIX - System V";
2448 case ELFOSABI_HPUX
: return "UNIX - HP-UX";
2449 case ELFOSABI_NETBSD
: return "UNIX - NetBSD";
2450 case ELFOSABI_LINUX
: return "UNIX - Linux";
2451 case ELFOSABI_HURD
: return "GNU/Hurd";
2452 case ELFOSABI_SOLARIS
: return "UNIX - Solaris";
2453 case ELFOSABI_AIX
: return "UNIX - AIX";
2454 case ELFOSABI_IRIX
: return "UNIX - IRIX";
2455 case ELFOSABI_FREEBSD
: return "UNIX - FreeBSD";
2456 case ELFOSABI_TRU64
: return "UNIX - TRU64";
2457 case ELFOSABI_MODESTO
: return "Novell - Modesto";
2458 case ELFOSABI_OPENBSD
: return "UNIX - OpenBSD";
2459 case ELFOSABI_STANDALONE
: return _("Standalone App");
2460 case ELFOSABI_ARM
: return "ARM";
2462 sprintf (buff
, _("<unknown: %x>"), osabi
);
2467 /* Decode the data held in 'elf_header'. */
2469 process_file_header ()
2471 if ( elf_header
.e_ident
[EI_MAG0
] != ELFMAG0
2472 || elf_header
.e_ident
[EI_MAG1
] != ELFMAG1
2473 || elf_header
.e_ident
[EI_MAG2
] != ELFMAG2
2474 || elf_header
.e_ident
[EI_MAG3
] != ELFMAG3
)
2477 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
2485 printf (_("ELF Header:\n"));
2486 printf (_(" Magic: "));
2487 for (i
= 0; i
< EI_NIDENT
; i
++)
2488 printf ("%2.2x ", elf_header
.e_ident
[i
]);
2490 printf (_(" Class: %s\n"),
2491 get_elf_class (elf_header
.e_ident
[EI_CLASS
]));
2492 printf (_(" Data: %s\n"),
2493 get_data_encoding (elf_header
.e_ident
[EI_DATA
]));
2494 printf (_(" Version: %d %s\n"),
2495 elf_header
.e_ident
[EI_VERSION
],
2496 (elf_header
.e_ident
[EI_VERSION
] == EV_CURRENT
2498 : (elf_header
.e_ident
[EI_VERSION
] != EV_NONE
2501 printf (_(" OS/ABI: %s\n"),
2502 get_osabi_name (elf_header
.e_ident
[EI_OSABI
]));
2503 printf (_(" ABI Version: %d\n"),
2504 elf_header
.e_ident
[EI_ABIVERSION
]);
2505 printf (_(" Type: %s\n"),
2506 get_file_type (elf_header
.e_type
));
2507 printf (_(" Machine: %s\n"),
2508 get_machine_name (elf_header
.e_machine
));
2509 printf (_(" Version: 0x%lx\n"),
2510 (unsigned long) elf_header
.e_version
);
2512 printf (_(" Entry point address: "));
2513 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
2514 printf (_("\n Start of program headers: "));
2515 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
2516 printf (_(" (bytes into file)\n Start of section headers: "));
2517 print_vma ((bfd_vma
) elf_header
.e_shoff
, DEC
);
2518 printf (_(" (bytes into file)\n"));
2520 printf (_(" Flags: 0x%lx%s\n"),
2521 (unsigned long) elf_header
.e_flags
,
2522 get_machine_flags (elf_header
.e_flags
, elf_header
.e_machine
));
2523 printf (_(" Size of this header: %ld (bytes)\n"),
2524 (long) elf_header
.e_ehsize
);
2525 printf (_(" Size of program headers: %ld (bytes)\n"),
2526 (long) elf_header
.e_phentsize
);
2527 printf (_(" Number of program headers: %ld\n"),
2528 (long) elf_header
.e_phnum
);
2529 printf (_(" Size of section headers: %ld (bytes)\n"),
2530 (long) elf_header
.e_shentsize
);
2531 printf (_(" Number of section headers: %ld"),
2532 (long) elf_header
.e_shnum
);
2533 if (section_headers
!= NULL
&& elf_header
.e_shnum
== 0)
2534 printf (" (%ld)", (long) section_headers
[0].sh_size
);
2535 putc ('\n', stdout
);
2536 printf (_(" Section header string table index: %ld"),
2537 (long) elf_header
.e_shstrndx
);
2538 if (section_headers
!= NULL
&& elf_header
.e_shstrndx
== SHN_XINDEX
)
2539 printf (" (%ld)", (long) section_headers
[0].sh_link
);
2540 putc ('\n', stdout
);
2543 if (section_headers
!= NULL
)
2545 if (elf_header
.e_shnum
== 0)
2546 elf_header
.e_shnum
= section_headers
[0].sh_size
;
2547 if (elf_header
.e_shstrndx
== SHN_XINDEX
)
2548 elf_header
.e_shstrndx
= section_headers
[0].sh_link
;
2549 free (section_headers
);
2550 section_headers
= NULL
;
2558 get_32bit_program_headers (file
, program_headers
)
2560 Elf_Internal_Phdr
* program_headers
;
2562 Elf32_External_Phdr
* phdrs
;
2563 Elf32_External_Phdr
* external
;
2564 Elf32_Internal_Phdr
* internal
;
2567 phdrs
= ((Elf32_External_Phdr
*)
2568 get_data (NULL
, file
, elf_header
.e_phoff
,
2569 elf_header
.e_phentsize
* elf_header
.e_phnum
,
2570 _("program headers")));
2574 for (i
= 0, internal
= program_headers
, external
= phdrs
;
2575 i
< elf_header
.e_phnum
;
2576 i
++, internal
++, external
++)
2578 internal
->p_type
= BYTE_GET (external
->p_type
);
2579 internal
->p_offset
= BYTE_GET (external
->p_offset
);
2580 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
2581 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
2582 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
2583 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
2584 internal
->p_flags
= BYTE_GET (external
->p_flags
);
2585 internal
->p_align
= BYTE_GET (external
->p_align
);
2594 get_64bit_program_headers (file
, program_headers
)
2596 Elf_Internal_Phdr
* program_headers
;
2598 Elf64_External_Phdr
* phdrs
;
2599 Elf64_External_Phdr
* external
;
2600 Elf64_Internal_Phdr
* internal
;
2603 phdrs
= ((Elf64_External_Phdr
*)
2604 get_data (NULL
, file
, elf_header
.e_phoff
,
2605 elf_header
.e_phentsize
* elf_header
.e_phnum
,
2606 _("program headers")));
2610 for (i
= 0, internal
= program_headers
, external
= phdrs
;
2611 i
< elf_header
.e_phnum
;
2612 i
++, internal
++, external
++)
2614 internal
->p_type
= BYTE_GET (external
->p_type
);
2615 internal
->p_flags
= BYTE_GET (external
->p_flags
);
2616 internal
->p_offset
= BYTE_GET8 (external
->p_offset
);
2617 internal
->p_vaddr
= BYTE_GET8 (external
->p_vaddr
);
2618 internal
->p_paddr
= BYTE_GET8 (external
->p_paddr
);
2619 internal
->p_filesz
= BYTE_GET8 (external
->p_filesz
);
2620 internal
->p_memsz
= BYTE_GET8 (external
->p_memsz
);
2621 internal
->p_align
= BYTE_GET8 (external
->p_align
);
2630 process_program_headers (file
)
2633 Elf_Internal_Phdr
* program_headers
;
2634 Elf_Internal_Phdr
* segment
;
2637 if (elf_header
.e_phnum
== 0)
2640 printf (_("\nThere are no program headers in this file.\n"));
2644 if (do_segments
&& !do_header
)
2646 printf (_("\nElf file type is %s\n"), get_file_type (elf_header
.e_type
));
2647 printf (_("Entry point "));
2648 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
2649 printf (_("\nThere are %d program headers, starting at offset "),
2650 elf_header
.e_phnum
);
2651 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
2655 program_headers
= (Elf_Internal_Phdr
*) malloc
2656 (elf_header
.e_phnum
* sizeof (Elf_Internal_Phdr
));
2658 if (program_headers
== NULL
)
2660 error (_("Out of memory\n"));
2665 i
= get_32bit_program_headers (file
, program_headers
);
2667 i
= get_64bit_program_headers (file
, program_headers
);
2671 free (program_headers
);
2678 (_("\nProgram Header%s:\n"), elf_header
.e_phnum
> 1 ? "s" : "");
2682 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
2685 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
2689 (_(" Type Offset VirtAddr PhysAddr\n"));
2691 (_(" FileSiz MemSiz Flags Align\n"));
2699 for (i
= 0, segment
= program_headers
;
2700 i
< elf_header
.e_phnum
;
2705 printf (" %-14.14s ", get_segment_type (segment
->p_type
));
2709 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
2710 printf ("0x%8.8lx ", (unsigned long) segment
->p_vaddr
);
2711 printf ("0x%8.8lx ", (unsigned long) segment
->p_paddr
);
2712 printf ("0x%5.5lx ", (unsigned long) segment
->p_filesz
);
2713 printf ("0x%5.5lx ", (unsigned long) segment
->p_memsz
);
2715 (segment
->p_flags
& PF_R
? 'R' : ' '),
2716 (segment
->p_flags
& PF_W
? 'W' : ' '),
2717 (segment
->p_flags
& PF_X
? 'E' : ' '));
2718 printf ("%#lx", (unsigned long) segment
->p_align
);
2722 if ((unsigned long) segment
->p_offset
== segment
->p_offset
)
2723 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
2726 print_vma (segment
->p_offset
, FULL_HEX
);
2730 print_vma (segment
->p_vaddr
, FULL_HEX
);
2732 print_vma (segment
->p_paddr
, FULL_HEX
);
2735 if ((unsigned long) segment
->p_filesz
== segment
->p_filesz
)
2736 printf ("0x%6.6lx ", (unsigned long) segment
->p_filesz
);
2739 print_vma (segment
->p_filesz
, FULL_HEX
);
2743 if ((unsigned long) segment
->p_memsz
== segment
->p_memsz
)
2744 printf ("0x%6.6lx", (unsigned long) segment
->p_memsz
);
2747 print_vma (segment
->p_offset
, FULL_HEX
);
2751 (segment
->p_flags
& PF_R
? 'R' : ' '),
2752 (segment
->p_flags
& PF_W
? 'W' : ' '),
2753 (segment
->p_flags
& PF_X
? 'E' : ' '));
2755 if ((unsigned long) segment
->p_align
== segment
->p_align
)
2756 printf ("%#lx", (unsigned long) segment
->p_align
);
2759 print_vma (segment
->p_align
, PREFIX_HEX
);
2764 print_vma (segment
->p_offset
, FULL_HEX
);
2766 print_vma (segment
->p_vaddr
, FULL_HEX
);
2768 print_vma (segment
->p_paddr
, FULL_HEX
);
2770 print_vma (segment
->p_filesz
, FULL_HEX
);
2772 print_vma (segment
->p_memsz
, FULL_HEX
);
2774 (segment
->p_flags
& PF_R
? 'R' : ' '),
2775 (segment
->p_flags
& PF_W
? 'W' : ' '),
2776 (segment
->p_flags
& PF_X
? 'E' : ' '));
2777 print_vma (segment
->p_align
, HEX
);
2781 switch (segment
->p_type
)
2785 loadaddr
= (segment
->p_vaddr
& 0xfffff000)
2786 - (segment
->p_offset
& 0xfffff000);
2791 error (_("more than one dynamic segment\n"));
2793 dynamic_addr
= segment
->p_offset
;
2794 dynamic_size
= segment
->p_filesz
;
2798 if (fseek (file
, (long) segment
->p_offset
, SEEK_SET
))
2799 error (_("Unable to find program interpreter name\n"));
2802 program_interpreter
[0] = 0;
2803 fscanf (file
, "%63s", program_interpreter
);
2806 printf (_("\n [Requesting program interpreter: %s]"),
2807 program_interpreter
);
2813 putc ('\n', stdout
);
2822 if (do_segments
&& section_headers
!= NULL
)
2824 printf (_("\n Section to Segment mapping:\n"));
2825 printf (_(" Segment Sections...\n"));
2827 assert (string_table
!= NULL
);
2829 for (i
= 0; i
< elf_header
.e_phnum
; i
++)
2832 Elf_Internal_Shdr
* section
;
2834 segment
= program_headers
+ i
;
2835 section
= section_headers
;
2837 printf (" %2.2d ", i
);
2839 for (j
= 1; j
< elf_header
.e_shnum
; j
++, section
++)
2841 if (section
->sh_size
> 0
2842 /* Compare allocated sections by VMA, unallocated
2843 sections by file offset. */
2844 && (section
->sh_flags
& SHF_ALLOC
2845 ? (section
->sh_addr
>= segment
->p_vaddr
2846 && section
->sh_addr
+ section
->sh_size
2847 <= segment
->p_vaddr
+ segment
->p_memsz
)
2848 : ((bfd_vma
) section
->sh_offset
>= segment
->p_offset
2849 && (section
->sh_offset
+ section
->sh_size
2850 <= segment
->p_offset
+ segment
->p_filesz
))))
2851 printf ("%s ", SECTION_NAME (section
));
2858 free (program_headers
);
2865 get_32bit_section_headers (file
, num
)
2869 Elf32_External_Shdr
* shdrs
;
2870 Elf32_Internal_Shdr
* internal
;
2873 shdrs
= ((Elf32_External_Shdr
*)
2874 get_data (NULL
, file
, elf_header
.e_shoff
,
2875 elf_header
.e_shentsize
* num
,
2876 _("section headers")));
2880 section_headers
= ((Elf_Internal_Shdr
*)
2881 malloc (num
* sizeof (Elf_Internal_Shdr
)));
2883 if (section_headers
== NULL
)
2885 error (_("Out of memory\n"));
2889 for (i
= 0, internal
= section_headers
;
2893 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
2894 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
2895 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
2896 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
2897 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
2898 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
2899 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
2900 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
2901 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
2902 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
2911 get_64bit_section_headers (file
, num
)
2915 Elf64_External_Shdr
* shdrs
;
2916 Elf64_Internal_Shdr
* internal
;
2919 shdrs
= ((Elf64_External_Shdr
*)
2920 get_data (NULL
, file
, elf_header
.e_shoff
,
2921 elf_header
.e_shentsize
* num
,
2922 _("section headers")));
2926 section_headers
= ((Elf_Internal_Shdr
*)
2927 malloc (num
* sizeof (Elf_Internal_Shdr
)));
2929 if (section_headers
== NULL
)
2931 error (_("Out of memory\n"));
2935 for (i
= 0, internal
= section_headers
;
2939 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
2940 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
2941 internal
->sh_flags
= BYTE_GET8 (shdrs
[i
].sh_flags
);
2942 internal
->sh_addr
= BYTE_GET8 (shdrs
[i
].sh_addr
);
2943 internal
->sh_size
= BYTE_GET8 (shdrs
[i
].sh_size
);
2944 internal
->sh_entsize
= BYTE_GET8 (shdrs
[i
].sh_entsize
);
2945 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
2946 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
2947 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
2948 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
2956 static Elf_Internal_Sym
*
2957 get_32bit_elf_symbols (file
, section
)
2959 Elf_Internal_Shdr
*section
;
2961 unsigned long number
;
2962 Elf32_External_Sym
* esyms
;
2963 Elf_External_Sym_Shndx
*shndx
;
2964 Elf_Internal_Sym
* isyms
;
2965 Elf_Internal_Sym
* psym
;
2968 esyms
= ((Elf32_External_Sym
*)
2969 get_data (NULL
, file
, section
->sh_offset
,
2970 section
->sh_size
, _("symbols")));
2975 if (symtab_shndx_hdr
!= NULL
2976 && (symtab_shndx_hdr
->sh_link
2977 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
2979 shndx
= ((Elf_External_Sym_Shndx
*)
2980 get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
2981 symtab_shndx_hdr
->sh_size
, _("symtab shndx")));
2989 number
= section
->sh_size
/ section
->sh_entsize
;
2990 isyms
= (Elf_Internal_Sym
*) malloc (number
* sizeof (Elf_Internal_Sym
));
2994 error (_("Out of memory\n"));
3001 for (j
= 0, psym
= isyms
;
3005 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3006 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3007 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3008 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3009 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3011 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3012 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3013 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3023 static Elf_Internal_Sym
*
3024 get_64bit_elf_symbols (file
, section
)
3026 Elf_Internal_Shdr
*section
;
3028 unsigned long number
;
3029 Elf64_External_Sym
* esyms
;
3030 Elf_External_Sym_Shndx
*shndx
;
3031 Elf_Internal_Sym
* isyms
;
3032 Elf_Internal_Sym
* psym
;
3035 esyms
= ((Elf64_External_Sym
*)
3036 get_data (NULL
, file
, section
->sh_offset
,
3037 section
->sh_size
, _("symbols")));
3042 if (symtab_shndx_hdr
!= NULL
3043 && (symtab_shndx_hdr
->sh_link
3044 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3046 shndx
= ((Elf_External_Sym_Shndx
*)
3047 get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3048 symtab_shndx_hdr
->sh_size
, _("symtab shndx")));
3056 number
= section
->sh_size
/ section
->sh_entsize
;
3057 isyms
= (Elf_Internal_Sym
*) malloc (number
* sizeof (Elf_Internal_Sym
));
3061 error (_("Out of memory\n"));
3068 for (j
= 0, psym
= isyms
;
3072 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3073 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3074 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3075 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3076 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3078 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3079 psym
->st_value
= BYTE_GET8 (esyms
[j
].st_value
);
3080 psym
->st_size
= BYTE_GET8 (esyms
[j
].st_size
);
3091 get_elf_section_flags (sh_flags
)
3094 static char buff
[32];
3102 flag
= sh_flags
& - sh_flags
;
3107 case SHF_WRITE
: strcat (buff
, "W"); break;
3108 case SHF_ALLOC
: strcat (buff
, "A"); break;
3109 case SHF_EXECINSTR
: strcat (buff
, "X"); break;
3110 case SHF_MERGE
: strcat (buff
, "M"); break;
3111 case SHF_STRINGS
: strcat (buff
, "S"); break;
3112 case SHF_INFO_LINK
: strcat (buff
, "I"); break;
3113 case SHF_LINK_ORDER
: strcat (buff
, "L"); break;
3114 case SHF_OS_NONCONFORMING
: strcat (buff
, "O"); break;
3115 case SHF_GROUP
: strcat (buff
, "G"); break;
3118 if (flag
& SHF_MASKOS
)
3121 sh_flags
&= ~ SHF_MASKOS
;
3123 else if (flag
& SHF_MASKPROC
)
3126 sh_flags
&= ~ SHF_MASKPROC
;
3138 process_section_headers (file
)
3141 Elf_Internal_Shdr
* section
;
3144 section_headers
= NULL
;
3146 if (elf_header
.e_shnum
== 0)
3149 printf (_("\nThere are no sections in this file.\n"));
3154 if (do_sections
&& !do_header
)
3155 printf (_("There are %d section headers, starting at offset 0x%lx:\n"),
3156 elf_header
.e_shnum
, (unsigned long) elf_header
.e_shoff
);
3160 if (! get_32bit_section_headers (file
, elf_header
.e_shnum
))
3163 else if (! get_64bit_section_headers (file
, elf_header
.e_shnum
))
3166 /* Read in the string table, so that we have names to display. */
3167 section
= SECTION_HEADER (elf_header
.e_shstrndx
);
3169 if (section
->sh_size
!= 0)
3171 string_table
= (char *) get_data (NULL
, file
, section
->sh_offset
,
3172 section
->sh_size
, _("string table"));
3174 string_table_length
= section
->sh_size
;
3177 /* Scan the sections for the dynamic symbol table
3178 and dynamic string table and debug sections. */
3179 dynamic_symbols
= NULL
;
3180 dynamic_strings
= NULL
;
3181 dynamic_syminfo
= NULL
;
3183 for (i
= 0, section
= section_headers
;
3184 i
< elf_header
.e_shnum
;
3187 char * name
= SECTION_NAME (section
);
3189 if (section
->sh_type
== SHT_DYNSYM
)
3191 if (dynamic_symbols
!= NULL
)
3193 error (_("File contains multiple dynamic symbol tables\n"));
3197 num_dynamic_syms
= section
->sh_size
/ section
->sh_entsize
;
3198 dynamic_symbols
= GET_ELF_SYMBOLS (file
, section
);
3200 else if (section
->sh_type
== SHT_STRTAB
3201 && strcmp (name
, ".dynstr") == 0)
3203 if (dynamic_strings
!= NULL
)
3205 error (_("File contains multiple dynamic string tables\n"));
3209 dynamic_strings
= (char *) get_data (NULL
, file
, section
->sh_offset
,
3211 _("dynamic strings"));
3213 else if (section
->sh_type
== SHT_SYMTAB_SHNDX
)
3215 if (symtab_shndx_hdr
!= NULL
)
3217 error (_("File contains multiple symtab shndx tables\n"));
3220 symtab_shndx_hdr
= section
;
3222 else if ((do_debugging
|| do_debug_info
|| do_debug_abbrevs
3223 || do_debug_lines
|| do_debug_pubnames
|| do_debug_aranges
3224 || do_debug_frames
|| do_debug_macinfo
|| do_debug_str
)
3225 && strncmp (name
, ".debug_", 7) == 0)
3230 || (do_debug_info
&& (strcmp (name
, "info") == 0))
3231 || (do_debug_abbrevs
&& (strcmp (name
, "abbrev") == 0))
3232 || (do_debug_lines
&& (strcmp (name
, "line") == 0))
3233 || (do_debug_pubnames
&& (strcmp (name
, "pubnames") == 0))
3234 || (do_debug_aranges
&& (strcmp (name
, "aranges") == 0))
3235 || (do_debug_frames
&& (strcmp (name
, "frame") == 0))
3236 || (do_debug_macinfo
&& (strcmp (name
, "macinfo") == 0))
3237 || (do_debug_str
&& (strcmp (name
, "str") == 0))
3239 request_dump (i
, DEBUG_DUMP
);
3241 /* linkonce section to be combined with .debug_info at link time. */
3242 else if ((do_debugging
|| do_debug_info
)
3243 && strncmp (name
, ".gnu.linkonce.wi.", 17) == 0)
3244 request_dump (i
, DEBUG_DUMP
);
3245 else if (do_debug_frames
&& strcmp (name
, ".eh_frame") == 0)
3246 request_dump (i
, DEBUG_DUMP
);
3252 printf (_("\nSection Header%s:\n"), elf_header
.e_shnum
> 1 ? "s" : "");
3256 (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
3259 (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n"));
3262 printf (_(" [Nr] Name Type Address Offset\n"));
3263 printf (_(" Size EntSize Flags Link Info Align\n"));
3266 for (i
= 0, section
= section_headers
;
3267 i
< elf_header
.e_shnum
;
3270 printf (" [%2u] %-17.17s %-15.15s ",
3271 SECTION_HEADER_NUM (i
),
3272 SECTION_NAME (section
),
3273 get_section_type_name (section
->sh_type
));
3277 print_vma (section
->sh_addr
, LONG_HEX
);
3279 printf ( " %6.6lx %6.6lx %2.2lx",
3280 (unsigned long) section
->sh_offset
,
3281 (unsigned long) section
->sh_size
,
3282 (unsigned long) section
->sh_entsize
);
3284 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
3286 printf ("%2ld %3lx %2ld\n",
3287 (unsigned long) section
->sh_link
,
3288 (unsigned long) section
->sh_info
,
3289 (unsigned long) section
->sh_addralign
);
3293 print_vma (section
->sh_addr
, LONG_HEX
);
3295 if ((long) section
->sh_offset
== section
->sh_offset
)
3296 printf (" %6.6lx", (unsigned long) section
->sh_offset
);
3300 print_vma (section
->sh_offset
, LONG_HEX
);
3303 if ((unsigned long) section
->sh_size
== section
->sh_size
)
3304 printf (" %6.6lx", (unsigned long) section
->sh_size
);
3308 print_vma (section
->sh_size
, LONG_HEX
);
3311 if ((unsigned long) section
->sh_entsize
== section
->sh_entsize
)
3312 printf (" %2.2lx", (unsigned long) section
->sh_entsize
);
3316 print_vma (section
->sh_entsize
, LONG_HEX
);
3319 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
3321 printf ("%2ld %3lx ",
3322 (unsigned long) section
->sh_link
,
3323 (unsigned long) section
->sh_info
);
3325 if ((unsigned long) section
->sh_addralign
== section
->sh_addralign
)
3326 printf ("%2ld\n", (unsigned long) section
->sh_addralign
);
3329 print_vma (section
->sh_addralign
, DEC
);
3336 print_vma (section
->sh_addr
, LONG_HEX
);
3337 if ((long) section
->sh_offset
== section
->sh_offset
)
3338 printf (" %8.8lx", (unsigned long) section
->sh_offset
);
3342 print_vma (section
->sh_offset
, LONG_HEX
);
3345 print_vma (section
->sh_size
, LONG_HEX
);
3347 print_vma (section
->sh_entsize
, LONG_HEX
);
3349 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
3351 printf (" %2ld %3lx %ld\n",
3352 (unsigned long) section
->sh_link
,
3353 (unsigned long) section
->sh_info
,
3354 (unsigned long) section
->sh_addralign
);
3358 printf (_("Key to Flags:\n\
3359 W (write), A (alloc), X (execute), M (merge), S (strings)\n\
3360 I (info), L (link order), G (group), x (unknown)\n\
3361 O (extra OS processing required) o (OS specific), p (processor specific)\n"));
3366 /* Process the reloc section. */
3368 process_relocs (file
)
3371 unsigned long rel_size
;
3372 unsigned long rel_offset
;
3378 if (do_using_dynamic
)
3380 int is_rela
= FALSE
;
3385 if (dynamic_info
[DT_REL
])
3387 rel_offset
= dynamic_info
[DT_REL
];
3388 rel_size
= dynamic_info
[DT_RELSZ
];
3391 else if (dynamic_info
[DT_RELA
])
3393 rel_offset
= dynamic_info
[DT_RELA
];
3394 rel_size
= dynamic_info
[DT_RELASZ
];
3397 else if (dynamic_info
[DT_JMPREL
])
3399 rel_offset
= dynamic_info
[DT_JMPREL
];
3400 rel_size
= dynamic_info
[DT_PLTRELSZ
];
3402 switch (dynamic_info
[DT_PLTREL
])
3419 (_("\nRelocation section at offset 0x%lx contains %ld bytes:\n"),
3420 rel_offset
, rel_size
);
3422 dump_relocations (file
, rel_offset
- loadaddr
, rel_size
,
3423 dynamic_symbols
, num_dynamic_syms
, dynamic_strings
, is_rela
);
3426 printf (_("\nThere are no dynamic relocations in this file.\n"));
3430 Elf32_Internal_Shdr
* section
;
3434 for (i
= 0, section
= section_headers
;
3435 i
< elf_header
.e_shnum
;
3438 if ( section
->sh_type
!= SHT_RELA
3439 && section
->sh_type
!= SHT_REL
)
3442 rel_offset
= section
->sh_offset
;
3443 rel_size
= section
->sh_size
;
3447 Elf32_Internal_Shdr
* strsec
;
3448 Elf_Internal_Sym
* symtab
;
3451 unsigned long nsyms
;
3453 printf (_("\nRelocation section "));
3455 if (string_table
== NULL
)
3456 printf ("%d", section
->sh_name
);
3458 printf ("'%s'", SECTION_NAME (section
));
3460 printf (_(" at offset 0x%lx contains %lu entries:\n"),
3461 rel_offset
, (unsigned long) (rel_size
/ section
->sh_entsize
));
3466 if (section
->sh_link
)
3468 Elf32_Internal_Shdr
* symsec
;
3470 symsec
= SECTION_HEADER (section
->sh_link
);
3471 nsyms
= symsec
->sh_size
/ symsec
->sh_entsize
;
3472 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
3477 strsec
= SECTION_HEADER (symsec
->sh_link
);
3479 strtab
= (char *) get_data (NULL
, file
, strsec
->sh_offset
,
3483 is_rela
= section
->sh_type
== SHT_RELA
;
3485 dump_relocations (file
, rel_offset
, rel_size
,
3486 symtab
, nsyms
, strtab
, is_rela
);
3498 printf (_("\nThere are no relocations in this file.\n"));
3504 #include "unwind-ia64.h"
3506 /* An absolute address consists of a section and an offset. If the
3507 section is NULL, the offset itself is the address, otherwise, the
3508 address equals to LOAD_ADDRESS(section) + offset. */
3512 unsigned short section
;
3518 struct unw_table_entry
3520 struct absaddr start
;
3522 struct absaddr info
;
3524 *table
; /* Unwind table. */
3525 unsigned long table_len
; /* Length of unwind table. */
3526 unsigned char * info
; /* Unwind info. */
3527 unsigned long info_size
; /* Size of unwind info. */
3528 bfd_vma info_addr
; /* starting address of unwind info. */
3529 bfd_vma seg_base
; /* Starting address of segment. */
3530 Elf_Internal_Sym
* symtab
; /* The symbol table. */
3531 unsigned long nsyms
; /* Number of symbols. */
3532 char * strtab
; /* The string table. */
3533 unsigned long strtab_size
; /* Size of string table. */
3536 static void find_symbol_for_address
PARAMS ((struct unw_aux_info
*,
3537 struct absaddr
, const char **,
3539 static void dump_ia64_unwind
PARAMS ((struct unw_aux_info
*));
3540 static int slurp_ia64_unwind_table
PARAMS ((FILE *, struct unw_aux_info
*,
3541 Elf32_Internal_Shdr
*));
3544 find_symbol_for_address (aux
, addr
, symname
, offset
)
3545 struct unw_aux_info
*aux
;
3546 struct absaddr addr
;
3547 const char **symname
;
3550 bfd_vma dist
= (bfd_vma
) 0x100000;
3551 Elf_Internal_Sym
*sym
, *best
= NULL
;
3554 for (i
= 0, sym
= aux
->symtab
; i
< aux
->nsyms
; ++i
, ++sym
)
3556 if (ELF_ST_TYPE (sym
->st_info
) == STT_FUNC
3557 && sym
->st_name
!= 0
3558 && (addr
.section
== SHN_UNDEF
|| addr
.section
== sym
->st_shndx
)
3559 && addr
.offset
>= sym
->st_value
3560 && addr
.offset
- sym
->st_value
< dist
)
3563 dist
= addr
.offset
- sym
->st_value
;
3570 *symname
= (best
->st_name
>= aux
->strtab_size
3571 ? "<corrupt>" : aux
->strtab
+ best
->st_name
);
3576 *offset
= addr
.offset
;
3580 dump_ia64_unwind (aux
)
3581 struct unw_aux_info
*aux
;
3584 struct unw_table_entry
* tp
;
3587 addr_size
= is_32bit_elf
? 4 : 8;
3589 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
3593 const unsigned char * dp
;
3594 const unsigned char * head
;
3595 const char * procname
;
3597 find_symbol_for_address (aux
, tp
->start
, &procname
, &offset
);
3599 fputs ("\n<", stdout
);
3603 fputs (procname
, stdout
);
3606 printf ("+%lx", (unsigned long) offset
);
3609 fputs (">: [", stdout
);
3610 print_vma (tp
->start
.offset
, PREFIX_HEX
);
3611 fputc ('-', stdout
);
3612 print_vma (tp
->end
.offset
, PREFIX_HEX
);
3613 printf ("), info at +0x%lx\n",
3614 (unsigned long) (tp
->info
.offset
- aux
->seg_base
));
3616 head
= aux
->info
+ (tp
->info
.offset
- aux
->info_addr
);
3617 stamp
= BYTE_GET8 ((unsigned char *) head
);
3619 printf (" v%u, flags=0x%lx (%s%s ), len=%lu bytes\n",
3620 (unsigned) UNW_VER (stamp
),
3621 (unsigned long) ((stamp
& UNW_FLAG_MASK
) >> 32),
3622 UNW_FLAG_EHANDLER (stamp
) ? " ehandler" : "",
3623 UNW_FLAG_UHANDLER (stamp
) ? " uhandler" : "",
3624 (unsigned long) (addr_size
* UNW_LENGTH (stamp
)));
3626 if (UNW_VER (stamp
) != 1)
3628 printf ("\tUnknown version.\n");
3633 for (dp
= head
+ 8; dp
< head
+ 8 + addr_size
* UNW_LENGTH (stamp
);)
3634 dp
= unw_decode (dp
, in_body
, & in_body
);
3639 slurp_ia64_unwind_table (file
, aux
, sec
)
3641 struct unw_aux_info
*aux
;
3642 Elf32_Internal_Shdr
*sec
;
3644 unsigned long size
, addr_size
, nrelas
, i
;
3645 Elf_Internal_Phdr
*prog_hdrs
, *seg
;
3646 struct unw_table_entry
*tep
;
3647 Elf32_Internal_Shdr
*relsec
;
3648 Elf_Internal_Rela
*rela
, *rp
;
3649 unsigned char *table
, *tp
;
3650 Elf_Internal_Sym
*sym
;
3651 const char *relname
;
3654 addr_size
= is_32bit_elf
? 4 : 8;
3656 /* First, find the starting address of the segment that includes
3659 if (elf_header
.e_phnum
)
3661 prog_hdrs
= (Elf_Internal_Phdr
*)
3662 xmalloc (elf_header
.e_phnum
* sizeof (Elf_Internal_Phdr
));
3665 result
= get_32bit_program_headers (file
, prog_hdrs
);
3667 result
= get_64bit_program_headers (file
, prog_hdrs
);
3675 for (seg
= prog_hdrs
; seg
< prog_hdrs
+ elf_header
.e_phnum
; ++seg
)
3677 if (seg
->p_type
!= PT_LOAD
)
3680 if (sec
->sh_addr
>= seg
->p_vaddr
3681 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
3683 aux
->seg_base
= seg
->p_vaddr
;
3691 /* Second, build the unwind table from the contents of the unwind section: */
3692 size
= sec
->sh_size
;
3693 table
= (char *) get_data (NULL
, file
, sec
->sh_offset
,
3694 size
, _("unwind table"));
3698 tep
= aux
->table
= xmalloc (size
/ (3 * addr_size
) * sizeof (aux
->table
[0]));
3699 for (tp
= table
; tp
< table
+ size
; tp
+= 3 * addr_size
, ++ tep
)
3701 tep
->start
.section
= SHN_UNDEF
;
3702 tep
->end
.section
= SHN_UNDEF
;
3703 tep
->info
.section
= SHN_UNDEF
;
3706 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
3707 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
3708 tep
->info
.offset
= byte_get ((unsigned char *) tp
+ 8, 4);
3712 tep
->start
.offset
= BYTE_GET8 ((unsigned char *) tp
+ 0);
3713 tep
->end
.offset
= BYTE_GET8 ((unsigned char *) tp
+ 8);
3714 tep
->info
.offset
= BYTE_GET8 ((unsigned char *) tp
+ 16);
3716 tep
->start
.offset
+= aux
->seg_base
;
3717 tep
->end
.offset
+= aux
->seg_base
;
3718 tep
->info
.offset
+= aux
->seg_base
;
3722 /* Third, apply any relocations to the unwind table: */
3724 for (relsec
= section_headers
;
3725 relsec
< section_headers
+ elf_header
.e_shnum
;
3728 if (relsec
->sh_type
!= SHT_RELA
3729 || SECTION_HEADER (relsec
->sh_info
) != sec
)
3732 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
3736 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
3740 relname
= elf_ia64_reloc_type (ELF32_R_TYPE (rp
->r_info
));
3741 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
3743 if (ELF32_ST_TYPE (sym
->st_info
) != STT_SECTION
)
3745 warn (_("Skipping unexpected symbol type %u\n"),
3746 ELF32_ST_TYPE (sym
->st_info
));
3752 relname
= elf_ia64_reloc_type (ELF64_R_TYPE (rp
->r_info
));
3753 sym
= aux
->symtab
+ ELF64_R_SYM (rp
->r_info
);
3755 if (ELF64_ST_TYPE (sym
->st_info
) != STT_SECTION
)
3757 warn (_("Skipping unexpected symbol type %u\n"),
3758 ELF64_ST_TYPE (sym
->st_info
));
3763 if (strncmp (relname
, "R_IA64_SEGREL", 13) != 0)
3765 warn (_("Skipping unexpected relocation type %s\n"), relname
);
3769 i
= rp
->r_offset
/ (3 * addr_size
);
3771 switch (rp
->r_offset
/addr_size
% 3)
3774 aux
->table
[i
].start
.section
= sym
->st_shndx
;
3775 aux
->table
[i
].start
.offset
+= rp
->r_addend
;
3778 aux
->table
[i
].end
.section
= sym
->st_shndx
;
3779 aux
->table
[i
].end
.offset
+= rp
->r_addend
;
3782 aux
->table
[i
].info
.section
= sym
->st_shndx
;
3783 aux
->table
[i
].info
.offset
+= rp
->r_addend
;
3793 aux
->table_len
= size
/ (3 * addr_size
);
3798 process_unwind (file
)
3801 Elf32_Internal_Shdr
*sec
, *unwsec
= NULL
, *strsec
;
3802 unsigned long i
, addr_size
, unwcount
= 0, unwstart
= 0;
3803 struct unw_aux_info aux
;
3808 if (elf_header
.e_machine
!= EM_IA_64
)
3810 printf (_("\nThere are no unwind sections in this file.\n"));
3814 memset (& aux
, 0, sizeof (aux
));
3816 addr_size
= is_32bit_elf
? 4 : 8;
3818 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
3820 if (sec
->sh_type
== SHT_SYMTAB
)
3822 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
3823 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
3825 strsec
= SECTION_HEADER (sec
->sh_link
);
3826 aux
.strtab_size
= strsec
->sh_size
;
3827 aux
.strtab
= (char *) get_data (NULL
, file
, strsec
->sh_offset
,
3828 aux
.strtab_size
, _("string table"));
3830 else if (sec
->sh_type
== SHT_IA_64_UNWIND
)
3835 printf (_("\nThere are no unwind sections in this file.\n"));
3837 while (unwcount
-- > 0)
3842 for (i
= unwstart
, sec
= section_headers
+ unwstart
;
3843 i
< elf_header
.e_shnum
; ++i
, ++sec
)
3844 if (sec
->sh_type
== SHT_IA_64_UNWIND
)
3851 len
= sizeof (ELF_STRING_ia64_unwind_once
) - 1;
3853 if (strncmp (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind_once
,
3856 /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO */
3857 len2
= sizeof (ELF_STRING_ia64_unwind_info_once
) - 1;
3858 suffix
= SECTION_NAME (unwsec
) + len
;
3859 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
3861 if (strncmp (SECTION_NAME (sec
),
3862 ELF_STRING_ia64_unwind_info_once
, len2
) == 0
3863 && strcmp (SECTION_NAME (sec
) + len2
, suffix
) == 0)
3868 /* .IA_64.unwindFOO -> .IA_64.unwind_infoFOO
3869 .IA_64.unwind or BAR -> .IA_64.unwind_info */
3870 len
= sizeof (ELF_STRING_ia64_unwind
) - 1;
3871 len2
= sizeof (ELF_STRING_ia64_unwind_info
) - 1;
3873 if (strncmp (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind
,
3875 suffix
= SECTION_NAME (unwsec
) + len
;
3876 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
3878 if (strncmp (SECTION_NAME (sec
),
3879 ELF_STRING_ia64_unwind_info
, len2
) == 0
3880 && strcmp (SECTION_NAME (sec
) + len2
, suffix
) == 0)
3884 if (i
== elf_header
.e_shnum
)
3886 printf (_("\nCould not find unwind info section for "));
3888 if (string_table
== NULL
)
3889 printf ("%d", unwsec
->sh_name
);
3891 printf ("'%s'", SECTION_NAME (unwsec
));
3895 aux
.info_size
= sec
->sh_size
;
3896 aux
.info_addr
= sec
->sh_addr
;
3897 aux
.info
= (char *) get_data (NULL
, file
, sec
->sh_offset
,
3898 aux
.info_size
, _("unwind info"));
3900 printf (_("\nUnwind section "));
3902 if (string_table
== NULL
)
3903 printf ("%d", unwsec
->sh_name
);
3905 printf ("'%s'", SECTION_NAME (unwsec
));
3907 printf (_(" at offset 0x%lx contains %lu entries:\n"),
3908 (unsigned long) unwsec
->sh_offset
,
3909 (unsigned long) (unwsec
->sh_size
/ (3 * addr_size
)));
3911 (void) slurp_ia64_unwind_table (file
, & aux
, unwsec
);
3913 if (aux
.table_len
> 0)
3914 dump_ia64_unwind (& aux
);
3917 free ((char *) aux
.table
);
3919 free ((char *) aux
.info
);
3928 free ((char *) aux
.strtab
);
3934 dynamic_segment_mips_val (entry
)
3935 Elf_Internal_Dyn
* entry
;
3937 switch (entry
->d_tag
)
3940 if (entry
->d_un
.d_val
== 0)
3944 static const char * opts
[] =
3946 "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT",
3947 "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS",
3948 "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD",
3949 "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF",
3954 for (cnt
= 0; cnt
< NUM_ELEM (opts
); ++ cnt
)
3955 if (entry
->d_un
.d_val
& (1 << cnt
))
3957 printf ("%s%s", first
? "" : " ", opts
[cnt
]);
3964 case DT_MIPS_IVERSION
:
3965 if (dynamic_strings
!= NULL
)
3966 printf ("Interface Version: %s\n",
3967 dynamic_strings
+ entry
->d_un
.d_val
);
3969 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
3972 case DT_MIPS_TIME_STAMP
:
3977 time_t time
= entry
->d_un
.d_val
;
3978 tmp
= gmtime (&time
);
3979 sprintf (timebuf
, "%04u-%02u-%02uT%02u:%02u:%02u",
3980 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
3981 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
3982 printf ("Time Stamp: %s\n", timebuf
);
3986 case DT_MIPS_RLD_VERSION
:
3987 case DT_MIPS_LOCAL_GOTNO
:
3988 case DT_MIPS_CONFLICTNO
:
3989 case DT_MIPS_LIBLISTNO
:
3990 case DT_MIPS_SYMTABNO
:
3991 case DT_MIPS_UNREFEXTNO
:
3992 case DT_MIPS_HIPAGENO
:
3993 case DT_MIPS_DELTA_CLASS_NO
:
3994 case DT_MIPS_DELTA_INSTANCE_NO
:
3995 case DT_MIPS_DELTA_RELOC_NO
:
3996 case DT_MIPS_DELTA_SYM_NO
:
3997 case DT_MIPS_DELTA_CLASSSYM_NO
:
3998 case DT_MIPS_COMPACT_SIZE
:
3999 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
4003 printf ("%#lx\n", (long) entry
->d_un
.d_ptr
);
4009 dynamic_segment_parisc_val (entry
)
4010 Elf_Internal_Dyn
* entry
;
4012 switch (entry
->d_tag
)
4014 case DT_HP_DLD_FLAGS
:
4023 { DT_HP_DEBUG_PRIVATE
, "HP_DEBUG_PRIVATE" },
4024 { DT_HP_DEBUG_CALLBACK
, "HP_DEBUG_CALLBACK" },
4025 { DT_HP_DEBUG_CALLBACK_BOR
, "HP_DEBUG_CALLBACK_BOR" },
4026 { DT_HP_NO_ENVVAR
, "HP_NO_ENVVAR" },
4027 { DT_HP_BIND_NOW
, "HP_BIND_NOW" },
4028 { DT_HP_BIND_NONFATAL
, "HP_BIND_NONFATAL" },
4029 { DT_HP_BIND_VERBOSE
, "HP_BIND_VERBOSE" },
4030 { DT_HP_BIND_RESTRICTED
, "HP_BIND_RESTRICTED" },
4031 { DT_HP_BIND_SYMBOLIC
, "HP_BIND_SYMBOLIC" },
4032 { DT_HP_RPATH_FIRST
, "HP_RPATH_FIRST" },
4033 { DT_HP_BIND_DEPTH_FIRST
, "HP_BIND_DEPTH_FIRST" }
4037 bfd_vma val
= entry
->d_un
.d_val
;
4039 for (cnt
= 0; cnt
< sizeof (flags
) / sizeof (flags
[0]); ++cnt
)
4040 if (val
& flags
[cnt
].bit
)
4044 fputs (flags
[cnt
].str
, stdout
);
4046 val
^= flags
[cnt
].bit
;
4049 if (val
!= 0 || first
)
4053 print_vma (val
, HEX
);
4059 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
4065 get_32bit_dynamic_segment (file
)
4068 Elf32_External_Dyn
* edyn
;
4069 Elf_Internal_Dyn
* entry
;
4072 edyn
= (Elf32_External_Dyn
*) get_data (NULL
, file
, dynamic_addr
,
4073 dynamic_size
, _("dynamic segment"));
4077 /* SGI's ELF has more than one section in the DYNAMIC segment. Determine
4078 how large this .dynamic is now. We can do this even before the byte
4079 swapping since the DT_NULL tag is recognizable. */
4081 while (*(Elf32_Word
*) edyn
[dynamic_size
++].d_tag
!= DT_NULL
)
4084 dynamic_segment
= (Elf_Internal_Dyn
*)
4085 malloc (dynamic_size
* sizeof (Elf_Internal_Dyn
));
4087 if (dynamic_segment
== NULL
)
4089 error (_("Out of memory\n"));
4094 for (i
= 0, entry
= dynamic_segment
;
4098 entry
->d_tag
= BYTE_GET (edyn
[i
].d_tag
);
4099 entry
->d_un
.d_val
= BYTE_GET (edyn
[i
].d_un
.d_val
);
4108 get_64bit_dynamic_segment (file
)
4111 Elf64_External_Dyn
* edyn
;
4112 Elf_Internal_Dyn
* entry
;
4115 edyn
= (Elf64_External_Dyn
*) get_data (NULL
, file
, dynamic_addr
,
4116 dynamic_size
, _("dynamic segment"));
4120 /* SGI's ELF has more than one section in the DYNAMIC segment. Determine
4121 how large this .dynamic is now. We can do this even before the byte
4122 swapping since the DT_NULL tag is recognizable. */
4124 while (*(bfd_vma
*) edyn
[dynamic_size
++].d_tag
!= DT_NULL
)
4127 dynamic_segment
= (Elf_Internal_Dyn
*)
4128 malloc (dynamic_size
* sizeof (Elf_Internal_Dyn
));
4130 if (dynamic_segment
== NULL
)
4132 error (_("Out of memory\n"));
4137 for (i
= 0, entry
= dynamic_segment
;
4141 entry
->d_tag
= BYTE_GET8 (edyn
[i
].d_tag
);
4142 entry
->d_un
.d_val
= BYTE_GET8 (edyn
[i
].d_un
.d_val
);
4151 get_dynamic_flags (flags
)
4154 static char buff
[64];
4159 flag
= flags
& - flags
;
4164 case DF_ORIGIN
: strcat (buff
, "ORIGIN "); break;
4165 case DF_SYMBOLIC
: strcat (buff
, "SYMBOLIC "); break;
4166 case DF_TEXTREL
: strcat (buff
, "TEXTREL "); break;
4167 case DF_BIND_NOW
: strcat (buff
, "BIND_NOW "); break;
4168 default: strcat (buff
, "unknown "); break;
4174 /* Parse and display the contents of the dynamic segment. */
4176 process_dynamic_segment (file
)
4179 Elf_Internal_Dyn
* entry
;
4182 if (dynamic_size
== 0)
4185 printf (_("\nThere is no dynamic segment in this file.\n"));
4192 if (! get_32bit_dynamic_segment (file
))
4195 else if (! get_64bit_dynamic_segment (file
))
4198 /* Find the appropriate symbol table. */
4199 if (dynamic_symbols
== NULL
)
4201 for (i
= 0, entry
= dynamic_segment
;
4205 Elf32_Internal_Shdr section
;
4207 if (entry
->d_tag
!= DT_SYMTAB
)
4210 dynamic_info
[DT_SYMTAB
] = entry
->d_un
.d_val
;
4212 /* Since we do not know how big the symbol table is,
4213 we default to reading in the entire file (!) and
4214 processing that. This is overkill, I know, but it
4216 section
.sh_offset
= entry
->d_un
.d_val
- loadaddr
;
4218 if (fseek (file
, 0, SEEK_END
))
4219 error (_("Unable to seek to end of file!"));
4221 section
.sh_size
= ftell (file
) - section
.sh_offset
;
4223 section
.sh_entsize
= sizeof (Elf32_External_Sym
);
4225 section
.sh_entsize
= sizeof (Elf64_External_Sym
);
4227 num_dynamic_syms
= section
.sh_size
/ section
.sh_entsize
;
4228 if (num_dynamic_syms
< 1)
4230 error (_("Unable to determine the number of symbols to load\n"));
4234 dynamic_symbols
= GET_ELF_SYMBOLS (file
, §ion
);
4238 /* Similarly find a string table. */
4239 if (dynamic_strings
== NULL
)
4241 for (i
= 0, entry
= dynamic_segment
;
4245 unsigned long offset
;
4248 if (entry
->d_tag
!= DT_STRTAB
)
4251 dynamic_info
[DT_STRTAB
] = entry
->d_un
.d_val
;
4253 /* Since we do not know how big the string table is,
4254 we default to reading in the entire file (!) and
4255 processing that. This is overkill, I know, but it
4258 offset
= entry
->d_un
.d_val
- loadaddr
;
4259 if (fseek (file
, 0, SEEK_END
))
4260 error (_("Unable to seek to end of file\n"));
4261 str_tab_len
= ftell (file
) - offset
;
4263 if (str_tab_len
< 1)
4266 (_("Unable to determine the length of the dynamic string table\n"));
4270 dynamic_strings
= (char *) get_data (NULL
, file
, offset
, str_tab_len
,
4271 _("dynamic string table"));
4276 /* And find the syminfo section if available. */
4277 if (dynamic_syminfo
== NULL
)
4279 unsigned int syminsz
= 0;
4281 for (i
= 0, entry
= dynamic_segment
;
4285 if (entry
->d_tag
== DT_SYMINENT
)
4287 /* Note: these braces are necessary to avoid a syntax
4288 error from the SunOS4 C compiler. */
4289 assert (sizeof (Elf_External_Syminfo
) == entry
->d_un
.d_val
);
4291 else if (entry
->d_tag
== DT_SYMINSZ
)
4292 syminsz
= entry
->d_un
.d_val
;
4293 else if (entry
->d_tag
== DT_SYMINFO
)
4294 dynamic_syminfo_offset
= entry
->d_un
.d_val
- loadaddr
;
4297 if (dynamic_syminfo_offset
!= 0 && syminsz
!= 0)
4299 Elf_External_Syminfo
* extsyminfo
;
4300 Elf_Internal_Syminfo
* syminfo
;
4302 /* There is a syminfo section. Read the data. */
4303 extsyminfo
= ((Elf_External_Syminfo
*)
4304 get_data (NULL
, file
, dynamic_syminfo_offset
,
4305 syminsz
, _("symbol information")));
4309 dynamic_syminfo
= (Elf_Internal_Syminfo
*) malloc (syminsz
);
4310 if (dynamic_syminfo
== NULL
)
4312 error (_("Out of memory\n"));
4316 dynamic_syminfo_nent
= syminsz
/ sizeof (Elf_External_Syminfo
);
4317 for (i
= 0, syminfo
= dynamic_syminfo
; i
< dynamic_syminfo_nent
;
4320 syminfo
->si_boundto
= BYTE_GET (extsyminfo
[i
].si_boundto
);
4321 syminfo
->si_flags
= BYTE_GET (extsyminfo
[i
].si_flags
);
4328 if (do_dynamic
&& dynamic_addr
)
4329 printf (_("\nDynamic segment at offset 0x%x contains %ld entries:\n"),
4330 dynamic_addr
, (long) dynamic_size
);
4332 printf (_(" Tag Type Name/Value\n"));
4334 for (i
= 0, entry
= dynamic_segment
;
4343 print_vma (entry
->d_tag
, FULL_HEX
);
4344 dtype
= get_dynamic_type (entry
->d_tag
);
4345 printf (" (%s)%*s", dtype
,
4346 ((is_32bit_elf
? 27 : 19)
4347 - (int) strlen (dtype
)),
4351 switch (entry
->d_tag
)
4355 printf ("%s", get_dynamic_flags (entry
->d_un
.d_val
));
4365 switch (entry
->d_tag
)
4368 printf (_("Auxiliary library"));
4372 printf (_("Filter library"));
4376 printf (_("Configuration file"));
4380 printf (_("Dependency audit library"));
4384 printf (_("Audit library"));
4388 if (dynamic_strings
)
4389 printf (": [%s]\n", dynamic_strings
+ entry
->d_un
.d_val
);
4393 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4402 printf (_("Flags:"));
4403 if (entry
->d_un
.d_val
== 0)
4404 printf (_(" None\n"));
4407 unsigned long int val
= entry
->d_un
.d_val
;
4408 if (val
& DTF_1_PARINIT
)
4410 printf (" PARINIT");
4411 val
^= DTF_1_PARINIT
;
4413 if (val
& DTF_1_CONFEXP
)
4415 printf (" CONFEXP");
4416 val
^= DTF_1_CONFEXP
;
4419 printf (" %lx", val
);
4428 printf (_("Flags:"));
4429 if (entry
->d_un
.d_val
== 0)
4430 printf (_(" None\n"));
4433 unsigned long int val
= entry
->d_un
.d_val
;
4434 if (val
& DF_P1_LAZYLOAD
)
4436 printf (" LAZYLOAD");
4437 val
^= DF_P1_LAZYLOAD
;
4439 if (val
& DF_P1_GROUPPERM
)
4441 printf (" GROUPPERM");
4442 val
^= DF_P1_GROUPPERM
;
4445 printf (" %lx", val
);
4454 printf (_("Flags:"));
4455 if (entry
->d_un
.d_val
== 0)
4456 printf (_(" None\n"));
4459 unsigned long int val
= entry
->d_un
.d_val
;
4465 if (val
& DF_1_GLOBAL
)
4470 if (val
& DF_1_GROUP
)
4475 if (val
& DF_1_NODELETE
)
4477 printf (" NODELETE");
4478 val
^= DF_1_NODELETE
;
4480 if (val
& DF_1_LOADFLTR
)
4482 printf (" LOADFLTR");
4483 val
^= DF_1_LOADFLTR
;
4485 if (val
& DF_1_INITFIRST
)
4487 printf (" INITFIRST");
4488 val
^= DF_1_INITFIRST
;
4490 if (val
& DF_1_NOOPEN
)
4495 if (val
& DF_1_ORIGIN
)
4500 if (val
& DF_1_DIRECT
)
4505 if (val
& DF_1_TRANS
)
4510 if (val
& DF_1_INTERPOSE
)
4512 printf (" INTERPOSE");
4513 val
^= DF_1_INTERPOSE
;
4515 if (val
& DF_1_NODEFLIB
)
4517 printf (" NODEFLIB");
4518 val
^= DF_1_NODEFLIB
;
4520 if (val
& DF_1_NODUMP
)
4525 if (val
& DF_1_CONLFAT
)
4527 printf (" CONLFAT");
4528 val
^= DF_1_CONLFAT
;
4531 printf (" %lx", val
);
4539 puts (get_dynamic_type (entry
->d_un
.d_val
));
4559 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
4565 if (dynamic_strings
== NULL
)
4568 name
= dynamic_strings
+ entry
->d_un
.d_val
;
4572 switch (entry
->d_tag
)
4575 printf (_("Shared library: [%s]"), name
);
4577 if (strcmp (name
, program_interpreter
) == 0)
4578 printf (_(" program interpreter"));
4582 printf (_("Library soname: [%s]"), name
);
4586 printf (_("Library rpath: [%s]"), name
);
4590 printf (_("Library runpath: [%s]"), name
);
4594 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4599 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4615 case DT_INIT_ARRAYSZ
:
4616 case DT_FINI_ARRAYSZ
:
4619 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
4620 printf (" (bytes)\n");
4630 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
4643 if (dynamic_strings
!= NULL
&& entry
->d_tag
== DT_USED
)
4647 name
= dynamic_strings
+ entry
->d_un
.d_val
;
4651 printf (_("Not needed object: [%s]\n"), name
);
4656 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4662 /* The value of this entry is ignored. */
4666 if ((entry
->d_tag
>= DT_VERSYM
) && (entry
->d_tag
<= DT_VERNEEDNUM
))
4667 version_info
[DT_VERSIONTAGIDX (entry
->d_tag
)] =
4672 switch (elf_header
.e_machine
)
4675 case EM_MIPS_RS3_LE
:
4676 dynamic_segment_mips_val (entry
);
4679 dynamic_segment_parisc_val (entry
);
4682 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4694 get_ver_flags (flags
)
4697 static char buff
[32];
4704 if (flags
& VER_FLG_BASE
)
4705 strcat (buff
, "BASE ");
4707 if (flags
& VER_FLG_WEAK
)
4709 if (flags
& VER_FLG_BASE
)
4710 strcat (buff
, "| ");
4712 strcat (buff
, "WEAK ");
4715 if (flags
& ~(VER_FLG_BASE
| VER_FLG_WEAK
))
4716 strcat (buff
, "| <unknown>");
4721 /* Display the contents of the version sections. */
4723 process_version_sections (file
)
4726 Elf32_Internal_Shdr
* section
;
4733 for (i
= 0, section
= section_headers
;
4734 i
< elf_header
.e_shnum
;
4737 switch (section
->sh_type
)
4739 case SHT_GNU_verdef
:
4741 Elf_External_Verdef
* edefs
;
4748 (_("\nVersion definition section '%s' contains %ld entries:\n"),
4749 SECTION_NAME (section
), section
->sh_info
);
4751 printf (_(" Addr: 0x"));
4752 printf_vma (section
->sh_addr
);
4753 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
4754 (unsigned long) section
->sh_offset
, section
->sh_link
,
4755 SECTION_NAME (SECTION_HEADER (section
->sh_link
)));
4757 edefs
= ((Elf_External_Verdef
*)
4758 get_data (NULL
, file
, section
->sh_offset
,
4760 _("version definition section")));
4764 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++ cnt
)
4767 Elf_External_Verdef
* edef
;
4768 Elf_Internal_Verdef ent
;
4769 Elf_External_Verdaux
* eaux
;
4770 Elf_Internal_Verdaux aux
;
4774 vstart
= ((char *) edefs
) + idx
;
4776 edef
= (Elf_External_Verdef
*) vstart
;
4778 ent
.vd_version
= BYTE_GET (edef
->vd_version
);
4779 ent
.vd_flags
= BYTE_GET (edef
->vd_flags
);
4780 ent
.vd_ndx
= BYTE_GET (edef
->vd_ndx
);
4781 ent
.vd_cnt
= BYTE_GET (edef
->vd_cnt
);
4782 ent
.vd_hash
= BYTE_GET (edef
->vd_hash
);
4783 ent
.vd_aux
= BYTE_GET (edef
->vd_aux
);
4784 ent
.vd_next
= BYTE_GET (edef
->vd_next
);
4786 printf (_(" %#06x: Rev: %d Flags: %s"),
4787 idx
, ent
.vd_version
, get_ver_flags (ent
.vd_flags
));
4789 printf (_(" Index: %d Cnt: %d "),
4790 ent
.vd_ndx
, ent
.vd_cnt
);
4792 vstart
+= ent
.vd_aux
;
4794 eaux
= (Elf_External_Verdaux
*) vstart
;
4796 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
4797 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
4799 if (dynamic_strings
)
4800 printf (_("Name: %s\n"), dynamic_strings
+ aux
.vda_name
);
4802 printf (_("Name index: %ld\n"), aux
.vda_name
);
4804 isum
= idx
+ ent
.vd_aux
;
4806 for (j
= 1; j
< ent
.vd_cnt
; j
++)
4808 isum
+= aux
.vda_next
;
4809 vstart
+= aux
.vda_next
;
4811 eaux
= (Elf_External_Verdaux
*) vstart
;
4813 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
4814 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
4816 if (dynamic_strings
)
4817 printf (_(" %#06x: Parent %d: %s\n"),
4818 isum
, j
, dynamic_strings
+ aux
.vda_name
);
4820 printf (_(" %#06x: Parent %d, name index: %ld\n"),
4821 isum
, j
, aux
.vda_name
);
4831 case SHT_GNU_verneed
:
4833 Elf_External_Verneed
* eneed
;
4839 printf (_("\nVersion needs section '%s' contains %ld entries:\n"),
4840 SECTION_NAME (section
), section
->sh_info
);
4842 printf (_(" Addr: 0x"));
4843 printf_vma (section
->sh_addr
);
4844 printf (_(" Offset: %#08lx Link to section: %ld (%s)\n"),
4845 (unsigned long) section
->sh_offset
, section
->sh_link
,
4846 SECTION_NAME (SECTION_HEADER (section
->sh_link
)));
4848 eneed
= ((Elf_External_Verneed
*)
4849 get_data (NULL
, file
, section
->sh_offset
,
4850 section
->sh_size
, _("version need section")));
4854 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
4856 Elf_External_Verneed
* entry
;
4857 Elf_Internal_Verneed ent
;
4862 vstart
= ((char *) eneed
) + idx
;
4864 entry
= (Elf_External_Verneed
*) vstart
;
4866 ent
.vn_version
= BYTE_GET (entry
->vn_version
);
4867 ent
.vn_cnt
= BYTE_GET (entry
->vn_cnt
);
4868 ent
.vn_file
= BYTE_GET (entry
->vn_file
);
4869 ent
.vn_aux
= BYTE_GET (entry
->vn_aux
);
4870 ent
.vn_next
= BYTE_GET (entry
->vn_next
);
4872 printf (_(" %#06x: Version: %d"), idx
, ent
.vn_version
);
4874 if (dynamic_strings
)
4875 printf (_(" File: %s"), dynamic_strings
+ ent
.vn_file
);
4877 printf (_(" File: %lx"), ent
.vn_file
);
4879 printf (_(" Cnt: %d\n"), ent
.vn_cnt
);
4881 vstart
+= ent
.vn_aux
;
4883 for (j
= 0, isum
= idx
+ ent
.vn_aux
; j
< ent
.vn_cnt
; ++j
)
4885 Elf_External_Vernaux
* eaux
;
4886 Elf_Internal_Vernaux aux
;
4888 eaux
= (Elf_External_Vernaux
*) vstart
;
4890 aux
.vna_hash
= BYTE_GET (eaux
->vna_hash
);
4891 aux
.vna_flags
= BYTE_GET (eaux
->vna_flags
);
4892 aux
.vna_other
= BYTE_GET (eaux
->vna_other
);
4893 aux
.vna_name
= BYTE_GET (eaux
->vna_name
);
4894 aux
.vna_next
= BYTE_GET (eaux
->vna_next
);
4896 if (dynamic_strings
)
4897 printf (_(" %#06x: Name: %s"),
4898 isum
, dynamic_strings
+ aux
.vna_name
);
4900 printf (_(" %#06x: Name index: %lx"),
4901 isum
, aux
.vna_name
);
4903 printf (_(" Flags: %s Version: %d\n"),
4904 get_ver_flags (aux
.vna_flags
), aux
.vna_other
);
4906 isum
+= aux
.vna_next
;
4907 vstart
+= aux
.vna_next
;
4917 case SHT_GNU_versym
:
4919 Elf32_Internal_Shdr
* link_section
;
4922 unsigned char * edata
;
4923 unsigned short * data
;
4925 Elf_Internal_Sym
* symbols
;
4926 Elf32_Internal_Shdr
* string_sec
;
4928 link_section
= SECTION_HEADER (section
->sh_link
);
4929 total
= section
->sh_size
/ section
->sh_entsize
;
4933 symbols
= GET_ELF_SYMBOLS (file
, link_section
);
4935 string_sec
= SECTION_HEADER (link_section
->sh_link
);
4937 strtab
= (char *) get_data (NULL
, file
, string_sec
->sh_offset
,
4938 string_sec
->sh_size
,
4939 _("version string table"));
4943 printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
4944 SECTION_NAME (section
), total
);
4946 printf (_(" Addr: "));
4947 printf_vma (section
->sh_addr
);
4948 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
4949 (unsigned long) section
->sh_offset
, section
->sh_link
,
4950 SECTION_NAME (link_section
));
4954 get_data (NULL
, file
,
4955 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] - loadaddr
,
4956 total
* sizeof (short), _("version symbol data")));
4963 data
= (unsigned short *) malloc (total
* sizeof (short));
4965 for (cnt
= total
; cnt
--;)
4966 data
[cnt
] = byte_get (edata
+ cnt
* sizeof (short),
4971 for (cnt
= 0; cnt
< total
; cnt
+= 4)
4974 int check_def
, check_need
;
4977 printf (" %03x:", cnt
);
4979 for (j
= 0; (j
< 4) && (cnt
+ j
) < total
; ++j
)
4980 switch (data
[cnt
+ j
])
4983 fputs (_(" 0 (*local*) "), stdout
);
4987 fputs (_(" 1 (*global*) "), stdout
);
4991 nn
= printf ("%4x%c", data
[cnt
+ j
] & 0x7fff,
4992 data
[cnt
+ j
] & 0x8000 ? 'h' : ' ');
4996 if (SECTION_HEADER (symbols
[cnt
+ j
].st_shndx
)->sh_type
4999 if (symbols
[cnt
+ j
].st_shndx
== SHN_UNDEF
)
5006 && version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)])
5008 Elf_Internal_Verneed ivn
;
5009 unsigned long offset
;
5011 offset
= version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
5016 Elf_Internal_Vernaux ivna
;
5017 Elf_External_Verneed evn
;
5018 Elf_External_Vernaux evna
;
5019 unsigned long a_off
;
5021 get_data (&evn
, file
, offset
, sizeof (evn
),
5024 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
5025 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
5027 a_off
= offset
+ ivn
.vn_aux
;
5031 get_data (&evna
, file
, a_off
, sizeof (evna
),
5032 _("version need aux (2)"));
5034 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
5035 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
5037 a_off
+= ivna
.vna_next
;
5039 while (ivna
.vna_other
!= data
[cnt
+ j
]
5040 && ivna
.vna_next
!= 0);
5042 if (ivna
.vna_other
== data
[cnt
+ j
])
5044 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
5046 name
= strtab
+ ivna
.vna_name
;
5047 nn
+= printf ("(%s%-*s",
5049 12 - (int) strlen (name
),
5055 offset
+= ivn
.vn_next
;
5057 while (ivn
.vn_next
);
5060 if (check_def
&& data
[cnt
+ j
] != 0x8001
5061 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
5063 Elf_Internal_Verdef ivd
;
5064 Elf_External_Verdef evd
;
5065 unsigned long offset
;
5067 offset
= version_info
5068 [DT_VERSIONTAGIDX (DT_VERDEF
)] - loadaddr
;
5072 get_data (&evd
, file
, offset
, sizeof (evd
),
5075 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
5076 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
5078 offset
+= ivd
.vd_next
;
5080 while (ivd
.vd_ndx
!= (data
[cnt
+ j
] & 0x7fff)
5081 && ivd
.vd_next
!= 0);
5083 if (ivd
.vd_ndx
== (data
[cnt
+ j
] & 0x7fff))
5085 Elf_External_Verdaux evda
;
5086 Elf_Internal_Verdaux ivda
;
5088 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
5090 get_data (&evda
, file
,
5091 offset
- ivd
.vd_next
+ ivd
.vd_aux
,
5092 sizeof (evda
), _("version def aux"));
5094 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
5096 name
= strtab
+ ivda
.vda_name
;
5097 nn
+= printf ("(%s%-*s",
5099 12 - (int) strlen (name
),
5105 printf ("%*c", 18 - nn
, ' ');
5123 printf (_("\nNo version information found in this file.\n"));
5129 get_symbol_binding (binding
)
5130 unsigned int binding
;
5132 static char buff
[32];
5136 case STB_LOCAL
: return "LOCAL";
5137 case STB_GLOBAL
: return "GLOBAL";
5138 case STB_WEAK
: return "WEAK";
5140 if (binding
>= STB_LOPROC
&& binding
<= STB_HIPROC
)
5141 sprintf (buff
, _("<processor specific>: %d"), binding
);
5142 else if (binding
>= STB_LOOS
&& binding
<= STB_HIOS
)
5143 sprintf (buff
, _("<OS specific>: %d"), binding
);
5145 sprintf (buff
, _("<unknown>: %d"), binding
);
5151 get_symbol_type (type
)
5154 static char buff
[32];
5158 case STT_NOTYPE
: return "NOTYPE";
5159 case STT_OBJECT
: return "OBJECT";
5160 case STT_FUNC
: return "FUNC";
5161 case STT_SECTION
: return "SECTION";
5162 case STT_FILE
: return "FILE";
5163 case STT_COMMON
: return "COMMON";
5165 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
5167 if (elf_header
.e_machine
== EM_ARM
&& type
== STT_ARM_TFUNC
)
5168 return "THUMB_FUNC";
5170 if (elf_header
.e_machine
== EM_SPARCV9
&& type
== STT_REGISTER
)
5173 if (elf_header
.e_machine
== EM_PARISC
&& type
== STT_PARISC_MILLI
)
5174 return "PARISC_MILLI";
5176 sprintf (buff
, _("<processor specific>: %d"), type
);
5178 else if (type
>= STT_LOOS
&& type
<= STT_HIOS
)
5180 if (elf_header
.e_machine
== EM_PARISC
)
5182 if (type
== STT_HP_OPAQUE
)
5184 if (type
== STT_HP_STUB
)
5188 sprintf (buff
, _("<OS specific>: %d"), type
);
5191 sprintf (buff
, _("<unknown>: %d"), type
);
5197 get_symbol_visibility (visibility
)
5198 unsigned int visibility
;
5202 case STV_DEFAULT
: return "DEFAULT";
5203 case STV_INTERNAL
: return "INTERNAL";
5204 case STV_HIDDEN
: return "HIDDEN";
5205 case STV_PROTECTED
: return "PROTECTED";
5211 get_symbol_index_type (type
)
5216 case SHN_UNDEF
: return "UND";
5217 case SHN_ABS
: return "ABS";
5218 case SHN_COMMON
: return "COM";
5220 if (type
>= SHN_LOPROC
&& type
<= SHN_HIPROC
)
5222 else if (type
>= SHN_LOOS
&& type
<= SHN_HIOS
)
5224 else if (type
>= SHN_LORESERVE
&& type
<= SHN_HIRESERVE
)
5228 static char buff
[32];
5230 sprintf (buff
, "%3d", type
);
5237 get_dynamic_data (file
, number
)
5239 unsigned int number
;
5241 unsigned char * e_data
;
5244 e_data
= (unsigned char *) malloc (number
* 4);
5248 error (_("Out of memory\n"));
5252 if (fread (e_data
, 4, number
, file
) != number
)
5254 error (_("Unable to read in dynamic data\n"));
5258 i_data
= (int *) malloc (number
* sizeof (* i_data
));
5262 error (_("Out of memory\n"));
5268 i_data
[number
] = byte_get (e_data
+ number
* 4, 4);
5275 /* Dump the symbol table. */
5277 process_symbol_table (file
)
5280 Elf32_Internal_Shdr
* section
;
5281 unsigned char nb
[4];
5282 unsigned char nc
[4];
5285 int * buckets
= NULL
;
5286 int * chains
= NULL
;
5288 if (! do_syms
&& !do_histogram
)
5291 if (dynamic_info
[DT_HASH
] && ((do_using_dynamic
&& dynamic_strings
!= NULL
)
5294 if (fseek (file
, dynamic_info
[DT_HASH
] - loadaddr
, SEEK_SET
))
5296 error (_("Unable to seek to start of dynamic information"));
5300 if (fread (nb
, sizeof (nb
), 1, file
) != 1)
5302 error (_("Failed to read in number of buckets\n"));
5306 if (fread (nc
, sizeof (nc
), 1, file
) != 1)
5308 error (_("Failed to read in number of chains\n"));
5312 nbuckets
= byte_get (nb
, 4);
5313 nchains
= byte_get (nc
, 4);
5315 buckets
= get_dynamic_data (file
, nbuckets
);
5316 chains
= get_dynamic_data (file
, nchains
);
5318 if (buckets
== NULL
|| chains
== NULL
)
5323 && dynamic_info
[DT_HASH
] && do_using_dynamic
&& dynamic_strings
!= NULL
)
5328 printf (_("\nSymbol table for image:\n"));
5330 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
5332 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
5334 for (hn
= 0; hn
< nbuckets
; hn
++)
5339 for (si
= buckets
[hn
]; si
< nchains
&& si
> 0; si
= chains
[si
])
5341 Elf_Internal_Sym
* psym
;
5343 psym
= dynamic_symbols
+ si
;
5345 printf (" %3d %3d: ", si
, hn
);
5346 print_vma (psym
->st_value
, LONG_HEX
);
5348 print_vma (psym
->st_size
, DEC_5
);
5350 printf (" %6s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
5351 printf (" %6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
5352 printf (" %3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
5353 printf (" %3.3s ", get_symbol_index_type (psym
->st_shndx
));
5354 print_symbol (25, dynamic_strings
+ psym
->st_name
);
5359 else if (do_syms
&& !do_using_dynamic
)
5363 for (i
= 0, section
= section_headers
;
5364 i
< elf_header
.e_shnum
;
5369 Elf_Internal_Sym
* symtab
;
5370 Elf_Internal_Sym
* psym
;
5373 if ( section
->sh_type
!= SHT_SYMTAB
5374 && section
->sh_type
!= SHT_DYNSYM
)
5377 printf (_("\nSymbol table '%s' contains %lu entries:\n"),
5378 SECTION_NAME (section
),
5379 (unsigned long) (section
->sh_size
/ section
->sh_entsize
));
5381 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
5383 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
5385 symtab
= GET_ELF_SYMBOLS (file
, section
);
5389 if (section
->sh_link
== elf_header
.e_shstrndx
)
5390 strtab
= string_table
;
5393 Elf32_Internal_Shdr
* string_sec
;
5395 string_sec
= SECTION_HEADER (section
->sh_link
);
5397 strtab
= (char *) get_data (NULL
, file
, string_sec
->sh_offset
,
5398 string_sec
->sh_size
,
5402 for (si
= 0, psym
= symtab
;
5403 si
< section
->sh_size
/ section
->sh_entsize
;
5406 printf ("%6d: ", si
);
5407 print_vma (psym
->st_value
, LONG_HEX
);
5409 print_vma (psym
->st_size
, DEC_5
);
5410 printf (" %-7s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
5411 printf (" %-6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
5412 printf (" %-3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
5413 printf (" %4s ", get_symbol_index_type (psym
->st_shndx
));
5414 print_symbol (25, strtab
+ psym
->st_name
);
5416 if (section
->sh_type
== SHT_DYNSYM
&&
5417 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] != 0)
5419 unsigned char data
[2];
5420 unsigned short vers_data
;
5421 unsigned long offset
;
5425 offset
= version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)]
5428 get_data (&data
, file
, offset
+ si
* sizeof (vers_data
),
5429 sizeof (data
), _("version data"));
5431 vers_data
= byte_get (data
, 2);
5433 is_nobits
= (SECTION_HEADER (psym
->st_shndx
)->sh_type
5436 check_def
= (psym
->st_shndx
!= SHN_UNDEF
);
5438 if ((vers_data
& 0x8000) || vers_data
> 1)
5440 if (version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
5441 && (is_nobits
|| ! check_def
))
5443 Elf_External_Verneed evn
;
5444 Elf_Internal_Verneed ivn
;
5445 Elf_Internal_Vernaux ivna
;
5447 /* We must test both. */
5448 offset
= version_info
5449 [DT_VERSIONTAGIDX (DT_VERNEED
)] - loadaddr
;
5453 unsigned long vna_off
;
5455 get_data (&evn
, file
, offset
, sizeof (evn
),
5458 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
5459 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
5461 vna_off
= offset
+ ivn
.vn_aux
;
5465 Elf_External_Vernaux evna
;
5467 get_data (&evna
, file
, vna_off
,
5469 _("version need aux (3)"));
5471 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
5472 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
5473 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
5475 vna_off
+= ivna
.vna_next
;
5477 while (ivna
.vna_other
!= vers_data
5478 && ivna
.vna_next
!= 0);
5480 if (ivna
.vna_other
== vers_data
)
5483 offset
+= ivn
.vn_next
;
5485 while (ivn
.vn_next
!= 0);
5487 if (ivna
.vna_other
== vers_data
)
5490 strtab
+ ivna
.vna_name
, ivna
.vna_other
);
5493 else if (! is_nobits
)
5494 error (_("bad dynamic symbol"));
5501 if (vers_data
!= 0x8001
5502 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
5504 Elf_Internal_Verdef ivd
;
5505 Elf_Internal_Verdaux ivda
;
5506 Elf_External_Verdaux evda
;
5507 unsigned long offset
;
5510 version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)]
5515 Elf_External_Verdef evd
;
5517 get_data (&evd
, file
, offset
, sizeof (evd
),
5520 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
5521 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
5522 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
5524 offset
+= ivd
.vd_next
;
5526 while (ivd
.vd_ndx
!= (vers_data
& 0x7fff)
5527 && ivd
.vd_next
!= 0);
5529 offset
-= ivd
.vd_next
;
5530 offset
+= ivd
.vd_aux
;
5532 get_data (&evda
, file
, offset
, sizeof (evda
),
5533 _("version def aux"));
5535 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
5537 if (psym
->st_name
!= ivda
.vda_name
)
5538 printf ((vers_data
& 0x8000)
5540 strtab
+ ivda
.vda_name
);
5550 if (strtab
!= string_table
)
5556 (_("\nDynamic symbol information is not available for displaying symbols.\n"));
5558 if (do_histogram
&& buckets
!= NULL
)
5565 int nzero_counts
= 0;
5568 printf (_("\nHistogram for bucket list length (total of %d buckets):\n"),
5570 printf (_(" Length Number %% of total Coverage\n"));
5572 lengths
= (int *) calloc (nbuckets
, sizeof (int));
5573 if (lengths
== NULL
)
5575 error (_("Out of memory"));
5578 for (hn
= 0; hn
< nbuckets
; ++hn
)
5583 for (si
= buckets
[hn
]; si
> 0 && si
< nchains
; si
= chains
[si
])
5586 if (maxlength
< ++lengths
[hn
])
5591 counts
= (int *) calloc (maxlength
+ 1, sizeof (int));
5594 error (_("Out of memory"));
5598 for (hn
= 0; hn
< nbuckets
; ++hn
)
5599 ++ counts
[lengths
[hn
]];
5603 printf (" 0 %-10d (%5.1f%%)\n",
5604 counts
[0], (counts
[0] * 100.0) / nbuckets
);
5605 for (si
= 1; si
<= maxlength
; ++si
)
5607 nzero_counts
+= counts
[si
] * si
;
5608 printf ("%7d %-10d (%5.1f%%) %5.1f%%\n",
5609 si
, counts
[si
], (counts
[si
] * 100.0) / nbuckets
,
5610 (nzero_counts
* 100.0) / nsyms
);
5618 if (buckets
!= NULL
)
5628 process_syminfo (file
)
5629 FILE * file ATTRIBUTE_UNUSED
;
5633 if (dynamic_syminfo
== NULL
5635 /* No syminfo, this is ok. */
5638 /* There better should be a dynamic symbol section. */
5639 if (dynamic_symbols
== NULL
|| dynamic_strings
== NULL
)
5643 printf (_("\nDynamic info segment at offset 0x%lx contains %d entries:\n"),
5644 dynamic_syminfo_offset
, dynamic_syminfo_nent
);
5646 printf (_(" Num: Name BoundTo Flags\n"));
5647 for (i
= 0; i
< dynamic_syminfo_nent
; ++i
)
5649 unsigned short int flags
= dynamic_syminfo
[i
].si_flags
;
5651 printf ("%4d: ", i
);
5652 print_symbol (30, dynamic_strings
+ dynamic_symbols
[i
].st_name
);
5655 switch (dynamic_syminfo
[i
].si_boundto
)
5657 case SYMINFO_BT_SELF
:
5658 fputs ("SELF ", stdout
);
5660 case SYMINFO_BT_PARENT
:
5661 fputs ("PARENT ", stdout
);
5664 if (dynamic_syminfo
[i
].si_boundto
> 0
5665 && dynamic_syminfo
[i
].si_boundto
< dynamic_size
)
5667 print_symbol (10, dynamic_strings
5669 [dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
);
5673 printf ("%-10d ", dynamic_syminfo
[i
].si_boundto
);
5677 if (flags
& SYMINFO_FLG_DIRECT
)
5679 if (flags
& SYMINFO_FLG_PASSTHRU
)
5680 printf (" PASSTHRU");
5681 if (flags
& SYMINFO_FLG_COPY
)
5683 if (flags
& SYMINFO_FLG_LAZYLOAD
)
5684 printf (" LAZYLOAD");
5692 #ifdef SUPPORT_DISASSEMBLY
5694 disassemble_section (section
, file
)
5695 Elf32_Internal_Shdr
* section
;
5698 printf (_("\nAssembly dump of section %s\n"),
5699 SECTION_NAME (section
));
5701 /* XXX -- to be done --- XXX */
5708 dump_section (section
, file
)
5709 Elf32_Internal_Shdr
* section
;
5712 bfd_size_type bytes
;
5714 unsigned char * data
;
5715 unsigned char * start
;
5717 bytes
= section
->sh_size
;
5721 printf (_("\nSection '%s' has no data to dump.\n"),
5722 SECTION_NAME (section
));
5726 printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section
));
5728 addr
= section
->sh_addr
;
5730 start
= (unsigned char *) get_data (NULL
, file
, section
->sh_offset
, bytes
,
5743 lbytes
= (bytes
> 16 ? 16 : bytes
);
5745 printf (" 0x%8.8lx ", (unsigned long) addr
);
5747 switch (elf_header
.e_ident
[EI_DATA
])
5751 for (j
= 15; j
>= 0; j
--)
5754 printf ("%2.2x", data
[j
]);
5764 for (j
= 0; j
< 16; j
++)
5767 printf ("%2.2x", data
[j
]);
5777 for (j
= 0; j
< lbytes
; j
++)
5780 if (k
>= ' ' && k
< 0x80)
5799 static unsigned long int
5800 read_leb128 (data
, length_return
, sign
)
5801 unsigned char * data
;
5802 int * length_return
;
5805 unsigned long int result
= 0;
5806 unsigned int num_read
= 0;
5815 result
|= (byte
& 0x7f) << shift
;
5820 while (byte
& 0x80);
5822 if (length_return
!= NULL
)
5823 * length_return
= num_read
;
5825 if (sign
&& (shift
< 32) && (byte
& 0x40))
5826 result
|= -1 << shift
;
5831 typedef struct State_Machine_Registers
5833 unsigned long address
;
5836 unsigned int column
;
5840 /* This variable hold the number of the last entry seen
5841 in the File Table. */
5842 unsigned int last_file_entry
;
5845 static SMR state_machine_regs
;
5848 reset_state_machine (is_stmt
)
5851 state_machine_regs
.address
= 0;
5852 state_machine_regs
.file
= 1;
5853 state_machine_regs
.line
= 1;
5854 state_machine_regs
.column
= 0;
5855 state_machine_regs
.is_stmt
= is_stmt
;
5856 state_machine_regs
.basic_block
= 0;
5857 state_machine_regs
.end_sequence
= 0;
5858 state_machine_regs
.last_file_entry
= 0;
5861 /* Handled an extend line op. Returns true if this is the end
5864 process_extended_line_op (data
, is_stmt
, pointer_size
)
5865 unsigned char * data
;
5869 unsigned char op_code
;
5872 unsigned char * name
;
5875 len
= read_leb128 (data
, & bytes_read
, 0);
5880 warn (_("badly formed extended line op encountered!\n"));
5885 op_code
= * data
++;
5887 printf (_(" Extended opcode %d: "), op_code
);
5891 case DW_LNE_end_sequence
:
5892 printf (_("End of Sequence\n\n"));
5893 reset_state_machine (is_stmt
);
5896 case DW_LNE_set_address
:
5897 adr
= byte_get (data
, pointer_size
);
5898 printf (_("set Address to 0x%lx\n"), adr
);
5899 state_machine_regs
.address
= adr
;
5902 case DW_LNE_define_file
:
5903 printf (_(" define new File Table entry\n"));
5904 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
5906 printf (_(" %d\t"), ++ state_machine_regs
.last_file_entry
);
5908 data
+= strlen ((char *) data
) + 1;
5909 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
5911 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
5913 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
5914 printf (_("%s\n\n"), name
);
5918 printf (_("UNKNOWN: length %d\n"), len
- bytes_read
);
5925 /* Size of pointers in the .debug_line section. This information is not
5926 really present in that section. It's obtained before dumping the debug
5927 sections by doing some pre-scan of the .debug_info section. */
5928 static int debug_line_pointer_size
= 4;
5931 display_debug_lines (section
, start
, file
)
5932 Elf32_Internal_Shdr
* section
;
5933 unsigned char * start
;
5934 FILE * file ATTRIBUTE_UNUSED
;
5936 DWARF2_External_LineInfo
* external
;
5937 DWARF2_Internal_LineInfo info
;
5938 unsigned char * standard_opcodes
;
5939 unsigned char * data
= start
;
5940 unsigned char * end
= start
+ section
->sh_size
;
5941 unsigned char * end_of_sequence
;
5944 printf (_("\nDump of debug contents of section %s:\n\n"),
5945 SECTION_NAME (section
));
5949 external
= (DWARF2_External_LineInfo
*) data
;
5951 /* Check the length of the block. */
5952 info
.li_length
= BYTE_GET (external
->li_length
);
5954 if (info
.li_length
== 0xffffffff)
5956 warn (_("64-bit DWARF line info is not supported yet.\n"));
5960 if (info
.li_length
+ sizeof (external
->li_length
) > section
->sh_size
)
5963 (_("The line info appears to be corrupt - the section is too small\n"));
5967 /* Check its version number. */
5968 info
.li_version
= BYTE_GET (external
->li_version
);
5969 if (info
.li_version
!= 2)
5971 warn (_("Only DWARF version 2 line info is currently supported.\n"));
5975 info
.li_prologue_length
= BYTE_GET (external
->li_prologue_length
);
5976 info
.li_min_insn_length
= BYTE_GET (external
->li_min_insn_length
);
5977 info
.li_default_is_stmt
= BYTE_GET (external
->li_default_is_stmt
);
5978 info
.li_line_base
= BYTE_GET (external
->li_line_base
);
5979 info
.li_line_range
= BYTE_GET (external
->li_line_range
);
5980 info
.li_opcode_base
= BYTE_GET (external
->li_opcode_base
);
5982 /* Sign extend the line base field. */
5983 info
.li_line_base
<<= 24;
5984 info
.li_line_base
>>= 24;
5986 printf (_(" Length: %ld\n"), info
.li_length
);
5987 printf (_(" DWARF Version: %d\n"), info
.li_version
);
5988 printf (_(" Prologue Length: %d\n"), info
.li_prologue_length
);
5989 printf (_(" Minimum Instruction Length: %d\n"), info
.li_min_insn_length
);
5990 printf (_(" Initial value of 'is_stmt': %d\n"), info
.li_default_is_stmt
);
5991 printf (_(" Line Base: %d\n"), info
.li_line_base
);
5992 printf (_(" Line Range: %d\n"), info
.li_line_range
);
5993 printf (_(" Opcode Base: %d\n"), info
.li_opcode_base
);
5995 end_of_sequence
= data
+ info
.li_length
+ sizeof (external
->li_length
);
5997 reset_state_machine (info
.li_default_is_stmt
);
5999 /* Display the contents of the Opcodes table. */
6000 standard_opcodes
= data
+ sizeof (* external
);
6002 printf (_("\n Opcodes:\n"));
6004 for (i
= 1; i
< info
.li_opcode_base
; i
++)
6005 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
6007 /* Display the contents of the Directory table. */
6008 data
= standard_opcodes
+ info
.li_opcode_base
- 1;
6011 printf (_("\n The Directory Table is empty.\n"));
6014 printf (_("\n The Directory Table:\n"));
6018 printf (_(" %s\n"), data
);
6020 data
+= strlen ((char *) data
) + 1;
6024 /* Skip the NUL at the end of the table. */
6027 /* Display the contents of the File Name table. */
6029 printf (_("\n The File Name Table is empty.\n"));
6032 printf (_("\n The File Name Table:\n"));
6033 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
6037 unsigned char * name
;
6040 printf (_(" %d\t"), ++ state_machine_regs
.last_file_entry
);
6043 data
+= strlen ((char *) data
) + 1;
6045 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6047 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6049 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6051 printf (_("%s\n"), name
);
6055 /* Skip the NUL at the end of the table. */
6058 /* Now display the statements. */
6059 printf (_("\n Line Number Statements:\n"));
6062 while (data
< end_of_sequence
)
6064 unsigned char op_code
;
6068 op_code
= * data
++;
6070 if (op_code
>= info
.li_opcode_base
)
6072 op_code
-= info
.li_opcode_base
;
6073 adv
= (op_code
/ info
.li_line_range
) * info
.li_min_insn_length
;
6074 state_machine_regs
.address
+= adv
;
6075 printf (_(" Special opcode %d: advance Address by %d to 0x%lx"),
6076 op_code
, adv
, state_machine_regs
.address
);
6077 adv
= (op_code
% info
.li_line_range
) + info
.li_line_base
;
6078 state_machine_regs
.line
+= adv
;
6079 printf (_(" and Line by %d to %d\n"),
6080 adv
, state_machine_regs
.line
);
6082 else switch (op_code
)
6084 case DW_LNS_extended_op
:
6085 data
+= process_extended_line_op (data
, info
.li_default_is_stmt
,
6086 debug_line_pointer_size
);
6090 printf (_(" Copy\n"));
6093 case DW_LNS_advance_pc
:
6094 adv
= info
.li_min_insn_length
* read_leb128 (data
, & bytes_read
, 0);
6096 state_machine_regs
.address
+= adv
;
6097 printf (_(" Advance PC by %d to %lx\n"), adv
,
6098 state_machine_regs
.address
);
6101 case DW_LNS_advance_line
:
6102 adv
= read_leb128 (data
, & bytes_read
, 1);
6104 state_machine_regs
.line
+= adv
;
6105 printf (_(" Advance Line by %d to %d\n"), adv
,
6106 state_machine_regs
.line
);
6109 case DW_LNS_set_file
:
6110 adv
= read_leb128 (data
, & bytes_read
, 0);
6112 printf (_(" Set File Name to entry %d in the File Name Table\n"),
6114 state_machine_regs
.file
= adv
;
6117 case DW_LNS_set_column
:
6118 adv
= read_leb128 (data
, & bytes_read
, 0);
6120 printf (_(" Set column to %d\n"), adv
);
6121 state_machine_regs
.column
= adv
;
6124 case DW_LNS_negate_stmt
:
6125 adv
= state_machine_regs
.is_stmt
;
6127 printf (_(" Set is_stmt to %d\n"), adv
);
6128 state_machine_regs
.is_stmt
= adv
;
6131 case DW_LNS_set_basic_block
:
6132 printf (_(" Set basic block\n"));
6133 state_machine_regs
.basic_block
= 1;
6136 case DW_LNS_const_add_pc
:
6137 adv
= (((255 - info
.li_opcode_base
) / info
.li_line_range
)
6138 * info
.li_min_insn_length
);
6139 state_machine_regs
.address
+= adv
;
6140 printf (_(" Advance PC by constant %d to 0x%lx\n"), adv
,
6141 state_machine_regs
.address
);
6144 case DW_LNS_fixed_advance_pc
:
6145 adv
= byte_get (data
, 2);
6147 state_machine_regs
.address
+= adv
;
6148 printf (_(" Advance PC by fixed size amount %d to 0x%lx\n"),
6149 adv
, state_machine_regs
.address
);
6152 case DW_LNS_set_prologue_end
:
6153 printf (_(" Set prologue_end to true\n"));
6156 case DW_LNS_set_epilogue_begin
:
6157 printf (_(" Set epilogue_begin to true\n"));
6160 case DW_LNS_set_isa
:
6161 adv
= read_leb128 (data
, & bytes_read
, 0);
6163 printf (_(" Set ISA to %d\n"), adv
);
6167 printf (_(" Unknown opcode %d with operands: "), op_code
);
6170 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
6172 printf ("0x%lx%s", read_leb128 (data
, &bytes_read
, 0),
6173 i
== 1 ? "" : ", ");
6188 display_debug_pubnames (section
, start
, file
)
6189 Elf32_Internal_Shdr
* section
;
6190 unsigned char * start
;
6191 FILE * file ATTRIBUTE_UNUSED
;
6193 DWARF2_External_PubNames
* external
;
6194 DWARF2_Internal_PubNames pubnames
;
6195 unsigned char * end
;
6197 end
= start
+ section
->sh_size
;
6199 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
6203 unsigned char * data
;
6204 unsigned long offset
;
6206 external
= (DWARF2_External_PubNames
*) start
;
6208 pubnames
.pn_length
= BYTE_GET (external
->pn_length
);
6209 pubnames
.pn_version
= BYTE_GET (external
->pn_version
);
6210 pubnames
.pn_offset
= BYTE_GET (external
->pn_offset
);
6211 pubnames
.pn_size
= BYTE_GET (external
->pn_size
);
6213 data
= start
+ sizeof (* external
);
6214 start
+= pubnames
.pn_length
+ sizeof (external
->pn_length
);
6216 if (pubnames
.pn_length
== 0xffffffff)
6218 warn (_("64-bit DWARF pubnames are not supported yet.\n"));
6222 if (pubnames
.pn_version
!= 2)
6224 static int warned
= 0;
6228 warn (_("Only DWARF 2 pubnames are currently supported\n"));
6235 printf (_(" Length: %ld\n"),
6236 pubnames
.pn_length
);
6237 printf (_(" Version: %d\n"),
6238 pubnames
.pn_version
);
6239 printf (_(" Offset into .debug_info section: %ld\n"),
6240 pubnames
.pn_offset
);
6241 printf (_(" Size of area in .debug_info section: %ld\n"),
6244 printf (_("\n Offset\tName\n"));
6248 offset
= byte_get (data
, 4);
6253 printf (" %ld\t\t%s\n", offset
, data
);
6254 data
+= strlen ((char *) data
) + 1;
6257 while (offset
!= 0);
6270 case DW_TAG_padding
: return "DW_TAG_padding";
6271 case DW_TAG_array_type
: return "DW_TAG_array_type";
6272 case DW_TAG_class_type
: return "DW_TAG_class_type";
6273 case DW_TAG_entry_point
: return "DW_TAG_entry_point";
6274 case DW_TAG_enumeration_type
: return "DW_TAG_enumeration_type";
6275 case DW_TAG_formal_parameter
: return "DW_TAG_formal_parameter";
6276 case DW_TAG_imported_declaration
: return "DW_TAG_imported_declaration";
6277 case DW_TAG_label
: return "DW_TAG_label";
6278 case DW_TAG_lexical_block
: return "DW_TAG_lexical_block";
6279 case DW_TAG_member
: return "DW_TAG_member";
6280 case DW_TAG_pointer_type
: return "DW_TAG_pointer_type";
6281 case DW_TAG_reference_type
: return "DW_TAG_reference_type";
6282 case DW_TAG_compile_unit
: return "DW_TAG_compile_unit";
6283 case DW_TAG_string_type
: return "DW_TAG_string_type";
6284 case DW_TAG_structure_type
: return "DW_TAG_structure_type";
6285 case DW_TAG_subroutine_type
: return "DW_TAG_subroutine_type";
6286 case DW_TAG_typedef
: return "DW_TAG_typedef";
6287 case DW_TAG_union_type
: return "DW_TAG_union_type";
6288 case DW_TAG_unspecified_parameters
: return "DW_TAG_unspecified_parameters";
6289 case DW_TAG_variant
: return "DW_TAG_variant";
6290 case DW_TAG_common_block
: return "DW_TAG_common_block";
6291 case DW_TAG_common_inclusion
: return "DW_TAG_common_inclusion";
6292 case DW_TAG_inheritance
: return "DW_TAG_inheritance";
6293 case DW_TAG_inlined_subroutine
: return "DW_TAG_inlined_subroutine";
6294 case DW_TAG_module
: return "DW_TAG_module";
6295 case DW_TAG_ptr_to_member_type
: return "DW_TAG_ptr_to_member_type";
6296 case DW_TAG_set_type
: return "DW_TAG_set_type";
6297 case DW_TAG_subrange_type
: return "DW_TAG_subrange_type";
6298 case DW_TAG_with_stmt
: return "DW_TAG_with_stmt";
6299 case DW_TAG_access_declaration
: return "DW_TAG_access_declaration";
6300 case DW_TAG_base_type
: return "DW_TAG_base_type";
6301 case DW_TAG_catch_block
: return "DW_TAG_catch_block";
6302 case DW_TAG_const_type
: return "DW_TAG_const_type";
6303 case DW_TAG_constant
: return "DW_TAG_constant";
6304 case DW_TAG_enumerator
: return "DW_TAG_enumerator";
6305 case DW_TAG_file_type
: return "DW_TAG_file_type";
6306 case DW_TAG_friend
: return "DW_TAG_friend";
6307 case DW_TAG_namelist
: return "DW_TAG_namelist";
6308 case DW_TAG_namelist_item
: return "DW_TAG_namelist_item";
6309 case DW_TAG_packed_type
: return "DW_TAG_packed_type";
6310 case DW_TAG_subprogram
: return "DW_TAG_subprogram";
6311 case DW_TAG_template_type_param
: return "DW_TAG_template_type_param";
6312 case DW_TAG_template_value_param
: return "DW_TAG_template_value_param";
6313 case DW_TAG_thrown_type
: return "DW_TAG_thrown_type";
6314 case DW_TAG_try_block
: return "DW_TAG_try_block";
6315 case DW_TAG_variant_part
: return "DW_TAG_variant_part";
6316 case DW_TAG_variable
: return "DW_TAG_variable";
6317 case DW_TAG_volatile_type
: return "DW_TAG_volatile_type";
6318 case DW_TAG_MIPS_loop
: return "DW_TAG_MIPS_loop";
6319 case DW_TAG_format_label
: return "DW_TAG_format_label";
6320 case DW_TAG_function_template
: return "DW_TAG_function_template";
6321 case DW_TAG_class_template
: return "DW_TAG_class_template";
6322 /* DWARF 2.1 values. */
6323 case DW_TAG_dwarf_procedure
: return "DW_TAG_dwarf_procedure";
6324 case DW_TAG_restrict_type
: return "DW_TAG_restrict_type";
6325 case DW_TAG_interface_type
: return "DW_TAG_interface_type";
6326 case DW_TAG_namespace
: return "DW_TAG_namespace";
6327 case DW_TAG_imported_module
: return "DW_TAG_imported_module";
6328 case DW_TAG_unspecified_type
: return "DW_TAG_unspecified_type";
6329 case DW_TAG_partial_unit
: return "DW_TAG_partial_unit";
6330 case DW_TAG_imported_unit
: return "DW_TAG_imported_unit";
6333 static char buffer
[100];
6335 sprintf (buffer
, _("Unknown TAG value: %lx"), tag
);
6342 get_AT_name (attribute
)
6343 unsigned long attribute
;
6347 case DW_AT_sibling
: return "DW_AT_sibling";
6348 case DW_AT_location
: return "DW_AT_location";
6349 case DW_AT_name
: return "DW_AT_name";
6350 case DW_AT_ordering
: return "DW_AT_ordering";
6351 case DW_AT_subscr_data
: return "DW_AT_subscr_data";
6352 case DW_AT_byte_size
: return "DW_AT_byte_size";
6353 case DW_AT_bit_offset
: return "DW_AT_bit_offset";
6354 case DW_AT_bit_size
: return "DW_AT_bit_size";
6355 case DW_AT_element_list
: return "DW_AT_element_list";
6356 case DW_AT_stmt_list
: return "DW_AT_stmt_list";
6357 case DW_AT_low_pc
: return "DW_AT_low_pc";
6358 case DW_AT_high_pc
: return "DW_AT_high_pc";
6359 case DW_AT_language
: return "DW_AT_language";
6360 case DW_AT_member
: return "DW_AT_member";
6361 case DW_AT_discr
: return "DW_AT_discr";
6362 case DW_AT_discr_value
: return "DW_AT_discr_value";
6363 case DW_AT_visibility
: return "DW_AT_visibility";
6364 case DW_AT_import
: return "DW_AT_import";
6365 case DW_AT_string_length
: return "DW_AT_string_length";
6366 case DW_AT_common_reference
: return "DW_AT_common_reference";
6367 case DW_AT_comp_dir
: return "DW_AT_comp_dir";
6368 case DW_AT_const_value
: return "DW_AT_const_value";
6369 case DW_AT_containing_type
: return "DW_AT_containing_type";
6370 case DW_AT_default_value
: return "DW_AT_default_value";
6371 case DW_AT_inline
: return "DW_AT_inline";
6372 case DW_AT_is_optional
: return "DW_AT_is_optional";
6373 case DW_AT_lower_bound
: return "DW_AT_lower_bound";
6374 case DW_AT_producer
: return "DW_AT_producer";
6375 case DW_AT_prototyped
: return "DW_AT_prototyped";
6376 case DW_AT_return_addr
: return "DW_AT_return_addr";
6377 case DW_AT_start_scope
: return "DW_AT_start_scope";
6378 case DW_AT_stride_size
: return "DW_AT_stride_size";
6379 case DW_AT_upper_bound
: return "DW_AT_upper_bound";
6380 case DW_AT_abstract_origin
: return "DW_AT_abstract_origin";
6381 case DW_AT_accessibility
: return "DW_AT_accessibility";
6382 case DW_AT_address_class
: return "DW_AT_address_class";
6383 case DW_AT_artificial
: return "DW_AT_artificial";
6384 case DW_AT_base_types
: return "DW_AT_base_types";
6385 case DW_AT_calling_convention
: return "DW_AT_calling_convention";
6386 case DW_AT_count
: return "DW_AT_count";
6387 case DW_AT_data_member_location
: return "DW_AT_data_member_location";
6388 case DW_AT_decl_column
: return "DW_AT_decl_column";
6389 case DW_AT_decl_file
: return "DW_AT_decl_file";
6390 case DW_AT_decl_line
: return "DW_AT_decl_line";
6391 case DW_AT_declaration
: return "DW_AT_declaration";
6392 case DW_AT_discr_list
: return "DW_AT_discr_list";
6393 case DW_AT_encoding
: return "DW_AT_encoding";
6394 case DW_AT_external
: return "DW_AT_external";
6395 case DW_AT_frame_base
: return "DW_AT_frame_base";
6396 case DW_AT_friend
: return "DW_AT_friend";
6397 case DW_AT_identifier_case
: return "DW_AT_identifier_case";
6398 case DW_AT_macro_info
: return "DW_AT_macro_info";
6399 case DW_AT_namelist_items
: return "DW_AT_namelist_items";
6400 case DW_AT_priority
: return "DW_AT_priority";
6401 case DW_AT_segment
: return "DW_AT_segment";
6402 case DW_AT_specification
: return "DW_AT_specification";
6403 case DW_AT_static_link
: return "DW_AT_static_link";
6404 case DW_AT_type
: return "DW_AT_type";
6405 case DW_AT_use_location
: return "DW_AT_use_location";
6406 case DW_AT_variable_parameter
: return "DW_AT_variable_parameter";
6407 case DW_AT_virtuality
: return "DW_AT_virtuality";
6408 case DW_AT_vtable_elem_location
: return "DW_AT_vtable_elem_location";
6409 /* DWARF 2.1 values. */
6410 case DW_AT_allocated
: return "DW_AT_allocated";
6411 case DW_AT_associated
: return "DW_AT_associated";
6412 case DW_AT_data_location
: return "DW_AT_data_location";
6413 case DW_AT_stride
: return "DW_AT_stride";
6414 case DW_AT_entry_pc
: return "DW_AT_entry_pc";
6415 case DW_AT_use_UTF8
: return "DW_AT_use_UTF8";
6416 case DW_AT_extension
: return "DW_AT_extension";
6417 case DW_AT_ranges
: return "DW_AT_ranges";
6418 case DW_AT_trampoline
: return "DW_AT_trampoline";
6419 case DW_AT_call_column
: return "DW_AT_call_column";
6420 case DW_AT_call_file
: return "DW_AT_call_file";
6421 case DW_AT_call_line
: return "DW_AT_call_line";
6422 /* SGI/MIPS extensions. */
6423 case DW_AT_MIPS_fde
: return "DW_AT_MIPS_fde";
6424 case DW_AT_MIPS_loop_begin
: return "DW_AT_MIPS_loop_begin";
6425 case DW_AT_MIPS_tail_loop_begin
: return "DW_AT_MIPS_tail_loop_begin";
6426 case DW_AT_MIPS_epilog_begin
: return "DW_AT_MIPS_epilog_begin";
6427 case DW_AT_MIPS_loop_unroll_factor
: return "DW_AT_MIPS_loop_unroll_factor";
6428 case DW_AT_MIPS_software_pipeline_depth
: return "DW_AT_MIPS_software_pipeline_depth";
6429 case DW_AT_MIPS_linkage_name
: return "DW_AT_MIPS_linkage_name";
6430 case DW_AT_MIPS_stride
: return "DW_AT_MIPS_stride";
6431 case DW_AT_MIPS_abstract_name
: return "DW_AT_MIPS_abstract_name";
6432 case DW_AT_MIPS_clone_origin
: return "DW_AT_MIPS_clone_origin";
6433 case DW_AT_MIPS_has_inlines
: return "DW_AT_MIPS_has_inlines";
6434 /* GNU extensions. */
6435 case DW_AT_sf_names
: return "DW_AT_sf_names";
6436 case DW_AT_src_info
: return "DW_AT_src_info";
6437 case DW_AT_mac_info
: return "DW_AT_mac_info";
6438 case DW_AT_src_coords
: return "DW_AT_src_coords";
6439 case DW_AT_body_begin
: return "DW_AT_body_begin";
6440 case DW_AT_body_end
: return "DW_AT_body_end";
6443 static char buffer
[100];
6445 sprintf (buffer
, _("Unknown AT value: %lx"), attribute
);
6452 get_FORM_name (form
)
6457 case DW_FORM_addr
: return "DW_FORM_addr";
6458 case DW_FORM_block2
: return "DW_FORM_block2";
6459 case DW_FORM_block4
: return "DW_FORM_block4";
6460 case DW_FORM_data2
: return "DW_FORM_data2";
6461 case DW_FORM_data4
: return "DW_FORM_data4";
6462 case DW_FORM_data8
: return "DW_FORM_data8";
6463 case DW_FORM_string
: return "DW_FORM_string";
6464 case DW_FORM_block
: return "DW_FORM_block";
6465 case DW_FORM_block1
: return "DW_FORM_block1";
6466 case DW_FORM_data1
: return "DW_FORM_data1";
6467 case DW_FORM_flag
: return "DW_FORM_flag";
6468 case DW_FORM_sdata
: return "DW_FORM_sdata";
6469 case DW_FORM_strp
: return "DW_FORM_strp";
6470 case DW_FORM_udata
: return "DW_FORM_udata";
6471 case DW_FORM_ref_addr
: return "DW_FORM_ref_addr";
6472 case DW_FORM_ref1
: return "DW_FORM_ref1";
6473 case DW_FORM_ref2
: return "DW_FORM_ref2";
6474 case DW_FORM_ref4
: return "DW_FORM_ref4";
6475 case DW_FORM_ref8
: return "DW_FORM_ref8";
6476 case DW_FORM_ref_udata
: return "DW_FORM_ref_udata";
6477 case DW_FORM_indirect
: return "DW_FORM_indirect";
6480 static char buffer
[100];
6482 sprintf (buffer
, _("Unknown FORM value: %lx"), form
);
6488 /* FIXME: There are better and more effiecint ways to handle
6489 these structures. For now though, I just want something that
6490 is simple to implement. */
6491 typedef struct abbrev_attr
6493 unsigned long attribute
;
6495 struct abbrev_attr
* next
;
6499 typedef struct abbrev_entry
6501 unsigned long entry
;
6504 struct abbrev_attr
* first_attr
;
6505 struct abbrev_attr
* last_attr
;
6506 struct abbrev_entry
* next
;
6510 static abbrev_entry
* first_abbrev
= NULL
;
6511 static abbrev_entry
* last_abbrev
= NULL
;
6514 free_abbrevs
PARAMS ((void))
6516 abbrev_entry
* abbrev
;
6518 for (abbrev
= first_abbrev
; abbrev
;)
6520 abbrev_entry
* next
= abbrev
->next
;
6523 for (attr
= abbrev
->first_attr
; attr
;)
6525 abbrev_attr
* next
= attr
->next
;
6535 last_abbrev
= first_abbrev
= NULL
;
6539 add_abbrev (number
, tag
, children
)
6540 unsigned long number
;
6544 abbrev_entry
* entry
;
6546 entry
= (abbrev_entry
*) malloc (sizeof (* entry
));
6552 entry
->entry
= number
;
6554 entry
->children
= children
;
6555 entry
->first_attr
= NULL
;
6556 entry
->last_attr
= NULL
;
6559 if (first_abbrev
== NULL
)
6560 first_abbrev
= entry
;
6562 last_abbrev
->next
= entry
;
6564 last_abbrev
= entry
;
6568 add_abbrev_attr (attribute
, form
)
6569 unsigned long attribute
;
6574 attr
= (abbrev_attr
*) malloc (sizeof (* attr
));
6580 attr
->attribute
= attribute
;
6584 if (last_abbrev
->first_attr
== NULL
)
6585 last_abbrev
->first_attr
= attr
;
6587 last_abbrev
->last_attr
->next
= attr
;
6589 last_abbrev
->last_attr
= attr
;
6592 /* Processes the (partial) contents of a .debug_abbrev section.
6593 Returns NULL if the end of the section was encountered.
6594 Returns the address after the last byte read if the end of
6595 an abbreviation set was found. */
6597 static unsigned char *
6598 process_abbrev_section (start
, end
)
6599 unsigned char * start
;
6600 unsigned char * end
;
6602 if (first_abbrev
!= NULL
)
6608 unsigned long entry
;
6610 unsigned long attribute
;
6613 entry
= read_leb128 (start
, & bytes_read
, 0);
6614 start
+= bytes_read
;
6616 /* A single zero is supposed to end the section according
6617 to the standard. If there's more, then signal that to
6620 return start
== end
? NULL
: start
;
6622 tag
= read_leb128 (start
, & bytes_read
, 0);
6623 start
+= bytes_read
;
6625 children
= * start
++;
6627 add_abbrev (entry
, tag
, children
);
6633 attribute
= read_leb128 (start
, & bytes_read
, 0);
6634 start
+= bytes_read
;
6636 form
= read_leb128 (start
, & bytes_read
, 0);
6637 start
+= bytes_read
;
6640 add_abbrev_attr (attribute
, form
);
6642 while (attribute
!= 0);
6650 display_debug_macinfo (section
, start
, file
)
6651 Elf32_Internal_Shdr
* section
;
6652 unsigned char * start
;
6653 FILE * file ATTRIBUTE_UNUSED
;
6655 unsigned char * end
= start
+ section
->sh_size
;
6656 unsigned char * curr
= start
;
6657 unsigned int bytes_read
;
6658 enum dwarf_macinfo_record_type op
;
6660 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
6664 unsigned int lineno
;
6665 const char * string
;
6672 case DW_MACINFO_start_file
:
6674 unsigned int filenum
;
6676 lineno
= read_leb128 (curr
, & bytes_read
, 0);
6678 filenum
= read_leb128 (curr
, & bytes_read
, 0);
6681 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), lineno
, filenum
);
6685 case DW_MACINFO_end_file
:
6686 printf (_(" DW_MACINFO_end_file\n"));
6689 case DW_MACINFO_define
:
6690 lineno
= read_leb128 (curr
, & bytes_read
, 0);
6693 curr
+= strlen (string
) + 1;
6694 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), lineno
, string
);
6697 case DW_MACINFO_undef
:
6698 lineno
= read_leb128 (curr
, & bytes_read
, 0);
6701 curr
+= strlen (string
) + 1;
6702 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), lineno
, string
);
6705 case DW_MACINFO_vendor_ext
:
6707 unsigned int constant
;
6709 constant
= read_leb128 (curr
, & bytes_read
, 0);
6712 curr
+= strlen (string
) + 1;
6713 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), constant
, string
);
6724 display_debug_abbrev (section
, start
, file
)
6725 Elf32_Internal_Shdr
* section
;
6726 unsigned char * start
;
6727 FILE * file ATTRIBUTE_UNUSED
;
6729 abbrev_entry
* entry
;
6730 unsigned char * end
= start
+ section
->sh_size
;
6732 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
6736 start
= process_abbrev_section (start
, end
);
6738 if (first_abbrev
== NULL
)
6741 printf (_(" Number TAG\n"));
6743 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
6747 printf (_(" %ld %s [%s]\n"),
6749 get_TAG_name (entry
->tag
),
6750 entry
->children
? _("has children") : _("no children"));
6752 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
6754 printf (_(" %-18s %s\n"),
6755 get_AT_name (attr
->attribute
),
6756 get_FORM_name (attr
->form
));
6770 static unsigned char *
6771 display_block (data
, length
)
6772 unsigned char * data
;
6773 unsigned long length
;
6775 printf (_(" %lu byte block: "), length
);
6778 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
6784 decode_location_expression (data
, pointer_size
, length
)
6785 unsigned char * data
;
6786 unsigned int pointer_size
;
6787 unsigned long length
;
6791 unsigned long uvalue
;
6792 unsigned char * end
= data
+ length
;
6801 printf ("DW_OP_addr: %lx",
6802 (unsigned long) byte_get (data
, pointer_size
));
6803 data
+= pointer_size
;
6806 printf ("DW_OP_deref");
6809 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data
++, 1));
6812 printf ("DW_OP_const1s: %ld", (long) byte_get (data
++, 1));
6815 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data
, 2));
6819 printf ("DW_OP_const2s: %ld", (long) byte_get (data
, 2));
6823 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data
, 4));
6827 printf ("DW_OP_const4s: %ld", (long) byte_get (data
, 4));
6831 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data
, 4),
6832 (unsigned long) byte_get (data
+ 4, 4));
6836 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data
, 4),
6837 (long) byte_get (data
+ 4, 4));
6841 printf ("DW_OP_constu: %lu", read_leb128 (data
, &bytes_read
, 0));
6845 printf ("DW_OP_consts: %ld", read_leb128 (data
, &bytes_read
, 1));
6849 printf ("DW_OP_dup");
6852 printf ("DW_OP_drop");
6855 printf ("DW_OP_over");
6858 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data
++, 1));
6861 printf ("DW_OP_swap");
6864 printf ("DW_OP_rot");
6867 printf ("DW_OP_xderef");
6870 printf ("DW_OP_abs");
6873 printf ("DW_OP_and");
6876 printf ("DW_OP_div");
6879 printf ("DW_OP_minus");
6882 printf ("DW_OP_mod");
6885 printf ("DW_OP_mul");
6888 printf ("DW_OP_neg");
6891 printf ("DW_OP_not");
6894 printf ("DW_OP_or");
6897 printf ("DW_OP_plus");
6899 case DW_OP_plus_uconst
:
6900 printf ("DW_OP_plus_uconst: %lu",
6901 read_leb128 (data
, &bytes_read
, 0));
6905 printf ("DW_OP_shl");
6908 printf ("DW_OP_shr");
6911 printf ("DW_OP_shra");
6914 printf ("DW_OP_xor");
6917 printf ("DW_OP_bra: %ld", (long) byte_get (data
, 2));
6921 printf ("DW_OP_eq");
6924 printf ("DW_OP_ge");
6927 printf ("DW_OP_gt");
6930 printf ("DW_OP_le");
6933 printf ("DW_OP_lt");
6936 printf ("DW_OP_ne");
6939 printf ("DW_OP_skip: %ld", (long) byte_get (data
, 2));
6975 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
7010 printf ("DW_OP_reg%d", op
- DW_OP_reg0
);
7045 printf ("DW_OP_breg%d: %ld", op
- DW_OP_breg0
,
7046 read_leb128 (data
, &bytes_read
, 1));
7051 printf ("DW_OP_regx: %lu", read_leb128 (data
, &bytes_read
, 0));
7055 printf ("DW_OP_fbreg: %ld", read_leb128 (data
, &bytes_read
, 1));
7059 uvalue
= read_leb128 (data
, &bytes_read
, 0);
7061 printf ("DW_OP_bregx: %lu %ld", uvalue
,
7062 read_leb128 (data
, &bytes_read
, 1));
7066 printf ("DW_OP_piece: %lu", read_leb128 (data
, &bytes_read
, 0));
7069 case DW_OP_deref_size
:
7070 printf ("DW_OP_deref_size: %ld", (long) byte_get (data
++, 1));
7072 case DW_OP_xderef_size
:
7073 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data
++, 1));
7076 printf ("DW_OP_nop");
7079 /* DWARF 2.1 extensions. */
7080 case DW_OP_push_object_address
:
7081 printf ("DW_OP_push_object_address");
7084 printf ("DW_OP_call2: <%lx>", (long) byte_get (data
, 2));
7088 printf ("DW_OP_call4: <%lx>", (long) byte_get (data
, 4));
7092 printf ("DW_OP_calli");
7096 if (op
>= DW_OP_lo_user
7097 && op
<= DW_OP_hi_user
)
7098 printf (_("(User defined location op)"));
7100 printf (_("(Unknown location op)"));
7101 /* No way to tell where the next op is, so just bail. */
7105 /* Separate the ops. */
7111 static const char * debug_str_contents
;
7112 static bfd_vma debug_str_size
;
7115 load_debug_str (file
)
7118 Elf32_Internal_Shdr
* sec
;
7121 /* If it is already loaded, do nothing. */
7122 if (debug_str_contents
!= NULL
)
7125 /* Locate the .debug_str section. */
7126 for (i
= 0, sec
= section_headers
;
7127 i
< elf_header
.e_shnum
;
7129 if (strcmp (SECTION_NAME (sec
), ".debug_str") == 0)
7132 if (i
== elf_header
.e_shnum
|| sec
->sh_size
== 0)
7135 debug_str_size
= sec
->sh_size
;
7137 debug_str_contents
= ((char *)
7138 get_data (NULL
, file
, sec
->sh_offset
, sec
->sh_size
,
7139 _("debug_str section data")));
7145 if (debug_str_contents
== NULL
)
7148 free ((char *) debug_str_contents
);
7149 debug_str_contents
= NULL
;
7154 fetch_indirect_string (offset
)
7155 unsigned long offset
;
7157 if (debug_str_contents
== NULL
)
7158 return _("<no .debug_str section>");
7160 if (offset
> debug_str_size
)
7161 return _("<offset is too big>");
7163 return debug_str_contents
+ offset
;
7168 display_debug_str (section
, start
, file
)
7169 Elf32_Internal_Shdr
* section
;
7170 unsigned char * start
;
7171 FILE * file ATTRIBUTE_UNUSED
;
7173 unsigned long bytes
;
7176 addr
= section
->sh_addr
;
7177 bytes
= section
->sh_size
;
7181 printf (_("\nThe .debug_str section is empty.\n"));
7185 printf (_("Contents of the .debug_str section:\n\n"));
7193 lbytes
= (bytes
> 16 ? 16 : bytes
);
7195 printf (" 0x%8.8lx ", (unsigned long) addr
);
7197 for (j
= 0; j
< 16; j
++)
7200 printf ("%2.2x", start
[j
]);
7208 for (j
= 0; j
< lbytes
; j
++)
7211 if (k
>= ' ' && k
< 0x80)
7228 static unsigned char *
7229 read_and_display_attr_value (attribute
, form
, data
, cu_offset
, pointer_size
)
7230 unsigned long attribute
;
7232 unsigned char * data
;
7233 unsigned long cu_offset
;
7234 unsigned long pointer_size
;
7236 unsigned long uvalue
= 0;
7237 unsigned char * block_start
= NULL
;
7245 case DW_FORM_ref_addr
:
7247 uvalue
= byte_get (data
, pointer_size
);
7248 data
+= pointer_size
;
7252 uvalue
= byte_get (data
, /* offset_size */ 4);
7253 data
+= /* offset_size */ 4;
7259 uvalue
= byte_get (data
++, 1);
7264 uvalue
= byte_get (data
, 2);
7270 uvalue
= byte_get (data
, 4);
7275 uvalue
= read_leb128 (data
, & bytes_read
, 1);
7279 case DW_FORM_ref_udata
:
7281 uvalue
= read_leb128 (data
, & bytes_read
, 0);
7285 case DW_FORM_indirect
:
7286 form
= read_leb128 (data
, & bytes_read
, 0);
7288 printf (" %s", get_FORM_name (form
));
7289 return read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
7295 case DW_FORM_ref_addr
:
7296 printf (" <#%lx>", uvalue
);
7302 case DW_FORM_ref_udata
:
7303 printf (" <%lx>", uvalue
+ cu_offset
);
7307 printf (" %#lx", uvalue
);
7315 printf (" %ld", uvalue
);
7320 uvalue
= byte_get (data
, 4);
7321 printf (" %lx", uvalue
);
7322 printf (" %lx", (unsigned long) byte_get (data
+ 4, 4));
7326 case DW_FORM_string
:
7327 printf (" %s", data
);
7328 data
+= strlen ((char *) data
) + 1;
7332 uvalue
= read_leb128 (data
, & bytes_read
, 0);
7333 block_start
= data
+ bytes_read
;
7334 data
= display_block (block_start
, uvalue
);
7337 case DW_FORM_block1
:
7338 uvalue
= byte_get (data
, 1);
7339 block_start
= data
+ 1;
7340 data
= display_block (block_start
, uvalue
);
7343 case DW_FORM_block2
:
7344 uvalue
= byte_get (data
, 2);
7345 block_start
= data
+ 2;
7346 data
= display_block (block_start
, uvalue
);
7349 case DW_FORM_block4
:
7350 uvalue
= byte_get (data
, 4);
7351 block_start
= data
+ 4;
7352 data
= display_block (block_start
, uvalue
);
7356 printf (_(" (indirect string, offset: 0x%lx): "), uvalue
);
7357 printf (fetch_indirect_string (uvalue
));
7360 case DW_FORM_indirect
:
7361 /* Handled above. */
7365 warn (_("Unrecognised form: %d\n"), form
);
7369 /* For some attributes we can display futher information. */
7378 case DW_INL_not_inlined
: printf (_("(not inlined)")); break;
7379 case DW_INL_inlined
: printf (_("(inlined)")); break;
7380 case DW_INL_declared_not_inlined
: printf (_("(declared as inline but ignored)")); break;
7381 case DW_INL_declared_inlined
: printf (_("(declared as inline and inlined)")); break;
7382 default: printf (_(" (Unknown inline attribute value: %lx)"), uvalue
); break;
7386 case DW_AT_language
:
7389 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
7390 case DW_LANG_C89
: printf ("(ANSI C)"); break;
7391 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
7392 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
7393 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
7394 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
7395 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
7396 case DW_LANG_Ada83
: printf ("(Ada)"); break;
7397 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
7398 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
7399 /* DWARF 2.1 values. */
7400 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
7401 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
7402 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
7403 /* MIPS extension. */
7404 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
7405 default: printf ("(Unknown: %lx)", uvalue
); break;
7409 case DW_AT_encoding
:
7412 case DW_ATE_void
: printf ("(void)"); break;
7413 case DW_ATE_address
: printf ("(machine address)"); break;
7414 case DW_ATE_boolean
: printf ("(boolean)"); break;
7415 case DW_ATE_complex_float
: printf ("(complex float)"); break;
7416 case DW_ATE_float
: printf ("(float)"); break;
7417 case DW_ATE_signed
: printf ("(signed)"); break;
7418 case DW_ATE_signed_char
: printf ("(signed char)"); break;
7419 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
7420 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
7421 /* DWARF 2.1 value. */
7422 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
7424 if (uvalue
>= DW_ATE_lo_user
7425 && uvalue
<= DW_ATE_hi_user
)
7426 printf ("(user defined type)");
7428 printf ("(unknown type)");
7433 case DW_AT_accessibility
:
7436 case DW_ACCESS_public
: printf ("(public)"); break;
7437 case DW_ACCESS_protected
: printf ("(protected)"); break;
7438 case DW_ACCESS_private
: printf ("(private)"); break;
7439 default: printf ("(unknown accessibility)"); break;
7443 case DW_AT_visibility
:
7446 case DW_VIS_local
: printf ("(local)"); break;
7447 case DW_VIS_exported
: printf ("(exported)"); break;
7448 case DW_VIS_qualified
: printf ("(qualified)"); break;
7449 default: printf ("(unknown visibility)"); break;
7453 case DW_AT_virtuality
:
7456 case DW_VIRTUALITY_none
: printf ("(none)"); break;
7457 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
7458 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
7459 default: printf ("(unknown virtuality)"); break;
7463 case DW_AT_identifier_case
:
7466 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
7467 case DW_ID_up_case
: printf ("(up_case)"); break;
7468 case DW_ID_down_case
: printf ("(down_case)"); break;
7469 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
7470 default: printf ("(unknown case)"); break;
7474 case DW_AT_calling_convention
:
7477 case DW_CC_normal
: printf ("(normal)"); break;
7478 case DW_CC_program
: printf ("(program)"); break;
7479 case DW_CC_nocall
: printf ("(nocall)"); break;
7481 if (uvalue
>= DW_CC_lo_user
7482 && uvalue
<= DW_CC_hi_user
)
7483 printf ("(user defined)");
7485 printf ("(unknown convention)");
7489 case DW_AT_ordering
:
7492 case -1: printf ("(undefined)"); break;
7493 case 0: printf ("(row major)"); break;
7494 case 1: printf ("(column major)"); break;
7498 case DW_AT_frame_base
:
7499 case DW_AT_location
:
7500 case DW_AT_data_member_location
:
7501 case DW_AT_vtable_elem_location
:
7502 case DW_AT_allocated
:
7503 case DW_AT_associated
:
7504 case DW_AT_data_location
:
7506 case DW_AT_upper_bound
:
7507 case DW_AT_lower_bound
:
7511 decode_location_expression (block_start
, pointer_size
, uvalue
);
7523 static unsigned char *
7524 read_and_display_attr (attribute
, form
, data
, cu_offset
, pointer_size
)
7525 unsigned long attribute
;
7527 unsigned char * data
;
7528 unsigned long cu_offset
;
7529 unsigned long pointer_size
;
7531 printf (" %-18s:", get_AT_name (attribute
));
7532 data
= read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
7539 display_debug_info (section
, start
, file
)
7540 Elf32_Internal_Shdr
* section
;
7541 unsigned char * start
;
7544 unsigned char * end
= start
+ section
->sh_size
;
7545 unsigned char * section_begin
= start
;
7547 printf (_("The section %s contains:\n\n"), SECTION_NAME (section
));
7549 load_debug_str (file
);
7553 DWARF2_External_CompUnit
* external
;
7554 DWARF2_Internal_CompUnit compunit
;
7555 Elf32_Internal_Shdr
* relsec
;
7556 unsigned char * tags
;
7559 unsigned long cu_offset
;
7561 external
= (DWARF2_External_CompUnit
*) start
;
7563 compunit
.cu_length
= BYTE_GET (external
->cu_length
);
7564 compunit
.cu_version
= BYTE_GET (external
->cu_version
);
7565 compunit
.cu_abbrev_offset
= BYTE_GET (external
->cu_abbrev_offset
);
7566 compunit
.cu_pointer_size
= BYTE_GET (external
->cu_pointer_size
);
7568 if (compunit
.cu_length
== 0xffffffff)
7570 warn (_("64-bit DWARF debug info is not supported yet.\n"));
7574 /* Check for RELA relocations in the abbrev_offset address, and
7576 for (relsec
= section_headers
;
7577 relsec
< section_headers
+ elf_header
.e_shnum
;
7580 unsigned long nrelas
;
7581 Elf_Internal_Rela
*rela
, *rp
;
7582 Elf32_Internal_Shdr
*symsec
;
7583 Elf_Internal_Sym
*symtab
;
7584 Elf_Internal_Sym
*sym
;
7586 if (relsec
->sh_type
!= SHT_RELA
7587 || SECTION_HEADER (relsec
->sh_info
) != section
)
7590 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
7594 symsec
= SECTION_HEADER (relsec
->sh_link
);
7595 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
7597 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
7600 != (bfd_vma
) ((unsigned char *) &external
->cu_abbrev_offset
7606 sym
= symtab
+ ELF32_R_SYM (rp
->r_info
);
7608 if (ELF32_ST_TYPE (sym
->st_info
) != STT_SECTION
)
7610 warn (_("Skipping unexpected symbol type %u\n"),
7611 ELF32_ST_TYPE (sym
->st_info
));
7617 sym
= symtab
+ ELF64_R_SYM (rp
->r_info
);
7619 if (ELF64_ST_TYPE (sym
->st_info
) != STT_SECTION
)
7621 warn (_("Skipping unexpected symbol type %u\n"),
7622 ELF64_ST_TYPE (sym
->st_info
));
7627 compunit
.cu_abbrev_offset
+= rp
->r_addend
;
7635 tags
= start
+ sizeof (* external
);
7636 cu_offset
= start
- section_begin
;
7637 start
+= compunit
.cu_length
+ sizeof (external
->cu_length
);
7639 printf (_(" Compilation Unit @ %lx:\n"), cu_offset
);
7640 printf (_(" Length: %ld\n"), compunit
.cu_length
);
7641 printf (_(" Version: %d\n"), compunit
.cu_version
);
7642 printf (_(" Abbrev Offset: %ld\n"), compunit
.cu_abbrev_offset
);
7643 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
7645 if (compunit
.cu_version
!= 2)
7647 warn (_("Only version 2 DWARF debug information is currently supported.\n"));
7653 /* Read in the abbrevs used by this compilation unit. */
7656 Elf32_Internal_Shdr
* sec
;
7657 unsigned char * begin
;
7659 /* Locate the .debug_abbrev section and process it. */
7660 for (i
= 0, sec
= section_headers
;
7661 i
< elf_header
.e_shnum
;
7663 if (strcmp (SECTION_NAME (sec
), ".debug_abbrev") == 0)
7666 if (i
== elf_header
.e_shnum
|| sec
->sh_size
== 0)
7668 warn (_("Unable to locate .debug_abbrev section!\n"));
7672 begin
= ((unsigned char *)
7673 get_data (NULL
, file
, sec
->sh_offset
, sec
->sh_size
,
7674 _("debug_abbrev section data")));
7678 process_abbrev_section (begin
+ compunit
.cu_abbrev_offset
,
7679 begin
+ sec
->sh_size
);
7685 while (tags
< start
)
7688 unsigned long abbrev_number
;
7689 abbrev_entry
* entry
;
7692 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
7695 /* A null DIE marks the end of a list of children. */
7696 if (abbrev_number
== 0)
7702 /* Scan through the abbreviation list until we reach the
7704 for (entry
= first_abbrev
;
7705 entry
&& entry
->entry
!= abbrev_number
;
7706 entry
= entry
->next
)
7711 warn (_("Unable to locate entry %lu in the abbreviation table\n"),
7716 printf (_(" <%d><%lx>: Abbrev Number: %lu (%s)\n"),
7718 (unsigned long) (tags
- section_begin
- bytes_read
),
7720 get_TAG_name (entry
->tag
));
7722 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
7723 tags
= read_and_display_attr (attr
->attribute
,
7726 compunit
.cu_pointer_size
);
7728 if (entry
->children
)
7741 display_debug_aranges (section
, start
, file
)
7742 Elf32_Internal_Shdr
* section
;
7743 unsigned char * start
;
7744 FILE * file ATTRIBUTE_UNUSED
;
7746 unsigned char * end
= start
+ section
->sh_size
;
7748 printf (_("The section %s contains:\n\n"), SECTION_NAME (section
));
7752 DWARF2_External_ARange
* external
;
7753 DWARF2_Internal_ARange arange
;
7754 unsigned char * ranges
;
7755 unsigned long length
;
7756 unsigned long address
;
7759 external
= (DWARF2_External_ARange
*) start
;
7761 arange
.ar_length
= BYTE_GET (external
->ar_length
);
7762 arange
.ar_version
= BYTE_GET (external
->ar_version
);
7763 arange
.ar_info_offset
= BYTE_GET (external
->ar_info_offset
);
7764 arange
.ar_pointer_size
= BYTE_GET (external
->ar_pointer_size
);
7765 arange
.ar_segment_size
= BYTE_GET (external
->ar_segment_size
);
7767 if (arange
.ar_length
== 0xffffffff)
7769 warn (_("64-bit DWARF aranges are not supported yet.\n"));
7773 if (arange
.ar_version
!= 2)
7775 warn (_("Only DWARF 2 aranges are currently supported.\n"));
7779 printf (_(" Length: %ld\n"), arange
.ar_length
);
7780 printf (_(" Version: %d\n"), arange
.ar_version
);
7781 printf (_(" Offset into .debug_info: %lx\n"), arange
.ar_info_offset
);
7782 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
7783 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
7785 printf (_("\n Address Length\n"));
7787 ranges
= start
+ sizeof (* external
);
7789 /* Must pad to an alignment boundary that is twice the pointer size. */
7790 excess
= sizeof (* external
) % (2 * arange
.ar_pointer_size
);
7792 ranges
+= (2 * arange
.ar_pointer_size
) - excess
;
7796 address
= byte_get (ranges
, arange
.ar_pointer_size
);
7798 ranges
+= arange
.ar_pointer_size
;
7800 length
= byte_get (ranges
, arange
.ar_pointer_size
);
7802 ranges
+= arange
.ar_pointer_size
;
7804 /* A pair of zeros marks the end of the list. */
7805 if (address
== 0 && length
== 0)
7808 printf (" %8.8lx %lu\n", address
, length
);
7811 start
+= arange
.ar_length
+ sizeof (external
->ar_length
);
7819 typedef struct Frame_Chunk
7821 struct Frame_Chunk
* next
;
7822 unsigned char * chunk_start
;
7824 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
7825 short int * col_type
;
7827 char * augmentation
;
7828 unsigned int code_factor
;
7830 unsigned long pc_begin
;
7831 unsigned long pc_range
;
7835 unsigned char fde_encoding
;
7839 /* A marker for a col_type that means this column was never referenced
7840 in the frame info. */
7841 #define DW_CFA_unreferenced (-1)
7843 static void frame_need_space
PARAMS ((Frame_Chunk
*, int));
7844 static void frame_display_row
PARAMS ((Frame_Chunk
*, int *, int *));
7845 static int size_of_encoded_value
PARAMS ((int));
7848 frame_need_space (fc
, reg
)
7852 int prev
= fc
->ncols
;
7854 if (reg
< fc
->ncols
)
7857 fc
->ncols
= reg
+ 1;
7858 fc
->col_type
= (short int *) xrealloc (fc
->col_type
,
7859 fc
->ncols
* sizeof (short int));
7860 fc
->col_offset
= (int *) xrealloc (fc
->col_offset
,
7861 fc
->ncols
* sizeof (int));
7863 while (prev
< fc
->ncols
)
7865 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
7866 fc
->col_offset
[prev
] = 0;
7872 frame_display_row (fc
, need_col_headers
, max_regs
)
7874 int * need_col_headers
;
7880 if (* max_regs
< fc
->ncols
)
7881 * max_regs
= fc
->ncols
;
7883 if (* need_col_headers
)
7885 * need_col_headers
= 0;
7887 printf (" LOC CFA ");
7889 for (r
= 0; r
< * max_regs
; r
++)
7890 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
7895 printf ("r%-4d", r
);
7901 printf ("%08lx ", fc
->pc_begin
);
7902 sprintf (tmp
, "r%d%+d", fc
->cfa_reg
, fc
->cfa_offset
);
7903 printf ("%-8s ", tmp
);
7905 for (r
= 0; r
< fc
->ncols
; r
++)
7907 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
7909 switch (fc
->col_type
[r
])
7911 case DW_CFA_undefined
:
7914 case DW_CFA_same_value
:
7918 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
7920 case DW_CFA_register
:
7921 sprintf (tmp
, "r%d", fc
->col_offset
[r
]);
7924 strcpy (tmp
, "n/a");
7927 printf ("%-5s", tmp
);
7934 size_of_encoded_value (encoding
)
7937 switch (encoding
& 0x7)
7940 case 0: return is_32bit_elf
? 4 : 8;
7947 #define GET(N) byte_get (start, N); start += N
7948 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
7949 #define SLEB() read_leb128 (start, & length_return, 1); start += length_return
7952 display_debug_frames (section
, start
, file
)
7953 Elf32_Internal_Shdr
* section
;
7954 unsigned char * start
;
7955 FILE * file ATTRIBUTE_UNUSED
;
7957 unsigned char * end
= start
+ section
->sh_size
;
7958 unsigned char * section_start
= start
;
7959 Frame_Chunk
* chunks
= 0;
7960 Frame_Chunk
* remembered_state
= 0;
7962 int is_eh
= (strcmp (SECTION_NAME (section
), ".eh_frame") == 0);
7965 int addr_size
= is_32bit_elf
? 4 : 8;
7967 printf (_("The section %s contains:\n"), SECTION_NAME (section
));
7971 unsigned char * saved_start
;
7972 unsigned char * block_end
;
7973 unsigned long length
;
7974 unsigned long cie_id
;
7977 int need_col_headers
= 1;
7978 unsigned char * augmentation_data
= NULL
;
7979 unsigned long augmentation_data_len
= 0;
7980 int encoded_ptr_size
= addr_size
;
7982 saved_start
= start
;
7983 length
= byte_get (start
, 4); start
+= 4;
7988 if (length
== 0xffffffff)
7990 warn (_("64-bit DWARF format frames are not supported yet.\n"));
7994 block_end
= saved_start
+ length
+ 4;
7995 cie_id
= byte_get (start
, 4); start
+= 4;
7997 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
8001 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
8002 memset (fc
, 0, sizeof (Frame_Chunk
));
8006 fc
->chunk_start
= saved_start
;
8008 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
8009 fc
->col_offset
= (int *) xmalloc (sizeof (int));
8010 frame_need_space (fc
, max_regs
-1);
8014 fc
->augmentation
= start
;
8015 start
= strchr (start
, '\0') + 1;
8017 if (fc
->augmentation
[0] == 'z')
8019 fc
->code_factor
= LEB ();
8020 fc
->data_factor
= SLEB ();
8021 fc
->ra
= byte_get (start
, 1); start
+= 1;
8022 augmentation_data_len
= LEB ();
8023 augmentation_data
= start
;
8024 start
+= augmentation_data_len
;
8026 else if (strcmp (fc
->augmentation
, "eh") == 0)
8029 fc
->code_factor
= LEB ();
8030 fc
->data_factor
= SLEB ();
8031 fc
->ra
= byte_get (start
, 1); start
+= 1;
8035 fc
->code_factor
= LEB ();
8036 fc
->data_factor
= SLEB ();
8037 fc
->ra
= byte_get (start
, 1); start
+= 1;
8041 if (do_debug_frames_interp
)
8042 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
8043 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
8044 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
8048 printf ("\n%08lx %08lx %08lx CIE\n",
8049 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
8050 printf (" Version: %d\n", version
);
8051 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
8052 printf (" Code alignment factor: %u\n", fc
->code_factor
);
8053 printf (" Data alignment factor: %d\n", fc
->data_factor
);
8054 printf (" Return address column: %d\n", fc
->ra
);
8056 if (augmentation_data_len
)
8059 printf (" Augmentation data: ");
8060 for (i
= 0; i
< augmentation_data_len
; ++i
)
8061 printf (" %02x", augmentation_data
[i
]);
8067 if (augmentation_data_len
)
8069 unsigned char *p
, *q
;
8070 p
= fc
->augmentation
+ 1;
8071 q
= augmentation_data
;
8078 q
+= 1 + size_of_encoded_value (*q
);
8080 fc
->fde_encoding
= *q
++;
8086 if (fc
->fde_encoding
)
8087 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
8090 frame_need_space (fc
, fc
->ra
);
8094 unsigned char * look_for
;
8095 static Frame_Chunk fde_fc
;
8098 memset (fc
, 0, sizeof (Frame_Chunk
));
8100 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
8102 for (cie
= chunks
; cie
; cie
= cie
->next
)
8103 if (cie
->chunk_start
== look_for
)
8108 warn ("Invalid CIE pointer %08lx in FDE at %08lx\n",
8109 cie_id
, saved_start
);
8112 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
8113 fc
->col_offset
= (int *) xmalloc (sizeof (int));
8114 frame_need_space (fc
, max_regs
- 1);
8116 fc
->augmentation
= "";
8117 fc
->fde_encoding
= 0;
8121 fc
->ncols
= cie
->ncols
;
8122 fc
->col_type
= (short int *) xmalloc (fc
->ncols
* sizeof (short int));
8123 fc
->col_offset
= (int *) xmalloc (fc
->ncols
* sizeof (int));
8124 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
8125 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
8126 fc
->augmentation
= cie
->augmentation
;
8127 fc
->code_factor
= cie
->code_factor
;
8128 fc
->data_factor
= cie
->data_factor
;
8129 fc
->cfa_reg
= cie
->cfa_reg
;
8130 fc
->cfa_offset
= cie
->cfa_offset
;
8132 frame_need_space (fc
, max_regs
-1);
8133 fc
->fde_encoding
= cie
->fde_encoding
;
8136 if (fc
->fde_encoding
)
8137 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
8139 fc
->pc_begin
= byte_get (start
, encoded_ptr_size
);
8140 start
+= encoded_ptr_size
;
8141 fc
->pc_range
= byte_get (start
, encoded_ptr_size
);
8142 start
+= encoded_ptr_size
;
8144 if (cie
->augmentation
[0] == 'z')
8146 augmentation_data_len
= LEB ();
8147 augmentation_data
= start
;
8148 start
+= augmentation_data_len
;
8151 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=%08lx..%08lx\n",
8152 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
8153 (unsigned long)(cie
->chunk_start
- section_start
),
8154 fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
8155 if (! do_debug_frames_interp
&& augmentation_data_len
)
8158 printf (" Augmentation data: ");
8159 for (i
= 0; i
< augmentation_data_len
; ++i
)
8160 printf (" %02x", augmentation_data
[i
]);
8166 /* At this point, fc is the current chunk, cie (if any) is set, and we're
8167 about to interpret instructions for the chunk. */
8169 if (do_debug_frames_interp
)
8171 /* Start by making a pass over the chunk, allocating storage
8172 and taking note of what registers are used. */
8173 unsigned char * tmp
= start
;
8175 while (start
< block_end
)
8185 /* Warning: if you add any more cases to this switch, be
8186 sure to add them to the corresponding switch below. */
8189 case DW_CFA_advance_loc
:
8193 frame_need_space (fc
, opa
);
8194 fc
->col_type
[opa
] = DW_CFA_undefined
;
8196 case DW_CFA_restore
:
8197 frame_need_space (fc
, opa
);
8198 fc
->col_type
[opa
] = DW_CFA_undefined
;
8200 case DW_CFA_set_loc
:
8201 start
+= encoded_ptr_size
;
8203 case DW_CFA_advance_loc1
:
8206 case DW_CFA_advance_loc2
:
8209 case DW_CFA_advance_loc4
:
8212 case DW_CFA_offset_extended
:
8213 reg
= LEB (); LEB ();
8214 frame_need_space (fc
, reg
);
8215 fc
->col_type
[reg
] = DW_CFA_undefined
;
8217 case DW_CFA_restore_extended
:
8219 frame_need_space (fc
, reg
);
8220 fc
->col_type
[reg
] = DW_CFA_undefined
;
8222 case DW_CFA_undefined
:
8224 frame_need_space (fc
, reg
);
8225 fc
->col_type
[reg
] = DW_CFA_undefined
;
8227 case DW_CFA_same_value
:
8229 frame_need_space (fc
, reg
);
8230 fc
->col_type
[reg
] = DW_CFA_undefined
;
8232 case DW_CFA_register
:
8233 reg
= LEB (); LEB ();
8234 frame_need_space (fc
, reg
);
8235 fc
->col_type
[reg
] = DW_CFA_undefined
;
8237 case DW_CFA_def_cfa
:
8240 case DW_CFA_def_cfa_register
:
8243 case DW_CFA_def_cfa_offset
:
8246 #ifndef DW_CFA_GNU_args_size
8247 #define DW_CFA_GNU_args_size 0x2e
8249 case DW_CFA_GNU_args_size
:
8252 #ifndef DW_CFA_GNU_negative_offset_extended
8253 #define DW_CFA_GNU_negative_offset_extended 0x2f
8255 case DW_CFA_GNU_negative_offset_extended
:
8256 reg
= LEB (); LEB ();
8257 frame_need_space (fc
, reg
);
8258 fc
->col_type
[reg
] = DW_CFA_undefined
;
8267 /* Now we know what registers are used, make a second pass over
8268 the chunk, this time actually printing out the info. */
8270 while (start
< block_end
)
8273 unsigned long ul
, reg
, roffs
;
8282 /* Warning: if you add any more cases to this switch, be
8283 sure to add them to the corresponding switch above. */
8286 case DW_CFA_advance_loc
:
8287 if (do_debug_frames_interp
)
8288 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8290 printf (" DW_CFA_advance_loc: %d to %08lx\n",
8291 opa
* fc
->code_factor
,
8292 fc
->pc_begin
+ opa
* fc
->code_factor
);
8293 fc
->pc_begin
+= opa
* fc
->code_factor
;
8298 if (! do_debug_frames_interp
)
8299 printf (" DW_CFA_offset: r%d at cfa%+ld\n",
8300 opa
, roffs
* fc
->data_factor
);
8301 fc
->col_type
[opa
] = DW_CFA_offset
;
8302 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
8305 case DW_CFA_restore
:
8306 if (! do_debug_frames_interp
)
8307 printf (" DW_CFA_restore: r%d\n", opa
);
8308 fc
->col_type
[opa
] = cie
->col_type
[opa
];
8309 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
8312 case DW_CFA_set_loc
:
8313 vma
= byte_get (start
, encoded_ptr_size
);
8314 start
+= encoded_ptr_size
;
8315 if (do_debug_frames_interp
)
8316 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8318 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
8322 case DW_CFA_advance_loc1
:
8323 ofs
= byte_get (start
, 1); start
+= 1;
8324 if (do_debug_frames_interp
)
8325 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8327 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
8328 ofs
* fc
->code_factor
,
8329 fc
->pc_begin
+ ofs
* fc
->code_factor
);
8330 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8333 case DW_CFA_advance_loc2
:
8334 ofs
= byte_get (start
, 2); start
+= 2;
8335 if (do_debug_frames_interp
)
8336 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8338 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
8339 ofs
* fc
->code_factor
,
8340 fc
->pc_begin
+ ofs
* fc
->code_factor
);
8341 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8344 case DW_CFA_advance_loc4
:
8345 ofs
= byte_get (start
, 4); start
+= 4;
8346 if (do_debug_frames_interp
)
8347 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8349 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
8350 ofs
* fc
->code_factor
,
8351 fc
->pc_begin
+ ofs
* fc
->code_factor
);
8352 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8355 case DW_CFA_offset_extended
:
8358 if (! do_debug_frames_interp
)
8359 printf (" DW_CFA_offset_extended: r%ld at cfa%+ld\n",
8360 reg
, roffs
* fc
->data_factor
);
8361 fc
->col_type
[reg
] = DW_CFA_offset
;
8362 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
8365 case DW_CFA_restore_extended
:
8367 if (! do_debug_frames_interp
)
8368 printf (" DW_CFA_restore_extended: r%ld\n", reg
);
8369 fc
->col_type
[reg
] = cie
->col_type
[reg
];
8370 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
8373 case DW_CFA_undefined
:
8375 if (! do_debug_frames_interp
)
8376 printf (" DW_CFA_undefined: r%ld\n", reg
);
8377 fc
->col_type
[reg
] = DW_CFA_undefined
;
8378 fc
->col_offset
[reg
] = 0;
8381 case DW_CFA_same_value
:
8383 if (! do_debug_frames_interp
)
8384 printf (" DW_CFA_same_value: r%ld\n", reg
);
8385 fc
->col_type
[reg
] = DW_CFA_same_value
;
8386 fc
->col_offset
[reg
] = 0;
8389 case DW_CFA_register
:
8392 if (! do_debug_frames_interp
)
8393 printf (" DW_CFA_register: r%ld\n", reg
);
8394 fc
->col_type
[reg
] = DW_CFA_register
;
8395 fc
->col_offset
[reg
] = roffs
;
8398 case DW_CFA_remember_state
:
8399 if (! do_debug_frames_interp
)
8400 printf (" DW_CFA_remember_state\n");
8401 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
8402 rs
->ncols
= fc
->ncols
;
8403 rs
->col_type
= (short int *) xmalloc (rs
->ncols
* sizeof (short int));
8404 rs
->col_offset
= (int *) xmalloc (rs
->ncols
* sizeof (int));
8405 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
8406 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
8407 rs
->next
= remembered_state
;
8408 remembered_state
= rs
;
8411 case DW_CFA_restore_state
:
8412 if (! do_debug_frames_interp
)
8413 printf (" DW_CFA_restore_state\n");
8414 rs
= remembered_state
;
8415 remembered_state
= rs
->next
;
8416 frame_need_space (fc
, rs
->ncols
-1);
8417 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
8418 memcpy (fc
->col_offset
, rs
->col_offset
, rs
->ncols
* sizeof (int));
8419 free (rs
->col_type
);
8420 free (rs
->col_offset
);
8424 case DW_CFA_def_cfa
:
8425 fc
->cfa_reg
= LEB ();
8426 fc
->cfa_offset
= LEB ();
8427 if (! do_debug_frames_interp
)
8428 printf (" DW_CFA_def_cfa: r%d ofs %d\n",
8429 fc
->cfa_reg
, fc
->cfa_offset
);
8432 case DW_CFA_def_cfa_register
:
8433 fc
->cfa_reg
= LEB ();
8434 if (! do_debug_frames_interp
)
8435 printf (" DW_CFA_def_cfa_reg: r%d\n", fc
->cfa_reg
);
8438 case DW_CFA_def_cfa_offset
:
8439 fc
->cfa_offset
= LEB ();
8440 if (! do_debug_frames_interp
)
8441 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
8445 if (! do_debug_frames_interp
)
8446 printf (" DW_CFA_nop\n");
8449 #ifndef DW_CFA_GNU_window_save
8450 #define DW_CFA_GNU_window_save 0x2d
8452 case DW_CFA_GNU_window_save
:
8453 if (! do_debug_frames_interp
)
8454 printf (" DW_CFA_GNU_window_save\n");
8457 case DW_CFA_GNU_args_size
:
8459 if (! do_debug_frames_interp
)
8460 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
8463 case DW_CFA_GNU_negative_offset_extended
:
8466 frame_need_space (fc
, reg
);
8467 if (! do_debug_frames_interp
)
8468 printf (" DW_CFA_GNU_negative_offset_extended: r%ld at cfa%+ld\n",
8469 reg
, l
* fc
->data_factor
);
8470 fc
->col_type
[reg
] = DW_CFA_offset
;
8471 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
8475 fprintf (stderr
, "unsupported or unknown DW_CFA_%d\n", op
);
8480 if (do_debug_frames_interp
)
8481 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8496 display_debug_not_supported (section
, start
, file
)
8497 Elf32_Internal_Shdr
* section
;
8498 unsigned char * start ATTRIBUTE_UNUSED
;
8499 FILE * file ATTRIBUTE_UNUSED
;
8501 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
8502 SECTION_NAME (section
));
8507 /* Pre-scan the .debug_info section to record the size of address.
8508 When dumping the .debug_line, we use that size information, assuming
8509 that all compilation units have the same address size. */
8511 prescan_debug_info (section
, start
, file
)
8512 Elf32_Internal_Shdr
* section ATTRIBUTE_UNUSED
;
8513 unsigned char * start
;
8514 FILE * file ATTRIBUTE_UNUSED
;
8516 DWARF2_External_CompUnit
* external
;
8518 external
= (DWARF2_External_CompUnit
*) start
;
8520 debug_line_pointer_size
= BYTE_GET (external
->cu_pointer_size
);
8524 /* A structure containing the name of a debug section and a pointer
8525 to a function that can decode it. The third field is a prescan
8526 function to be run over the section before displaying any of the
8530 const char * const name
;
8531 int (* display
) PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
8532 int (* prescan
) PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
8536 { ".debug_abbrev", display_debug_abbrev
, NULL
},
8537 { ".debug_aranges", display_debug_aranges
, NULL
},
8538 { ".debug_frame", display_debug_frames
, NULL
},
8539 { ".debug_info", display_debug_info
, prescan_debug_info
},
8540 { ".debug_line", display_debug_lines
, NULL
},
8541 { ".debug_pubnames", display_debug_pubnames
, NULL
},
8542 { ".eh_frame", display_debug_frames
, NULL
},
8543 { ".debug_macinfo", display_debug_macinfo
, NULL
},
8544 { ".debug_str", display_debug_str
, NULL
},
8546 { ".debug_pubtypes", display_debug_not_supported
, NULL
},
8547 { ".debug_ranges", display_debug_not_supported
, NULL
},
8548 { ".debug_static_func", display_debug_not_supported
, NULL
},
8549 { ".debug_static_vars", display_debug_not_supported
, NULL
},
8550 { ".debug_types", display_debug_not_supported
, NULL
},
8551 { ".debug_weaknames", display_debug_not_supported
, NULL
}
8555 display_debug_section (section
, file
)
8556 Elf32_Internal_Shdr
* section
;
8559 char * name
= SECTION_NAME (section
);
8560 bfd_size_type length
;
8561 unsigned char * start
;
8564 length
= section
->sh_size
;
8567 printf (_("\nSection '%s' has no debugging data.\n"), name
);
8571 start
= (unsigned char *) get_data (NULL
, file
, section
->sh_offset
, length
,
8572 _("debug section data"));
8576 /* See if we know how to display the contents of this section. */
8577 if (strncmp (name
, ".gnu.linkonce.wi.", 17) == 0)
8578 name
= ".debug_info";
8580 for (i
= NUM_ELEM (debug_displays
); i
--;)
8581 if (strcmp (debug_displays
[i
].name
, name
) == 0)
8583 debug_displays
[i
].display (section
, start
, file
);
8588 printf (_("Unrecognised debug section: %s\n"), name
);
8592 /* If we loaded in the abbrev section at some point,
8593 we must release it here. */
8600 process_section_contents (file
)
8603 Elf32_Internal_Shdr
* section
;
8609 /* Pre-scan the debug sections to find some debug information not
8610 present in some of them. For the .debug_line, we must find out the
8611 size of address (specified in .debug_info and .debug_aranges). */
8612 for (i
= 0, section
= section_headers
;
8613 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
8616 char * name
= SECTION_NAME (section
);
8619 if (section
->sh_size
== 0)
8622 /* See if there is some pre-scan operation for this section. */
8623 for (j
= NUM_ELEM (debug_displays
); j
--;)
8624 if (strcmp (debug_displays
[j
].name
, name
) == 0)
8626 if (debug_displays
[j
].prescan
!= NULL
)
8628 bfd_size_type length
;
8629 unsigned char * start
;
8631 length
= section
->sh_size
;
8632 start
= ((unsigned char *)
8633 get_data (NULL
, file
, section
->sh_offset
, length
,
8634 _("debug section data")));
8638 debug_displays
[j
].prescan (section
, start
, file
);
8646 for (i
= 0, section
= section_headers
;
8647 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
8650 #ifdef SUPPORT_DISASSEMBLY
8651 if (dump_sects
[i
] & DISASS_DUMP
)
8652 disassemble_section (section
, file
);
8654 if (dump_sects
[i
] & HEX_DUMP
)
8655 dump_section (section
, file
);
8657 if (dump_sects
[i
] & DEBUG_DUMP
)
8658 display_debug_section (section
, file
);
8661 if (i
< num_dump_sects
)
8662 warn (_("Some sections were not dumped because they do not exist!\n"));
8668 process_mips_fpe_exception (mask
)
8674 if (mask
& OEX_FPU_INEX
)
8675 fputs ("INEX", stdout
), first
= 0;
8676 if (mask
& OEX_FPU_UFLO
)
8677 printf ("%sUFLO", first
? "" : "|"), first
= 0;
8678 if (mask
& OEX_FPU_OFLO
)
8679 printf ("%sOFLO", first
? "" : "|"), first
= 0;
8680 if (mask
& OEX_FPU_DIV0
)
8681 printf ("%sDIV0", first
? "" : "|"), first
= 0;
8682 if (mask
& OEX_FPU_INVAL
)
8683 printf ("%sINVAL", first
? "" : "|");
8686 fputs ("0", stdout
);
8690 process_mips_specific (file
)
8693 Elf_Internal_Dyn
* entry
;
8694 size_t liblist_offset
= 0;
8695 size_t liblistno
= 0;
8696 size_t conflictsno
= 0;
8697 size_t options_offset
= 0;
8698 size_t conflicts_offset
= 0;
8700 /* We have a lot of special sections. Thanks SGI! */
8701 if (dynamic_segment
== NULL
)
8702 /* No information available. */
8705 for (entry
= dynamic_segment
; entry
->d_tag
!= DT_NULL
; ++entry
)
8706 switch (entry
->d_tag
)
8708 case DT_MIPS_LIBLIST
:
8709 liblist_offset
= entry
->d_un
.d_val
- loadaddr
;
8711 case DT_MIPS_LIBLISTNO
:
8712 liblistno
= entry
->d_un
.d_val
;
8714 case DT_MIPS_OPTIONS
:
8715 options_offset
= entry
->d_un
.d_val
- loadaddr
;
8717 case DT_MIPS_CONFLICT
:
8718 conflicts_offset
= entry
->d_un
.d_val
- loadaddr
;
8720 case DT_MIPS_CONFLICTNO
:
8721 conflictsno
= entry
->d_un
.d_val
;
8727 if (liblist_offset
!= 0 && liblistno
!= 0 && do_dynamic
)
8729 Elf32_External_Lib
* elib
;
8732 elib
= ((Elf32_External_Lib
*)
8733 get_data (NULL
, file
, liblist_offset
,
8734 liblistno
* sizeof (Elf32_External_Lib
),
8738 printf ("\nSection '.liblist' contains %lu entries:\n",
8739 (unsigned long) liblistno
);
8740 fputs (" Library Time Stamp Checksum Version Flags\n",
8743 for (cnt
= 0; cnt
< liblistno
; ++cnt
)
8750 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
8751 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
8752 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
8753 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
8754 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
8756 tmp
= gmtime (&time
);
8757 sprintf (timebuf
, "%04u-%02u-%02uT%02u:%02u:%02u",
8758 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
8759 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
8761 printf ("%3lu: ", (unsigned long) cnt
);
8762 print_symbol (20, dynamic_strings
+ liblist
.l_name
);
8763 printf (" %s %#10lx %-7ld", timebuf
, liblist
.l_checksum
,
8766 if (liblist
.l_flags
== 0)
8777 { " EXACT_MATCH", LL_EXACT_MATCH
},
8778 { " IGNORE_INT_VER", LL_IGNORE_INT_VER
},
8779 { " REQUIRE_MINOR", LL_REQUIRE_MINOR
},
8780 { " EXPORTS", LL_EXPORTS
},
8781 { " DELAY_LOAD", LL_DELAY_LOAD
},
8782 { " DELTA", LL_DELTA
}
8784 int flags
= liblist
.l_flags
;
8788 fcnt
< sizeof (l_flags_vals
) / sizeof (l_flags_vals
[0]);
8790 if ((flags
& l_flags_vals
[fcnt
].bit
) != 0)
8792 fputs (l_flags_vals
[fcnt
].name
, stdout
);
8793 flags
^= l_flags_vals
[fcnt
].bit
;
8796 printf (" %#x", (unsigned int) flags
);
8806 if (options_offset
!= 0)
8808 Elf_External_Options
* eopt
;
8809 Elf_Internal_Shdr
* sect
= section_headers
;
8810 Elf_Internal_Options
* iopt
;
8811 Elf_Internal_Options
* option
;
8815 /* Find the section header so that we get the size. */
8816 while (sect
->sh_type
!= SHT_MIPS_OPTIONS
)
8819 eopt
= (Elf_External_Options
*) get_data (NULL
, file
, options_offset
,
8820 sect
->sh_size
, _("options"));
8823 iopt
= ((Elf_Internal_Options
*)
8824 malloc ((sect
->sh_size
/ sizeof (eopt
)) * sizeof (* iopt
)));
8827 error (_("Out of memory"));
8834 while (offset
< sect
->sh_size
)
8836 Elf_External_Options
* eoption
;
8838 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
8840 option
->kind
= BYTE_GET (eoption
->kind
);
8841 option
->size
= BYTE_GET (eoption
->size
);
8842 option
->section
= BYTE_GET (eoption
->section
);
8843 option
->info
= BYTE_GET (eoption
->info
);
8845 offset
+= option
->size
;
8851 printf (_("\nSection '%s' contains %d entries:\n"),
8852 SECTION_NAME (sect
), cnt
);
8860 switch (option
->kind
)
8863 /* This shouldn't happen. */
8864 printf (" NULL %d %lx", option
->section
, option
->info
);
8867 printf (" REGINFO ");
8868 if (elf_header
.e_machine
== EM_MIPS
)
8871 Elf32_External_RegInfo
* ereg
;
8872 Elf32_RegInfo reginfo
;
8874 ereg
= (Elf32_External_RegInfo
*) (option
+ 1);
8875 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8876 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8877 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8878 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8879 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8880 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
8882 printf ("GPR %08lx GP 0x%lx\n",
8884 (unsigned long) reginfo
.ri_gp_value
);
8885 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8886 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8887 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8892 Elf64_External_RegInfo
* ereg
;
8893 Elf64_Internal_RegInfo reginfo
;
8895 ereg
= (Elf64_External_RegInfo
*) (option
+ 1);
8896 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8897 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8898 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8899 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8900 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8901 reginfo
.ri_gp_value
= BYTE_GET8 (ereg
->ri_gp_value
);
8903 printf ("GPR %08lx GP 0x",
8904 reginfo
.ri_gprmask
);
8905 printf_vma (reginfo
.ri_gp_value
);
8908 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8909 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8910 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8914 case ODK_EXCEPTIONS
:
8915 fputs (" EXCEPTIONS fpe_min(", stdout
);
8916 process_mips_fpe_exception (option
->info
& OEX_FPU_MIN
);
8917 fputs (") fpe_max(", stdout
);
8918 process_mips_fpe_exception ((option
->info
& OEX_FPU_MAX
) >> 8);
8919 fputs (")", stdout
);
8921 if (option
->info
& OEX_PAGE0
)
8922 fputs (" PAGE0", stdout
);
8923 if (option
->info
& OEX_SMM
)
8924 fputs (" SMM", stdout
);
8925 if (option
->info
& OEX_FPDBUG
)
8926 fputs (" FPDBUG", stdout
);
8927 if (option
->info
& OEX_DISMISS
)
8928 fputs (" DISMISS", stdout
);
8931 fputs (" PAD ", stdout
);
8932 if (option
->info
& OPAD_PREFIX
)
8933 fputs (" PREFIX", stdout
);
8934 if (option
->info
& OPAD_POSTFIX
)
8935 fputs (" POSTFIX", stdout
);
8936 if (option
->info
& OPAD_SYMBOL
)
8937 fputs (" SYMBOL", stdout
);
8940 fputs (" HWPATCH ", stdout
);
8941 if (option
->info
& OHW_R4KEOP
)
8942 fputs (" R4KEOP", stdout
);
8943 if (option
->info
& OHW_R8KPFETCH
)
8944 fputs (" R8KPFETCH", stdout
);
8945 if (option
->info
& OHW_R5KEOP
)
8946 fputs (" R5KEOP", stdout
);
8947 if (option
->info
& OHW_R5KCVTL
)
8948 fputs (" R5KCVTL", stdout
);
8951 fputs (" FILL ", stdout
);
8952 /* XXX Print content of info word? */
8955 fputs (" TAGS ", stdout
);
8956 /* XXX Print content of info word? */
8959 fputs (" HWAND ", stdout
);
8960 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8961 fputs (" R4KEOP_CHECKED", stdout
);
8962 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8963 fputs (" R4KEOP_CLEAN", stdout
);
8966 fputs (" HWOR ", stdout
);
8967 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8968 fputs (" R4KEOP_CHECKED", stdout
);
8969 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8970 fputs (" R4KEOP_CLEAN", stdout
);
8973 printf (" GP_GROUP %#06lx self-contained %#06lx",
8974 option
->info
& OGP_GROUP
,
8975 (option
->info
& OGP_SELF
) >> 16);
8978 printf (" IDENT %#06lx self-contained %#06lx",
8979 option
->info
& OGP_GROUP
,
8980 (option
->info
& OGP_SELF
) >> 16);
8983 /* This shouldn't happen. */
8984 printf (" %3d ??? %d %lx",
8985 option
->kind
, option
->section
, option
->info
);
8989 len
= sizeof (* eopt
);
8990 while (len
< option
->size
)
8991 if (((char *) option
)[len
] >= ' '
8992 && ((char *) option
)[len
] < 0x7f)
8993 printf ("%c", ((char *) option
)[len
++]);
8995 printf ("\\%03o", ((char *) option
)[len
++]);
8997 fputs ("\n", stdout
);
9005 if (conflicts_offset
!= 0 && conflictsno
!= 0)
9007 Elf32_Conflict
* iconf
;
9010 if (dynamic_symbols
== NULL
)
9012 error (_("conflict list with without table"));
9016 iconf
= (Elf32_Conflict
*) malloc (conflictsno
* sizeof (* iconf
));
9019 error (_("Out of memory"));
9025 Elf32_External_Conflict
* econf32
;
9027 econf32
= ((Elf32_External_Conflict
*)
9028 get_data (NULL
, file
, conflicts_offset
,
9029 conflictsno
* sizeof (* econf32
),
9034 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
9035 iconf
[cnt
] = BYTE_GET (econf32
[cnt
]);
9041 Elf64_External_Conflict
* econf64
;
9043 econf64
= ((Elf64_External_Conflict
*)
9044 get_data (NULL
, file
, conflicts_offset
,
9045 conflictsno
* sizeof (* econf64
),
9050 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
9051 iconf
[cnt
] = BYTE_GET (econf64
[cnt
]);
9056 printf (_("\nSection '.conflict' contains %ld entries:\n"),
9057 (long) conflictsno
);
9058 puts (_(" Num: Index Value Name"));
9060 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
9062 Elf_Internal_Sym
* psym
= & dynamic_symbols
[iconf
[cnt
]];
9064 printf ("%5lu: %8lu ", (unsigned long) cnt
, iconf
[cnt
]);
9065 print_vma (psym
->st_value
, FULL_HEX
);
9067 print_symbol (25, dynamic_strings
+ psym
->st_name
);
9078 get_note_type (e_type
)
9081 static char buff
[64];
9085 case NT_PRSTATUS
: return _("NT_PRSTATUS (prstatus structure)");
9086 case NT_FPREGSET
: return _("NT_FPREGSET (floating point registers)");
9087 case NT_PRPSINFO
: return _("NT_PRPSINFO (prpsinfo structure)");
9088 case NT_TASKSTRUCT
: return _("NT_TASKSTRUCT (task structure)");
9089 case NT_PRXFPREG
: return _("NT_PRXFPREG (user_xfpregs structure)");
9090 case NT_PSTATUS
: return _("NT_PSTATUS (pstatus structure)");
9091 case NT_FPREGS
: return _("NT_FPREGS (floating point registers)");
9092 case NT_PSINFO
: return _("NT_PSINFO (psinfo structure)");
9093 case NT_LWPSTATUS
: return _("NT_LWPSTATUS (lwpstatus_t structure)");
9094 case NT_LWPSINFO
: return _("NT_LWPSINFO (lwpsinfo_t structure)");
9095 case NT_WIN32PSTATUS
: return _("NT_WIN32PSTATUS (win32_pstatus strcuture)");
9097 sprintf (buff
, _("Unknown note type: (0x%08x)"), e_type
);
9103 get_netbsd_elfcore_note_type (e_type
)
9106 static char buff
[64];
9108 if (e_type
== NT_NETBSDCORE_PROCINFO
)
9110 /* NetBSD core "procinfo" structure. */
9111 return _("NetBSD procinfo structure");
9114 /* As of Jan 2002 there are no other machine-independent notes
9115 defined for NetBSD core files. If the note type is less
9116 than the start of the machine-dependent note types, we don't
9119 if (e_type
< NT_NETBSDCORE_FIRSTMACH
)
9121 sprintf (buff
, _("Unknown note type: (0x%08x)"), e_type
);
9125 switch (elf_header
.e_machine
)
9127 /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0
9128 and PT_GETFPREGS == mach+2. */
9133 case EM_SPARC32PLUS
:
9137 case NT_NETBSDCORE_FIRSTMACH
+0:
9138 return _("PT_GETREGS (reg structure)");
9139 case NT_NETBSDCORE_FIRSTMACH
+2:
9140 return _("PT_GETFPREGS (fpreg structure)");
9146 /* On all other arch's, PT_GETREGS == mach+1 and
9147 PT_GETFPREGS == mach+3. */
9151 case NT_NETBSDCORE_FIRSTMACH
+1:
9152 return _("PT_GETREGS (reg structure)");
9153 case NT_NETBSDCORE_FIRSTMACH
+3:
9154 return _("PT_GETFPREGS (fpreg structure)");
9160 sprintf (buff
, _("PT_FIRSTMACH+%d"), e_type
- NT_NETBSDCORE_FIRSTMACH
);
9164 /* Note that by the ELF standard, the name field is already null byte
9165 terminated, and namesz includes the terminating null byte.
9166 I.E. the value of namesz for the name "FSF" is 4.
9168 If the value of namesz is zero, there is no name present. */
9170 process_note (pnote
)
9171 Elf32_Internal_Note
* pnote
;
9175 if (pnote
->namesz
== 0)
9177 /* If there is no note name, then use the default set of
9178 note type strings. */
9179 nt
= get_note_type (pnote
->type
);
9181 else if (strncmp (pnote
->namedata
, "NetBSD-CORE", 11) == 0)
9183 /* NetBSD-specific core file notes. */
9184 nt
= get_netbsd_elfcore_note_type (pnote
->type
);
9188 /* Don't recognize this note name; just use the default set of
9189 note type strings. */
9190 nt
= get_note_type (pnote
->type
);
9193 printf (" %s\t\t0x%08lx\t%s\n",
9194 pnote
->namesz
? pnote
->namedata
: "(NONE)",
9201 process_corefile_note_segment (file
, offset
, length
)
9206 Elf_External_Note
* pnotes
;
9207 Elf_External_Note
* external
;
9213 pnotes
= (Elf_External_Note
*) get_data (NULL
, file
, offset
, length
,
9220 printf (_("\nNotes at offset 0x%08lx with length 0x%08lx:\n"),
9221 (unsigned long) offset
, (unsigned long) length
);
9222 printf (_(" Owner\t\tData size\tDescription\n"));
9224 while (external
< (Elf_External_Note
*)((char *) pnotes
+ length
))
9226 Elf32_Internal_Note inote
;
9229 inote
.type
= BYTE_GET (external
->type
);
9230 inote
.namesz
= BYTE_GET (external
->namesz
);
9231 inote
.namedata
= external
->name
;
9232 inote
.descsz
= BYTE_GET (external
->descsz
);
9233 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 2);
9234 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
9236 external
= (Elf_External_Note
*)(inote
.descdata
+ align_power (inote
.descsz
, 2));
9238 /* Verify that name is null terminated. It appears that at least
9239 one version of Linux (RedHat 6.0) generates corefiles that don't
9240 comply with the ELF spec by failing to include the null byte in
9242 if (inote
.namedata
[inote
.namesz
] != '\0')
9244 temp
= malloc (inote
.namesz
+ 1);
9248 error (_("Out of memory\n"));
9253 strncpy (temp
, inote
.namedata
, inote
.namesz
);
9254 temp
[inote
.namesz
] = 0;
9256 /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */
9257 inote
.namedata
= temp
;
9260 res
&= process_note (& inote
);
9275 process_corefile_note_segments (file
)
9278 Elf_Internal_Phdr
* program_headers
;
9279 Elf_Internal_Phdr
* segment
;
9283 program_headers
= (Elf_Internal_Phdr
*) malloc
9284 (elf_header
.e_phnum
* sizeof (Elf_Internal_Phdr
));
9286 if (program_headers
== NULL
)
9288 error (_("Out of memory\n"));
9293 i
= get_32bit_program_headers (file
, program_headers
);
9295 i
= get_64bit_program_headers (file
, program_headers
);
9299 free (program_headers
);
9303 for (i
= 0, segment
= program_headers
;
9304 i
< elf_header
.e_phnum
;
9307 if (segment
->p_type
== PT_NOTE
)
9308 res
&= process_corefile_note_segment (file
,
9309 (bfd_vma
) segment
->p_offset
,
9310 (bfd_vma
) segment
->p_filesz
);
9313 free (program_headers
);
9319 process_corefile_contents (file
)
9322 /* If we have not been asked to display the notes then do nothing. */
9326 /* If file is not a core file then exit. */
9327 if (elf_header
.e_type
!= ET_CORE
)
9330 /* No program headers means no NOTE segment. */
9331 if (elf_header
.e_phnum
== 0)
9333 printf (_("No note segments present in the core file.\n"));
9337 return process_corefile_note_segments (file
);
9341 process_arch_specific (file
)
9347 switch (elf_header
.e_machine
)
9350 case EM_MIPS_RS3_LE
:
9351 return process_mips_specific (file
);
9360 get_file_header (file
)
9363 /* Read in the identity array. */
9364 if (fread (elf_header
.e_ident
, EI_NIDENT
, 1, file
) != 1)
9367 /* Determine how to read the rest of the header. */
9368 switch (elf_header
.e_ident
[EI_DATA
])
9370 default: /* fall through */
9371 case ELFDATANONE
: /* fall through */
9372 case ELFDATA2LSB
: byte_get
= byte_get_little_endian
; break;
9373 case ELFDATA2MSB
: byte_get
= byte_get_big_endian
; break;
9376 /* For now we only support 32 bit and 64 bit ELF files. */
9377 is_32bit_elf
= (elf_header
.e_ident
[EI_CLASS
] != ELFCLASS64
);
9379 /* Read in the rest of the header. */
9382 Elf32_External_Ehdr ehdr32
;
9384 if (fread (ehdr32
.e_type
, sizeof (ehdr32
) - EI_NIDENT
, 1, file
) != 1)
9387 elf_header
.e_type
= BYTE_GET (ehdr32
.e_type
);
9388 elf_header
.e_machine
= BYTE_GET (ehdr32
.e_machine
);
9389 elf_header
.e_version
= BYTE_GET (ehdr32
.e_version
);
9390 elf_header
.e_entry
= BYTE_GET (ehdr32
.e_entry
);
9391 elf_header
.e_phoff
= BYTE_GET (ehdr32
.e_phoff
);
9392 elf_header
.e_shoff
= BYTE_GET (ehdr32
.e_shoff
);
9393 elf_header
.e_flags
= BYTE_GET (ehdr32
.e_flags
);
9394 elf_header
.e_ehsize
= BYTE_GET (ehdr32
.e_ehsize
);
9395 elf_header
.e_phentsize
= BYTE_GET (ehdr32
.e_phentsize
);
9396 elf_header
.e_phnum
= BYTE_GET (ehdr32
.e_phnum
);
9397 elf_header
.e_shentsize
= BYTE_GET (ehdr32
.e_shentsize
);
9398 elf_header
.e_shnum
= BYTE_GET (ehdr32
.e_shnum
);
9399 elf_header
.e_shstrndx
= BYTE_GET (ehdr32
.e_shstrndx
);
9403 Elf64_External_Ehdr ehdr64
;
9405 /* If we have been compiled with sizeof (bfd_vma) == 4, then
9406 we will not be able to cope with the 64bit data found in
9407 64 ELF files. Detect this now and abort before we start
9408 overwritting things. */
9409 if (sizeof (bfd_vma
) < 8)
9411 error (_("This instance of readelf has been built without support for a\n\
9412 64 bit data type and so it cannot read 64 bit ELF files.\n"));
9416 if (fread (ehdr64
.e_type
, sizeof (ehdr64
) - EI_NIDENT
, 1, file
) != 1)
9419 elf_header
.e_type
= BYTE_GET (ehdr64
.e_type
);
9420 elf_header
.e_machine
= BYTE_GET (ehdr64
.e_machine
);
9421 elf_header
.e_version
= BYTE_GET (ehdr64
.e_version
);
9422 elf_header
.e_entry
= BYTE_GET8 (ehdr64
.e_entry
);
9423 elf_header
.e_phoff
= BYTE_GET8 (ehdr64
.e_phoff
);
9424 elf_header
.e_shoff
= BYTE_GET8 (ehdr64
.e_shoff
);
9425 elf_header
.e_flags
= BYTE_GET (ehdr64
.e_flags
);
9426 elf_header
.e_ehsize
= BYTE_GET (ehdr64
.e_ehsize
);
9427 elf_header
.e_phentsize
= BYTE_GET (ehdr64
.e_phentsize
);
9428 elf_header
.e_phnum
= BYTE_GET (ehdr64
.e_phnum
);
9429 elf_header
.e_shentsize
= BYTE_GET (ehdr64
.e_shentsize
);
9430 elf_header
.e_shnum
= BYTE_GET (ehdr64
.e_shnum
);
9431 elf_header
.e_shstrndx
= BYTE_GET (ehdr64
.e_shstrndx
);
9434 /* There may be some extensions in the first section header. Don't
9435 bomb if we can't read it. */
9437 get_32bit_section_headers (file
, 1);
9439 get_64bit_section_headers (file
, 1);
9445 process_file (file_name
)
9449 struct stat statbuf
;
9452 if (stat (file_name
, & statbuf
) < 0)
9454 error (_("Cannot stat input file %s.\n"), file_name
);
9458 file
= fopen (file_name
, "rb");
9461 error (_("Input file %s not found.\n"), file_name
);
9465 if (! get_file_header (file
))
9467 error (_("%s: Failed to read file header\n"), file_name
);
9472 /* Initialise per file variables. */
9473 for (i
= NUM_ELEM (version_info
); i
--;)
9474 version_info
[i
] = 0;
9476 for (i
= NUM_ELEM (dynamic_info
); i
--;)
9477 dynamic_info
[i
] = 0;
9479 /* Process the file. */
9481 printf (_("\nFile: %s\n"), file_name
);
9483 if (! process_file_header ())
9489 process_section_headers (file
);
9491 process_program_headers (file
);
9493 process_dynamic_segment (file
);
9495 process_relocs (file
);
9497 process_unwind (file
);
9499 process_symbol_table (file
);
9501 process_syminfo (file
);
9503 process_version_sections (file
);
9505 process_section_contents (file
);
9507 process_corefile_contents (file
);
9509 process_arch_specific (file
);
9513 if (section_headers
)
9515 free (section_headers
);
9516 section_headers
= NULL
;
9521 free (string_table
);
9522 string_table
= NULL
;
9523 string_table_length
= 0;
9526 if (dynamic_strings
)
9528 free (dynamic_strings
);
9529 dynamic_strings
= NULL
;
9532 if (dynamic_symbols
)
9534 free (dynamic_symbols
);
9535 dynamic_symbols
= NULL
;
9536 num_dynamic_syms
= 0;
9539 if (dynamic_syminfo
)
9541 free (dynamic_syminfo
);
9542 dynamic_syminfo
= NULL
;
9548 #ifdef SUPPORT_DISASSEMBLY
9549 /* Needed by the i386 disassembler. For extra credit, someone could
9550 fix this so that we insert symbolic addresses here, esp for GOT/PLT
9554 print_address (unsigned int addr
, FILE * outfile
)
9556 fprintf (outfile
,"0x%8.8x", addr
);
9559 /* Needed by the i386 disassembler. */
9561 db_task_printsym (unsigned int addr
)
9563 print_address (addr
, stderr
);
9567 int main
PARAMS ((int, char **));
9576 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
9577 setlocale (LC_MESSAGES
, "");
9579 #if defined (HAVE_SETLOCALE)
9580 setlocale (LC_CTYPE
, "");
9582 bindtextdomain (PACKAGE
, LOCALEDIR
);
9583 textdomain (PACKAGE
);
9585 parse_args (argc
, argv
);
9587 if (optind
< (argc
- 1))
9591 while (optind
< argc
)
9592 err
|= process_file (argv
[optind
++]);
9594 if (dump_sects
!= NULL
)