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
52 #include "elf/alpha.h"
68 #include "elf/mcore.h"
71 #include "elf/mn10200.h"
72 #include "elf/mn10300.h"
78 #include "elf/sparc.h"
80 #include "elf/x86-64.h"
81 #include "elf/xstormy16.h"
86 char * program_name
= "readelf";
87 unsigned int dynamic_addr
;
88 bfd_size_type dynamic_size
;
89 unsigned int rela_addr
;
90 unsigned int rela_size
;
91 char * dynamic_strings
;
93 unsigned long string_table_length
;
94 unsigned long num_dynamic_syms
;
95 Elf_Internal_Sym
* dynamic_symbols
;
96 Elf_Internal_Syminfo
* dynamic_syminfo
;
97 unsigned long dynamic_syminfo_offset
;
98 unsigned int dynamic_syminfo_nent
;
99 char program_interpreter
[64];
100 int dynamic_info
[DT_JMPREL
+ 1];
101 int version_info
[16];
103 Elf_Internal_Ehdr elf_header
;
104 Elf_Internal_Shdr
* section_headers
;
105 Elf_Internal_Dyn
* dynamic_segment
;
106 Elf_Internal_Shdr
* symtab_shndx_hdr
;
114 int do_using_dynamic
;
122 int do_debug_abbrevs
;
124 int do_debug_pubnames
;
125 int do_debug_aranges
;
127 int do_debug_frames_interp
;
128 int do_debug_macinfo
;
134 /* A dynamic array of flags indicating which sections require dumping. */
135 char * dump_sects
= NULL
;
136 unsigned int num_dump_sects
= 0;
138 #define HEX_DUMP (1 << 0)
139 #define DISASS_DUMP (1 << 1)
140 #define DEBUG_DUMP (1 << 2)
142 /* How to rpint a vma value. */
143 typedef enum print_mode
155 /* Forward declarations for dumb compilers. */
156 static void print_vma
PARAMS ((bfd_vma
, print_mode
));
157 static void print_symbol
PARAMS ((int, char *));
158 static bfd_vma (* byte_get
) PARAMS ((unsigned char *, int));
159 static bfd_vma byte_get_little_endian
PARAMS ((unsigned char *, int));
160 static bfd_vma byte_get_big_endian
PARAMS ((unsigned char *, int));
161 static const char * get_mips_dynamic_type
PARAMS ((unsigned long));
162 static const char * get_sparc64_dynamic_type
PARAMS ((unsigned long));
163 static const char * get_ppc64_dynamic_type
PARAMS ((unsigned long));
164 static const char * get_parisc_dynamic_type
PARAMS ((unsigned long));
165 static const char * get_dynamic_type
PARAMS ((unsigned long));
166 static int slurp_rela_relocs
PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Rela
**, unsigned long *));
167 static int slurp_rel_relocs
PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Rel
**, unsigned long *));
168 static int dump_relocations
PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Sym
*, unsigned long, char *, int));
169 static char * get_file_type
PARAMS ((unsigned));
170 static char * get_machine_name
PARAMS ((unsigned));
171 static void decode_ARM_machine_flags
PARAMS ((unsigned, char []));
172 static char * get_machine_flags
PARAMS ((unsigned, unsigned));
173 static const char * get_mips_segment_type
PARAMS ((unsigned long));
174 static const char * get_parisc_segment_type
PARAMS ((unsigned long));
175 static const char * get_ia64_segment_type
PARAMS ((unsigned long));
176 static const char * get_segment_type
PARAMS ((unsigned long));
177 static const char * get_mips_section_type_name
PARAMS ((unsigned int));
178 static const char * get_parisc_section_type_name
PARAMS ((unsigned int));
179 static const char * get_ia64_section_type_name
PARAMS ((unsigned int));
180 static const char * get_section_type_name
PARAMS ((unsigned int));
181 static const char * get_symbol_binding
PARAMS ((unsigned int));
182 static const char * get_symbol_type
PARAMS ((unsigned int));
183 static const char * get_symbol_visibility
PARAMS ((unsigned int));
184 static const char * get_symbol_index_type
PARAMS ((unsigned int));
185 static const char * get_dynamic_flags
PARAMS ((bfd_vma
));
186 static void usage
PARAMS ((void));
187 static void parse_args
PARAMS ((int, char **));
188 static int process_file_header
PARAMS ((void));
189 static int process_program_headers
PARAMS ((FILE *));
190 static int process_section_headers
PARAMS ((FILE *));
191 static int process_unwind
PARAMS ((FILE *));
192 static void dynamic_segment_mips_val
PARAMS ((Elf_Internal_Dyn
*));
193 static void dynamic_segment_parisc_val
PARAMS ((Elf_Internal_Dyn
*));
194 static int process_dynamic_segment
PARAMS ((FILE *));
195 static int process_symbol_table
PARAMS ((FILE *));
196 static int process_syminfo
PARAMS ((FILE *));
197 static int process_section_contents
PARAMS ((FILE *));
198 static void process_mips_fpe_exception
PARAMS ((int));
199 static int process_mips_specific
PARAMS ((FILE *));
200 static int process_file
PARAMS ((char *));
201 static int process_relocs
PARAMS ((FILE *));
202 static int process_version_sections
PARAMS ((FILE *));
203 static char * get_ver_flags
PARAMS ((unsigned int));
204 static int get_32bit_section_headers
PARAMS ((FILE *, unsigned int));
205 static int get_64bit_section_headers
PARAMS ((FILE *, unsigned int));
206 static int get_32bit_program_headers
PARAMS ((FILE *, Elf_Internal_Phdr
*));
207 static int get_64bit_program_headers
PARAMS ((FILE *, Elf_Internal_Phdr
*));
208 static int get_file_header
PARAMS ((FILE *));
209 static Elf_Internal_Sym
* get_32bit_elf_symbols
PARAMS ((FILE *, Elf_Internal_Shdr
*));
210 static Elf_Internal_Sym
* get_64bit_elf_symbols
PARAMS ((FILE *, Elf_Internal_Shdr
*));
211 static const char * get_elf_section_flags
PARAMS ((bfd_vma
));
212 static int * get_dynamic_data
PARAMS ((FILE *, unsigned int));
213 static int get_32bit_dynamic_segment
PARAMS ((FILE *));
214 static int get_64bit_dynamic_segment
PARAMS ((FILE *));
215 #ifdef SUPPORT_DISASSEMBLY
216 static int disassemble_section
PARAMS ((Elf32_Internal_Shdr
*, FILE *));
218 static int dump_section
PARAMS ((Elf32_Internal_Shdr
*, FILE *));
219 static int display_debug_section
PARAMS ((Elf32_Internal_Shdr
*, FILE *));
220 static int display_debug_info
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
221 static int display_debug_not_supported
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
222 static int prescan_debug_info
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
223 static int display_debug_lines
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
224 static int display_debug_pubnames
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
225 static int display_debug_abbrev
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
226 static int display_debug_aranges
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
227 static int display_debug_frames
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
228 static int display_debug_macinfo
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
229 static int display_debug_str
PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
230 static unsigned char * process_abbrev_section
PARAMS ((unsigned char *, unsigned char *));
231 static void load_debug_str
PARAMS ((FILE *));
232 static void free_debug_str
PARAMS ((void));
233 static const char * fetch_indirect_string
PARAMS ((unsigned long));
234 static unsigned long read_leb128
PARAMS ((unsigned char *, int *, int));
235 static int process_extended_line_op
PARAMS ((unsigned char *, int, int));
236 static void reset_state_machine
PARAMS ((int));
237 static char * get_TAG_name
PARAMS ((unsigned long));
238 static char * get_AT_name
PARAMS ((unsigned long));
239 static char * get_FORM_name
PARAMS ((unsigned long));
240 static void free_abbrevs
PARAMS ((void));
241 static void add_abbrev
PARAMS ((unsigned long, unsigned long, int));
242 static void add_abbrev_attr
PARAMS ((unsigned long, unsigned long));
243 static unsigned char * read_and_display_attr
PARAMS ((unsigned long, unsigned long, unsigned char *, unsigned long, unsigned long));
244 static unsigned char * read_and_display_attr_value
PARAMS ((unsigned long, unsigned long, unsigned char *, unsigned long, unsigned long));
245 static unsigned char * display_block
PARAMS ((unsigned char *, unsigned long));
246 static void decode_location_expression
PARAMS ((unsigned char *, unsigned int, unsigned long));
247 static void request_dump
PARAMS ((unsigned int, int));
248 static const char * get_elf_class
PARAMS ((unsigned int));
249 static const char * get_data_encoding
PARAMS ((unsigned int));
250 static const char * get_osabi_name
PARAMS ((unsigned int));
251 static int guess_is_rela
PARAMS ((unsigned long));
252 static const char * get_note_type
PARAMS ((unsigned int));
253 static const char * get_netbsd_elfcore_note_type
PARAMS ((unsigned int));
254 static int process_note
PARAMS ((Elf32_Internal_Note
*));
255 static int process_corefile_note_segment
PARAMS ((FILE *, bfd_vma
, bfd_vma
));
256 static int process_corefile_note_segments
PARAMS ((FILE *));
257 static int process_corefile_contents
PARAMS ((FILE *));
258 static int process_arch_specific
PARAMS ((FILE *));
260 typedef int Elf32_Word
;
268 #define SECTION_NAME(X) ((X) == NULL ? "<none>" : \
269 ((X)->sh_name >= string_table_length \
270 ? "<corrupt>" : string_table + (X)->sh_name))
272 /* Given st_shndx I, map to section_headers index. */
273 #define SECTION_HEADER_INDEX(I) \
274 ((I) < SHN_LORESERVE \
276 : ((I) <= SHN_HIRESERVE \
278 : (I) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))
280 /* Reverse of the above. */
281 #define SECTION_HEADER_NUM(N) \
282 ((N) < SHN_LORESERVE \
284 : (N) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))
286 #define SECTION_HEADER(I) (section_headers + SECTION_HEADER_INDEX (I))
288 #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
290 #define BYTE_GET(field) byte_get (field, sizeof (field))
292 /* If we can support a 64 bit data type then BFD64 should be defined
293 and sizeof (bfd_vma) == 8. In this case when translating from an
294 external 8 byte field to an internal field, we can assume that the
295 internal field is also 8 bytes wide and so we can extract all the data.
296 If, however, BFD64 is not defined, then we must assume that the
297 internal data structure only has 4 byte wide fields that are the
298 equivalent of the 8 byte wide external counterparts, and so we must
299 truncate the data. */
301 #define BYTE_GET8(field) byte_get (field, -8)
303 #define BYTE_GET8(field) byte_get (field, 8)
306 #define NUM_ELEM(array) (sizeof (array) / sizeof ((array)[0]))
308 #define GET_ELF_SYMBOLS(file, section) \
309 (is_32bit_elf ? get_32bit_elf_symbols (file, section) \
310 : get_64bit_elf_symbols (file, section))
314 error
VPARAMS ((const char *message
, ...))
316 VA_OPEN (args
, message
);
317 VA_FIXEDARG (args
, const char *, message
);
319 fprintf (stderr
, _("%s: Error: "), program_name
);
320 vfprintf (stderr
, message
, args
);
325 warn
VPARAMS ((const char *message
, ...))
327 VA_OPEN (args
, message
);
328 VA_FIXEDARG (args
, const char *, message
);
330 fprintf (stderr
, _("%s: Warning: "), program_name
);
331 vfprintf (stderr
, message
, args
);
335 static PTR get_data
PARAMS ((PTR
, FILE *, long, size_t, const char *));
338 get_data (var
, file
, offset
, size
, reason
)
350 if (fseek (file
, offset
, SEEK_SET
))
352 error (_("Unable to seek to %x for %s\n"), offset
, reason
);
359 mvar
= (PTR
) malloc (size
);
363 error (_("Out of memory allocating %d bytes for %s\n"),
369 if (fread (mvar
, size
, 1, file
) != 1)
371 error (_("Unable to read in %d bytes of %s\n"), size
, reason
);
381 byte_get_little_endian (field
, size
)
382 unsigned char * field
;
391 return ((unsigned int) (field
[0]))
392 | (((unsigned int) (field
[1])) << 8);
396 /* We want to extract data from an 8 byte wide field and
397 place it into a 4 byte wide field. Since this is a little
398 endian source we can juts use the 4 byte extraction code. */
402 return ((unsigned long) (field
[0]))
403 | (((unsigned long) (field
[1])) << 8)
404 | (((unsigned long) (field
[2])) << 16)
405 | (((unsigned long) (field
[3])) << 24);
410 /* This is a special case, generated by the BYTE_GET8 macro.
411 It means that we are loading an 8 byte value from a field
412 in an external structure into an 8 byte value in a field
413 in an internal strcuture. */
414 return ((bfd_vma
) (field
[0]))
415 | (((bfd_vma
) (field
[1])) << 8)
416 | (((bfd_vma
) (field
[2])) << 16)
417 | (((bfd_vma
) (field
[3])) << 24)
418 | (((bfd_vma
) (field
[4])) << 32)
419 | (((bfd_vma
) (field
[5])) << 40)
420 | (((bfd_vma
) (field
[6])) << 48)
421 | (((bfd_vma
) (field
[7])) << 56);
424 error (_("Unhandled data length: %d\n"), size
);
429 /* Print a VMA value. */
431 print_vma (vma
, mode
)
441 case FULL_HEX
: printf ("0x"); /* drop through */
442 case LONG_HEX
: printf ("%8.8lx", (unsigned long) vma
); break;
443 case PREFIX_HEX
: printf ("0x"); /* drop through */
444 case HEX
: printf ("%lx", (unsigned long) vma
); break;
445 case DEC
: printf ("%ld", (unsigned long) vma
); break;
446 case DEC_5
: printf ("%5ld", (long) vma
); break;
447 case UNSIGNED
: printf ("%lu", (unsigned long) vma
); break;
468 #if BFD_HOST_64BIT_LONG
471 if (_bfd_int64_high (vma
))
472 printf ("%lx%8.8lx", _bfd_int64_high (vma
), _bfd_int64_low (vma
));
474 printf ("%lx", _bfd_int64_low (vma
));
479 #if BFD_HOST_64BIT_LONG
482 if (_bfd_int64_high (vma
))
484 printf ("++%ld", _bfd_int64_low (vma
));
486 printf ("%ld", _bfd_int64_low (vma
));
491 #if BFD_HOST_64BIT_LONG
492 printf ("%5ld", vma
);
494 if (_bfd_int64_high (vma
))
496 printf ("++%ld", _bfd_int64_low (vma
));
498 printf ("%5ld", _bfd_int64_low (vma
));
503 #if BFD_HOST_64BIT_LONG
506 if (_bfd_int64_high (vma
))
508 printf ("++%lu", _bfd_int64_low (vma
));
510 printf ("%lu", _bfd_int64_low (vma
));
518 /* Display a symbol on stdout. If do_wide is not true then
519 format the symbol to be at most WIDTH characters,
520 truhncating as necessary. If WIDTH is negative then
521 format the string to be exactly - WIDTH characters,
522 truncating or padding as necessary. */
525 print_symbol (width
, symbol
)
532 printf ("%-*.*s", width
, width
, symbol
);
534 printf ("%-.*s", width
, symbol
);
538 byte_get_big_endian (field
, size
)
539 unsigned char * field
;
548 return ((unsigned int) (field
[1])) | (((int) (field
[0])) << 8);
551 return ((unsigned long) (field
[3]))
552 | (((unsigned long) (field
[2])) << 8)
553 | (((unsigned long) (field
[1])) << 16)
554 | (((unsigned long) (field
[0])) << 24);
558 /* Although we are extracing data from an 8 byte wide field, we
559 are returning only 4 bytes of data. */
560 return ((unsigned long) (field
[7]))
561 | (((unsigned long) (field
[6])) << 8)
562 | (((unsigned long) (field
[5])) << 16)
563 | (((unsigned long) (field
[4])) << 24);
567 /* This is a special case, generated by the BYTE_GET8 macro.
568 It means that we are loading an 8 byte value from a field
569 in an external structure into an 8 byte value in a field
570 in an internal strcuture. */
571 return ((bfd_vma
) (field
[7]))
572 | (((bfd_vma
) (field
[6])) << 8)
573 | (((bfd_vma
) (field
[5])) << 16)
574 | (((bfd_vma
) (field
[4])) << 24)
575 | (((bfd_vma
) (field
[3])) << 32)
576 | (((bfd_vma
) (field
[2])) << 40)
577 | (((bfd_vma
) (field
[1])) << 48)
578 | (((bfd_vma
) (field
[0])) << 56);
582 error (_("Unhandled data length: %d\n"), size
);
587 /* Guess the relocation size commonly used by the specific machines. */
590 guess_is_rela (e_machine
)
591 unsigned long e_machine
;
595 /* Targets that use REL relocations. */
610 /* Targets that use RELA relocations. */
625 case EM_CYGNUS_MN10200
:
627 case EM_CYGNUS_MN10300
:
664 warn (_("Don't know about relocations on this machine architecture\n"));
670 slurp_rela_relocs (file
, rel_offset
, rel_size
, relasp
, nrelasp
)
672 unsigned long rel_offset
;
673 unsigned long rel_size
;
674 Elf_Internal_Rela
**relasp
;
675 unsigned long *nrelasp
;
677 Elf_Internal_Rela
*relas
;
678 unsigned long nrelas
;
683 Elf32_External_Rela
* erelas
;
685 erelas
= (Elf32_External_Rela
*) get_data (NULL
, file
, rel_offset
,
686 rel_size
, _("relocs"));
690 nrelas
= rel_size
/ sizeof (Elf32_External_Rela
);
692 relas
= (Elf_Internal_Rela
*)
693 malloc (nrelas
* sizeof (Elf_Internal_Rela
));
697 error(_("out of memory parsing relocs"));
701 for (i
= 0; i
< nrelas
; i
++)
703 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
704 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
705 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
712 Elf64_External_Rela
* erelas
;
714 erelas
= (Elf64_External_Rela
*) get_data (NULL
, file
, rel_offset
,
715 rel_size
, _("relocs"));
719 nrelas
= rel_size
/ sizeof (Elf64_External_Rela
);
721 relas
= (Elf_Internal_Rela
*)
722 malloc (nrelas
* sizeof (Elf_Internal_Rela
));
726 error(_("out of memory parsing relocs"));
730 for (i
= 0; i
< nrelas
; i
++)
732 relas
[i
].r_offset
= BYTE_GET8 (erelas
[i
].r_offset
);
733 relas
[i
].r_info
= BYTE_GET8 (erelas
[i
].r_info
);
734 relas
[i
].r_addend
= BYTE_GET8 (erelas
[i
].r_addend
);
745 slurp_rel_relocs (file
, rel_offset
, rel_size
, relsp
, nrelsp
)
747 unsigned long rel_offset
;
748 unsigned long rel_size
;
749 Elf_Internal_Rel
**relsp
;
750 unsigned long *nrelsp
;
752 Elf_Internal_Rel
*rels
;
758 Elf32_External_Rel
* erels
;
760 erels
= (Elf32_External_Rel
*) get_data (NULL
, file
, rel_offset
,
761 rel_size
, _("relocs"));
765 nrels
= rel_size
/ sizeof (Elf32_External_Rel
);
767 rels
= (Elf_Internal_Rel
*) malloc (nrels
* sizeof (Elf_Internal_Rel
));
771 error(_("out of memory parsing relocs"));
775 for (i
= 0; i
< nrels
; i
++)
777 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
778 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
785 Elf64_External_Rel
* erels
;
787 erels
= (Elf64_External_Rel
*) get_data (NULL
, file
, rel_offset
,
788 rel_size
, _("relocs"));
792 nrels
= rel_size
/ sizeof (Elf64_External_Rel
);
794 rels
= (Elf_Internal_Rel
*) malloc (nrels
* sizeof (Elf_Internal_Rel
));
798 error(_("out of memory parsing relocs"));
802 for (i
= 0; i
< nrels
; i
++)
804 rels
[i
].r_offset
= BYTE_GET8 (erels
[i
].r_offset
);
805 rels
[i
].r_info
= BYTE_GET8 (erels
[i
].r_info
);
815 /* Display the contents of the relocation data found at the specified offset. */
817 dump_relocations (file
, rel_offset
, rel_size
, symtab
, nsyms
, strtab
, is_rela
)
819 unsigned long rel_offset
;
820 unsigned long rel_size
;
821 Elf_Internal_Sym
* symtab
;
827 Elf_Internal_Rel
* rels
;
828 Elf_Internal_Rela
* relas
;
831 if (is_rela
== UNKNOWN
)
832 is_rela
= guess_is_rela (elf_header
.e_machine
);
836 if (!slurp_rela_relocs (file
, rel_offset
, rel_size
, &relas
, &rel_size
))
841 if (!slurp_rel_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
849 (_(" Offset Info Type Symbol's Value Symbol's Name Addend\n"));
852 (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
858 (_(" Offset Info Type Symbol's Value Symbol's Name Addend\n"));
861 (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
864 for (i
= 0; i
< rel_size
; i
++)
869 bfd_vma symtab_index
;
874 offset
= relas
[i
].r_offset
;
875 info
= relas
[i
].r_info
;
879 offset
= rels
[i
].r_offset
;
880 info
= rels
[i
].r_info
;
885 type
= ELF32_R_TYPE (info
);
886 symtab_index
= ELF32_R_SYM (info
);
890 if (elf_header
.e_machine
== EM_SPARCV9
)
891 type
= ELF64_R_TYPE_ID (info
);
893 type
= ELF64_R_TYPE (info
);
894 /* The #ifdef BFD64 below is to prevent a compile time warning.
895 We know that if we do not have a 64 bit data type that we
896 will never execute this code anyway. */
898 symtab_index
= ELF64_R_SYM (info
);
904 #ifdef _bfd_int64_low
905 printf ("%8.8lx %8.8lx ", _bfd_int64_low (offset
), _bfd_int64_low (info
));
907 printf ("%8.8lx %8.8lx ", offset
, info
);
912 #ifdef _bfd_int64_low
913 printf ("%8.8lx%8.8lx %8.8lx%8.8lx ",
914 _bfd_int64_high (offset
),
915 _bfd_int64_low (offset
),
916 _bfd_int64_high (info
),
917 _bfd_int64_low (info
));
919 printf ("%16.16lx %16.16lx ", offset
, info
);
923 switch (elf_header
.e_machine
)
931 rtype
= elf_m32r_reloc_type (type
);
936 rtype
= elf_i386_reloc_type (type
);
940 rtype
= elf_m68k_reloc_type (type
);
944 rtype
= elf_i960_reloc_type (type
);
949 rtype
= elf_avr_reloc_type (type
);
956 rtype
= elf_sparc_reloc_type (type
);
961 rtype
= v850_reloc_type (type
);
966 rtype
= elf_d10v_reloc_type (type
);
971 rtype
= elf_d30v_reloc_type (type
);
975 rtype
= elf_sh_reloc_type (type
);
979 case EM_CYGNUS_MN10300
:
980 rtype
= elf_mn10300_reloc_type (type
);
984 case EM_CYGNUS_MN10200
:
985 rtype
= elf_mn10200_reloc_type (type
);
990 rtype
= elf_fr30_reloc_type (type
);
994 rtype
= elf_mcore_reloc_type (type
);
998 rtype
= elf_mmix_reloc_type (type
);
1003 rtype
= elf_ppc_reloc_type (type
);
1007 case EM_MIPS_RS3_LE
:
1008 rtype
= elf_mips_reloc_type (type
);
1012 rtype
= elf_alpha_reloc_type (type
);
1016 rtype
= elf_arm_reloc_type (type
);
1020 rtype
= elf_arc_reloc_type (type
);
1024 rtype
= elf_hppa_reloc_type (type
);
1030 rtype
= elf_h8_reloc_type (type
);
1035 rtype
= elf_or32_reloc_type (type
);
1040 rtype
= elf_pj_reloc_type (type
);
1043 rtype
= elf_ia64_reloc_type (type
);
1047 rtype
= elf_cris_reloc_type (type
);
1051 rtype
= elf_i860_reloc_type (type
);
1055 rtype
= elf_x86_64_reloc_type (type
);
1060 rtype
= elf_s390_reloc_type (type
);
1064 rtype
= elf_xstormy16_reloc_type (type
);
1069 #ifdef _bfd_int64_low
1070 printf (_("unrecognised: %-7lx"), _bfd_int64_low (type
));
1072 printf (_("unrecognised: %-7lx"), type
);
1075 printf ("%-21.21s", rtype
);
1079 if (symtab
== NULL
|| symtab_index
>= nsyms
)
1080 printf (" bad symbol index: %08lx", (unsigned long) symtab_index
);
1083 Elf_Internal_Sym
* psym
;
1085 psym
= symtab
+ symtab_index
;
1088 print_vma (psym
->st_value
, LONG_HEX
);
1091 if (psym
->st_name
== 0)
1092 print_symbol (-25, SECTION_NAME (section_headers
+ psym
->st_shndx
));
1093 else if (strtab
== NULL
)
1094 printf (_("<string table index %3ld>"), psym
->st_name
);
1096 print_symbol (-25, strtab
+ psym
->st_name
);
1099 printf (" + %lx", (unsigned long) relas
[i
].r_addend
);
1104 printf ("%*c", is_32bit_elf
? 34 : 26, ' ');
1105 print_vma (relas
[i
].r_addend
, LONG_HEX
);
1108 if (elf_header
.e_machine
== EM_SPARCV9
1109 && !strcmp (rtype
, "R_SPARC_OLO10"))
1110 printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (info
));
1124 get_mips_dynamic_type (type
)
1129 case DT_MIPS_RLD_VERSION
: return "MIPS_RLD_VERSION";
1130 case DT_MIPS_TIME_STAMP
: return "MIPS_TIME_STAMP";
1131 case DT_MIPS_ICHECKSUM
: return "MIPS_ICHECKSUM";
1132 case DT_MIPS_IVERSION
: return "MIPS_IVERSION";
1133 case DT_MIPS_FLAGS
: return "MIPS_FLAGS";
1134 case DT_MIPS_BASE_ADDRESS
: return "MIPS_BASE_ADDRESS";
1135 case DT_MIPS_MSYM
: return "MIPS_MSYM";
1136 case DT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
1137 case DT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
1138 case DT_MIPS_LOCAL_GOTNO
: return "MIPS_LOCAL_GOTNO";
1139 case DT_MIPS_CONFLICTNO
: return "MIPS_CONFLICTNO";
1140 case DT_MIPS_LIBLISTNO
: return "MIPS_LIBLISTNO";
1141 case DT_MIPS_SYMTABNO
: return "MIPS_SYMTABNO";
1142 case DT_MIPS_UNREFEXTNO
: return "MIPS_UNREFEXTNO";
1143 case DT_MIPS_GOTSYM
: return "MIPS_GOTSYM";
1144 case DT_MIPS_HIPAGENO
: return "MIPS_HIPAGENO";
1145 case DT_MIPS_RLD_MAP
: return "MIPS_RLD_MAP";
1146 case DT_MIPS_DELTA_CLASS
: return "MIPS_DELTA_CLASS";
1147 case DT_MIPS_DELTA_CLASS_NO
: return "MIPS_DELTA_CLASS_NO";
1148 case DT_MIPS_DELTA_INSTANCE
: return "MIPS_DELTA_INSTANCE";
1149 case DT_MIPS_DELTA_INSTANCE_NO
: return "MIPS_DELTA_INSTANCE_NO";
1150 case DT_MIPS_DELTA_RELOC
: return "MIPS_DELTA_RELOC";
1151 case DT_MIPS_DELTA_RELOC_NO
: return "MIPS_DELTA_RELOC_NO";
1152 case DT_MIPS_DELTA_SYM
: return "MIPS_DELTA_SYM";
1153 case DT_MIPS_DELTA_SYM_NO
: return "MIPS_DELTA_SYM_NO";
1154 case DT_MIPS_DELTA_CLASSSYM
: return "MIPS_DELTA_CLASSSYM";
1155 case DT_MIPS_DELTA_CLASSSYM_NO
: return "MIPS_DELTA_CLASSSYM_NO";
1156 case DT_MIPS_CXX_FLAGS
: return "MIPS_CXX_FLAGS";
1157 case DT_MIPS_PIXIE_INIT
: return "MIPS_PIXIE_INIT";
1158 case DT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
1159 case DT_MIPS_LOCALPAGE_GOTIDX
: return "MIPS_LOCALPAGE_GOTIDX";
1160 case DT_MIPS_LOCAL_GOTIDX
: return "MIPS_LOCAL_GOTIDX";
1161 case DT_MIPS_HIDDEN_GOTIDX
: return "MIPS_HIDDEN_GOTIDX";
1162 case DT_MIPS_PROTECTED_GOTIDX
: return "MIPS_PROTECTED_GOTIDX";
1163 case DT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
1164 case DT_MIPS_INTERFACE
: return "MIPS_INTERFACE";
1165 case DT_MIPS_DYNSTR_ALIGN
: return "MIPS_DYNSTR_ALIGN";
1166 case DT_MIPS_INTERFACE_SIZE
: return "MIPS_INTERFACE_SIZE";
1167 case DT_MIPS_RLD_TEXT_RESOLVE_ADDR
: return "MIPS_RLD_TEXT_RESOLVE_ADDR";
1168 case DT_MIPS_PERF_SUFFIX
: return "MIPS_PERF_SUFFIX";
1169 case DT_MIPS_COMPACT_SIZE
: return "MIPS_COMPACT_SIZE";
1170 case DT_MIPS_GP_VALUE
: return "MIPS_GP_VALUE";
1171 case DT_MIPS_AUX_DYNAMIC
: return "MIPS_AUX_DYNAMIC";
1178 get_sparc64_dynamic_type (type
)
1183 case DT_SPARC_REGISTER
: return "SPARC_REGISTER";
1190 get_ppc64_dynamic_type (type
)
1195 case DT_PPC64_GLINK
: return "PPC64_GLINK";
1202 get_parisc_dynamic_type (type
)
1207 case DT_HP_LOAD_MAP
: return "HP_LOAD_MAP";
1208 case DT_HP_DLD_FLAGS
: return "HP_DLD_FLAGS";
1209 case DT_HP_DLD_HOOK
: return "HP_DLD_HOOK";
1210 case DT_HP_UX10_INIT
: return "HP_UX10_INIT";
1211 case DT_HP_UX10_INITSZ
: return "HP_UX10_INITSZ";
1212 case DT_HP_PREINIT
: return "HP_PREINIT";
1213 case DT_HP_PREINITSZ
: return "HP_PREINITSZ";
1214 case DT_HP_NEEDED
: return "HP_NEEDED";
1215 case DT_HP_TIME_STAMP
: return "HP_TIME_STAMP";
1216 case DT_HP_CHECKSUM
: return "HP_CHECKSUM";
1217 case DT_HP_GST_SIZE
: return "HP_GST_SIZE";
1218 case DT_HP_GST_VERSION
: return "HP_GST_VERSION";
1219 case DT_HP_GST_HASHVAL
: return "HP_GST_HASHVAL";
1226 get_dynamic_type (type
)
1229 static char buff
[32];
1233 case DT_NULL
: return "NULL";
1234 case DT_NEEDED
: return "NEEDED";
1235 case DT_PLTRELSZ
: return "PLTRELSZ";
1236 case DT_PLTGOT
: return "PLTGOT";
1237 case DT_HASH
: return "HASH";
1238 case DT_STRTAB
: return "STRTAB";
1239 case DT_SYMTAB
: return "SYMTAB";
1240 case DT_RELA
: return "RELA";
1241 case DT_RELASZ
: return "RELASZ";
1242 case DT_RELAENT
: return "RELAENT";
1243 case DT_STRSZ
: return "STRSZ";
1244 case DT_SYMENT
: return "SYMENT";
1245 case DT_INIT
: return "INIT";
1246 case DT_FINI
: return "FINI";
1247 case DT_SONAME
: return "SONAME";
1248 case DT_RPATH
: return "RPATH";
1249 case DT_SYMBOLIC
: return "SYMBOLIC";
1250 case DT_REL
: return "REL";
1251 case DT_RELSZ
: return "RELSZ";
1252 case DT_RELENT
: return "RELENT";
1253 case DT_PLTREL
: return "PLTREL";
1254 case DT_DEBUG
: return "DEBUG";
1255 case DT_TEXTREL
: return "TEXTREL";
1256 case DT_JMPREL
: return "JMPREL";
1257 case DT_BIND_NOW
: return "BIND_NOW";
1258 case DT_INIT_ARRAY
: return "INIT_ARRAY";
1259 case DT_FINI_ARRAY
: return "FINI_ARRAY";
1260 case DT_INIT_ARRAYSZ
: return "INIT_ARRAYSZ";
1261 case DT_FINI_ARRAYSZ
: return "FINI_ARRAYSZ";
1262 case DT_RUNPATH
: return "RUNPATH";
1263 case DT_FLAGS
: return "FLAGS";
1265 case DT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
1266 case DT_PREINIT_ARRAYSZ
: return "PREINIT_ARRAYSZ";
1268 case DT_CHECKSUM
: return "CHECKSUM";
1269 case DT_PLTPADSZ
: return "PLTPADSZ";
1270 case DT_MOVEENT
: return "MOVEENT";
1271 case DT_MOVESZ
: return "MOVESZ";
1272 case DT_FEATURE
: return "FEATURE";
1273 case DT_POSFLAG_1
: return "POSFLAG_1";
1274 case DT_SYMINSZ
: return "SYMINSZ";
1275 case DT_SYMINENT
: return "SYMINENT"; /* aka VALRNGHI */
1277 case DT_ADDRRNGLO
: return "ADDRRNGLO";
1278 case DT_CONFIG
: return "CONFIG";
1279 case DT_DEPAUDIT
: return "DEPAUDIT";
1280 case DT_AUDIT
: return "AUDIT";
1281 case DT_PLTPAD
: return "PLTPAD";
1282 case DT_MOVETAB
: return "MOVETAB";
1283 case DT_SYMINFO
: return "SYMINFO"; /* aka ADDRRNGHI */
1285 case DT_VERSYM
: return "VERSYM";
1287 case DT_RELACOUNT
: return "RELACOUNT";
1288 case DT_RELCOUNT
: return "RELCOUNT";
1289 case DT_FLAGS_1
: return "FLAGS_1";
1290 case DT_VERDEF
: return "VERDEF";
1291 case DT_VERDEFNUM
: return "VERDEFNUM";
1292 case DT_VERNEED
: return "VERNEED";
1293 case DT_VERNEEDNUM
: return "VERNEEDNUM";
1295 case DT_AUXILIARY
: return "AUXILIARY";
1296 case DT_USED
: return "USED";
1297 case DT_FILTER
: return "FILTER";
1300 if ((type
>= DT_LOPROC
) && (type
<= DT_HIPROC
))
1302 const char * result
;
1304 switch (elf_header
.e_machine
)
1307 case EM_MIPS_RS3_LE
:
1308 result
= get_mips_dynamic_type (type
);
1311 result
= get_sparc64_dynamic_type (type
);
1314 result
= get_ppc64_dynamic_type (type
);
1324 sprintf (buff
, _("Processor Specific: %lx"), type
);
1326 else if ((type
>= DT_LOOS
) && (type
<= DT_HIOS
))
1328 const char * result
;
1330 switch (elf_header
.e_machine
)
1333 result
= get_parisc_dynamic_type (type
);
1343 sprintf (buff
, _("Operating System specific: %lx"), type
);
1346 sprintf (buff
, _("<unknown>: %lx"), type
);
1353 get_file_type (e_type
)
1356 static char buff
[32];
1360 case ET_NONE
: return _("NONE (None)");
1361 case ET_REL
: return _("REL (Relocatable file)");
1362 case ET_EXEC
: return _("EXEC (Executable file)");
1363 case ET_DYN
: return _("DYN (Shared object file)");
1364 case ET_CORE
: return _("CORE (Core file)");
1367 if ((e_type
>= ET_LOPROC
) && (e_type
<= ET_HIPROC
))
1368 sprintf (buff
, _("Processor Specific: (%x)"), e_type
);
1369 else if ((e_type
>= ET_LOOS
) && (e_type
<= ET_HIOS
))
1370 sprintf (buff
, _("OS Specific: (%x)"), e_type
);
1372 sprintf (buff
, _("<unknown>: %x"), e_type
);
1378 get_machine_name (e_machine
)
1381 static char buff
[64]; /* XXX */
1385 case EM_NONE
: return _("None");
1386 case EM_M32
: return "WE32100";
1387 case EM_SPARC
: return "Sparc";
1388 case EM_386
: return "Intel 80386";
1389 case EM_68K
: return "MC68000";
1390 case EM_88K
: return "MC88000";
1391 case EM_486
: return "Intel 80486";
1392 case EM_860
: return "Intel 80860";
1393 case EM_MIPS
: return "MIPS R3000";
1394 case EM_S370
: return "IBM System/370";
1395 case EM_MIPS_RS3_LE
: return "MIPS R4000 big-endian";
1396 case EM_OLD_SPARCV9
: return "Sparc v9 (old)";
1397 case EM_PARISC
: return "HPPA";
1398 case EM_PPC_OLD
: return "Power PC (old)";
1399 case EM_SPARC32PLUS
: return "Sparc v8+" ;
1400 case EM_960
: return "Intel 90860";
1401 case EM_PPC
: return "PowerPC";
1402 case EM_PPC64
: return "PowerPC64";
1403 case EM_V800
: return "NEC V800";
1404 case EM_FR20
: return "Fujitsu FR20";
1405 case EM_RH32
: return "TRW RH32";
1406 case EM_MCORE
: return "MCORE";
1407 case EM_ARM
: return "ARM";
1408 case EM_OLD_ALPHA
: return "Digital Alpha (old)";
1409 case EM_SH
: return "Hitachi SH";
1410 case EM_SPARCV9
: return "Sparc v9";
1411 case EM_TRICORE
: return "Siemens Tricore";
1412 case EM_ARC
: return "ARC";
1413 case EM_H8_300
: return "Hitachi H8/300";
1414 case EM_H8_300H
: return "Hitachi H8/300H";
1415 case EM_H8S
: return "Hitachi H8S";
1416 case EM_H8_500
: return "Hitachi H8/500";
1417 case EM_IA_64
: return "Intel IA-64";
1418 case EM_MIPS_X
: return "Stanford MIPS-X";
1419 case EM_COLDFIRE
: return "Motorola Coldfire";
1420 case EM_68HC12
: return "Motorola M68HC12";
1421 case EM_ALPHA
: return "Alpha";
1422 case EM_CYGNUS_D10V
:
1423 case EM_D10V
: return "d10v";
1424 case EM_CYGNUS_D30V
:
1425 case EM_D30V
: return "d30v";
1426 case EM_CYGNUS_M32R
:
1427 case EM_M32R
: return "Mitsubishi M32r";
1428 case EM_CYGNUS_V850
:
1429 case EM_V850
: return "NEC v850";
1430 case EM_CYGNUS_MN10300
:
1431 case EM_MN10300
: return "mn10300";
1432 case EM_CYGNUS_MN10200
:
1433 case EM_MN10200
: return "mn10200";
1434 case EM_CYGNUS_FR30
:
1435 case EM_FR30
: return "Fujitsu FR30";
1437 case EM_PJ
: return "picoJava";
1438 case EM_MMA
: return "Fujitsu Multimedia Accelerator";
1439 case EM_PCP
: return "Siemens PCP";
1440 case EM_NCPU
: return "Sony nCPU embedded RISC processor";
1441 case EM_NDR1
: return "Denso NDR1 microprocesspr";
1442 case EM_STARCORE
: return "Motorola Star*Core processor";
1443 case EM_ME16
: return "Toyota ME16 processor";
1444 case EM_ST100
: return "STMicroelectronics ST100 processor";
1445 case EM_TINYJ
: return "Advanced Logic Corp. TinyJ embedded processor";
1446 case EM_FX66
: return "Siemens FX66 microcontroller";
1447 case EM_ST9PLUS
: return "STMicroelectronics ST9+ 8/16 bit microcontroller";
1448 case EM_ST7
: return "STMicroelectronics ST7 8-bit microcontroller";
1449 case EM_68HC16
: return "Motorola MC68HC16 Microcontroller";
1450 case EM_68HC11
: return "Motorola MC68HC11 Microcontroller";
1451 case EM_68HC08
: return "Motorola MC68HC08 Microcontroller";
1452 case EM_68HC05
: return "Motorola MC68HC05 Microcontroller";
1453 case EM_SVX
: return "Silicon Graphics SVx";
1454 case EM_ST19
: return "STMicroelectronics ST19 8-bit microcontroller";
1455 case EM_VAX
: return "Digital VAX";
1457 case EM_AVR
: return "Atmel AVR 8-bit microcontroller";
1458 case EM_CRIS
: return "Axis Communications 32-bit embedded processor";
1459 case EM_JAVELIN
: return "Infineon Technologies 32-bit embedded cpu";
1460 case EM_FIREPATH
: return "Element 14 64-bit DSP processor";
1461 case EM_ZSP
: return "LSI Logic's 16-bit DSP processor";
1462 case EM_MMIX
: return "Donald Knuth's educational 64-bit processor";
1463 case EM_HUANY
: return "Harvard Universitys's machine-independent object format";
1464 case EM_PRISM
: return "SiTera Prism";
1465 case EM_X86_64
: return "Advanced Micro Devices X86-64";
1467 case EM_S390
: return "IBM S/390";
1468 case EM_XSTORMY16
: return "Sanyo Xstormy16 CPU core";
1470 case EM_OR32
: return "OpenRISC";
1472 sprintf (buff
, _("<unknown>: %x"), e_machine
);
1478 decode_ARM_machine_flags (e_flags
, buf
)
1485 eabi
= EF_ARM_EABI_VERSION (e_flags
);
1486 e_flags
&= ~ EF_ARM_EABIMASK
;
1488 /* Handle "generic" ARM flags. */
1489 if (e_flags
& EF_ARM_RELEXEC
)
1491 strcat (buf
, ", relocatable executable");
1492 e_flags
&= ~ EF_ARM_RELEXEC
;
1495 if (e_flags
& EF_ARM_HASENTRY
)
1497 strcat (buf
, ", has entry point");
1498 e_flags
&= ~ EF_ARM_HASENTRY
;
1501 /* Now handle EABI specific flags. */
1505 strcat (buf
, ", <unrecognised EABI>");
1510 case EF_ARM_EABI_VER1
:
1511 strcat (buf
, ", Version1 EABI");
1516 /* Process flags one bit at a time. */
1517 flag
= e_flags
& - e_flags
;
1522 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1523 strcat (buf
, ", sorted symbol tables");
1533 case EF_ARM_EABI_VER2
:
1534 strcat (buf
, ", Version2 EABI");
1539 /* Process flags one bit at a time. */
1540 flag
= e_flags
& - e_flags
;
1545 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1546 strcat (buf
, ", sorted symbol tables");
1549 case EF_ARM_DYNSYMSUSESEGIDX
:
1550 strcat (buf
, ", dynamic symbols use segment index");
1553 case EF_ARM_MAPSYMSFIRST
:
1554 strcat (buf
, ", mapping symbols precede others");
1564 case EF_ARM_EABI_UNKNOWN
:
1565 strcat (buf
, ", GNU EABI");
1570 /* Process flags one bit at a time. */
1571 flag
= e_flags
& - e_flags
;
1576 case EF_ARM_INTERWORK
:
1577 strcat (buf
, ", interworking enabled");
1580 case EF_ARM_APCS_26
:
1581 strcat (buf
, ", uses APCS/26");
1584 case EF_ARM_APCS_FLOAT
:
1585 strcat (buf
, ", uses APCS/float");
1589 strcat (buf
, ", position independent");
1593 strcat (buf
, ", 8 bit structure alignment");
1596 case EF_ARM_NEW_ABI
:
1597 strcat (buf
, ", uses new ABI");
1600 case EF_ARM_OLD_ABI
:
1601 strcat (buf
, ", uses old ABI");
1604 case EF_ARM_SOFT_FLOAT
:
1605 strcat (buf
, ", software FP");
1616 strcat (buf
,", <unknown>");
1620 get_machine_flags (e_flags
, e_machine
)
1624 static char buf
[1024];
1636 decode_ARM_machine_flags (e_flags
, buf
);
1640 if (e_flags
& EF_CPU32
)
1641 strcat (buf
, ", cpu32");
1645 if (e_flags
& EF_PPC_EMB
)
1646 strcat (buf
, ", emb");
1648 if (e_flags
& EF_PPC_RELOCATABLE
)
1649 strcat (buf
, ", relocatable");
1651 if (e_flags
& EF_PPC_RELOCATABLE_LIB
)
1652 strcat (buf
, ", relocatable-lib");
1656 case EM_CYGNUS_V850
:
1657 switch (e_flags
& EF_V850_ARCH
)
1660 strcat (buf
, ", v850e");
1663 strcat (buf
, ", v850ea");
1666 strcat (buf
, ", v850");
1669 strcat (buf
, ", unknown v850 architecture variant");
1675 case EM_CYGNUS_M32R
:
1676 if ((e_flags
& EF_M32R_ARCH
) == E_M32R_ARCH
)
1677 strcat (buf
, ", m32r");
1682 case EM_MIPS_RS3_LE
:
1683 if (e_flags
& EF_MIPS_NOREORDER
)
1684 strcat (buf
, ", noreorder");
1686 if (e_flags
& EF_MIPS_PIC
)
1687 strcat (buf
, ", pic");
1689 if (e_flags
& EF_MIPS_CPIC
)
1690 strcat (buf
, ", cpic");
1692 if (e_flags
& EF_MIPS_UCODE
)
1693 strcat (buf
, ", ugen_reserved");
1695 if (e_flags
& EF_MIPS_ABI2
)
1696 strcat (buf
, ", abi2");
1698 if (e_flags
& EF_MIPS_OPTIONS_FIRST
)
1699 strcat (buf
, ", odk first");
1701 if (e_flags
& EF_MIPS_32BITMODE
)
1702 strcat (buf
, ", 32bitmode");
1704 switch ((e_flags
& EF_MIPS_MACH
))
1706 case E_MIPS_MACH_3900
: strcat (buf
, ", 3900"); break;
1707 case E_MIPS_MACH_4010
: strcat (buf
, ", 4010"); break;
1708 case E_MIPS_MACH_4100
: strcat (buf
, ", 4100"); break;
1709 case E_MIPS_MACH_4650
: strcat (buf
, ", 4650"); break;
1710 case E_MIPS_MACH_4111
: strcat (buf
, ", 4111"); break;
1711 case E_MIPS_MACH_SB1
: strcat (buf
, ", sb1"); break;
1713 /* We simply ignore the field in this case to avoid confusion:
1714 MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
1717 default: strcat (buf
, ", unknown CPU"); break;
1720 switch ((e_flags
& EF_MIPS_ABI
))
1722 case E_MIPS_ABI_O32
: strcat (buf
, ", o32"); break;
1723 case E_MIPS_ABI_O64
: strcat (buf
, ", o64"); break;
1724 case E_MIPS_ABI_EABI32
: strcat (buf
, ", eabi32"); break;
1725 case E_MIPS_ABI_EABI64
: strcat (buf
, ", eabi64"); break;
1727 /* We simply ignore the field in this case to avoid confusion:
1728 MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension.
1729 This means it is likely to be an o32 file, but not for
1732 default: strcat (buf
, ", unknown ABI"); break;
1735 if (e_flags
& EF_MIPS_ARCH_ASE_MDMX
)
1736 strcat (buf
, ", mdmx");
1738 if (e_flags
& EF_MIPS_ARCH_ASE_M16
)
1739 strcat (buf
, ", mips16");
1741 switch ((e_flags
& EF_MIPS_ARCH
))
1743 case E_MIPS_ARCH_1
: strcat (buf
, ", mips1"); break;
1744 case E_MIPS_ARCH_2
: strcat (buf
, ", mips2"); break;
1745 case E_MIPS_ARCH_3
: strcat (buf
, ", mips3"); break;
1746 case E_MIPS_ARCH_4
: strcat (buf
, ", mips4"); break;
1747 case E_MIPS_ARCH_5
: strcat (buf
, ", mips5"); break;
1748 case E_MIPS_ARCH_32
: strcat (buf
, ", mips32"); break;
1749 case E_MIPS_ARCH_64
: strcat (buf
, ", mips64"); break;
1750 default: strcat (buf
, ", unknown ISA"); break;
1756 if (e_flags
& EF_SPARC_32PLUS
)
1757 strcat (buf
, ", v8+");
1759 if (e_flags
& EF_SPARC_SUN_US1
)
1760 strcat (buf
, ", ultrasparcI");
1762 if (e_flags
& EF_SPARC_SUN_US3
)
1763 strcat (buf
, ", ultrasparcIII");
1765 if (e_flags
& EF_SPARC_HAL_R1
)
1766 strcat (buf
, ", halr1");
1768 if (e_flags
& EF_SPARC_LEDATA
)
1769 strcat (buf
, ", ledata");
1771 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_TSO
)
1772 strcat (buf
, ", tso");
1774 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_PSO
)
1775 strcat (buf
, ", pso");
1777 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_RMO
)
1778 strcat (buf
, ", rmo");
1782 switch (e_flags
& EF_PARISC_ARCH
)
1784 case EFA_PARISC_1_0
:
1785 strcpy (buf
, ", PA-RISC 1.0");
1787 case EFA_PARISC_1_1
:
1788 strcpy (buf
, ", PA-RISC 1.1");
1790 case EFA_PARISC_2_0
:
1791 strcpy (buf
, ", PA-RISC 2.0");
1796 if (e_flags
& EF_PARISC_TRAPNIL
)
1797 strcat (buf
, ", trapnil");
1798 if (e_flags
& EF_PARISC_EXT
)
1799 strcat (buf
, ", ext");
1800 if (e_flags
& EF_PARISC_LSB
)
1801 strcat (buf
, ", lsb");
1802 if (e_flags
& EF_PARISC_WIDE
)
1803 strcat (buf
, ", wide");
1804 if (e_flags
& EF_PARISC_NO_KABP
)
1805 strcat (buf
, ", no kabp");
1806 if (e_flags
& EF_PARISC_LAZYSWAP
)
1807 strcat (buf
, ", lazyswap");
1812 if ((e_flags
& EF_PICOJAVA_NEWCALLS
) == EF_PICOJAVA_NEWCALLS
)
1813 strcat (buf
, ", new calling convention");
1815 if ((e_flags
& EF_PICOJAVA_GNUCALLS
) == EF_PICOJAVA_GNUCALLS
)
1816 strcat (buf
, ", gnu calling convention");
1820 if ((e_flags
& EF_IA_64_ABI64
))
1821 strcat (buf
, ", 64-bit");
1823 strcat (buf
, ", 32-bit");
1824 if ((e_flags
& EF_IA_64_REDUCEDFP
))
1825 strcat (buf
, ", reduced fp model");
1826 if ((e_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
))
1827 strcat (buf
, ", no function descriptors, constant gp");
1828 else if ((e_flags
& EF_IA_64_CONS_GP
))
1829 strcat (buf
, ", constant gp");
1830 if ((e_flags
& EF_IA_64_ABSOLUTE
))
1831 strcat (buf
, ", absolute");
1840 get_mips_segment_type (type
)
1845 case PT_MIPS_REGINFO
:
1847 case PT_MIPS_RTPROC
:
1849 case PT_MIPS_OPTIONS
:
1859 get_parisc_segment_type (type
)
1864 case PT_HP_TLS
: return "HP_TLS";
1865 case PT_HP_CORE_NONE
: return "HP_CORE_NONE";
1866 case PT_HP_CORE_VERSION
: return "HP_CORE_VERSION";
1867 case PT_HP_CORE_KERNEL
: return "HP_CORE_KERNEL";
1868 case PT_HP_CORE_COMM
: return "HP_CORE_COMM";
1869 case PT_HP_CORE_PROC
: return "HP_CORE_PROC";
1870 case PT_HP_CORE_LOADABLE
: return "HP_CORE_LOADABLE";
1871 case PT_HP_CORE_STACK
: return "HP_CORE_STACK";
1872 case PT_HP_CORE_SHM
: return "HP_CORE_SHM";
1873 case PT_HP_CORE_MMF
: return "HP_CORE_MMF";
1874 case PT_HP_PARALLEL
: return "HP_PARALLEL";
1875 case PT_HP_FASTBIND
: return "HP_FASTBIND";
1876 case PT_PARISC_ARCHEXT
: return "PARISC_ARCHEXT";
1877 case PT_PARISC_UNWIND
: return "PARISC_UNWIND";
1886 get_ia64_segment_type (type
)
1891 case PT_IA_64_ARCHEXT
: return "IA_64_ARCHEXT";
1892 case PT_IA_64_UNWIND
: return "IA_64_UNWIND";
1893 case PT_HP_TLS
: return "HP_TLS";
1894 case PT_IA_64_HP_OPT_ANOT
: return "HP_OPT_ANNOT";
1895 case PT_IA_64_HP_HSL_ANOT
: return "HP_HSL_ANNOT";
1896 case PT_IA_64_HP_STACK
: return "HP_STACK";
1905 get_segment_type (p_type
)
1906 unsigned long p_type
;
1908 static char buff
[32];
1912 case PT_NULL
: return "NULL";
1913 case PT_LOAD
: return "LOAD";
1914 case PT_DYNAMIC
: return "DYNAMIC";
1915 case PT_INTERP
: return "INTERP";
1916 case PT_NOTE
: return "NOTE";
1917 case PT_SHLIB
: return "SHLIB";
1918 case PT_PHDR
: return "PHDR";
1920 case PT_GNU_EH_FRAME
:
1921 return "GNU_EH_FRAME";
1924 if ((p_type
>= PT_LOPROC
) && (p_type
<= PT_HIPROC
))
1926 const char * result
;
1928 switch (elf_header
.e_machine
)
1931 case EM_MIPS_RS3_LE
:
1932 result
= get_mips_segment_type (p_type
);
1935 result
= get_parisc_segment_type (p_type
);
1938 result
= get_ia64_segment_type (p_type
);
1948 sprintf (buff
, "LOPROC+%lx", p_type
- PT_LOPROC
);
1950 else if ((p_type
>= PT_LOOS
) && (p_type
<= PT_HIOS
))
1952 const char * result
;
1954 switch (elf_header
.e_machine
)
1957 result
= get_parisc_segment_type (p_type
);
1960 result
= get_ia64_segment_type (p_type
);
1970 sprintf (buff
, "LOOS+%lx", p_type
- PT_LOOS
);
1973 sprintf (buff
, _("<unknown>: %lx"), p_type
);
1980 get_mips_section_type_name (sh_type
)
1981 unsigned int sh_type
;
1985 case SHT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
1986 case SHT_MIPS_MSYM
: return "MIPS_MSYM";
1987 case SHT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
1988 case SHT_MIPS_GPTAB
: return "MIPS_GPTAB";
1989 case SHT_MIPS_UCODE
: return "MIPS_UCODE";
1990 case SHT_MIPS_DEBUG
: return "MIPS_DEBUG";
1991 case SHT_MIPS_REGINFO
: return "MIPS_REGINFO";
1992 case SHT_MIPS_PACKAGE
: return "MIPS_PACKAGE";
1993 case SHT_MIPS_PACKSYM
: return "MIPS_PACKSYM";
1994 case SHT_MIPS_RELD
: return "MIPS_RELD";
1995 case SHT_MIPS_IFACE
: return "MIPS_IFACE";
1996 case SHT_MIPS_CONTENT
: return "MIPS_CONTENT";
1997 case SHT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
1998 case SHT_MIPS_SHDR
: return "MIPS_SHDR";
1999 case SHT_MIPS_FDESC
: return "MIPS_FDESC";
2000 case SHT_MIPS_EXTSYM
: return "MIPS_EXTSYM";
2001 case SHT_MIPS_DENSE
: return "MIPS_DENSE";
2002 case SHT_MIPS_PDESC
: return "MIPS_PDESC";
2003 case SHT_MIPS_LOCSYM
: return "MIPS_LOCSYM";
2004 case SHT_MIPS_AUXSYM
: return "MIPS_AUXSYM";
2005 case SHT_MIPS_OPTSYM
: return "MIPS_OPTSYM";
2006 case SHT_MIPS_LOCSTR
: return "MIPS_LOCSTR";
2007 case SHT_MIPS_LINE
: return "MIPS_LINE";
2008 case SHT_MIPS_RFDESC
: return "MIPS_RFDESC";
2009 case SHT_MIPS_DELTASYM
: return "MIPS_DELTASYM";
2010 case SHT_MIPS_DELTAINST
: return "MIPS_DELTAINST";
2011 case SHT_MIPS_DELTACLASS
: return "MIPS_DELTACLASS";
2012 case SHT_MIPS_DWARF
: return "MIPS_DWARF";
2013 case SHT_MIPS_DELTADECL
: return "MIPS_DELTADECL";
2014 case SHT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
2015 case SHT_MIPS_EVENTS
: return "MIPS_EVENTS";
2016 case SHT_MIPS_TRANSLATE
: return "MIPS_TRANSLATE";
2017 case SHT_MIPS_PIXIE
: return "MIPS_PIXIE";
2018 case SHT_MIPS_XLATE
: return "MIPS_XLATE";
2019 case SHT_MIPS_XLATE_DEBUG
: return "MIPS_XLATE_DEBUG";
2020 case SHT_MIPS_WHIRL
: return "MIPS_WHIRL";
2021 case SHT_MIPS_EH_REGION
: return "MIPS_EH_REGION";
2022 case SHT_MIPS_XLATE_OLD
: return "MIPS_XLATE_OLD";
2023 case SHT_MIPS_PDR_EXCEPTION
: return "MIPS_PDR_EXCEPTION";
2031 get_parisc_section_type_name (sh_type
)
2032 unsigned int sh_type
;
2036 case SHT_PARISC_EXT
: return "PARISC_EXT";
2037 case SHT_PARISC_UNWIND
: return "PARISC_UNWIND";
2038 case SHT_PARISC_DOC
: return "PARISC_DOC";
2046 get_ia64_section_type_name (sh_type
)
2047 unsigned int sh_type
;
2051 case SHT_IA_64_EXT
: return "IA_64_EXT";
2052 case SHT_IA_64_UNWIND
: return "IA_64_UNWIND";
2060 get_section_type_name (sh_type
)
2061 unsigned int sh_type
;
2063 static char buff
[32];
2067 case SHT_NULL
: return "NULL";
2068 case SHT_PROGBITS
: return "PROGBITS";
2069 case SHT_SYMTAB
: return "SYMTAB";
2070 case SHT_STRTAB
: return "STRTAB";
2071 case SHT_RELA
: return "RELA";
2072 case SHT_HASH
: return "HASH";
2073 case SHT_DYNAMIC
: return "DYNAMIC";
2074 case SHT_NOTE
: return "NOTE";
2075 case SHT_NOBITS
: return "NOBITS";
2076 case SHT_REL
: return "REL";
2077 case SHT_SHLIB
: return "SHLIB";
2078 case SHT_DYNSYM
: return "DYNSYM";
2079 case SHT_INIT_ARRAY
: return "INIT_ARRAY";
2080 case SHT_FINI_ARRAY
: return "FINI_ARRAY";
2081 case SHT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
2082 case SHT_GROUP
: return "GROUP";
2083 case SHT_SYMTAB_SHNDX
: return "SYMTAB SECTION INDICIES";
2084 case SHT_GNU_verdef
: return "VERDEF";
2085 case SHT_GNU_verneed
: return "VERNEED";
2086 case SHT_GNU_versym
: return "VERSYM";
2087 case 0x6ffffff0: return "VERSYM";
2088 case 0x6ffffffc: return "VERDEF";
2089 case 0x7ffffffd: return "AUXILIARY";
2090 case 0x7fffffff: return "FILTER";
2093 if ((sh_type
>= SHT_LOPROC
) && (sh_type
<= SHT_HIPROC
))
2095 const char * result
;
2097 switch (elf_header
.e_machine
)
2100 case EM_MIPS_RS3_LE
:
2101 result
= get_mips_section_type_name (sh_type
);
2104 result
= get_parisc_section_type_name (sh_type
);
2107 result
= get_ia64_section_type_name (sh_type
);
2117 sprintf (buff
, "LOPROC+%x", sh_type
- SHT_LOPROC
);
2119 else if ((sh_type
>= SHT_LOOS
) && (sh_type
<= SHT_HIOS
))
2120 sprintf (buff
, "LOOS+%x", sh_type
- SHT_LOOS
);
2121 else if ((sh_type
>= SHT_LOUSER
) && (sh_type
<= SHT_HIUSER
))
2122 sprintf (buff
, "LOUSER+%x", sh_type
- SHT_LOUSER
);
2124 sprintf (buff
, _("<unknown>: %x"), sh_type
);
2130 struct option options
[] =
2132 {"all", no_argument
, 0, 'a'},
2133 {"file-header", no_argument
, 0, 'h'},
2134 {"program-headers", no_argument
, 0, 'l'},
2135 {"headers", no_argument
, 0, 'e'},
2136 {"histogram", no_argument
, 0, 'I'},
2137 {"segments", no_argument
, 0, 'l'},
2138 {"sections", no_argument
, 0, 'S'},
2139 {"section-headers", no_argument
, 0, 'S'},
2140 {"symbols", no_argument
, 0, 's'},
2141 {"syms", no_argument
, 0, 's'},
2142 {"relocs", no_argument
, 0, 'r'},
2143 {"notes", no_argument
, 0, 'n'},
2144 {"dynamic", no_argument
, 0, 'd'},
2145 {"arch-specific", no_argument
, 0, 'A'},
2146 {"version-info", no_argument
, 0, 'V'},
2147 {"use-dynamic", no_argument
, 0, 'D'},
2148 {"hex-dump", required_argument
, 0, 'x'},
2149 {"debug-dump", optional_argument
, 0, 'w'},
2150 {"unwind", no_argument
, 0, 'u'},
2151 #ifdef SUPPORT_DISASSEMBLY
2152 {"instruction-dump", required_argument
, 0, 'i'},
2155 {"version", no_argument
, 0, 'v'},
2156 {"wide", no_argument
, 0, 'W'},
2157 {"help", no_argument
, 0, 'H'},
2158 {0, no_argument
, 0, 0}
2164 fprintf (stdout
, _("Usage: readelf <option(s)> elf-file(s)\n"));
2165 fprintf (stdout
, _(" Display information about the contents of ELF format files\n"));
2166 fprintf (stdout
, _(" Options are:\n\
2167 -a --all Equivalent to: -h -l -S -s -r -d -V -A -I\n\
2168 -h --file-header Display the ELF file header\n\
2169 -l --program-headers Display the program headers\n\
2170 --segments An alias for --program-headers\n\
2171 -S --section-headers Display the sections' header\n\
2172 --sections An alias for --section-headers\n\
2173 -e --headers Equivalent to: -h -l -S\n\
2174 -s --syms Display the symbol table\n\
2175 --symbols An alias for --syms\n\
2176 -n --notes Display the core notes (if present)\n\
2177 -r --relocs Display the relocations (if present)\n\
2178 -u --unwind Display the unwind info (if present)\n\
2179 -d --dynamic Display the dynamic segment (if present)\n\
2180 -V --version-info Display the version sections (if present)\n\
2181 -A --arch-specific Display architecture specific information (if any).\n\
2182 -D --use-dynamic Use the dynamic section info when displaying symbols\n\
2183 -x --hex-dump=<number> Dump the contents of section <number>\n\
2184 -w --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=str]\n\
2185 Display the contents of DWARF2 debug sections\n"));
2186 #ifdef SUPPORT_DISASSEMBLY
2187 fprintf (stdout
, _("\
2188 -i --instruction-dump=<number>\n\
2189 Disassemble the contents of section <number>\n"));
2191 fprintf (stdout
, _("\
2192 -I --histogram Display histogram of bucket list lengths\n\
2193 -W --wide Allow output width to exceed 80 characters\n\
2194 -H --help Display this information\n\
2195 -v --version Display the version number of readelf\n"));
2196 fprintf (stdout
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
2202 request_dump (section
, type
)
2203 unsigned int section
;
2206 if (section
>= num_dump_sects
)
2208 char * new_dump_sects
;
2210 new_dump_sects
= (char *) calloc (section
+ 1, 1);
2212 if (new_dump_sects
== NULL
)
2213 error (_("Out of memory allocating dump request table."));
2216 /* Copy current flag settings. */
2217 memcpy (new_dump_sects
, dump_sects
, num_dump_sects
);
2221 dump_sects
= new_dump_sects
;
2222 num_dump_sects
= section
+ 1;
2227 dump_sects
[section
] |= type
;
2233 parse_args (argc
, argv
)
2242 while ((c
= getopt_long
2243 (argc
, argv
, "ersuahnldSDAIw::x:i:vVW", options
, NULL
)) != EOF
)
2279 do_using_dynamic
++;
2310 section
= strtoul (optarg
, & cp
, 0);
2311 if (! * cp
&& section
>= 0)
2313 request_dump (section
, HEX_DUMP
);
2323 unsigned int index
= 0;
2327 while (optarg
[index
])
2328 switch (optarg
[index
++])
2337 do_debug_abbrevs
= 1;
2347 do_debug_pubnames
= 1;
2352 do_debug_aranges
= 1;
2356 do_debug_frames_interp
= 1;
2358 do_debug_frames
= 1;
2363 do_debug_macinfo
= 1;
2372 warn (_("Unrecognised debug option '%s'\n"), optarg
);
2377 #ifdef SUPPORT_DISASSEMBLY
2380 section
= strtoul (optarg
, & cp
, 0);
2381 if (! * cp
&& section
>= 0)
2383 request_dump (section
, DISASS_DUMP
);
2389 print_version (program_name
);
2399 /* xgettext:c-format */
2400 error (_("Invalid option '-%c'\n"), c
);
2407 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
2408 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
2409 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
)
2413 warn (_("Nothing to do.\n"));
2419 get_elf_class (elf_class
)
2420 unsigned int elf_class
;
2422 static char buff
[32];
2426 case ELFCLASSNONE
: return _("none");
2427 case ELFCLASS32
: return "ELF32";
2428 case ELFCLASS64
: return "ELF64";
2430 sprintf (buff
, _("<unknown: %x>"), elf_class
);
2436 get_data_encoding (encoding
)
2437 unsigned int encoding
;
2439 static char buff
[32];
2443 case ELFDATANONE
: return _("none");
2444 case ELFDATA2LSB
: return _("2's complement, little endian");
2445 case ELFDATA2MSB
: return _("2's complement, big endian");
2447 sprintf (buff
, _("<unknown: %x>"), encoding
);
2453 get_osabi_name (osabi
)
2456 static char buff
[32];
2460 case ELFOSABI_NONE
: return "UNIX - System V";
2461 case ELFOSABI_HPUX
: return "UNIX - HP-UX";
2462 case ELFOSABI_NETBSD
: return "UNIX - NetBSD";
2463 case ELFOSABI_LINUX
: return "UNIX - Linux";
2464 case ELFOSABI_HURD
: return "GNU/Hurd";
2465 case ELFOSABI_SOLARIS
: return "UNIX - Solaris";
2466 case ELFOSABI_AIX
: return "UNIX - AIX";
2467 case ELFOSABI_IRIX
: return "UNIX - IRIX";
2468 case ELFOSABI_FREEBSD
: return "UNIX - FreeBSD";
2469 case ELFOSABI_TRU64
: return "UNIX - TRU64";
2470 case ELFOSABI_MODESTO
: return "Novell - Modesto";
2471 case ELFOSABI_OPENBSD
: return "UNIX - OpenBSD";
2472 case ELFOSABI_STANDALONE
: return _("Standalone App");
2473 case ELFOSABI_ARM
: return "ARM";
2475 sprintf (buff
, _("<unknown: %x>"), osabi
);
2480 /* Decode the data held in 'elf_header'. */
2482 process_file_header ()
2484 if ( elf_header
.e_ident
[EI_MAG0
] != ELFMAG0
2485 || elf_header
.e_ident
[EI_MAG1
] != ELFMAG1
2486 || elf_header
.e_ident
[EI_MAG2
] != ELFMAG2
2487 || elf_header
.e_ident
[EI_MAG3
] != ELFMAG3
)
2490 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
2498 printf (_("ELF Header:\n"));
2499 printf (_(" Magic: "));
2500 for (i
= 0; i
< EI_NIDENT
; i
++)
2501 printf ("%2.2x ", elf_header
.e_ident
[i
]);
2503 printf (_(" Class: %s\n"),
2504 get_elf_class (elf_header
.e_ident
[EI_CLASS
]));
2505 printf (_(" Data: %s\n"),
2506 get_data_encoding (elf_header
.e_ident
[EI_DATA
]));
2507 printf (_(" Version: %d %s\n"),
2508 elf_header
.e_ident
[EI_VERSION
],
2509 (elf_header
.e_ident
[EI_VERSION
] == EV_CURRENT
2511 : (elf_header
.e_ident
[EI_VERSION
] != EV_NONE
2514 printf (_(" OS/ABI: %s\n"),
2515 get_osabi_name (elf_header
.e_ident
[EI_OSABI
]));
2516 printf (_(" ABI Version: %d\n"),
2517 elf_header
.e_ident
[EI_ABIVERSION
]);
2518 printf (_(" Type: %s\n"),
2519 get_file_type (elf_header
.e_type
));
2520 printf (_(" Machine: %s\n"),
2521 get_machine_name (elf_header
.e_machine
));
2522 printf (_(" Version: 0x%lx\n"),
2523 (unsigned long) elf_header
.e_version
);
2525 printf (_(" Entry point address: "));
2526 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
2527 printf (_("\n Start of program headers: "));
2528 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
2529 printf (_(" (bytes into file)\n Start of section headers: "));
2530 print_vma ((bfd_vma
) elf_header
.e_shoff
, DEC
);
2531 printf (_(" (bytes into file)\n"));
2533 printf (_(" Flags: 0x%lx%s\n"),
2534 (unsigned long) elf_header
.e_flags
,
2535 get_machine_flags (elf_header
.e_flags
, elf_header
.e_machine
));
2536 printf (_(" Size of this header: %ld (bytes)\n"),
2537 (long) elf_header
.e_ehsize
);
2538 printf (_(" Size of program headers: %ld (bytes)\n"),
2539 (long) elf_header
.e_phentsize
);
2540 printf (_(" Number of program headers: %ld\n"),
2541 (long) elf_header
.e_phnum
);
2542 printf (_(" Size of section headers: %ld (bytes)\n"),
2543 (long) elf_header
.e_shentsize
);
2544 printf (_(" Number of section headers: %ld"),
2545 (long) elf_header
.e_shnum
);
2546 if (section_headers
!= NULL
&& elf_header
.e_shnum
== 0)
2547 printf (" (%ld)", (long) section_headers
[0].sh_size
);
2548 putc ('\n', stdout
);
2549 printf (_(" Section header string table index: %ld"),
2550 (long) elf_header
.e_shstrndx
);
2551 if (section_headers
!= NULL
&& elf_header
.e_shstrndx
== SHN_XINDEX
)
2552 printf (" (%ld)", (long) section_headers
[0].sh_link
);
2553 putc ('\n', stdout
);
2556 if (section_headers
!= NULL
)
2558 if (elf_header
.e_shnum
== 0)
2559 elf_header
.e_shnum
= section_headers
[0].sh_size
;
2560 if (elf_header
.e_shstrndx
== SHN_XINDEX
)
2561 elf_header
.e_shstrndx
= section_headers
[0].sh_link
;
2562 free (section_headers
);
2563 section_headers
= NULL
;
2571 get_32bit_program_headers (file
, program_headers
)
2573 Elf_Internal_Phdr
* program_headers
;
2575 Elf32_External_Phdr
* phdrs
;
2576 Elf32_External_Phdr
* external
;
2577 Elf32_Internal_Phdr
* internal
;
2580 phdrs
= ((Elf32_External_Phdr
*)
2581 get_data (NULL
, file
, elf_header
.e_phoff
,
2582 elf_header
.e_phentsize
* elf_header
.e_phnum
,
2583 _("program headers")));
2587 for (i
= 0, internal
= program_headers
, external
= phdrs
;
2588 i
< elf_header
.e_phnum
;
2589 i
++, internal
++, external
++)
2591 internal
->p_type
= BYTE_GET (external
->p_type
);
2592 internal
->p_offset
= BYTE_GET (external
->p_offset
);
2593 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
2594 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
2595 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
2596 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
2597 internal
->p_flags
= BYTE_GET (external
->p_flags
);
2598 internal
->p_align
= BYTE_GET (external
->p_align
);
2607 get_64bit_program_headers (file
, program_headers
)
2609 Elf_Internal_Phdr
* program_headers
;
2611 Elf64_External_Phdr
* phdrs
;
2612 Elf64_External_Phdr
* external
;
2613 Elf64_Internal_Phdr
* internal
;
2616 phdrs
= ((Elf64_External_Phdr
*)
2617 get_data (NULL
, file
, elf_header
.e_phoff
,
2618 elf_header
.e_phentsize
* elf_header
.e_phnum
,
2619 _("program headers")));
2623 for (i
= 0, internal
= program_headers
, external
= phdrs
;
2624 i
< elf_header
.e_phnum
;
2625 i
++, internal
++, external
++)
2627 internal
->p_type
= BYTE_GET (external
->p_type
);
2628 internal
->p_flags
= BYTE_GET (external
->p_flags
);
2629 internal
->p_offset
= BYTE_GET8 (external
->p_offset
);
2630 internal
->p_vaddr
= BYTE_GET8 (external
->p_vaddr
);
2631 internal
->p_paddr
= BYTE_GET8 (external
->p_paddr
);
2632 internal
->p_filesz
= BYTE_GET8 (external
->p_filesz
);
2633 internal
->p_memsz
= BYTE_GET8 (external
->p_memsz
);
2634 internal
->p_align
= BYTE_GET8 (external
->p_align
);
2643 process_program_headers (file
)
2646 Elf_Internal_Phdr
* program_headers
;
2647 Elf_Internal_Phdr
* segment
;
2650 if (elf_header
.e_phnum
== 0)
2653 printf (_("\nThere are no program headers in this file.\n"));
2657 if (do_segments
&& !do_header
)
2659 printf (_("\nElf file type is %s\n"), get_file_type (elf_header
.e_type
));
2660 printf (_("Entry point "));
2661 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
2662 printf (_("\nThere are %d program headers, starting at offset "),
2663 elf_header
.e_phnum
);
2664 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
2668 program_headers
= (Elf_Internal_Phdr
*) malloc
2669 (elf_header
.e_phnum
* sizeof (Elf_Internal_Phdr
));
2671 if (program_headers
== NULL
)
2673 error (_("Out of memory\n"));
2678 i
= get_32bit_program_headers (file
, program_headers
);
2680 i
= get_64bit_program_headers (file
, program_headers
);
2684 free (program_headers
);
2691 (_("\nProgram Header%s:\n"), elf_header
.e_phnum
> 1 ? "s" : "");
2695 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
2698 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
2702 (_(" Type Offset VirtAddr PhysAddr\n"));
2704 (_(" FileSiz MemSiz Flags Align\n"));
2712 for (i
= 0, segment
= program_headers
;
2713 i
< elf_header
.e_phnum
;
2718 printf (" %-14.14s ", get_segment_type (segment
->p_type
));
2722 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
2723 printf ("0x%8.8lx ", (unsigned long) segment
->p_vaddr
);
2724 printf ("0x%8.8lx ", (unsigned long) segment
->p_paddr
);
2725 printf ("0x%5.5lx ", (unsigned long) segment
->p_filesz
);
2726 printf ("0x%5.5lx ", (unsigned long) segment
->p_memsz
);
2728 (segment
->p_flags
& PF_R
? 'R' : ' '),
2729 (segment
->p_flags
& PF_W
? 'W' : ' '),
2730 (segment
->p_flags
& PF_X
? 'E' : ' '));
2731 printf ("%#lx", (unsigned long) segment
->p_align
);
2735 if ((unsigned long) segment
->p_offset
== segment
->p_offset
)
2736 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
2739 print_vma (segment
->p_offset
, FULL_HEX
);
2743 print_vma (segment
->p_vaddr
, FULL_HEX
);
2745 print_vma (segment
->p_paddr
, FULL_HEX
);
2748 if ((unsigned long) segment
->p_filesz
== segment
->p_filesz
)
2749 printf ("0x%6.6lx ", (unsigned long) segment
->p_filesz
);
2752 print_vma (segment
->p_filesz
, FULL_HEX
);
2756 if ((unsigned long) segment
->p_memsz
== segment
->p_memsz
)
2757 printf ("0x%6.6lx", (unsigned long) segment
->p_memsz
);
2760 print_vma (segment
->p_offset
, FULL_HEX
);
2764 (segment
->p_flags
& PF_R
? 'R' : ' '),
2765 (segment
->p_flags
& PF_W
? 'W' : ' '),
2766 (segment
->p_flags
& PF_X
? 'E' : ' '));
2768 if ((unsigned long) segment
->p_align
== segment
->p_align
)
2769 printf ("%#lx", (unsigned long) segment
->p_align
);
2772 print_vma (segment
->p_align
, PREFIX_HEX
);
2777 print_vma (segment
->p_offset
, FULL_HEX
);
2779 print_vma (segment
->p_vaddr
, FULL_HEX
);
2781 print_vma (segment
->p_paddr
, FULL_HEX
);
2783 print_vma (segment
->p_filesz
, FULL_HEX
);
2785 print_vma (segment
->p_memsz
, FULL_HEX
);
2787 (segment
->p_flags
& PF_R
? 'R' : ' '),
2788 (segment
->p_flags
& PF_W
? 'W' : ' '),
2789 (segment
->p_flags
& PF_X
? 'E' : ' '));
2790 print_vma (segment
->p_align
, HEX
);
2794 switch (segment
->p_type
)
2798 loadaddr
= (segment
->p_vaddr
& 0xfffff000)
2799 - (segment
->p_offset
& 0xfffff000);
2804 error (_("more than one dynamic segment\n"));
2806 dynamic_addr
= segment
->p_offset
;
2807 dynamic_size
= segment
->p_filesz
;
2811 if (fseek (file
, (long) segment
->p_offset
, SEEK_SET
))
2812 error (_("Unable to find program interpreter name\n"));
2815 program_interpreter
[0] = 0;
2816 fscanf (file
, "%63s", program_interpreter
);
2819 printf (_("\n [Requesting program interpreter: %s]"),
2820 program_interpreter
);
2826 putc ('\n', stdout
);
2835 if (do_segments
&& section_headers
!= NULL
)
2837 printf (_("\n Section to Segment mapping:\n"));
2838 printf (_(" Segment Sections...\n"));
2840 assert (string_table
!= NULL
);
2842 for (i
= 0; i
< elf_header
.e_phnum
; i
++)
2845 Elf_Internal_Shdr
* section
;
2847 segment
= program_headers
+ i
;
2848 section
= section_headers
;
2850 printf (" %2.2d ", i
);
2852 for (j
= 1; j
< elf_header
.e_shnum
; j
++, section
++)
2854 if (section
->sh_size
> 0
2855 /* Compare allocated sections by VMA, unallocated
2856 sections by file offset. */
2857 && (section
->sh_flags
& SHF_ALLOC
2858 ? (section
->sh_addr
>= segment
->p_vaddr
2859 && section
->sh_addr
+ section
->sh_size
2860 <= segment
->p_vaddr
+ segment
->p_memsz
)
2861 : ((bfd_vma
) section
->sh_offset
>= segment
->p_offset
2862 && (section
->sh_offset
+ section
->sh_size
2863 <= segment
->p_offset
+ segment
->p_filesz
))))
2864 printf ("%s ", SECTION_NAME (section
));
2871 free (program_headers
);
2878 get_32bit_section_headers (file
, num
)
2882 Elf32_External_Shdr
* shdrs
;
2883 Elf32_Internal_Shdr
* internal
;
2886 shdrs
= ((Elf32_External_Shdr
*)
2887 get_data (NULL
, file
, elf_header
.e_shoff
,
2888 elf_header
.e_shentsize
* num
,
2889 _("section headers")));
2893 section_headers
= ((Elf_Internal_Shdr
*)
2894 malloc (num
* sizeof (Elf_Internal_Shdr
)));
2896 if (section_headers
== NULL
)
2898 error (_("Out of memory\n"));
2902 for (i
= 0, internal
= section_headers
;
2906 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
2907 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
2908 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
2909 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
2910 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
2911 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
2912 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
2913 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
2914 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
2915 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
2924 get_64bit_section_headers (file
, num
)
2928 Elf64_External_Shdr
* shdrs
;
2929 Elf64_Internal_Shdr
* internal
;
2932 shdrs
= ((Elf64_External_Shdr
*)
2933 get_data (NULL
, file
, elf_header
.e_shoff
,
2934 elf_header
.e_shentsize
* num
,
2935 _("section headers")));
2939 section_headers
= ((Elf_Internal_Shdr
*)
2940 malloc (num
* sizeof (Elf_Internal_Shdr
)));
2942 if (section_headers
== NULL
)
2944 error (_("Out of memory\n"));
2948 for (i
= 0, internal
= section_headers
;
2952 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
2953 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
2954 internal
->sh_flags
= BYTE_GET8 (shdrs
[i
].sh_flags
);
2955 internal
->sh_addr
= BYTE_GET8 (shdrs
[i
].sh_addr
);
2956 internal
->sh_size
= BYTE_GET8 (shdrs
[i
].sh_size
);
2957 internal
->sh_entsize
= BYTE_GET8 (shdrs
[i
].sh_entsize
);
2958 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
2959 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
2960 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
2961 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
2969 static Elf_Internal_Sym
*
2970 get_32bit_elf_symbols (file
, section
)
2972 Elf_Internal_Shdr
*section
;
2974 unsigned long number
;
2975 Elf32_External_Sym
* esyms
;
2976 Elf_External_Sym_Shndx
*shndx
;
2977 Elf_Internal_Sym
* isyms
;
2978 Elf_Internal_Sym
* psym
;
2981 esyms
= ((Elf32_External_Sym
*)
2982 get_data (NULL
, file
, section
->sh_offset
,
2983 section
->sh_size
, _("symbols")));
2988 if (symtab_shndx_hdr
!= NULL
2989 && (symtab_shndx_hdr
->sh_link
2990 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
2992 shndx
= ((Elf_External_Sym_Shndx
*)
2993 get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
2994 symtab_shndx_hdr
->sh_size
, _("symtab shndx")));
3002 number
= section
->sh_size
/ section
->sh_entsize
;
3003 isyms
= (Elf_Internal_Sym
*) malloc (number
* sizeof (Elf_Internal_Sym
));
3007 error (_("Out of memory\n"));
3014 for (j
= 0, psym
= isyms
;
3018 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3019 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3020 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3021 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3022 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3024 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3025 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3026 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3036 static Elf_Internal_Sym
*
3037 get_64bit_elf_symbols (file
, section
)
3039 Elf_Internal_Shdr
*section
;
3041 unsigned long number
;
3042 Elf64_External_Sym
* esyms
;
3043 Elf_External_Sym_Shndx
*shndx
;
3044 Elf_Internal_Sym
* isyms
;
3045 Elf_Internal_Sym
* psym
;
3048 esyms
= ((Elf64_External_Sym
*)
3049 get_data (NULL
, file
, section
->sh_offset
,
3050 section
->sh_size
, _("symbols")));
3055 if (symtab_shndx_hdr
!= NULL
3056 && (symtab_shndx_hdr
->sh_link
3057 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3059 shndx
= ((Elf_External_Sym_Shndx
*)
3060 get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3061 symtab_shndx_hdr
->sh_size
, _("symtab shndx")));
3069 number
= section
->sh_size
/ section
->sh_entsize
;
3070 isyms
= (Elf_Internal_Sym
*) malloc (number
* sizeof (Elf_Internal_Sym
));
3074 error (_("Out of memory\n"));
3081 for (j
= 0, psym
= isyms
;
3085 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3086 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3087 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3088 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3089 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3091 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3092 psym
->st_value
= BYTE_GET8 (esyms
[j
].st_value
);
3093 psym
->st_size
= BYTE_GET8 (esyms
[j
].st_size
);
3104 get_elf_section_flags (sh_flags
)
3107 static char buff
[32];
3115 flag
= sh_flags
& - sh_flags
;
3120 case SHF_WRITE
: strcat (buff
, "W"); break;
3121 case SHF_ALLOC
: strcat (buff
, "A"); break;
3122 case SHF_EXECINSTR
: strcat (buff
, "X"); break;
3123 case SHF_MERGE
: strcat (buff
, "M"); break;
3124 case SHF_STRINGS
: strcat (buff
, "S"); break;
3125 case SHF_INFO_LINK
: strcat (buff
, "I"); break;
3126 case SHF_LINK_ORDER
: strcat (buff
, "L"); break;
3127 case SHF_OS_NONCONFORMING
: strcat (buff
, "O"); break;
3128 case SHF_GROUP
: strcat (buff
, "G"); break;
3131 if (flag
& SHF_MASKOS
)
3134 sh_flags
&= ~ SHF_MASKOS
;
3136 else if (flag
& SHF_MASKPROC
)
3139 sh_flags
&= ~ SHF_MASKPROC
;
3151 process_section_headers (file
)
3154 Elf_Internal_Shdr
* section
;
3157 section_headers
= NULL
;
3159 if (elf_header
.e_shnum
== 0)
3162 printf (_("\nThere are no sections in this file.\n"));
3167 if (do_sections
&& !do_header
)
3168 printf (_("There are %d section headers, starting at offset 0x%lx:\n"),
3169 elf_header
.e_shnum
, (unsigned long) elf_header
.e_shoff
);
3173 if (! get_32bit_section_headers (file
, elf_header
.e_shnum
))
3176 else if (! get_64bit_section_headers (file
, elf_header
.e_shnum
))
3179 /* Read in the string table, so that we have names to display. */
3180 section
= SECTION_HEADER (elf_header
.e_shstrndx
);
3182 if (section
->sh_size
!= 0)
3184 string_table
= (char *) get_data (NULL
, file
, section
->sh_offset
,
3185 section
->sh_size
, _("string table"));
3187 string_table_length
= section
->sh_size
;
3190 /* Scan the sections for the dynamic symbol table
3191 and dynamic string table and debug sections. */
3192 dynamic_symbols
= NULL
;
3193 dynamic_strings
= NULL
;
3194 dynamic_syminfo
= NULL
;
3196 for (i
= 0, section
= section_headers
;
3197 i
< elf_header
.e_shnum
;
3200 char * name
= SECTION_NAME (section
);
3202 if (section
->sh_type
== SHT_DYNSYM
)
3204 if (dynamic_symbols
!= NULL
)
3206 error (_("File contains multiple dynamic symbol tables\n"));
3210 num_dynamic_syms
= section
->sh_size
/ section
->sh_entsize
;
3211 dynamic_symbols
= GET_ELF_SYMBOLS (file
, section
);
3213 else if (section
->sh_type
== SHT_STRTAB
3214 && strcmp (name
, ".dynstr") == 0)
3216 if (dynamic_strings
!= NULL
)
3218 error (_("File contains multiple dynamic string tables\n"));
3222 dynamic_strings
= (char *) get_data (NULL
, file
, section
->sh_offset
,
3224 _("dynamic strings"));
3226 else if (section
->sh_type
== SHT_SYMTAB_SHNDX
)
3228 if (symtab_shndx_hdr
!= NULL
)
3230 error (_("File contains multiple symtab shndx tables\n"));
3233 symtab_shndx_hdr
= section
;
3235 else if ((do_debugging
|| do_debug_info
|| do_debug_abbrevs
3236 || do_debug_lines
|| do_debug_pubnames
|| do_debug_aranges
3237 || do_debug_frames
|| do_debug_macinfo
|| do_debug_str
)
3238 && strncmp (name
, ".debug_", 7) == 0)
3243 || (do_debug_info
&& (strcmp (name
, "info") == 0))
3244 || (do_debug_abbrevs
&& (strcmp (name
, "abbrev") == 0))
3245 || (do_debug_lines
&& (strcmp (name
, "line") == 0))
3246 || (do_debug_pubnames
&& (strcmp (name
, "pubnames") == 0))
3247 || (do_debug_aranges
&& (strcmp (name
, "aranges") == 0))
3248 || (do_debug_frames
&& (strcmp (name
, "frame") == 0))
3249 || (do_debug_macinfo
&& (strcmp (name
, "macinfo") == 0))
3250 || (do_debug_str
&& (strcmp (name
, "str") == 0))
3252 request_dump (i
, DEBUG_DUMP
);
3254 /* linkonce section to be combined with .debug_info at link time. */
3255 else if ((do_debugging
|| do_debug_info
)
3256 && strncmp (name
, ".gnu.linkonce.wi.", 17) == 0)
3257 request_dump (i
, DEBUG_DUMP
);
3258 else if (do_debug_frames
&& strcmp (name
, ".eh_frame") == 0)
3259 request_dump (i
, DEBUG_DUMP
);
3265 printf (_("\nSection Header%s:\n"), elf_header
.e_shnum
> 1 ? "s" : "");
3269 (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
3272 (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n"));
3275 printf (_(" [Nr] Name Type Address Offset\n"));
3276 printf (_(" Size EntSize Flags Link Info Align\n"));
3279 for (i
= 0, section
= section_headers
;
3280 i
< elf_header
.e_shnum
;
3283 printf (" [%2u] %-17.17s %-15.15s ",
3284 SECTION_HEADER_NUM (i
),
3285 SECTION_NAME (section
),
3286 get_section_type_name (section
->sh_type
));
3290 print_vma (section
->sh_addr
, LONG_HEX
);
3292 printf ( " %6.6lx %6.6lx %2.2lx",
3293 (unsigned long) section
->sh_offset
,
3294 (unsigned long) section
->sh_size
,
3295 (unsigned long) section
->sh_entsize
);
3297 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
3299 printf ("%2ld %3lx %2ld\n",
3300 (unsigned long) section
->sh_link
,
3301 (unsigned long) section
->sh_info
,
3302 (unsigned long) section
->sh_addralign
);
3306 print_vma (section
->sh_addr
, LONG_HEX
);
3308 if ((long) section
->sh_offset
== section
->sh_offset
)
3309 printf (" %6.6lx", (unsigned long) section
->sh_offset
);
3313 print_vma (section
->sh_offset
, LONG_HEX
);
3316 if ((unsigned long) section
->sh_size
== section
->sh_size
)
3317 printf (" %6.6lx", (unsigned long) section
->sh_size
);
3321 print_vma (section
->sh_size
, LONG_HEX
);
3324 if ((unsigned long) section
->sh_entsize
== section
->sh_entsize
)
3325 printf (" %2.2lx", (unsigned long) section
->sh_entsize
);
3329 print_vma (section
->sh_entsize
, LONG_HEX
);
3332 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
3334 printf ("%2ld %3lx ",
3335 (unsigned long) section
->sh_link
,
3336 (unsigned long) section
->sh_info
);
3338 if ((unsigned long) section
->sh_addralign
== section
->sh_addralign
)
3339 printf ("%2ld\n", (unsigned long) section
->sh_addralign
);
3342 print_vma (section
->sh_addralign
, DEC
);
3349 print_vma (section
->sh_addr
, LONG_HEX
);
3350 if ((long) section
->sh_offset
== section
->sh_offset
)
3351 printf (" %8.8lx", (unsigned long) section
->sh_offset
);
3355 print_vma (section
->sh_offset
, LONG_HEX
);
3358 print_vma (section
->sh_size
, LONG_HEX
);
3360 print_vma (section
->sh_entsize
, LONG_HEX
);
3362 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
3364 printf (" %2ld %3lx %ld\n",
3365 (unsigned long) section
->sh_link
,
3366 (unsigned long) section
->sh_info
,
3367 (unsigned long) section
->sh_addralign
);
3371 printf (_("Key to Flags:\n\
3372 W (write), A (alloc), X (execute), M (merge), S (strings)\n\
3373 I (info), L (link order), G (group), x (unknown)\n\
3374 O (extra OS processing required) o (OS specific), p (processor specific)\n"));
3379 /* Process the reloc section. */
3381 process_relocs (file
)
3384 unsigned long rel_size
;
3385 unsigned long rel_offset
;
3391 if (do_using_dynamic
)
3393 int is_rela
= FALSE
;
3398 if (dynamic_info
[DT_REL
])
3400 rel_offset
= dynamic_info
[DT_REL
];
3401 rel_size
= dynamic_info
[DT_RELSZ
];
3404 else if (dynamic_info
[DT_RELA
])
3406 rel_offset
= dynamic_info
[DT_RELA
];
3407 rel_size
= dynamic_info
[DT_RELASZ
];
3410 else if (dynamic_info
[DT_JMPREL
])
3412 rel_offset
= dynamic_info
[DT_JMPREL
];
3413 rel_size
= dynamic_info
[DT_PLTRELSZ
];
3415 switch (dynamic_info
[DT_PLTREL
])
3432 (_("\nRelocation section at offset 0x%lx contains %ld bytes:\n"),
3433 rel_offset
, rel_size
);
3435 dump_relocations (file
, rel_offset
- loadaddr
, rel_size
,
3436 dynamic_symbols
, num_dynamic_syms
, dynamic_strings
, is_rela
);
3439 printf (_("\nThere are no dynamic relocations in this file.\n"));
3443 Elf32_Internal_Shdr
* section
;
3447 for (i
= 0, section
= section_headers
;
3448 i
< elf_header
.e_shnum
;
3451 if ( section
->sh_type
!= SHT_RELA
3452 && section
->sh_type
!= SHT_REL
)
3455 rel_offset
= section
->sh_offset
;
3456 rel_size
= section
->sh_size
;
3460 Elf32_Internal_Shdr
* strsec
;
3461 Elf_Internal_Sym
* symtab
;
3464 unsigned long nsyms
;
3466 printf (_("\nRelocation section "));
3468 if (string_table
== NULL
)
3469 printf ("%d", section
->sh_name
);
3471 printf ("'%s'", SECTION_NAME (section
));
3473 printf (_(" at offset 0x%lx contains %lu entries:\n"),
3474 rel_offset
, (unsigned long) (rel_size
/ section
->sh_entsize
));
3479 if (section
->sh_link
)
3481 Elf32_Internal_Shdr
* symsec
;
3483 symsec
= SECTION_HEADER (section
->sh_link
);
3484 nsyms
= symsec
->sh_size
/ symsec
->sh_entsize
;
3485 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
3490 strsec
= SECTION_HEADER (symsec
->sh_link
);
3492 strtab
= (char *) get_data (NULL
, file
, strsec
->sh_offset
,
3496 is_rela
= section
->sh_type
== SHT_RELA
;
3498 dump_relocations (file
, rel_offset
, rel_size
,
3499 symtab
, nsyms
, strtab
, is_rela
);
3511 printf (_("\nThere are no relocations in this file.\n"));
3517 #include "unwind-ia64.h"
3519 /* An absolute address consists of a section and an offset. If the
3520 section is NULL, the offset itself is the address, otherwise, the
3521 address equals to LOAD_ADDRESS(section) + offset. */
3525 unsigned short section
;
3531 struct unw_table_entry
3533 struct absaddr start
;
3535 struct absaddr info
;
3537 *table
; /* Unwind table. */
3538 unsigned long table_len
; /* Length of unwind table. */
3539 unsigned char * info
; /* Unwind info. */
3540 unsigned long info_size
; /* Size of unwind info. */
3541 bfd_vma info_addr
; /* starting address of unwind info. */
3542 bfd_vma seg_base
; /* Starting address of segment. */
3543 Elf_Internal_Sym
* symtab
; /* The symbol table. */
3544 unsigned long nsyms
; /* Number of symbols. */
3545 char * strtab
; /* The string table. */
3546 unsigned long strtab_size
; /* Size of string table. */
3549 static void find_symbol_for_address
PARAMS ((struct unw_aux_info
*,
3550 struct absaddr
, const char **,
3552 static void dump_ia64_unwind
PARAMS ((struct unw_aux_info
*));
3553 static int slurp_ia64_unwind_table
PARAMS ((FILE *, struct unw_aux_info
*,
3554 Elf32_Internal_Shdr
*));
3557 find_symbol_for_address (aux
, addr
, symname
, offset
)
3558 struct unw_aux_info
*aux
;
3559 struct absaddr addr
;
3560 const char **symname
;
3563 bfd_vma dist
= (bfd_vma
) 0x100000;
3564 Elf_Internal_Sym
*sym
, *best
= NULL
;
3567 for (i
= 0, sym
= aux
->symtab
; i
< aux
->nsyms
; ++i
, ++sym
)
3569 if (ELF_ST_TYPE (sym
->st_info
) == STT_FUNC
3570 && sym
->st_name
!= 0
3571 && (addr
.section
== SHN_UNDEF
|| addr
.section
== sym
->st_shndx
)
3572 && addr
.offset
>= sym
->st_value
3573 && addr
.offset
- sym
->st_value
< dist
)
3576 dist
= addr
.offset
- sym
->st_value
;
3583 *symname
= (best
->st_name
>= aux
->strtab_size
3584 ? "<corrupt>" : aux
->strtab
+ best
->st_name
);
3589 *offset
= addr
.offset
;
3593 dump_ia64_unwind (aux
)
3594 struct unw_aux_info
*aux
;
3597 struct unw_table_entry
* tp
;
3600 addr_size
= is_32bit_elf
? 4 : 8;
3602 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
3606 const unsigned char * dp
;
3607 const unsigned char * head
;
3608 const char * procname
;
3610 find_symbol_for_address (aux
, tp
->start
, &procname
, &offset
);
3612 fputs ("\n<", stdout
);
3616 fputs (procname
, stdout
);
3619 printf ("+%lx", (unsigned long) offset
);
3622 fputs (">: [", stdout
);
3623 print_vma (tp
->start
.offset
, PREFIX_HEX
);
3624 fputc ('-', stdout
);
3625 print_vma (tp
->end
.offset
, PREFIX_HEX
);
3626 printf ("), info at +0x%lx\n",
3627 (unsigned long) (tp
->info
.offset
- aux
->seg_base
));
3629 head
= aux
->info
+ (tp
->info
.offset
- aux
->info_addr
);
3630 stamp
= BYTE_GET8 ((unsigned char *) head
);
3632 printf (" v%u, flags=0x%lx (%s%s ), len=%lu bytes\n",
3633 (unsigned) UNW_VER (stamp
),
3634 (unsigned long) ((stamp
& UNW_FLAG_MASK
) >> 32),
3635 UNW_FLAG_EHANDLER (stamp
) ? " ehandler" : "",
3636 UNW_FLAG_UHANDLER (stamp
) ? " uhandler" : "",
3637 (unsigned long) (addr_size
* UNW_LENGTH (stamp
)));
3639 if (UNW_VER (stamp
) != 1)
3641 printf ("\tUnknown version.\n");
3646 for (dp
= head
+ 8; dp
< head
+ 8 + addr_size
* UNW_LENGTH (stamp
);)
3647 dp
= unw_decode (dp
, in_body
, & in_body
);
3652 slurp_ia64_unwind_table (file
, aux
, sec
)
3654 struct unw_aux_info
*aux
;
3655 Elf32_Internal_Shdr
*sec
;
3657 unsigned long size
, addr_size
, nrelas
, i
;
3658 Elf_Internal_Phdr
*prog_hdrs
, *seg
;
3659 struct unw_table_entry
*tep
;
3660 Elf32_Internal_Shdr
*relsec
;
3661 Elf_Internal_Rela
*rela
, *rp
;
3662 unsigned char *table
, *tp
;
3663 Elf_Internal_Sym
*sym
;
3664 const char *relname
;
3667 addr_size
= is_32bit_elf
? 4 : 8;
3669 /* First, find the starting address of the segment that includes
3672 if (elf_header
.e_phnum
)
3674 prog_hdrs
= (Elf_Internal_Phdr
*)
3675 xmalloc (elf_header
.e_phnum
* sizeof (Elf_Internal_Phdr
));
3678 result
= get_32bit_program_headers (file
, prog_hdrs
);
3680 result
= get_64bit_program_headers (file
, prog_hdrs
);
3688 for (seg
= prog_hdrs
; seg
< prog_hdrs
+ elf_header
.e_phnum
; ++seg
)
3690 if (seg
->p_type
!= PT_LOAD
)
3693 if (sec
->sh_addr
>= seg
->p_vaddr
3694 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
3696 aux
->seg_base
= seg
->p_vaddr
;
3704 /* Second, build the unwind table from the contents of the unwind section: */
3705 size
= sec
->sh_size
;
3706 table
= (char *) get_data (NULL
, file
, sec
->sh_offset
,
3707 size
, _("unwind table"));
3711 tep
= aux
->table
= xmalloc (size
/ (3 * addr_size
) * sizeof (aux
->table
[0]));
3712 for (tp
= table
; tp
< table
+ size
; tp
+= 3 * addr_size
, ++ tep
)
3714 tep
->start
.section
= SHN_UNDEF
;
3715 tep
->end
.section
= SHN_UNDEF
;
3716 tep
->info
.section
= SHN_UNDEF
;
3719 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
3720 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
3721 tep
->info
.offset
= byte_get ((unsigned char *) tp
+ 8, 4);
3725 tep
->start
.offset
= BYTE_GET8 ((unsigned char *) tp
+ 0);
3726 tep
->end
.offset
= BYTE_GET8 ((unsigned char *) tp
+ 8);
3727 tep
->info
.offset
= BYTE_GET8 ((unsigned char *) tp
+ 16);
3729 tep
->start
.offset
+= aux
->seg_base
;
3730 tep
->end
.offset
+= aux
->seg_base
;
3731 tep
->info
.offset
+= aux
->seg_base
;
3735 /* Third, apply any relocations to the unwind table: */
3737 for (relsec
= section_headers
;
3738 relsec
< section_headers
+ elf_header
.e_shnum
;
3741 if (relsec
->sh_type
!= SHT_RELA
3742 || SECTION_HEADER (relsec
->sh_info
) != sec
)
3745 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
3749 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
3753 relname
= elf_ia64_reloc_type (ELF32_R_TYPE (rp
->r_info
));
3754 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
3756 if (ELF32_ST_TYPE (sym
->st_info
) != STT_SECTION
)
3758 warn (_("Skipping unexpected symbol type %u\n"),
3759 ELF32_ST_TYPE (sym
->st_info
));
3765 relname
= elf_ia64_reloc_type (ELF64_R_TYPE (rp
->r_info
));
3766 sym
= aux
->symtab
+ ELF64_R_SYM (rp
->r_info
);
3768 if (ELF64_ST_TYPE (sym
->st_info
) != STT_SECTION
)
3770 warn (_("Skipping unexpected symbol type %u\n"),
3771 ELF64_ST_TYPE (sym
->st_info
));
3776 if (strncmp (relname
, "R_IA64_SEGREL", 13) != 0)
3778 warn (_("Skipping unexpected relocation type %s\n"), relname
);
3782 i
= rp
->r_offset
/ (3 * addr_size
);
3784 switch (rp
->r_offset
/addr_size
% 3)
3787 aux
->table
[i
].start
.section
= sym
->st_shndx
;
3788 aux
->table
[i
].start
.offset
+= rp
->r_addend
;
3791 aux
->table
[i
].end
.section
= sym
->st_shndx
;
3792 aux
->table
[i
].end
.offset
+= rp
->r_addend
;
3795 aux
->table
[i
].info
.section
= sym
->st_shndx
;
3796 aux
->table
[i
].info
.offset
+= rp
->r_addend
;
3806 aux
->table_len
= size
/ (3 * addr_size
);
3811 process_unwind (file
)
3814 Elf32_Internal_Shdr
*sec
, *unwsec
= NULL
, *strsec
;
3815 unsigned long i
, addr_size
, unwcount
= 0, unwstart
= 0;
3816 struct unw_aux_info aux
;
3821 if (elf_header
.e_machine
!= EM_IA_64
)
3823 printf (_("\nThere are no unwind sections in this file.\n"));
3827 memset (& aux
, 0, sizeof (aux
));
3829 addr_size
= is_32bit_elf
? 4 : 8;
3831 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
3833 if (sec
->sh_type
== SHT_SYMTAB
)
3835 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
3836 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
3838 strsec
= SECTION_HEADER (sec
->sh_link
);
3839 aux
.strtab_size
= strsec
->sh_size
;
3840 aux
.strtab
= (char *) get_data (NULL
, file
, strsec
->sh_offset
,
3841 aux
.strtab_size
, _("string table"));
3843 else if (sec
->sh_type
== SHT_IA_64_UNWIND
)
3848 printf (_("\nThere are no unwind sections in this file.\n"));
3850 while (unwcount
-- > 0)
3855 for (i
= unwstart
, sec
= section_headers
+ unwstart
;
3856 i
< elf_header
.e_shnum
; ++i
, ++sec
)
3857 if (sec
->sh_type
== SHT_IA_64_UNWIND
)
3864 len
= sizeof (ELF_STRING_ia64_unwind_once
) - 1;
3866 if (strncmp (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind_once
,
3869 /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO */
3870 len2
= sizeof (ELF_STRING_ia64_unwind_info_once
) - 1;
3871 suffix
= SECTION_NAME (unwsec
) + len
;
3872 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
3874 if (strncmp (SECTION_NAME (sec
),
3875 ELF_STRING_ia64_unwind_info_once
, len2
) == 0
3876 && strcmp (SECTION_NAME (sec
) + len2
, suffix
) == 0)
3881 /* .IA_64.unwindFOO -> .IA_64.unwind_infoFOO
3882 .IA_64.unwind or BAR -> .IA_64.unwind_info */
3883 len
= sizeof (ELF_STRING_ia64_unwind
) - 1;
3884 len2
= sizeof (ELF_STRING_ia64_unwind_info
) - 1;
3886 if (strncmp (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind
,
3888 suffix
= SECTION_NAME (unwsec
) + len
;
3889 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
3891 if (strncmp (SECTION_NAME (sec
),
3892 ELF_STRING_ia64_unwind_info
, len2
) == 0
3893 && strcmp (SECTION_NAME (sec
) + len2
, suffix
) == 0)
3897 if (i
== elf_header
.e_shnum
)
3899 printf (_("\nCould not find unwind info section for "));
3901 if (string_table
== NULL
)
3902 printf ("%d", unwsec
->sh_name
);
3904 printf ("'%s'", SECTION_NAME (unwsec
));
3908 aux
.info_size
= sec
->sh_size
;
3909 aux
.info_addr
= sec
->sh_addr
;
3910 aux
.info
= (char *) get_data (NULL
, file
, sec
->sh_offset
,
3911 aux
.info_size
, _("unwind info"));
3913 printf (_("\nUnwind section "));
3915 if (string_table
== NULL
)
3916 printf ("%d", unwsec
->sh_name
);
3918 printf ("'%s'", SECTION_NAME (unwsec
));
3920 printf (_(" at offset 0x%lx contains %lu entries:\n"),
3921 (unsigned long) unwsec
->sh_offset
,
3922 (unsigned long) (unwsec
->sh_size
/ (3 * addr_size
)));
3924 (void) slurp_ia64_unwind_table (file
, & aux
, unwsec
);
3926 if (aux
.table_len
> 0)
3927 dump_ia64_unwind (& aux
);
3930 free ((char *) aux
.table
);
3932 free ((char *) aux
.info
);
3941 free ((char *) aux
.strtab
);
3947 dynamic_segment_mips_val (entry
)
3948 Elf_Internal_Dyn
* entry
;
3950 switch (entry
->d_tag
)
3953 if (entry
->d_un
.d_val
== 0)
3957 static const char * opts
[] =
3959 "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT",
3960 "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS",
3961 "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD",
3962 "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF",
3967 for (cnt
= 0; cnt
< NUM_ELEM (opts
); ++ cnt
)
3968 if (entry
->d_un
.d_val
& (1 << cnt
))
3970 printf ("%s%s", first
? "" : " ", opts
[cnt
]);
3977 case DT_MIPS_IVERSION
:
3978 if (dynamic_strings
!= NULL
)
3979 printf ("Interface Version: %s\n",
3980 dynamic_strings
+ entry
->d_un
.d_val
);
3982 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
3985 case DT_MIPS_TIME_STAMP
:
3990 time_t time
= entry
->d_un
.d_val
;
3991 tmp
= gmtime (&time
);
3992 sprintf (timebuf
, "%04u-%02u-%02uT%02u:%02u:%02u",
3993 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
3994 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
3995 printf ("Time Stamp: %s\n", timebuf
);
3999 case DT_MIPS_RLD_VERSION
:
4000 case DT_MIPS_LOCAL_GOTNO
:
4001 case DT_MIPS_CONFLICTNO
:
4002 case DT_MIPS_LIBLISTNO
:
4003 case DT_MIPS_SYMTABNO
:
4004 case DT_MIPS_UNREFEXTNO
:
4005 case DT_MIPS_HIPAGENO
:
4006 case DT_MIPS_DELTA_CLASS_NO
:
4007 case DT_MIPS_DELTA_INSTANCE_NO
:
4008 case DT_MIPS_DELTA_RELOC_NO
:
4009 case DT_MIPS_DELTA_SYM_NO
:
4010 case DT_MIPS_DELTA_CLASSSYM_NO
:
4011 case DT_MIPS_COMPACT_SIZE
:
4012 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
4016 printf ("%#lx\n", (long) entry
->d_un
.d_ptr
);
4022 dynamic_segment_parisc_val (entry
)
4023 Elf_Internal_Dyn
* entry
;
4025 switch (entry
->d_tag
)
4027 case DT_HP_DLD_FLAGS
:
4036 { DT_HP_DEBUG_PRIVATE
, "HP_DEBUG_PRIVATE" },
4037 { DT_HP_DEBUG_CALLBACK
, "HP_DEBUG_CALLBACK" },
4038 { DT_HP_DEBUG_CALLBACK_BOR
, "HP_DEBUG_CALLBACK_BOR" },
4039 { DT_HP_NO_ENVVAR
, "HP_NO_ENVVAR" },
4040 { DT_HP_BIND_NOW
, "HP_BIND_NOW" },
4041 { DT_HP_BIND_NONFATAL
, "HP_BIND_NONFATAL" },
4042 { DT_HP_BIND_VERBOSE
, "HP_BIND_VERBOSE" },
4043 { DT_HP_BIND_RESTRICTED
, "HP_BIND_RESTRICTED" },
4044 { DT_HP_BIND_SYMBOLIC
, "HP_BIND_SYMBOLIC" },
4045 { DT_HP_RPATH_FIRST
, "HP_RPATH_FIRST" },
4046 { DT_HP_BIND_DEPTH_FIRST
, "HP_BIND_DEPTH_FIRST" }
4050 bfd_vma val
= entry
->d_un
.d_val
;
4052 for (cnt
= 0; cnt
< sizeof (flags
) / sizeof (flags
[0]); ++cnt
)
4053 if (val
& flags
[cnt
].bit
)
4057 fputs (flags
[cnt
].str
, stdout
);
4059 val
^= flags
[cnt
].bit
;
4062 if (val
!= 0 || first
)
4066 print_vma (val
, HEX
);
4072 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
4078 get_32bit_dynamic_segment (file
)
4081 Elf32_External_Dyn
* edyn
;
4082 Elf_Internal_Dyn
* entry
;
4085 edyn
= (Elf32_External_Dyn
*) get_data (NULL
, file
, dynamic_addr
,
4086 dynamic_size
, _("dynamic segment"));
4090 /* SGI's ELF has more than one section in the DYNAMIC segment. Determine
4091 how large this .dynamic is now. We can do this even before the byte
4092 swapping since the DT_NULL tag is recognizable. */
4094 while (*(Elf32_Word
*) edyn
[dynamic_size
++].d_tag
!= DT_NULL
)
4097 dynamic_segment
= (Elf_Internal_Dyn
*)
4098 malloc (dynamic_size
* sizeof (Elf_Internal_Dyn
));
4100 if (dynamic_segment
== NULL
)
4102 error (_("Out of memory\n"));
4107 for (i
= 0, entry
= dynamic_segment
;
4111 entry
->d_tag
= BYTE_GET (edyn
[i
].d_tag
);
4112 entry
->d_un
.d_val
= BYTE_GET (edyn
[i
].d_un
.d_val
);
4121 get_64bit_dynamic_segment (file
)
4124 Elf64_External_Dyn
* edyn
;
4125 Elf_Internal_Dyn
* entry
;
4128 edyn
= (Elf64_External_Dyn
*) get_data (NULL
, file
, dynamic_addr
,
4129 dynamic_size
, _("dynamic segment"));
4133 /* SGI's ELF has more than one section in the DYNAMIC segment. Determine
4134 how large this .dynamic is now. We can do this even before the byte
4135 swapping since the DT_NULL tag is recognizable. */
4137 while (*(bfd_vma
*) edyn
[dynamic_size
++].d_tag
!= DT_NULL
)
4140 dynamic_segment
= (Elf_Internal_Dyn
*)
4141 malloc (dynamic_size
* sizeof (Elf_Internal_Dyn
));
4143 if (dynamic_segment
== NULL
)
4145 error (_("Out of memory\n"));
4150 for (i
= 0, entry
= dynamic_segment
;
4154 entry
->d_tag
= BYTE_GET8 (edyn
[i
].d_tag
);
4155 entry
->d_un
.d_val
= BYTE_GET8 (edyn
[i
].d_un
.d_val
);
4164 get_dynamic_flags (flags
)
4167 static char buff
[64];
4172 flag
= flags
& - flags
;
4177 case DF_ORIGIN
: strcat (buff
, "ORIGIN "); break;
4178 case DF_SYMBOLIC
: strcat (buff
, "SYMBOLIC "); break;
4179 case DF_TEXTREL
: strcat (buff
, "TEXTREL "); break;
4180 case DF_BIND_NOW
: strcat (buff
, "BIND_NOW "); break;
4181 default: strcat (buff
, "unknown "); break;
4187 /* Parse and display the contents of the dynamic segment. */
4189 process_dynamic_segment (file
)
4192 Elf_Internal_Dyn
* entry
;
4195 if (dynamic_size
== 0)
4198 printf (_("\nThere is no dynamic segment in this file.\n"));
4205 if (! get_32bit_dynamic_segment (file
))
4208 else if (! get_64bit_dynamic_segment (file
))
4211 /* Find the appropriate symbol table. */
4212 if (dynamic_symbols
== NULL
)
4214 for (i
= 0, entry
= dynamic_segment
;
4218 Elf32_Internal_Shdr section
;
4220 if (entry
->d_tag
!= DT_SYMTAB
)
4223 dynamic_info
[DT_SYMTAB
] = entry
->d_un
.d_val
;
4225 /* Since we do not know how big the symbol table is,
4226 we default to reading in the entire file (!) and
4227 processing that. This is overkill, I know, but it
4229 section
.sh_offset
= entry
->d_un
.d_val
- loadaddr
;
4231 if (fseek (file
, 0, SEEK_END
))
4232 error (_("Unable to seek to end of file!"));
4234 section
.sh_size
= ftell (file
) - section
.sh_offset
;
4236 section
.sh_entsize
= sizeof (Elf32_External_Sym
);
4238 section
.sh_entsize
= sizeof (Elf64_External_Sym
);
4240 num_dynamic_syms
= section
.sh_size
/ section
.sh_entsize
;
4241 if (num_dynamic_syms
< 1)
4243 error (_("Unable to determine the number of symbols to load\n"));
4247 dynamic_symbols
= GET_ELF_SYMBOLS (file
, §ion
);
4251 /* Similarly find a string table. */
4252 if (dynamic_strings
== NULL
)
4254 for (i
= 0, entry
= dynamic_segment
;
4258 unsigned long offset
;
4261 if (entry
->d_tag
!= DT_STRTAB
)
4264 dynamic_info
[DT_STRTAB
] = entry
->d_un
.d_val
;
4266 /* Since we do not know how big the string table is,
4267 we default to reading in the entire file (!) and
4268 processing that. This is overkill, I know, but it
4271 offset
= entry
->d_un
.d_val
- loadaddr
;
4272 if (fseek (file
, 0, SEEK_END
))
4273 error (_("Unable to seek to end of file\n"));
4274 str_tab_len
= ftell (file
) - offset
;
4276 if (str_tab_len
< 1)
4279 (_("Unable to determine the length of the dynamic string table\n"));
4283 dynamic_strings
= (char *) get_data (NULL
, file
, offset
, str_tab_len
,
4284 _("dynamic string table"));
4289 /* And find the syminfo section if available. */
4290 if (dynamic_syminfo
== NULL
)
4292 unsigned int syminsz
= 0;
4294 for (i
= 0, entry
= dynamic_segment
;
4298 if (entry
->d_tag
== DT_SYMINENT
)
4300 /* Note: these braces are necessary to avoid a syntax
4301 error from the SunOS4 C compiler. */
4302 assert (sizeof (Elf_External_Syminfo
) == entry
->d_un
.d_val
);
4304 else if (entry
->d_tag
== DT_SYMINSZ
)
4305 syminsz
= entry
->d_un
.d_val
;
4306 else if (entry
->d_tag
== DT_SYMINFO
)
4307 dynamic_syminfo_offset
= entry
->d_un
.d_val
- loadaddr
;
4310 if (dynamic_syminfo_offset
!= 0 && syminsz
!= 0)
4312 Elf_External_Syminfo
* extsyminfo
;
4313 Elf_Internal_Syminfo
* syminfo
;
4315 /* There is a syminfo section. Read the data. */
4316 extsyminfo
= ((Elf_External_Syminfo
*)
4317 get_data (NULL
, file
, dynamic_syminfo_offset
,
4318 syminsz
, _("symbol information")));
4322 dynamic_syminfo
= (Elf_Internal_Syminfo
*) malloc (syminsz
);
4323 if (dynamic_syminfo
== NULL
)
4325 error (_("Out of memory\n"));
4329 dynamic_syminfo_nent
= syminsz
/ sizeof (Elf_External_Syminfo
);
4330 for (i
= 0, syminfo
= dynamic_syminfo
; i
< dynamic_syminfo_nent
;
4333 syminfo
->si_boundto
= BYTE_GET (extsyminfo
[i
].si_boundto
);
4334 syminfo
->si_flags
= BYTE_GET (extsyminfo
[i
].si_flags
);
4341 if (do_dynamic
&& dynamic_addr
)
4342 printf (_("\nDynamic segment at offset 0x%x contains %ld entries:\n"),
4343 dynamic_addr
, (long) dynamic_size
);
4345 printf (_(" Tag Type Name/Value\n"));
4347 for (i
= 0, entry
= dynamic_segment
;
4356 print_vma (entry
->d_tag
, FULL_HEX
);
4357 dtype
= get_dynamic_type (entry
->d_tag
);
4358 printf (" (%s)%*s", dtype
,
4359 ((is_32bit_elf
? 27 : 19)
4360 - (int) strlen (dtype
)),
4364 switch (entry
->d_tag
)
4368 printf ("%s", get_dynamic_flags (entry
->d_un
.d_val
));
4378 switch (entry
->d_tag
)
4381 printf (_("Auxiliary library"));
4385 printf (_("Filter library"));
4389 printf (_("Configuration file"));
4393 printf (_("Dependency audit library"));
4397 printf (_("Audit library"));
4401 if (dynamic_strings
)
4402 printf (": [%s]\n", dynamic_strings
+ entry
->d_un
.d_val
);
4406 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4415 printf (_("Flags:"));
4416 if (entry
->d_un
.d_val
== 0)
4417 printf (_(" None\n"));
4420 unsigned long int val
= entry
->d_un
.d_val
;
4421 if (val
& DTF_1_PARINIT
)
4423 printf (" PARINIT");
4424 val
^= DTF_1_PARINIT
;
4426 if (val
& DTF_1_CONFEXP
)
4428 printf (" CONFEXP");
4429 val
^= DTF_1_CONFEXP
;
4432 printf (" %lx", val
);
4441 printf (_("Flags:"));
4442 if (entry
->d_un
.d_val
== 0)
4443 printf (_(" None\n"));
4446 unsigned long int val
= entry
->d_un
.d_val
;
4447 if (val
& DF_P1_LAZYLOAD
)
4449 printf (" LAZYLOAD");
4450 val
^= DF_P1_LAZYLOAD
;
4452 if (val
& DF_P1_GROUPPERM
)
4454 printf (" GROUPPERM");
4455 val
^= DF_P1_GROUPPERM
;
4458 printf (" %lx", val
);
4467 printf (_("Flags:"));
4468 if (entry
->d_un
.d_val
== 0)
4469 printf (_(" None\n"));
4472 unsigned long int val
= entry
->d_un
.d_val
;
4478 if (val
& DF_1_GLOBAL
)
4483 if (val
& DF_1_GROUP
)
4488 if (val
& DF_1_NODELETE
)
4490 printf (" NODELETE");
4491 val
^= DF_1_NODELETE
;
4493 if (val
& DF_1_LOADFLTR
)
4495 printf (" LOADFLTR");
4496 val
^= DF_1_LOADFLTR
;
4498 if (val
& DF_1_INITFIRST
)
4500 printf (" INITFIRST");
4501 val
^= DF_1_INITFIRST
;
4503 if (val
& DF_1_NOOPEN
)
4508 if (val
& DF_1_ORIGIN
)
4513 if (val
& DF_1_DIRECT
)
4518 if (val
& DF_1_TRANS
)
4523 if (val
& DF_1_INTERPOSE
)
4525 printf (" INTERPOSE");
4526 val
^= DF_1_INTERPOSE
;
4528 if (val
& DF_1_NODEFLIB
)
4530 printf (" NODEFLIB");
4531 val
^= DF_1_NODEFLIB
;
4533 if (val
& DF_1_NODUMP
)
4538 if (val
& DF_1_CONLFAT
)
4540 printf (" CONLFAT");
4541 val
^= DF_1_CONLFAT
;
4544 printf (" %lx", val
);
4552 puts (get_dynamic_type (entry
->d_un
.d_val
));
4572 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
4578 if (dynamic_strings
== NULL
)
4581 name
= dynamic_strings
+ entry
->d_un
.d_val
;
4585 switch (entry
->d_tag
)
4588 printf (_("Shared library: [%s]"), name
);
4590 if (strcmp (name
, program_interpreter
) == 0)
4591 printf (_(" program interpreter"));
4595 printf (_("Library soname: [%s]"), name
);
4599 printf (_("Library rpath: [%s]"), name
);
4603 printf (_("Library runpath: [%s]"), name
);
4607 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4612 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4628 case DT_INIT_ARRAYSZ
:
4629 case DT_FINI_ARRAYSZ
:
4632 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
4633 printf (" (bytes)\n");
4643 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
4656 if (dynamic_strings
!= NULL
&& entry
->d_tag
== DT_USED
)
4660 name
= dynamic_strings
+ entry
->d_un
.d_val
;
4664 printf (_("Not needed object: [%s]\n"), name
);
4669 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4675 /* The value of this entry is ignored. */
4679 if ((entry
->d_tag
>= DT_VERSYM
) && (entry
->d_tag
<= DT_VERNEEDNUM
))
4680 version_info
[DT_VERSIONTAGIDX (entry
->d_tag
)] =
4685 switch (elf_header
.e_machine
)
4688 case EM_MIPS_RS3_LE
:
4689 dynamic_segment_mips_val (entry
);
4692 dynamic_segment_parisc_val (entry
);
4695 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
4707 get_ver_flags (flags
)
4710 static char buff
[32];
4717 if (flags
& VER_FLG_BASE
)
4718 strcat (buff
, "BASE ");
4720 if (flags
& VER_FLG_WEAK
)
4722 if (flags
& VER_FLG_BASE
)
4723 strcat (buff
, "| ");
4725 strcat (buff
, "WEAK ");
4728 if (flags
& ~(VER_FLG_BASE
| VER_FLG_WEAK
))
4729 strcat (buff
, "| <unknown>");
4734 /* Display the contents of the version sections. */
4736 process_version_sections (file
)
4739 Elf32_Internal_Shdr
* section
;
4746 for (i
= 0, section
= section_headers
;
4747 i
< elf_header
.e_shnum
;
4750 switch (section
->sh_type
)
4752 case SHT_GNU_verdef
:
4754 Elf_External_Verdef
* edefs
;
4761 (_("\nVersion definition section '%s' contains %ld entries:\n"),
4762 SECTION_NAME (section
), section
->sh_info
);
4764 printf (_(" Addr: 0x"));
4765 printf_vma (section
->sh_addr
);
4766 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
4767 (unsigned long) section
->sh_offset
, section
->sh_link
,
4768 SECTION_NAME (SECTION_HEADER (section
->sh_link
)));
4770 edefs
= ((Elf_External_Verdef
*)
4771 get_data (NULL
, file
, section
->sh_offset
,
4773 _("version definition section")));
4777 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++ cnt
)
4780 Elf_External_Verdef
* edef
;
4781 Elf_Internal_Verdef ent
;
4782 Elf_External_Verdaux
* eaux
;
4783 Elf_Internal_Verdaux aux
;
4787 vstart
= ((char *) edefs
) + idx
;
4789 edef
= (Elf_External_Verdef
*) vstart
;
4791 ent
.vd_version
= BYTE_GET (edef
->vd_version
);
4792 ent
.vd_flags
= BYTE_GET (edef
->vd_flags
);
4793 ent
.vd_ndx
= BYTE_GET (edef
->vd_ndx
);
4794 ent
.vd_cnt
= BYTE_GET (edef
->vd_cnt
);
4795 ent
.vd_hash
= BYTE_GET (edef
->vd_hash
);
4796 ent
.vd_aux
= BYTE_GET (edef
->vd_aux
);
4797 ent
.vd_next
= BYTE_GET (edef
->vd_next
);
4799 printf (_(" %#06x: Rev: %d Flags: %s"),
4800 idx
, ent
.vd_version
, get_ver_flags (ent
.vd_flags
));
4802 printf (_(" Index: %d Cnt: %d "),
4803 ent
.vd_ndx
, ent
.vd_cnt
);
4805 vstart
+= ent
.vd_aux
;
4807 eaux
= (Elf_External_Verdaux
*) vstart
;
4809 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
4810 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
4812 if (dynamic_strings
)
4813 printf (_("Name: %s\n"), dynamic_strings
+ aux
.vda_name
);
4815 printf (_("Name index: %ld\n"), aux
.vda_name
);
4817 isum
= idx
+ ent
.vd_aux
;
4819 for (j
= 1; j
< ent
.vd_cnt
; j
++)
4821 isum
+= aux
.vda_next
;
4822 vstart
+= aux
.vda_next
;
4824 eaux
= (Elf_External_Verdaux
*) vstart
;
4826 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
4827 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
4829 if (dynamic_strings
)
4830 printf (_(" %#06x: Parent %d: %s\n"),
4831 isum
, j
, dynamic_strings
+ aux
.vda_name
);
4833 printf (_(" %#06x: Parent %d, name index: %ld\n"),
4834 isum
, j
, aux
.vda_name
);
4844 case SHT_GNU_verneed
:
4846 Elf_External_Verneed
* eneed
;
4852 printf (_("\nVersion needs section '%s' contains %ld entries:\n"),
4853 SECTION_NAME (section
), section
->sh_info
);
4855 printf (_(" Addr: 0x"));
4856 printf_vma (section
->sh_addr
);
4857 printf (_(" Offset: %#08lx Link to section: %ld (%s)\n"),
4858 (unsigned long) section
->sh_offset
, section
->sh_link
,
4859 SECTION_NAME (SECTION_HEADER (section
->sh_link
)));
4861 eneed
= ((Elf_External_Verneed
*)
4862 get_data (NULL
, file
, section
->sh_offset
,
4863 section
->sh_size
, _("version need section")));
4867 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
4869 Elf_External_Verneed
* entry
;
4870 Elf_Internal_Verneed ent
;
4875 vstart
= ((char *) eneed
) + idx
;
4877 entry
= (Elf_External_Verneed
*) vstart
;
4879 ent
.vn_version
= BYTE_GET (entry
->vn_version
);
4880 ent
.vn_cnt
= BYTE_GET (entry
->vn_cnt
);
4881 ent
.vn_file
= BYTE_GET (entry
->vn_file
);
4882 ent
.vn_aux
= BYTE_GET (entry
->vn_aux
);
4883 ent
.vn_next
= BYTE_GET (entry
->vn_next
);
4885 printf (_(" %#06x: Version: %d"), idx
, ent
.vn_version
);
4887 if (dynamic_strings
)
4888 printf (_(" File: %s"), dynamic_strings
+ ent
.vn_file
);
4890 printf (_(" File: %lx"), ent
.vn_file
);
4892 printf (_(" Cnt: %d\n"), ent
.vn_cnt
);
4894 vstart
+= ent
.vn_aux
;
4896 for (j
= 0, isum
= idx
+ ent
.vn_aux
; j
< ent
.vn_cnt
; ++j
)
4898 Elf_External_Vernaux
* eaux
;
4899 Elf_Internal_Vernaux aux
;
4901 eaux
= (Elf_External_Vernaux
*) vstart
;
4903 aux
.vna_hash
= BYTE_GET (eaux
->vna_hash
);
4904 aux
.vna_flags
= BYTE_GET (eaux
->vna_flags
);
4905 aux
.vna_other
= BYTE_GET (eaux
->vna_other
);
4906 aux
.vna_name
= BYTE_GET (eaux
->vna_name
);
4907 aux
.vna_next
= BYTE_GET (eaux
->vna_next
);
4909 if (dynamic_strings
)
4910 printf (_(" %#06x: Name: %s"),
4911 isum
, dynamic_strings
+ aux
.vna_name
);
4913 printf (_(" %#06x: Name index: %lx"),
4914 isum
, aux
.vna_name
);
4916 printf (_(" Flags: %s Version: %d\n"),
4917 get_ver_flags (aux
.vna_flags
), aux
.vna_other
);
4919 isum
+= aux
.vna_next
;
4920 vstart
+= aux
.vna_next
;
4930 case SHT_GNU_versym
:
4932 Elf32_Internal_Shdr
* link_section
;
4935 unsigned char * edata
;
4936 unsigned short * data
;
4938 Elf_Internal_Sym
* symbols
;
4939 Elf32_Internal_Shdr
* string_sec
;
4941 link_section
= SECTION_HEADER (section
->sh_link
);
4942 total
= section
->sh_size
/ section
->sh_entsize
;
4946 symbols
= GET_ELF_SYMBOLS (file
, link_section
);
4948 string_sec
= SECTION_HEADER (link_section
->sh_link
);
4950 strtab
= (char *) get_data (NULL
, file
, string_sec
->sh_offset
,
4951 string_sec
->sh_size
,
4952 _("version string table"));
4956 printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
4957 SECTION_NAME (section
), total
);
4959 printf (_(" Addr: "));
4960 printf_vma (section
->sh_addr
);
4961 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
4962 (unsigned long) section
->sh_offset
, section
->sh_link
,
4963 SECTION_NAME (link_section
));
4967 get_data (NULL
, file
,
4968 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] - loadaddr
,
4969 total
* sizeof (short), _("version symbol data")));
4976 data
= (unsigned short *) malloc (total
* sizeof (short));
4978 for (cnt
= total
; cnt
--;)
4979 data
[cnt
] = byte_get (edata
+ cnt
* sizeof (short),
4984 for (cnt
= 0; cnt
< total
; cnt
+= 4)
4987 int check_def
, check_need
;
4990 printf (" %03x:", cnt
);
4992 for (j
= 0; (j
< 4) && (cnt
+ j
) < total
; ++j
)
4993 switch (data
[cnt
+ j
])
4996 fputs (_(" 0 (*local*) "), stdout
);
5000 fputs (_(" 1 (*global*) "), stdout
);
5004 nn
= printf ("%4x%c", data
[cnt
+ j
] & 0x7fff,
5005 data
[cnt
+ j
] & 0x8000 ? 'h' : ' ');
5009 if (SECTION_HEADER (symbols
[cnt
+ j
].st_shndx
)->sh_type
5012 if (symbols
[cnt
+ j
].st_shndx
== SHN_UNDEF
)
5019 && version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)])
5021 Elf_Internal_Verneed ivn
;
5022 unsigned long offset
;
5024 offset
= version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
5029 Elf_Internal_Vernaux ivna
;
5030 Elf_External_Verneed evn
;
5031 Elf_External_Vernaux evna
;
5032 unsigned long a_off
;
5034 get_data (&evn
, file
, offset
, sizeof (evn
),
5037 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
5038 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
5040 a_off
= offset
+ ivn
.vn_aux
;
5044 get_data (&evna
, file
, a_off
, sizeof (evna
),
5045 _("version need aux (2)"));
5047 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
5048 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
5050 a_off
+= ivna
.vna_next
;
5052 while (ivna
.vna_other
!= data
[cnt
+ j
]
5053 && ivna
.vna_next
!= 0);
5055 if (ivna
.vna_other
== data
[cnt
+ j
])
5057 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
5059 name
= strtab
+ ivna
.vna_name
;
5060 nn
+= printf ("(%s%-*s",
5062 12 - (int) strlen (name
),
5068 offset
+= ivn
.vn_next
;
5070 while (ivn
.vn_next
);
5073 if (check_def
&& data
[cnt
+ j
] != 0x8001
5074 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
5076 Elf_Internal_Verdef ivd
;
5077 Elf_External_Verdef evd
;
5078 unsigned long offset
;
5080 offset
= version_info
5081 [DT_VERSIONTAGIDX (DT_VERDEF
)] - loadaddr
;
5085 get_data (&evd
, file
, offset
, sizeof (evd
),
5088 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
5089 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
5091 offset
+= ivd
.vd_next
;
5093 while (ivd
.vd_ndx
!= (data
[cnt
+ j
] & 0x7fff)
5094 && ivd
.vd_next
!= 0);
5096 if (ivd
.vd_ndx
== (data
[cnt
+ j
] & 0x7fff))
5098 Elf_External_Verdaux evda
;
5099 Elf_Internal_Verdaux ivda
;
5101 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
5103 get_data (&evda
, file
,
5104 offset
- ivd
.vd_next
+ ivd
.vd_aux
,
5105 sizeof (evda
), _("version def aux"));
5107 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
5109 name
= strtab
+ ivda
.vda_name
;
5110 nn
+= printf ("(%s%-*s",
5112 12 - (int) strlen (name
),
5118 printf ("%*c", 18 - nn
, ' ');
5136 printf (_("\nNo version information found in this file.\n"));
5142 get_symbol_binding (binding
)
5143 unsigned int binding
;
5145 static char buff
[32];
5149 case STB_LOCAL
: return "LOCAL";
5150 case STB_GLOBAL
: return "GLOBAL";
5151 case STB_WEAK
: return "WEAK";
5153 if (binding
>= STB_LOPROC
&& binding
<= STB_HIPROC
)
5154 sprintf (buff
, _("<processor specific>: %d"), binding
);
5155 else if (binding
>= STB_LOOS
&& binding
<= STB_HIOS
)
5156 sprintf (buff
, _("<OS specific>: %d"), binding
);
5158 sprintf (buff
, _("<unknown>: %d"), binding
);
5164 get_symbol_type (type
)
5167 static char buff
[32];
5171 case STT_NOTYPE
: return "NOTYPE";
5172 case STT_OBJECT
: return "OBJECT";
5173 case STT_FUNC
: return "FUNC";
5174 case STT_SECTION
: return "SECTION";
5175 case STT_FILE
: return "FILE";
5176 case STT_COMMON
: return "COMMON";
5178 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
5180 if (elf_header
.e_machine
== EM_ARM
&& type
== STT_ARM_TFUNC
)
5181 return "THUMB_FUNC";
5183 if (elf_header
.e_machine
== EM_SPARCV9
&& type
== STT_REGISTER
)
5186 if (elf_header
.e_machine
== EM_PARISC
&& type
== STT_PARISC_MILLI
)
5187 return "PARISC_MILLI";
5189 sprintf (buff
, _("<processor specific>: %d"), type
);
5191 else if (type
>= STT_LOOS
&& type
<= STT_HIOS
)
5193 if (elf_header
.e_machine
== EM_PARISC
)
5195 if (type
== STT_HP_OPAQUE
)
5197 if (type
== STT_HP_STUB
)
5201 sprintf (buff
, _("<OS specific>: %d"), type
);
5204 sprintf (buff
, _("<unknown>: %d"), type
);
5210 get_symbol_visibility (visibility
)
5211 unsigned int visibility
;
5215 case STV_DEFAULT
: return "DEFAULT";
5216 case STV_INTERNAL
: return "INTERNAL";
5217 case STV_HIDDEN
: return "HIDDEN";
5218 case STV_PROTECTED
: return "PROTECTED";
5224 get_symbol_index_type (type
)
5229 case SHN_UNDEF
: return "UND";
5230 case SHN_ABS
: return "ABS";
5231 case SHN_COMMON
: return "COM";
5233 if (type
>= SHN_LOPROC
&& type
<= SHN_HIPROC
)
5235 else if (type
>= SHN_LOOS
&& type
<= SHN_HIOS
)
5237 else if (type
>= SHN_LORESERVE
&& type
<= SHN_HIRESERVE
)
5241 static char buff
[32];
5243 sprintf (buff
, "%3d", type
);
5250 get_dynamic_data (file
, number
)
5252 unsigned int number
;
5254 unsigned char * e_data
;
5257 e_data
= (unsigned char *) malloc (number
* 4);
5261 error (_("Out of memory\n"));
5265 if (fread (e_data
, 4, number
, file
) != number
)
5267 error (_("Unable to read in dynamic data\n"));
5271 i_data
= (int *) malloc (number
* sizeof (* i_data
));
5275 error (_("Out of memory\n"));
5281 i_data
[number
] = byte_get (e_data
+ number
* 4, 4);
5288 /* Dump the symbol table. */
5290 process_symbol_table (file
)
5293 Elf32_Internal_Shdr
* section
;
5294 unsigned char nb
[4];
5295 unsigned char nc
[4];
5298 int * buckets
= NULL
;
5299 int * chains
= NULL
;
5301 if (! do_syms
&& !do_histogram
)
5304 if (dynamic_info
[DT_HASH
] && ((do_using_dynamic
&& dynamic_strings
!= NULL
)
5307 if (fseek (file
, dynamic_info
[DT_HASH
] - loadaddr
, SEEK_SET
))
5309 error (_("Unable to seek to start of dynamic information"));
5313 if (fread (nb
, sizeof (nb
), 1, file
) != 1)
5315 error (_("Failed to read in number of buckets\n"));
5319 if (fread (nc
, sizeof (nc
), 1, file
) != 1)
5321 error (_("Failed to read in number of chains\n"));
5325 nbuckets
= byte_get (nb
, 4);
5326 nchains
= byte_get (nc
, 4);
5328 buckets
= get_dynamic_data (file
, nbuckets
);
5329 chains
= get_dynamic_data (file
, nchains
);
5331 if (buckets
== NULL
|| chains
== NULL
)
5336 && dynamic_info
[DT_HASH
] && do_using_dynamic
&& dynamic_strings
!= NULL
)
5341 printf (_("\nSymbol table for image:\n"));
5343 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
5345 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
5347 for (hn
= 0; hn
< nbuckets
; hn
++)
5352 for (si
= buckets
[hn
]; si
< nchains
&& si
> 0; si
= chains
[si
])
5354 Elf_Internal_Sym
* psym
;
5356 psym
= dynamic_symbols
+ si
;
5358 printf (" %3d %3d: ", si
, hn
);
5359 print_vma (psym
->st_value
, LONG_HEX
);
5361 print_vma (psym
->st_size
, DEC_5
);
5363 printf (" %6s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
5364 printf (" %6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
5365 printf (" %3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
5366 printf (" %3.3s ", get_symbol_index_type (psym
->st_shndx
));
5367 print_symbol (25, dynamic_strings
+ psym
->st_name
);
5372 else if (do_syms
&& !do_using_dynamic
)
5376 for (i
= 0, section
= section_headers
;
5377 i
< elf_header
.e_shnum
;
5382 Elf_Internal_Sym
* symtab
;
5383 Elf_Internal_Sym
* psym
;
5386 if ( section
->sh_type
!= SHT_SYMTAB
5387 && section
->sh_type
!= SHT_DYNSYM
)
5390 printf (_("\nSymbol table '%s' contains %lu entries:\n"),
5391 SECTION_NAME (section
),
5392 (unsigned long) (section
->sh_size
/ section
->sh_entsize
));
5394 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
5396 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
5398 symtab
= GET_ELF_SYMBOLS (file
, section
);
5402 if (section
->sh_link
== elf_header
.e_shstrndx
)
5403 strtab
= string_table
;
5406 Elf32_Internal_Shdr
* string_sec
;
5408 string_sec
= SECTION_HEADER (section
->sh_link
);
5410 strtab
= (char *) get_data (NULL
, file
, string_sec
->sh_offset
,
5411 string_sec
->sh_size
,
5415 for (si
= 0, psym
= symtab
;
5416 si
< section
->sh_size
/ section
->sh_entsize
;
5419 printf ("%6d: ", si
);
5420 print_vma (psym
->st_value
, LONG_HEX
);
5422 print_vma (psym
->st_size
, DEC_5
);
5423 printf (" %-7s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
5424 printf (" %-6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
5425 printf (" %-3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
5426 printf (" %4s ", get_symbol_index_type (psym
->st_shndx
));
5427 print_symbol (25, strtab
+ psym
->st_name
);
5429 if (section
->sh_type
== SHT_DYNSYM
&&
5430 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] != 0)
5432 unsigned char data
[2];
5433 unsigned short vers_data
;
5434 unsigned long offset
;
5438 offset
= version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)]
5441 get_data (&data
, file
, offset
+ si
* sizeof (vers_data
),
5442 sizeof (data
), _("version data"));
5444 vers_data
= byte_get (data
, 2);
5446 is_nobits
= (SECTION_HEADER (psym
->st_shndx
)->sh_type
5449 check_def
= (psym
->st_shndx
!= SHN_UNDEF
);
5451 if ((vers_data
& 0x8000) || vers_data
> 1)
5453 if (version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
5454 && (is_nobits
|| ! check_def
))
5456 Elf_External_Verneed evn
;
5457 Elf_Internal_Verneed ivn
;
5458 Elf_Internal_Vernaux ivna
;
5460 /* We must test both. */
5461 offset
= version_info
5462 [DT_VERSIONTAGIDX (DT_VERNEED
)] - loadaddr
;
5466 unsigned long vna_off
;
5468 get_data (&evn
, file
, offset
, sizeof (evn
),
5471 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
5472 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
5474 vna_off
= offset
+ ivn
.vn_aux
;
5478 Elf_External_Vernaux evna
;
5480 get_data (&evna
, file
, vna_off
,
5482 _("version need aux (3)"));
5484 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
5485 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
5486 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
5488 vna_off
+= ivna
.vna_next
;
5490 while (ivna
.vna_other
!= vers_data
5491 && ivna
.vna_next
!= 0);
5493 if (ivna
.vna_other
== vers_data
)
5496 offset
+= ivn
.vn_next
;
5498 while (ivn
.vn_next
!= 0);
5500 if (ivna
.vna_other
== vers_data
)
5503 strtab
+ ivna
.vna_name
, ivna
.vna_other
);
5506 else if (! is_nobits
)
5507 error (_("bad dynamic symbol"));
5514 if (vers_data
!= 0x8001
5515 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
5517 Elf_Internal_Verdef ivd
;
5518 Elf_Internal_Verdaux ivda
;
5519 Elf_External_Verdaux evda
;
5520 unsigned long offset
;
5523 version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)]
5528 Elf_External_Verdef evd
;
5530 get_data (&evd
, file
, offset
, sizeof (evd
),
5533 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
5534 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
5535 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
5537 offset
+= ivd
.vd_next
;
5539 while (ivd
.vd_ndx
!= (vers_data
& 0x7fff)
5540 && ivd
.vd_next
!= 0);
5542 offset
-= ivd
.vd_next
;
5543 offset
+= ivd
.vd_aux
;
5545 get_data (&evda
, file
, offset
, sizeof (evda
),
5546 _("version def aux"));
5548 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
5550 if (psym
->st_name
!= ivda
.vda_name
)
5551 printf ((vers_data
& 0x8000)
5553 strtab
+ ivda
.vda_name
);
5563 if (strtab
!= string_table
)
5569 (_("\nDynamic symbol information is not available for displaying symbols.\n"));
5571 if (do_histogram
&& buckets
!= NULL
)
5578 int nzero_counts
= 0;
5581 printf (_("\nHistogram for bucket list length (total of %d buckets):\n"),
5583 printf (_(" Length Number %% of total Coverage\n"));
5585 lengths
= (int *) calloc (nbuckets
, sizeof (int));
5586 if (lengths
== NULL
)
5588 error (_("Out of memory"));
5591 for (hn
= 0; hn
< nbuckets
; ++hn
)
5596 for (si
= buckets
[hn
]; si
> 0 && si
< nchains
; si
= chains
[si
])
5599 if (maxlength
< ++lengths
[hn
])
5604 counts
= (int *) calloc (maxlength
+ 1, sizeof (int));
5607 error (_("Out of memory"));
5611 for (hn
= 0; hn
< nbuckets
; ++hn
)
5612 ++ counts
[lengths
[hn
]];
5616 printf (" 0 %-10d (%5.1f%%)\n",
5617 counts
[0], (counts
[0] * 100.0) / nbuckets
);
5618 for (si
= 1; si
<= maxlength
; ++si
)
5620 nzero_counts
+= counts
[si
] * si
;
5621 printf ("%7d %-10d (%5.1f%%) %5.1f%%\n",
5622 si
, counts
[si
], (counts
[si
] * 100.0) / nbuckets
,
5623 (nzero_counts
* 100.0) / nsyms
);
5631 if (buckets
!= NULL
)
5641 process_syminfo (file
)
5642 FILE * file ATTRIBUTE_UNUSED
;
5646 if (dynamic_syminfo
== NULL
5648 /* No syminfo, this is ok. */
5651 /* There better should be a dynamic symbol section. */
5652 if (dynamic_symbols
== NULL
|| dynamic_strings
== NULL
)
5656 printf (_("\nDynamic info segment at offset 0x%lx contains %d entries:\n"),
5657 dynamic_syminfo_offset
, dynamic_syminfo_nent
);
5659 printf (_(" Num: Name BoundTo Flags\n"));
5660 for (i
= 0; i
< dynamic_syminfo_nent
; ++i
)
5662 unsigned short int flags
= dynamic_syminfo
[i
].si_flags
;
5664 printf ("%4d: ", i
);
5665 print_symbol (30, dynamic_strings
+ dynamic_symbols
[i
].st_name
);
5668 switch (dynamic_syminfo
[i
].si_boundto
)
5670 case SYMINFO_BT_SELF
:
5671 fputs ("SELF ", stdout
);
5673 case SYMINFO_BT_PARENT
:
5674 fputs ("PARENT ", stdout
);
5677 if (dynamic_syminfo
[i
].si_boundto
> 0
5678 && dynamic_syminfo
[i
].si_boundto
< dynamic_size
)
5680 print_symbol (10, dynamic_strings
5682 [dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
);
5686 printf ("%-10d ", dynamic_syminfo
[i
].si_boundto
);
5690 if (flags
& SYMINFO_FLG_DIRECT
)
5692 if (flags
& SYMINFO_FLG_PASSTHRU
)
5693 printf (" PASSTHRU");
5694 if (flags
& SYMINFO_FLG_COPY
)
5696 if (flags
& SYMINFO_FLG_LAZYLOAD
)
5697 printf (" LAZYLOAD");
5705 #ifdef SUPPORT_DISASSEMBLY
5707 disassemble_section (section
, file
)
5708 Elf32_Internal_Shdr
* section
;
5711 printf (_("\nAssembly dump of section %s\n"),
5712 SECTION_NAME (section
));
5714 /* XXX -- to be done --- XXX */
5721 dump_section (section
, file
)
5722 Elf32_Internal_Shdr
* section
;
5725 bfd_size_type bytes
;
5727 unsigned char * data
;
5728 unsigned char * start
;
5730 bytes
= section
->sh_size
;
5734 printf (_("\nSection '%s' has no data to dump.\n"),
5735 SECTION_NAME (section
));
5739 printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section
));
5741 addr
= section
->sh_addr
;
5743 start
= (unsigned char *) get_data (NULL
, file
, section
->sh_offset
, bytes
,
5756 lbytes
= (bytes
> 16 ? 16 : bytes
);
5758 printf (" 0x%8.8lx ", (unsigned long) addr
);
5760 switch (elf_header
.e_ident
[EI_DATA
])
5764 for (j
= 15; j
>= 0; j
--)
5767 printf ("%2.2x", data
[j
]);
5777 for (j
= 0; j
< 16; j
++)
5780 printf ("%2.2x", data
[j
]);
5790 for (j
= 0; j
< lbytes
; j
++)
5793 if (k
>= ' ' && k
< 0x80)
5812 static unsigned long int
5813 read_leb128 (data
, length_return
, sign
)
5814 unsigned char * data
;
5815 int * length_return
;
5818 unsigned long int result
= 0;
5819 unsigned int num_read
= 0;
5828 result
|= (byte
& 0x7f) << shift
;
5833 while (byte
& 0x80);
5835 if (length_return
!= NULL
)
5836 * length_return
= num_read
;
5838 if (sign
&& (shift
< 32) && (byte
& 0x40))
5839 result
|= -1 << shift
;
5844 typedef struct State_Machine_Registers
5846 unsigned long address
;
5849 unsigned int column
;
5853 /* This variable hold the number of the last entry seen
5854 in the File Table. */
5855 unsigned int last_file_entry
;
5858 static SMR state_machine_regs
;
5861 reset_state_machine (is_stmt
)
5864 state_machine_regs
.address
= 0;
5865 state_machine_regs
.file
= 1;
5866 state_machine_regs
.line
= 1;
5867 state_machine_regs
.column
= 0;
5868 state_machine_regs
.is_stmt
= is_stmt
;
5869 state_machine_regs
.basic_block
= 0;
5870 state_machine_regs
.end_sequence
= 0;
5871 state_machine_regs
.last_file_entry
= 0;
5874 /* Handled an extend line op. Returns true if this is the end
5877 process_extended_line_op (data
, is_stmt
, pointer_size
)
5878 unsigned char * data
;
5882 unsigned char op_code
;
5885 unsigned char * name
;
5888 len
= read_leb128 (data
, & bytes_read
, 0);
5893 warn (_("badly formed extended line op encountered!\n"));
5898 op_code
= * data
++;
5900 printf (_(" Extended opcode %d: "), op_code
);
5904 case DW_LNE_end_sequence
:
5905 printf (_("End of Sequence\n\n"));
5906 reset_state_machine (is_stmt
);
5909 case DW_LNE_set_address
:
5910 adr
= byte_get (data
, pointer_size
);
5911 printf (_("set Address to 0x%lx\n"), adr
);
5912 state_machine_regs
.address
= adr
;
5915 case DW_LNE_define_file
:
5916 printf (_(" define new File Table entry\n"));
5917 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
5919 printf (_(" %d\t"), ++ state_machine_regs
.last_file_entry
);
5921 data
+= strlen ((char *) data
) + 1;
5922 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
5924 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
5926 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
5927 printf (_("%s\n\n"), name
);
5931 printf (_("UNKNOWN: length %d\n"), len
- bytes_read
);
5938 /* Size of pointers in the .debug_line section. This information is not
5939 really present in that section. It's obtained before dumping the debug
5940 sections by doing some pre-scan of the .debug_info section. */
5941 static int debug_line_pointer_size
= 4;
5944 display_debug_lines (section
, start
, file
)
5945 Elf32_Internal_Shdr
* section
;
5946 unsigned char * start
;
5947 FILE * file ATTRIBUTE_UNUSED
;
5949 DWARF2_External_LineInfo
* external
;
5950 DWARF2_Internal_LineInfo info
;
5951 unsigned char * standard_opcodes
;
5952 unsigned char * data
= start
;
5953 unsigned char * end
= start
+ section
->sh_size
;
5954 unsigned char * end_of_sequence
;
5957 printf (_("\nDump of debug contents of section %s:\n\n"),
5958 SECTION_NAME (section
));
5962 external
= (DWARF2_External_LineInfo
*) data
;
5964 /* Check the length of the block. */
5965 info
.li_length
= BYTE_GET (external
->li_length
);
5967 if (info
.li_length
== 0xffffffff)
5969 warn (_("64-bit DWARF line info is not supported yet.\n"));
5973 if (info
.li_length
+ sizeof (external
->li_length
) > section
->sh_size
)
5976 (_("The line info appears to be corrupt - the section is too small\n"));
5980 /* Check its version number. */
5981 info
.li_version
= BYTE_GET (external
->li_version
);
5982 if (info
.li_version
!= 2)
5984 warn (_("Only DWARF version 2 line info is currently supported.\n"));
5988 info
.li_prologue_length
= BYTE_GET (external
->li_prologue_length
);
5989 info
.li_min_insn_length
= BYTE_GET (external
->li_min_insn_length
);
5990 info
.li_default_is_stmt
= BYTE_GET (external
->li_default_is_stmt
);
5991 info
.li_line_base
= BYTE_GET (external
->li_line_base
);
5992 info
.li_line_range
= BYTE_GET (external
->li_line_range
);
5993 info
.li_opcode_base
= BYTE_GET (external
->li_opcode_base
);
5995 /* Sign extend the line base field. */
5996 info
.li_line_base
<<= 24;
5997 info
.li_line_base
>>= 24;
5999 printf (_(" Length: %ld\n"), info
.li_length
);
6000 printf (_(" DWARF Version: %d\n"), info
.li_version
);
6001 printf (_(" Prologue Length: %d\n"), info
.li_prologue_length
);
6002 printf (_(" Minimum Instruction Length: %d\n"), info
.li_min_insn_length
);
6003 printf (_(" Initial value of 'is_stmt': %d\n"), info
.li_default_is_stmt
);
6004 printf (_(" Line Base: %d\n"), info
.li_line_base
);
6005 printf (_(" Line Range: %d\n"), info
.li_line_range
);
6006 printf (_(" Opcode Base: %d\n"), info
.li_opcode_base
);
6008 end_of_sequence
= data
+ info
.li_length
+ sizeof (external
->li_length
);
6010 reset_state_machine (info
.li_default_is_stmt
);
6012 /* Display the contents of the Opcodes table. */
6013 standard_opcodes
= data
+ sizeof (* external
);
6015 printf (_("\n Opcodes:\n"));
6017 for (i
= 1; i
< info
.li_opcode_base
; i
++)
6018 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
6020 /* Display the contents of the Directory table. */
6021 data
= standard_opcodes
+ info
.li_opcode_base
- 1;
6024 printf (_("\n The Directory Table is empty.\n"));
6027 printf (_("\n The Directory Table:\n"));
6031 printf (_(" %s\n"), data
);
6033 data
+= strlen ((char *) data
) + 1;
6037 /* Skip the NUL at the end of the table. */
6040 /* Display the contents of the File Name table. */
6042 printf (_("\n The File Name Table is empty.\n"));
6045 printf (_("\n The File Name Table:\n"));
6046 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
6050 unsigned char * name
;
6053 printf (_(" %d\t"), ++ state_machine_regs
.last_file_entry
);
6056 data
+= strlen ((char *) data
) + 1;
6058 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6060 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6062 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6064 printf (_("%s\n"), name
);
6068 /* Skip the NUL at the end of the table. */
6071 /* Now display the statements. */
6072 printf (_("\n Line Number Statements:\n"));
6075 while (data
< end_of_sequence
)
6077 unsigned char op_code
;
6081 op_code
= * data
++;
6083 if (op_code
>= info
.li_opcode_base
)
6085 op_code
-= info
.li_opcode_base
;
6086 adv
= (op_code
/ info
.li_line_range
) * info
.li_min_insn_length
;
6087 state_machine_regs
.address
+= adv
;
6088 printf (_(" Special opcode %d: advance Address by %d to 0x%lx"),
6089 op_code
, adv
, state_machine_regs
.address
);
6090 adv
= (op_code
% info
.li_line_range
) + info
.li_line_base
;
6091 state_machine_regs
.line
+= adv
;
6092 printf (_(" and Line by %d to %d\n"),
6093 adv
, state_machine_regs
.line
);
6095 else switch (op_code
)
6097 case DW_LNS_extended_op
:
6098 data
+= process_extended_line_op (data
, info
.li_default_is_stmt
,
6099 debug_line_pointer_size
);
6103 printf (_(" Copy\n"));
6106 case DW_LNS_advance_pc
:
6107 adv
= info
.li_min_insn_length
* read_leb128 (data
, & bytes_read
, 0);
6109 state_machine_regs
.address
+= adv
;
6110 printf (_(" Advance PC by %d to %lx\n"), adv
,
6111 state_machine_regs
.address
);
6114 case DW_LNS_advance_line
:
6115 adv
= read_leb128 (data
, & bytes_read
, 1);
6117 state_machine_regs
.line
+= adv
;
6118 printf (_(" Advance Line by %d to %d\n"), adv
,
6119 state_machine_regs
.line
);
6122 case DW_LNS_set_file
:
6123 adv
= read_leb128 (data
, & bytes_read
, 0);
6125 printf (_(" Set File Name to entry %d in the File Name Table\n"),
6127 state_machine_regs
.file
= adv
;
6130 case DW_LNS_set_column
:
6131 adv
= read_leb128 (data
, & bytes_read
, 0);
6133 printf (_(" Set column to %d\n"), adv
);
6134 state_machine_regs
.column
= adv
;
6137 case DW_LNS_negate_stmt
:
6138 adv
= state_machine_regs
.is_stmt
;
6140 printf (_(" Set is_stmt to %d\n"), adv
);
6141 state_machine_regs
.is_stmt
= adv
;
6144 case DW_LNS_set_basic_block
:
6145 printf (_(" Set basic block\n"));
6146 state_machine_regs
.basic_block
= 1;
6149 case DW_LNS_const_add_pc
:
6150 adv
= (((255 - info
.li_opcode_base
) / info
.li_line_range
)
6151 * info
.li_min_insn_length
);
6152 state_machine_regs
.address
+= adv
;
6153 printf (_(" Advance PC by constant %d to 0x%lx\n"), adv
,
6154 state_machine_regs
.address
);
6157 case DW_LNS_fixed_advance_pc
:
6158 adv
= byte_get (data
, 2);
6160 state_machine_regs
.address
+= adv
;
6161 printf (_(" Advance PC by fixed size amount %d to 0x%lx\n"),
6162 adv
, state_machine_regs
.address
);
6165 case DW_LNS_set_prologue_end
:
6166 printf (_(" Set prologue_end to true\n"));
6169 case DW_LNS_set_epilogue_begin
:
6170 printf (_(" Set epilogue_begin to true\n"));
6173 case DW_LNS_set_isa
:
6174 adv
= read_leb128 (data
, & bytes_read
, 0);
6176 printf (_(" Set ISA to %d\n"), adv
);
6180 printf (_(" Unknown opcode %d with operands: "), op_code
);
6183 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
6185 printf ("0x%lx%s", read_leb128 (data
, &bytes_read
, 0),
6186 i
== 1 ? "" : ", ");
6201 display_debug_pubnames (section
, start
, file
)
6202 Elf32_Internal_Shdr
* section
;
6203 unsigned char * start
;
6204 FILE * file ATTRIBUTE_UNUSED
;
6206 DWARF2_External_PubNames
* external
;
6207 DWARF2_Internal_PubNames pubnames
;
6208 unsigned char * end
;
6210 end
= start
+ section
->sh_size
;
6212 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
6216 unsigned char * data
;
6217 unsigned long offset
;
6219 external
= (DWARF2_External_PubNames
*) start
;
6221 pubnames
.pn_length
= BYTE_GET (external
->pn_length
);
6222 pubnames
.pn_version
= BYTE_GET (external
->pn_version
);
6223 pubnames
.pn_offset
= BYTE_GET (external
->pn_offset
);
6224 pubnames
.pn_size
= BYTE_GET (external
->pn_size
);
6226 data
= start
+ sizeof (* external
);
6227 start
+= pubnames
.pn_length
+ sizeof (external
->pn_length
);
6229 if (pubnames
.pn_length
== 0xffffffff)
6231 warn (_("64-bit DWARF pubnames are not supported yet.\n"));
6235 if (pubnames
.pn_version
!= 2)
6237 static int warned
= 0;
6241 warn (_("Only DWARF 2 pubnames are currently supported\n"));
6248 printf (_(" Length: %ld\n"),
6249 pubnames
.pn_length
);
6250 printf (_(" Version: %d\n"),
6251 pubnames
.pn_version
);
6252 printf (_(" Offset into .debug_info section: %ld\n"),
6253 pubnames
.pn_offset
);
6254 printf (_(" Size of area in .debug_info section: %ld\n"),
6257 printf (_("\n Offset\tName\n"));
6261 offset
= byte_get (data
, 4);
6266 printf (" %ld\t\t%s\n", offset
, data
);
6267 data
+= strlen ((char *) data
) + 1;
6270 while (offset
!= 0);
6283 case DW_TAG_padding
: return "DW_TAG_padding";
6284 case DW_TAG_array_type
: return "DW_TAG_array_type";
6285 case DW_TAG_class_type
: return "DW_TAG_class_type";
6286 case DW_TAG_entry_point
: return "DW_TAG_entry_point";
6287 case DW_TAG_enumeration_type
: return "DW_TAG_enumeration_type";
6288 case DW_TAG_formal_parameter
: return "DW_TAG_formal_parameter";
6289 case DW_TAG_imported_declaration
: return "DW_TAG_imported_declaration";
6290 case DW_TAG_label
: return "DW_TAG_label";
6291 case DW_TAG_lexical_block
: return "DW_TAG_lexical_block";
6292 case DW_TAG_member
: return "DW_TAG_member";
6293 case DW_TAG_pointer_type
: return "DW_TAG_pointer_type";
6294 case DW_TAG_reference_type
: return "DW_TAG_reference_type";
6295 case DW_TAG_compile_unit
: return "DW_TAG_compile_unit";
6296 case DW_TAG_string_type
: return "DW_TAG_string_type";
6297 case DW_TAG_structure_type
: return "DW_TAG_structure_type";
6298 case DW_TAG_subroutine_type
: return "DW_TAG_subroutine_type";
6299 case DW_TAG_typedef
: return "DW_TAG_typedef";
6300 case DW_TAG_union_type
: return "DW_TAG_union_type";
6301 case DW_TAG_unspecified_parameters
: return "DW_TAG_unspecified_parameters";
6302 case DW_TAG_variant
: return "DW_TAG_variant";
6303 case DW_TAG_common_block
: return "DW_TAG_common_block";
6304 case DW_TAG_common_inclusion
: return "DW_TAG_common_inclusion";
6305 case DW_TAG_inheritance
: return "DW_TAG_inheritance";
6306 case DW_TAG_inlined_subroutine
: return "DW_TAG_inlined_subroutine";
6307 case DW_TAG_module
: return "DW_TAG_module";
6308 case DW_TAG_ptr_to_member_type
: return "DW_TAG_ptr_to_member_type";
6309 case DW_TAG_set_type
: return "DW_TAG_set_type";
6310 case DW_TAG_subrange_type
: return "DW_TAG_subrange_type";
6311 case DW_TAG_with_stmt
: return "DW_TAG_with_stmt";
6312 case DW_TAG_access_declaration
: return "DW_TAG_access_declaration";
6313 case DW_TAG_base_type
: return "DW_TAG_base_type";
6314 case DW_TAG_catch_block
: return "DW_TAG_catch_block";
6315 case DW_TAG_const_type
: return "DW_TAG_const_type";
6316 case DW_TAG_constant
: return "DW_TAG_constant";
6317 case DW_TAG_enumerator
: return "DW_TAG_enumerator";
6318 case DW_TAG_file_type
: return "DW_TAG_file_type";
6319 case DW_TAG_friend
: return "DW_TAG_friend";
6320 case DW_TAG_namelist
: return "DW_TAG_namelist";
6321 case DW_TAG_namelist_item
: return "DW_TAG_namelist_item";
6322 case DW_TAG_packed_type
: return "DW_TAG_packed_type";
6323 case DW_TAG_subprogram
: return "DW_TAG_subprogram";
6324 case DW_TAG_template_type_param
: return "DW_TAG_template_type_param";
6325 case DW_TAG_template_value_param
: return "DW_TAG_template_value_param";
6326 case DW_TAG_thrown_type
: return "DW_TAG_thrown_type";
6327 case DW_TAG_try_block
: return "DW_TAG_try_block";
6328 case DW_TAG_variant_part
: return "DW_TAG_variant_part";
6329 case DW_TAG_variable
: return "DW_TAG_variable";
6330 case DW_TAG_volatile_type
: return "DW_TAG_volatile_type";
6331 case DW_TAG_MIPS_loop
: return "DW_TAG_MIPS_loop";
6332 case DW_TAG_format_label
: return "DW_TAG_format_label";
6333 case DW_TAG_function_template
: return "DW_TAG_function_template";
6334 case DW_TAG_class_template
: return "DW_TAG_class_template";
6335 /* DWARF 2.1 values. */
6336 case DW_TAG_dwarf_procedure
: return "DW_TAG_dwarf_procedure";
6337 case DW_TAG_restrict_type
: return "DW_TAG_restrict_type";
6338 case DW_TAG_interface_type
: return "DW_TAG_interface_type";
6339 case DW_TAG_namespace
: return "DW_TAG_namespace";
6340 case DW_TAG_imported_module
: return "DW_TAG_imported_module";
6341 case DW_TAG_unspecified_type
: return "DW_TAG_unspecified_type";
6342 case DW_TAG_partial_unit
: return "DW_TAG_partial_unit";
6343 case DW_TAG_imported_unit
: return "DW_TAG_imported_unit";
6346 static char buffer
[100];
6348 sprintf (buffer
, _("Unknown TAG value: %lx"), tag
);
6355 get_AT_name (attribute
)
6356 unsigned long attribute
;
6360 case DW_AT_sibling
: return "DW_AT_sibling";
6361 case DW_AT_location
: return "DW_AT_location";
6362 case DW_AT_name
: return "DW_AT_name";
6363 case DW_AT_ordering
: return "DW_AT_ordering";
6364 case DW_AT_subscr_data
: return "DW_AT_subscr_data";
6365 case DW_AT_byte_size
: return "DW_AT_byte_size";
6366 case DW_AT_bit_offset
: return "DW_AT_bit_offset";
6367 case DW_AT_bit_size
: return "DW_AT_bit_size";
6368 case DW_AT_element_list
: return "DW_AT_element_list";
6369 case DW_AT_stmt_list
: return "DW_AT_stmt_list";
6370 case DW_AT_low_pc
: return "DW_AT_low_pc";
6371 case DW_AT_high_pc
: return "DW_AT_high_pc";
6372 case DW_AT_language
: return "DW_AT_language";
6373 case DW_AT_member
: return "DW_AT_member";
6374 case DW_AT_discr
: return "DW_AT_discr";
6375 case DW_AT_discr_value
: return "DW_AT_discr_value";
6376 case DW_AT_visibility
: return "DW_AT_visibility";
6377 case DW_AT_import
: return "DW_AT_import";
6378 case DW_AT_string_length
: return "DW_AT_string_length";
6379 case DW_AT_common_reference
: return "DW_AT_common_reference";
6380 case DW_AT_comp_dir
: return "DW_AT_comp_dir";
6381 case DW_AT_const_value
: return "DW_AT_const_value";
6382 case DW_AT_containing_type
: return "DW_AT_containing_type";
6383 case DW_AT_default_value
: return "DW_AT_default_value";
6384 case DW_AT_inline
: return "DW_AT_inline";
6385 case DW_AT_is_optional
: return "DW_AT_is_optional";
6386 case DW_AT_lower_bound
: return "DW_AT_lower_bound";
6387 case DW_AT_producer
: return "DW_AT_producer";
6388 case DW_AT_prototyped
: return "DW_AT_prototyped";
6389 case DW_AT_return_addr
: return "DW_AT_return_addr";
6390 case DW_AT_start_scope
: return "DW_AT_start_scope";
6391 case DW_AT_stride_size
: return "DW_AT_stride_size";
6392 case DW_AT_upper_bound
: return "DW_AT_upper_bound";
6393 case DW_AT_abstract_origin
: return "DW_AT_abstract_origin";
6394 case DW_AT_accessibility
: return "DW_AT_accessibility";
6395 case DW_AT_address_class
: return "DW_AT_address_class";
6396 case DW_AT_artificial
: return "DW_AT_artificial";
6397 case DW_AT_base_types
: return "DW_AT_base_types";
6398 case DW_AT_calling_convention
: return "DW_AT_calling_convention";
6399 case DW_AT_count
: return "DW_AT_count";
6400 case DW_AT_data_member_location
: return "DW_AT_data_member_location";
6401 case DW_AT_decl_column
: return "DW_AT_decl_column";
6402 case DW_AT_decl_file
: return "DW_AT_decl_file";
6403 case DW_AT_decl_line
: return "DW_AT_decl_line";
6404 case DW_AT_declaration
: return "DW_AT_declaration";
6405 case DW_AT_discr_list
: return "DW_AT_discr_list";
6406 case DW_AT_encoding
: return "DW_AT_encoding";
6407 case DW_AT_external
: return "DW_AT_external";
6408 case DW_AT_frame_base
: return "DW_AT_frame_base";
6409 case DW_AT_friend
: return "DW_AT_friend";
6410 case DW_AT_identifier_case
: return "DW_AT_identifier_case";
6411 case DW_AT_macro_info
: return "DW_AT_macro_info";
6412 case DW_AT_namelist_items
: return "DW_AT_namelist_items";
6413 case DW_AT_priority
: return "DW_AT_priority";
6414 case DW_AT_segment
: return "DW_AT_segment";
6415 case DW_AT_specification
: return "DW_AT_specification";
6416 case DW_AT_static_link
: return "DW_AT_static_link";
6417 case DW_AT_type
: return "DW_AT_type";
6418 case DW_AT_use_location
: return "DW_AT_use_location";
6419 case DW_AT_variable_parameter
: return "DW_AT_variable_parameter";
6420 case DW_AT_virtuality
: return "DW_AT_virtuality";
6421 case DW_AT_vtable_elem_location
: return "DW_AT_vtable_elem_location";
6422 /* DWARF 2.1 values. */
6423 case DW_AT_allocated
: return "DW_AT_allocated";
6424 case DW_AT_associated
: return "DW_AT_associated";
6425 case DW_AT_data_location
: return "DW_AT_data_location";
6426 case DW_AT_stride
: return "DW_AT_stride";
6427 case DW_AT_entry_pc
: return "DW_AT_entry_pc";
6428 case DW_AT_use_UTF8
: return "DW_AT_use_UTF8";
6429 case DW_AT_extension
: return "DW_AT_extension";
6430 case DW_AT_ranges
: return "DW_AT_ranges";
6431 case DW_AT_trampoline
: return "DW_AT_trampoline";
6432 case DW_AT_call_column
: return "DW_AT_call_column";
6433 case DW_AT_call_file
: return "DW_AT_call_file";
6434 case DW_AT_call_line
: return "DW_AT_call_line";
6435 /* SGI/MIPS extensions. */
6436 case DW_AT_MIPS_fde
: return "DW_AT_MIPS_fde";
6437 case DW_AT_MIPS_loop_begin
: return "DW_AT_MIPS_loop_begin";
6438 case DW_AT_MIPS_tail_loop_begin
: return "DW_AT_MIPS_tail_loop_begin";
6439 case DW_AT_MIPS_epilog_begin
: return "DW_AT_MIPS_epilog_begin";
6440 case DW_AT_MIPS_loop_unroll_factor
: return "DW_AT_MIPS_loop_unroll_factor";
6441 case DW_AT_MIPS_software_pipeline_depth
: return "DW_AT_MIPS_software_pipeline_depth";
6442 case DW_AT_MIPS_linkage_name
: return "DW_AT_MIPS_linkage_name";
6443 case DW_AT_MIPS_stride
: return "DW_AT_MIPS_stride";
6444 case DW_AT_MIPS_abstract_name
: return "DW_AT_MIPS_abstract_name";
6445 case DW_AT_MIPS_clone_origin
: return "DW_AT_MIPS_clone_origin";
6446 case DW_AT_MIPS_has_inlines
: return "DW_AT_MIPS_has_inlines";
6447 /* GNU extensions. */
6448 case DW_AT_sf_names
: return "DW_AT_sf_names";
6449 case DW_AT_src_info
: return "DW_AT_src_info";
6450 case DW_AT_mac_info
: return "DW_AT_mac_info";
6451 case DW_AT_src_coords
: return "DW_AT_src_coords";
6452 case DW_AT_body_begin
: return "DW_AT_body_begin";
6453 case DW_AT_body_end
: return "DW_AT_body_end";
6456 static char buffer
[100];
6458 sprintf (buffer
, _("Unknown AT value: %lx"), attribute
);
6465 get_FORM_name (form
)
6470 case DW_FORM_addr
: return "DW_FORM_addr";
6471 case DW_FORM_block2
: return "DW_FORM_block2";
6472 case DW_FORM_block4
: return "DW_FORM_block4";
6473 case DW_FORM_data2
: return "DW_FORM_data2";
6474 case DW_FORM_data4
: return "DW_FORM_data4";
6475 case DW_FORM_data8
: return "DW_FORM_data8";
6476 case DW_FORM_string
: return "DW_FORM_string";
6477 case DW_FORM_block
: return "DW_FORM_block";
6478 case DW_FORM_block1
: return "DW_FORM_block1";
6479 case DW_FORM_data1
: return "DW_FORM_data1";
6480 case DW_FORM_flag
: return "DW_FORM_flag";
6481 case DW_FORM_sdata
: return "DW_FORM_sdata";
6482 case DW_FORM_strp
: return "DW_FORM_strp";
6483 case DW_FORM_udata
: return "DW_FORM_udata";
6484 case DW_FORM_ref_addr
: return "DW_FORM_ref_addr";
6485 case DW_FORM_ref1
: return "DW_FORM_ref1";
6486 case DW_FORM_ref2
: return "DW_FORM_ref2";
6487 case DW_FORM_ref4
: return "DW_FORM_ref4";
6488 case DW_FORM_ref8
: return "DW_FORM_ref8";
6489 case DW_FORM_ref_udata
: return "DW_FORM_ref_udata";
6490 case DW_FORM_indirect
: return "DW_FORM_indirect";
6493 static char buffer
[100];
6495 sprintf (buffer
, _("Unknown FORM value: %lx"), form
);
6501 /* FIXME: There are better and more effiecint ways to handle
6502 these structures. For now though, I just want something that
6503 is simple to implement. */
6504 typedef struct abbrev_attr
6506 unsigned long attribute
;
6508 struct abbrev_attr
* next
;
6512 typedef struct abbrev_entry
6514 unsigned long entry
;
6517 struct abbrev_attr
* first_attr
;
6518 struct abbrev_attr
* last_attr
;
6519 struct abbrev_entry
* next
;
6523 static abbrev_entry
* first_abbrev
= NULL
;
6524 static abbrev_entry
* last_abbrev
= NULL
;
6527 free_abbrevs
PARAMS ((void))
6529 abbrev_entry
* abbrev
;
6531 for (abbrev
= first_abbrev
; abbrev
;)
6533 abbrev_entry
* next
= abbrev
->next
;
6536 for (attr
= abbrev
->first_attr
; attr
;)
6538 abbrev_attr
* next
= attr
->next
;
6548 last_abbrev
= first_abbrev
= NULL
;
6552 add_abbrev (number
, tag
, children
)
6553 unsigned long number
;
6557 abbrev_entry
* entry
;
6559 entry
= (abbrev_entry
*) malloc (sizeof (* entry
));
6565 entry
->entry
= number
;
6567 entry
->children
= children
;
6568 entry
->first_attr
= NULL
;
6569 entry
->last_attr
= NULL
;
6572 if (first_abbrev
== NULL
)
6573 first_abbrev
= entry
;
6575 last_abbrev
->next
= entry
;
6577 last_abbrev
= entry
;
6581 add_abbrev_attr (attribute
, form
)
6582 unsigned long attribute
;
6587 attr
= (abbrev_attr
*) malloc (sizeof (* attr
));
6593 attr
->attribute
= attribute
;
6597 if (last_abbrev
->first_attr
== NULL
)
6598 last_abbrev
->first_attr
= attr
;
6600 last_abbrev
->last_attr
->next
= attr
;
6602 last_abbrev
->last_attr
= attr
;
6605 /* Processes the (partial) contents of a .debug_abbrev section.
6606 Returns NULL if the end of the section was encountered.
6607 Returns the address after the last byte read if the end of
6608 an abbreviation set was found. */
6610 static unsigned char *
6611 process_abbrev_section (start
, end
)
6612 unsigned char * start
;
6613 unsigned char * end
;
6615 if (first_abbrev
!= NULL
)
6621 unsigned long entry
;
6623 unsigned long attribute
;
6626 entry
= read_leb128 (start
, & bytes_read
, 0);
6627 start
+= bytes_read
;
6629 /* A single zero is supposed to end the section according
6630 to the standard. If there's more, then signal that to
6633 return start
== end
? NULL
: start
;
6635 tag
= read_leb128 (start
, & bytes_read
, 0);
6636 start
+= bytes_read
;
6638 children
= * start
++;
6640 add_abbrev (entry
, tag
, children
);
6646 attribute
= read_leb128 (start
, & bytes_read
, 0);
6647 start
+= bytes_read
;
6649 form
= read_leb128 (start
, & bytes_read
, 0);
6650 start
+= bytes_read
;
6653 add_abbrev_attr (attribute
, form
);
6655 while (attribute
!= 0);
6663 display_debug_macinfo (section
, start
, file
)
6664 Elf32_Internal_Shdr
* section
;
6665 unsigned char * start
;
6666 FILE * file ATTRIBUTE_UNUSED
;
6668 unsigned char * end
= start
+ section
->sh_size
;
6669 unsigned char * curr
= start
;
6670 unsigned int bytes_read
;
6671 enum dwarf_macinfo_record_type op
;
6673 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
6677 unsigned int lineno
;
6678 const char * string
;
6685 case DW_MACINFO_start_file
:
6687 unsigned int filenum
;
6689 lineno
= read_leb128 (curr
, & bytes_read
, 0);
6691 filenum
= read_leb128 (curr
, & bytes_read
, 0);
6694 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), lineno
, filenum
);
6698 case DW_MACINFO_end_file
:
6699 printf (_(" DW_MACINFO_end_file\n"));
6702 case DW_MACINFO_define
:
6703 lineno
= read_leb128 (curr
, & bytes_read
, 0);
6706 curr
+= strlen (string
) + 1;
6707 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), lineno
, string
);
6710 case DW_MACINFO_undef
:
6711 lineno
= read_leb128 (curr
, & bytes_read
, 0);
6714 curr
+= strlen (string
) + 1;
6715 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), lineno
, string
);
6718 case DW_MACINFO_vendor_ext
:
6720 unsigned int constant
;
6722 constant
= read_leb128 (curr
, & bytes_read
, 0);
6725 curr
+= strlen (string
) + 1;
6726 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), constant
, string
);
6737 display_debug_abbrev (section
, start
, file
)
6738 Elf32_Internal_Shdr
* section
;
6739 unsigned char * start
;
6740 FILE * file ATTRIBUTE_UNUSED
;
6742 abbrev_entry
* entry
;
6743 unsigned char * end
= start
+ section
->sh_size
;
6745 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
6749 start
= process_abbrev_section (start
, end
);
6751 if (first_abbrev
== NULL
)
6754 printf (_(" Number TAG\n"));
6756 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
6760 printf (_(" %ld %s [%s]\n"),
6762 get_TAG_name (entry
->tag
),
6763 entry
->children
? _("has children") : _("no children"));
6765 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
6767 printf (_(" %-18s %s\n"),
6768 get_AT_name (attr
->attribute
),
6769 get_FORM_name (attr
->form
));
6783 static unsigned char *
6784 display_block (data
, length
)
6785 unsigned char * data
;
6786 unsigned long length
;
6788 printf (_(" %lu byte block: "), length
);
6791 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
6797 decode_location_expression (data
, pointer_size
, length
)
6798 unsigned char * data
;
6799 unsigned int pointer_size
;
6800 unsigned long length
;
6804 unsigned long uvalue
;
6805 unsigned char * end
= data
+ length
;
6814 printf ("DW_OP_addr: %lx",
6815 (unsigned long) byte_get (data
, pointer_size
));
6816 data
+= pointer_size
;
6819 printf ("DW_OP_deref");
6822 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data
++, 1));
6825 printf ("DW_OP_const1s: %ld", (long) byte_get (data
++, 1));
6828 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data
, 2));
6832 printf ("DW_OP_const2s: %ld", (long) byte_get (data
, 2));
6836 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data
, 4));
6840 printf ("DW_OP_const4s: %ld", (long) byte_get (data
, 4));
6844 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data
, 4),
6845 (unsigned long) byte_get (data
+ 4, 4));
6849 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data
, 4),
6850 (long) byte_get (data
+ 4, 4));
6854 printf ("DW_OP_constu: %lu", read_leb128 (data
, &bytes_read
, 0));
6858 printf ("DW_OP_consts: %ld", read_leb128 (data
, &bytes_read
, 1));
6862 printf ("DW_OP_dup");
6865 printf ("DW_OP_drop");
6868 printf ("DW_OP_over");
6871 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data
++, 1));
6874 printf ("DW_OP_swap");
6877 printf ("DW_OP_rot");
6880 printf ("DW_OP_xderef");
6883 printf ("DW_OP_abs");
6886 printf ("DW_OP_and");
6889 printf ("DW_OP_div");
6892 printf ("DW_OP_minus");
6895 printf ("DW_OP_mod");
6898 printf ("DW_OP_mul");
6901 printf ("DW_OP_neg");
6904 printf ("DW_OP_not");
6907 printf ("DW_OP_or");
6910 printf ("DW_OP_plus");
6912 case DW_OP_plus_uconst
:
6913 printf ("DW_OP_plus_uconst: %lu",
6914 read_leb128 (data
, &bytes_read
, 0));
6918 printf ("DW_OP_shl");
6921 printf ("DW_OP_shr");
6924 printf ("DW_OP_shra");
6927 printf ("DW_OP_xor");
6930 printf ("DW_OP_bra: %ld", (long) byte_get (data
, 2));
6934 printf ("DW_OP_eq");
6937 printf ("DW_OP_ge");
6940 printf ("DW_OP_gt");
6943 printf ("DW_OP_le");
6946 printf ("DW_OP_lt");
6949 printf ("DW_OP_ne");
6952 printf ("DW_OP_skip: %ld", (long) byte_get (data
, 2));
6988 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
7023 printf ("DW_OP_reg%d", op
- DW_OP_reg0
);
7058 printf ("DW_OP_breg%d: %ld", op
- DW_OP_breg0
,
7059 read_leb128 (data
, &bytes_read
, 1));
7064 printf ("DW_OP_regx: %lu", read_leb128 (data
, &bytes_read
, 0));
7068 printf ("DW_OP_fbreg: %ld", read_leb128 (data
, &bytes_read
, 1));
7072 uvalue
= read_leb128 (data
, &bytes_read
, 0);
7074 printf ("DW_OP_bregx: %lu %ld", uvalue
,
7075 read_leb128 (data
, &bytes_read
, 1));
7079 printf ("DW_OP_piece: %lu", read_leb128 (data
, &bytes_read
, 0));
7082 case DW_OP_deref_size
:
7083 printf ("DW_OP_deref_size: %ld", (long) byte_get (data
++, 1));
7085 case DW_OP_xderef_size
:
7086 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data
++, 1));
7089 printf ("DW_OP_nop");
7092 /* DWARF 2.1 extensions. */
7093 case DW_OP_push_object_address
:
7094 printf ("DW_OP_push_object_address");
7097 printf ("DW_OP_call2: <%lx>", (long) byte_get (data
, 2));
7101 printf ("DW_OP_call4: <%lx>", (long) byte_get (data
, 4));
7105 printf ("DW_OP_calli");
7109 if (op
>= DW_OP_lo_user
7110 && op
<= DW_OP_hi_user
)
7111 printf (_("(User defined location op)"));
7113 printf (_("(Unknown location op)"));
7114 /* No way to tell where the next op is, so just bail. */
7118 /* Separate the ops. */
7124 static const char * debug_str_contents
;
7125 static bfd_vma debug_str_size
;
7128 load_debug_str (file
)
7131 Elf32_Internal_Shdr
* sec
;
7134 /* If it is already loaded, do nothing. */
7135 if (debug_str_contents
!= NULL
)
7138 /* Locate the .debug_str section. */
7139 for (i
= 0, sec
= section_headers
;
7140 i
< elf_header
.e_shnum
;
7142 if (strcmp (SECTION_NAME (sec
), ".debug_str") == 0)
7145 if (i
== elf_header
.e_shnum
|| sec
->sh_size
== 0)
7148 debug_str_size
= sec
->sh_size
;
7150 debug_str_contents
= ((char *)
7151 get_data (NULL
, file
, sec
->sh_offset
, sec
->sh_size
,
7152 _("debug_str section data")));
7158 if (debug_str_contents
== NULL
)
7161 free ((char *) debug_str_contents
);
7162 debug_str_contents
= NULL
;
7167 fetch_indirect_string (offset
)
7168 unsigned long offset
;
7170 if (debug_str_contents
== NULL
)
7171 return _("<no .debug_str section>");
7173 if (offset
> debug_str_size
)
7174 return _("<offset is too big>");
7176 return debug_str_contents
+ offset
;
7181 display_debug_str (section
, start
, file
)
7182 Elf32_Internal_Shdr
* section
;
7183 unsigned char * start
;
7184 FILE * file ATTRIBUTE_UNUSED
;
7186 unsigned long bytes
;
7189 addr
= section
->sh_addr
;
7190 bytes
= section
->sh_size
;
7194 printf (_("\nThe .debug_str section is empty.\n"));
7198 printf (_("Contents of the .debug_str section:\n\n"));
7206 lbytes
= (bytes
> 16 ? 16 : bytes
);
7208 printf (" 0x%8.8lx ", (unsigned long) addr
);
7210 for (j
= 0; j
< 16; j
++)
7213 printf ("%2.2x", start
[j
]);
7221 for (j
= 0; j
< lbytes
; j
++)
7224 if (k
>= ' ' && k
< 0x80)
7241 static unsigned char *
7242 read_and_display_attr_value (attribute
, form
, data
, cu_offset
, pointer_size
)
7243 unsigned long attribute
;
7245 unsigned char * data
;
7246 unsigned long cu_offset
;
7247 unsigned long pointer_size
;
7249 unsigned long uvalue
= 0;
7250 unsigned char * block_start
= NULL
;
7258 case DW_FORM_ref_addr
:
7260 uvalue
= byte_get (data
, pointer_size
);
7261 data
+= pointer_size
;
7265 uvalue
= byte_get (data
, /* offset_size */ 4);
7266 data
+= /* offset_size */ 4;
7272 uvalue
= byte_get (data
++, 1);
7277 uvalue
= byte_get (data
, 2);
7283 uvalue
= byte_get (data
, 4);
7288 uvalue
= read_leb128 (data
, & bytes_read
, 1);
7292 case DW_FORM_ref_udata
:
7294 uvalue
= read_leb128 (data
, & bytes_read
, 0);
7298 case DW_FORM_indirect
:
7299 form
= read_leb128 (data
, & bytes_read
, 0);
7301 printf (" %s", get_FORM_name (form
));
7302 return read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
7308 case DW_FORM_ref_addr
:
7309 printf (" <#%lx>", uvalue
);
7315 case DW_FORM_ref_udata
:
7316 printf (" <%lx>", uvalue
+ cu_offset
);
7320 printf (" %#lx", uvalue
);
7328 printf (" %ld", uvalue
);
7333 uvalue
= byte_get (data
, 4);
7334 printf (" %lx", uvalue
);
7335 printf (" %lx", (unsigned long) byte_get (data
+ 4, 4));
7339 case DW_FORM_string
:
7340 printf (" %s", data
);
7341 data
+= strlen ((char *) data
) + 1;
7345 uvalue
= read_leb128 (data
, & bytes_read
, 0);
7346 block_start
= data
+ bytes_read
;
7347 data
= display_block (block_start
, uvalue
);
7350 case DW_FORM_block1
:
7351 uvalue
= byte_get (data
, 1);
7352 block_start
= data
+ 1;
7353 data
= display_block (block_start
, uvalue
);
7356 case DW_FORM_block2
:
7357 uvalue
= byte_get (data
, 2);
7358 block_start
= data
+ 2;
7359 data
= display_block (block_start
, uvalue
);
7362 case DW_FORM_block4
:
7363 uvalue
= byte_get (data
, 4);
7364 block_start
= data
+ 4;
7365 data
= display_block (block_start
, uvalue
);
7369 printf (_(" (indirect string, offset: 0x%lx): "), uvalue
);
7370 printf (fetch_indirect_string (uvalue
));
7373 case DW_FORM_indirect
:
7374 /* Handled above. */
7378 warn (_("Unrecognised form: %d\n"), form
);
7382 /* For some attributes we can display futher information. */
7391 case DW_INL_not_inlined
: printf (_("(not inlined)")); break;
7392 case DW_INL_inlined
: printf (_("(inlined)")); break;
7393 case DW_INL_declared_not_inlined
: printf (_("(declared as inline but ignored)")); break;
7394 case DW_INL_declared_inlined
: printf (_("(declared as inline and inlined)")); break;
7395 default: printf (_(" (Unknown inline attribute value: %lx)"), uvalue
); break;
7399 case DW_AT_language
:
7402 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
7403 case DW_LANG_C89
: printf ("(ANSI C)"); break;
7404 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
7405 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
7406 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
7407 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
7408 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
7409 case DW_LANG_Ada83
: printf ("(Ada)"); break;
7410 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
7411 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
7412 /* DWARF 2.1 values. */
7413 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
7414 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
7415 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
7416 /* MIPS extension. */
7417 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
7418 default: printf ("(Unknown: %lx)", uvalue
); break;
7422 case DW_AT_encoding
:
7425 case DW_ATE_void
: printf ("(void)"); break;
7426 case DW_ATE_address
: printf ("(machine address)"); break;
7427 case DW_ATE_boolean
: printf ("(boolean)"); break;
7428 case DW_ATE_complex_float
: printf ("(complex float)"); break;
7429 case DW_ATE_float
: printf ("(float)"); break;
7430 case DW_ATE_signed
: printf ("(signed)"); break;
7431 case DW_ATE_signed_char
: printf ("(signed char)"); break;
7432 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
7433 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
7434 /* DWARF 2.1 value. */
7435 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
7437 if (uvalue
>= DW_ATE_lo_user
7438 && uvalue
<= DW_ATE_hi_user
)
7439 printf ("(user defined type)");
7441 printf ("(unknown type)");
7446 case DW_AT_accessibility
:
7449 case DW_ACCESS_public
: printf ("(public)"); break;
7450 case DW_ACCESS_protected
: printf ("(protected)"); break;
7451 case DW_ACCESS_private
: printf ("(private)"); break;
7452 default: printf ("(unknown accessibility)"); break;
7456 case DW_AT_visibility
:
7459 case DW_VIS_local
: printf ("(local)"); break;
7460 case DW_VIS_exported
: printf ("(exported)"); break;
7461 case DW_VIS_qualified
: printf ("(qualified)"); break;
7462 default: printf ("(unknown visibility)"); break;
7466 case DW_AT_virtuality
:
7469 case DW_VIRTUALITY_none
: printf ("(none)"); break;
7470 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
7471 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
7472 default: printf ("(unknown virtuality)"); break;
7476 case DW_AT_identifier_case
:
7479 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
7480 case DW_ID_up_case
: printf ("(up_case)"); break;
7481 case DW_ID_down_case
: printf ("(down_case)"); break;
7482 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
7483 default: printf ("(unknown case)"); break;
7487 case DW_AT_calling_convention
:
7490 case DW_CC_normal
: printf ("(normal)"); break;
7491 case DW_CC_program
: printf ("(program)"); break;
7492 case DW_CC_nocall
: printf ("(nocall)"); break;
7494 if (uvalue
>= DW_CC_lo_user
7495 && uvalue
<= DW_CC_hi_user
)
7496 printf ("(user defined)");
7498 printf ("(unknown convention)");
7502 case DW_AT_ordering
:
7505 case -1: printf ("(undefined)"); break;
7506 case 0: printf ("(row major)"); break;
7507 case 1: printf ("(column major)"); break;
7511 case DW_AT_frame_base
:
7512 case DW_AT_location
:
7513 case DW_AT_data_member_location
:
7514 case DW_AT_vtable_elem_location
:
7515 case DW_AT_allocated
:
7516 case DW_AT_associated
:
7517 case DW_AT_data_location
:
7519 case DW_AT_upper_bound
:
7520 case DW_AT_lower_bound
:
7524 decode_location_expression (block_start
, pointer_size
, uvalue
);
7536 static unsigned char *
7537 read_and_display_attr (attribute
, form
, data
, cu_offset
, pointer_size
)
7538 unsigned long attribute
;
7540 unsigned char * data
;
7541 unsigned long cu_offset
;
7542 unsigned long pointer_size
;
7544 printf (" %-18s:", get_AT_name (attribute
));
7545 data
= read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
7552 display_debug_info (section
, start
, file
)
7553 Elf32_Internal_Shdr
* section
;
7554 unsigned char * start
;
7557 unsigned char * end
= start
+ section
->sh_size
;
7558 unsigned char * section_begin
= start
;
7560 printf (_("The section %s contains:\n\n"), SECTION_NAME (section
));
7562 load_debug_str (file
);
7566 DWARF2_External_CompUnit
* external
;
7567 DWARF2_Internal_CompUnit compunit
;
7568 Elf32_Internal_Shdr
* relsec
;
7569 unsigned char * tags
;
7572 unsigned long cu_offset
;
7574 external
= (DWARF2_External_CompUnit
*) start
;
7576 compunit
.cu_length
= BYTE_GET (external
->cu_length
);
7577 compunit
.cu_version
= BYTE_GET (external
->cu_version
);
7578 compunit
.cu_abbrev_offset
= BYTE_GET (external
->cu_abbrev_offset
);
7579 compunit
.cu_pointer_size
= BYTE_GET (external
->cu_pointer_size
);
7581 if (compunit
.cu_length
== 0xffffffff)
7583 warn (_("64-bit DWARF debug info is not supported yet.\n"));
7587 /* Check for RELA relocations in the abbrev_offset address, and
7589 for (relsec
= section_headers
;
7590 relsec
< section_headers
+ elf_header
.e_shnum
;
7593 unsigned long nrelas
;
7594 Elf_Internal_Rela
*rela
, *rp
;
7595 Elf32_Internal_Shdr
*symsec
;
7596 Elf_Internal_Sym
*symtab
;
7597 Elf_Internal_Sym
*sym
;
7599 if (relsec
->sh_type
!= SHT_RELA
7600 || SECTION_HEADER (relsec
->sh_info
) != section
)
7603 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
7607 symsec
= SECTION_HEADER (relsec
->sh_link
);
7608 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
7610 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
7613 != (bfd_vma
) ((unsigned char *) &external
->cu_abbrev_offset
7619 sym
= symtab
+ ELF32_R_SYM (rp
->r_info
);
7621 if (ELF32_ST_TYPE (sym
->st_info
) != STT_SECTION
)
7623 warn (_("Skipping unexpected symbol type %u\n"),
7624 ELF32_ST_TYPE (sym
->st_info
));
7630 sym
= symtab
+ ELF64_R_SYM (rp
->r_info
);
7632 if (ELF64_ST_TYPE (sym
->st_info
) != STT_SECTION
)
7634 warn (_("Skipping unexpected symbol type %u\n"),
7635 ELF64_ST_TYPE (sym
->st_info
));
7640 compunit
.cu_abbrev_offset
+= rp
->r_addend
;
7648 tags
= start
+ sizeof (* external
);
7649 cu_offset
= start
- section_begin
;
7650 start
+= compunit
.cu_length
+ sizeof (external
->cu_length
);
7652 printf (_(" Compilation Unit @ %lx:\n"), cu_offset
);
7653 printf (_(" Length: %ld\n"), compunit
.cu_length
);
7654 printf (_(" Version: %d\n"), compunit
.cu_version
);
7655 printf (_(" Abbrev Offset: %ld\n"), compunit
.cu_abbrev_offset
);
7656 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
7658 if (compunit
.cu_version
!= 2)
7660 warn (_("Only version 2 DWARF debug information is currently supported.\n"));
7666 /* Read in the abbrevs used by this compilation unit. */
7669 Elf32_Internal_Shdr
* sec
;
7670 unsigned char * begin
;
7672 /* Locate the .debug_abbrev section and process it. */
7673 for (i
= 0, sec
= section_headers
;
7674 i
< elf_header
.e_shnum
;
7676 if (strcmp (SECTION_NAME (sec
), ".debug_abbrev") == 0)
7679 if (i
== elf_header
.e_shnum
|| sec
->sh_size
== 0)
7681 warn (_("Unable to locate .debug_abbrev section!\n"));
7685 begin
= ((unsigned char *)
7686 get_data (NULL
, file
, sec
->sh_offset
, sec
->sh_size
,
7687 _("debug_abbrev section data")));
7691 process_abbrev_section (begin
+ compunit
.cu_abbrev_offset
,
7692 begin
+ sec
->sh_size
);
7698 while (tags
< start
)
7701 unsigned long abbrev_number
;
7702 abbrev_entry
* entry
;
7705 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
7708 /* A null DIE marks the end of a list of children. */
7709 if (abbrev_number
== 0)
7715 /* Scan through the abbreviation list until we reach the
7717 for (entry
= first_abbrev
;
7718 entry
&& entry
->entry
!= abbrev_number
;
7719 entry
= entry
->next
)
7724 warn (_("Unable to locate entry %lu in the abbreviation table\n"),
7729 printf (_(" <%d><%lx>: Abbrev Number: %lu (%s)\n"),
7731 (unsigned long) (tags
- section_begin
- bytes_read
),
7733 get_TAG_name (entry
->tag
));
7735 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
7736 tags
= read_and_display_attr (attr
->attribute
,
7739 compunit
.cu_pointer_size
);
7741 if (entry
->children
)
7754 display_debug_aranges (section
, start
, file
)
7755 Elf32_Internal_Shdr
* section
;
7756 unsigned char * start
;
7757 FILE * file ATTRIBUTE_UNUSED
;
7759 unsigned char * end
= start
+ section
->sh_size
;
7761 printf (_("The section %s contains:\n\n"), SECTION_NAME (section
));
7765 DWARF2_External_ARange
* external
;
7766 DWARF2_Internal_ARange arange
;
7767 unsigned char * ranges
;
7768 unsigned long length
;
7769 unsigned long address
;
7772 external
= (DWARF2_External_ARange
*) start
;
7774 arange
.ar_length
= BYTE_GET (external
->ar_length
);
7775 arange
.ar_version
= BYTE_GET (external
->ar_version
);
7776 arange
.ar_info_offset
= BYTE_GET (external
->ar_info_offset
);
7777 arange
.ar_pointer_size
= BYTE_GET (external
->ar_pointer_size
);
7778 arange
.ar_segment_size
= BYTE_GET (external
->ar_segment_size
);
7780 if (arange
.ar_length
== 0xffffffff)
7782 warn (_("64-bit DWARF aranges are not supported yet.\n"));
7786 if (arange
.ar_version
!= 2)
7788 warn (_("Only DWARF 2 aranges are currently supported.\n"));
7792 printf (_(" Length: %ld\n"), arange
.ar_length
);
7793 printf (_(" Version: %d\n"), arange
.ar_version
);
7794 printf (_(" Offset into .debug_info: %lx\n"), arange
.ar_info_offset
);
7795 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
7796 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
7798 printf (_("\n Address Length\n"));
7800 ranges
= start
+ sizeof (* external
);
7802 /* Must pad to an alignment boundary that is twice the pointer size. */
7803 excess
= sizeof (* external
) % (2 * arange
.ar_pointer_size
);
7805 ranges
+= (2 * arange
.ar_pointer_size
) - excess
;
7809 address
= byte_get (ranges
, arange
.ar_pointer_size
);
7811 ranges
+= arange
.ar_pointer_size
;
7813 length
= byte_get (ranges
, arange
.ar_pointer_size
);
7815 ranges
+= arange
.ar_pointer_size
;
7817 /* A pair of zeros marks the end of the list. */
7818 if (address
== 0 && length
== 0)
7821 printf (" %8.8lx %lu\n", address
, length
);
7824 start
+= arange
.ar_length
+ sizeof (external
->ar_length
);
7832 typedef struct Frame_Chunk
7834 struct Frame_Chunk
* next
;
7835 unsigned char * chunk_start
;
7837 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
7838 short int * col_type
;
7840 char * augmentation
;
7841 unsigned int code_factor
;
7843 unsigned long pc_begin
;
7844 unsigned long pc_range
;
7848 unsigned char fde_encoding
;
7852 /* A marker for a col_type that means this column was never referenced
7853 in the frame info. */
7854 #define DW_CFA_unreferenced (-1)
7856 static void frame_need_space
PARAMS ((Frame_Chunk
*, int));
7857 static void frame_display_row
PARAMS ((Frame_Chunk
*, int *, int *));
7858 static int size_of_encoded_value
PARAMS ((int));
7861 frame_need_space (fc
, reg
)
7865 int prev
= fc
->ncols
;
7867 if (reg
< fc
->ncols
)
7870 fc
->ncols
= reg
+ 1;
7871 fc
->col_type
= (short int *) xrealloc (fc
->col_type
,
7872 fc
->ncols
* sizeof (short int));
7873 fc
->col_offset
= (int *) xrealloc (fc
->col_offset
,
7874 fc
->ncols
* sizeof (int));
7876 while (prev
< fc
->ncols
)
7878 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
7879 fc
->col_offset
[prev
] = 0;
7885 frame_display_row (fc
, need_col_headers
, max_regs
)
7887 int * need_col_headers
;
7893 if (* max_regs
< fc
->ncols
)
7894 * max_regs
= fc
->ncols
;
7896 if (* need_col_headers
)
7898 * need_col_headers
= 0;
7900 printf (" LOC CFA ");
7902 for (r
= 0; r
< * max_regs
; r
++)
7903 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
7908 printf ("r%-4d", r
);
7914 printf ("%08lx ", fc
->pc_begin
);
7915 sprintf (tmp
, "r%d%+d", fc
->cfa_reg
, fc
->cfa_offset
);
7916 printf ("%-8s ", tmp
);
7918 for (r
= 0; r
< fc
->ncols
; r
++)
7920 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
7922 switch (fc
->col_type
[r
])
7924 case DW_CFA_undefined
:
7927 case DW_CFA_same_value
:
7931 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
7933 case DW_CFA_register
:
7934 sprintf (tmp
, "r%d", fc
->col_offset
[r
]);
7937 strcpy (tmp
, "n/a");
7940 printf ("%-5s", tmp
);
7947 size_of_encoded_value (encoding
)
7950 switch (encoding
& 0x7)
7953 case 0: return is_32bit_elf
? 4 : 8;
7960 #define GET(N) byte_get (start, N); start += N
7961 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
7962 #define SLEB() read_leb128 (start, & length_return, 1); start += length_return
7965 display_debug_frames (section
, start
, file
)
7966 Elf32_Internal_Shdr
* section
;
7967 unsigned char * start
;
7968 FILE * file ATTRIBUTE_UNUSED
;
7970 unsigned char * end
= start
+ section
->sh_size
;
7971 unsigned char * section_start
= start
;
7972 Frame_Chunk
* chunks
= 0;
7973 Frame_Chunk
* remembered_state
= 0;
7975 int is_eh
= (strcmp (SECTION_NAME (section
), ".eh_frame") == 0);
7978 int addr_size
= is_32bit_elf
? 4 : 8;
7980 printf (_("The section %s contains:\n"), SECTION_NAME (section
));
7984 unsigned char * saved_start
;
7985 unsigned char * block_end
;
7986 unsigned long length
;
7987 unsigned long cie_id
;
7990 int need_col_headers
= 1;
7991 unsigned char * augmentation_data
= NULL
;
7992 unsigned long augmentation_data_len
= 0;
7993 int encoded_ptr_size
= addr_size
;
7995 saved_start
= start
;
7996 length
= byte_get (start
, 4); start
+= 4;
8001 if (length
== 0xffffffff)
8003 warn (_("64-bit DWARF format frames are not supported yet.\n"));
8007 block_end
= saved_start
+ length
+ 4;
8008 cie_id
= byte_get (start
, 4); start
+= 4;
8010 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
8014 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
8015 memset (fc
, 0, sizeof (Frame_Chunk
));
8019 fc
->chunk_start
= saved_start
;
8021 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
8022 fc
->col_offset
= (int *) xmalloc (sizeof (int));
8023 frame_need_space (fc
, max_regs
-1);
8027 fc
->augmentation
= start
;
8028 start
= strchr (start
, '\0') + 1;
8030 if (fc
->augmentation
[0] == 'z')
8032 fc
->code_factor
= LEB ();
8033 fc
->data_factor
= SLEB ();
8034 fc
->ra
= byte_get (start
, 1); start
+= 1;
8035 augmentation_data_len
= LEB ();
8036 augmentation_data
= start
;
8037 start
+= augmentation_data_len
;
8039 else if (strcmp (fc
->augmentation
, "eh") == 0)
8042 fc
->code_factor
= LEB ();
8043 fc
->data_factor
= SLEB ();
8044 fc
->ra
= byte_get (start
, 1); start
+= 1;
8048 fc
->code_factor
= LEB ();
8049 fc
->data_factor
= SLEB ();
8050 fc
->ra
= byte_get (start
, 1); start
+= 1;
8054 if (do_debug_frames_interp
)
8055 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
8056 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
8057 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
8061 printf ("\n%08lx %08lx %08lx CIE\n",
8062 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
8063 printf (" Version: %d\n", version
);
8064 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
8065 printf (" Code alignment factor: %u\n", fc
->code_factor
);
8066 printf (" Data alignment factor: %d\n", fc
->data_factor
);
8067 printf (" Return address column: %d\n", fc
->ra
);
8069 if (augmentation_data_len
)
8072 printf (" Augmentation data: ");
8073 for (i
= 0; i
< augmentation_data_len
; ++i
)
8074 printf (" %02x", augmentation_data
[i
]);
8080 if (augmentation_data_len
)
8082 unsigned char *p
, *q
;
8083 p
= fc
->augmentation
+ 1;
8084 q
= augmentation_data
;
8091 q
+= 1 + size_of_encoded_value (*q
);
8093 fc
->fde_encoding
= *q
++;
8099 if (fc
->fde_encoding
)
8100 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
8103 frame_need_space (fc
, fc
->ra
);
8107 unsigned char * look_for
;
8108 static Frame_Chunk fde_fc
;
8111 memset (fc
, 0, sizeof (Frame_Chunk
));
8113 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
8115 for (cie
= chunks
; cie
; cie
= cie
->next
)
8116 if (cie
->chunk_start
== look_for
)
8121 warn ("Invalid CIE pointer %08lx in FDE at %08lx\n",
8122 cie_id
, saved_start
);
8125 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
8126 fc
->col_offset
= (int *) xmalloc (sizeof (int));
8127 frame_need_space (fc
, max_regs
- 1);
8129 fc
->augmentation
= "";
8130 fc
->fde_encoding
= 0;
8134 fc
->ncols
= cie
->ncols
;
8135 fc
->col_type
= (short int *) xmalloc (fc
->ncols
* sizeof (short int));
8136 fc
->col_offset
= (int *) xmalloc (fc
->ncols
* sizeof (int));
8137 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
8138 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
8139 fc
->augmentation
= cie
->augmentation
;
8140 fc
->code_factor
= cie
->code_factor
;
8141 fc
->data_factor
= cie
->data_factor
;
8142 fc
->cfa_reg
= cie
->cfa_reg
;
8143 fc
->cfa_offset
= cie
->cfa_offset
;
8145 frame_need_space (fc
, max_regs
-1);
8146 fc
->fde_encoding
= cie
->fde_encoding
;
8149 if (fc
->fde_encoding
)
8150 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
8152 fc
->pc_begin
= byte_get (start
, encoded_ptr_size
);
8153 start
+= encoded_ptr_size
;
8154 fc
->pc_range
= byte_get (start
, encoded_ptr_size
);
8155 start
+= encoded_ptr_size
;
8157 if (cie
->augmentation
[0] == 'z')
8159 augmentation_data_len
= LEB ();
8160 augmentation_data
= start
;
8161 start
+= augmentation_data_len
;
8164 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=%08lx..%08lx\n",
8165 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
8166 (unsigned long)(cie
->chunk_start
- section_start
),
8167 fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
8168 if (! do_debug_frames_interp
&& augmentation_data_len
)
8171 printf (" Augmentation data: ");
8172 for (i
= 0; i
< augmentation_data_len
; ++i
)
8173 printf (" %02x", augmentation_data
[i
]);
8179 /* At this point, fc is the current chunk, cie (if any) is set, and we're
8180 about to interpret instructions for the chunk. */
8182 if (do_debug_frames_interp
)
8184 /* Start by making a pass over the chunk, allocating storage
8185 and taking note of what registers are used. */
8186 unsigned char * tmp
= start
;
8188 while (start
< block_end
)
8198 /* Warning: if you add any more cases to this switch, be
8199 sure to add them to the corresponding switch below. */
8202 case DW_CFA_advance_loc
:
8206 frame_need_space (fc
, opa
);
8207 fc
->col_type
[opa
] = DW_CFA_undefined
;
8209 case DW_CFA_restore
:
8210 frame_need_space (fc
, opa
);
8211 fc
->col_type
[opa
] = DW_CFA_undefined
;
8213 case DW_CFA_set_loc
:
8214 start
+= encoded_ptr_size
;
8216 case DW_CFA_advance_loc1
:
8219 case DW_CFA_advance_loc2
:
8222 case DW_CFA_advance_loc4
:
8225 case DW_CFA_offset_extended
:
8226 reg
= LEB (); LEB ();
8227 frame_need_space (fc
, reg
);
8228 fc
->col_type
[reg
] = DW_CFA_undefined
;
8230 case DW_CFA_restore_extended
:
8232 frame_need_space (fc
, reg
);
8233 fc
->col_type
[reg
] = DW_CFA_undefined
;
8235 case DW_CFA_undefined
:
8237 frame_need_space (fc
, reg
);
8238 fc
->col_type
[reg
] = DW_CFA_undefined
;
8240 case DW_CFA_same_value
:
8242 frame_need_space (fc
, reg
);
8243 fc
->col_type
[reg
] = DW_CFA_undefined
;
8245 case DW_CFA_register
:
8246 reg
= LEB (); LEB ();
8247 frame_need_space (fc
, reg
);
8248 fc
->col_type
[reg
] = DW_CFA_undefined
;
8250 case DW_CFA_def_cfa
:
8253 case DW_CFA_def_cfa_register
:
8256 case DW_CFA_def_cfa_offset
:
8259 #ifndef DW_CFA_GNU_args_size
8260 #define DW_CFA_GNU_args_size 0x2e
8262 case DW_CFA_GNU_args_size
:
8265 #ifndef DW_CFA_GNU_negative_offset_extended
8266 #define DW_CFA_GNU_negative_offset_extended 0x2f
8268 case DW_CFA_GNU_negative_offset_extended
:
8269 reg
= LEB (); LEB ();
8270 frame_need_space (fc
, reg
);
8271 fc
->col_type
[reg
] = DW_CFA_undefined
;
8280 /* Now we know what registers are used, make a second pass over
8281 the chunk, this time actually printing out the info. */
8283 while (start
< block_end
)
8286 unsigned long ul
, reg
, roffs
;
8295 /* Warning: if you add any more cases to this switch, be
8296 sure to add them to the corresponding switch above. */
8299 case DW_CFA_advance_loc
:
8300 if (do_debug_frames_interp
)
8301 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8303 printf (" DW_CFA_advance_loc: %d to %08lx\n",
8304 opa
* fc
->code_factor
,
8305 fc
->pc_begin
+ opa
* fc
->code_factor
);
8306 fc
->pc_begin
+= opa
* fc
->code_factor
;
8311 if (! do_debug_frames_interp
)
8312 printf (" DW_CFA_offset: r%d at cfa%+ld\n",
8313 opa
, roffs
* fc
->data_factor
);
8314 fc
->col_type
[opa
] = DW_CFA_offset
;
8315 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
8318 case DW_CFA_restore
:
8319 if (! do_debug_frames_interp
)
8320 printf (" DW_CFA_restore: r%d\n", opa
);
8321 fc
->col_type
[opa
] = cie
->col_type
[opa
];
8322 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
8325 case DW_CFA_set_loc
:
8326 vma
= byte_get (start
, encoded_ptr_size
);
8327 start
+= encoded_ptr_size
;
8328 if (do_debug_frames_interp
)
8329 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8331 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
8335 case DW_CFA_advance_loc1
:
8336 ofs
= byte_get (start
, 1); start
+= 1;
8337 if (do_debug_frames_interp
)
8338 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8340 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
8341 ofs
* fc
->code_factor
,
8342 fc
->pc_begin
+ ofs
* fc
->code_factor
);
8343 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8346 case DW_CFA_advance_loc2
:
8347 ofs
= byte_get (start
, 2); start
+= 2;
8348 if (do_debug_frames_interp
)
8349 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8351 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
8352 ofs
* fc
->code_factor
,
8353 fc
->pc_begin
+ ofs
* fc
->code_factor
);
8354 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8357 case DW_CFA_advance_loc4
:
8358 ofs
= byte_get (start
, 4); start
+= 4;
8359 if (do_debug_frames_interp
)
8360 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8362 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
8363 ofs
* fc
->code_factor
,
8364 fc
->pc_begin
+ ofs
* fc
->code_factor
);
8365 fc
->pc_begin
+= ofs
* fc
->code_factor
;
8368 case DW_CFA_offset_extended
:
8371 if (! do_debug_frames_interp
)
8372 printf (" DW_CFA_offset_extended: r%ld at cfa%+ld\n",
8373 reg
, roffs
* fc
->data_factor
);
8374 fc
->col_type
[reg
] = DW_CFA_offset
;
8375 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
8378 case DW_CFA_restore_extended
:
8380 if (! do_debug_frames_interp
)
8381 printf (" DW_CFA_restore_extended: r%ld\n", reg
);
8382 fc
->col_type
[reg
] = cie
->col_type
[reg
];
8383 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
8386 case DW_CFA_undefined
:
8388 if (! do_debug_frames_interp
)
8389 printf (" DW_CFA_undefined: r%ld\n", reg
);
8390 fc
->col_type
[reg
] = DW_CFA_undefined
;
8391 fc
->col_offset
[reg
] = 0;
8394 case DW_CFA_same_value
:
8396 if (! do_debug_frames_interp
)
8397 printf (" DW_CFA_same_value: r%ld\n", reg
);
8398 fc
->col_type
[reg
] = DW_CFA_same_value
;
8399 fc
->col_offset
[reg
] = 0;
8402 case DW_CFA_register
:
8405 if (! do_debug_frames_interp
)
8406 printf (" DW_CFA_register: r%ld\n", reg
);
8407 fc
->col_type
[reg
] = DW_CFA_register
;
8408 fc
->col_offset
[reg
] = roffs
;
8411 case DW_CFA_remember_state
:
8412 if (! do_debug_frames_interp
)
8413 printf (" DW_CFA_remember_state\n");
8414 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
8415 rs
->ncols
= fc
->ncols
;
8416 rs
->col_type
= (short int *) xmalloc (rs
->ncols
* sizeof (short int));
8417 rs
->col_offset
= (int *) xmalloc (rs
->ncols
* sizeof (int));
8418 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
8419 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
8420 rs
->next
= remembered_state
;
8421 remembered_state
= rs
;
8424 case DW_CFA_restore_state
:
8425 if (! do_debug_frames_interp
)
8426 printf (" DW_CFA_restore_state\n");
8427 rs
= remembered_state
;
8428 remembered_state
= rs
->next
;
8429 frame_need_space (fc
, rs
->ncols
-1);
8430 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
8431 memcpy (fc
->col_offset
, rs
->col_offset
, rs
->ncols
* sizeof (int));
8432 free (rs
->col_type
);
8433 free (rs
->col_offset
);
8437 case DW_CFA_def_cfa
:
8438 fc
->cfa_reg
= LEB ();
8439 fc
->cfa_offset
= LEB ();
8440 if (! do_debug_frames_interp
)
8441 printf (" DW_CFA_def_cfa: r%d ofs %d\n",
8442 fc
->cfa_reg
, fc
->cfa_offset
);
8445 case DW_CFA_def_cfa_register
:
8446 fc
->cfa_reg
= LEB ();
8447 if (! do_debug_frames_interp
)
8448 printf (" DW_CFA_def_cfa_reg: r%d\n", fc
->cfa_reg
);
8451 case DW_CFA_def_cfa_offset
:
8452 fc
->cfa_offset
= LEB ();
8453 if (! do_debug_frames_interp
)
8454 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
8458 if (! do_debug_frames_interp
)
8459 printf (" DW_CFA_nop\n");
8462 #ifndef DW_CFA_GNU_window_save
8463 #define DW_CFA_GNU_window_save 0x2d
8465 case DW_CFA_GNU_window_save
:
8466 if (! do_debug_frames_interp
)
8467 printf (" DW_CFA_GNU_window_save\n");
8470 case DW_CFA_GNU_args_size
:
8472 if (! do_debug_frames_interp
)
8473 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
8476 case DW_CFA_GNU_negative_offset_extended
:
8479 frame_need_space (fc
, reg
);
8480 if (! do_debug_frames_interp
)
8481 printf (" DW_CFA_GNU_negative_offset_extended: r%ld at cfa%+ld\n",
8482 reg
, l
* fc
->data_factor
);
8483 fc
->col_type
[reg
] = DW_CFA_offset
;
8484 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
8488 fprintf (stderr
, "unsupported or unknown DW_CFA_%d\n", op
);
8493 if (do_debug_frames_interp
)
8494 frame_display_row (fc
, &need_col_headers
, &max_regs
);
8509 display_debug_not_supported (section
, start
, file
)
8510 Elf32_Internal_Shdr
* section
;
8511 unsigned char * start ATTRIBUTE_UNUSED
;
8512 FILE * file ATTRIBUTE_UNUSED
;
8514 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
8515 SECTION_NAME (section
));
8520 /* Pre-scan the .debug_info section to record the size of address.
8521 When dumping the .debug_line, we use that size information, assuming
8522 that all compilation units have the same address size. */
8524 prescan_debug_info (section
, start
, file
)
8525 Elf32_Internal_Shdr
* section ATTRIBUTE_UNUSED
;
8526 unsigned char * start
;
8527 FILE * file ATTRIBUTE_UNUSED
;
8529 DWARF2_External_CompUnit
* external
;
8531 external
= (DWARF2_External_CompUnit
*) start
;
8533 debug_line_pointer_size
= BYTE_GET (external
->cu_pointer_size
);
8537 /* A structure containing the name of a debug section and a pointer
8538 to a function that can decode it. The third field is a prescan
8539 function to be run over the section before displaying any of the
8543 const char * const name
;
8544 int (* display
) PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
8545 int (* prescan
) PARAMS ((Elf32_Internal_Shdr
*, unsigned char *, FILE *));
8549 { ".debug_abbrev", display_debug_abbrev
, NULL
},
8550 { ".debug_aranges", display_debug_aranges
, NULL
},
8551 { ".debug_frame", display_debug_frames
, NULL
},
8552 { ".debug_info", display_debug_info
, prescan_debug_info
},
8553 { ".debug_line", display_debug_lines
, NULL
},
8554 { ".debug_pubnames", display_debug_pubnames
, NULL
},
8555 { ".eh_frame", display_debug_frames
, NULL
},
8556 { ".debug_macinfo", display_debug_macinfo
, NULL
},
8557 { ".debug_str", display_debug_str
, NULL
},
8559 { ".debug_pubtypes", display_debug_not_supported
, NULL
},
8560 { ".debug_ranges", display_debug_not_supported
, NULL
},
8561 { ".debug_static_func", display_debug_not_supported
, NULL
},
8562 { ".debug_static_vars", display_debug_not_supported
, NULL
},
8563 { ".debug_types", display_debug_not_supported
, NULL
},
8564 { ".debug_weaknames", display_debug_not_supported
, NULL
}
8568 display_debug_section (section
, file
)
8569 Elf32_Internal_Shdr
* section
;
8572 char * name
= SECTION_NAME (section
);
8573 bfd_size_type length
;
8574 unsigned char * start
;
8577 length
= section
->sh_size
;
8580 printf (_("\nSection '%s' has no debugging data.\n"), name
);
8584 start
= (unsigned char *) get_data (NULL
, file
, section
->sh_offset
, length
,
8585 _("debug section data"));
8589 /* See if we know how to display the contents of this section. */
8590 if (strncmp (name
, ".gnu.linkonce.wi.", 17) == 0)
8591 name
= ".debug_info";
8593 for (i
= NUM_ELEM (debug_displays
); i
--;)
8594 if (strcmp (debug_displays
[i
].name
, name
) == 0)
8596 debug_displays
[i
].display (section
, start
, file
);
8601 printf (_("Unrecognised debug section: %s\n"), name
);
8605 /* If we loaded in the abbrev section at some point,
8606 we must release it here. */
8613 process_section_contents (file
)
8616 Elf32_Internal_Shdr
* section
;
8622 /* Pre-scan the debug sections to find some debug information not
8623 present in some of them. For the .debug_line, we must find out the
8624 size of address (specified in .debug_info and .debug_aranges). */
8625 for (i
= 0, section
= section_headers
;
8626 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
8629 char * name
= SECTION_NAME (section
);
8632 if (section
->sh_size
== 0)
8635 /* See if there is some pre-scan operation for this section. */
8636 for (j
= NUM_ELEM (debug_displays
); j
--;)
8637 if (strcmp (debug_displays
[j
].name
, name
) == 0)
8639 if (debug_displays
[j
].prescan
!= NULL
)
8641 bfd_size_type length
;
8642 unsigned char * start
;
8644 length
= section
->sh_size
;
8645 start
= ((unsigned char *)
8646 get_data (NULL
, file
, section
->sh_offset
, length
,
8647 _("debug section data")));
8651 debug_displays
[j
].prescan (section
, start
, file
);
8659 for (i
= 0, section
= section_headers
;
8660 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
8663 #ifdef SUPPORT_DISASSEMBLY
8664 if (dump_sects
[i
] & DISASS_DUMP
)
8665 disassemble_section (section
, file
);
8667 if (dump_sects
[i
] & HEX_DUMP
)
8668 dump_section (section
, file
);
8670 if (dump_sects
[i
] & DEBUG_DUMP
)
8671 display_debug_section (section
, file
);
8674 if (i
< num_dump_sects
)
8675 warn (_("Some sections were not dumped because they do not exist!\n"));
8681 process_mips_fpe_exception (mask
)
8687 if (mask
& OEX_FPU_INEX
)
8688 fputs ("INEX", stdout
), first
= 0;
8689 if (mask
& OEX_FPU_UFLO
)
8690 printf ("%sUFLO", first
? "" : "|"), first
= 0;
8691 if (mask
& OEX_FPU_OFLO
)
8692 printf ("%sOFLO", first
? "" : "|"), first
= 0;
8693 if (mask
& OEX_FPU_DIV0
)
8694 printf ("%sDIV0", first
? "" : "|"), first
= 0;
8695 if (mask
& OEX_FPU_INVAL
)
8696 printf ("%sINVAL", first
? "" : "|");
8699 fputs ("0", stdout
);
8703 process_mips_specific (file
)
8706 Elf_Internal_Dyn
* entry
;
8707 size_t liblist_offset
= 0;
8708 size_t liblistno
= 0;
8709 size_t conflictsno
= 0;
8710 size_t options_offset
= 0;
8711 size_t conflicts_offset
= 0;
8713 /* We have a lot of special sections. Thanks SGI! */
8714 if (dynamic_segment
== NULL
)
8715 /* No information available. */
8718 for (entry
= dynamic_segment
; entry
->d_tag
!= DT_NULL
; ++entry
)
8719 switch (entry
->d_tag
)
8721 case DT_MIPS_LIBLIST
:
8722 liblist_offset
= entry
->d_un
.d_val
- loadaddr
;
8724 case DT_MIPS_LIBLISTNO
:
8725 liblistno
= entry
->d_un
.d_val
;
8727 case DT_MIPS_OPTIONS
:
8728 options_offset
= entry
->d_un
.d_val
- loadaddr
;
8730 case DT_MIPS_CONFLICT
:
8731 conflicts_offset
= entry
->d_un
.d_val
- loadaddr
;
8733 case DT_MIPS_CONFLICTNO
:
8734 conflictsno
= entry
->d_un
.d_val
;
8740 if (liblist_offset
!= 0 && liblistno
!= 0 && do_dynamic
)
8742 Elf32_External_Lib
* elib
;
8745 elib
= ((Elf32_External_Lib
*)
8746 get_data (NULL
, file
, liblist_offset
,
8747 liblistno
* sizeof (Elf32_External_Lib
),
8751 printf ("\nSection '.liblist' contains %lu entries:\n",
8752 (unsigned long) liblistno
);
8753 fputs (" Library Time Stamp Checksum Version Flags\n",
8756 for (cnt
= 0; cnt
< liblistno
; ++cnt
)
8763 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
8764 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
8765 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
8766 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
8767 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
8769 tmp
= gmtime (&time
);
8770 sprintf (timebuf
, "%04u-%02u-%02uT%02u:%02u:%02u",
8771 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
8772 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
8774 printf ("%3lu: ", (unsigned long) cnt
);
8775 print_symbol (20, dynamic_strings
+ liblist
.l_name
);
8776 printf (" %s %#10lx %-7ld", timebuf
, liblist
.l_checksum
,
8779 if (liblist
.l_flags
== 0)
8790 { " EXACT_MATCH", LL_EXACT_MATCH
},
8791 { " IGNORE_INT_VER", LL_IGNORE_INT_VER
},
8792 { " REQUIRE_MINOR", LL_REQUIRE_MINOR
},
8793 { " EXPORTS", LL_EXPORTS
},
8794 { " DELAY_LOAD", LL_DELAY_LOAD
},
8795 { " DELTA", LL_DELTA
}
8797 int flags
= liblist
.l_flags
;
8801 fcnt
< sizeof (l_flags_vals
) / sizeof (l_flags_vals
[0]);
8803 if ((flags
& l_flags_vals
[fcnt
].bit
) != 0)
8805 fputs (l_flags_vals
[fcnt
].name
, stdout
);
8806 flags
^= l_flags_vals
[fcnt
].bit
;
8809 printf (" %#x", (unsigned int) flags
);
8819 if (options_offset
!= 0)
8821 Elf_External_Options
* eopt
;
8822 Elf_Internal_Shdr
* sect
= section_headers
;
8823 Elf_Internal_Options
* iopt
;
8824 Elf_Internal_Options
* option
;
8828 /* Find the section header so that we get the size. */
8829 while (sect
->sh_type
!= SHT_MIPS_OPTIONS
)
8832 eopt
= (Elf_External_Options
*) get_data (NULL
, file
, options_offset
,
8833 sect
->sh_size
, _("options"));
8836 iopt
= ((Elf_Internal_Options
*)
8837 malloc ((sect
->sh_size
/ sizeof (eopt
)) * sizeof (* iopt
)));
8840 error (_("Out of memory"));
8847 while (offset
< sect
->sh_size
)
8849 Elf_External_Options
* eoption
;
8851 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
8853 option
->kind
= BYTE_GET (eoption
->kind
);
8854 option
->size
= BYTE_GET (eoption
->size
);
8855 option
->section
= BYTE_GET (eoption
->section
);
8856 option
->info
= BYTE_GET (eoption
->info
);
8858 offset
+= option
->size
;
8864 printf (_("\nSection '%s' contains %d entries:\n"),
8865 SECTION_NAME (sect
), cnt
);
8873 switch (option
->kind
)
8876 /* This shouldn't happen. */
8877 printf (" NULL %d %lx", option
->section
, option
->info
);
8880 printf (" REGINFO ");
8881 if (elf_header
.e_machine
== EM_MIPS
)
8884 Elf32_External_RegInfo
* ereg
;
8885 Elf32_RegInfo reginfo
;
8887 ereg
= (Elf32_External_RegInfo
*) (option
+ 1);
8888 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8889 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8890 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8891 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8892 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8893 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
8895 printf ("GPR %08lx GP 0x%lx\n",
8897 (unsigned long) reginfo
.ri_gp_value
);
8898 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8899 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8900 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8905 Elf64_External_RegInfo
* ereg
;
8906 Elf64_Internal_RegInfo reginfo
;
8908 ereg
= (Elf64_External_RegInfo
*) (option
+ 1);
8909 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8910 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8911 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8912 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8913 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8914 reginfo
.ri_gp_value
= BYTE_GET8 (ereg
->ri_gp_value
);
8916 printf ("GPR %08lx GP 0x",
8917 reginfo
.ri_gprmask
);
8918 printf_vma (reginfo
.ri_gp_value
);
8921 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8922 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8923 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8927 case ODK_EXCEPTIONS
:
8928 fputs (" EXCEPTIONS fpe_min(", stdout
);
8929 process_mips_fpe_exception (option
->info
& OEX_FPU_MIN
);
8930 fputs (") fpe_max(", stdout
);
8931 process_mips_fpe_exception ((option
->info
& OEX_FPU_MAX
) >> 8);
8932 fputs (")", stdout
);
8934 if (option
->info
& OEX_PAGE0
)
8935 fputs (" PAGE0", stdout
);
8936 if (option
->info
& OEX_SMM
)
8937 fputs (" SMM", stdout
);
8938 if (option
->info
& OEX_FPDBUG
)
8939 fputs (" FPDBUG", stdout
);
8940 if (option
->info
& OEX_DISMISS
)
8941 fputs (" DISMISS", stdout
);
8944 fputs (" PAD ", stdout
);
8945 if (option
->info
& OPAD_PREFIX
)
8946 fputs (" PREFIX", stdout
);
8947 if (option
->info
& OPAD_POSTFIX
)
8948 fputs (" POSTFIX", stdout
);
8949 if (option
->info
& OPAD_SYMBOL
)
8950 fputs (" SYMBOL", stdout
);
8953 fputs (" HWPATCH ", stdout
);
8954 if (option
->info
& OHW_R4KEOP
)
8955 fputs (" R4KEOP", stdout
);
8956 if (option
->info
& OHW_R8KPFETCH
)
8957 fputs (" R8KPFETCH", stdout
);
8958 if (option
->info
& OHW_R5KEOP
)
8959 fputs (" R5KEOP", stdout
);
8960 if (option
->info
& OHW_R5KCVTL
)
8961 fputs (" R5KCVTL", stdout
);
8964 fputs (" FILL ", stdout
);
8965 /* XXX Print content of info word? */
8968 fputs (" TAGS ", stdout
);
8969 /* XXX Print content of info word? */
8972 fputs (" HWAND ", stdout
);
8973 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8974 fputs (" R4KEOP_CHECKED", stdout
);
8975 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8976 fputs (" R4KEOP_CLEAN", stdout
);
8979 fputs (" HWOR ", stdout
);
8980 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8981 fputs (" R4KEOP_CHECKED", stdout
);
8982 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8983 fputs (" R4KEOP_CLEAN", stdout
);
8986 printf (" GP_GROUP %#06lx self-contained %#06lx",
8987 option
->info
& OGP_GROUP
,
8988 (option
->info
& OGP_SELF
) >> 16);
8991 printf (" IDENT %#06lx self-contained %#06lx",
8992 option
->info
& OGP_GROUP
,
8993 (option
->info
& OGP_SELF
) >> 16);
8996 /* This shouldn't happen. */
8997 printf (" %3d ??? %d %lx",
8998 option
->kind
, option
->section
, option
->info
);
9002 len
= sizeof (* eopt
);
9003 while (len
< option
->size
)
9004 if (((char *) option
)[len
] >= ' '
9005 && ((char *) option
)[len
] < 0x7f)
9006 printf ("%c", ((char *) option
)[len
++]);
9008 printf ("\\%03o", ((char *) option
)[len
++]);
9010 fputs ("\n", stdout
);
9018 if (conflicts_offset
!= 0 && conflictsno
!= 0)
9020 Elf32_Conflict
* iconf
;
9023 if (dynamic_symbols
== NULL
)
9025 error (_("conflict list with without table"));
9029 iconf
= (Elf32_Conflict
*) malloc (conflictsno
* sizeof (* iconf
));
9032 error (_("Out of memory"));
9038 Elf32_External_Conflict
* econf32
;
9040 econf32
= ((Elf32_External_Conflict
*)
9041 get_data (NULL
, file
, conflicts_offset
,
9042 conflictsno
* sizeof (* econf32
),
9047 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
9048 iconf
[cnt
] = BYTE_GET (econf32
[cnt
]);
9054 Elf64_External_Conflict
* econf64
;
9056 econf64
= ((Elf64_External_Conflict
*)
9057 get_data (NULL
, file
, conflicts_offset
,
9058 conflictsno
* sizeof (* econf64
),
9063 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
9064 iconf
[cnt
] = BYTE_GET (econf64
[cnt
]);
9069 printf (_("\nSection '.conflict' contains %ld entries:\n"),
9070 (long) conflictsno
);
9071 puts (_(" Num: Index Value Name"));
9073 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
9075 Elf_Internal_Sym
* psym
= & dynamic_symbols
[iconf
[cnt
]];
9077 printf ("%5lu: %8lu ", (unsigned long) cnt
, iconf
[cnt
]);
9078 print_vma (psym
->st_value
, FULL_HEX
);
9080 print_symbol (25, dynamic_strings
+ psym
->st_name
);
9091 get_note_type (e_type
)
9094 static char buff
[64];
9098 case NT_PRSTATUS
: return _("NT_PRSTATUS (prstatus structure)");
9099 case NT_FPREGSET
: return _("NT_FPREGSET (floating point registers)");
9100 case NT_PRPSINFO
: return _("NT_PRPSINFO (prpsinfo structure)");
9101 case NT_TASKSTRUCT
: return _("NT_TASKSTRUCT (task structure)");
9102 case NT_PRXFPREG
: return _("NT_PRXFPREG (user_xfpregs structure)");
9103 case NT_PSTATUS
: return _("NT_PSTATUS (pstatus structure)");
9104 case NT_FPREGS
: return _("NT_FPREGS (floating point registers)");
9105 case NT_PSINFO
: return _("NT_PSINFO (psinfo structure)");
9106 case NT_LWPSTATUS
: return _("NT_LWPSTATUS (lwpstatus_t structure)");
9107 case NT_LWPSINFO
: return _("NT_LWPSINFO (lwpsinfo_t structure)");
9108 case NT_WIN32PSTATUS
: return _("NT_WIN32PSTATUS (win32_pstatus strcuture)");
9110 sprintf (buff
, _("Unknown note type: (0x%08x)"), e_type
);
9116 get_netbsd_elfcore_note_type (e_type
)
9119 static char buff
[64];
9121 if (e_type
== NT_NETBSDCORE_PROCINFO
)
9123 /* NetBSD core "procinfo" structure. */
9124 return _("NetBSD procinfo structure");
9127 /* As of Jan 2002 there are no other machine-independent notes
9128 defined for NetBSD core files. If the note type is less
9129 than the start of the machine-dependent note types, we don't
9132 if (e_type
< NT_NETBSDCORE_FIRSTMACH
)
9134 sprintf (buff
, _("Unknown note type: (0x%08x)"), e_type
);
9138 switch (elf_header
.e_machine
)
9140 /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0
9141 and PT_GETFPREGS == mach+2. */
9146 case EM_SPARC32PLUS
:
9150 case NT_NETBSDCORE_FIRSTMACH
+0:
9151 return _("PT_GETREGS (reg structure)");
9152 case NT_NETBSDCORE_FIRSTMACH
+2:
9153 return _("PT_GETFPREGS (fpreg structure)");
9159 /* On all other arch's, PT_GETREGS == mach+1 and
9160 PT_GETFPREGS == mach+3. */
9164 case NT_NETBSDCORE_FIRSTMACH
+1:
9165 return _("PT_GETREGS (reg structure)");
9166 case NT_NETBSDCORE_FIRSTMACH
+3:
9167 return _("PT_GETFPREGS (fpreg structure)");
9173 sprintf (buff
, _("PT_FIRSTMACH+%d"), e_type
- NT_NETBSDCORE_FIRSTMACH
);
9177 /* Note that by the ELF standard, the name field is already null byte
9178 terminated, and namesz includes the terminating null byte.
9179 I.E. the value of namesz for the name "FSF" is 4.
9181 If the value of namesz is zero, there is no name present. */
9183 process_note (pnote
)
9184 Elf32_Internal_Note
* pnote
;
9188 if (pnote
->namesz
== 0)
9190 /* If there is no note name, then use the default set of
9191 note type strings. */
9192 nt
= get_note_type (pnote
->type
);
9194 else if (strncmp (pnote
->namedata
, "NetBSD-CORE", 11) == 0)
9196 /* NetBSD-specific core file notes. */
9197 nt
= get_netbsd_elfcore_note_type (pnote
->type
);
9201 /* Don't recognize this note name; just use the default set of
9202 note type strings. */
9203 nt
= get_note_type (pnote
->type
);
9206 printf (" %s\t\t0x%08lx\t%s\n",
9207 pnote
->namesz
? pnote
->namedata
: "(NONE)",
9214 process_corefile_note_segment (file
, offset
, length
)
9219 Elf_External_Note
* pnotes
;
9220 Elf_External_Note
* external
;
9226 pnotes
= (Elf_External_Note
*) get_data (NULL
, file
, offset
, length
,
9233 printf (_("\nNotes at offset 0x%08lx with length 0x%08lx:\n"),
9234 (unsigned long) offset
, (unsigned long) length
);
9235 printf (_(" Owner\t\tData size\tDescription\n"));
9237 while (external
< (Elf_External_Note
*)((char *) pnotes
+ length
))
9239 Elf32_Internal_Note inote
;
9242 inote
.type
= BYTE_GET (external
->type
);
9243 inote
.namesz
= BYTE_GET (external
->namesz
);
9244 inote
.namedata
= external
->name
;
9245 inote
.descsz
= BYTE_GET (external
->descsz
);
9246 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 2);
9247 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
9249 external
= (Elf_External_Note
*)(inote
.descdata
+ align_power (inote
.descsz
, 2));
9251 /* Verify that name is null terminated. It appears that at least
9252 one version of Linux (RedHat 6.0) generates corefiles that don't
9253 comply with the ELF spec by failing to include the null byte in
9255 if (inote
.namedata
[inote
.namesz
] != '\0')
9257 temp
= malloc (inote
.namesz
+ 1);
9261 error (_("Out of memory\n"));
9266 strncpy (temp
, inote
.namedata
, inote
.namesz
);
9267 temp
[inote
.namesz
] = 0;
9269 /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */
9270 inote
.namedata
= temp
;
9273 res
&= process_note (& inote
);
9288 process_corefile_note_segments (file
)
9291 Elf_Internal_Phdr
* program_headers
;
9292 Elf_Internal_Phdr
* segment
;
9296 program_headers
= (Elf_Internal_Phdr
*) malloc
9297 (elf_header
.e_phnum
* sizeof (Elf_Internal_Phdr
));
9299 if (program_headers
== NULL
)
9301 error (_("Out of memory\n"));
9306 i
= get_32bit_program_headers (file
, program_headers
);
9308 i
= get_64bit_program_headers (file
, program_headers
);
9312 free (program_headers
);
9316 for (i
= 0, segment
= program_headers
;
9317 i
< elf_header
.e_phnum
;
9320 if (segment
->p_type
== PT_NOTE
)
9321 res
&= process_corefile_note_segment (file
,
9322 (bfd_vma
) segment
->p_offset
,
9323 (bfd_vma
) segment
->p_filesz
);
9326 free (program_headers
);
9332 process_corefile_contents (file
)
9335 /* If we have not been asked to display the notes then do nothing. */
9339 /* If file is not a core file then exit. */
9340 if (elf_header
.e_type
!= ET_CORE
)
9343 /* No program headers means no NOTE segment. */
9344 if (elf_header
.e_phnum
== 0)
9346 printf (_("No note segments present in the core file.\n"));
9350 return process_corefile_note_segments (file
);
9354 process_arch_specific (file
)
9360 switch (elf_header
.e_machine
)
9363 case EM_MIPS_RS3_LE
:
9364 return process_mips_specific (file
);
9373 get_file_header (file
)
9376 /* Read in the identity array. */
9377 if (fread (elf_header
.e_ident
, EI_NIDENT
, 1, file
) != 1)
9380 /* Determine how to read the rest of the header. */
9381 switch (elf_header
.e_ident
[EI_DATA
])
9383 default: /* fall through */
9384 case ELFDATANONE
: /* fall through */
9385 case ELFDATA2LSB
: byte_get
= byte_get_little_endian
; break;
9386 case ELFDATA2MSB
: byte_get
= byte_get_big_endian
; break;
9389 /* For now we only support 32 bit and 64 bit ELF files. */
9390 is_32bit_elf
= (elf_header
.e_ident
[EI_CLASS
] != ELFCLASS64
);
9392 /* Read in the rest of the header. */
9395 Elf32_External_Ehdr ehdr32
;
9397 if (fread (ehdr32
.e_type
, sizeof (ehdr32
) - EI_NIDENT
, 1, file
) != 1)
9400 elf_header
.e_type
= BYTE_GET (ehdr32
.e_type
);
9401 elf_header
.e_machine
= BYTE_GET (ehdr32
.e_machine
);
9402 elf_header
.e_version
= BYTE_GET (ehdr32
.e_version
);
9403 elf_header
.e_entry
= BYTE_GET (ehdr32
.e_entry
);
9404 elf_header
.e_phoff
= BYTE_GET (ehdr32
.e_phoff
);
9405 elf_header
.e_shoff
= BYTE_GET (ehdr32
.e_shoff
);
9406 elf_header
.e_flags
= BYTE_GET (ehdr32
.e_flags
);
9407 elf_header
.e_ehsize
= BYTE_GET (ehdr32
.e_ehsize
);
9408 elf_header
.e_phentsize
= BYTE_GET (ehdr32
.e_phentsize
);
9409 elf_header
.e_phnum
= BYTE_GET (ehdr32
.e_phnum
);
9410 elf_header
.e_shentsize
= BYTE_GET (ehdr32
.e_shentsize
);
9411 elf_header
.e_shnum
= BYTE_GET (ehdr32
.e_shnum
);
9412 elf_header
.e_shstrndx
= BYTE_GET (ehdr32
.e_shstrndx
);
9416 Elf64_External_Ehdr ehdr64
;
9418 /* If we have been compiled with sizeof (bfd_vma) == 4, then
9419 we will not be able to cope with the 64bit data found in
9420 64 ELF files. Detect this now and abort before we start
9421 overwritting things. */
9422 if (sizeof (bfd_vma
) < 8)
9424 error (_("This instance of readelf has been built without support for a\n\
9425 64 bit data type and so it cannot read 64 bit ELF files.\n"));
9429 if (fread (ehdr64
.e_type
, sizeof (ehdr64
) - EI_NIDENT
, 1, file
) != 1)
9432 elf_header
.e_type
= BYTE_GET (ehdr64
.e_type
);
9433 elf_header
.e_machine
= BYTE_GET (ehdr64
.e_machine
);
9434 elf_header
.e_version
= BYTE_GET (ehdr64
.e_version
);
9435 elf_header
.e_entry
= BYTE_GET8 (ehdr64
.e_entry
);
9436 elf_header
.e_phoff
= BYTE_GET8 (ehdr64
.e_phoff
);
9437 elf_header
.e_shoff
= BYTE_GET8 (ehdr64
.e_shoff
);
9438 elf_header
.e_flags
= BYTE_GET (ehdr64
.e_flags
);
9439 elf_header
.e_ehsize
= BYTE_GET (ehdr64
.e_ehsize
);
9440 elf_header
.e_phentsize
= BYTE_GET (ehdr64
.e_phentsize
);
9441 elf_header
.e_phnum
= BYTE_GET (ehdr64
.e_phnum
);
9442 elf_header
.e_shentsize
= BYTE_GET (ehdr64
.e_shentsize
);
9443 elf_header
.e_shnum
= BYTE_GET (ehdr64
.e_shnum
);
9444 elf_header
.e_shstrndx
= BYTE_GET (ehdr64
.e_shstrndx
);
9447 /* There may be some extensions in the first section header. Don't
9448 bomb if we can't read it. */
9450 get_32bit_section_headers (file
, 1);
9452 get_64bit_section_headers (file
, 1);
9458 process_file (file_name
)
9462 struct stat statbuf
;
9465 if (stat (file_name
, & statbuf
) < 0)
9467 error (_("Cannot stat input file %s.\n"), file_name
);
9471 file
= fopen (file_name
, "rb");
9474 error (_("Input file %s not found.\n"), file_name
);
9478 if (! get_file_header (file
))
9480 error (_("%s: Failed to read file header\n"), file_name
);
9485 /* Initialise per file variables. */
9486 for (i
= NUM_ELEM (version_info
); i
--;)
9487 version_info
[i
] = 0;
9489 for (i
= NUM_ELEM (dynamic_info
); i
--;)
9490 dynamic_info
[i
] = 0;
9492 /* Process the file. */
9494 printf (_("\nFile: %s\n"), file_name
);
9496 if (! process_file_header ())
9502 process_section_headers (file
);
9504 process_program_headers (file
);
9506 process_dynamic_segment (file
);
9508 process_relocs (file
);
9510 process_unwind (file
);
9512 process_symbol_table (file
);
9514 process_syminfo (file
);
9516 process_version_sections (file
);
9518 process_section_contents (file
);
9520 process_corefile_contents (file
);
9522 process_arch_specific (file
);
9526 if (section_headers
)
9528 free (section_headers
);
9529 section_headers
= NULL
;
9534 free (string_table
);
9535 string_table
= NULL
;
9536 string_table_length
= 0;
9539 if (dynamic_strings
)
9541 free (dynamic_strings
);
9542 dynamic_strings
= NULL
;
9545 if (dynamic_symbols
)
9547 free (dynamic_symbols
);
9548 dynamic_symbols
= NULL
;
9549 num_dynamic_syms
= 0;
9552 if (dynamic_syminfo
)
9554 free (dynamic_syminfo
);
9555 dynamic_syminfo
= NULL
;
9561 #ifdef SUPPORT_DISASSEMBLY
9562 /* Needed by the i386 disassembler. For extra credit, someone could
9563 fix this so that we insert symbolic addresses here, esp for GOT/PLT
9567 print_address (unsigned int addr
, FILE * outfile
)
9569 fprintf (outfile
,"0x%8.8x", addr
);
9572 /* Needed by the i386 disassembler. */
9574 db_task_printsym (unsigned int addr
)
9576 print_address (addr
, stderr
);
9580 int main
PARAMS ((int, char **));
9589 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
9590 setlocale (LC_MESSAGES
, "");
9592 #if defined (HAVE_SETLOCALE)
9593 setlocale (LC_CTYPE
, "");
9595 bindtextdomain (PACKAGE
, LOCALEDIR
);
9596 textdomain (PACKAGE
);
9598 parse_args (argc
, argv
);
9600 if (optind
< (argc
- 1))
9604 while (optind
< argc
)
9605 err
|= process_file (argv
[optind
++]);
9607 if (dump_sects
!= NULL
)