1 /* readelf.c -- display contents of an ELF format file
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003 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 believe 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"
72 #include "elf/m68hc11.h"
73 #include "elf/mcore.h"
76 #include "elf/mn10200.h"
77 #include "elf/mn10300.h"
78 #include "elf/msp430.h"
82 #include "elf/ppc64.h"
85 #include "elf/sparc.h"
88 #include "elf/x86-64.h"
89 #include "elf/xstormy16.h"
90 #include "elf/iq2000.h"
91 #include "elf/xtensa.h"
95 #include "libiberty.h"
97 char *program_name
= "readelf";
98 unsigned long dynamic_addr
;
99 bfd_size_type dynamic_size
;
100 char *dynamic_strings
;
102 unsigned long string_table_length
;
103 unsigned long num_dynamic_syms
;
104 Elf_Internal_Sym
*dynamic_symbols
;
105 Elf_Internal_Syminfo
*dynamic_syminfo
;
106 unsigned long dynamic_syminfo_offset
;
107 unsigned int dynamic_syminfo_nent
;
108 char program_interpreter
[64];
109 long dynamic_info
[DT_JMPREL
+ 1];
110 long version_info
[16];
112 Elf_Internal_Ehdr elf_header
;
113 Elf_Internal_Shdr
*section_headers
;
114 Elf_Internal_Dyn
*dynamic_segment
;
115 Elf_Internal_Shdr
*symtab_shndx_hdr
;
123 int do_using_dynamic
;
131 int do_debug_abbrevs
;
133 int do_debug_pubnames
;
134 int do_debug_aranges
;
136 int do_debug_frames_interp
;
137 int do_debug_macinfo
;
144 /* A dynamic array of flags indicating which sections require dumping. */
145 char *dump_sects
= NULL
;
146 unsigned int num_dump_sects
= 0;
148 #define HEX_DUMP (1 << 0)
149 #define DISASS_DUMP (1 << 1)
150 #define DEBUG_DUMP (1 << 2)
152 /* How to rpint a vma value. */
153 typedef enum print_mode
165 /* Forward declarations for dumb compilers. */
166 static void print_vma
167 PARAMS ((bfd_vma
, print_mode
));
168 static void print_symbol
169 PARAMS ((int, const char *));
170 static bfd_vma (*byte_get
)
171 PARAMS ((unsigned char *, int));
172 static bfd_vma byte_get_little_endian
173 PARAMS ((unsigned char *, int));
174 static bfd_vma byte_get_big_endian
175 PARAMS ((unsigned char *, int));
176 static bfd_vma byte_get_signed
177 PARAMS ((unsigned char *, int));
178 static void (*byte_put
)
179 PARAMS ((unsigned char *, bfd_vma
, int));
180 static void byte_put_little_endian
181 PARAMS ((unsigned char *, bfd_vma
, int));
182 static void byte_put_big_endian
183 PARAMS ((unsigned char *, bfd_vma
, int));
184 static const char *get_mips_dynamic_type
185 PARAMS ((unsigned long));
186 static const char *get_sparc64_dynamic_type
187 PARAMS ((unsigned long));
188 static const char *get_ppc64_dynamic_type
189 PARAMS ((unsigned long));
190 static const char *get_parisc_dynamic_type
191 PARAMS ((unsigned long));
192 static const char *get_ia64_dynamic_type
193 PARAMS ((unsigned long));
194 static const char *get_dynamic_type
195 PARAMS ((unsigned long));
196 static int slurp_rela_relocs
197 PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Rela
**,
199 static int slurp_rel_relocs
200 PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Rela
**,
202 static int dump_relocations
203 PARAMS ((FILE *, unsigned long, unsigned long, Elf_Internal_Sym
*,
204 unsigned long, char *, int));
205 static char *get_file_type
207 static char *get_machine_name
209 static void decode_ARM_machine_flags
210 PARAMS ((unsigned, char[]));
211 static char *get_machine_flags
212 PARAMS ((unsigned, unsigned));
213 static const char *get_mips_segment_type
214 PARAMS ((unsigned long));
215 static const char *get_parisc_segment_type
216 PARAMS ((unsigned long));
217 static const char *get_ia64_segment_type
218 PARAMS ((unsigned long));
219 static const char *get_segment_type
220 PARAMS ((unsigned long));
221 static const char *get_mips_section_type_name
222 PARAMS ((unsigned int));
223 static const char *get_parisc_section_type_name
224 PARAMS ((unsigned int));
225 static const char *get_ia64_section_type_name
226 PARAMS ((unsigned int));
227 static const char *get_section_type_name
228 PARAMS ((unsigned int));
229 static const char *get_symbol_binding
230 PARAMS ((unsigned int));
231 static const char *get_symbol_type
232 PARAMS ((unsigned int));
233 static const char *get_symbol_visibility
234 PARAMS ((unsigned int));
235 static const char *get_symbol_index_type
236 PARAMS ((unsigned int));
237 static const char *get_dynamic_flags
241 static void parse_args
242 PARAMS ((int, char **));
243 static int process_file_header
245 static int process_program_headers
247 static int process_section_headers
249 static int process_unwind
251 static void dynamic_segment_mips_val
252 PARAMS ((Elf_Internal_Dyn
*));
253 static void dynamic_segment_parisc_val
254 PARAMS ((Elf_Internal_Dyn
*));
255 static void dynamic_segment_ia64_val
256 PARAMS ((Elf_Internal_Dyn
*));
257 static int process_dynamic_segment
259 static int process_symbol_table
261 static int process_syminfo
263 static int process_section_contents
265 static void process_mips_fpe_exception
267 static int process_mips_specific
269 static int process_file
271 static int process_relocs
273 static int process_version_sections
275 static char *get_ver_flags
276 PARAMS ((unsigned int));
277 static int get_32bit_section_headers
278 PARAMS ((FILE *, unsigned int));
279 static int get_64bit_section_headers
280 PARAMS ((FILE *, unsigned int));
281 static int get_32bit_program_headers
282 PARAMS ((FILE *, Elf_Internal_Phdr
*));
283 static int get_64bit_program_headers
284 PARAMS ((FILE *, Elf_Internal_Phdr
*));
285 static int get_file_header
287 static Elf_Internal_Sym
*get_32bit_elf_symbols
288 PARAMS ((FILE *, Elf_Internal_Shdr
*));
289 static Elf_Internal_Sym
*get_64bit_elf_symbols
290 PARAMS ((FILE *, Elf_Internal_Shdr
*));
291 static const char *get_elf_section_flags
293 static int *get_dynamic_data
294 PARAMS ((FILE *, unsigned int));
295 static int get_32bit_dynamic_segment
297 static int get_64bit_dynamic_segment
299 #ifdef SUPPORT_DISASSEMBLY
300 static int disassemble_section
301 PARAMS ((Elf_Internal_Shdr
*, FILE *));
303 static int dump_section
304 PARAMS ((Elf_Internal_Shdr
*, FILE *));
305 static int display_debug_section
306 PARAMS ((Elf_Internal_Shdr
*, FILE *));
307 static int display_debug_info
308 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
309 static int display_debug_not_supported
310 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
311 static int prescan_debug_info
312 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
313 static int display_debug_lines
314 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
315 static int display_debug_pubnames
316 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
317 static int display_debug_abbrev
318 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
319 static int display_debug_aranges
320 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
321 static int display_debug_frames
322 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
323 static int display_debug_macinfo
324 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
325 static int display_debug_str
326 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
327 static int display_debug_loc
328 PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
329 static unsigned char *process_abbrev_section
330 PARAMS ((unsigned char *, unsigned char *));
331 static void load_debug_str
333 static void free_debug_str
335 static const char *fetch_indirect_string
336 PARAMS ((unsigned long));
337 static void load_debug_loc
339 static void free_debug_loc
341 static unsigned long read_leb128
342 PARAMS ((unsigned char *, int *, int));
343 static int process_extended_line_op
344 PARAMS ((unsigned char *, int, int));
345 static void reset_state_machine
347 static char *get_TAG_name
348 PARAMS ((unsigned long));
349 static char *get_AT_name
350 PARAMS ((unsigned long));
351 static char *get_FORM_name
352 PARAMS ((unsigned long));
353 static void free_abbrevs
355 static void add_abbrev
356 PARAMS ((unsigned long, unsigned long, int));
357 static void add_abbrev_attr
358 PARAMS ((unsigned long, unsigned long));
359 static unsigned char *read_and_display_attr
360 PARAMS ((unsigned long, unsigned long, unsigned char *, unsigned long,
361 unsigned long, unsigned long, int));
362 static unsigned char *read_and_display_attr_value
363 PARAMS ((unsigned long, unsigned long, unsigned char *, unsigned long,
364 unsigned long, unsigned long, int));
365 static unsigned char *display_block
366 PARAMS ((unsigned char *, unsigned long));
367 static void decode_location_expression
368 PARAMS ((unsigned char *, unsigned int, unsigned long));
369 static void request_dump
370 PARAMS ((unsigned int, int));
371 static const char *get_elf_class
372 PARAMS ((unsigned int));
373 static const char *get_data_encoding
374 PARAMS ((unsigned int));
375 static const char *get_osabi_name
376 PARAMS ((unsigned int));
377 static int guess_is_rela
378 PARAMS ((unsigned long));
379 static const char *get_note_type
380 PARAMS ((unsigned int));
381 static const char *get_netbsd_elfcore_note_type
382 PARAMS ((unsigned int));
383 static int process_note
384 PARAMS ((Elf_Internal_Note
*));
385 static int process_corefile_note_segment
386 PARAMS ((FILE *, bfd_vma
, bfd_vma
));
387 static int process_corefile_note_segments
389 static int process_corefile_contents
391 static int process_arch_specific
393 static int process_gnu_liblist
396 typedef int Elf32_Word
;
400 #define SECTION_NAME(X) ((X) == NULL ? "<none>" : \
401 ((X)->sh_name >= string_table_length \
402 ? "<corrupt>" : string_table + (X)->sh_name))
404 /* Given st_shndx I, map to section_headers index. */
405 #define SECTION_HEADER_INDEX(I) \
406 ((I) < SHN_LORESERVE \
408 : ((I) <= SHN_HIRESERVE \
410 : (I) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))
412 /* Reverse of the above. */
413 #define SECTION_HEADER_NUM(N) \
414 ((N) < SHN_LORESERVE \
416 : (N) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))
418 #define SECTION_HEADER(I) (section_headers + SECTION_HEADER_INDEX (I))
420 #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
422 #define BYTE_GET(field) byte_get (field, sizeof (field))
424 /* If we can support a 64 bit data type then BFD64 should be defined
425 and sizeof (bfd_vma) == 8. In this case when translating from an
426 external 8 byte field to an internal field, we can assume that the
427 internal field is also 8 bytes wide and so we can extract all the data.
428 If, however, BFD64 is not defined, then we must assume that the
429 internal data structure only has 4 byte wide fields that are the
430 equivalent of the 8 byte wide external counterparts, and so we must
431 truncate the data. */
433 #define BYTE_GET8(field) byte_get (field, -8)
435 #define BYTE_GET8(field) byte_get (field, 8)
438 #define NUM_ELEM(array) (sizeof (array) / sizeof ((array)[0]))
440 #define GET_ELF_SYMBOLS(file, section) \
441 (is_32bit_elf ? get_32bit_elf_symbols (file, section) \
442 : get_64bit_elf_symbols (file, section))
446 error
VPARAMS ((const char *message
, ...))
448 VA_OPEN (args
, message
);
449 VA_FIXEDARG (args
, const char *, message
);
451 fprintf (stderr
, _("%s: Error: "), program_name
);
452 vfprintf (stderr
, message
, args
);
457 warn
VPARAMS ((const char *message
, ...))
459 VA_OPEN (args
, message
);
460 VA_FIXEDARG (args
, const char *, message
);
462 fprintf (stderr
, _("%s: Warning: "), program_name
);
463 vfprintf (stderr
, message
, args
);
467 static PTR get_data
PARAMS ((PTR
, FILE *, long, size_t, const char *));
470 get_data (var
, file
, offset
, size
, reason
)
482 if (fseek (file
, offset
, SEEK_SET
))
484 error (_("Unable to seek to %x for %s\n"), offset
, reason
);
491 mvar
= (PTR
) malloc (size
);
495 error (_("Out of memory allocating %d bytes for %s\n"),
501 if (fread (mvar
, size
, 1, file
) != 1)
503 error (_("Unable to read in %d bytes of %s\n"), size
, reason
);
513 byte_get_little_endian (field
, size
)
514 unsigned char *field
;
523 return ((unsigned int) (field
[0]))
524 | (((unsigned int) (field
[1])) << 8);
528 /* We want to extract data from an 8 byte wide field and
529 place it into a 4 byte wide field. Since this is a little
530 endian source we can just use the 4 byte extraction code. */
534 return ((unsigned long) (field
[0]))
535 | (((unsigned long) (field
[1])) << 8)
536 | (((unsigned long) (field
[2])) << 16)
537 | (((unsigned long) (field
[3])) << 24);
542 /* This is a special case, generated by the BYTE_GET8 macro.
543 It means that we are loading an 8 byte value from a field
544 in an external structure into an 8 byte value in a field
545 in an internal strcuture. */
546 return ((bfd_vma
) (field
[0]))
547 | (((bfd_vma
) (field
[1])) << 8)
548 | (((bfd_vma
) (field
[2])) << 16)
549 | (((bfd_vma
) (field
[3])) << 24)
550 | (((bfd_vma
) (field
[4])) << 32)
551 | (((bfd_vma
) (field
[5])) << 40)
552 | (((bfd_vma
) (field
[6])) << 48)
553 | (((bfd_vma
) (field
[7])) << 56);
556 error (_("Unhandled data length: %d\n"), size
);
562 byte_get_signed (field
, size
)
563 unsigned char *field
;
566 bfd_vma x
= byte_get (field
, size
);
571 return (x
^ 0x80) - 0x80;
573 return (x
^ 0x8000) - 0x8000;
575 return (x
^ 0x80000000) - 0x80000000;
585 byte_put_little_endian (field
, value
, size
)
586 unsigned char * field
;
593 field
[7] = (((value
>> 24) >> 24) >> 8) & 0xff;
594 field
[6] = ((value
>> 24) >> 24) & 0xff;
595 field
[5] = ((value
>> 24) >> 16) & 0xff;
596 field
[4] = ((value
>> 24) >> 8) & 0xff;
599 field
[3] = (value
>> 24) & 0xff;
600 field
[2] = (value
>> 16) & 0xff;
603 field
[1] = (value
>> 8) & 0xff;
606 field
[0] = value
& 0xff;
610 error (_("Unhandled data length: %d\n"), size
);
615 /* Print a VMA value. */
617 print_vma (vma
, mode
)
631 printf ("%8.8lx", (unsigned long) vma
);
637 printf ("%5ld", (long) vma
);
645 printf ("%lx", (unsigned long) vma
);
649 printf ("%ld", (unsigned long) vma
);
653 printf ("%lu", (unsigned long) vma
);
675 #if BFD_HOST_64BIT_LONG
678 if (_bfd_int64_high (vma
))
679 printf ("%lx%8.8lx", _bfd_int64_high (vma
), _bfd_int64_low (vma
));
681 printf ("%lx", _bfd_int64_low (vma
));
686 #if BFD_HOST_64BIT_LONG
689 if (_bfd_int64_high (vma
))
691 printf ("++%ld", _bfd_int64_low (vma
));
693 printf ("%ld", _bfd_int64_low (vma
));
698 #if BFD_HOST_64BIT_LONG
700 printf ("%5ld", vma
);
702 printf ("%#lx", vma
);
704 if (_bfd_int64_high (vma
))
706 printf ("++%ld", _bfd_int64_low (vma
));
707 else if (vma
<= 99999)
708 printf ("%5ld", _bfd_int64_low (vma
));
710 printf ("%#lx", _bfd_int64_low (vma
));
715 #if BFD_HOST_64BIT_LONG
718 if (_bfd_int64_high (vma
))
720 printf ("++%lu", _bfd_int64_low (vma
));
722 printf ("%lu", _bfd_int64_low (vma
));
730 /* Display a symbol on stdout. If do_wide is not true then
731 format the symbol to be at most WIDTH characters,
732 truncating as necessary. If WIDTH is negative then
733 format the string to be exactly - WIDTH characters,
734 truncating or padding as necessary. */
737 print_symbol (width
, symbol
)
742 printf ("%s", symbol
);
744 printf ("%-*.*s", width
, width
, symbol
);
746 printf ("%-.*s", width
, symbol
);
750 byte_get_big_endian (field
, size
)
751 unsigned char *field
;
760 return ((unsigned int) (field
[1])) | (((int) (field
[0])) << 8);
763 return ((unsigned long) (field
[3]))
764 | (((unsigned long) (field
[2])) << 8)
765 | (((unsigned long) (field
[1])) << 16)
766 | (((unsigned long) (field
[0])) << 24);
770 /* Although we are extracing data from an 8 byte wide field, we
771 are returning only 4 bytes of data. */
772 return ((unsigned long) (field
[7]))
773 | (((unsigned long) (field
[6])) << 8)
774 | (((unsigned long) (field
[5])) << 16)
775 | (((unsigned long) (field
[4])) << 24);
779 /* This is a special case, generated by the BYTE_GET8 macro.
780 It means that we are loading an 8 byte value from a field
781 in an external structure into an 8 byte value in a field
782 in an internal strcuture. */
783 return ((bfd_vma
) (field
[7]))
784 | (((bfd_vma
) (field
[6])) << 8)
785 | (((bfd_vma
) (field
[5])) << 16)
786 | (((bfd_vma
) (field
[4])) << 24)
787 | (((bfd_vma
) (field
[3])) << 32)
788 | (((bfd_vma
) (field
[2])) << 40)
789 | (((bfd_vma
) (field
[1])) << 48)
790 | (((bfd_vma
) (field
[0])) << 56);
794 error (_("Unhandled data length: %d\n"), size
);
800 byte_put_big_endian (field
, value
, size
)
801 unsigned char * field
;
808 field
[7] = value
& 0xff;
809 field
[6] = (value
>> 8) & 0xff;
810 field
[5] = (value
>> 16) & 0xff;
811 field
[4] = (value
>> 24) & 0xff;
816 field
[3] = value
& 0xff;
817 field
[2] = (value
>> 8) & 0xff;
821 field
[1] = value
& 0xff;
825 field
[0] = value
& 0xff;
829 error (_("Unhandled data length: %d\n"), size
);
834 /* Guess the relocation size commonly used by the specific machines. */
837 guess_is_rela (e_machine
)
838 unsigned long e_machine
;
842 /* Targets that use REL relocations. */
858 /* Targets that use RELA relocations. */
873 case EM_CYGNUS_MN10200
:
875 case EM_CYGNUS_MN10300
:
920 warn (_("Don't know about relocations on this machine architecture\n"));
926 slurp_rela_relocs (file
, rel_offset
, rel_size
, relasp
, nrelasp
)
928 unsigned long rel_offset
;
929 unsigned long rel_size
;
930 Elf_Internal_Rela
**relasp
;
931 unsigned long *nrelasp
;
933 Elf_Internal_Rela
*relas
;
934 unsigned long nrelas
;
939 Elf32_External_Rela
*erelas
;
941 erelas
= (Elf32_External_Rela
*) get_data (NULL
, file
, rel_offset
,
942 rel_size
, _("relocs"));
946 nrelas
= rel_size
/ sizeof (Elf32_External_Rela
);
948 relas
= (Elf_Internal_Rela
*)
949 malloc (nrelas
* sizeof (Elf_Internal_Rela
));
953 error(_("out of memory parsing relocs"));
957 for (i
= 0; i
< nrelas
; i
++)
959 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
960 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
961 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
968 Elf64_External_Rela
*erelas
;
970 erelas
= (Elf64_External_Rela
*) get_data (NULL
, file
, rel_offset
,
971 rel_size
, _("relocs"));
975 nrelas
= rel_size
/ sizeof (Elf64_External_Rela
);
977 relas
= (Elf_Internal_Rela
*)
978 malloc (nrelas
* sizeof (Elf_Internal_Rela
));
982 error(_("out of memory parsing relocs"));
986 for (i
= 0; i
< nrelas
; i
++)
988 relas
[i
].r_offset
= BYTE_GET8 (erelas
[i
].r_offset
);
989 relas
[i
].r_info
= BYTE_GET8 (erelas
[i
].r_info
);
990 relas
[i
].r_addend
= BYTE_GET8 (erelas
[i
].r_addend
);
1001 slurp_rel_relocs (file
, rel_offset
, rel_size
, relsp
, nrelsp
)
1003 unsigned long rel_offset
;
1004 unsigned long rel_size
;
1005 Elf_Internal_Rela
**relsp
;
1006 unsigned long *nrelsp
;
1008 Elf_Internal_Rela
*rels
;
1009 unsigned long nrels
;
1014 Elf32_External_Rel
*erels
;
1016 erels
= (Elf32_External_Rel
*) get_data (NULL
, file
, rel_offset
,
1017 rel_size
, _("relocs"));
1021 nrels
= rel_size
/ sizeof (Elf32_External_Rel
);
1023 rels
= (Elf_Internal_Rela
*) malloc (nrels
* sizeof (Elf_Internal_Rela
));
1027 error(_("out of memory parsing relocs"));
1031 for (i
= 0; i
< nrels
; i
++)
1033 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
1034 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
1035 rels
[i
].r_addend
= 0;
1042 Elf64_External_Rel
*erels
;
1044 erels
= (Elf64_External_Rel
*) get_data (NULL
, file
, rel_offset
,
1045 rel_size
, _("relocs"));
1049 nrels
= rel_size
/ sizeof (Elf64_External_Rel
);
1051 rels
= (Elf_Internal_Rela
*) malloc (nrels
* sizeof (Elf_Internal_Rela
));
1055 error(_("out of memory parsing relocs"));
1059 for (i
= 0; i
< nrels
; i
++)
1061 rels
[i
].r_offset
= BYTE_GET8 (erels
[i
].r_offset
);
1062 rels
[i
].r_info
= BYTE_GET8 (erels
[i
].r_info
);
1063 rels
[i
].r_addend
= 0;
1073 /* Display the contents of the relocation data found at the specified offset. */
1076 dump_relocations (file
, rel_offset
, rel_size
, symtab
, nsyms
, strtab
, is_rela
)
1078 unsigned long rel_offset
;
1079 unsigned long rel_size
;
1080 Elf_Internal_Sym
*symtab
;
1081 unsigned long nsyms
;
1086 Elf_Internal_Rela
*rels
;
1089 if (is_rela
== UNKNOWN
)
1090 is_rela
= guess_is_rela (elf_header
.e_machine
);
1094 if (!slurp_rela_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
1099 if (!slurp_rel_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
1108 printf (_(" Offset Info Type Sym. Value Symbol's Name + Addend\n"));
1110 printf (_(" Offset Info Type Sym.Value Sym. Name + Addend\n"));
1115 printf (_(" Offset Info Type Sym. Value Symbol's Name\n"));
1117 printf (_(" Offset Info Type Sym.Value Sym. Name\n"));
1125 printf (_(" Offset Info Type Symbol's Value Symbol's Name + Addend\n"));
1127 printf (_(" Offset Info Type Sym. Value Sym. Name + Addend\n"));
1132 printf (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
1134 printf (_(" Offset Info Type Sym. Value Sym. Name\n"));
1138 for (i
= 0; i
< rel_size
; i
++)
1141 const char *rtype2
= NULL
;
1142 const char *rtype3
= NULL
;
1145 bfd_vma symtab_index
;
1147 bfd_vma type2
= (bfd_vma
) NULL
;
1148 bfd_vma type3
= (bfd_vma
) NULL
;
1150 offset
= rels
[i
].r_offset
;
1151 info
= rels
[i
].r_info
;
1155 type
= ELF32_R_TYPE (info
);
1156 symtab_index
= ELF32_R_SYM (info
);
1160 /* The #ifdef BFD64 below is to prevent a compile time warning.
1161 We know that if we do not have a 64 bit data type that we
1162 will never execute this code anyway. */
1164 if (elf_header
.e_machine
== EM_MIPS
)
1166 /* In little-endian objects, r_info isn't really a 64-bit
1167 little-endian value: it has a 32-bit little-endian
1168 symbol index followed by four individual byte fields.
1169 Reorder INFO accordingly. */
1170 if (elf_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
1171 info
= (((info
& 0xffffffff) << 32)
1172 | ((info
>> 56) & 0xff)
1173 | ((info
>> 40) & 0xff00)
1174 | ((info
>> 24) & 0xff0000)
1175 | ((info
>> 8) & 0xff000000));
1176 type
= ELF64_MIPS_R_TYPE (info
);
1177 type2
= ELF64_MIPS_R_TYPE2 (info
);
1178 type3
= ELF64_MIPS_R_TYPE3 (info
);
1180 else if (elf_header
.e_machine
== EM_SPARCV9
)
1181 type
= ELF64_R_TYPE_ID (info
);
1183 type
= ELF64_R_TYPE (info
);
1185 symtab_index
= ELF64_R_SYM (info
);
1191 #ifdef _bfd_int64_low
1192 printf ("%8.8lx %8.8lx ", _bfd_int64_low (offset
), _bfd_int64_low (info
));
1194 printf ("%8.8lx %8.8lx ", offset
, info
);
1199 #ifdef _bfd_int64_low
1201 ? "%8.8lx%8.8lx %8.8lx%8.8lx "
1202 : "%4.4lx%8.8lx %4.4lx%8.8lx ",
1203 _bfd_int64_high (offset
),
1204 _bfd_int64_low (offset
),
1205 _bfd_int64_high (info
),
1206 _bfd_int64_low (info
));
1209 ? "%16.16lx %16.16lx "
1210 : "%12.12lx %12.12lx ",
1215 switch (elf_header
.e_machine
)
1222 case EM_CYGNUS_M32R
:
1223 rtype
= elf_m32r_reloc_type (type
);
1228 rtype
= elf_i386_reloc_type (type
);
1233 rtype
= elf_m68hc11_reloc_type (type
);
1237 rtype
= elf_m68k_reloc_type (type
);
1241 rtype
= elf_i960_reloc_type (type
);
1246 rtype
= elf_avr_reloc_type (type
);
1249 case EM_OLD_SPARCV9
:
1250 case EM_SPARC32PLUS
:
1253 rtype
= elf_sparc_reloc_type (type
);
1257 case EM_CYGNUS_V850
:
1258 rtype
= v850_reloc_type (type
);
1262 case EM_CYGNUS_D10V
:
1263 rtype
= elf_d10v_reloc_type (type
);
1267 case EM_CYGNUS_D30V
:
1268 rtype
= elf_d30v_reloc_type (type
);
1272 rtype
= elf_dlx_reloc_type (type
);
1276 rtype
= elf_sh_reloc_type (type
);
1280 case EM_CYGNUS_MN10300
:
1281 rtype
= elf_mn10300_reloc_type (type
);
1285 case EM_CYGNUS_MN10200
:
1286 rtype
= elf_mn10200_reloc_type (type
);
1290 case EM_CYGNUS_FR30
:
1291 rtype
= elf_fr30_reloc_type (type
);
1295 rtype
= elf_frv_reloc_type (type
);
1299 rtype
= elf_mcore_reloc_type (type
);
1303 rtype
= elf_mmix_reloc_type (type
);
1308 rtype
= elf_msp430_reloc_type (type
);
1312 rtype
= elf_ppc_reloc_type (type
);
1316 rtype
= elf_ppc64_reloc_type (type
);
1320 case EM_MIPS_RS3_LE
:
1321 rtype
= elf_mips_reloc_type (type
);
1324 rtype2
= elf_mips_reloc_type (type2
);
1325 rtype3
= elf_mips_reloc_type (type3
);
1330 rtype
= elf_alpha_reloc_type (type
);
1334 rtype
= elf_arm_reloc_type (type
);
1338 rtype
= elf_arc_reloc_type (type
);
1342 rtype
= elf_hppa_reloc_type (type
);
1348 rtype
= elf_h8_reloc_type (type
);
1353 rtype
= elf_or32_reloc_type (type
);
1358 rtype
= elf_pj_reloc_type (type
);
1361 rtype
= elf_ia64_reloc_type (type
);
1365 rtype
= elf_cris_reloc_type (type
);
1369 rtype
= elf_i860_reloc_type (type
);
1373 rtype
= elf_x86_64_reloc_type (type
);
1377 rtype
= i370_reloc_type (type
);
1382 rtype
= elf_s390_reloc_type (type
);
1386 rtype
= elf_xstormy16_reloc_type (type
);
1390 rtype
= elf_vax_reloc_type (type
);
1395 rtype
= elf_ip2k_reloc_type (type
);
1399 rtype
= elf_iq2000_reloc_type (type
);
1404 rtype
= elf_xtensa_reloc_type (type
);
1409 #ifdef _bfd_int64_low
1410 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type
));
1412 printf (_("unrecognized: %-7lx"), type
);
1415 printf (do_wide
? "%-22.22s" : "%-17.17s", rtype
);
1419 if (symtab
== NULL
|| symtab_index
>= nsyms
)
1420 printf (" bad symbol index: %08lx", (unsigned long) symtab_index
);
1423 Elf_Internal_Sym
*psym
;
1425 psym
= symtab
+ symtab_index
;
1428 print_vma (psym
->st_value
, LONG_HEX
);
1429 printf (is_32bit_elf
? " " : " ");
1431 if (psym
->st_name
== 0)
1433 const char *sec_name
= "<null>";
1436 if (ELF_ST_TYPE (psym
->st_info
) == STT_SECTION
)
1438 bfd_vma sec_index
= (bfd_vma
) -1;
1440 if (psym
->st_shndx
< SHN_LORESERVE
)
1441 sec_index
= psym
->st_shndx
;
1442 else if (psym
->st_shndx
> SHN_LORESERVE
)
1443 sec_index
= psym
->st_shndx
- (SHN_HIRESERVE
+ 1
1446 if (sec_index
!= (bfd_vma
) -1)
1447 sec_name
= SECTION_NAME (section_headers
+ sec_index
);
1448 else if (psym
->st_shndx
== SHN_ABS
)
1450 else if (psym
->st_shndx
== SHN_COMMON
)
1451 sec_name
= "COMMON";
1454 sprintf (name_buf
, "<section 0x%x>",
1455 (unsigned int) psym
->st_shndx
);
1456 sec_name
= name_buf
;
1459 print_symbol (22, sec_name
);
1461 else if (strtab
== NULL
)
1462 printf (_("<string table index %3ld>"), psym
->st_name
);
1464 print_symbol (22, strtab
+ psym
->st_name
);
1467 printf (" + %lx", (unsigned long) rels
[i
].r_addend
);
1472 printf ("%*c", is_32bit_elf
? (do_wide
? 34 : 28) : (do_wide
? 26 : 20), ' ');
1473 print_vma (rels
[i
].r_addend
, LONG_HEX
);
1476 if (elf_header
.e_machine
== EM_SPARCV9
1477 && !strcmp (rtype
, "R_SPARC_OLO10"))
1478 printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (info
));
1482 if (! is_32bit_elf
&& elf_header
.e_machine
== EM_MIPS
)
1484 printf (" Type2: ");
1487 #ifdef _bfd_int64_low
1488 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type2
));
1490 printf (_("unrecognized: %-7lx"), type2
);
1493 printf ("%-17.17s", rtype2
);
1495 printf("\n Type3: ");
1498 #ifdef _bfd_int64_low
1499 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type3
));
1501 printf (_("unrecognized: %-7lx"), type3
);
1504 printf ("%-17.17s", rtype3
);
1516 get_mips_dynamic_type (type
)
1521 case DT_MIPS_RLD_VERSION
: return "MIPS_RLD_VERSION";
1522 case DT_MIPS_TIME_STAMP
: return "MIPS_TIME_STAMP";
1523 case DT_MIPS_ICHECKSUM
: return "MIPS_ICHECKSUM";
1524 case DT_MIPS_IVERSION
: return "MIPS_IVERSION";
1525 case DT_MIPS_FLAGS
: return "MIPS_FLAGS";
1526 case DT_MIPS_BASE_ADDRESS
: return "MIPS_BASE_ADDRESS";
1527 case DT_MIPS_MSYM
: return "MIPS_MSYM";
1528 case DT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
1529 case DT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
1530 case DT_MIPS_LOCAL_GOTNO
: return "MIPS_LOCAL_GOTNO";
1531 case DT_MIPS_CONFLICTNO
: return "MIPS_CONFLICTNO";
1532 case DT_MIPS_LIBLISTNO
: return "MIPS_LIBLISTNO";
1533 case DT_MIPS_SYMTABNO
: return "MIPS_SYMTABNO";
1534 case DT_MIPS_UNREFEXTNO
: return "MIPS_UNREFEXTNO";
1535 case DT_MIPS_GOTSYM
: return "MIPS_GOTSYM";
1536 case DT_MIPS_HIPAGENO
: return "MIPS_HIPAGENO";
1537 case DT_MIPS_RLD_MAP
: return "MIPS_RLD_MAP";
1538 case DT_MIPS_DELTA_CLASS
: return "MIPS_DELTA_CLASS";
1539 case DT_MIPS_DELTA_CLASS_NO
: return "MIPS_DELTA_CLASS_NO";
1540 case DT_MIPS_DELTA_INSTANCE
: return "MIPS_DELTA_INSTANCE";
1541 case DT_MIPS_DELTA_INSTANCE_NO
: return "MIPS_DELTA_INSTANCE_NO";
1542 case DT_MIPS_DELTA_RELOC
: return "MIPS_DELTA_RELOC";
1543 case DT_MIPS_DELTA_RELOC_NO
: return "MIPS_DELTA_RELOC_NO";
1544 case DT_MIPS_DELTA_SYM
: return "MIPS_DELTA_SYM";
1545 case DT_MIPS_DELTA_SYM_NO
: return "MIPS_DELTA_SYM_NO";
1546 case DT_MIPS_DELTA_CLASSSYM
: return "MIPS_DELTA_CLASSSYM";
1547 case DT_MIPS_DELTA_CLASSSYM_NO
: return "MIPS_DELTA_CLASSSYM_NO";
1548 case DT_MIPS_CXX_FLAGS
: return "MIPS_CXX_FLAGS";
1549 case DT_MIPS_PIXIE_INIT
: return "MIPS_PIXIE_INIT";
1550 case DT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
1551 case DT_MIPS_LOCALPAGE_GOTIDX
: return "MIPS_LOCALPAGE_GOTIDX";
1552 case DT_MIPS_LOCAL_GOTIDX
: return "MIPS_LOCAL_GOTIDX";
1553 case DT_MIPS_HIDDEN_GOTIDX
: return "MIPS_HIDDEN_GOTIDX";
1554 case DT_MIPS_PROTECTED_GOTIDX
: return "MIPS_PROTECTED_GOTIDX";
1555 case DT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
1556 case DT_MIPS_INTERFACE
: return "MIPS_INTERFACE";
1557 case DT_MIPS_DYNSTR_ALIGN
: return "MIPS_DYNSTR_ALIGN";
1558 case DT_MIPS_INTERFACE_SIZE
: return "MIPS_INTERFACE_SIZE";
1559 case DT_MIPS_RLD_TEXT_RESOLVE_ADDR
: return "MIPS_RLD_TEXT_RESOLVE_ADDR";
1560 case DT_MIPS_PERF_SUFFIX
: return "MIPS_PERF_SUFFIX";
1561 case DT_MIPS_COMPACT_SIZE
: return "MIPS_COMPACT_SIZE";
1562 case DT_MIPS_GP_VALUE
: return "MIPS_GP_VALUE";
1563 case DT_MIPS_AUX_DYNAMIC
: return "MIPS_AUX_DYNAMIC";
1570 get_sparc64_dynamic_type (type
)
1575 case DT_SPARC_REGISTER
: return "SPARC_REGISTER";
1582 get_ppc64_dynamic_type (type
)
1587 case DT_PPC64_GLINK
: return "PPC64_GLINK";
1588 case DT_PPC64_OPD
: return "PPC64_OPD";
1589 case DT_PPC64_OPDSZ
: return "PPC64_OPDSZ";
1596 get_parisc_dynamic_type (type
)
1601 case DT_HP_LOAD_MAP
: return "HP_LOAD_MAP";
1602 case DT_HP_DLD_FLAGS
: return "HP_DLD_FLAGS";
1603 case DT_HP_DLD_HOOK
: return "HP_DLD_HOOK";
1604 case DT_HP_UX10_INIT
: return "HP_UX10_INIT";
1605 case DT_HP_UX10_INITSZ
: return "HP_UX10_INITSZ";
1606 case DT_HP_PREINIT
: return "HP_PREINIT";
1607 case DT_HP_PREINITSZ
: return "HP_PREINITSZ";
1608 case DT_HP_NEEDED
: return "HP_NEEDED";
1609 case DT_HP_TIME_STAMP
: return "HP_TIME_STAMP";
1610 case DT_HP_CHECKSUM
: return "HP_CHECKSUM";
1611 case DT_HP_GST_SIZE
: return "HP_GST_SIZE";
1612 case DT_HP_GST_VERSION
: return "HP_GST_VERSION";
1613 case DT_HP_GST_HASHVAL
: return "HP_GST_HASHVAL";
1620 get_ia64_dynamic_type (type
)
1625 case DT_IA_64_PLT_RESERVE
: return "IA_64_PLT_RESERVE";
1632 get_dynamic_type (type
)
1635 static char buff
[32];
1639 case DT_NULL
: return "NULL";
1640 case DT_NEEDED
: return "NEEDED";
1641 case DT_PLTRELSZ
: return "PLTRELSZ";
1642 case DT_PLTGOT
: return "PLTGOT";
1643 case DT_HASH
: return "HASH";
1644 case DT_STRTAB
: return "STRTAB";
1645 case DT_SYMTAB
: return "SYMTAB";
1646 case DT_RELA
: return "RELA";
1647 case DT_RELASZ
: return "RELASZ";
1648 case DT_RELAENT
: return "RELAENT";
1649 case DT_STRSZ
: return "STRSZ";
1650 case DT_SYMENT
: return "SYMENT";
1651 case DT_INIT
: return "INIT";
1652 case DT_FINI
: return "FINI";
1653 case DT_SONAME
: return "SONAME";
1654 case DT_RPATH
: return "RPATH";
1655 case DT_SYMBOLIC
: return "SYMBOLIC";
1656 case DT_REL
: return "REL";
1657 case DT_RELSZ
: return "RELSZ";
1658 case DT_RELENT
: return "RELENT";
1659 case DT_PLTREL
: return "PLTREL";
1660 case DT_DEBUG
: return "DEBUG";
1661 case DT_TEXTREL
: return "TEXTREL";
1662 case DT_JMPREL
: return "JMPREL";
1663 case DT_BIND_NOW
: return "BIND_NOW";
1664 case DT_INIT_ARRAY
: return "INIT_ARRAY";
1665 case DT_FINI_ARRAY
: return "FINI_ARRAY";
1666 case DT_INIT_ARRAYSZ
: return "INIT_ARRAYSZ";
1667 case DT_FINI_ARRAYSZ
: return "FINI_ARRAYSZ";
1668 case DT_RUNPATH
: return "RUNPATH";
1669 case DT_FLAGS
: return "FLAGS";
1671 case DT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
1672 case DT_PREINIT_ARRAYSZ
: return "PREINIT_ARRAYSZ";
1674 case DT_CHECKSUM
: return "CHECKSUM";
1675 case DT_PLTPADSZ
: return "PLTPADSZ";
1676 case DT_MOVEENT
: return "MOVEENT";
1677 case DT_MOVESZ
: return "MOVESZ";
1678 case DT_FEATURE
: return "FEATURE";
1679 case DT_POSFLAG_1
: return "POSFLAG_1";
1680 case DT_SYMINSZ
: return "SYMINSZ";
1681 case DT_SYMINENT
: return "SYMINENT"; /* aka VALRNGHI */
1683 case DT_ADDRRNGLO
: return "ADDRRNGLO";
1684 case DT_CONFIG
: return "CONFIG";
1685 case DT_DEPAUDIT
: return "DEPAUDIT";
1686 case DT_AUDIT
: return "AUDIT";
1687 case DT_PLTPAD
: return "PLTPAD";
1688 case DT_MOVETAB
: return "MOVETAB";
1689 case DT_SYMINFO
: return "SYMINFO"; /* aka ADDRRNGHI */
1691 case DT_VERSYM
: return "VERSYM";
1693 case DT_RELACOUNT
: return "RELACOUNT";
1694 case DT_RELCOUNT
: return "RELCOUNT";
1695 case DT_FLAGS_1
: return "FLAGS_1";
1696 case DT_VERDEF
: return "VERDEF";
1697 case DT_VERDEFNUM
: return "VERDEFNUM";
1698 case DT_VERNEED
: return "VERNEED";
1699 case DT_VERNEEDNUM
: return "VERNEEDNUM";
1701 case DT_AUXILIARY
: return "AUXILIARY";
1702 case DT_USED
: return "USED";
1703 case DT_FILTER
: return "FILTER";
1705 case DT_GNU_PRELINKED
: return "GNU_PRELINKED";
1706 case DT_GNU_CONFLICT
: return "GNU_CONFLICT";
1707 case DT_GNU_CONFLICTSZ
: return "GNU_CONFLICTSZ";
1708 case DT_GNU_LIBLIST
: return "GNU_LIBLIST";
1709 case DT_GNU_LIBLISTSZ
: return "GNU_LIBLISTSZ";
1712 if ((type
>= DT_LOPROC
) && (type
<= DT_HIPROC
))
1716 switch (elf_header
.e_machine
)
1719 case EM_MIPS_RS3_LE
:
1720 result
= get_mips_dynamic_type (type
);
1723 result
= get_sparc64_dynamic_type (type
);
1726 result
= get_ppc64_dynamic_type (type
);
1729 result
= get_ia64_dynamic_type (type
);
1739 sprintf (buff
, _("Processor Specific: %lx"), type
);
1741 else if ((type
>= DT_LOOS
) && (type
<= DT_HIOS
))
1745 switch (elf_header
.e_machine
)
1748 result
= get_parisc_dynamic_type (type
);
1758 sprintf (buff
, _("Operating System specific: %lx"), type
);
1761 sprintf (buff
, _("<unknown>: %lx"), type
);
1768 get_file_type (e_type
)
1771 static char buff
[32];
1775 case ET_NONE
: return _("NONE (None)");
1776 case ET_REL
: return _("REL (Relocatable file)");
1777 case ET_EXEC
: return _("EXEC (Executable file)");
1778 case ET_DYN
: return _("DYN (Shared object file)");
1779 case ET_CORE
: return _("CORE (Core file)");
1782 if ((e_type
>= ET_LOPROC
) && (e_type
<= ET_HIPROC
))
1783 sprintf (buff
, _("Processor Specific: (%x)"), e_type
);
1784 else if ((e_type
>= ET_LOOS
) && (e_type
<= ET_HIOS
))
1785 sprintf (buff
, _("OS Specific: (%x)"), e_type
);
1787 sprintf (buff
, _("<unknown>: %x"), e_type
);
1793 get_machine_name (e_machine
)
1796 static char buff
[64]; /* XXX */
1800 case EM_NONE
: return _("None");
1801 case EM_M32
: return "WE32100";
1802 case EM_SPARC
: return "Sparc";
1803 case EM_386
: return "Intel 80386";
1804 case EM_68K
: return "MC68000";
1805 case EM_88K
: return "MC88000";
1806 case EM_486
: return "Intel 80486";
1807 case EM_860
: return "Intel 80860";
1808 case EM_MIPS
: return "MIPS R3000";
1809 case EM_S370
: return "IBM System/370";
1810 case EM_MIPS_RS3_LE
: return "MIPS R4000 big-endian";
1811 case EM_OLD_SPARCV9
: return "Sparc v9 (old)";
1812 case EM_PARISC
: return "HPPA";
1813 case EM_PPC_OLD
: return "Power PC (old)";
1814 case EM_SPARC32PLUS
: return "Sparc v8+" ;
1815 case EM_960
: return "Intel 90860";
1816 case EM_PPC
: return "PowerPC";
1817 case EM_PPC64
: return "PowerPC64";
1818 case EM_V800
: return "NEC V800";
1819 case EM_FR20
: return "Fujitsu FR20";
1820 case EM_RH32
: return "TRW RH32";
1821 case EM_MCORE
: return "MCORE";
1822 case EM_ARM
: return "ARM";
1823 case EM_OLD_ALPHA
: return "Digital Alpha (old)";
1824 case EM_SH
: return "Renesas / SuperH SH";
1825 case EM_SPARCV9
: return "Sparc v9";
1826 case EM_TRICORE
: return "Siemens Tricore";
1827 case EM_ARC
: return "ARC";
1828 case EM_H8_300
: return "Renesas H8/300";
1829 case EM_H8_300H
: return "Renesas H8/300H";
1830 case EM_H8S
: return "Renesas H8S";
1831 case EM_H8_500
: return "Renesas H8/500";
1832 case EM_IA_64
: return "Intel IA-64";
1833 case EM_MIPS_X
: return "Stanford MIPS-X";
1834 case EM_COLDFIRE
: return "Motorola Coldfire";
1835 case EM_68HC12
: return "Motorola M68HC12";
1836 case EM_ALPHA
: return "Alpha";
1837 case EM_CYGNUS_D10V
:
1838 case EM_D10V
: return "d10v";
1839 case EM_CYGNUS_D30V
:
1840 case EM_D30V
: return "d30v";
1841 case EM_CYGNUS_M32R
:
1842 case EM_M32R
: return "Renesas M32R (formerly Mitsubishi M32r)";
1843 case EM_CYGNUS_V850
:
1844 case EM_V850
: return "NEC v850";
1845 case EM_CYGNUS_MN10300
:
1846 case EM_MN10300
: return "mn10300";
1847 case EM_CYGNUS_MN10200
:
1848 case EM_MN10200
: return "mn10200";
1849 case EM_CYGNUS_FR30
:
1850 case EM_FR30
: return "Fujitsu FR30";
1851 case EM_CYGNUS_FRV
: return "Fujitsu FR-V";
1853 case EM_PJ
: return "picoJava";
1854 case EM_MMA
: return "Fujitsu Multimedia Accelerator";
1855 case EM_PCP
: return "Siemens PCP";
1856 case EM_NCPU
: return "Sony nCPU embedded RISC processor";
1857 case EM_NDR1
: return "Denso NDR1 microprocesspr";
1858 case EM_STARCORE
: return "Motorola Star*Core processor";
1859 case EM_ME16
: return "Toyota ME16 processor";
1860 case EM_ST100
: return "STMicroelectronics ST100 processor";
1861 case EM_TINYJ
: return "Advanced Logic Corp. TinyJ embedded processor";
1862 case EM_FX66
: return "Siemens FX66 microcontroller";
1863 case EM_ST9PLUS
: return "STMicroelectronics ST9+ 8/16 bit microcontroller";
1864 case EM_ST7
: return "STMicroelectronics ST7 8-bit microcontroller";
1865 case EM_68HC16
: return "Motorola MC68HC16 Microcontroller";
1866 case EM_68HC11
: return "Motorola MC68HC11 Microcontroller";
1867 case EM_68HC08
: return "Motorola MC68HC08 Microcontroller";
1868 case EM_68HC05
: return "Motorola MC68HC05 Microcontroller";
1869 case EM_SVX
: return "Silicon Graphics SVx";
1870 case EM_ST19
: return "STMicroelectronics ST19 8-bit microcontroller";
1871 case EM_VAX
: return "Digital VAX";
1873 case EM_AVR
: return "Atmel AVR 8-bit microcontroller";
1874 case EM_CRIS
: return "Axis Communications 32-bit embedded processor";
1875 case EM_JAVELIN
: return "Infineon Technologies 32-bit embedded cpu";
1876 case EM_FIREPATH
: return "Element 14 64-bit DSP processor";
1877 case EM_ZSP
: return "LSI Logic's 16-bit DSP processor";
1878 case EM_MMIX
: return "Donald Knuth's educational 64-bit processor";
1879 case EM_HUANY
: return "Harvard Universitys's machine-independent object format";
1880 case EM_PRISM
: return "Vitesse Prism";
1881 case EM_X86_64
: return "Advanced Micro Devices X86-64";
1883 case EM_S390
: return "IBM S/390";
1884 case EM_XSTORMY16
: return "Sanyo Xstormy16 CPU core";
1886 case EM_OR32
: return "OpenRISC";
1887 case EM_DLX
: return "OpenDLX";
1889 case EM_IP2K
: return "Ubicom IP2xxx 8-bit microcontrollers";
1890 case EM_IQ2000
: return "Vitesse IQ2000";
1892 case EM_XTENSA
: return "Tensilica Xtensa Processor";
1894 sprintf (buff
, _("<unknown>: %x"), e_machine
);
1900 decode_ARM_machine_flags (e_flags
, buf
)
1907 eabi
= EF_ARM_EABI_VERSION (e_flags
);
1908 e_flags
&= ~ EF_ARM_EABIMASK
;
1910 /* Handle "generic" ARM flags. */
1911 if (e_flags
& EF_ARM_RELEXEC
)
1913 strcat (buf
, ", relocatable executable");
1914 e_flags
&= ~ EF_ARM_RELEXEC
;
1917 if (e_flags
& EF_ARM_HASENTRY
)
1919 strcat (buf
, ", has entry point");
1920 e_flags
&= ~ EF_ARM_HASENTRY
;
1923 /* Now handle EABI specific flags. */
1927 strcat (buf
, ", <unrecognized EABI>");
1932 case EF_ARM_EABI_VER1
:
1933 strcat (buf
, ", Version1 EABI");
1938 /* Process flags one bit at a time. */
1939 flag
= e_flags
& - e_flags
;
1944 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1945 strcat (buf
, ", sorted symbol tables");
1955 case EF_ARM_EABI_VER2
:
1956 strcat (buf
, ", Version2 EABI");
1961 /* Process flags one bit at a time. */
1962 flag
= e_flags
& - e_flags
;
1967 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1968 strcat (buf
, ", sorted symbol tables");
1971 case EF_ARM_DYNSYMSUSESEGIDX
:
1972 strcat (buf
, ", dynamic symbols use segment index");
1975 case EF_ARM_MAPSYMSFIRST
:
1976 strcat (buf
, ", mapping symbols precede others");
1986 case EF_ARM_EABI_UNKNOWN
:
1987 strcat (buf
, ", GNU EABI");
1992 /* Process flags one bit at a time. */
1993 flag
= e_flags
& - e_flags
;
1998 case EF_ARM_INTERWORK
:
1999 strcat (buf
, ", interworking enabled");
2002 case EF_ARM_APCS_26
:
2003 strcat (buf
, ", uses APCS/26");
2006 case EF_ARM_APCS_FLOAT
:
2007 strcat (buf
, ", uses APCS/float");
2011 strcat (buf
, ", position independent");
2015 strcat (buf
, ", 8 bit structure alignment");
2018 case EF_ARM_NEW_ABI
:
2019 strcat (buf
, ", uses new ABI");
2022 case EF_ARM_OLD_ABI
:
2023 strcat (buf
, ", uses old ABI");
2026 case EF_ARM_SOFT_FLOAT
:
2027 strcat (buf
, ", software FP");
2030 case EF_ARM_MAVERICK_FLOAT
:
2031 strcat (buf
, ", Maverick FP");
2042 strcat (buf
,", <unknown>");
2046 get_machine_flags (e_flags
, e_machine
)
2050 static char buf
[1024];
2062 decode_ARM_machine_flags (e_flags
, buf
);
2066 if (e_flags
& EF_CPU32
)
2067 strcat (buf
, ", cpu32");
2068 if (e_flags
& EF_M68000
)
2069 strcat (buf
, ", m68000");
2073 if (e_flags
& EF_PPC_EMB
)
2074 strcat (buf
, ", emb");
2076 if (e_flags
& EF_PPC_RELOCATABLE
)
2077 strcat (buf
, ", relocatable");
2079 if (e_flags
& EF_PPC_RELOCATABLE_LIB
)
2080 strcat (buf
, ", relocatable-lib");
2084 case EM_CYGNUS_V850
:
2085 switch (e_flags
& EF_V850_ARCH
)
2088 strcat (buf
, ", v850e");
2091 strcat (buf
, ", v850");
2094 strcat (buf
, ", unknown v850 architecture variant");
2100 case EM_CYGNUS_M32R
:
2101 if ((e_flags
& EF_M32R_ARCH
) == E_M32R_ARCH
)
2102 strcat (buf
, ", m32r");
2107 case EM_MIPS_RS3_LE
:
2108 if (e_flags
& EF_MIPS_NOREORDER
)
2109 strcat (buf
, ", noreorder");
2111 if (e_flags
& EF_MIPS_PIC
)
2112 strcat (buf
, ", pic");
2114 if (e_flags
& EF_MIPS_CPIC
)
2115 strcat (buf
, ", cpic");
2117 if (e_flags
& EF_MIPS_UCODE
)
2118 strcat (buf
, ", ugen_reserved");
2120 if (e_flags
& EF_MIPS_ABI2
)
2121 strcat (buf
, ", abi2");
2123 if (e_flags
& EF_MIPS_OPTIONS_FIRST
)
2124 strcat (buf
, ", odk first");
2126 if (e_flags
& EF_MIPS_32BITMODE
)
2127 strcat (buf
, ", 32bitmode");
2129 switch ((e_flags
& EF_MIPS_MACH
))
2131 case E_MIPS_MACH_3900
: strcat (buf
, ", 3900"); break;
2132 case E_MIPS_MACH_4010
: strcat (buf
, ", 4010"); break;
2133 case E_MIPS_MACH_4100
: strcat (buf
, ", 4100"); break;
2134 case E_MIPS_MACH_4111
: strcat (buf
, ", 4111"); break;
2135 case E_MIPS_MACH_4120
: strcat (buf
, ", 4120"); break;
2136 case E_MIPS_MACH_4650
: strcat (buf
, ", 4650"); break;
2137 case E_MIPS_MACH_5400
: strcat (buf
, ", 5400"); break;
2138 case E_MIPS_MACH_5500
: strcat (buf
, ", 5500"); break;
2139 case E_MIPS_MACH_SB1
: strcat (buf
, ", sb1"); break;
2141 /* We simply ignore the field in this case to avoid confusion:
2142 MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
2145 default: strcat (buf
, ", unknown CPU"); break;
2148 switch ((e_flags
& EF_MIPS_ABI
))
2150 case E_MIPS_ABI_O32
: strcat (buf
, ", o32"); break;
2151 case E_MIPS_ABI_O64
: strcat (buf
, ", o64"); break;
2152 case E_MIPS_ABI_EABI32
: strcat (buf
, ", eabi32"); break;
2153 case E_MIPS_ABI_EABI64
: strcat (buf
, ", eabi64"); break;
2155 /* We simply ignore the field in this case to avoid confusion:
2156 MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension.
2157 This means it is likely to be an o32 file, but not for
2160 default: strcat (buf
, ", unknown ABI"); break;
2163 if (e_flags
& EF_MIPS_ARCH_ASE_MDMX
)
2164 strcat (buf
, ", mdmx");
2166 if (e_flags
& EF_MIPS_ARCH_ASE_M16
)
2167 strcat (buf
, ", mips16");
2169 switch ((e_flags
& EF_MIPS_ARCH
))
2171 case E_MIPS_ARCH_1
: strcat (buf
, ", mips1"); break;
2172 case E_MIPS_ARCH_2
: strcat (buf
, ", mips2"); break;
2173 case E_MIPS_ARCH_3
: strcat (buf
, ", mips3"); break;
2174 case E_MIPS_ARCH_4
: strcat (buf
, ", mips4"); break;
2175 case E_MIPS_ARCH_5
: strcat (buf
, ", mips5"); break;
2176 case E_MIPS_ARCH_32
: strcat (buf
, ", mips32"); break;
2177 case E_MIPS_ARCH_32R2
: strcat (buf
, ", mips32r2"); break;
2178 case E_MIPS_ARCH_64
: strcat (buf
, ", mips64"); break;
2179 default: strcat (buf
, ", unknown ISA"); break;
2185 if (e_flags
& EF_SPARC_32PLUS
)
2186 strcat (buf
, ", v8+");
2188 if (e_flags
& EF_SPARC_SUN_US1
)
2189 strcat (buf
, ", ultrasparcI");
2191 if (e_flags
& EF_SPARC_SUN_US3
)
2192 strcat (buf
, ", ultrasparcIII");
2194 if (e_flags
& EF_SPARC_HAL_R1
)
2195 strcat (buf
, ", halr1");
2197 if (e_flags
& EF_SPARC_LEDATA
)
2198 strcat (buf
, ", ledata");
2200 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_TSO
)
2201 strcat (buf
, ", tso");
2203 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_PSO
)
2204 strcat (buf
, ", pso");
2206 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_RMO
)
2207 strcat (buf
, ", rmo");
2211 switch (e_flags
& EF_PARISC_ARCH
)
2213 case EFA_PARISC_1_0
:
2214 strcpy (buf
, ", PA-RISC 1.0");
2216 case EFA_PARISC_1_1
:
2217 strcpy (buf
, ", PA-RISC 1.1");
2219 case EFA_PARISC_2_0
:
2220 strcpy (buf
, ", PA-RISC 2.0");
2225 if (e_flags
& EF_PARISC_TRAPNIL
)
2226 strcat (buf
, ", trapnil");
2227 if (e_flags
& EF_PARISC_EXT
)
2228 strcat (buf
, ", ext");
2229 if (e_flags
& EF_PARISC_LSB
)
2230 strcat (buf
, ", lsb");
2231 if (e_flags
& EF_PARISC_WIDE
)
2232 strcat (buf
, ", wide");
2233 if (e_flags
& EF_PARISC_NO_KABP
)
2234 strcat (buf
, ", no kabp");
2235 if (e_flags
& EF_PARISC_LAZYSWAP
)
2236 strcat (buf
, ", lazyswap");
2241 if ((e_flags
& EF_PICOJAVA_NEWCALLS
) == EF_PICOJAVA_NEWCALLS
)
2242 strcat (buf
, ", new calling convention");
2244 if ((e_flags
& EF_PICOJAVA_GNUCALLS
) == EF_PICOJAVA_GNUCALLS
)
2245 strcat (buf
, ", gnu calling convention");
2249 if ((e_flags
& EF_IA_64_ABI64
))
2250 strcat (buf
, ", 64-bit");
2252 strcat (buf
, ", 32-bit");
2253 if ((e_flags
& EF_IA_64_REDUCEDFP
))
2254 strcat (buf
, ", reduced fp model");
2255 if ((e_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
))
2256 strcat (buf
, ", no function descriptors, constant gp");
2257 else if ((e_flags
& EF_IA_64_CONS_GP
))
2258 strcat (buf
, ", constant gp");
2259 if ((e_flags
& EF_IA_64_ABSOLUTE
))
2260 strcat (buf
, ", absolute");
2264 if ((e_flags
& EF_VAX_NONPIC
))
2265 strcat (buf
, ", non-PIC");
2266 if ((e_flags
& EF_VAX_DFLOAT
))
2267 strcat (buf
, ", D-Float");
2268 if ((e_flags
& EF_VAX_GFLOAT
))
2269 strcat (buf
, ", G-Float");
2278 get_mips_segment_type (type
)
2283 case PT_MIPS_REGINFO
:
2285 case PT_MIPS_RTPROC
:
2287 case PT_MIPS_OPTIONS
:
2297 get_parisc_segment_type (type
)
2302 case PT_HP_TLS
: return "HP_TLS";
2303 case PT_HP_CORE_NONE
: return "HP_CORE_NONE";
2304 case PT_HP_CORE_VERSION
: return "HP_CORE_VERSION";
2305 case PT_HP_CORE_KERNEL
: return "HP_CORE_KERNEL";
2306 case PT_HP_CORE_COMM
: return "HP_CORE_COMM";
2307 case PT_HP_CORE_PROC
: return "HP_CORE_PROC";
2308 case PT_HP_CORE_LOADABLE
: return "HP_CORE_LOADABLE";
2309 case PT_HP_CORE_STACK
: return "HP_CORE_STACK";
2310 case PT_HP_CORE_SHM
: return "HP_CORE_SHM";
2311 case PT_HP_CORE_MMF
: return "HP_CORE_MMF";
2312 case PT_HP_PARALLEL
: return "HP_PARALLEL";
2313 case PT_HP_FASTBIND
: return "HP_FASTBIND";
2314 case PT_PARISC_ARCHEXT
: return "PARISC_ARCHEXT";
2315 case PT_PARISC_UNWIND
: return "PARISC_UNWIND";
2324 get_ia64_segment_type (type
)
2329 case PT_IA_64_ARCHEXT
: return "IA_64_ARCHEXT";
2330 case PT_IA_64_UNWIND
: return "IA_64_UNWIND";
2331 case PT_HP_TLS
: return "HP_TLS";
2332 case PT_IA_64_HP_OPT_ANOT
: return "HP_OPT_ANNOT";
2333 case PT_IA_64_HP_HSL_ANOT
: return "HP_HSL_ANNOT";
2334 case PT_IA_64_HP_STACK
: return "HP_STACK";
2343 get_segment_type (p_type
)
2344 unsigned long p_type
;
2346 static char buff
[32];
2350 case PT_NULL
: return "NULL";
2351 case PT_LOAD
: return "LOAD";
2352 case PT_DYNAMIC
: return "DYNAMIC";
2353 case PT_INTERP
: return "INTERP";
2354 case PT_NOTE
: return "NOTE";
2355 case PT_SHLIB
: return "SHLIB";
2356 case PT_PHDR
: return "PHDR";
2357 case PT_TLS
: return "TLS";
2359 case PT_GNU_EH_FRAME
:
2360 return "GNU_EH_FRAME";
2361 case PT_GNU_STACK
: return "STACK";
2364 if ((p_type
>= PT_LOPROC
) && (p_type
<= PT_HIPROC
))
2368 switch (elf_header
.e_machine
)
2371 case EM_MIPS_RS3_LE
:
2372 result
= get_mips_segment_type (p_type
);
2375 result
= get_parisc_segment_type (p_type
);
2378 result
= get_ia64_segment_type (p_type
);
2388 sprintf (buff
, "LOPROC+%lx", p_type
- PT_LOPROC
);
2390 else if ((p_type
>= PT_LOOS
) && (p_type
<= PT_HIOS
))
2394 switch (elf_header
.e_machine
)
2397 result
= get_parisc_segment_type (p_type
);
2400 result
= get_ia64_segment_type (p_type
);
2410 sprintf (buff
, "LOOS+%lx", p_type
- PT_LOOS
);
2413 sprintf (buff
, _("<unknown>: %lx"), p_type
);
2420 get_mips_section_type_name (sh_type
)
2421 unsigned int sh_type
;
2425 case SHT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
2426 case SHT_MIPS_MSYM
: return "MIPS_MSYM";
2427 case SHT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
2428 case SHT_MIPS_GPTAB
: return "MIPS_GPTAB";
2429 case SHT_MIPS_UCODE
: return "MIPS_UCODE";
2430 case SHT_MIPS_DEBUG
: return "MIPS_DEBUG";
2431 case SHT_MIPS_REGINFO
: return "MIPS_REGINFO";
2432 case SHT_MIPS_PACKAGE
: return "MIPS_PACKAGE";
2433 case SHT_MIPS_PACKSYM
: return "MIPS_PACKSYM";
2434 case SHT_MIPS_RELD
: return "MIPS_RELD";
2435 case SHT_MIPS_IFACE
: return "MIPS_IFACE";
2436 case SHT_MIPS_CONTENT
: return "MIPS_CONTENT";
2437 case SHT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
2438 case SHT_MIPS_SHDR
: return "MIPS_SHDR";
2439 case SHT_MIPS_FDESC
: return "MIPS_FDESC";
2440 case SHT_MIPS_EXTSYM
: return "MIPS_EXTSYM";
2441 case SHT_MIPS_DENSE
: return "MIPS_DENSE";
2442 case SHT_MIPS_PDESC
: return "MIPS_PDESC";
2443 case SHT_MIPS_LOCSYM
: return "MIPS_LOCSYM";
2444 case SHT_MIPS_AUXSYM
: return "MIPS_AUXSYM";
2445 case SHT_MIPS_OPTSYM
: return "MIPS_OPTSYM";
2446 case SHT_MIPS_LOCSTR
: return "MIPS_LOCSTR";
2447 case SHT_MIPS_LINE
: return "MIPS_LINE";
2448 case SHT_MIPS_RFDESC
: return "MIPS_RFDESC";
2449 case SHT_MIPS_DELTASYM
: return "MIPS_DELTASYM";
2450 case SHT_MIPS_DELTAINST
: return "MIPS_DELTAINST";
2451 case SHT_MIPS_DELTACLASS
: return "MIPS_DELTACLASS";
2452 case SHT_MIPS_DWARF
: return "MIPS_DWARF";
2453 case SHT_MIPS_DELTADECL
: return "MIPS_DELTADECL";
2454 case SHT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
2455 case SHT_MIPS_EVENTS
: return "MIPS_EVENTS";
2456 case SHT_MIPS_TRANSLATE
: return "MIPS_TRANSLATE";
2457 case SHT_MIPS_PIXIE
: return "MIPS_PIXIE";
2458 case SHT_MIPS_XLATE
: return "MIPS_XLATE";
2459 case SHT_MIPS_XLATE_DEBUG
: return "MIPS_XLATE_DEBUG";
2460 case SHT_MIPS_WHIRL
: return "MIPS_WHIRL";
2461 case SHT_MIPS_EH_REGION
: return "MIPS_EH_REGION";
2462 case SHT_MIPS_XLATE_OLD
: return "MIPS_XLATE_OLD";
2463 case SHT_MIPS_PDR_EXCEPTION
: return "MIPS_PDR_EXCEPTION";
2471 get_parisc_section_type_name (sh_type
)
2472 unsigned int sh_type
;
2476 case SHT_PARISC_EXT
: return "PARISC_EXT";
2477 case SHT_PARISC_UNWIND
: return "PARISC_UNWIND";
2478 case SHT_PARISC_DOC
: return "PARISC_DOC";
2486 get_ia64_section_type_name (sh_type
)
2487 unsigned int sh_type
;
2489 /* If the top 8 bits are 0x78 the next 8 are the os/abi ID. */
2490 if ((sh_type
& 0xFF000000) == SHT_IA_64_LOPSREG
)
2491 return get_osabi_name ((sh_type
& 0x00FF0000) >> 16);
2495 case SHT_IA_64_EXT
: return "IA_64_EXT";
2496 case SHT_IA_64_UNWIND
: return "IA_64_UNWIND";
2497 case SHT_IA_64_PRIORITY_INIT
: return "IA_64_PRIORITY_INIT";
2505 get_section_type_name (sh_type
)
2506 unsigned int sh_type
;
2508 static char buff
[32];
2512 case SHT_NULL
: return "NULL";
2513 case SHT_PROGBITS
: return "PROGBITS";
2514 case SHT_SYMTAB
: return "SYMTAB";
2515 case SHT_STRTAB
: return "STRTAB";
2516 case SHT_RELA
: return "RELA";
2517 case SHT_HASH
: return "HASH";
2518 case SHT_DYNAMIC
: return "DYNAMIC";
2519 case SHT_NOTE
: return "NOTE";
2520 case SHT_NOBITS
: return "NOBITS";
2521 case SHT_REL
: return "REL";
2522 case SHT_SHLIB
: return "SHLIB";
2523 case SHT_DYNSYM
: return "DYNSYM";
2524 case SHT_INIT_ARRAY
: return "INIT_ARRAY";
2525 case SHT_FINI_ARRAY
: return "FINI_ARRAY";
2526 case SHT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
2527 case SHT_GROUP
: return "GROUP";
2528 case SHT_SYMTAB_SHNDX
: return "SYMTAB SECTION INDICIES";
2529 case SHT_GNU_verdef
: return "VERDEF";
2530 case SHT_GNU_verneed
: return "VERNEED";
2531 case SHT_GNU_versym
: return "VERSYM";
2532 case 0x6ffffff0: return "VERSYM";
2533 case 0x6ffffffc: return "VERDEF";
2534 case 0x7ffffffd: return "AUXILIARY";
2535 case 0x7fffffff: return "FILTER";
2536 case SHT_GNU_LIBLIST
: return "GNU_LIBLIST";
2539 if ((sh_type
>= SHT_LOPROC
) && (sh_type
<= SHT_HIPROC
))
2543 switch (elf_header
.e_machine
)
2546 case EM_MIPS_RS3_LE
:
2547 result
= get_mips_section_type_name (sh_type
);
2550 result
= get_parisc_section_type_name (sh_type
);
2553 result
= get_ia64_section_type_name (sh_type
);
2563 sprintf (buff
, "LOPROC+%x", sh_type
- SHT_LOPROC
);
2565 else if ((sh_type
>= SHT_LOOS
) && (sh_type
<= SHT_HIOS
))
2566 sprintf (buff
, "LOOS+%x", sh_type
- SHT_LOOS
);
2567 else if ((sh_type
>= SHT_LOUSER
) && (sh_type
<= SHT_HIUSER
))
2568 sprintf (buff
, "LOUSER+%x", sh_type
- SHT_LOUSER
);
2570 sprintf (buff
, _("<unknown>: %x"), sh_type
);
2576 #define OPTION_DEBUG_DUMP 512
2578 struct option options
[] =
2580 {"all", no_argument
, 0, 'a'},
2581 {"file-header", no_argument
, 0, 'h'},
2582 {"program-headers", no_argument
, 0, 'l'},
2583 {"headers", no_argument
, 0, 'e'},
2584 {"histogram", no_argument
, 0, 'I'},
2585 {"segments", no_argument
, 0, 'l'},
2586 {"sections", no_argument
, 0, 'S'},
2587 {"section-headers", no_argument
, 0, 'S'},
2588 {"symbols", no_argument
, 0, 's'},
2589 {"syms", no_argument
, 0, 's'},
2590 {"relocs", no_argument
, 0, 'r'},
2591 {"notes", no_argument
, 0, 'n'},
2592 {"dynamic", no_argument
, 0, 'd'},
2593 {"arch-specific", no_argument
, 0, 'A'},
2594 {"version-info", no_argument
, 0, 'V'},
2595 {"use-dynamic", no_argument
, 0, 'D'},
2596 {"hex-dump", required_argument
, 0, 'x'},
2597 {"debug-dump", optional_argument
, 0, OPTION_DEBUG_DUMP
},
2598 {"unwind", no_argument
, 0, 'u'},
2599 #ifdef SUPPORT_DISASSEMBLY
2600 {"instruction-dump", required_argument
, 0, 'i'},
2603 {"version", no_argument
, 0, 'v'},
2604 {"wide", no_argument
, 0, 'W'},
2605 {"help", no_argument
, 0, 'H'},
2606 {0, no_argument
, 0, 0}
2612 fprintf (stdout
, _("Usage: readelf <option(s)> elf-file(s)\n"));
2613 fprintf (stdout
, _(" Display information about the contents of ELF format files\n"));
2614 fprintf (stdout
, _(" Options are:\n\
2615 -a --all Equivalent to: -h -l -S -s -r -d -V -A -I\n\
2616 -h --file-header Display the ELF file header\n\
2617 -l --program-headers Display the program headers\n\
2618 --segments An alias for --program-headers\n\
2619 -S --section-headers Display the sections' header\n\
2620 --sections An alias for --section-headers\n\
2621 -e --headers Equivalent to: -h -l -S\n\
2622 -s --syms Display the symbol table\n\
2623 --symbols An alias for --syms\n\
2624 -n --notes Display the core notes (if present)\n\
2625 -r --relocs Display the relocations (if present)\n\
2626 -u --unwind Display the unwind info (if present)\n\
2627 -d --dynamic Display the dynamic segment (if present)\n\
2628 -V --version-info Display the version sections (if present)\n\
2629 -A --arch-specific Display architecture specific information (if any).\n\
2630 -D --use-dynamic Use the dynamic section info when displaying symbols\n\
2631 -x --hex-dump=<number> Dump the contents of section <number>\n\
2632 -w[liaprmfFso] or\n\
2633 --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=str,=loc]\n\
2634 Display the contents of DWARF2 debug sections\n"));
2635 #ifdef SUPPORT_DISASSEMBLY
2636 fprintf (stdout
, _("\
2637 -i --instruction-dump=<number>\n\
2638 Disassemble the contents of section <number>\n"));
2640 fprintf (stdout
, _("\
2641 -I --histogram Display histogram of bucket list lengths\n\
2642 -W --wide Allow output width to exceed 80 characters\n\
2643 -H --help Display this information\n\
2644 -v --version Display the version number of readelf\n"));
2645 fprintf (stdout
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
2651 request_dump (section
, type
)
2652 unsigned int section
;
2655 if (section
>= num_dump_sects
)
2657 char *new_dump_sects
;
2659 new_dump_sects
= (char *) calloc (section
+ 1, 1);
2661 if (new_dump_sects
== NULL
)
2662 error (_("Out of memory allocating dump request table."));
2665 /* Copy current flag settings. */
2666 memcpy (new_dump_sects
, dump_sects
, num_dump_sects
);
2670 dump_sects
= new_dump_sects
;
2671 num_dump_sects
= section
+ 1;
2676 dump_sects
[section
] |= type
;
2682 parse_args (argc
, argv
)
2691 while ((c
= getopt_long
2692 (argc
, argv
, "ersuahnldSDAIw::x:i:vVWH", options
, NULL
)) != EOF
)
2759 section
= strtoul (optarg
, & cp
, 0);
2760 if (! *cp
&& section
>= 0)
2762 request_dump (section
, HEX_DUMP
);
2772 unsigned int index
= 0;
2776 while (optarg
[index
])
2777 switch (optarg
[index
++])
2786 do_debug_abbrevs
= 1;
2796 do_debug_pubnames
= 1;
2801 do_debug_aranges
= 1;
2805 do_debug_frames_interp
= 1;
2807 do_debug_frames
= 1;
2812 do_debug_macinfo
= 1;
2826 warn (_("Unrecognized debug option '%s'\n"), optarg
);
2831 case OPTION_DEBUG_DUMP
:
2837 static const char *debug_dump_opt
[]
2838 = { "line", "info", "abbrev", "pubnames", "ranges",
2839 "macro", "frames", "frames-interp", "str", "loc", NULL
};
2848 for (index
= 0; debug_dump_opt
[index
]; index
++)
2850 size_t len
= strlen (debug_dump_opt
[index
]);
2852 if (strncmp (p
, debug_dump_opt
[index
], len
) == 0
2853 && (p
[len
] == ',' || p
[len
] == '\0'))
2862 do_debug_abbrevs
= 1;
2873 do_debug_pubnames
= 1;
2877 do_debug_aranges
= 1;
2882 do_debug_frames_interp
= 1;
2883 do_debug_frames
= 1;
2887 do_debug_macinfo
= 1;
2900 if (debug_dump_opt
[index
] == NULL
)
2902 warn (_("Unrecognized debug option '%s'\n"), p
);
2903 p
= strchr (p
, ',');
2913 #ifdef SUPPORT_DISASSEMBLY
2916 section
= strtoul (optarg
, & cp
, 0);
2917 if (! *cp
&& section
>= 0)
2919 request_dump (section
, DISASS_DUMP
);
2925 print_version (program_name
);
2935 /* xgettext:c-format */
2936 error (_("Invalid option '-%c'\n"), c
);
2943 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
2944 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
2945 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
)
2949 warn (_("Nothing to do.\n"));
2955 get_elf_class (elf_class
)
2956 unsigned int elf_class
;
2958 static char buff
[32];
2962 case ELFCLASSNONE
: return _("none");
2963 case ELFCLASS32
: return "ELF32";
2964 case ELFCLASS64
: return "ELF64";
2966 sprintf (buff
, _("<unknown: %x>"), elf_class
);
2972 get_data_encoding (encoding
)
2973 unsigned int encoding
;
2975 static char buff
[32];
2979 case ELFDATANONE
: return _("none");
2980 case ELFDATA2LSB
: return _("2's complement, little endian");
2981 case ELFDATA2MSB
: return _("2's complement, big endian");
2983 sprintf (buff
, _("<unknown: %x>"), encoding
);
2989 get_osabi_name (osabi
)
2992 static char buff
[32];
2996 case ELFOSABI_NONE
: return "UNIX - System V";
2997 case ELFOSABI_HPUX
: return "UNIX - HP-UX";
2998 case ELFOSABI_NETBSD
: return "UNIX - NetBSD";
2999 case ELFOSABI_LINUX
: return "UNIX - Linux";
3000 case ELFOSABI_HURD
: return "GNU/Hurd";
3001 case ELFOSABI_SOLARIS
: return "UNIX - Solaris";
3002 case ELFOSABI_AIX
: return "UNIX - AIX";
3003 case ELFOSABI_IRIX
: return "UNIX - IRIX";
3004 case ELFOSABI_FREEBSD
: return "UNIX - FreeBSD";
3005 case ELFOSABI_TRU64
: return "UNIX - TRU64";
3006 case ELFOSABI_MODESTO
: return "Novell - Modesto";
3007 case ELFOSABI_OPENBSD
: return "UNIX - OpenBSD";
3008 case ELFOSABI_OPENVMS
: return "VMS - OpenVMS";
3009 case ELFOSABI_NSK
: return "HP - Non-Stop Kernel";
3010 case ELFOSABI_AROS
: return "Amiga Research OS";
3011 case ELFOSABI_STANDALONE
: return _("Standalone App");
3012 case ELFOSABI_ARM
: return "ARM";
3014 sprintf (buff
, _("<unknown: %x>"), osabi
);
3019 /* Decode the data held in 'elf_header'. */
3022 process_file_header ()
3024 if ( elf_header
.e_ident
[EI_MAG0
] != ELFMAG0
3025 || elf_header
.e_ident
[EI_MAG1
] != ELFMAG1
3026 || elf_header
.e_ident
[EI_MAG2
] != ELFMAG2
3027 || elf_header
.e_ident
[EI_MAG3
] != ELFMAG3
)
3030 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
3038 printf (_("ELF Header:\n"));
3039 printf (_(" Magic: "));
3040 for (i
= 0; i
< EI_NIDENT
; i
++)
3041 printf ("%2.2x ", elf_header
.e_ident
[i
]);
3043 printf (_(" Class: %s\n"),
3044 get_elf_class (elf_header
.e_ident
[EI_CLASS
]));
3045 printf (_(" Data: %s\n"),
3046 get_data_encoding (elf_header
.e_ident
[EI_DATA
]));
3047 printf (_(" Version: %d %s\n"),
3048 elf_header
.e_ident
[EI_VERSION
],
3049 (elf_header
.e_ident
[EI_VERSION
] == EV_CURRENT
3051 : (elf_header
.e_ident
[EI_VERSION
] != EV_NONE
3054 printf (_(" OS/ABI: %s\n"),
3055 get_osabi_name (elf_header
.e_ident
[EI_OSABI
]));
3056 printf (_(" ABI Version: %d\n"),
3057 elf_header
.e_ident
[EI_ABIVERSION
]);
3058 printf (_(" Type: %s\n"),
3059 get_file_type (elf_header
.e_type
));
3060 printf (_(" Machine: %s\n"),
3061 get_machine_name (elf_header
.e_machine
));
3062 printf (_(" Version: 0x%lx\n"),
3063 (unsigned long) elf_header
.e_version
);
3065 printf (_(" Entry point address: "));
3066 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3067 printf (_("\n Start of program headers: "));
3068 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3069 printf (_(" (bytes into file)\n Start of section headers: "));
3070 print_vma ((bfd_vma
) elf_header
.e_shoff
, DEC
);
3071 printf (_(" (bytes into file)\n"));
3073 printf (_(" Flags: 0x%lx%s\n"),
3074 (unsigned long) elf_header
.e_flags
,
3075 get_machine_flags (elf_header
.e_flags
, elf_header
.e_machine
));
3076 printf (_(" Size of this header: %ld (bytes)\n"),
3077 (long) elf_header
.e_ehsize
);
3078 printf (_(" Size of program headers: %ld (bytes)\n"),
3079 (long) elf_header
.e_phentsize
);
3080 printf (_(" Number of program headers: %ld\n"),
3081 (long) elf_header
.e_phnum
);
3082 printf (_(" Size of section headers: %ld (bytes)\n"),
3083 (long) elf_header
.e_shentsize
);
3084 printf (_(" Number of section headers: %ld"),
3085 (long) elf_header
.e_shnum
);
3086 if (section_headers
!= NULL
&& elf_header
.e_shnum
== 0)
3087 printf (" (%ld)", (long) section_headers
[0].sh_size
);
3088 putc ('\n', stdout
);
3089 printf (_(" Section header string table index: %ld"),
3090 (long) elf_header
.e_shstrndx
);
3091 if (section_headers
!= NULL
&& elf_header
.e_shstrndx
== SHN_XINDEX
)
3092 printf (" (%ld)", (long) section_headers
[0].sh_link
);
3093 putc ('\n', stdout
);
3096 if (section_headers
!= NULL
)
3098 if (elf_header
.e_shnum
== 0)
3099 elf_header
.e_shnum
= section_headers
[0].sh_size
;
3100 if (elf_header
.e_shstrndx
== SHN_XINDEX
)
3101 elf_header
.e_shstrndx
= section_headers
[0].sh_link
;
3102 free (section_headers
);
3103 section_headers
= NULL
;
3111 get_32bit_program_headers (file
, program_headers
)
3113 Elf_Internal_Phdr
*program_headers
;
3115 Elf32_External_Phdr
*phdrs
;
3116 Elf32_External_Phdr
*external
;
3117 Elf_Internal_Phdr
*internal
;
3120 phdrs
= ((Elf32_External_Phdr
*)
3121 get_data (NULL
, file
, elf_header
.e_phoff
,
3122 elf_header
.e_phentsize
* elf_header
.e_phnum
,
3123 _("program headers")));
3127 for (i
= 0, internal
= program_headers
, external
= phdrs
;
3128 i
< elf_header
.e_phnum
;
3129 i
++, internal
++, external
++)
3131 internal
->p_type
= BYTE_GET (external
->p_type
);
3132 internal
->p_offset
= BYTE_GET (external
->p_offset
);
3133 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
3134 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
3135 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
3136 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
3137 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3138 internal
->p_align
= BYTE_GET (external
->p_align
);
3147 get_64bit_program_headers (file
, program_headers
)
3149 Elf_Internal_Phdr
*program_headers
;
3151 Elf64_External_Phdr
*phdrs
;
3152 Elf64_External_Phdr
*external
;
3153 Elf_Internal_Phdr
*internal
;
3156 phdrs
= ((Elf64_External_Phdr
*)
3157 get_data (NULL
, file
, elf_header
.e_phoff
,
3158 elf_header
.e_phentsize
* elf_header
.e_phnum
,
3159 _("program headers")));
3163 for (i
= 0, internal
= program_headers
, external
= phdrs
;
3164 i
< elf_header
.e_phnum
;
3165 i
++, internal
++, external
++)
3167 internal
->p_type
= BYTE_GET (external
->p_type
);
3168 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3169 internal
->p_offset
= BYTE_GET8 (external
->p_offset
);
3170 internal
->p_vaddr
= BYTE_GET8 (external
->p_vaddr
);
3171 internal
->p_paddr
= BYTE_GET8 (external
->p_paddr
);
3172 internal
->p_filesz
= BYTE_GET8 (external
->p_filesz
);
3173 internal
->p_memsz
= BYTE_GET8 (external
->p_memsz
);
3174 internal
->p_align
= BYTE_GET8 (external
->p_align
);
3182 /* Returns 1 if the program headers were loaded. */
3185 process_program_headers (file
)
3188 Elf_Internal_Phdr
*program_headers
;
3189 Elf_Internal_Phdr
*segment
;
3192 if (elf_header
.e_phnum
== 0)
3195 printf (_("\nThere are no program headers in this file.\n"));
3199 if (do_segments
&& !do_header
)
3201 printf (_("\nElf file type is %s\n"), get_file_type (elf_header
.e_type
));
3202 printf (_("Entry point "));
3203 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3204 printf (_("\nThere are %d program headers, starting at offset "),
3205 elf_header
.e_phnum
);
3206 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3210 program_headers
= (Elf_Internal_Phdr
*) malloc
3211 (elf_header
.e_phnum
* sizeof (Elf_Internal_Phdr
));
3213 if (program_headers
== NULL
)
3215 error (_("Out of memory\n"));
3220 i
= get_32bit_program_headers (file
, program_headers
);
3222 i
= get_64bit_program_headers (file
, program_headers
);
3226 free (program_headers
);
3232 if (elf_header
.e_phnum
> 1)
3233 printf (_("\nProgram Headers:\n"));
3235 printf (_("\nProgram Headers:\n"));
3239 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3242 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3246 (_(" Type Offset VirtAddr PhysAddr\n"));
3248 (_(" FileSiz MemSiz Flags Align\n"));
3256 for (i
= 0, segment
= program_headers
;
3257 i
< elf_header
.e_phnum
;
3262 printf (" %-14.14s ", get_segment_type (segment
->p_type
));
3266 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3267 printf ("0x%8.8lx ", (unsigned long) segment
->p_vaddr
);
3268 printf ("0x%8.8lx ", (unsigned long) segment
->p_paddr
);
3269 printf ("0x%5.5lx ", (unsigned long) segment
->p_filesz
);
3270 printf ("0x%5.5lx ", (unsigned long) segment
->p_memsz
);
3272 (segment
->p_flags
& PF_R
? 'R' : ' '),
3273 (segment
->p_flags
& PF_W
? 'W' : ' '),
3274 (segment
->p_flags
& PF_X
? 'E' : ' '));
3275 printf ("%#lx", (unsigned long) segment
->p_align
);
3279 if ((unsigned long) segment
->p_offset
== segment
->p_offset
)
3280 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3283 print_vma (segment
->p_offset
, FULL_HEX
);
3287 print_vma (segment
->p_vaddr
, FULL_HEX
);
3289 print_vma (segment
->p_paddr
, FULL_HEX
);
3292 if ((unsigned long) segment
->p_filesz
== segment
->p_filesz
)
3293 printf ("0x%6.6lx ", (unsigned long) segment
->p_filesz
);
3296 print_vma (segment
->p_filesz
, FULL_HEX
);
3300 if ((unsigned long) segment
->p_memsz
== segment
->p_memsz
)
3301 printf ("0x%6.6lx", (unsigned long) segment
->p_memsz
);
3304 print_vma (segment
->p_offset
, FULL_HEX
);
3308 (segment
->p_flags
& PF_R
? 'R' : ' '),
3309 (segment
->p_flags
& PF_W
? 'W' : ' '),
3310 (segment
->p_flags
& PF_X
? 'E' : ' '));
3312 if ((unsigned long) segment
->p_align
== segment
->p_align
)
3313 printf ("%#lx", (unsigned long) segment
->p_align
);
3316 print_vma (segment
->p_align
, PREFIX_HEX
);
3321 print_vma (segment
->p_offset
, FULL_HEX
);
3323 print_vma (segment
->p_vaddr
, FULL_HEX
);
3325 print_vma (segment
->p_paddr
, FULL_HEX
);
3327 print_vma (segment
->p_filesz
, FULL_HEX
);
3329 print_vma (segment
->p_memsz
, FULL_HEX
);
3331 (segment
->p_flags
& PF_R
? 'R' : ' '),
3332 (segment
->p_flags
& PF_W
? 'W' : ' '),
3333 (segment
->p_flags
& PF_X
? 'E' : ' '));
3334 print_vma (segment
->p_align
, HEX
);
3338 switch (segment
->p_type
)
3343 unsigned long align_mask
= -segment
->p_align
;
3345 if (align_mask
== 0)
3347 loadaddr
= ((segment
->p_vaddr
& align_mask
)
3348 - (segment
->p_offset
& align_mask
));
3354 error (_("more than one dynamic segment\n"));
3356 dynamic_addr
= segment
->p_offset
;
3357 dynamic_size
= segment
->p_filesz
;
3361 if (fseek (file
, (long) segment
->p_offset
, SEEK_SET
))
3362 error (_("Unable to find program interpreter name\n"));
3365 program_interpreter
[0] = 0;
3366 fscanf (file
, "%63s", program_interpreter
);
3369 printf (_("\n [Requesting program interpreter: %s]"),
3370 program_interpreter
);
3376 putc ('\n', stdout
);
3385 if (do_segments
&& section_headers
!= NULL
)
3387 printf (_("\n Section to Segment mapping:\n"));
3388 printf (_(" Segment Sections...\n"));
3390 assert (string_table
!= NULL
);
3392 for (i
= 0; i
< elf_header
.e_phnum
; i
++)
3395 Elf_Internal_Shdr
*section
;
3397 segment
= program_headers
+ i
;
3398 section
= section_headers
;
3400 printf (" %2.2d ", i
);
3402 for (j
= 1; j
< elf_header
.e_shnum
; j
++, section
++)
3404 if (section
->sh_size
> 0
3405 /* Compare allocated sections by VMA, unallocated
3406 sections by file offset. */
3407 && (section
->sh_flags
& SHF_ALLOC
3408 ? (section
->sh_addr
>= segment
->p_vaddr
3409 && section
->sh_addr
+ section
->sh_size
3410 <= segment
->p_vaddr
+ segment
->p_memsz
)
3411 : ((bfd_vma
) section
->sh_offset
>= segment
->p_offset
3412 && (section
->sh_offset
+ section
->sh_size
3413 <= segment
->p_offset
+ segment
->p_filesz
))))
3414 printf ("%s ", SECTION_NAME (section
));
3421 free (program_headers
);
3428 get_32bit_section_headers (file
, num
)
3432 Elf32_External_Shdr
*shdrs
;
3433 Elf_Internal_Shdr
*internal
;
3436 shdrs
= ((Elf32_External_Shdr
*)
3437 get_data (NULL
, file
, elf_header
.e_shoff
,
3438 elf_header
.e_shentsize
* num
,
3439 _("section headers")));
3443 section_headers
= ((Elf_Internal_Shdr
*)
3444 malloc (num
* sizeof (Elf_Internal_Shdr
)));
3446 if (section_headers
== NULL
)
3448 error (_("Out of memory\n"));
3452 for (i
= 0, internal
= section_headers
;
3456 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3457 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3458 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
3459 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
3460 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3461 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
3462 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3463 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3464 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3465 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
3474 get_64bit_section_headers (file
, num
)
3478 Elf64_External_Shdr
*shdrs
;
3479 Elf_Internal_Shdr
*internal
;
3482 shdrs
= ((Elf64_External_Shdr
*)
3483 get_data (NULL
, file
, elf_header
.e_shoff
,
3484 elf_header
.e_shentsize
* num
,
3485 _("section headers")));
3489 section_headers
= ((Elf_Internal_Shdr
*)
3490 malloc (num
* sizeof (Elf_Internal_Shdr
)));
3492 if (section_headers
== NULL
)
3494 error (_("Out of memory\n"));
3498 for (i
= 0, internal
= section_headers
;
3502 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3503 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3504 internal
->sh_flags
= BYTE_GET8 (shdrs
[i
].sh_flags
);
3505 internal
->sh_addr
= BYTE_GET8 (shdrs
[i
].sh_addr
);
3506 internal
->sh_size
= BYTE_GET8 (shdrs
[i
].sh_size
);
3507 internal
->sh_entsize
= BYTE_GET8 (shdrs
[i
].sh_entsize
);
3508 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3509 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3510 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3511 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3519 static Elf_Internal_Sym
*
3520 get_32bit_elf_symbols (file
, section
)
3522 Elf_Internal_Shdr
*section
;
3524 unsigned long number
;
3525 Elf32_External_Sym
*esyms
;
3526 Elf_External_Sym_Shndx
*shndx
;
3527 Elf_Internal_Sym
*isyms
;
3528 Elf_Internal_Sym
*psym
;
3531 esyms
= ((Elf32_External_Sym
*)
3532 get_data (NULL
, file
, section
->sh_offset
,
3533 section
->sh_size
, _("symbols")));
3538 if (symtab_shndx_hdr
!= NULL
3539 && (symtab_shndx_hdr
->sh_link
3540 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3542 shndx
= ((Elf_External_Sym_Shndx
*)
3543 get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3544 symtab_shndx_hdr
->sh_size
, _("symtab shndx")));
3552 number
= section
->sh_size
/ section
->sh_entsize
;
3553 isyms
= (Elf_Internal_Sym
*) malloc (number
* sizeof (Elf_Internal_Sym
));
3557 error (_("Out of memory\n"));
3564 for (j
= 0, psym
= isyms
;
3568 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3569 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3570 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3571 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3572 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3574 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3575 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3576 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3586 static Elf_Internal_Sym
*
3587 get_64bit_elf_symbols (file
, section
)
3589 Elf_Internal_Shdr
*section
;
3591 unsigned long number
;
3592 Elf64_External_Sym
*esyms
;
3593 Elf_External_Sym_Shndx
*shndx
;
3594 Elf_Internal_Sym
*isyms
;
3595 Elf_Internal_Sym
*psym
;
3598 esyms
= ((Elf64_External_Sym
*)
3599 get_data (NULL
, file
, section
->sh_offset
,
3600 section
->sh_size
, _("symbols")));
3605 if (symtab_shndx_hdr
!= NULL
3606 && (symtab_shndx_hdr
->sh_link
3607 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3609 shndx
= ((Elf_External_Sym_Shndx
*)
3610 get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3611 symtab_shndx_hdr
->sh_size
, _("symtab shndx")));
3619 number
= section
->sh_size
/ section
->sh_entsize
;
3620 isyms
= (Elf_Internal_Sym
*) malloc (number
* sizeof (Elf_Internal_Sym
));
3624 error (_("Out of memory\n"));
3631 for (j
= 0, psym
= isyms
;
3635 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3636 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3637 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3638 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3639 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3641 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3642 psym
->st_value
= BYTE_GET8 (esyms
[j
].st_value
);
3643 psym
->st_size
= BYTE_GET8 (esyms
[j
].st_size
);
3654 get_elf_section_flags (sh_flags
)
3657 static char buff
[32];
3665 flag
= sh_flags
& - sh_flags
;
3670 case SHF_WRITE
: strcat (buff
, "W"); break;
3671 case SHF_ALLOC
: strcat (buff
, "A"); break;
3672 case SHF_EXECINSTR
: strcat (buff
, "X"); break;
3673 case SHF_MERGE
: strcat (buff
, "M"); break;
3674 case SHF_STRINGS
: strcat (buff
, "S"); break;
3675 case SHF_INFO_LINK
: strcat (buff
, "I"); break;
3676 case SHF_LINK_ORDER
: strcat (buff
, "L"); break;
3677 case SHF_OS_NONCONFORMING
: strcat (buff
, "O"); break;
3678 case SHF_GROUP
: strcat (buff
, "G"); break;
3679 case SHF_TLS
: strcat (buff
, "T"); break;
3682 if (flag
& SHF_MASKOS
)
3685 sh_flags
&= ~ SHF_MASKOS
;
3687 else if (flag
& SHF_MASKPROC
)
3690 sh_flags
&= ~ SHF_MASKPROC
;
3702 process_section_headers (file
)
3705 Elf_Internal_Shdr
*section
;
3708 section_headers
= NULL
;
3710 if (elf_header
.e_shnum
== 0)
3713 printf (_("\nThere are no sections in this file.\n"));
3718 if (do_sections
&& !do_header
)
3719 printf (_("There are %d section headers, starting at offset 0x%lx:\n"),
3720 elf_header
.e_shnum
, (unsigned long) elf_header
.e_shoff
);
3724 if (! get_32bit_section_headers (file
, elf_header
.e_shnum
))
3727 else if (! get_64bit_section_headers (file
, elf_header
.e_shnum
))
3730 /* Read in the string table, so that we have names to display. */
3731 section
= SECTION_HEADER (elf_header
.e_shstrndx
);
3733 if (section
->sh_size
!= 0)
3735 string_table
= (char *) get_data (NULL
, file
, section
->sh_offset
,
3736 section
->sh_size
, _("string table"));
3738 string_table_length
= section
->sh_size
;
3741 /* Scan the sections for the dynamic symbol table
3742 and dynamic string table and debug sections. */
3743 dynamic_symbols
= NULL
;
3744 dynamic_strings
= NULL
;
3745 dynamic_syminfo
= NULL
;
3746 symtab_shndx_hdr
= NULL
;
3748 for (i
= 0, section
= section_headers
;
3749 i
< elf_header
.e_shnum
;
3752 char *name
= SECTION_NAME (section
);
3754 if (section
->sh_type
== SHT_DYNSYM
)
3756 if (dynamic_symbols
!= NULL
)
3758 error (_("File contains multiple dynamic symbol tables\n"));
3762 num_dynamic_syms
= section
->sh_size
/ section
->sh_entsize
;
3763 dynamic_symbols
= GET_ELF_SYMBOLS (file
, section
);
3765 else if (section
->sh_type
== SHT_STRTAB
3766 && strcmp (name
, ".dynstr") == 0)
3768 if (dynamic_strings
!= NULL
)
3770 error (_("File contains multiple dynamic string tables\n"));
3774 dynamic_strings
= (char *) get_data (NULL
, file
, section
->sh_offset
,
3776 _("dynamic strings"));
3778 else if (section
->sh_type
== SHT_SYMTAB_SHNDX
)
3780 if (symtab_shndx_hdr
!= NULL
)
3782 error (_("File contains multiple symtab shndx tables\n"));
3785 symtab_shndx_hdr
= section
;
3787 else if ((do_debugging
|| do_debug_info
|| do_debug_abbrevs
3788 || do_debug_lines
|| do_debug_pubnames
|| do_debug_aranges
3789 || do_debug_frames
|| do_debug_macinfo
|| do_debug_str
3791 && strncmp (name
, ".debug_", 7) == 0)
3796 || (do_debug_info
&& (strcmp (name
, "info") == 0))
3797 || (do_debug_abbrevs
&& (strcmp (name
, "abbrev") == 0))
3798 || (do_debug_lines
&& (strcmp (name
, "line") == 0))
3799 || (do_debug_pubnames
&& (strcmp (name
, "pubnames") == 0))
3800 || (do_debug_aranges
&& (strcmp (name
, "aranges") == 0))
3801 || (do_debug_frames
&& (strcmp (name
, "frame") == 0))
3802 || (do_debug_macinfo
&& (strcmp (name
, "macinfo") == 0))
3803 || (do_debug_str
&& (strcmp (name
, "str") == 0))
3804 || (do_debug_loc
&& (strcmp (name
, "loc") == 0))
3806 request_dump (i
, DEBUG_DUMP
);
3808 /* linkonce section to be combined with .debug_info at link time. */
3809 else if ((do_debugging
|| do_debug_info
)
3810 && strncmp (name
, ".gnu.linkonce.wi.", 17) == 0)
3811 request_dump (i
, DEBUG_DUMP
);
3812 else if (do_debug_frames
&& strcmp (name
, ".eh_frame") == 0)
3813 request_dump (i
, DEBUG_DUMP
);
3819 if (elf_header
.e_shnum
> 1)
3820 printf (_("\nSection Headers:\n"));
3822 printf (_("\nSection Header:\n"));
3826 (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
3829 (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n"));
3832 printf (_(" [Nr] Name Type Address Offset\n"));
3833 printf (_(" Size EntSize Flags Link Info Align\n"));
3836 for (i
= 0, section
= section_headers
;
3837 i
< elf_header
.e_shnum
;
3840 printf (" [%2u] %-17.17s %-15.15s ",
3841 SECTION_HEADER_NUM (i
),
3842 SECTION_NAME (section
),
3843 get_section_type_name (section
->sh_type
));
3847 print_vma (section
->sh_addr
, LONG_HEX
);
3849 printf ( " %6.6lx %6.6lx %2.2lx",
3850 (unsigned long) section
->sh_offset
,
3851 (unsigned long) section
->sh_size
,
3852 (unsigned long) section
->sh_entsize
);
3854 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
3856 printf ("%2ld %3lx %2ld\n",
3857 (unsigned long) section
->sh_link
,
3858 (unsigned long) section
->sh_info
,
3859 (unsigned long) section
->sh_addralign
);
3863 print_vma (section
->sh_addr
, LONG_HEX
);
3865 if ((long) section
->sh_offset
== section
->sh_offset
)
3866 printf (" %6.6lx", (unsigned long) section
->sh_offset
);
3870 print_vma (section
->sh_offset
, LONG_HEX
);
3873 if ((unsigned long) section
->sh_size
== section
->sh_size
)
3874 printf (" %6.6lx", (unsigned long) section
->sh_size
);
3878 print_vma (section
->sh_size
, LONG_HEX
);
3881 if ((unsigned long) section
->sh_entsize
== section
->sh_entsize
)
3882 printf (" %2.2lx", (unsigned long) section
->sh_entsize
);
3886 print_vma (section
->sh_entsize
, LONG_HEX
);
3889 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
3891 printf ("%2ld %3lx ",
3892 (unsigned long) section
->sh_link
,
3893 (unsigned long) section
->sh_info
);
3895 if ((unsigned long) section
->sh_addralign
== section
->sh_addralign
)
3896 printf ("%2ld\n", (unsigned long) section
->sh_addralign
);
3899 print_vma (section
->sh_addralign
, DEC
);
3906 print_vma (section
->sh_addr
, LONG_HEX
);
3907 if ((long) section
->sh_offset
== section
->sh_offset
)
3908 printf (" %8.8lx", (unsigned long) section
->sh_offset
);
3912 print_vma (section
->sh_offset
, LONG_HEX
);
3915 print_vma (section
->sh_size
, LONG_HEX
);
3917 print_vma (section
->sh_entsize
, LONG_HEX
);
3919 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
3921 printf (" %2ld %3lx %ld\n",
3922 (unsigned long) section
->sh_link
,
3923 (unsigned long) section
->sh_info
,
3924 (unsigned long) section
->sh_addralign
);
3928 printf (_("Key to Flags:\n\
3929 W (write), A (alloc), X (execute), M (merge), S (strings)\n\
3930 I (info), L (link order), G (group), x (unknown)\n\
3931 O (extra OS processing required) o (OS specific), p (processor specific)\n"));
3942 } dynamic_relocations
[] =
3944 { "REL", DT_REL
, DT_RELSZ
, FALSE
},
3945 { "RELA", DT_RELA
, DT_RELASZ
, TRUE
},
3946 { "PLT", DT_JMPREL
, DT_PLTRELSZ
, UNKNOWN
}
3949 /* Process the reloc section. */
3951 process_relocs (file
)
3954 unsigned long rel_size
;
3955 unsigned long rel_offset
;
3961 if (do_using_dynamic
)
3965 int has_dynamic_reloc
;
3968 has_dynamic_reloc
= 0;
3970 for (i
= 0; i
< ARRAY_SIZE (dynamic_relocations
); i
++)
3972 is_rela
= dynamic_relocations
[i
].rela
;
3973 name
= dynamic_relocations
[i
].name
;
3974 rel_size
= dynamic_info
[dynamic_relocations
[i
].size
];
3975 rel_offset
= dynamic_info
[dynamic_relocations
[i
].reloc
];
3977 has_dynamic_reloc
|= rel_size
;
3979 if (is_rela
== UNKNOWN
)
3981 if (dynamic_relocations
[i
].reloc
== DT_JMPREL
)
3982 switch (dynamic_info
[DT_PLTREL
])
3996 (_("\n'%s' relocation section at offset 0x%lx contains %ld bytes:\n"),
3997 name
, rel_offset
, rel_size
);
3999 dump_relocations (file
, rel_offset
- loadaddr
, rel_size
,
4000 dynamic_symbols
, num_dynamic_syms
,
4001 dynamic_strings
, is_rela
);
4005 if (! has_dynamic_reloc
)
4006 printf (_("\nThere are no dynamic relocations in this file.\n"));
4010 Elf_Internal_Shdr
*section
;
4014 for (i
= 0, section
= section_headers
;
4015 i
< elf_header
.e_shnum
;
4018 if ( section
->sh_type
!= SHT_RELA
4019 && section
->sh_type
!= SHT_REL
)
4022 rel_offset
= section
->sh_offset
;
4023 rel_size
= section
->sh_size
;
4027 Elf_Internal_Shdr
*strsec
;
4028 Elf_Internal_Sym
*symtab
;
4031 unsigned long nsyms
;
4033 printf (_("\nRelocation section "));
4035 if (string_table
== NULL
)
4036 printf ("%d", section
->sh_name
);
4038 printf (_("'%s'"), SECTION_NAME (section
));
4040 printf (_(" at offset 0x%lx contains %lu entries:\n"),
4041 rel_offset
, (unsigned long) (rel_size
/ section
->sh_entsize
));
4046 if (section
->sh_link
)
4048 Elf_Internal_Shdr
*symsec
;
4050 symsec
= SECTION_HEADER (section
->sh_link
);
4051 nsyms
= symsec
->sh_size
/ symsec
->sh_entsize
;
4052 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
4057 strsec
= SECTION_HEADER (symsec
->sh_link
);
4059 strtab
= (char *) get_data (NULL
, file
, strsec
->sh_offset
,
4063 is_rela
= section
->sh_type
== SHT_RELA
;
4065 dump_relocations (file
, rel_offset
, rel_size
,
4066 symtab
, nsyms
, strtab
, is_rela
);
4078 printf (_("\nThere are no relocations in this file.\n"));
4084 #include "unwind-ia64.h"
4086 /* An absolute address consists of a section and an offset. If the
4087 section is NULL, the offset itself is the address, otherwise, the
4088 address equals to LOAD_ADDRESS(section) + offset. */
4092 unsigned short section
;
4098 struct unw_table_entry
4100 struct absaddr start
;
4102 struct absaddr info
;
4104 *table
; /* Unwind table. */
4105 unsigned long table_len
; /* Length of unwind table. */
4106 unsigned char *info
; /* Unwind info. */
4107 unsigned long info_size
; /* Size of unwind info. */
4108 bfd_vma info_addr
; /* starting address of unwind info. */
4109 bfd_vma seg_base
; /* Starting address of segment. */
4110 Elf_Internal_Sym
*symtab
; /* The symbol table. */
4111 unsigned long nsyms
; /* Number of symbols. */
4112 char *strtab
; /* The string table. */
4113 unsigned long strtab_size
; /* Size of string table. */
4116 static void find_symbol_for_address
4117 PARAMS ((struct unw_aux_info
*, struct absaddr
, const char **, bfd_vma
*));
4118 static void dump_ia64_unwind
4119 PARAMS ((struct unw_aux_info
*));
4120 static int slurp_ia64_unwind_table
4121 PARAMS ((FILE *, struct unw_aux_info
*, Elf_Internal_Shdr
*));
4124 find_symbol_for_address (aux
, addr
, symname
, offset
)
4125 struct unw_aux_info
*aux
;
4126 struct absaddr addr
;
4127 const char **symname
;
4130 bfd_vma dist
= (bfd_vma
) 0x100000;
4131 Elf_Internal_Sym
*sym
, *best
= NULL
;
4134 for (i
= 0, sym
= aux
->symtab
; i
< aux
->nsyms
; ++i
, ++sym
)
4136 if (ELF_ST_TYPE (sym
->st_info
) == STT_FUNC
4137 && sym
->st_name
!= 0
4138 && (addr
.section
== SHN_UNDEF
|| addr
.section
== sym
->st_shndx
)
4139 && addr
.offset
>= sym
->st_value
4140 && addr
.offset
- sym
->st_value
< dist
)
4143 dist
= addr
.offset
- sym
->st_value
;
4150 *symname
= (best
->st_name
>= aux
->strtab_size
4151 ? "<corrupt>" : aux
->strtab
+ best
->st_name
);
4156 *offset
= addr
.offset
;
4160 dump_ia64_unwind (aux
)
4161 struct unw_aux_info
*aux
;
4164 struct unw_table_entry
*tp
;
4167 addr_size
= is_32bit_elf
? 4 : 8;
4169 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
4173 const unsigned char *dp
;
4174 const unsigned char *head
;
4175 const char *procname
;
4177 find_symbol_for_address (aux
, tp
->start
, &procname
, &offset
);
4179 fputs ("\n<", stdout
);
4183 fputs (procname
, stdout
);
4186 printf ("+%lx", (unsigned long) offset
);
4189 fputs (">: [", stdout
);
4190 print_vma (tp
->start
.offset
, PREFIX_HEX
);
4191 fputc ('-', stdout
);
4192 print_vma (tp
->end
.offset
, PREFIX_HEX
);
4193 printf ("], info at +0x%lx\n",
4194 (unsigned long) (tp
->info
.offset
- aux
->seg_base
));
4196 head
= aux
->info
+ (tp
->info
.offset
- aux
->info_addr
);
4197 stamp
= BYTE_GET8 ((unsigned char *) head
);
4199 printf (" v%u, flags=0x%lx (%s%s), len=%lu bytes\n",
4200 (unsigned) UNW_VER (stamp
),
4201 (unsigned long) ((stamp
& UNW_FLAG_MASK
) >> 32),
4202 UNW_FLAG_EHANDLER (stamp
) ? " ehandler" : "",
4203 UNW_FLAG_UHANDLER (stamp
) ? " uhandler" : "",
4204 (unsigned long) (addr_size
* UNW_LENGTH (stamp
)));
4206 if (UNW_VER (stamp
) != 1)
4208 printf ("\tUnknown version.\n");
4213 for (dp
= head
+ 8; dp
< head
+ 8 + addr_size
* UNW_LENGTH (stamp
);)
4214 dp
= unw_decode (dp
, in_body
, & in_body
);
4219 slurp_ia64_unwind_table (file
, aux
, sec
)
4221 struct unw_aux_info
*aux
;
4222 Elf_Internal_Shdr
*sec
;
4224 unsigned long size
, addr_size
, nrelas
, i
;
4225 Elf_Internal_Phdr
*prog_hdrs
, *seg
;
4226 struct unw_table_entry
*tep
;
4227 Elf_Internal_Shdr
*relsec
;
4228 Elf_Internal_Rela
*rela
, *rp
;
4229 unsigned char *table
, *tp
;
4230 Elf_Internal_Sym
*sym
;
4231 const char *relname
;
4234 addr_size
= is_32bit_elf
? 4 : 8;
4236 /* First, find the starting address of the segment that includes
4239 if (elf_header
.e_phnum
)
4241 prog_hdrs
= (Elf_Internal_Phdr
*)
4242 xmalloc (elf_header
.e_phnum
* sizeof (Elf_Internal_Phdr
));
4245 result
= get_32bit_program_headers (file
, prog_hdrs
);
4247 result
= get_64bit_program_headers (file
, prog_hdrs
);
4255 for (seg
= prog_hdrs
; seg
< prog_hdrs
+ elf_header
.e_phnum
; ++seg
)
4257 if (seg
->p_type
!= PT_LOAD
)
4260 if (sec
->sh_addr
>= seg
->p_vaddr
4261 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
4263 aux
->seg_base
= seg
->p_vaddr
;
4271 /* Second, build the unwind table from the contents of the unwind section: */
4272 size
= sec
->sh_size
;
4273 table
= (char *) get_data (NULL
, file
, sec
->sh_offset
,
4274 size
, _("unwind table"));
4278 tep
= aux
->table
= xmalloc (size
/ (3 * addr_size
) * sizeof (aux
->table
[0]));
4279 for (tp
= table
; tp
< table
+ size
; tp
+= 3 * addr_size
, ++tep
)
4281 tep
->start
.section
= SHN_UNDEF
;
4282 tep
->end
.section
= SHN_UNDEF
;
4283 tep
->info
.section
= SHN_UNDEF
;
4286 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
4287 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
4288 tep
->info
.offset
= byte_get ((unsigned char *) tp
+ 8, 4);
4292 tep
->start
.offset
= BYTE_GET8 ((unsigned char *) tp
+ 0);
4293 tep
->end
.offset
= BYTE_GET8 ((unsigned char *) tp
+ 8);
4294 tep
->info
.offset
= BYTE_GET8 ((unsigned char *) tp
+ 16);
4296 tep
->start
.offset
+= aux
->seg_base
;
4297 tep
->end
.offset
+= aux
->seg_base
;
4298 tep
->info
.offset
+= aux
->seg_base
;
4302 /* Third, apply any relocations to the unwind table: */
4304 for (relsec
= section_headers
;
4305 relsec
< section_headers
+ elf_header
.e_shnum
;
4308 if (relsec
->sh_type
!= SHT_RELA
4309 || SECTION_HEADER (relsec
->sh_info
) != sec
)
4312 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
4316 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
4320 relname
= elf_ia64_reloc_type (ELF32_R_TYPE (rp
->r_info
));
4321 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
4323 if (ELF32_ST_TYPE (sym
->st_info
) != STT_SECTION
)
4325 warn (_("Skipping unexpected symbol type %u\n"),
4326 ELF32_ST_TYPE (sym
->st_info
));
4332 relname
= elf_ia64_reloc_type (ELF64_R_TYPE (rp
->r_info
));
4333 sym
= aux
->symtab
+ ELF64_R_SYM (rp
->r_info
);
4335 if (ELF64_ST_TYPE (sym
->st_info
) != STT_SECTION
)
4337 warn (_("Skipping unexpected symbol type %u\n"),
4338 ELF64_ST_TYPE (sym
->st_info
));
4343 if (strncmp (relname
, "R_IA64_SEGREL", 13) != 0)
4345 warn (_("Skipping unexpected relocation type %s\n"), relname
);
4349 i
= rp
->r_offset
/ (3 * addr_size
);
4351 switch (rp
->r_offset
/addr_size
% 3)
4354 aux
->table
[i
].start
.section
= sym
->st_shndx
;
4355 aux
->table
[i
].start
.offset
+= rp
->r_addend
;
4358 aux
->table
[i
].end
.section
= sym
->st_shndx
;
4359 aux
->table
[i
].end
.offset
+= rp
->r_addend
;
4362 aux
->table
[i
].info
.section
= sym
->st_shndx
;
4363 aux
->table
[i
].info
.offset
+= rp
->r_addend
;
4373 aux
->table_len
= size
/ (3 * addr_size
);
4378 process_unwind (file
)
4381 Elf_Internal_Shdr
*sec
, *unwsec
= NULL
, *strsec
;
4382 unsigned long i
, addr_size
, unwcount
= 0, unwstart
= 0;
4383 struct unw_aux_info aux
;
4388 if (elf_header
.e_machine
!= EM_IA_64
)
4390 printf (_("\nThere are no unwind sections in this file.\n"));
4394 memset (& aux
, 0, sizeof (aux
));
4396 addr_size
= is_32bit_elf
? 4 : 8;
4398 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
4400 if (sec
->sh_type
== SHT_SYMTAB
)
4402 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
4403 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
4405 strsec
= SECTION_HEADER (sec
->sh_link
);
4406 aux
.strtab_size
= strsec
->sh_size
;
4407 aux
.strtab
= (char *) get_data (NULL
, file
, strsec
->sh_offset
,
4408 aux
.strtab_size
, _("string table"));
4410 else if (sec
->sh_type
== SHT_IA_64_UNWIND
)
4415 printf (_("\nThere are no unwind sections in this file.\n"));
4417 while (unwcount
-- > 0)
4422 for (i
= unwstart
, sec
= section_headers
+ unwstart
;
4423 i
< elf_header
.e_shnum
; ++i
, ++sec
)
4424 if (sec
->sh_type
== SHT_IA_64_UNWIND
)
4431 len
= sizeof (ELF_STRING_ia64_unwind_once
) - 1;
4433 if (strncmp (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind_once
,
4436 /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO */
4437 len2
= sizeof (ELF_STRING_ia64_unwind_info_once
) - 1;
4438 suffix
= SECTION_NAME (unwsec
) + len
;
4439 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
4441 if (strncmp (SECTION_NAME (sec
),
4442 ELF_STRING_ia64_unwind_info_once
, len2
) == 0
4443 && strcmp (SECTION_NAME (sec
) + len2
, suffix
) == 0)
4448 /* .IA_64.unwindFOO -> .IA_64.unwind_infoFOO
4449 .IA_64.unwind or BAR -> .IA_64.unwind_info */
4450 len
= sizeof (ELF_STRING_ia64_unwind
) - 1;
4451 len2
= sizeof (ELF_STRING_ia64_unwind_info
) - 1;
4453 if (strncmp (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind
,
4455 suffix
= SECTION_NAME (unwsec
) + len
;
4456 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
4458 if (strncmp (SECTION_NAME (sec
),
4459 ELF_STRING_ia64_unwind_info
, len2
) == 0
4460 && strcmp (SECTION_NAME (sec
) + len2
, suffix
) == 0)
4464 if (i
== elf_header
.e_shnum
)
4466 printf (_("\nCould not find unwind info section for "));
4468 if (string_table
== NULL
)
4469 printf ("%d", unwsec
->sh_name
);
4471 printf (_("'%s'"), SECTION_NAME (unwsec
));
4475 aux
.info_size
= sec
->sh_size
;
4476 aux
.info_addr
= sec
->sh_addr
;
4477 aux
.info
= (char *) get_data (NULL
, file
, sec
->sh_offset
,
4478 aux
.info_size
, _("unwind info"));
4480 printf (_("\nUnwind section "));
4482 if (string_table
== NULL
)
4483 printf ("%d", unwsec
->sh_name
);
4485 printf (_("'%s'"), SECTION_NAME (unwsec
));
4487 printf (_(" at offset 0x%lx contains %lu entries:\n"),
4488 (unsigned long) unwsec
->sh_offset
,
4489 (unsigned long) (unwsec
->sh_size
/ (3 * addr_size
)));
4491 (void) slurp_ia64_unwind_table (file
, & aux
, unwsec
);
4493 if (aux
.table_len
> 0)
4494 dump_ia64_unwind (& aux
);
4497 free ((char *) aux
.table
);
4499 free ((char *) aux
.info
);
4508 free ((char *) aux
.strtab
);
4514 dynamic_segment_mips_val (entry
)
4515 Elf_Internal_Dyn
*entry
;
4517 switch (entry
->d_tag
)
4520 if (entry
->d_un
.d_val
== 0)
4524 static const char * opts
[] =
4526 "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT",
4527 "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS",
4528 "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD",
4529 "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF",
4534 for (cnt
= 0; cnt
< NUM_ELEM (opts
); ++cnt
)
4535 if (entry
->d_un
.d_val
& (1 << cnt
))
4537 printf ("%s%s", first
? "" : " ", opts
[cnt
]);
4544 case DT_MIPS_IVERSION
:
4545 if (dynamic_strings
!= NULL
)
4546 printf ("Interface Version: %s\n",
4547 dynamic_strings
+ entry
->d_un
.d_val
);
4549 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
4552 case DT_MIPS_TIME_STAMP
:
4557 time_t time
= entry
->d_un
.d_val
;
4558 tmp
= gmtime (&time
);
4559 sprintf (timebuf
, "%04u-%02u-%02uT%02u:%02u:%02u",
4560 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
4561 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
4562 printf ("Time Stamp: %s\n", timebuf
);
4566 case DT_MIPS_RLD_VERSION
:
4567 case DT_MIPS_LOCAL_GOTNO
:
4568 case DT_MIPS_CONFLICTNO
:
4569 case DT_MIPS_LIBLISTNO
:
4570 case DT_MIPS_SYMTABNO
:
4571 case DT_MIPS_UNREFEXTNO
:
4572 case DT_MIPS_HIPAGENO
:
4573 case DT_MIPS_DELTA_CLASS_NO
:
4574 case DT_MIPS_DELTA_INSTANCE_NO
:
4575 case DT_MIPS_DELTA_RELOC_NO
:
4576 case DT_MIPS_DELTA_SYM_NO
:
4577 case DT_MIPS_DELTA_CLASSSYM_NO
:
4578 case DT_MIPS_COMPACT_SIZE
:
4579 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
4583 printf ("%#lx\n", (long) entry
->d_un
.d_ptr
);
4589 dynamic_segment_parisc_val (entry
)
4590 Elf_Internal_Dyn
*entry
;
4592 switch (entry
->d_tag
)
4594 case DT_HP_DLD_FLAGS
:
4603 { DT_HP_DEBUG_PRIVATE
, "HP_DEBUG_PRIVATE" },
4604 { DT_HP_DEBUG_CALLBACK
, "HP_DEBUG_CALLBACK" },
4605 { DT_HP_DEBUG_CALLBACK_BOR
, "HP_DEBUG_CALLBACK_BOR" },
4606 { DT_HP_NO_ENVVAR
, "HP_NO_ENVVAR" },
4607 { DT_HP_BIND_NOW
, "HP_BIND_NOW" },
4608 { DT_HP_BIND_NONFATAL
, "HP_BIND_NONFATAL" },
4609 { DT_HP_BIND_VERBOSE
, "HP_BIND_VERBOSE" },
4610 { DT_HP_BIND_RESTRICTED
, "HP_BIND_RESTRICTED" },
4611 { DT_HP_BIND_SYMBOLIC
, "HP_BIND_SYMBOLIC" },
4612 { DT_HP_RPATH_FIRST
, "HP_RPATH_FIRST" },
4613 { DT_HP_BIND_DEPTH_FIRST
, "HP_BIND_DEPTH_FIRST" }
4617 bfd_vma val
= entry
->d_un
.d_val
;
4619 for (cnt
= 0; cnt
< sizeof (flags
) / sizeof (flags
[0]); ++cnt
)
4620 if (val
& flags
[cnt
].bit
)
4624 fputs (flags
[cnt
].str
, stdout
);
4626 val
^= flags
[cnt
].bit
;
4629 if (val
!= 0 || first
)
4633 print_vma (val
, HEX
);
4639 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
4646 dynamic_segment_ia64_val (entry
)
4647 Elf_Internal_Dyn
*entry
;
4649 switch (entry
->d_tag
)
4651 case DT_IA_64_PLT_RESERVE
:
4652 /* First 3 bytes reserved. */
4653 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
4655 print_vma (entry
->d_un
.d_ptr
+ (3 * 8), PREFIX_HEX
);
4661 get_32bit_dynamic_segment (file
)
4664 Elf32_External_Dyn
*edyn
;
4665 Elf_Internal_Dyn
*entry
;
4668 edyn
= (Elf32_External_Dyn
*) get_data (NULL
, file
, dynamic_addr
,
4669 dynamic_size
, _("dynamic segment"));
4673 /* SGI's ELF has more than one section in the DYNAMIC segment. Determine
4674 how large this .dynamic is now. We can do this even before the byte
4675 swapping since the DT_NULL tag is recognizable. */
4677 while (*(Elf32_Word
*) edyn
[dynamic_size
++].d_tag
!= DT_NULL
)
4680 dynamic_segment
= (Elf_Internal_Dyn
*)
4681 malloc (dynamic_size
* sizeof (Elf_Internal_Dyn
));
4683 if (dynamic_segment
== NULL
)
4685 error (_("Out of memory\n"));
4690 for (i
= 0, entry
= dynamic_segment
;
4694 entry
->d_tag
= BYTE_GET (edyn
[i
].d_tag
);
4695 entry
->d_un
.d_val
= BYTE_GET (edyn
[i
].d_un
.d_val
);
4704 get_64bit_dynamic_segment (file
)
4707 Elf64_External_Dyn
*edyn
;
4708 Elf_Internal_Dyn
*entry
;
4711 edyn
= (Elf64_External_Dyn
*) get_data (NULL
, file
, dynamic_addr
,
4712 dynamic_size
, _("dynamic segment"));
4716 /* SGI's ELF has more than one section in the DYNAMIC segment. Determine
4717 how large this .dynamic is now. We can do this even before the byte
4718 swapping since the DT_NULL tag is recognizable. */
4720 while (*(bfd_vma
*) edyn
[dynamic_size
++].d_tag
!= DT_NULL
)
4723 dynamic_segment
= (Elf_Internal_Dyn
*)
4724 malloc (dynamic_size
* sizeof (Elf_Internal_Dyn
));
4726 if (dynamic_segment
== NULL
)
4728 error (_("Out of memory\n"));
4733 for (i
= 0, entry
= dynamic_segment
;
4737 entry
->d_tag
= BYTE_GET8 (edyn
[i
].d_tag
);
4738 entry
->d_un
.d_val
= BYTE_GET8 (edyn
[i
].d_un
.d_val
);
4747 get_dynamic_flags (flags
)
4750 static char buff
[128];
4758 flag
= flags
& - flags
;
4766 case DF_ORIGIN
: strcpy (p
, "ORIGIN"); break;
4767 case DF_SYMBOLIC
: strcpy (p
, "SYMBOLIC"); break;
4768 case DF_TEXTREL
: strcpy (p
, "TEXTREL"); break;
4769 case DF_BIND_NOW
: strcpy (p
, "BIND_NOW"); break;
4770 case DF_STATIC_TLS
: strcpy (p
, "STATIC_TLS"); break;
4771 default: strcpy (p
, "unknown"); break;
4774 p
= strchr (p
, '\0');
4779 /* Parse and display the contents of the dynamic segment. */
4781 process_dynamic_segment (file
)
4784 Elf_Internal_Dyn
*entry
;
4787 if (dynamic_size
== 0)
4790 printf (_("\nThere is no dynamic segment in this file.\n"));
4797 if (! get_32bit_dynamic_segment (file
))
4800 else if (! get_64bit_dynamic_segment (file
))
4803 /* Find the appropriate symbol table. */
4804 if (dynamic_symbols
== NULL
)
4806 for (i
= 0, entry
= dynamic_segment
;
4810 Elf_Internal_Shdr section
;
4812 if (entry
->d_tag
!= DT_SYMTAB
)
4815 dynamic_info
[DT_SYMTAB
] = entry
->d_un
.d_val
;
4817 /* Since we do not know how big the symbol table is,
4818 we default to reading in the entire file (!) and
4819 processing that. This is overkill, I know, but it
4821 section
.sh_offset
= entry
->d_un
.d_val
- loadaddr
;
4823 if (fseek (file
, 0, SEEK_END
))
4824 error (_("Unable to seek to end of file!"));
4826 section
.sh_size
= ftell (file
) - section
.sh_offset
;
4828 section
.sh_entsize
= sizeof (Elf32_External_Sym
);
4830 section
.sh_entsize
= sizeof (Elf64_External_Sym
);
4832 num_dynamic_syms
= section
.sh_size
/ section
.sh_entsize
;
4833 if (num_dynamic_syms
< 1)
4835 error (_("Unable to determine the number of symbols to load\n"));
4839 dynamic_symbols
= GET_ELF_SYMBOLS (file
, §ion
);
4843 /* Similarly find a string table. */
4844 if (dynamic_strings
== NULL
)
4846 for (i
= 0, entry
= dynamic_segment
;
4850 unsigned long offset
;
4853 if (entry
->d_tag
!= DT_STRTAB
)
4856 dynamic_info
[DT_STRTAB
] = entry
->d_un
.d_val
;
4858 /* Since we do not know how big the string table is,
4859 we default to reading in the entire file (!) and
4860 processing that. This is overkill, I know, but it
4863 offset
= entry
->d_un
.d_val
- loadaddr
;
4864 if (fseek (file
, 0, SEEK_END
))
4865 error (_("Unable to seek to end of file\n"));
4866 str_tab_len
= ftell (file
) - offset
;
4868 if (str_tab_len
< 1)
4871 (_("Unable to determine the length of the dynamic string table\n"));
4875 dynamic_strings
= (char *) get_data (NULL
, file
, offset
, str_tab_len
,
4876 _("dynamic string table"));
4881 /* And find the syminfo section if available. */
4882 if (dynamic_syminfo
== NULL
)
4884 unsigned long syminsz
= 0;
4886 for (i
= 0, entry
= dynamic_segment
;
4890 if (entry
->d_tag
== DT_SYMINENT
)
4892 /* Note: these braces are necessary to avoid a syntax
4893 error from the SunOS4 C compiler. */
4894 assert (sizeof (Elf_External_Syminfo
) == entry
->d_un
.d_val
);
4896 else if (entry
->d_tag
== DT_SYMINSZ
)
4897 syminsz
= entry
->d_un
.d_val
;
4898 else if (entry
->d_tag
== DT_SYMINFO
)
4899 dynamic_syminfo_offset
= entry
->d_un
.d_val
- loadaddr
;
4902 if (dynamic_syminfo_offset
!= 0 && syminsz
!= 0)
4904 Elf_External_Syminfo
*extsyminfo
;
4905 Elf_Internal_Syminfo
*syminfo
;
4907 /* There is a syminfo section. Read the data. */
4908 extsyminfo
= ((Elf_External_Syminfo
*)
4909 get_data (NULL
, file
, dynamic_syminfo_offset
,
4910 syminsz
, _("symbol information")));
4914 dynamic_syminfo
= (Elf_Internal_Syminfo
*) malloc (syminsz
);
4915 if (dynamic_syminfo
== NULL
)
4917 error (_("Out of memory\n"));
4921 dynamic_syminfo_nent
= syminsz
/ sizeof (Elf_External_Syminfo
);
4922 for (i
= 0, syminfo
= dynamic_syminfo
; i
< dynamic_syminfo_nent
;
4925 syminfo
->si_boundto
= BYTE_GET (extsyminfo
[i
].si_boundto
);
4926 syminfo
->si_flags
= BYTE_GET (extsyminfo
[i
].si_flags
);
4933 if (do_dynamic
&& dynamic_addr
)
4934 printf (_("\nDynamic segment at offset 0x%lx contains %ld entries:\n"),
4935 dynamic_addr
, (long) dynamic_size
);
4937 printf (_(" Tag Type Name/Value\n"));
4939 for (i
= 0, entry
= dynamic_segment
;
4948 print_vma (entry
->d_tag
, FULL_HEX
);
4949 dtype
= get_dynamic_type (entry
->d_tag
);
4950 printf (" (%s)%*s", dtype
,
4951 ((is_32bit_elf
? 27 : 19)
4952 - (int) strlen (dtype
)),
4956 switch (entry
->d_tag
)
4960 puts (get_dynamic_flags (entry
->d_un
.d_val
));
4970 switch (entry
->d_tag
)
4973 printf (_("Auxiliary library"));
4977 printf (_("Filter library"));
4981 printf (_("Configuration file"));
4985 printf (_("Dependency audit library"));
4989 printf (_("Audit library"));
4993 if (dynamic_strings
)
4994 printf (": [%s]\n", dynamic_strings
+ entry
->d_un
.d_val
);
4998 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
5007 printf (_("Flags:"));
5009 if (entry
->d_un
.d_val
== 0)
5010 printf (_(" None\n"));
5013 unsigned long int val
= entry
->d_un
.d_val
;
5015 if (val
& DTF_1_PARINIT
)
5017 printf (" PARINIT");
5018 val
^= DTF_1_PARINIT
;
5020 if (val
& DTF_1_CONFEXP
)
5022 printf (" CONFEXP");
5023 val
^= DTF_1_CONFEXP
;
5026 printf (" %lx", val
);
5035 printf (_("Flags:"));
5037 if (entry
->d_un
.d_val
== 0)
5038 printf (_(" None\n"));
5041 unsigned long int val
= entry
->d_un
.d_val
;
5043 if (val
& DF_P1_LAZYLOAD
)
5045 printf (" LAZYLOAD");
5046 val
^= DF_P1_LAZYLOAD
;
5048 if (val
& DF_P1_GROUPPERM
)
5050 printf (" GROUPPERM");
5051 val
^= DF_P1_GROUPPERM
;
5054 printf (" %lx", val
);
5063 printf (_("Flags:"));
5064 if (entry
->d_un
.d_val
== 0)
5065 printf (_(" None\n"));
5068 unsigned long int val
= entry
->d_un
.d_val
;
5075 if (val
& DF_1_GLOBAL
)
5080 if (val
& DF_1_GROUP
)
5085 if (val
& DF_1_NODELETE
)
5087 printf (" NODELETE");
5088 val
^= DF_1_NODELETE
;
5090 if (val
& DF_1_LOADFLTR
)
5092 printf (" LOADFLTR");
5093 val
^= DF_1_LOADFLTR
;
5095 if (val
& DF_1_INITFIRST
)
5097 printf (" INITFIRST");
5098 val
^= DF_1_INITFIRST
;
5100 if (val
& DF_1_NOOPEN
)
5105 if (val
& DF_1_ORIGIN
)
5110 if (val
& DF_1_DIRECT
)
5115 if (val
& DF_1_TRANS
)
5120 if (val
& DF_1_INTERPOSE
)
5122 printf (" INTERPOSE");
5123 val
^= DF_1_INTERPOSE
;
5125 if (val
& DF_1_NODEFLIB
)
5127 printf (" NODEFLIB");
5128 val
^= DF_1_NODEFLIB
;
5130 if (val
& DF_1_NODUMP
)
5135 if (val
& DF_1_CONLFAT
)
5137 printf (" CONLFAT");
5138 val
^= DF_1_CONLFAT
;
5141 printf (" %lx", val
);
5148 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
5150 puts (get_dynamic_type (entry
->d_un
.d_val
));
5170 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
5176 if (dynamic_strings
== NULL
)
5179 name
= dynamic_strings
+ entry
->d_un
.d_val
;
5183 switch (entry
->d_tag
)
5186 printf (_("Shared library: [%s]"), name
);
5188 if (strcmp (name
, program_interpreter
) == 0)
5189 printf (_(" program interpreter"));
5193 printf (_("Library soname: [%s]"), name
);
5197 printf (_("Library rpath: [%s]"), name
);
5201 printf (_("Library runpath: [%s]"), name
);
5205 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
5210 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
5223 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
5227 case DT_INIT_ARRAYSZ
:
5228 case DT_FINI_ARRAYSZ
:
5229 case DT_GNU_CONFLICTSZ
:
5230 case DT_GNU_LIBLISTSZ
:
5233 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
5234 printf (" (bytes)\n");
5244 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
5257 if (dynamic_strings
!= NULL
&& entry
->d_tag
== DT_USED
)
5261 name
= dynamic_strings
+ entry
->d_un
.d_val
;
5265 printf (_("Not needed object: [%s]\n"), name
);
5270 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
5276 /* The value of this entry is ignored. */
5281 case DT_GNU_PRELINKED
:
5285 time_t time
= entry
->d_un
.d_val
;
5287 tmp
= gmtime (&time
);
5288 printf ("%04u-%02u-%02uT%02u:%02u:%02u\n",
5289 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
5290 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
5296 if ((entry
->d_tag
>= DT_VERSYM
) && (entry
->d_tag
<= DT_VERNEEDNUM
))
5297 version_info
[DT_VERSIONTAGIDX (entry
->d_tag
)] =
5302 switch (elf_header
.e_machine
)
5305 case EM_MIPS_RS3_LE
:
5306 dynamic_segment_mips_val (entry
);
5309 dynamic_segment_parisc_val (entry
);
5312 dynamic_segment_ia64_val (entry
);
5315 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
5327 get_ver_flags (flags
)
5330 static char buff
[32];
5337 if (flags
& VER_FLG_BASE
)
5338 strcat (buff
, "BASE ");
5340 if (flags
& VER_FLG_WEAK
)
5342 if (flags
& VER_FLG_BASE
)
5343 strcat (buff
, "| ");
5345 strcat (buff
, "WEAK ");
5348 if (flags
& ~(VER_FLG_BASE
| VER_FLG_WEAK
))
5349 strcat (buff
, "| <unknown>");
5354 /* Display the contents of the version sections. */
5356 process_version_sections (file
)
5359 Elf_Internal_Shdr
*section
;
5366 for (i
= 0, section
= section_headers
;
5367 i
< elf_header
.e_shnum
;
5370 switch (section
->sh_type
)
5372 case SHT_GNU_verdef
:
5374 Elf_External_Verdef
*edefs
;
5381 (_("\nVersion definition section '%s' contains %ld entries:\n"),
5382 SECTION_NAME (section
), section
->sh_info
);
5384 printf (_(" Addr: 0x"));
5385 printf_vma (section
->sh_addr
);
5386 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
5387 (unsigned long) section
->sh_offset
, section
->sh_link
,
5388 SECTION_NAME (SECTION_HEADER (section
->sh_link
)));
5390 edefs
= ((Elf_External_Verdef
*)
5391 get_data (NULL
, file
, section
->sh_offset
,
5393 _("version definition section")));
5397 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
5400 Elf_External_Verdef
*edef
;
5401 Elf_Internal_Verdef ent
;
5402 Elf_External_Verdaux
*eaux
;
5403 Elf_Internal_Verdaux aux
;
5407 vstart
= ((char *) edefs
) + idx
;
5409 edef
= (Elf_External_Verdef
*) vstart
;
5411 ent
.vd_version
= BYTE_GET (edef
->vd_version
);
5412 ent
.vd_flags
= BYTE_GET (edef
->vd_flags
);
5413 ent
.vd_ndx
= BYTE_GET (edef
->vd_ndx
);
5414 ent
.vd_cnt
= BYTE_GET (edef
->vd_cnt
);
5415 ent
.vd_hash
= BYTE_GET (edef
->vd_hash
);
5416 ent
.vd_aux
= BYTE_GET (edef
->vd_aux
);
5417 ent
.vd_next
= BYTE_GET (edef
->vd_next
);
5419 printf (_(" %#06x: Rev: %d Flags: %s"),
5420 idx
, ent
.vd_version
, get_ver_flags (ent
.vd_flags
));
5422 printf (_(" Index: %d Cnt: %d "),
5423 ent
.vd_ndx
, ent
.vd_cnt
);
5425 vstart
+= ent
.vd_aux
;
5427 eaux
= (Elf_External_Verdaux
*) vstart
;
5429 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
5430 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
5432 if (dynamic_strings
)
5433 printf (_("Name: %s\n"), dynamic_strings
+ aux
.vda_name
);
5435 printf (_("Name index: %ld\n"), aux
.vda_name
);
5437 isum
= idx
+ ent
.vd_aux
;
5439 for (j
= 1; j
< ent
.vd_cnt
; j
++)
5441 isum
+= aux
.vda_next
;
5442 vstart
+= aux
.vda_next
;
5444 eaux
= (Elf_External_Verdaux
*) vstart
;
5446 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
5447 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
5449 if (dynamic_strings
)
5450 printf (_(" %#06x: Parent %d: %s\n"),
5451 isum
, j
, dynamic_strings
+ aux
.vda_name
);
5453 printf (_(" %#06x: Parent %d, name index: %ld\n"),
5454 isum
, j
, aux
.vda_name
);
5464 case SHT_GNU_verneed
:
5466 Elf_External_Verneed
*eneed
;
5472 printf (_("\nVersion needs section '%s' contains %ld entries:\n"),
5473 SECTION_NAME (section
), section
->sh_info
);
5475 printf (_(" Addr: 0x"));
5476 printf_vma (section
->sh_addr
);
5477 printf (_(" Offset: %#08lx Link to section: %ld (%s)\n"),
5478 (unsigned long) section
->sh_offset
, section
->sh_link
,
5479 SECTION_NAME (SECTION_HEADER (section
->sh_link
)));
5481 eneed
= ((Elf_External_Verneed
*)
5482 get_data (NULL
, file
, section
->sh_offset
,
5483 section
->sh_size
, _("version need section")));
5487 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
5489 Elf_External_Verneed
*entry
;
5490 Elf_Internal_Verneed ent
;
5495 vstart
= ((char *) eneed
) + idx
;
5497 entry
= (Elf_External_Verneed
*) vstart
;
5499 ent
.vn_version
= BYTE_GET (entry
->vn_version
);
5500 ent
.vn_cnt
= BYTE_GET (entry
->vn_cnt
);
5501 ent
.vn_file
= BYTE_GET (entry
->vn_file
);
5502 ent
.vn_aux
= BYTE_GET (entry
->vn_aux
);
5503 ent
.vn_next
= BYTE_GET (entry
->vn_next
);
5505 printf (_(" %#06x: Version: %d"), idx
, ent
.vn_version
);
5507 if (dynamic_strings
)
5508 printf (_(" File: %s"), dynamic_strings
+ ent
.vn_file
);
5510 printf (_(" File: %lx"), ent
.vn_file
);
5512 printf (_(" Cnt: %d\n"), ent
.vn_cnt
);
5514 vstart
+= ent
.vn_aux
;
5516 for (j
= 0, isum
= idx
+ ent
.vn_aux
; j
< ent
.vn_cnt
; ++j
)
5518 Elf_External_Vernaux
*eaux
;
5519 Elf_Internal_Vernaux aux
;
5521 eaux
= (Elf_External_Vernaux
*) vstart
;
5523 aux
.vna_hash
= BYTE_GET (eaux
->vna_hash
);
5524 aux
.vna_flags
= BYTE_GET (eaux
->vna_flags
);
5525 aux
.vna_other
= BYTE_GET (eaux
->vna_other
);
5526 aux
.vna_name
= BYTE_GET (eaux
->vna_name
);
5527 aux
.vna_next
= BYTE_GET (eaux
->vna_next
);
5529 if (dynamic_strings
)
5530 printf (_(" %#06x: Name: %s"),
5531 isum
, dynamic_strings
+ aux
.vna_name
);
5533 printf (_(" %#06x: Name index: %lx"),
5534 isum
, aux
.vna_name
);
5536 printf (_(" Flags: %s Version: %d\n"),
5537 get_ver_flags (aux
.vna_flags
), aux
.vna_other
);
5539 isum
+= aux
.vna_next
;
5540 vstart
+= aux
.vna_next
;
5550 case SHT_GNU_versym
:
5552 Elf_Internal_Shdr
*link_section
;
5555 unsigned char *edata
;
5556 unsigned short *data
;
5558 Elf_Internal_Sym
*symbols
;
5559 Elf_Internal_Shdr
*string_sec
;
5561 link_section
= SECTION_HEADER (section
->sh_link
);
5562 total
= section
->sh_size
/ section
->sh_entsize
;
5566 symbols
= GET_ELF_SYMBOLS (file
, link_section
);
5568 string_sec
= SECTION_HEADER (link_section
->sh_link
);
5570 strtab
= (char *) get_data (NULL
, file
, string_sec
->sh_offset
,
5571 string_sec
->sh_size
,
5572 _("version string table"));
5576 printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
5577 SECTION_NAME (section
), total
);
5579 printf (_(" Addr: "));
5580 printf_vma (section
->sh_addr
);
5581 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
5582 (unsigned long) section
->sh_offset
, section
->sh_link
,
5583 SECTION_NAME (link_section
));
5587 get_data (NULL
, file
,
5588 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] - loadaddr
,
5589 total
* sizeof (short), _("version symbol data")));
5596 data
= (unsigned short *) malloc (total
* sizeof (short));
5598 for (cnt
= total
; cnt
--;)
5599 data
[cnt
] = byte_get (edata
+ cnt
* sizeof (short),
5604 for (cnt
= 0; cnt
< total
; cnt
+= 4)
5607 int check_def
, check_need
;
5610 printf (" %03x:", cnt
);
5612 for (j
= 0; (j
< 4) && (cnt
+ j
) < total
; ++j
)
5613 switch (data
[cnt
+ j
])
5616 fputs (_(" 0 (*local*) "), stdout
);
5620 fputs (_(" 1 (*global*) "), stdout
);
5624 nn
= printf ("%4x%c", data
[cnt
+ j
] & 0x7fff,
5625 data
[cnt
+ j
] & 0x8000 ? 'h' : ' ');
5629 if (SECTION_HEADER (symbols
[cnt
+ j
].st_shndx
)->sh_type
5632 if (symbols
[cnt
+ j
].st_shndx
== SHN_UNDEF
)
5639 && version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)])
5641 Elf_Internal_Verneed ivn
;
5642 unsigned long offset
;
5644 offset
= version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
5649 Elf_Internal_Vernaux ivna
;
5650 Elf_External_Verneed evn
;
5651 Elf_External_Vernaux evna
;
5652 unsigned long a_off
;
5654 get_data (&evn
, file
, offset
, sizeof (evn
),
5657 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
5658 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
5660 a_off
= offset
+ ivn
.vn_aux
;
5664 get_data (&evna
, file
, a_off
, sizeof (evna
),
5665 _("version need aux (2)"));
5667 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
5668 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
5670 a_off
+= ivna
.vna_next
;
5672 while (ivna
.vna_other
!= data
[cnt
+ j
]
5673 && ivna
.vna_next
!= 0);
5675 if (ivna
.vna_other
== data
[cnt
+ j
])
5677 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
5679 name
= strtab
+ ivna
.vna_name
;
5680 nn
+= printf ("(%s%-*s",
5682 12 - (int) strlen (name
),
5688 offset
+= ivn
.vn_next
;
5690 while (ivn
.vn_next
);
5693 if (check_def
&& data
[cnt
+ j
] != 0x8001
5694 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
5696 Elf_Internal_Verdef ivd
;
5697 Elf_External_Verdef evd
;
5698 unsigned long offset
;
5700 offset
= (version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)]
5705 get_data (&evd
, file
, offset
, sizeof (evd
),
5708 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
5709 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
5711 offset
+= ivd
.vd_next
;
5713 while (ivd
.vd_ndx
!= (data
[cnt
+ j
] & 0x7fff)
5714 && ivd
.vd_next
!= 0);
5716 if (ivd
.vd_ndx
== (data
[cnt
+ j
] & 0x7fff))
5718 Elf_External_Verdaux evda
;
5719 Elf_Internal_Verdaux ivda
;
5721 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
5723 get_data (&evda
, file
,
5724 offset
- ivd
.vd_next
+ ivd
.vd_aux
,
5725 sizeof (evda
), _("version def aux"));
5727 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
5729 name
= strtab
+ ivda
.vda_name
;
5730 nn
+= printf ("(%s%-*s",
5732 12 - (int) strlen (name
),
5738 printf ("%*c", 18 - nn
, ' ');
5756 printf (_("\nNo version information found in this file.\n"));
5762 get_symbol_binding (binding
)
5763 unsigned int binding
;
5765 static char buff
[32];
5769 case STB_LOCAL
: return "LOCAL";
5770 case STB_GLOBAL
: return "GLOBAL";
5771 case STB_WEAK
: return "WEAK";
5773 if (binding
>= STB_LOPROC
&& binding
<= STB_HIPROC
)
5774 sprintf (buff
, _("<processor specific>: %d"), binding
);
5775 else if (binding
>= STB_LOOS
&& binding
<= STB_HIOS
)
5776 sprintf (buff
, _("<OS specific>: %d"), binding
);
5778 sprintf (buff
, _("<unknown>: %d"), binding
);
5784 get_symbol_type (type
)
5787 static char buff
[32];
5791 case STT_NOTYPE
: return "NOTYPE";
5792 case STT_OBJECT
: return "OBJECT";
5793 case STT_FUNC
: return "FUNC";
5794 case STT_SECTION
: return "SECTION";
5795 case STT_FILE
: return "FILE";
5796 case STT_COMMON
: return "COMMON";
5797 case STT_TLS
: return "TLS";
5799 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
5801 if (elf_header
.e_machine
== EM_ARM
&& type
== STT_ARM_TFUNC
)
5802 return "THUMB_FUNC";
5804 if (elf_header
.e_machine
== EM_SPARCV9
&& type
== STT_REGISTER
)
5807 if (elf_header
.e_machine
== EM_PARISC
&& type
== STT_PARISC_MILLI
)
5808 return "PARISC_MILLI";
5810 sprintf (buff
, _("<processor specific>: %d"), type
);
5812 else if (type
>= STT_LOOS
&& type
<= STT_HIOS
)
5814 if (elf_header
.e_machine
== EM_PARISC
)
5816 if (type
== STT_HP_OPAQUE
)
5818 if (type
== STT_HP_STUB
)
5822 sprintf (buff
, _("<OS specific>: %d"), type
);
5825 sprintf (buff
, _("<unknown>: %d"), type
);
5831 get_symbol_visibility (visibility
)
5832 unsigned int visibility
;
5836 case STV_DEFAULT
: return "DEFAULT";
5837 case STV_INTERNAL
: return "INTERNAL";
5838 case STV_HIDDEN
: return "HIDDEN";
5839 case STV_PROTECTED
: return "PROTECTED";
5845 get_symbol_index_type (type
)
5848 static char buff
[32];
5852 case SHN_UNDEF
: return "UND";
5853 case SHN_ABS
: return "ABS";
5854 case SHN_COMMON
: return "COM";
5856 if (type
>= SHN_LOPROC
&& type
<= SHN_HIPROC
)
5857 sprintf (buff
, "PRC[0x%04x]", type
);
5858 else if (type
>= SHN_LOOS
&& type
<= SHN_HIOS
)
5859 sprintf (buff
, "OS [0x%04x]", type
);
5860 else if (type
>= SHN_LORESERVE
&& type
<= SHN_HIRESERVE
)
5861 sprintf (buff
, "RSV[0x%04x]", type
);
5863 sprintf (buff
, "%3d", type
);
5871 get_dynamic_data (file
, number
)
5873 unsigned int number
;
5875 unsigned char *e_data
;
5878 e_data
= (unsigned char *) malloc (number
* 4);
5882 error (_("Out of memory\n"));
5886 if (fread (e_data
, 4, number
, file
) != number
)
5888 error (_("Unable to read in dynamic data\n"));
5892 i_data
= (int *) malloc (number
* sizeof (*i_data
));
5896 error (_("Out of memory\n"));
5902 i_data
[number
] = byte_get (e_data
+ number
* 4, 4);
5909 /* Dump the symbol table. */
5911 process_symbol_table (file
)
5914 Elf_Internal_Shdr
*section
;
5915 unsigned char nb
[4];
5916 unsigned char nc
[4];
5919 int *buckets
= NULL
;
5922 if (! do_syms
&& !do_histogram
)
5925 if (dynamic_info
[DT_HASH
] && ((do_using_dynamic
&& dynamic_strings
!= NULL
)
5928 if (fseek (file
, dynamic_info
[DT_HASH
] - loadaddr
, SEEK_SET
))
5930 error (_("Unable to seek to start of dynamic information"));
5934 if (fread (nb
, sizeof (nb
), 1, file
) != 1)
5936 error (_("Failed to read in number of buckets\n"));
5940 if (fread (nc
, sizeof (nc
), 1, file
) != 1)
5942 error (_("Failed to read in number of chains\n"));
5946 nbuckets
= byte_get (nb
, 4);
5947 nchains
= byte_get (nc
, 4);
5949 buckets
= get_dynamic_data (file
, nbuckets
);
5950 chains
= get_dynamic_data (file
, nchains
);
5952 if (buckets
== NULL
|| chains
== NULL
)
5957 && dynamic_info
[DT_HASH
] && do_using_dynamic
&& dynamic_strings
!= NULL
)
5962 printf (_("\nSymbol table for image:\n"));
5964 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
5966 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
5968 for (hn
= 0; hn
< nbuckets
; hn
++)
5973 for (si
= buckets
[hn
]; si
< nchains
&& si
> 0; si
= chains
[si
])
5975 Elf_Internal_Sym
*psym
;
5977 psym
= dynamic_symbols
+ si
;
5979 printf (" %3d %3d: ", si
, hn
);
5980 print_vma (psym
->st_value
, LONG_HEX
);
5982 print_vma (psym
->st_size
, DEC_5
);
5984 printf (" %6s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
5985 printf (" %6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
5986 printf (" %3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
5987 printf (" %3.3s ", get_symbol_index_type (psym
->st_shndx
));
5988 print_symbol (25, dynamic_strings
+ psym
->st_name
);
5993 else if (do_syms
&& !do_using_dynamic
)
5997 for (i
= 0, section
= section_headers
;
5998 i
< elf_header
.e_shnum
;
6003 Elf_Internal_Sym
*symtab
;
6004 Elf_Internal_Sym
*psym
;
6007 if ( section
->sh_type
!= SHT_SYMTAB
6008 && section
->sh_type
!= SHT_DYNSYM
)
6011 printf (_("\nSymbol table '%s' contains %lu entries:\n"),
6012 SECTION_NAME (section
),
6013 (unsigned long) (section
->sh_size
/ section
->sh_entsize
));
6015 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
6017 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
6019 symtab
= GET_ELF_SYMBOLS (file
, section
);
6023 if (section
->sh_link
== elf_header
.e_shstrndx
)
6024 strtab
= string_table
;
6027 Elf_Internal_Shdr
*string_sec
;
6029 string_sec
= SECTION_HEADER (section
->sh_link
);
6031 strtab
= (char *) get_data (NULL
, file
, string_sec
->sh_offset
,
6032 string_sec
->sh_size
,
6036 for (si
= 0, psym
= symtab
;
6037 si
< section
->sh_size
/ section
->sh_entsize
;
6040 printf ("%6d: ", si
);
6041 print_vma (psym
->st_value
, LONG_HEX
);
6043 print_vma (psym
->st_size
, DEC_5
);
6044 printf (" %-7s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
6045 printf (" %-6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
6046 printf (" %-3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
6047 printf (" %4s ", get_symbol_index_type (psym
->st_shndx
));
6048 print_symbol (25, strtab
+ psym
->st_name
);
6050 if (section
->sh_type
== SHT_DYNSYM
&&
6051 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] != 0)
6053 unsigned char data
[2];
6054 unsigned short vers_data
;
6055 unsigned long offset
;
6059 offset
= version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)]
6062 get_data (&data
, file
, offset
+ si
* sizeof (vers_data
),
6063 sizeof (data
), _("version data"));
6065 vers_data
= byte_get (data
, 2);
6067 is_nobits
= (SECTION_HEADER (psym
->st_shndx
)->sh_type
6070 check_def
= (psym
->st_shndx
!= SHN_UNDEF
);
6072 if ((vers_data
& 0x8000) || vers_data
> 1)
6074 if (version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
6075 && (is_nobits
|| ! check_def
))
6077 Elf_External_Verneed evn
;
6078 Elf_Internal_Verneed ivn
;
6079 Elf_Internal_Vernaux ivna
;
6081 /* We must test both. */
6082 offset
= (version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
6087 unsigned long vna_off
;
6089 get_data (&evn
, file
, offset
, sizeof (evn
),
6092 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
6093 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
6095 vna_off
= offset
+ ivn
.vn_aux
;
6099 Elf_External_Vernaux evna
;
6101 get_data (&evna
, file
, vna_off
,
6103 _("version need aux (3)"));
6105 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
6106 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
6107 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
6109 vna_off
+= ivna
.vna_next
;
6111 while (ivna
.vna_other
!= vers_data
6112 && ivna
.vna_next
!= 0);
6114 if (ivna
.vna_other
== vers_data
)
6117 offset
+= ivn
.vn_next
;
6119 while (ivn
.vn_next
!= 0);
6121 if (ivna
.vna_other
== vers_data
)
6124 strtab
+ ivna
.vna_name
, ivna
.vna_other
);
6127 else if (! is_nobits
)
6128 error (_("bad dynamic symbol"));
6135 if (vers_data
!= 0x8001
6136 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
6138 Elf_Internal_Verdef ivd
;
6139 Elf_Internal_Verdaux ivda
;
6140 Elf_External_Verdaux evda
;
6141 unsigned long offset
;
6144 = (version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)]
6149 Elf_External_Verdef evd
;
6151 get_data (&evd
, file
, offset
, sizeof (evd
),
6154 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
6155 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
6156 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
6158 offset
+= ivd
.vd_next
;
6160 while (ivd
.vd_ndx
!= (vers_data
& 0x7fff)
6161 && ivd
.vd_next
!= 0);
6163 offset
-= ivd
.vd_next
;
6164 offset
+= ivd
.vd_aux
;
6166 get_data (&evda
, file
, offset
, sizeof (evda
),
6167 _("version def aux"));
6169 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
6171 if (psym
->st_name
!= ivda
.vda_name
)
6172 printf ((vers_data
& 0x8000)
6174 strtab
+ ivda
.vda_name
);
6184 if (strtab
!= string_table
)
6190 (_("\nDynamic symbol information is not available for displaying symbols.\n"));
6192 if (do_histogram
&& buckets
!= NULL
)
6199 int nzero_counts
= 0;
6202 printf (_("\nHistogram for bucket list length (total of %d buckets):\n"),
6204 printf (_(" Length Number %% of total Coverage\n"));
6206 lengths
= (int *) calloc (nbuckets
, sizeof (int));
6207 if (lengths
== NULL
)
6209 error (_("Out of memory"));
6212 for (hn
= 0; hn
< nbuckets
; ++hn
)
6217 for (si
= buckets
[hn
]; si
> 0 && si
< nchains
; si
= chains
[si
])
6220 if (maxlength
< ++lengths
[hn
])
6225 counts
= (int *) calloc (maxlength
+ 1, sizeof (int));
6228 error (_("Out of memory"));
6232 for (hn
= 0; hn
< nbuckets
; ++hn
)
6233 ++counts
[lengths
[hn
]];
6237 printf (" 0 %-10d (%5.1f%%)\n",
6238 counts
[0], (counts
[0] * 100.0) / nbuckets
);
6239 for (si
= 1; si
<= maxlength
; ++si
)
6241 nzero_counts
+= counts
[si
] * si
;
6242 printf ("%7d %-10d (%5.1f%%) %5.1f%%\n",
6243 si
, counts
[si
], (counts
[si
] * 100.0) / nbuckets
,
6244 (nzero_counts
* 100.0) / nsyms
);
6252 if (buckets
!= NULL
)
6262 process_syminfo (file
)
6263 FILE *file ATTRIBUTE_UNUSED
;
6267 if (dynamic_syminfo
== NULL
6269 /* No syminfo, this is ok. */
6272 /* There better should be a dynamic symbol section. */
6273 if (dynamic_symbols
== NULL
|| dynamic_strings
== NULL
)
6277 printf (_("\nDynamic info segment at offset 0x%lx contains %d entries:\n"),
6278 dynamic_syminfo_offset
, dynamic_syminfo_nent
);
6280 printf (_(" Num: Name BoundTo Flags\n"));
6281 for (i
= 0; i
< dynamic_syminfo_nent
; ++i
)
6283 unsigned short int flags
= dynamic_syminfo
[i
].si_flags
;
6285 printf ("%4d: ", i
);
6286 print_symbol (30, dynamic_strings
+ dynamic_symbols
[i
].st_name
);
6289 switch (dynamic_syminfo
[i
].si_boundto
)
6291 case SYMINFO_BT_SELF
:
6292 fputs ("SELF ", stdout
);
6294 case SYMINFO_BT_PARENT
:
6295 fputs ("PARENT ", stdout
);
6298 if (dynamic_syminfo
[i
].si_boundto
> 0
6299 && dynamic_syminfo
[i
].si_boundto
< dynamic_size
)
6304 [dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
));
6308 printf ("%-10d ", dynamic_syminfo
[i
].si_boundto
);
6312 if (flags
& SYMINFO_FLG_DIRECT
)
6314 if (flags
& SYMINFO_FLG_PASSTHRU
)
6315 printf (" PASSTHRU");
6316 if (flags
& SYMINFO_FLG_COPY
)
6318 if (flags
& SYMINFO_FLG_LAZYLOAD
)
6319 printf (" LAZYLOAD");
6327 #ifdef SUPPORT_DISASSEMBLY
6329 disassemble_section (section
, file
)
6330 Elf_Internal_Shdr
*section
;
6333 printf (_("\nAssembly dump of section %s\n"),
6334 SECTION_NAME (section
));
6336 /* XXX -- to be done --- XXX */
6343 dump_section (section
, file
)
6344 Elf_Internal_Shdr
*section
;
6347 bfd_size_type bytes
;
6349 unsigned char *data
;
6350 unsigned char *start
;
6352 bytes
= section
->sh_size
;
6356 printf (_("\nSection '%s' has no data to dump.\n"),
6357 SECTION_NAME (section
));
6361 printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section
));
6363 addr
= section
->sh_addr
;
6365 start
= (unsigned char *) get_data (NULL
, file
, section
->sh_offset
, bytes
,
6378 lbytes
= (bytes
> 16 ? 16 : bytes
);
6380 printf (" 0x%8.8lx ", (unsigned long) addr
);
6382 switch (elf_header
.e_ident
[EI_DATA
])
6386 for (j
= 15; j
>= 0; j
--)
6389 printf ("%2.2x", data
[j
]);
6399 for (j
= 0; j
< 16; j
++)
6402 printf ("%2.2x", data
[j
]);
6412 for (j
= 0; j
< lbytes
; j
++)
6415 if (k
>= ' ' && k
< 0x80)
6434 static unsigned long int
6435 read_leb128 (data
, length_return
, sign
)
6436 unsigned char *data
;
6440 unsigned long int result
= 0;
6441 unsigned int num_read
= 0;
6450 result
|= (byte
& 0x7f) << shift
;
6455 while (byte
& 0x80);
6457 if (length_return
!= NULL
)
6458 *length_return
= num_read
;
6460 if (sign
&& (shift
< 32) && (byte
& 0x40))
6461 result
|= -1 << shift
;
6466 typedef struct State_Machine_Registers
6468 unsigned long address
;
6471 unsigned int column
;
6475 /* This variable hold the number of the last entry seen
6476 in the File Table. */
6477 unsigned int last_file_entry
;
6480 static SMR state_machine_regs
;
6483 reset_state_machine (is_stmt
)
6486 state_machine_regs
.address
= 0;
6487 state_machine_regs
.file
= 1;
6488 state_machine_regs
.line
= 1;
6489 state_machine_regs
.column
= 0;
6490 state_machine_regs
.is_stmt
= is_stmt
;
6491 state_machine_regs
.basic_block
= 0;
6492 state_machine_regs
.end_sequence
= 0;
6493 state_machine_regs
.last_file_entry
= 0;
6496 /* Handled an extend line op. Returns true if this is the end
6499 process_extended_line_op (data
, is_stmt
, pointer_size
)
6500 unsigned char *data
;
6504 unsigned char op_code
;
6507 unsigned char *name
;
6510 len
= read_leb128 (data
, & bytes_read
, 0);
6515 warn (_("badly formed extended line op encountered!\n"));
6522 printf (_(" Extended opcode %d: "), op_code
);
6526 case DW_LNE_end_sequence
:
6527 printf (_("End of Sequence\n\n"));
6528 reset_state_machine (is_stmt
);
6531 case DW_LNE_set_address
:
6532 adr
= byte_get (data
, pointer_size
);
6533 printf (_("set Address to 0x%lx\n"), adr
);
6534 state_machine_regs
.address
= adr
;
6537 case DW_LNE_define_file
:
6538 printf (_(" define new File Table entry\n"));
6539 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
6541 printf (_(" %d\t"), ++state_machine_regs
.last_file_entry
);
6543 data
+= strlen ((char *) data
) + 1;
6544 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6546 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6548 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6549 printf (_("%s\n\n"), name
);
6553 printf (_("UNKNOWN: length %d\n"), len
- bytes_read
);
6560 /* Size of pointers in the .debug_line section. This information is not
6561 really present in that section. It's obtained before dumping the debug
6562 sections by doing some pre-scan of the .debug_info section. */
6563 static int debug_line_pointer_size
= 4;
6566 display_debug_lines (section
, start
, file
)
6567 Elf_Internal_Shdr
*section
;
6568 unsigned char * start
;
6569 FILE *file ATTRIBUTE_UNUSED
;
6571 unsigned char *hdrptr
;
6572 DWARF2_Internal_LineInfo info
;
6573 unsigned char *standard_opcodes
;
6574 unsigned char *data
= start
;
6575 unsigned char *end
= start
+ section
->sh_size
;
6576 unsigned char *end_of_sequence
;
6579 int initial_length_size
;
6581 printf (_("\nDump of debug contents of section %s:\n\n"),
6582 SECTION_NAME (section
));
6588 /* Check the length of the block. */
6589 info
.li_length
= byte_get (hdrptr
, 4);
6592 if (info
.li_length
== 0xffffffff)
6594 /* This section is 64-bit DWARF 3. */
6595 info
.li_length
= byte_get (hdrptr
, 8);
6598 initial_length_size
= 12;
6603 initial_length_size
= 4;
6606 if (info
.li_length
+ initial_length_size
> section
->sh_size
)
6609 (_("The line info appears to be corrupt - the section is too small\n"));
6613 /* Check its version number. */
6614 info
.li_version
= byte_get (hdrptr
, 2);
6616 if (info
.li_version
!= 2 && info
.li_version
!= 3)
6618 warn (_("Only DWARF version 2 and 3 line info is currently supported.\n"));
6622 info
.li_prologue_length
= byte_get (hdrptr
, offset_size
);
6623 hdrptr
+= offset_size
;
6624 info
.li_min_insn_length
= byte_get (hdrptr
, 1);
6626 info
.li_default_is_stmt
= byte_get (hdrptr
, 1);
6628 info
.li_line_base
= byte_get (hdrptr
, 1);
6630 info
.li_line_range
= byte_get (hdrptr
, 1);
6632 info
.li_opcode_base
= byte_get (hdrptr
, 1);
6635 /* Sign extend the line base field. */
6636 info
.li_line_base
<<= 24;
6637 info
.li_line_base
>>= 24;
6639 printf (_(" Length: %ld\n"), info
.li_length
);
6640 printf (_(" DWARF Version: %d\n"), info
.li_version
);
6641 printf (_(" Prologue Length: %d\n"), info
.li_prologue_length
);
6642 printf (_(" Minimum Instruction Length: %d\n"), info
.li_min_insn_length
);
6643 printf (_(" Initial value of 'is_stmt': %d\n"), info
.li_default_is_stmt
);
6644 printf (_(" Line Base: %d\n"), info
.li_line_base
);
6645 printf (_(" Line Range: %d\n"), info
.li_line_range
);
6646 printf (_(" Opcode Base: %d\n"), info
.li_opcode_base
);
6648 end_of_sequence
= data
+ info
.li_length
+ initial_length_size
;
6650 reset_state_machine (info
.li_default_is_stmt
);
6652 /* Display the contents of the Opcodes table. */
6653 standard_opcodes
= hdrptr
;
6655 printf (_("\n Opcodes:\n"));
6657 for (i
= 1; i
< info
.li_opcode_base
; i
++)
6658 printf (_(" Opcode %d has %d args\n"), i
, standard_opcodes
[i
- 1]);
6660 /* Display the contents of the Directory table. */
6661 data
= standard_opcodes
+ info
.li_opcode_base
- 1;
6664 printf (_("\n The Directory Table is empty.\n"));
6667 printf (_("\n The Directory Table:\n"));
6671 printf (_(" %s\n"), data
);
6673 data
+= strlen ((char *) data
) + 1;
6677 /* Skip the NUL at the end of the table. */
6680 /* Display the contents of the File Name table. */
6682 printf (_("\n The File Name Table is empty.\n"));
6685 printf (_("\n The File Name Table:\n"));
6686 printf (_(" Entry\tDir\tTime\tSize\tName\n"));
6690 unsigned char *name
;
6693 printf (_(" %d\t"), ++state_machine_regs
.last_file_entry
);
6696 data
+= strlen ((char *) data
) + 1;
6698 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6700 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6702 printf (_("%lu\t"), read_leb128 (data
, & bytes_read
, 0));
6704 printf (_("%s\n"), name
);
6708 /* Skip the NUL at the end of the table. */
6711 /* Now display the statements. */
6712 printf (_("\n Line Number Statements:\n"));
6715 while (data
< end_of_sequence
)
6717 unsigned char op_code
;
6723 if (op_code
>= info
.li_opcode_base
)
6725 op_code
-= info
.li_opcode_base
;
6726 adv
= (op_code
/ info
.li_line_range
) * info
.li_min_insn_length
;
6727 state_machine_regs
.address
+= adv
;
6728 printf (_(" Special opcode %d: advance Address by %d to 0x%lx"),
6729 op_code
, adv
, state_machine_regs
.address
);
6730 adv
= (op_code
% info
.li_line_range
) + info
.li_line_base
;
6731 state_machine_regs
.line
+= adv
;
6732 printf (_(" and Line by %d to %d\n"),
6733 adv
, state_machine_regs
.line
);
6735 else switch (op_code
)
6737 case DW_LNS_extended_op
:
6738 data
+= process_extended_line_op (data
, info
.li_default_is_stmt
,
6739 debug_line_pointer_size
);
6743 printf (_(" Copy\n"));
6746 case DW_LNS_advance_pc
:
6747 adv
= info
.li_min_insn_length
* read_leb128 (data
, & bytes_read
, 0);
6749 state_machine_regs
.address
+= adv
;
6750 printf (_(" Advance PC by %d to %lx\n"), adv
,
6751 state_machine_regs
.address
);
6754 case DW_LNS_advance_line
:
6755 adv
= read_leb128 (data
, & bytes_read
, 1);
6757 state_machine_regs
.line
+= adv
;
6758 printf (_(" Advance Line by %d to %d\n"), adv
,
6759 state_machine_regs
.line
);
6762 case DW_LNS_set_file
:
6763 adv
= read_leb128 (data
, & bytes_read
, 0);
6765 printf (_(" Set File Name to entry %d in the File Name Table\n"),
6767 state_machine_regs
.file
= adv
;
6770 case DW_LNS_set_column
:
6771 adv
= read_leb128 (data
, & bytes_read
, 0);
6773 printf (_(" Set column to %d\n"), adv
);
6774 state_machine_regs
.column
= adv
;
6777 case DW_LNS_negate_stmt
:
6778 adv
= state_machine_regs
.is_stmt
;
6780 printf (_(" Set is_stmt to %d\n"), adv
);
6781 state_machine_regs
.is_stmt
= adv
;
6784 case DW_LNS_set_basic_block
:
6785 printf (_(" Set basic block\n"));
6786 state_machine_regs
.basic_block
= 1;
6789 case DW_LNS_const_add_pc
:
6790 adv
= (((255 - info
.li_opcode_base
) / info
.li_line_range
)
6791 * info
.li_min_insn_length
);
6792 state_machine_regs
.address
+= adv
;
6793 printf (_(" Advance PC by constant %d to 0x%lx\n"), adv
,
6794 state_machine_regs
.address
);
6797 case DW_LNS_fixed_advance_pc
:
6798 adv
= byte_get (data
, 2);
6800 state_machine_regs
.address
+= adv
;
6801 printf (_(" Advance PC by fixed size amount %d to 0x%lx\n"),
6802 adv
, state_machine_regs
.address
);
6805 case DW_LNS_set_prologue_end
:
6806 printf (_(" Set prologue_end to true\n"));
6809 case DW_LNS_set_epilogue_begin
:
6810 printf (_(" Set epilogue_begin to true\n"));
6813 case DW_LNS_set_isa
:
6814 adv
= read_leb128 (data
, & bytes_read
, 0);
6816 printf (_(" Set ISA to %d\n"), adv
);
6820 printf (_(" Unknown opcode %d with operands: "), op_code
);
6823 for (i
= standard_opcodes
[op_code
- 1]; i
> 0 ; --i
)
6825 printf ("0x%lx%s", read_leb128 (data
, &bytes_read
, 0),
6826 i
== 1 ? "" : ", ");
6841 display_debug_pubnames (section
, start
, file
)
6842 Elf_Internal_Shdr
*section
;
6843 unsigned char *start
;
6844 FILE *file ATTRIBUTE_UNUSED
;
6846 DWARF2_Internal_PubNames pubnames
;
6849 end
= start
+ section
->sh_size
;
6851 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
6855 unsigned char *data
;
6856 unsigned long offset
;
6857 int offset_size
, initial_length_size
;
6861 pubnames
.pn_length
= byte_get (data
, 4);
6863 if (pubnames
.pn_length
== 0xffffffff)
6865 pubnames
.pn_length
= byte_get (data
, 8);
6868 initial_length_size
= 12;
6873 initial_length_size
= 4;
6876 pubnames
.pn_version
= byte_get (data
, 2);
6878 pubnames
.pn_offset
= byte_get (data
, offset_size
);
6879 data
+= offset_size
;
6880 pubnames
.pn_size
= byte_get (data
, offset_size
);
6881 data
+= offset_size
;
6883 start
+= pubnames
.pn_length
+ initial_length_size
;
6885 if (pubnames
.pn_version
!= 2 && pubnames
.pn_version
!= 3)
6887 static int warned
= 0;
6891 warn (_("Only DWARF 2 and 3 pubnames are currently supported\n"));
6898 printf (_(" Length: %ld\n"),
6899 pubnames
.pn_length
);
6900 printf (_(" Version: %d\n"),
6901 pubnames
.pn_version
);
6902 printf (_(" Offset into .debug_info section: %ld\n"),
6903 pubnames
.pn_offset
);
6904 printf (_(" Size of area in .debug_info section: %ld\n"),
6907 printf (_("\n Offset\tName\n"));
6911 offset
= byte_get (data
, offset_size
);
6915 data
+= offset_size
;
6916 printf (" %ld\t\t%s\n", offset
, data
);
6917 data
+= strlen ((char *) data
) + 1;
6920 while (offset
!= 0);
6933 case DW_TAG_padding
: return "DW_TAG_padding";
6934 case DW_TAG_array_type
: return "DW_TAG_array_type";
6935 case DW_TAG_class_type
: return "DW_TAG_class_type";
6936 case DW_TAG_entry_point
: return "DW_TAG_entry_point";
6937 case DW_TAG_enumeration_type
: return "DW_TAG_enumeration_type";
6938 case DW_TAG_formal_parameter
: return "DW_TAG_formal_parameter";
6939 case DW_TAG_imported_declaration
: return "DW_TAG_imported_declaration";
6940 case DW_TAG_label
: return "DW_TAG_label";
6941 case DW_TAG_lexical_block
: return "DW_TAG_lexical_block";
6942 case DW_TAG_member
: return "DW_TAG_member";
6943 case DW_TAG_pointer_type
: return "DW_TAG_pointer_type";
6944 case DW_TAG_reference_type
: return "DW_TAG_reference_type";
6945 case DW_TAG_compile_unit
: return "DW_TAG_compile_unit";
6946 case DW_TAG_string_type
: return "DW_TAG_string_type";
6947 case DW_TAG_structure_type
: return "DW_TAG_structure_type";
6948 case DW_TAG_subroutine_type
: return "DW_TAG_subroutine_type";
6949 case DW_TAG_typedef
: return "DW_TAG_typedef";
6950 case DW_TAG_union_type
: return "DW_TAG_union_type";
6951 case DW_TAG_unspecified_parameters
: return "DW_TAG_unspecified_parameters";
6952 case DW_TAG_variant
: return "DW_TAG_variant";
6953 case DW_TAG_common_block
: return "DW_TAG_common_block";
6954 case DW_TAG_common_inclusion
: return "DW_TAG_common_inclusion";
6955 case DW_TAG_inheritance
: return "DW_TAG_inheritance";
6956 case DW_TAG_inlined_subroutine
: return "DW_TAG_inlined_subroutine";
6957 case DW_TAG_module
: return "DW_TAG_module";
6958 case DW_TAG_ptr_to_member_type
: return "DW_TAG_ptr_to_member_type";
6959 case DW_TAG_set_type
: return "DW_TAG_set_type";
6960 case DW_TAG_subrange_type
: return "DW_TAG_subrange_type";
6961 case DW_TAG_with_stmt
: return "DW_TAG_with_stmt";
6962 case DW_TAG_access_declaration
: return "DW_TAG_access_declaration";
6963 case DW_TAG_base_type
: return "DW_TAG_base_type";
6964 case DW_TAG_catch_block
: return "DW_TAG_catch_block";
6965 case DW_TAG_const_type
: return "DW_TAG_const_type";
6966 case DW_TAG_constant
: return "DW_TAG_constant";
6967 case DW_TAG_enumerator
: return "DW_TAG_enumerator";
6968 case DW_TAG_file_type
: return "DW_TAG_file_type";
6969 case DW_TAG_friend
: return "DW_TAG_friend";
6970 case DW_TAG_namelist
: return "DW_TAG_namelist";
6971 case DW_TAG_namelist_item
: return "DW_TAG_namelist_item";
6972 case DW_TAG_packed_type
: return "DW_TAG_packed_type";
6973 case DW_TAG_subprogram
: return "DW_TAG_subprogram";
6974 case DW_TAG_template_type_param
: return "DW_TAG_template_type_param";
6975 case DW_TAG_template_value_param
: return "DW_TAG_template_value_param";
6976 case DW_TAG_thrown_type
: return "DW_TAG_thrown_type";
6977 case DW_TAG_try_block
: return "DW_TAG_try_block";
6978 case DW_TAG_variant_part
: return "DW_TAG_variant_part";
6979 case DW_TAG_variable
: return "DW_TAG_variable";
6980 case DW_TAG_volatile_type
: return "DW_TAG_volatile_type";
6981 case DW_TAG_MIPS_loop
: return "DW_TAG_MIPS_loop";
6982 case DW_TAG_format_label
: return "DW_TAG_format_label";
6983 case DW_TAG_function_template
: return "DW_TAG_function_template";
6984 case DW_TAG_class_template
: return "DW_TAG_class_template";
6985 /* DWARF 2.1 values. */
6986 case DW_TAG_dwarf_procedure
: return "DW_TAG_dwarf_procedure";
6987 case DW_TAG_restrict_type
: return "DW_TAG_restrict_type";
6988 case DW_TAG_interface_type
: return "DW_TAG_interface_type";
6989 case DW_TAG_namespace
: return "DW_TAG_namespace";
6990 case DW_TAG_imported_module
: return "DW_TAG_imported_module";
6991 case DW_TAG_unspecified_type
: return "DW_TAG_unspecified_type";
6992 case DW_TAG_partial_unit
: return "DW_TAG_partial_unit";
6993 case DW_TAG_imported_unit
: return "DW_TAG_imported_unit";
6995 case DW_TAG_upc_shared_type
: return "DW_TAG_upc_shared_type";
6996 case DW_TAG_upc_strict_type
: return "DW_TAG_upc_strict_type";
6997 case DW_TAG_upc_relaxed_type
: return "DW_TAG_upc_relaxed_type";
7000 static char buffer
[100];
7002 sprintf (buffer
, _("Unknown TAG value: %lx"), tag
);
7009 get_AT_name (attribute
)
7010 unsigned long attribute
;
7014 case DW_AT_sibling
: return "DW_AT_sibling";
7015 case DW_AT_location
: return "DW_AT_location";
7016 case DW_AT_name
: return "DW_AT_name";
7017 case DW_AT_ordering
: return "DW_AT_ordering";
7018 case DW_AT_subscr_data
: return "DW_AT_subscr_data";
7019 case DW_AT_byte_size
: return "DW_AT_byte_size";
7020 case DW_AT_bit_offset
: return "DW_AT_bit_offset";
7021 case DW_AT_bit_size
: return "DW_AT_bit_size";
7022 case DW_AT_element_list
: return "DW_AT_element_list";
7023 case DW_AT_stmt_list
: return "DW_AT_stmt_list";
7024 case DW_AT_low_pc
: return "DW_AT_low_pc";
7025 case DW_AT_high_pc
: return "DW_AT_high_pc";
7026 case DW_AT_language
: return "DW_AT_language";
7027 case DW_AT_member
: return "DW_AT_member";
7028 case DW_AT_discr
: return "DW_AT_discr";
7029 case DW_AT_discr_value
: return "DW_AT_discr_value";
7030 case DW_AT_visibility
: return "DW_AT_visibility";
7031 case DW_AT_import
: return "DW_AT_import";
7032 case DW_AT_string_length
: return "DW_AT_string_length";
7033 case DW_AT_common_reference
: return "DW_AT_common_reference";
7034 case DW_AT_comp_dir
: return "DW_AT_comp_dir";
7035 case DW_AT_const_value
: return "DW_AT_const_value";
7036 case DW_AT_containing_type
: return "DW_AT_containing_type";
7037 case DW_AT_default_value
: return "DW_AT_default_value";
7038 case DW_AT_inline
: return "DW_AT_inline";
7039 case DW_AT_is_optional
: return "DW_AT_is_optional";
7040 case DW_AT_lower_bound
: return "DW_AT_lower_bound";
7041 case DW_AT_producer
: return "DW_AT_producer";
7042 case DW_AT_prototyped
: return "DW_AT_prototyped";
7043 case DW_AT_return_addr
: return "DW_AT_return_addr";
7044 case DW_AT_start_scope
: return "DW_AT_start_scope";
7045 case DW_AT_stride_size
: return "DW_AT_stride_size";
7046 case DW_AT_upper_bound
: return "DW_AT_upper_bound";
7047 case DW_AT_abstract_origin
: return "DW_AT_abstract_origin";
7048 case DW_AT_accessibility
: return "DW_AT_accessibility";
7049 case DW_AT_address_class
: return "DW_AT_address_class";
7050 case DW_AT_artificial
: return "DW_AT_artificial";
7051 case DW_AT_base_types
: return "DW_AT_base_types";
7052 case DW_AT_calling_convention
: return "DW_AT_calling_convention";
7053 case DW_AT_count
: return "DW_AT_count";
7054 case DW_AT_data_member_location
: return "DW_AT_data_member_location";
7055 case DW_AT_decl_column
: return "DW_AT_decl_column";
7056 case DW_AT_decl_file
: return "DW_AT_decl_file";
7057 case DW_AT_decl_line
: return "DW_AT_decl_line";
7058 case DW_AT_declaration
: return "DW_AT_declaration";
7059 case DW_AT_discr_list
: return "DW_AT_discr_list";
7060 case DW_AT_encoding
: return "DW_AT_encoding";
7061 case DW_AT_external
: return "DW_AT_external";
7062 case DW_AT_frame_base
: return "DW_AT_frame_base";
7063 case DW_AT_friend
: return "DW_AT_friend";
7064 case DW_AT_identifier_case
: return "DW_AT_identifier_case";
7065 case DW_AT_macro_info
: return "DW_AT_macro_info";
7066 case DW_AT_namelist_items
: return "DW_AT_namelist_items";
7067 case DW_AT_priority
: return "DW_AT_priority";
7068 case DW_AT_segment
: return "DW_AT_segment";
7069 case DW_AT_specification
: return "DW_AT_specification";
7070 case DW_AT_static_link
: return "DW_AT_static_link";
7071 case DW_AT_type
: return "DW_AT_type";
7072 case DW_AT_use_location
: return "DW_AT_use_location";
7073 case DW_AT_variable_parameter
: return "DW_AT_variable_parameter";
7074 case DW_AT_virtuality
: return "DW_AT_virtuality";
7075 case DW_AT_vtable_elem_location
: return "DW_AT_vtable_elem_location";
7076 /* DWARF 2.1 values. */
7077 case DW_AT_allocated
: return "DW_AT_allocated";
7078 case DW_AT_associated
: return "DW_AT_associated";
7079 case DW_AT_data_location
: return "DW_AT_data_location";
7080 case DW_AT_stride
: return "DW_AT_stride";
7081 case DW_AT_entry_pc
: return "DW_AT_entry_pc";
7082 case DW_AT_use_UTF8
: return "DW_AT_use_UTF8";
7083 case DW_AT_extension
: return "DW_AT_extension";
7084 case DW_AT_ranges
: return "DW_AT_ranges";
7085 case DW_AT_trampoline
: return "DW_AT_trampoline";
7086 case DW_AT_call_column
: return "DW_AT_call_column";
7087 case DW_AT_call_file
: return "DW_AT_call_file";
7088 case DW_AT_call_line
: return "DW_AT_call_line";
7089 /* SGI/MIPS extensions. */
7090 case DW_AT_MIPS_fde
: return "DW_AT_MIPS_fde";
7091 case DW_AT_MIPS_loop_begin
: return "DW_AT_MIPS_loop_begin";
7092 case DW_AT_MIPS_tail_loop_begin
: return "DW_AT_MIPS_tail_loop_begin";
7093 case DW_AT_MIPS_epilog_begin
: return "DW_AT_MIPS_epilog_begin";
7094 case DW_AT_MIPS_loop_unroll_factor
: return "DW_AT_MIPS_loop_unroll_factor";
7095 case DW_AT_MIPS_software_pipeline_depth
:
7096 return "DW_AT_MIPS_software_pipeline_depth";
7097 case DW_AT_MIPS_linkage_name
: return "DW_AT_MIPS_linkage_name";
7098 case DW_AT_MIPS_stride
: return "DW_AT_MIPS_stride";
7099 case DW_AT_MIPS_abstract_name
: return "DW_AT_MIPS_abstract_name";
7100 case DW_AT_MIPS_clone_origin
: return "DW_AT_MIPS_clone_origin";
7101 case DW_AT_MIPS_has_inlines
: return "DW_AT_MIPS_has_inlines";
7102 /* GNU extensions. */
7103 case DW_AT_sf_names
: return "DW_AT_sf_names";
7104 case DW_AT_src_info
: return "DW_AT_src_info";
7105 case DW_AT_mac_info
: return "DW_AT_mac_info";
7106 case DW_AT_src_coords
: return "DW_AT_src_coords";
7107 case DW_AT_body_begin
: return "DW_AT_body_begin";
7108 case DW_AT_body_end
: return "DW_AT_body_end";
7109 case DW_AT_GNU_vector
: return "DW_AT_GNU_vector";
7110 /* UPC extension. */
7111 case DW_AT_upc_threads_scaled
: return "DW_AT_upc_threads_scaled";
7114 static char buffer
[100];
7116 sprintf (buffer
, _("Unknown AT value: %lx"), attribute
);
7123 get_FORM_name (form
)
7128 case DW_FORM_addr
: return "DW_FORM_addr";
7129 case DW_FORM_block2
: return "DW_FORM_block2";
7130 case DW_FORM_block4
: return "DW_FORM_block4";
7131 case DW_FORM_data2
: return "DW_FORM_data2";
7132 case DW_FORM_data4
: return "DW_FORM_data4";
7133 case DW_FORM_data8
: return "DW_FORM_data8";
7134 case DW_FORM_string
: return "DW_FORM_string";
7135 case DW_FORM_block
: return "DW_FORM_block";
7136 case DW_FORM_block1
: return "DW_FORM_block1";
7137 case DW_FORM_data1
: return "DW_FORM_data1";
7138 case DW_FORM_flag
: return "DW_FORM_flag";
7139 case DW_FORM_sdata
: return "DW_FORM_sdata";
7140 case DW_FORM_strp
: return "DW_FORM_strp";
7141 case DW_FORM_udata
: return "DW_FORM_udata";
7142 case DW_FORM_ref_addr
: return "DW_FORM_ref_addr";
7143 case DW_FORM_ref1
: return "DW_FORM_ref1";
7144 case DW_FORM_ref2
: return "DW_FORM_ref2";
7145 case DW_FORM_ref4
: return "DW_FORM_ref4";
7146 case DW_FORM_ref8
: return "DW_FORM_ref8";
7147 case DW_FORM_ref_udata
: return "DW_FORM_ref_udata";
7148 case DW_FORM_indirect
: return "DW_FORM_indirect";
7151 static char buffer
[100];
7153 sprintf (buffer
, _("Unknown FORM value: %lx"), form
);
7159 /* FIXME: There are better and more effiecint ways to handle
7160 these structures. For now though, I just want something that
7161 is simple to implement. */
7162 typedef struct abbrev_attr
7164 unsigned long attribute
;
7166 struct abbrev_attr
*next
;
7170 typedef struct abbrev_entry
7172 unsigned long entry
;
7175 struct abbrev_attr
*first_attr
;
7176 struct abbrev_attr
*last_attr
;
7177 struct abbrev_entry
*next
;
7181 static abbrev_entry
*first_abbrev
= NULL
;
7182 static abbrev_entry
*last_abbrev
= NULL
;
7187 abbrev_entry
*abbrev
;
7189 for (abbrev
= first_abbrev
; abbrev
;)
7191 abbrev_entry
*next
= abbrev
->next
;
7194 for (attr
= abbrev
->first_attr
; attr
;)
7196 abbrev_attr
*next
= attr
->next
;
7206 last_abbrev
= first_abbrev
= NULL
;
7210 add_abbrev (number
, tag
, children
)
7211 unsigned long number
;
7215 abbrev_entry
*entry
;
7217 entry
= (abbrev_entry
*) malloc (sizeof (*entry
));
7223 entry
->entry
= number
;
7225 entry
->children
= children
;
7226 entry
->first_attr
= NULL
;
7227 entry
->last_attr
= NULL
;
7230 if (first_abbrev
== NULL
)
7231 first_abbrev
= entry
;
7233 last_abbrev
->next
= entry
;
7235 last_abbrev
= entry
;
7239 add_abbrev_attr (attribute
, form
)
7240 unsigned long attribute
;
7245 attr
= (abbrev_attr
*) malloc (sizeof (*attr
));
7251 attr
->attribute
= attribute
;
7255 if (last_abbrev
->first_attr
== NULL
)
7256 last_abbrev
->first_attr
= attr
;
7258 last_abbrev
->last_attr
->next
= attr
;
7260 last_abbrev
->last_attr
= attr
;
7263 /* Processes the (partial) contents of a .debug_abbrev section.
7264 Returns NULL if the end of the section was encountered.
7265 Returns the address after the last byte read if the end of
7266 an abbreviation set was found. */
7268 static unsigned char *
7269 process_abbrev_section (start
, end
)
7270 unsigned char *start
;
7273 if (first_abbrev
!= NULL
)
7279 unsigned long entry
;
7281 unsigned long attribute
;
7284 entry
= read_leb128 (start
, & bytes_read
, 0);
7285 start
+= bytes_read
;
7287 /* A single zero is supposed to end the section according
7288 to the standard. If there's more, then signal that to
7291 return start
== end
? NULL
: start
;
7293 tag
= read_leb128 (start
, & bytes_read
, 0);
7294 start
+= bytes_read
;
7296 children
= *start
++;
7298 add_abbrev (entry
, tag
, children
);
7304 attribute
= read_leb128 (start
, & bytes_read
, 0);
7305 start
+= bytes_read
;
7307 form
= read_leb128 (start
, & bytes_read
, 0);
7308 start
+= bytes_read
;
7311 add_abbrev_attr (attribute
, form
);
7313 while (attribute
!= 0);
7321 display_debug_macinfo (section
, start
, file
)
7322 Elf_Internal_Shdr
*section
;
7323 unsigned char *start
;
7324 FILE *file ATTRIBUTE_UNUSED
;
7326 unsigned char *end
= start
+ section
->sh_size
;
7327 unsigned char *curr
= start
;
7328 unsigned int bytes_read
;
7329 enum dwarf_macinfo_record_type op
;
7331 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
7335 unsigned int lineno
;
7343 case DW_MACINFO_start_file
:
7345 unsigned int filenum
;
7347 lineno
= read_leb128 (curr
, & bytes_read
, 0);
7349 filenum
= read_leb128 (curr
, & bytes_read
, 0);
7352 printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), lineno
, filenum
);
7356 case DW_MACINFO_end_file
:
7357 printf (_(" DW_MACINFO_end_file\n"));
7360 case DW_MACINFO_define
:
7361 lineno
= read_leb128 (curr
, & bytes_read
, 0);
7364 curr
+= strlen (string
) + 1;
7365 printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), lineno
, string
);
7368 case DW_MACINFO_undef
:
7369 lineno
= read_leb128 (curr
, & bytes_read
, 0);
7372 curr
+= strlen (string
) + 1;
7373 printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), lineno
, string
);
7376 case DW_MACINFO_vendor_ext
:
7378 unsigned int constant
;
7380 constant
= read_leb128 (curr
, & bytes_read
, 0);
7383 curr
+= strlen (string
) + 1;
7384 printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), constant
, string
);
7395 display_debug_abbrev (section
, start
, file
)
7396 Elf_Internal_Shdr
*section
;
7397 unsigned char *start
;
7398 FILE *file ATTRIBUTE_UNUSED
;
7400 abbrev_entry
*entry
;
7401 unsigned char *end
= start
+ section
->sh_size
;
7403 printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section
));
7407 start
= process_abbrev_section (start
, end
);
7409 if (first_abbrev
== NULL
)
7412 printf (_(" Number TAG\n"));
7414 for (entry
= first_abbrev
; entry
; entry
= entry
->next
)
7418 printf (_(" %ld %s [%s]\n"),
7420 get_TAG_name (entry
->tag
),
7421 entry
->children
? _("has children") : _("no children"));
7423 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
7425 printf (_(" %-18s %s\n"),
7426 get_AT_name (attr
->attribute
),
7427 get_FORM_name (attr
->form
));
7441 static unsigned char *
7442 display_block (data
, length
)
7443 unsigned char *data
;
7444 unsigned long length
;
7446 printf (_(" %lu byte block: "), length
);
7449 printf ("%lx ", (unsigned long) byte_get (data
++, 1));
7455 decode_location_expression (data
, pointer_size
, length
)
7456 unsigned char * data
;
7457 unsigned int pointer_size
;
7458 unsigned long length
;
7462 unsigned long uvalue
;
7463 unsigned char *end
= data
+ length
;
7472 printf ("DW_OP_addr: %lx",
7473 (unsigned long) byte_get (data
, pointer_size
));
7474 data
+= pointer_size
;
7477 printf ("DW_OP_deref");
7480 printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data
++, 1));
7483 printf ("DW_OP_const1s: %ld", (long) byte_get (data
++, 1));
7486 printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data
, 2));
7490 printf ("DW_OP_const2s: %ld", (long) byte_get (data
, 2));
7494 printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data
, 4));
7498 printf ("DW_OP_const4s: %ld", (long) byte_get (data
, 4));
7502 printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data
, 4),
7503 (unsigned long) byte_get (data
+ 4, 4));
7507 printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data
, 4),
7508 (long) byte_get (data
+ 4, 4));
7512 printf ("DW_OP_constu: %lu", read_leb128 (data
, &bytes_read
, 0));
7516 printf ("DW_OP_consts: %ld", read_leb128 (data
, &bytes_read
, 1));
7520 printf ("DW_OP_dup");
7523 printf ("DW_OP_drop");
7526 printf ("DW_OP_over");
7529 printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data
++, 1));
7532 printf ("DW_OP_swap");
7535 printf ("DW_OP_rot");
7538 printf ("DW_OP_xderef");
7541 printf ("DW_OP_abs");
7544 printf ("DW_OP_and");
7547 printf ("DW_OP_div");
7550 printf ("DW_OP_minus");
7553 printf ("DW_OP_mod");
7556 printf ("DW_OP_mul");
7559 printf ("DW_OP_neg");
7562 printf ("DW_OP_not");
7565 printf ("DW_OP_or");
7568 printf ("DW_OP_plus");
7570 case DW_OP_plus_uconst
:
7571 printf ("DW_OP_plus_uconst: %lu",
7572 read_leb128 (data
, &bytes_read
, 0));
7576 printf ("DW_OP_shl");
7579 printf ("DW_OP_shr");
7582 printf ("DW_OP_shra");
7585 printf ("DW_OP_xor");
7588 printf ("DW_OP_bra: %ld", (long) byte_get (data
, 2));
7592 printf ("DW_OP_eq");
7595 printf ("DW_OP_ge");
7598 printf ("DW_OP_gt");
7601 printf ("DW_OP_le");
7604 printf ("DW_OP_lt");
7607 printf ("DW_OP_ne");
7610 printf ("DW_OP_skip: %ld", (long) byte_get (data
, 2));
7646 printf ("DW_OP_lit%d", op
- DW_OP_lit0
);
7681 printf ("DW_OP_reg%d", op
- DW_OP_reg0
);
7716 printf ("DW_OP_breg%d: %ld", op
- DW_OP_breg0
,
7717 read_leb128 (data
, &bytes_read
, 1));
7722 printf ("DW_OP_regx: %lu", read_leb128 (data
, &bytes_read
, 0));
7726 printf ("DW_OP_fbreg: %ld", read_leb128 (data
, &bytes_read
, 1));
7730 uvalue
= read_leb128 (data
, &bytes_read
, 0);
7732 printf ("DW_OP_bregx: %lu %ld", uvalue
,
7733 read_leb128 (data
, &bytes_read
, 1));
7737 printf ("DW_OP_piece: %lu", read_leb128 (data
, &bytes_read
, 0));
7740 case DW_OP_deref_size
:
7741 printf ("DW_OP_deref_size: %ld", (long) byte_get (data
++, 1));
7743 case DW_OP_xderef_size
:
7744 printf ("DW_OP_xderef_size: %ld", (long) byte_get (data
++, 1));
7747 printf ("DW_OP_nop");
7750 /* DWARF 3 extensions. */
7751 case DW_OP_push_object_address
:
7752 printf ("DW_OP_push_object_address");
7755 printf ("DW_OP_call2: <%lx>", (long) byte_get (data
, 2));
7759 printf ("DW_OP_call4: <%lx>", (long) byte_get (data
, 4));
7762 case DW_OP_call_ref
:
7763 printf ("DW_OP_call_ref");
7766 /* GNU extensions. */
7767 case DW_OP_GNU_push_tls_address
:
7768 printf ("DW_OP_GNU_push_tls_address");
7772 if (op
>= DW_OP_lo_user
7773 && op
<= DW_OP_hi_user
)
7774 printf (_("(User defined location op)"));
7776 printf (_("(Unknown location op)"));
7777 /* No way to tell where the next op is, so just bail. */
7781 /* Separate the ops. */
7787 static const char *debug_loc_contents
;
7788 static bfd_vma debug_loc_size
;
7791 load_debug_loc (file
)
7794 Elf_Internal_Shdr
*sec
;
7797 /* If it is already loaded, do nothing. */
7798 if (debug_loc_contents
!= NULL
)
7801 /* Locate the .debug_loc section. */
7802 for (i
= 0, sec
= section_headers
;
7803 i
< elf_header
.e_shnum
;
7805 if (strcmp (SECTION_NAME (sec
), ".debug_loc") == 0)
7808 if (i
== elf_header
.e_shnum
|| sec
->sh_size
== 0)
7811 debug_loc_size
= sec
->sh_size
;
7813 debug_loc_contents
= ((char *)
7814 get_data (NULL
, file
, sec
->sh_offset
, sec
->sh_size
,
7815 _("debug_loc section data")));
7821 if (debug_loc_contents
== NULL
)
7824 free ((char *) debug_loc_contents
);
7825 debug_loc_contents
= NULL
;
7831 display_debug_loc (section
, start
, file
)
7832 Elf_Internal_Shdr
*section
;
7833 unsigned char *start
;
7834 FILE *file ATTRIBUTE_UNUSED
;
7836 unsigned char *section_end
;
7837 unsigned long bytes
;
7838 unsigned char *section_begin
= start
;
7841 addr
= section
->sh_addr
;
7842 bytes
= section
->sh_size
;
7843 section_end
= start
+ bytes
;
7847 printf (_("\nThe .debug_loc section is empty.\n"));
7851 printf (_("Contents of the .debug_loc section:\n\n"));
7852 printf (_("\n Offset Begin End Expression\n"));
7854 while (start
< section_end
)
7856 unsigned long begin
;
7858 unsigned short length
;
7859 unsigned long offset
;
7861 offset
= start
- section_begin
;
7865 /* Normally, the lists in the debug_loc section are related to a
7866 given compilation unit, and thus, we would use the pointer size
7867 of that compilation unit. However, since we are displaying it
7868 seperately here, we either have to store pointer sizes of all
7869 compilation units, or assume they don't change. We assume,
7870 like the debug_line display, that it doesn't change. */
7871 begin
= byte_get (start
, debug_line_pointer_size
);
7872 start
+= debug_line_pointer_size
;
7873 end
= byte_get (start
, debug_line_pointer_size
);
7874 start
+= debug_line_pointer_size
;
7876 if (begin
== 0 && end
== 0)
7879 /* For now, skip any base address specifiers. */
7880 if (begin
== 0xffffffff)
7886 length
= byte_get (start
, 2);
7889 printf (" %8.8lx %8.8lx %8.8lx (", offset
, begin
, end
);
7890 decode_location_expression (start
, debug_line_pointer_size
, length
);
7900 static const char *debug_str_contents
;
7901 static bfd_vma debug_str_size
;
7904 load_debug_str (file
)
7907 Elf_Internal_Shdr
*sec
;
7910 /* If it is already loaded, do nothing. */
7911 if (debug_str_contents
!= NULL
)
7914 /* Locate the .debug_str section. */
7915 for (i
= 0, sec
= section_headers
;
7916 i
< elf_header
.e_shnum
;
7918 if (strcmp (SECTION_NAME (sec
), ".debug_str") == 0)
7921 if (i
== elf_header
.e_shnum
|| sec
->sh_size
== 0)
7924 debug_str_size
= sec
->sh_size
;
7926 debug_str_contents
= ((char *)
7927 get_data (NULL
, file
, sec
->sh_offset
, sec
->sh_size
,
7928 _("debug_str section data")));
7934 if (debug_str_contents
== NULL
)
7937 free ((char *) debug_str_contents
);
7938 debug_str_contents
= NULL
;
7943 fetch_indirect_string (offset
)
7944 unsigned long offset
;
7946 if (debug_str_contents
== NULL
)
7947 return _("<no .debug_str section>");
7949 if (offset
> debug_str_size
)
7950 return _("<offset is too big>");
7952 return debug_str_contents
+ offset
;
7956 display_debug_str (section
, start
, file
)
7957 Elf_Internal_Shdr
*section
;
7958 unsigned char *start
;
7959 FILE *file ATTRIBUTE_UNUSED
;
7961 unsigned long bytes
;
7964 addr
= section
->sh_addr
;
7965 bytes
= section
->sh_size
;
7969 printf (_("\nThe .debug_str section is empty.\n"));
7973 printf (_("Contents of the .debug_str section:\n\n"));
7981 lbytes
= (bytes
> 16 ? 16 : bytes
);
7983 printf (" 0x%8.8lx ", (unsigned long) addr
);
7985 for (j
= 0; j
< 16; j
++)
7988 printf ("%2.2x", start
[j
]);
7996 for (j
= 0; j
< lbytes
; j
++)
7999 if (k
>= ' ' && k
< 0x80)
8015 static unsigned char *
8016 read_and_display_attr_value (attribute
, form
, data
, cu_offset
, pointer_size
,
8017 offset_size
, dwarf_version
)
8018 unsigned long attribute
;
8020 unsigned char *data
;
8021 unsigned long cu_offset
;
8022 unsigned long pointer_size
;
8023 unsigned long offset_size
;
8026 unsigned long uvalue
= 0;
8027 unsigned char *block_start
= NULL
;
8035 case DW_FORM_ref_addr
:
8036 if (dwarf_version
== 2)
8038 uvalue
= byte_get (data
, pointer_size
);
8039 data
+= pointer_size
;
8041 else if (dwarf_version
== 3)
8043 uvalue
= byte_get (data
, offset_size
);
8044 data
+= offset_size
;
8048 error (_("Internal error: DWARF version is not 2 or 3.\n"));
8053 uvalue
= byte_get (data
, pointer_size
);
8054 data
+= pointer_size
;
8058 uvalue
= byte_get (data
, offset_size
);
8059 data
+= offset_size
;
8065 uvalue
= byte_get (data
++, 1);
8070 uvalue
= byte_get (data
, 2);
8076 uvalue
= byte_get (data
, 4);
8081 uvalue
= read_leb128 (data
, & bytes_read
, 1);
8085 case DW_FORM_ref_udata
:
8087 uvalue
= read_leb128 (data
, & bytes_read
, 0);
8091 case DW_FORM_indirect
:
8092 form
= read_leb128 (data
, & bytes_read
, 0);
8094 printf (" %s", get_FORM_name (form
));
8095 return read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
8096 pointer_size
, offset_size
,
8102 case DW_FORM_ref_addr
:
8103 printf (" <#%lx>", uvalue
);
8109 case DW_FORM_ref_udata
:
8110 printf (" <%lx>", uvalue
+ cu_offset
);
8114 printf (" %#lx", uvalue
);
8122 printf (" %ld", uvalue
);
8127 uvalue
= byte_get (data
, 4);
8128 printf (" %lx", uvalue
);
8129 printf (" %lx", (unsigned long) byte_get (data
+ 4, 4));
8133 case DW_FORM_string
:
8134 printf (" %s", data
);
8135 data
+= strlen ((char *) data
) + 1;
8139 uvalue
= read_leb128 (data
, & bytes_read
, 0);
8140 block_start
= data
+ bytes_read
;
8141 data
= display_block (block_start
, uvalue
);
8144 case DW_FORM_block1
:
8145 uvalue
= byte_get (data
, 1);
8146 block_start
= data
+ 1;
8147 data
= display_block (block_start
, uvalue
);
8150 case DW_FORM_block2
:
8151 uvalue
= byte_get (data
, 2);
8152 block_start
= data
+ 2;
8153 data
= display_block (block_start
, uvalue
);
8156 case DW_FORM_block4
:
8157 uvalue
= byte_get (data
, 4);
8158 block_start
= data
+ 4;
8159 data
= display_block (block_start
, uvalue
);
8163 printf (_(" (indirect string, offset: 0x%lx): %s"),
8164 uvalue
, fetch_indirect_string (uvalue
));
8167 case DW_FORM_indirect
:
8168 /* Handled above. */
8172 warn (_("Unrecognized form: %d\n"), form
);
8176 /* For some attributes we can display futher information. */
8185 case DW_INL_not_inlined
:
8186 printf (_("(not inlined)"));
8188 case DW_INL_inlined
:
8189 printf (_("(inlined)"));
8191 case DW_INL_declared_not_inlined
:
8192 printf (_("(declared as inline but ignored)"));
8194 case DW_INL_declared_inlined
:
8195 printf (_("(declared as inline and inlined)"));
8198 printf (_(" (Unknown inline attribute value: %lx)"), uvalue
);
8203 case DW_AT_language
:
8206 case DW_LANG_C
: printf ("(non-ANSI C)"); break;
8207 case DW_LANG_C89
: printf ("(ANSI C)"); break;
8208 case DW_LANG_C_plus_plus
: printf ("(C++)"); break;
8209 case DW_LANG_Fortran77
: printf ("(FORTRAN 77)"); break;
8210 case DW_LANG_Fortran90
: printf ("(Fortran 90)"); break;
8211 case DW_LANG_Modula2
: printf ("(Modula 2)"); break;
8212 case DW_LANG_Pascal83
: printf ("(ANSI Pascal)"); break;
8213 case DW_LANG_Ada83
: printf ("(Ada)"); break;
8214 case DW_LANG_Cobol74
: printf ("(Cobol 74)"); break;
8215 case DW_LANG_Cobol85
: printf ("(Cobol 85)"); break;
8216 /* DWARF 2.1 values. */
8217 case DW_LANG_C99
: printf ("(ANSI C99)"); break;
8218 case DW_LANG_Ada95
: printf ("(ADA 95)"); break;
8219 case DW_LANG_Fortran95
: printf ("(Fortran 95)"); break;
8220 /* MIPS extension. */
8221 case DW_LANG_Mips_Assembler
: printf ("(MIPS assembler)"); break;
8222 /* UPC extension. */
8223 case DW_LANG_Upc
: printf ("(Unified Parallel C)"); break;
8225 printf ("(Unknown: %lx)", uvalue
);
8230 case DW_AT_encoding
:
8233 case DW_ATE_void
: printf ("(void)"); break;
8234 case DW_ATE_address
: printf ("(machine address)"); break;
8235 case DW_ATE_boolean
: printf ("(boolean)"); break;
8236 case DW_ATE_complex_float
: printf ("(complex float)"); break;
8237 case DW_ATE_float
: printf ("(float)"); break;
8238 case DW_ATE_signed
: printf ("(signed)"); break;
8239 case DW_ATE_signed_char
: printf ("(signed char)"); break;
8240 case DW_ATE_unsigned
: printf ("(unsigned)"); break;
8241 case DW_ATE_unsigned_char
: printf ("(unsigned char)"); break;
8242 /* DWARF 2.1 value. */
8243 case DW_ATE_imaginary_float
: printf ("(imaginary float)"); break;
8245 if (uvalue
>= DW_ATE_lo_user
8246 && uvalue
<= DW_ATE_hi_user
)
8247 printf ("(user defined type)");
8249 printf ("(unknown type)");
8254 case DW_AT_accessibility
:
8257 case DW_ACCESS_public
: printf ("(public)"); break;
8258 case DW_ACCESS_protected
: printf ("(protected)"); break;
8259 case DW_ACCESS_private
: printf ("(private)"); break;
8261 printf ("(unknown accessibility)");
8266 case DW_AT_visibility
:
8269 case DW_VIS_local
: printf ("(local)"); break;
8270 case DW_VIS_exported
: printf ("(exported)"); break;
8271 case DW_VIS_qualified
: printf ("(qualified)"); break;
8272 default: printf ("(unknown visibility)"); break;
8276 case DW_AT_virtuality
:
8279 case DW_VIRTUALITY_none
: printf ("(none)"); break;
8280 case DW_VIRTUALITY_virtual
: printf ("(virtual)"); break;
8281 case DW_VIRTUALITY_pure_virtual
:printf ("(pure_virtual)"); break;
8282 default: printf ("(unknown virtuality)"); break;
8286 case DW_AT_identifier_case
:
8289 case DW_ID_case_sensitive
: printf ("(case_sensitive)"); break;
8290 case DW_ID_up_case
: printf ("(up_case)"); break;
8291 case DW_ID_down_case
: printf ("(down_case)"); break;
8292 case DW_ID_case_insensitive
: printf ("(case_insensitive)"); break;
8293 default: printf ("(unknown case)"); break;
8297 case DW_AT_calling_convention
:
8300 case DW_CC_normal
: printf ("(normal)"); break;
8301 case DW_CC_program
: printf ("(program)"); break;
8302 case DW_CC_nocall
: printf ("(nocall)"); break;
8304 if (uvalue
>= DW_CC_lo_user
8305 && uvalue
<= DW_CC_hi_user
)
8306 printf ("(user defined)");
8308 printf ("(unknown convention)");
8312 case DW_AT_ordering
:
8315 case -1: printf ("(undefined)"); break;
8316 case 0: printf ("(row major)"); break;
8317 case 1: printf ("(column major)"); break;
8321 case DW_AT_frame_base
:
8322 case DW_AT_location
:
8323 case DW_AT_data_member_location
:
8324 case DW_AT_vtable_elem_location
:
8325 case DW_AT_allocated
:
8326 case DW_AT_associated
:
8327 case DW_AT_data_location
:
8329 case DW_AT_upper_bound
:
8330 case DW_AT_lower_bound
:
8334 decode_location_expression (block_start
, pointer_size
, uvalue
);
8337 else if (form
== DW_FORM_data4
|| form
== DW_FORM_data8
)
8340 printf ("location list");
8352 static unsigned char *
8353 read_and_display_attr (attribute
, form
, data
, cu_offset
, pointer_size
,
8354 offset_size
, dwarf_version
)
8355 unsigned long attribute
;
8357 unsigned char *data
;
8358 unsigned long cu_offset
;
8359 unsigned long pointer_size
;
8360 unsigned long offset_size
;
8363 printf (" %-18s:", get_AT_name (attribute
));
8364 data
= read_and_display_attr_value (attribute
, form
, data
, cu_offset
,
8365 pointer_size
, offset_size
, dwarf_version
);
8371 display_debug_info (section
, start
, file
)
8372 Elf_Internal_Shdr
*section
;
8373 unsigned char *start
;
8376 unsigned char *end
= start
+ section
->sh_size
;
8377 unsigned char *section_begin
= start
;
8379 printf (_("The section %s contains:\n\n"), SECTION_NAME (section
));
8381 load_debug_str (file
);
8382 load_debug_loc (file
);
8386 DWARF2_Internal_CompUnit compunit
;
8387 Elf_Internal_Shdr
*relsec
;
8388 unsigned char *hdrptr
;
8389 unsigned char *cu_abbrev_offset_ptr
;
8390 unsigned char *tags
;
8393 unsigned long cu_offset
;
8395 int initial_length_size
;
8399 compunit
.cu_length
= byte_get (hdrptr
, 4);
8402 if (compunit
.cu_length
== 0xffffffff)
8404 compunit
.cu_length
= byte_get (hdrptr
, 8);
8407 initial_length_size
= 12;
8412 initial_length_size
= 4;
8415 compunit
.cu_version
= byte_get (hdrptr
, 2);
8418 /* Apply addends of RELA relocations. */
8419 for (relsec
= section_headers
;
8420 relsec
< section_headers
+ elf_header
.e_shnum
;
8423 unsigned long nrelas
;
8424 Elf_Internal_Rela
*rela
, *rp
;
8425 Elf_Internal_Shdr
*symsec
;
8426 Elf_Internal_Sym
*symtab
;
8427 Elf_Internal_Sym
*sym
;
8429 if (relsec
->sh_type
!= SHT_RELA
8430 || SECTION_HEADER (relsec
->sh_info
) != section
8431 || relsec
->sh_size
== 0)
8434 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
8438 symsec
= SECTION_HEADER (relsec
->sh_link
);
8439 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
8441 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
8445 if (rp
->r_offset
>= (bfd_vma
) (hdrptr
- section_begin
)
8446 && section
->sh_size
> (bfd_vma
) offset_size
8447 && rp
->r_offset
<= section
->sh_size
- offset_size
)
8448 loc
= section_begin
+ rp
->r_offset
;
8454 sym
= symtab
+ ELF32_R_SYM (rp
->r_info
);
8456 if (ELF32_R_SYM (rp
->r_info
) != 0
8457 && ELF32_ST_TYPE (sym
->st_info
) != STT_SECTION
)
8459 warn (_("Skipping unexpected symbol type %u\n"),
8460 ELF32_ST_TYPE (sym
->st_info
));
8466 sym
= symtab
+ ELF64_R_SYM (rp
->r_info
);
8468 if (ELF64_R_SYM (rp
->r_info
) != 0
8469 && ELF64_ST_TYPE (sym
->st_info
) != STT_SECTION
)
8471 warn (_("Skipping unexpected symbol type %u\n"),
8472 ELF64_ST_TYPE (sym
->st_info
));
8477 byte_put (loc
, rp
->r_addend
, offset_size
);
8484 cu_abbrev_offset_ptr
= hdrptr
;
8485 compunit
.cu_abbrev_offset
= byte_get (hdrptr
, offset_size
);
8486 hdrptr
+= offset_size
;
8488 compunit
.cu_pointer_size
= byte_get (hdrptr
, 1);
8492 cu_offset
= start
- section_begin
;
8493 start
+= compunit
.cu_length
+ initial_length_size
;
8495 printf (_(" Compilation Unit @ %lx:\n"), cu_offset
);
8496 printf (_(" Length: %ld\n"), compunit
.cu_length
);
8497 printf (_(" Version: %d\n"), compunit
.cu_version
);
8498 printf (_(" Abbrev Offset: %ld\n"), compunit
.cu_abbrev_offset
);
8499 printf (_(" Pointer Size: %d\n"), compunit
.cu_pointer_size
);
8501 if (compunit
.cu_version
!= 2 && compunit
.cu_version
!= 3)
8503 warn (_("Only version 2 and 3 DWARF debug information is currently supported.\n"));
8509 /* Read in the abbrevs used by this compilation unit. */
8511 Elf_Internal_Shdr
*sec
;
8512 unsigned char *begin
;
8514 /* Locate the .debug_abbrev section and process it. */
8515 for (i
= 0, sec
= section_headers
;
8516 i
< elf_header
.e_shnum
;
8518 if (strcmp (SECTION_NAME (sec
), ".debug_abbrev") == 0)
8521 if (i
== elf_header
.e_shnum
|| sec
->sh_size
== 0)
8523 warn (_("Unable to locate .debug_abbrev section!\n"));
8527 begin
= ((unsigned char *)
8528 get_data (NULL
, file
, sec
->sh_offset
, sec
->sh_size
,
8529 _("debug_abbrev section data")));
8533 process_abbrev_section (begin
+ compunit
.cu_abbrev_offset
,
8534 begin
+ sec
->sh_size
);
8540 while (tags
< start
)
8543 unsigned long abbrev_number
;
8544 abbrev_entry
*entry
;
8547 abbrev_number
= read_leb128 (tags
, & bytes_read
, 0);
8550 /* A null DIE marks the end of a list of children. */
8551 if (abbrev_number
== 0)
8557 /* Scan through the abbreviation list until we reach the
8559 for (entry
= first_abbrev
;
8560 entry
&& entry
->entry
!= abbrev_number
;
8561 entry
= entry
->next
)
8566 warn (_("Unable to locate entry %lu in the abbreviation table\n"),
8571 printf (_(" <%d><%lx>: Abbrev Number: %lu (%s)\n"),
8573 (unsigned long) (tags
- section_begin
- bytes_read
),
8575 get_TAG_name (entry
->tag
));
8577 for (attr
= entry
->first_attr
; attr
; attr
= attr
->next
)
8578 tags
= read_and_display_attr (attr
->attribute
,
8581 compunit
.cu_pointer_size
,
8583 compunit
.cu_version
);
8585 if (entry
->children
)
8599 display_debug_aranges (section
, start
, file
)
8600 Elf_Internal_Shdr
*section
;
8601 unsigned char *start
;
8602 FILE *file ATTRIBUTE_UNUSED
;
8604 unsigned char *end
= start
+ section
->sh_size
;
8606 printf (_("The section %s contains:\n\n"), SECTION_NAME (section
));
8610 unsigned char *hdrptr
;
8611 DWARF2_Internal_ARange arange
;
8612 unsigned char *ranges
;
8613 unsigned long length
;
8614 unsigned long address
;
8617 int initial_length_size
;
8621 arange
.ar_length
= byte_get (hdrptr
, 4);
8624 if (arange
.ar_length
== 0xffffffff)
8626 arange
.ar_length
= byte_get (hdrptr
, 8);
8629 initial_length_size
= 12;
8634 initial_length_size
= 4;
8637 arange
.ar_version
= byte_get (hdrptr
, 2);
8640 arange
.ar_info_offset
= byte_get (hdrptr
, offset_size
);
8641 hdrptr
+= offset_size
;
8643 arange
.ar_pointer_size
= byte_get (hdrptr
, 1);
8646 arange
.ar_segment_size
= byte_get (hdrptr
, 1);
8649 if (arange
.ar_version
!= 2 && arange
.ar_version
!= 3)
8651 warn (_("Only DWARF 2 and 3 aranges are currently supported.\n"));
8655 printf (_(" Length: %ld\n"), arange
.ar_length
);
8656 printf (_(" Version: %d\n"), arange
.ar_version
);
8657 printf (_(" Offset into .debug_info: %lx\n"), arange
.ar_info_offset
);
8658 printf (_(" Pointer Size: %d\n"), arange
.ar_pointer_size
);
8659 printf (_(" Segment Size: %d\n"), arange
.ar_segment_size
);
8661 printf (_("\n Address Length\n"));
8665 /* Must pad to an alignment boundary that is twice the pointer size. */
8666 excess
= (hdrptr
- start
) % (2 * arange
.ar_pointer_size
);
8668 ranges
+= (2 * arange
.ar_pointer_size
) - excess
;
8672 address
= byte_get (ranges
, arange
.ar_pointer_size
);
8674 ranges
+= arange
.ar_pointer_size
;
8676 length
= byte_get (ranges
, arange
.ar_pointer_size
);
8678 ranges
+= arange
.ar_pointer_size
;
8680 /* A pair of zeros marks the end of the list. */
8681 if (address
== 0 && length
== 0)
8684 printf (" %8.8lx %lu\n", address
, length
);
8687 start
+= arange
.ar_length
+ initial_length_size
;
8695 typedef struct Frame_Chunk
8697 struct Frame_Chunk
*next
;
8698 unsigned char *chunk_start
;
8700 /* DW_CFA_{undefined,same_value,offset,register,unreferenced} */
8701 short int *col_type
;
8704 unsigned int code_factor
;
8706 unsigned long pc_begin
;
8707 unsigned long pc_range
;
8711 unsigned char fde_encoding
;
8712 unsigned char cfa_exp
;
8716 /* A marker for a col_type that means this column was never referenced
8717 in the frame info. */
8718 #define DW_CFA_unreferenced (-1)
8720 static void frame_need_space
PARAMS ((Frame_Chunk
*, int));
8721 static void frame_display_row
PARAMS ((Frame_Chunk
*, int *, int *));
8722 static int size_of_encoded_value
PARAMS ((int));
8723 static bfd_vma get_encoded_value
PARAMS ((unsigned char *, int));
8726 frame_need_space (fc
, reg
)
8730 int prev
= fc
->ncols
;
8732 if (reg
< fc
->ncols
)
8735 fc
->ncols
= reg
+ 1;
8736 fc
->col_type
= (short int *) xrealloc (fc
->col_type
,
8737 fc
->ncols
* sizeof (short int));
8738 fc
->col_offset
= (int *) xrealloc (fc
->col_offset
,
8739 fc
->ncols
* sizeof (int));
8741 while (prev
< fc
->ncols
)
8743 fc
->col_type
[prev
] = DW_CFA_unreferenced
;
8744 fc
->col_offset
[prev
] = 0;
8750 frame_display_row (fc
, need_col_headers
, max_regs
)
8752 int *need_col_headers
;
8758 if (*max_regs
< fc
->ncols
)
8759 *max_regs
= fc
->ncols
;
8761 if (*need_col_headers
)
8763 *need_col_headers
= 0;
8765 printf (" LOC CFA ");
8767 for (r
= 0; r
< *max_regs
; r
++)
8768 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
8773 printf ("r%-4d", r
);
8779 printf ("%08lx ", fc
->pc_begin
);
8781 strcpy (tmp
, "exp");
8783 sprintf (tmp
, "r%d%+d", fc
->cfa_reg
, fc
->cfa_offset
);
8784 printf ("%-8s ", tmp
);
8786 for (r
= 0; r
< fc
->ncols
; r
++)
8788 if (fc
->col_type
[r
] != DW_CFA_unreferenced
)
8790 switch (fc
->col_type
[r
])
8792 case DW_CFA_undefined
:
8795 case DW_CFA_same_value
:
8799 sprintf (tmp
, "c%+d", fc
->col_offset
[r
]);
8801 case DW_CFA_register
:
8802 sprintf (tmp
, "r%d", fc
->col_offset
[r
]);
8804 case DW_CFA_expression
:
8805 strcpy (tmp
, "exp");
8808 strcpy (tmp
, "n/a");
8811 printf ("%-5s", tmp
);
8818 size_of_encoded_value (encoding
)
8821 switch (encoding
& 0x7)
8824 case 0: return is_32bit_elf
? 4 : 8;
8832 get_encoded_value (data
, encoding
)
8833 unsigned char *data
;
8836 int size
= size_of_encoded_value (encoding
);
8837 if (encoding
& DW_EH_PE_signed
)
8838 return byte_get_signed (data
, size
);
8840 return byte_get (data
, size
);
8843 #define GET(N) byte_get (start, N); start += N
8844 #define LEB() read_leb128 (start, & length_return, 0); start += length_return
8845 #define SLEB() read_leb128 (start, & length_return, 1); start += length_return
8848 display_debug_frames (section
, start
, file
)
8849 Elf_Internal_Shdr
*section
;
8850 unsigned char *start
;
8851 FILE *file ATTRIBUTE_UNUSED
;
8853 unsigned char *end
= start
+ section
->sh_size
;
8854 unsigned char *section_start
= start
;
8855 Frame_Chunk
*chunks
= 0;
8856 Frame_Chunk
*remembered_state
= 0;
8858 int is_eh
= (strcmp (SECTION_NAME (section
), ".eh_frame") == 0);
8861 int addr_size
= is_32bit_elf
? 4 : 8;
8863 printf (_("The section %s contains:\n"), SECTION_NAME (section
));
8867 unsigned char *saved_start
;
8868 unsigned char *block_end
;
8869 unsigned long length
;
8870 unsigned long cie_id
;
8873 int need_col_headers
= 1;
8874 unsigned char *augmentation_data
= NULL
;
8875 unsigned long augmentation_data_len
= 0;
8876 int encoded_ptr_size
= addr_size
;
8878 int initial_length_size
;
8880 saved_start
= start
;
8881 length
= byte_get (start
, 4); start
+= 4;
8885 printf ("\n%08lx ZERO terminator\n\n",
8886 (unsigned long)(saved_start
- section_start
));
8890 if (length
== 0xffffffff)
8892 length
= byte_get (start
, 8);
8895 initial_length_size
= 12;
8900 initial_length_size
= 4;
8903 block_end
= saved_start
+ length
+ initial_length_size
;
8904 cie_id
= byte_get (start
, offset_size
); start
+= offset_size
;
8906 if (is_eh
? (cie_id
== 0) : (cie_id
== DW_CIE_ID
))
8910 fc
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
8911 memset (fc
, 0, sizeof (Frame_Chunk
));
8915 fc
->chunk_start
= saved_start
;
8917 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
8918 fc
->col_offset
= (int *) xmalloc (sizeof (int));
8919 frame_need_space (fc
, max_regs
-1);
8923 fc
->augmentation
= start
;
8924 start
= strchr (start
, '\0') + 1;
8926 if (fc
->augmentation
[0] == 'z')
8928 fc
->code_factor
= LEB ();
8929 fc
->data_factor
= SLEB ();
8930 fc
->ra
= byte_get (start
, 1); start
+= 1;
8931 augmentation_data_len
= LEB ();
8932 augmentation_data
= start
;
8933 start
+= augmentation_data_len
;
8935 else if (strcmp (fc
->augmentation
, "eh") == 0)
8938 fc
->code_factor
= LEB ();
8939 fc
->data_factor
= SLEB ();
8940 fc
->ra
= byte_get (start
, 1); start
+= 1;
8944 fc
->code_factor
= LEB ();
8945 fc
->data_factor
= SLEB ();
8946 fc
->ra
= byte_get (start
, 1); start
+= 1;
8950 if (do_debug_frames_interp
)
8951 printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n",
8952 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
8953 fc
->augmentation
, fc
->code_factor
, fc
->data_factor
,
8957 printf ("\n%08lx %08lx %08lx CIE\n",
8958 (unsigned long)(saved_start
- section_start
), length
, cie_id
);
8959 printf (" Version: %d\n", version
);
8960 printf (" Augmentation: \"%s\"\n", fc
->augmentation
);
8961 printf (" Code alignment factor: %u\n", fc
->code_factor
);
8962 printf (" Data alignment factor: %d\n", fc
->data_factor
);
8963 printf (" Return address column: %d\n", fc
->ra
);
8965 if (augmentation_data_len
)
8968 printf (" Augmentation data: ");
8969 for (i
= 0; i
< augmentation_data_len
; ++i
)
8970 printf (" %02x", augmentation_data
[i
]);
8976 if (augmentation_data_len
)
8978 unsigned char *p
, *q
;
8979 p
= fc
->augmentation
+ 1;
8980 q
= augmentation_data
;
8987 q
+= 1 + size_of_encoded_value (*q
);
8989 fc
->fde_encoding
= *q
++;
8995 if (fc
->fde_encoding
)
8996 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
8999 frame_need_space (fc
, fc
->ra
);
9003 unsigned char *look_for
;
9004 static Frame_Chunk fde_fc
;
9007 memset (fc
, 0, sizeof (Frame_Chunk
));
9009 look_for
= is_eh
? start
- 4 - cie_id
: section_start
+ cie_id
;
9011 for (cie
= chunks
; cie
; cie
= cie
->next
)
9012 if (cie
->chunk_start
== look_for
)
9017 warn ("Invalid CIE pointer %08lx in FDE at %08lx\n",
9018 cie_id
, saved_start
);
9021 fc
->col_type
= (short int *) xmalloc (sizeof (short int));
9022 fc
->col_offset
= (int *) xmalloc (sizeof (int));
9023 frame_need_space (fc
, max_regs
- 1);
9025 fc
->augmentation
= "";
9026 fc
->fde_encoding
= 0;
9030 fc
->ncols
= cie
->ncols
;
9031 fc
->col_type
= (short int *) xmalloc (fc
->ncols
* sizeof (short int));
9032 fc
->col_offset
= (int *) xmalloc (fc
->ncols
* sizeof (int));
9033 memcpy (fc
->col_type
, cie
->col_type
, fc
->ncols
* sizeof (short int));
9034 memcpy (fc
->col_offset
, cie
->col_offset
, fc
->ncols
* sizeof (int));
9035 fc
->augmentation
= cie
->augmentation
;
9036 fc
->code_factor
= cie
->code_factor
;
9037 fc
->data_factor
= cie
->data_factor
;
9038 fc
->cfa_reg
= cie
->cfa_reg
;
9039 fc
->cfa_offset
= cie
->cfa_offset
;
9041 frame_need_space (fc
, max_regs
-1);
9042 fc
->fde_encoding
= cie
->fde_encoding
;
9045 if (fc
->fde_encoding
)
9046 encoded_ptr_size
= size_of_encoded_value (fc
->fde_encoding
);
9048 fc
->pc_begin
= get_encoded_value (start
, fc
->fde_encoding
);
9049 if ((fc
->fde_encoding
& 0x70) == DW_EH_PE_pcrel
)
9050 fc
->pc_begin
+= section
->sh_addr
+ (start
- section_start
);
9051 start
+= encoded_ptr_size
;
9052 fc
->pc_range
= byte_get (start
, encoded_ptr_size
);
9053 start
+= encoded_ptr_size
;
9055 if (cie
->augmentation
[0] == 'z')
9057 augmentation_data_len
= LEB ();
9058 augmentation_data
= start
;
9059 start
+= augmentation_data_len
;
9062 printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=%08lx..%08lx\n",
9063 (unsigned long)(saved_start
- section_start
), length
, cie_id
,
9064 (unsigned long)(cie
->chunk_start
- section_start
),
9065 fc
->pc_begin
, fc
->pc_begin
+ fc
->pc_range
);
9066 if (! do_debug_frames_interp
&& augmentation_data_len
)
9069 printf (" Augmentation data: ");
9070 for (i
= 0; i
< augmentation_data_len
; ++i
)
9071 printf (" %02x", augmentation_data
[i
]);
9077 /* At this point, fc is the current chunk, cie (if any) is set, and we're
9078 about to interpret instructions for the chunk. */
9079 /* ??? At present we need to do this always, since this sizes the
9080 fc->col_type and fc->col_offset arrays, which we write into always.
9081 We should probably split the interpreted and non-interpreted bits
9082 into two different routines, since there's so much that doesn't
9083 really overlap between them. */
9084 if (1 || do_debug_frames_interp
)
9086 /* Start by making a pass over the chunk, allocating storage
9087 and taking note of what registers are used. */
9088 unsigned char *tmp
= start
;
9090 while (start
< block_end
)
9093 unsigned long reg
, tmp
;
9100 /* Warning: if you add any more cases to this switch, be
9101 sure to add them to the corresponding switch below. */
9104 case DW_CFA_advance_loc
:
9108 frame_need_space (fc
, opa
);
9109 fc
->col_type
[opa
] = DW_CFA_undefined
;
9111 case DW_CFA_restore
:
9112 frame_need_space (fc
, opa
);
9113 fc
->col_type
[opa
] = DW_CFA_undefined
;
9115 case DW_CFA_set_loc
:
9116 start
+= encoded_ptr_size
;
9118 case DW_CFA_advance_loc1
:
9121 case DW_CFA_advance_loc2
:
9124 case DW_CFA_advance_loc4
:
9127 case DW_CFA_offset_extended
:
9128 reg
= LEB (); LEB ();
9129 frame_need_space (fc
, reg
);
9130 fc
->col_type
[reg
] = DW_CFA_undefined
;
9132 case DW_CFA_restore_extended
:
9134 frame_need_space (fc
, reg
);
9135 fc
->col_type
[reg
] = DW_CFA_undefined
;
9137 case DW_CFA_undefined
:
9139 frame_need_space (fc
, reg
);
9140 fc
->col_type
[reg
] = DW_CFA_undefined
;
9142 case DW_CFA_same_value
:
9144 frame_need_space (fc
, reg
);
9145 fc
->col_type
[reg
] = DW_CFA_undefined
;
9147 case DW_CFA_register
:
9148 reg
= LEB (); LEB ();
9149 frame_need_space (fc
, reg
);
9150 fc
->col_type
[reg
] = DW_CFA_undefined
;
9152 case DW_CFA_def_cfa
:
9155 case DW_CFA_def_cfa_register
:
9158 case DW_CFA_def_cfa_offset
:
9161 case DW_CFA_def_cfa_expression
:
9165 case DW_CFA_expression
:
9169 frame_need_space (fc
, reg
);
9170 fc
->col_type
[reg
] = DW_CFA_undefined
;
9172 case DW_CFA_offset_extended_sf
:
9173 reg
= LEB (); SLEB ();
9174 frame_need_space (fc
, reg
);
9175 fc
->col_type
[reg
] = DW_CFA_undefined
;
9177 case DW_CFA_def_cfa_sf
:
9180 case DW_CFA_def_cfa_offset_sf
:
9183 case DW_CFA_MIPS_advance_loc8
:
9186 case DW_CFA_GNU_args_size
:
9189 case DW_CFA_GNU_negative_offset_extended
:
9190 reg
= LEB (); LEB ();
9191 frame_need_space (fc
, reg
);
9192 fc
->col_type
[reg
] = DW_CFA_undefined
;
9201 /* Now we know what registers are used, make a second pass over
9202 the chunk, this time actually printing out the info. */
9204 while (start
< block_end
)
9207 unsigned long ul
, reg
, roffs
;
9216 /* Warning: if you add any more cases to this switch, be
9217 sure to add them to the corresponding switch above. */
9220 case DW_CFA_advance_loc
:
9221 if (do_debug_frames_interp
)
9222 frame_display_row (fc
, &need_col_headers
, &max_regs
);
9224 printf (" DW_CFA_advance_loc: %d to %08lx\n",
9225 opa
* fc
->code_factor
,
9226 fc
->pc_begin
+ opa
* fc
->code_factor
);
9227 fc
->pc_begin
+= opa
* fc
->code_factor
;
9232 if (! do_debug_frames_interp
)
9233 printf (" DW_CFA_offset: r%d at cfa%+ld\n",
9234 opa
, roffs
* fc
->data_factor
);
9235 fc
->col_type
[opa
] = DW_CFA_offset
;
9236 fc
->col_offset
[opa
] = roffs
* fc
->data_factor
;
9239 case DW_CFA_restore
:
9240 if (! do_debug_frames_interp
)
9241 printf (" DW_CFA_restore: r%d\n", opa
);
9242 fc
->col_type
[opa
] = cie
->col_type
[opa
];
9243 fc
->col_offset
[opa
] = cie
->col_offset
[opa
];
9246 case DW_CFA_set_loc
:
9247 vma
= get_encoded_value (start
, fc
->fde_encoding
);
9248 if ((fc
->fde_encoding
& 0x70) == DW_EH_PE_pcrel
)
9249 vma
+= section
->sh_addr
+ (start
- section_start
);
9250 start
+= encoded_ptr_size
;
9251 if (do_debug_frames_interp
)
9252 frame_display_row (fc
, &need_col_headers
, &max_regs
);
9254 printf (" DW_CFA_set_loc: %08lx\n", (unsigned long)vma
);
9258 case DW_CFA_advance_loc1
:
9259 ofs
= byte_get (start
, 1); start
+= 1;
9260 if (do_debug_frames_interp
)
9261 frame_display_row (fc
, &need_col_headers
, &max_regs
);
9263 printf (" DW_CFA_advance_loc1: %ld to %08lx\n",
9264 ofs
* fc
->code_factor
,
9265 fc
->pc_begin
+ ofs
* fc
->code_factor
);
9266 fc
->pc_begin
+= ofs
* fc
->code_factor
;
9269 case DW_CFA_advance_loc2
:
9270 ofs
= byte_get (start
, 2); start
+= 2;
9271 if (do_debug_frames_interp
)
9272 frame_display_row (fc
, &need_col_headers
, &max_regs
);
9274 printf (" DW_CFA_advance_loc2: %ld to %08lx\n",
9275 ofs
* fc
->code_factor
,
9276 fc
->pc_begin
+ ofs
* fc
->code_factor
);
9277 fc
->pc_begin
+= ofs
* fc
->code_factor
;
9280 case DW_CFA_advance_loc4
:
9281 ofs
= byte_get (start
, 4); start
+= 4;
9282 if (do_debug_frames_interp
)
9283 frame_display_row (fc
, &need_col_headers
, &max_regs
);
9285 printf (" DW_CFA_advance_loc4: %ld to %08lx\n",
9286 ofs
* fc
->code_factor
,
9287 fc
->pc_begin
+ ofs
* fc
->code_factor
);
9288 fc
->pc_begin
+= ofs
* fc
->code_factor
;
9291 case DW_CFA_offset_extended
:
9294 if (! do_debug_frames_interp
)
9295 printf (" DW_CFA_offset_extended: r%ld at cfa%+ld\n",
9296 reg
, roffs
* fc
->data_factor
);
9297 fc
->col_type
[reg
] = DW_CFA_offset
;
9298 fc
->col_offset
[reg
] = roffs
* fc
->data_factor
;
9301 case DW_CFA_restore_extended
:
9303 if (! do_debug_frames_interp
)
9304 printf (" DW_CFA_restore_extended: r%ld\n", reg
);
9305 fc
->col_type
[reg
] = cie
->col_type
[reg
];
9306 fc
->col_offset
[reg
] = cie
->col_offset
[reg
];
9309 case DW_CFA_undefined
:
9311 if (! do_debug_frames_interp
)
9312 printf (" DW_CFA_undefined: r%ld\n", reg
);
9313 fc
->col_type
[reg
] = DW_CFA_undefined
;
9314 fc
->col_offset
[reg
] = 0;
9317 case DW_CFA_same_value
:
9319 if (! do_debug_frames_interp
)
9320 printf (" DW_CFA_same_value: r%ld\n", reg
);
9321 fc
->col_type
[reg
] = DW_CFA_same_value
;
9322 fc
->col_offset
[reg
] = 0;
9325 case DW_CFA_register
:
9328 if (! do_debug_frames_interp
)
9329 printf (" DW_CFA_register: r%ld in r%ld\n", reg
, roffs
);
9330 fc
->col_type
[reg
] = DW_CFA_register
;
9331 fc
->col_offset
[reg
] = roffs
;
9334 case DW_CFA_remember_state
:
9335 if (! do_debug_frames_interp
)
9336 printf (" DW_CFA_remember_state\n");
9337 rs
= (Frame_Chunk
*) xmalloc (sizeof (Frame_Chunk
));
9338 rs
->ncols
= fc
->ncols
;
9339 rs
->col_type
= (short int *) xmalloc (rs
->ncols
* sizeof (short int));
9340 rs
->col_offset
= (int *) xmalloc (rs
->ncols
* sizeof (int));
9341 memcpy (rs
->col_type
, fc
->col_type
, rs
->ncols
);
9342 memcpy (rs
->col_offset
, fc
->col_offset
, rs
->ncols
* sizeof (int));
9343 rs
->next
= remembered_state
;
9344 remembered_state
= rs
;
9347 case DW_CFA_restore_state
:
9348 if (! do_debug_frames_interp
)
9349 printf (" DW_CFA_restore_state\n");
9350 rs
= remembered_state
;
9351 remembered_state
= rs
->next
;
9352 frame_need_space (fc
, rs
->ncols
-1);
9353 memcpy (fc
->col_type
, rs
->col_type
, rs
->ncols
);
9354 memcpy (fc
->col_offset
, rs
->col_offset
, rs
->ncols
* sizeof (int));
9355 free (rs
->col_type
);
9356 free (rs
->col_offset
);
9360 case DW_CFA_def_cfa
:
9361 fc
->cfa_reg
= LEB ();
9362 fc
->cfa_offset
= LEB ();
9364 if (! do_debug_frames_interp
)
9365 printf (" DW_CFA_def_cfa: r%d ofs %d\n",
9366 fc
->cfa_reg
, fc
->cfa_offset
);
9369 case DW_CFA_def_cfa_register
:
9370 fc
->cfa_reg
= LEB ();
9372 if (! do_debug_frames_interp
)
9373 printf (" DW_CFA_def_cfa_reg: r%d\n", fc
->cfa_reg
);
9376 case DW_CFA_def_cfa_offset
:
9377 fc
->cfa_offset
= LEB ();
9378 if (! do_debug_frames_interp
)
9379 printf (" DW_CFA_def_cfa_offset: %d\n", fc
->cfa_offset
);
9383 if (! do_debug_frames_interp
)
9384 printf (" DW_CFA_nop\n");
9387 case DW_CFA_def_cfa_expression
:
9389 if (! do_debug_frames_interp
)
9391 printf (" DW_CFA_def_cfa_expression (");
9392 decode_location_expression (start
, addr_size
, ul
);
9399 case DW_CFA_expression
:
9402 if (! do_debug_frames_interp
)
9404 printf (" DW_CFA_expression: r%ld (", reg
);
9405 decode_location_expression (start
, addr_size
, ul
);
9408 fc
->col_type
[reg
] = DW_CFA_expression
;
9412 case DW_CFA_offset_extended_sf
:
9415 frame_need_space (fc
, reg
);
9416 if (! do_debug_frames_interp
)
9417 printf (" DW_CFA_offset_extended_sf: r%ld at cfa%+ld\n",
9418 reg
, l
* fc
->data_factor
);
9419 fc
->col_type
[reg
] = DW_CFA_offset
;
9420 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
9423 case DW_CFA_def_cfa_sf
:
9424 fc
->cfa_reg
= LEB ();
9425 fc
->cfa_offset
= SLEB ();
9427 if (! do_debug_frames_interp
)
9428 printf (" DW_CFA_def_cfa_sf: r%d ofs %d\n",
9429 fc
->cfa_reg
, fc
->cfa_offset
);
9432 case DW_CFA_def_cfa_offset_sf
:
9433 fc
->cfa_offset
= SLEB ();
9434 if (! do_debug_frames_interp
)
9435 printf (" DW_CFA_def_cfa_offset_sf: %d\n", fc
->cfa_offset
);
9438 case DW_CFA_MIPS_advance_loc8
:
9439 ofs
= byte_get (start
, 8); start
+= 8;
9440 if (do_debug_frames_interp
)
9441 frame_display_row (fc
, &need_col_headers
, &max_regs
);
9443 printf (" DW_CFA_MIPS_advance_loc8: %ld to %08lx\n",
9444 ofs
* fc
->code_factor
,
9445 fc
->pc_begin
+ ofs
* fc
->code_factor
);
9446 fc
->pc_begin
+= ofs
* fc
->code_factor
;
9449 case DW_CFA_GNU_window_save
:
9450 if (! do_debug_frames_interp
)
9451 printf (" DW_CFA_GNU_window_save\n");
9454 case DW_CFA_GNU_args_size
:
9456 if (! do_debug_frames_interp
)
9457 printf (" DW_CFA_GNU_args_size: %ld\n", ul
);
9460 case DW_CFA_GNU_negative_offset_extended
:
9463 frame_need_space (fc
, reg
);
9464 if (! do_debug_frames_interp
)
9465 printf (" DW_CFA_GNU_negative_offset_extended: r%ld at cfa%+ld\n",
9466 reg
, l
* fc
->data_factor
);
9467 fc
->col_type
[reg
] = DW_CFA_offset
;
9468 fc
->col_offset
[reg
] = l
* fc
->data_factor
;
9472 fprintf (stderr
, "unsupported or unknown DW_CFA_%d\n", op
);
9477 if (do_debug_frames_interp
)
9478 frame_display_row (fc
, &need_col_headers
, &max_regs
);
9493 display_debug_not_supported (section
, start
, file
)
9494 Elf_Internal_Shdr
*section
;
9495 unsigned char *start ATTRIBUTE_UNUSED
;
9496 FILE *file ATTRIBUTE_UNUSED
;
9498 printf (_("Displaying the debug contents of section %s is not yet supported.\n"),
9499 SECTION_NAME (section
));
9504 /* Pre-scan the .debug_info section to record the size of address.
9505 When dumping the .debug_line, we use that size information, assuming
9506 that all compilation units have the same address size. */
9508 prescan_debug_info (section
, start
, file
)
9509 Elf_Internal_Shdr
*section ATTRIBUTE_UNUSED
;
9510 unsigned char *start
;
9511 FILE *file ATTRIBUTE_UNUSED
;
9513 unsigned long length
;
9515 /* Read the first 4 bytes. For a 32-bit DWARF section, this will
9516 be the length. For a 64-bit DWARF section, it'll be the escape
9517 code 0xffffffff followed by an 8 byte length. For the purposes
9518 of this prescan, we don't care about the actual length, but the
9519 presence of the escape bytes does affect the location of the byte
9520 which describes the address size. */
9521 length
= byte_get (start
, 4);
9523 if (length
== 0xffffffff)
9525 /* For 64-bit DWARF, the 1-byte address_size field is 22 bytes
9526 from the start of the section. This is computed as follows:
9528 unit_length: 12 bytes
9530 debug_abbrev_offset: 8 bytes
9531 -----------------------------
9534 debug_line_pointer_size
= byte_get (start
+ 22, 1);
9538 /* For 32-bit DWARF, the 1-byte address_size field is 10 bytes from
9539 the start of the section:
9540 unit_length: 4 bytes
9542 debug_abbrev_offset: 4 bytes
9543 -----------------------------
9546 debug_line_pointer_size
= byte_get (start
+ 10, 1);
9551 /* A structure containing the name of a debug section and a pointer
9552 to a function that can decode it. The third field is a prescan
9553 function to be run over the section before displaying any of the
9557 const char *const name
;
9558 int (*display
) PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
9559 int (*prescan
) PARAMS ((Elf_Internal_Shdr
*, unsigned char *, FILE *));
9563 { ".debug_abbrev", display_debug_abbrev
, NULL
},
9564 { ".debug_aranges", display_debug_aranges
, NULL
},
9565 { ".debug_frame", display_debug_frames
, NULL
},
9566 { ".debug_info", display_debug_info
, prescan_debug_info
},
9567 { ".debug_line", display_debug_lines
, NULL
},
9568 { ".debug_pubnames", display_debug_pubnames
, NULL
},
9569 { ".eh_frame", display_debug_frames
, NULL
},
9570 { ".debug_macinfo", display_debug_macinfo
, NULL
},
9571 { ".debug_str", display_debug_str
, NULL
},
9572 { ".debug_loc", display_debug_loc
, NULL
},
9573 { ".debug_pubtypes", display_debug_not_supported
, NULL
},
9574 { ".debug_ranges", display_debug_not_supported
, NULL
},
9575 { ".debug_static_func", display_debug_not_supported
, NULL
},
9576 { ".debug_static_vars", display_debug_not_supported
, NULL
},
9577 { ".debug_types", display_debug_not_supported
, NULL
},
9578 { ".debug_weaknames", display_debug_not_supported
, NULL
}
9582 display_debug_section (section
, file
)
9583 Elf_Internal_Shdr
*section
;
9586 char *name
= SECTION_NAME (section
);
9587 bfd_size_type length
;
9588 unsigned char *start
;
9591 length
= section
->sh_size
;
9594 printf (_("\nSection '%s' has no debugging data.\n"), name
);
9598 start
= (unsigned char *) get_data (NULL
, file
, section
->sh_offset
, length
,
9599 _("debug section data"));
9603 /* See if we know how to display the contents of this section. */
9604 if (strncmp (name
, ".gnu.linkonce.wi.", 17) == 0)
9605 name
= ".debug_info";
9607 for (i
= NUM_ELEM (debug_displays
); i
--;)
9608 if (strcmp (debug_displays
[i
].name
, name
) == 0)
9610 debug_displays
[i
].display (section
, start
, file
);
9615 printf (_("Unrecognized debug section: %s\n"), name
);
9619 /* If we loaded in the abbrev section at some point,
9620 we must release it here. */
9627 process_section_contents (file
)
9630 Elf_Internal_Shdr
*section
;
9636 /* Pre-scan the debug sections to find some debug information not
9637 present in some of them. For the .debug_line, we must find out the
9638 size of address (specified in .debug_info and .debug_aranges). */
9639 for (i
= 0, section
= section_headers
;
9640 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
9643 char *name
= SECTION_NAME (section
);
9646 if (section
->sh_size
== 0)
9649 /* See if there is some pre-scan operation for this section. */
9650 for (j
= NUM_ELEM (debug_displays
); j
--;)
9651 if (strcmp (debug_displays
[j
].name
, name
) == 0)
9653 if (debug_displays
[j
].prescan
!= NULL
)
9655 bfd_size_type length
;
9656 unsigned char *start
;
9658 length
= section
->sh_size
;
9659 start
= ((unsigned char *)
9660 get_data (NULL
, file
, section
->sh_offset
, length
,
9661 _("debug section data")));
9665 debug_displays
[j
].prescan (section
, start
, file
);
9673 for (i
= 0, section
= section_headers
;
9674 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
9677 #ifdef SUPPORT_DISASSEMBLY
9678 if (dump_sects
[i
] & DISASS_DUMP
)
9679 disassemble_section (section
, file
);
9681 if (dump_sects
[i
] & HEX_DUMP
)
9682 dump_section (section
, file
);
9684 if (dump_sects
[i
] & DEBUG_DUMP
)
9685 display_debug_section (section
, file
);
9688 if (i
< num_dump_sects
)
9689 warn (_("Some sections were not dumped because they do not exist!\n"));
9695 process_mips_fpe_exception (mask
)
9701 if (mask
& OEX_FPU_INEX
)
9702 fputs ("INEX", stdout
), first
= 0;
9703 if (mask
& OEX_FPU_UFLO
)
9704 printf ("%sUFLO", first
? "" : "|"), first
= 0;
9705 if (mask
& OEX_FPU_OFLO
)
9706 printf ("%sOFLO", first
? "" : "|"), first
= 0;
9707 if (mask
& OEX_FPU_DIV0
)
9708 printf ("%sDIV0", first
? "" : "|"), first
= 0;
9709 if (mask
& OEX_FPU_INVAL
)
9710 printf ("%sINVAL", first
? "" : "|");
9713 fputs ("0", stdout
);
9717 process_mips_specific (file
)
9720 Elf_Internal_Dyn
*entry
;
9721 size_t liblist_offset
= 0;
9722 size_t liblistno
= 0;
9723 size_t conflictsno
= 0;
9724 size_t options_offset
= 0;
9725 size_t conflicts_offset
= 0;
9727 /* We have a lot of special sections. Thanks SGI! */
9728 if (dynamic_segment
== NULL
)
9729 /* No information available. */
9732 for (entry
= dynamic_segment
; entry
->d_tag
!= DT_NULL
; ++entry
)
9733 switch (entry
->d_tag
)
9735 case DT_MIPS_LIBLIST
:
9736 liblist_offset
= entry
->d_un
.d_val
- loadaddr
;
9738 case DT_MIPS_LIBLISTNO
:
9739 liblistno
= entry
->d_un
.d_val
;
9741 case DT_MIPS_OPTIONS
:
9742 options_offset
= entry
->d_un
.d_val
- loadaddr
;
9744 case DT_MIPS_CONFLICT
:
9745 conflicts_offset
= entry
->d_un
.d_val
- loadaddr
;
9747 case DT_MIPS_CONFLICTNO
:
9748 conflictsno
= entry
->d_un
.d_val
;
9754 if (liblist_offset
!= 0 && liblistno
!= 0 && do_dynamic
)
9756 Elf32_External_Lib
*elib
;
9759 elib
= ((Elf32_External_Lib
*)
9760 get_data (NULL
, file
, liblist_offset
,
9761 liblistno
* sizeof (Elf32_External_Lib
),
9765 printf ("\nSection '.liblist' contains %lu entries:\n",
9766 (unsigned long) liblistno
);
9767 fputs (" Library Time Stamp Checksum Version Flags\n",
9770 for (cnt
= 0; cnt
< liblistno
; ++cnt
)
9777 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
9778 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
9779 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
9780 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
9781 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
9783 tmp
= gmtime (&time
);
9784 sprintf (timebuf
, "%04u-%02u-%02uT%02u:%02u:%02u",
9785 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
9786 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
9788 printf ("%3lu: ", (unsigned long) cnt
);
9789 print_symbol (20, dynamic_strings
+ liblist
.l_name
);
9790 printf (" %s %#10lx %-7ld", timebuf
, liblist
.l_checksum
,
9793 if (liblist
.l_flags
== 0)
9804 { " EXACT_MATCH", LL_EXACT_MATCH
},
9805 { " IGNORE_INT_VER", LL_IGNORE_INT_VER
},
9806 { " REQUIRE_MINOR", LL_REQUIRE_MINOR
},
9807 { " EXPORTS", LL_EXPORTS
},
9808 { " DELAY_LOAD", LL_DELAY_LOAD
},
9809 { " DELTA", LL_DELTA
}
9811 int flags
= liblist
.l_flags
;
9815 fcnt
< sizeof (l_flags_vals
) / sizeof (l_flags_vals
[0]);
9817 if ((flags
& l_flags_vals
[fcnt
].bit
) != 0)
9819 fputs (l_flags_vals
[fcnt
].name
, stdout
);
9820 flags
^= l_flags_vals
[fcnt
].bit
;
9823 printf (" %#x", (unsigned int) flags
);
9833 if (options_offset
!= 0)
9835 Elf_External_Options
*eopt
;
9836 Elf_Internal_Shdr
*sect
= section_headers
;
9837 Elf_Internal_Options
*iopt
;
9838 Elf_Internal_Options
*option
;
9842 /* Find the section header so that we get the size. */
9843 while (sect
->sh_type
!= SHT_MIPS_OPTIONS
)
9846 eopt
= (Elf_External_Options
*) get_data (NULL
, file
, options_offset
,
9847 sect
->sh_size
, _("options"));
9850 iopt
= ((Elf_Internal_Options
*)
9851 malloc ((sect
->sh_size
/ sizeof (eopt
)) * sizeof (*iopt
)));
9854 error (_("Out of memory"));
9861 while (offset
< sect
->sh_size
)
9863 Elf_External_Options
*eoption
;
9865 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
9867 option
->kind
= BYTE_GET (eoption
->kind
);
9868 option
->size
= BYTE_GET (eoption
->size
);
9869 option
->section
= BYTE_GET (eoption
->section
);
9870 option
->info
= BYTE_GET (eoption
->info
);
9872 offset
+= option
->size
;
9878 printf (_("\nSection '%s' contains %d entries:\n"),
9879 SECTION_NAME (sect
), cnt
);
9887 switch (option
->kind
)
9890 /* This shouldn't happen. */
9891 printf (" NULL %d %lx", option
->section
, option
->info
);
9894 printf (" REGINFO ");
9895 if (elf_header
.e_machine
== EM_MIPS
)
9898 Elf32_External_RegInfo
*ereg
;
9899 Elf32_RegInfo reginfo
;
9901 ereg
= (Elf32_External_RegInfo
*) (option
+ 1);
9902 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
9903 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
9904 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
9905 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
9906 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
9907 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
9909 printf ("GPR %08lx GP 0x%lx\n",
9911 (unsigned long) reginfo
.ri_gp_value
);
9912 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
9913 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
9914 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
9919 Elf64_External_RegInfo
*ereg
;
9920 Elf64_Internal_RegInfo reginfo
;
9922 ereg
= (Elf64_External_RegInfo
*) (option
+ 1);
9923 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
9924 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
9925 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
9926 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
9927 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
9928 reginfo
.ri_gp_value
= BYTE_GET8 (ereg
->ri_gp_value
);
9930 printf ("GPR %08lx GP 0x",
9931 reginfo
.ri_gprmask
);
9932 printf_vma (reginfo
.ri_gp_value
);
9935 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
9936 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
9937 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
9941 case ODK_EXCEPTIONS
:
9942 fputs (" EXCEPTIONS fpe_min(", stdout
);
9943 process_mips_fpe_exception (option
->info
& OEX_FPU_MIN
);
9944 fputs (") fpe_max(", stdout
);
9945 process_mips_fpe_exception ((option
->info
& OEX_FPU_MAX
) >> 8);
9946 fputs (")", stdout
);
9948 if (option
->info
& OEX_PAGE0
)
9949 fputs (" PAGE0", stdout
);
9950 if (option
->info
& OEX_SMM
)
9951 fputs (" SMM", stdout
);
9952 if (option
->info
& OEX_FPDBUG
)
9953 fputs (" FPDBUG", stdout
);
9954 if (option
->info
& OEX_DISMISS
)
9955 fputs (" DISMISS", stdout
);
9958 fputs (" PAD ", stdout
);
9959 if (option
->info
& OPAD_PREFIX
)
9960 fputs (" PREFIX", stdout
);
9961 if (option
->info
& OPAD_POSTFIX
)
9962 fputs (" POSTFIX", stdout
);
9963 if (option
->info
& OPAD_SYMBOL
)
9964 fputs (" SYMBOL", stdout
);
9967 fputs (" HWPATCH ", stdout
);
9968 if (option
->info
& OHW_R4KEOP
)
9969 fputs (" R4KEOP", stdout
);
9970 if (option
->info
& OHW_R8KPFETCH
)
9971 fputs (" R8KPFETCH", stdout
);
9972 if (option
->info
& OHW_R5KEOP
)
9973 fputs (" R5KEOP", stdout
);
9974 if (option
->info
& OHW_R5KCVTL
)
9975 fputs (" R5KCVTL", stdout
);
9978 fputs (" FILL ", stdout
);
9979 /* XXX Print content of info word? */
9982 fputs (" TAGS ", stdout
);
9983 /* XXX Print content of info word? */
9986 fputs (" HWAND ", stdout
);
9987 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
9988 fputs (" R4KEOP_CHECKED", stdout
);
9989 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
9990 fputs (" R4KEOP_CLEAN", stdout
);
9993 fputs (" HWOR ", stdout
);
9994 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
9995 fputs (" R4KEOP_CHECKED", stdout
);
9996 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
9997 fputs (" R4KEOP_CLEAN", stdout
);
10000 printf (" GP_GROUP %#06lx self-contained %#06lx",
10001 option
->info
& OGP_GROUP
,
10002 (option
->info
& OGP_SELF
) >> 16);
10005 printf (" IDENT %#06lx self-contained %#06lx",
10006 option
->info
& OGP_GROUP
,
10007 (option
->info
& OGP_SELF
) >> 16);
10010 /* This shouldn't happen. */
10011 printf (" %3d ??? %d %lx",
10012 option
->kind
, option
->section
, option
->info
);
10016 len
= sizeof (*eopt
);
10017 while (len
< option
->size
)
10018 if (((char *) option
)[len
] >= ' '
10019 && ((char *) option
)[len
] < 0x7f)
10020 printf ("%c", ((char *) option
)[len
++]);
10022 printf ("\\%03o", ((char *) option
)[len
++]);
10024 fputs ("\n", stdout
);
10032 if (conflicts_offset
!= 0 && conflictsno
!= 0)
10034 Elf32_Conflict
*iconf
;
10037 if (dynamic_symbols
== NULL
)
10039 error (_("conflict list found without a dynamic symbol table"));
10043 iconf
= (Elf32_Conflict
*) malloc (conflictsno
* sizeof (*iconf
));
10046 error (_("Out of memory"));
10052 Elf32_External_Conflict
*econf32
;
10054 econf32
= ((Elf32_External_Conflict
*)
10055 get_data (NULL
, file
, conflicts_offset
,
10056 conflictsno
* sizeof (*econf32
),
10061 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
10062 iconf
[cnt
] = BYTE_GET (econf32
[cnt
]);
10068 Elf64_External_Conflict
*econf64
;
10070 econf64
= ((Elf64_External_Conflict
*)
10071 get_data (NULL
, file
, conflicts_offset
,
10072 conflictsno
* sizeof (*econf64
),
10077 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
10078 iconf
[cnt
] = BYTE_GET (econf64
[cnt
]);
10083 printf (_("\nSection '.conflict' contains %ld entries:\n"),
10084 (long) conflictsno
);
10085 puts (_(" Num: Index Value Name"));
10087 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
10089 Elf_Internal_Sym
*psym
= & dynamic_symbols
[iconf
[cnt
]];
10091 printf ("%5lu: %8lu ", (unsigned long) cnt
, iconf
[cnt
]);
10092 print_vma (psym
->st_value
, FULL_HEX
);
10094 print_symbol (25, dynamic_strings
+ psym
->st_name
);
10105 process_gnu_liblist (file
)
10108 Elf_Internal_Shdr
*section
, *string_sec
;
10109 Elf32_External_Lib
*elib
;
10117 for (i
= 0, section
= section_headers
;
10118 i
< elf_header
.e_shnum
;
10121 switch (section
->sh_type
)
10123 case SHT_GNU_LIBLIST
:
10124 elib
= ((Elf32_External_Lib
*)
10125 get_data (NULL
, file
, section
->sh_offset
, section
->sh_size
,
10130 string_sec
= SECTION_HEADER (section
->sh_link
);
10132 strtab
= (char *) get_data (NULL
, file
, string_sec
->sh_offset
,
10133 string_sec
->sh_size
,
10134 _("liblist string table"));
10137 || section
->sh_entsize
!= sizeof (Elf32_External_Lib
))
10143 printf (_("\nLibrary list section '%s' contains %lu entries:\n"),
10144 SECTION_NAME (section
),
10145 (long) (section
->sh_size
/ sizeof (Elf32_External_Lib
)));
10147 puts (" Library Time Stamp Checksum Version Flags");
10149 for (cnt
= 0; cnt
< section
->sh_size
/ sizeof (Elf32_External_Lib
);
10157 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
10158 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
10159 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
10160 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
10161 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
10163 tmp
= gmtime (&time
);
10164 sprintf (timebuf
, "%04u-%02u-%02uT%02u:%02u:%02u",
10165 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
10166 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
10168 printf ("%3lu: ", (unsigned long) cnt
);
10170 printf ("%-20s", strtab
+ liblist
.l_name
);
10172 printf ("%-20.20s", strtab
+ liblist
.l_name
);
10173 printf (" %s %#010lx %-7ld %-7ld\n", timebuf
, liblist
.l_checksum
,
10174 liblist
.l_version
, liblist
.l_flags
);
10184 static const char *
10185 get_note_type (e_type
)
10188 static char buff
[64];
10192 case NT_PRSTATUS
: return _("NT_PRSTATUS (prstatus structure)");
10193 case NT_FPREGSET
: return _("NT_FPREGSET (floating point registers)");
10194 case NT_PRPSINFO
: return _("NT_PRPSINFO (prpsinfo structure)");
10195 case NT_TASKSTRUCT
: return _("NT_TASKSTRUCT (task structure)");
10196 case NT_PRXFPREG
: return _("NT_PRXFPREG (user_xfpregs structure)");
10197 case NT_PSTATUS
: return _("NT_PSTATUS (pstatus structure)");
10198 case NT_FPREGS
: return _("NT_FPREGS (floating point registers)");
10199 case NT_PSINFO
: return _("NT_PSINFO (psinfo structure)");
10200 case NT_LWPSTATUS
: return _("NT_LWPSTATUS (lwpstatus_t structure)");
10201 case NT_LWPSINFO
: return _("NT_LWPSINFO (lwpsinfo_t structure)");
10202 case NT_WIN32PSTATUS
: return _("NT_WIN32PSTATUS (win32_pstatus structure)");
10204 sprintf (buff
, _("Unknown note type: (0x%08x)"), e_type
);
10209 static const char *
10210 get_netbsd_elfcore_note_type (e_type
)
10213 static char buff
[64];
10215 if (e_type
== NT_NETBSDCORE_PROCINFO
)
10217 /* NetBSD core "procinfo" structure. */
10218 return _("NetBSD procinfo structure");
10221 /* As of Jan 2002 there are no other machine-independent notes
10222 defined for NetBSD core files. If the note type is less
10223 than the start of the machine-dependent note types, we don't
10226 if (e_type
< NT_NETBSDCORE_FIRSTMACH
)
10228 sprintf (buff
, _("Unknown note type: (0x%08x)"), e_type
);
10232 switch (elf_header
.e_machine
)
10234 /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0
10235 and PT_GETFPREGS == mach+2. */
10240 case EM_SPARC32PLUS
:
10244 case NT_NETBSDCORE_FIRSTMACH
+0:
10245 return _("PT_GETREGS (reg structure)");
10246 case NT_NETBSDCORE_FIRSTMACH
+2:
10247 return _("PT_GETFPREGS (fpreg structure)");
10253 /* On all other arch's, PT_GETREGS == mach+1 and
10254 PT_GETFPREGS == mach+3. */
10258 case NT_NETBSDCORE_FIRSTMACH
+1:
10259 return _("PT_GETREGS (reg structure)");
10260 case NT_NETBSDCORE_FIRSTMACH
+3:
10261 return _("PT_GETFPREGS (fpreg structure)");
10267 sprintf (buff
, _("PT_FIRSTMACH+%d"), e_type
- NT_NETBSDCORE_FIRSTMACH
);
10271 /* Note that by the ELF standard, the name field is already null byte
10272 terminated, and namesz includes the terminating null byte.
10273 I.E. the value of namesz for the name "FSF" is 4.
10275 If the value of namesz is zero, there is no name present. */
10277 process_note (pnote
)
10278 Elf_Internal_Note
*pnote
;
10282 if (pnote
->namesz
== 0)
10284 /* If there is no note name, then use the default set of
10285 note type strings. */
10286 nt
= get_note_type (pnote
->type
);
10288 else if (strncmp (pnote
->namedata
, "NetBSD-CORE", 11) == 0)
10290 /* NetBSD-specific core file notes. */
10291 nt
= get_netbsd_elfcore_note_type (pnote
->type
);
10295 /* Don't recognize this note name; just use the default set of
10296 note type strings. */
10297 nt
= get_note_type (pnote
->type
);
10300 printf (" %s\t\t0x%08lx\t%s\n",
10301 pnote
->namesz
? pnote
->namedata
: "(NONE)",
10302 pnote
->descsz
, nt
);
10308 process_corefile_note_segment (file
, offset
, length
)
10313 Elf_External_Note
*pnotes
;
10314 Elf_External_Note
*external
;
10320 pnotes
= (Elf_External_Note
*) get_data (NULL
, file
, offset
, length
,
10327 printf (_("\nNotes at offset 0x%08lx with length 0x%08lx:\n"),
10328 (unsigned long) offset
, (unsigned long) length
);
10329 printf (_(" Owner\t\tData size\tDescription\n"));
10331 while (external
< (Elf_External_Note
*)((char *) pnotes
+ length
))
10333 Elf_External_Note
*next
;
10334 Elf_Internal_Note inote
;
10337 inote
.type
= BYTE_GET (external
->type
);
10338 inote
.namesz
= BYTE_GET (external
->namesz
);
10339 inote
.namedata
= external
->name
;
10340 inote
.descsz
= BYTE_GET (external
->descsz
);
10341 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 2);
10342 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
10344 next
= (Elf_External_Note
*)(inote
.descdata
+ align_power (inote
.descsz
, 2));
10346 if (((char *) next
) > (((char *) pnotes
) + length
))
10348 warn (_("corrupt note found at offset %x into core notes\n"),
10349 ((char *) external
) - ((char *) pnotes
));
10350 warn (_(" type: %x, namesize: %08lx, descsize: %08lx\n"),
10351 inote
.type
, inote
.namesz
, inote
.descsz
);
10357 /* Verify that name is null terminated. It appears that at least
10358 one version of Linux (RedHat 6.0) generates corefiles that don't
10359 comply with the ELF spec by failing to include the null byte in
10361 if (inote
.namedata
[inote
.namesz
] != '\0')
10363 temp
= malloc (inote
.namesz
+ 1);
10367 error (_("Out of memory\n"));
10372 strncpy (temp
, inote
.namedata
, inote
.namesz
);
10373 temp
[inote
.namesz
] = 0;
10375 /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */
10376 inote
.namedata
= temp
;
10379 res
&= process_note (& inote
);
10394 process_corefile_note_segments (file
)
10397 Elf_Internal_Phdr
*program_headers
;
10398 Elf_Internal_Phdr
*segment
;
10402 program_headers
= (Elf_Internal_Phdr
*) malloc
10403 (elf_header
.e_phnum
* sizeof (Elf_Internal_Phdr
));
10405 if (program_headers
== NULL
)
10407 error (_("Out of memory\n"));
10412 i
= get_32bit_program_headers (file
, program_headers
);
10414 i
= get_64bit_program_headers (file
, program_headers
);
10418 free (program_headers
);
10422 for (i
= 0, segment
= program_headers
;
10423 i
< elf_header
.e_phnum
;
10426 if (segment
->p_type
== PT_NOTE
)
10427 res
&= process_corefile_note_segment (file
,
10428 (bfd_vma
) segment
->p_offset
,
10429 (bfd_vma
) segment
->p_filesz
);
10432 free (program_headers
);
10438 process_corefile_contents (file
)
10441 /* If we have not been asked to display the notes then do nothing. */
10445 /* If file is not a core file then exit. */
10446 if (elf_header
.e_type
!= ET_CORE
)
10449 /* No program headers means no NOTE segment. */
10450 if (elf_header
.e_phnum
== 0)
10452 printf (_("No note segments present in the core file.\n"));
10456 return process_corefile_note_segments (file
);
10460 process_arch_specific (file
)
10466 switch (elf_header
.e_machine
)
10469 case EM_MIPS_RS3_LE
:
10470 return process_mips_specific (file
);
10479 get_file_header (file
)
10482 /* Read in the identity array. */
10483 if (fread (elf_header
.e_ident
, EI_NIDENT
, 1, file
) != 1)
10486 /* Determine how to read the rest of the header. */
10487 switch (elf_header
.e_ident
[EI_DATA
])
10489 default: /* fall through */
10490 case ELFDATANONE
: /* fall through */
10492 byte_get
= byte_get_little_endian
;
10493 byte_put
= byte_put_little_endian
;
10496 byte_get
= byte_get_big_endian
;
10497 byte_put
= byte_put_big_endian
;
10501 /* For now we only support 32 bit and 64 bit ELF files. */
10502 is_32bit_elf
= (elf_header
.e_ident
[EI_CLASS
] != ELFCLASS64
);
10504 /* Read in the rest of the header. */
10507 Elf32_External_Ehdr ehdr32
;
10509 if (fread (ehdr32
.e_type
, sizeof (ehdr32
) - EI_NIDENT
, 1, file
) != 1)
10512 elf_header
.e_type
= BYTE_GET (ehdr32
.e_type
);
10513 elf_header
.e_machine
= BYTE_GET (ehdr32
.e_machine
);
10514 elf_header
.e_version
= BYTE_GET (ehdr32
.e_version
);
10515 elf_header
.e_entry
= BYTE_GET (ehdr32
.e_entry
);
10516 elf_header
.e_phoff
= BYTE_GET (ehdr32
.e_phoff
);
10517 elf_header
.e_shoff
= BYTE_GET (ehdr32
.e_shoff
);
10518 elf_header
.e_flags
= BYTE_GET (ehdr32
.e_flags
);
10519 elf_header
.e_ehsize
= BYTE_GET (ehdr32
.e_ehsize
);
10520 elf_header
.e_phentsize
= BYTE_GET (ehdr32
.e_phentsize
);
10521 elf_header
.e_phnum
= BYTE_GET (ehdr32
.e_phnum
);
10522 elf_header
.e_shentsize
= BYTE_GET (ehdr32
.e_shentsize
);
10523 elf_header
.e_shnum
= BYTE_GET (ehdr32
.e_shnum
);
10524 elf_header
.e_shstrndx
= BYTE_GET (ehdr32
.e_shstrndx
);
10528 Elf64_External_Ehdr ehdr64
;
10530 /* If we have been compiled with sizeof (bfd_vma) == 4, then
10531 we will not be able to cope with the 64bit data found in
10532 64 ELF files. Detect this now and abort before we start
10533 overwritting things. */
10534 if (sizeof (bfd_vma
) < 8)
10536 error (_("This instance of readelf has been built without support for a\n\
10537 64 bit data type and so it cannot read 64 bit ELF files.\n"));
10541 if (fread (ehdr64
.e_type
, sizeof (ehdr64
) - EI_NIDENT
, 1, file
) != 1)
10544 elf_header
.e_type
= BYTE_GET (ehdr64
.e_type
);
10545 elf_header
.e_machine
= BYTE_GET (ehdr64
.e_machine
);
10546 elf_header
.e_version
= BYTE_GET (ehdr64
.e_version
);
10547 elf_header
.e_entry
= BYTE_GET8 (ehdr64
.e_entry
);
10548 elf_header
.e_phoff
= BYTE_GET8 (ehdr64
.e_phoff
);
10549 elf_header
.e_shoff
= BYTE_GET8 (ehdr64
.e_shoff
);
10550 elf_header
.e_flags
= BYTE_GET (ehdr64
.e_flags
);
10551 elf_header
.e_ehsize
= BYTE_GET (ehdr64
.e_ehsize
);
10552 elf_header
.e_phentsize
= BYTE_GET (ehdr64
.e_phentsize
);
10553 elf_header
.e_phnum
= BYTE_GET (ehdr64
.e_phnum
);
10554 elf_header
.e_shentsize
= BYTE_GET (ehdr64
.e_shentsize
);
10555 elf_header
.e_shnum
= BYTE_GET (ehdr64
.e_shnum
);
10556 elf_header
.e_shstrndx
= BYTE_GET (ehdr64
.e_shstrndx
);
10559 if (elf_header
.e_shoff
)
10561 /* There may be some extensions in the first section header. Don't
10562 bomb if we can't read it. */
10564 get_32bit_section_headers (file
, 1);
10566 get_64bit_section_headers (file
, 1);
10573 process_file (file_name
)
10577 struct stat statbuf
;
10580 if (stat (file_name
, & statbuf
) < 0)
10582 error (_("Cannot stat input file %s.\n"), file_name
);
10586 file
= fopen (file_name
, "rb");
10589 error (_("Input file %s not found.\n"), file_name
);
10593 if (! get_file_header (file
))
10595 error (_("%s: Failed to read file header\n"), file_name
);
10600 /* Initialise per file variables. */
10601 for (i
= NUM_ELEM (version_info
); i
--;)
10602 version_info
[i
] = 0;
10604 for (i
= NUM_ELEM (dynamic_info
); i
--;)
10605 dynamic_info
[i
] = 0;
10607 /* Process the file. */
10609 printf (_("\nFile: %s\n"), file_name
);
10611 if (! process_file_header ())
10617 if (! process_section_headers (file
))
10619 /* Without loaded section headers we
10620 cannot process lots of things. */
10621 do_unwind
= do_version
= do_dump
= do_arch
= 0;
10623 if (! do_using_dynamic
)
10624 do_syms
= do_reloc
= 0;
10627 if (process_program_headers (file
))
10628 process_dynamic_segment (file
);
10630 process_relocs (file
);
10632 process_unwind (file
);
10634 process_symbol_table (file
);
10636 process_syminfo (file
);
10638 process_version_sections (file
);
10640 process_section_contents (file
);
10642 process_corefile_contents (file
);
10644 process_gnu_liblist (file
);
10646 process_arch_specific (file
);
10650 if (section_headers
)
10652 free (section_headers
);
10653 section_headers
= NULL
;
10658 free (string_table
);
10659 string_table
= NULL
;
10660 string_table_length
= 0;
10663 if (dynamic_strings
)
10665 free (dynamic_strings
);
10666 dynamic_strings
= NULL
;
10669 if (dynamic_symbols
)
10671 free (dynamic_symbols
);
10672 dynamic_symbols
= NULL
;
10673 num_dynamic_syms
= 0;
10676 if (dynamic_syminfo
)
10678 free (dynamic_syminfo
);
10679 dynamic_syminfo
= NULL
;
10685 #ifdef SUPPORT_DISASSEMBLY
10686 /* Needed by the i386 disassembler. For extra credit, someone could
10687 fix this so that we insert symbolic addresses here, esp for GOT/PLT
10691 print_address (unsigned int addr
, FILE *outfile
)
10693 fprintf (outfile
,"0x%8.8x", addr
);
10696 /* Needed by the i386 disassembler. */
10698 db_task_printsym (unsigned int addr
)
10700 print_address (addr
, stderr
);
10704 int main
PARAMS ((int, char **));
10712 char *cmdline_dump_sects
= NULL
;
10713 unsigned num_cmdline_dump_sects
= 0;
10715 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
10716 setlocale (LC_MESSAGES
, "");
10718 #if defined (HAVE_SETLOCALE)
10719 setlocale (LC_CTYPE
, "");
10721 bindtextdomain (PACKAGE
, LOCALEDIR
);
10722 textdomain (PACKAGE
);
10724 parse_args (argc
, argv
);
10726 if (optind
< (argc
- 1))
10729 /* When processing more than one file remember the dump requests
10730 issued on command line to reset them after each file. */
10731 if (optind
+ 1 < argc
&& dump_sects
!= NULL
)
10733 cmdline_dump_sects
= malloc (num_dump_sects
);
10734 if (cmdline_dump_sects
== NULL
)
10735 error (_("Out of memory allocating dump request table."));
10738 memcpy (cmdline_dump_sects
, dump_sects
, num_dump_sects
);
10739 num_cmdline_dump_sects
= num_dump_sects
;
10744 while (optind
< argc
)
10746 err
|= process_file (argv
[optind
++]);
10748 /* Reset dump requests. */
10749 if (optind
< argc
&& dump_sects
!= NULL
)
10751 num_dump_sects
= num_cmdline_dump_sects
;
10752 if (num_cmdline_dump_sects
> 0)
10753 memcpy (dump_sects
, cmdline_dump_sects
, num_cmdline_dump_sects
);
10757 if (dump_sects
!= NULL
)
10759 if (cmdline_dump_sects
!= NULL
)
10760 free (cmdline_dump_sects
);