1 /* readelf.c -- display contents of an ELF format file
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
3 Free Software Foundation, Inc.
5 Originally developed by Eric Youngdale <eric@andante.jic.com>
6 Modifications by Nick Clifton <nickc@redhat.com>
8 This file is part of GNU Binutils.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
25 /* The difference between readelf and objdump:
27 Both programs are capable of displaying the contents of ELF format files,
28 so why does the binutils project have two file dumpers ?
30 The reason is that objdump sees an ELF file through a BFD filter of the
31 world; if BFD has a bug where, say, it disagrees about a machine constant
32 in e_flags, then the odds are good that it will remain internally
33 consistent. The linker sees it the BFD way, objdump sees it the BFD way,
34 GAS sees it the BFD way. There was need for a tool to go find out what
35 the file actually says.
37 This is why the readelf program does not link against the BFD library - it
38 exists as an independent program to help verify the correct working of BFD.
40 There is also the case that readelf can provide more information about an
41 ELF file than is provided by objdump. In particular it can display DWARF
42 debugging information which (at the moment) objdump cannot. */
45 #include <sys/types.h>
51 /* Define BFD64 here, even if our default architecture is 32 bit ELF
52 as this will allow us to read in and parse 64bit and 32bit ELF files.
53 Only do this if we believe that the compiler can support a 64 bit
54 data type. For now we only rely on GCC being able to do this. */
60 #include "elf/common.h"
61 #include "elf/external.h"
62 #include "elf/internal.h"
64 /* The following headers use the elf/reloc-macros.h file to
65 automatically generate relocation recognition functions
66 such as elf_mips_reloc_type() */
68 #define RELOC_MACROS_GEN_FUNC
70 #include "elf/alpha.h"
90 #include "elf/iq2000.h"
94 #include "elf/m68hc11.h"
95 #include "elf/mcore.h"
98 #include "elf/mn10200.h"
99 #include "elf/mn10300.h"
101 #include "elf/msp430.h"
102 #include "elf/or32.h"
105 #include "elf/ppc64.h"
106 #include "elf/s390.h"
107 #include "elf/score.h"
109 #include "elf/sparc.h"
110 #include "elf/v850.h"
112 #include "elf/x86-64.h"
113 #include "elf/xstormy16.h"
114 #include "elf/xtensa.h"
120 #include "libiberty.h"
122 char *program_name
= "readelf";
123 static long archive_file_offset
;
124 static unsigned long archive_file_size
;
125 static unsigned long dynamic_addr
;
126 static bfd_size_type dynamic_size
;
127 static unsigned int dynamic_nent
;
128 static char *dynamic_strings
;
129 static unsigned long dynamic_strings_length
;
130 static char *string_table
;
131 static unsigned long string_table_length
;
132 static unsigned long num_dynamic_syms
;
133 static Elf_Internal_Sym
*dynamic_symbols
;
134 static Elf_Internal_Syminfo
*dynamic_syminfo
;
135 static unsigned long dynamic_syminfo_offset
;
136 static unsigned int dynamic_syminfo_nent
;
137 static char program_interpreter
[64];
138 static bfd_vma dynamic_info
[DT_JMPREL
+ 1];
139 static bfd_vma dynamic_info_DT_GNU_HASH
;
140 static bfd_vma version_info
[16];
141 static Elf_Internal_Ehdr elf_header
;
142 static Elf_Internal_Shdr
*section_headers
;
143 static Elf_Internal_Phdr
*program_headers
;
144 static Elf_Internal_Dyn
*dynamic_section
;
145 static Elf_Internal_Shdr
*symtab_shndx_hdr
;
146 static int show_name
;
147 static int do_dynamic
;
150 static int do_sections
;
151 static int do_section_groups
;
152 static int do_section_details
;
153 static int do_segments
;
154 static int do_unwind
;
155 static int do_using_dynamic
;
156 static int do_header
;
158 static int do_version
;
160 static int do_histogram
;
161 static int do_debugging
;
164 static int is_32bit_elf
;
168 struct group_list
*next
;
169 unsigned int section_index
;
174 struct group_list
*root
;
175 unsigned int group_index
;
178 static size_t group_count
;
179 static struct group
*section_groups
;
180 static struct group
**section_headers_groups
;
182 /* A linked list of the section names for which dumps were requested
184 struct dump_list_entry
188 struct dump_list_entry
*next
;
190 static struct dump_list_entry
*dump_sects_byname
;
192 /* A dynamic array of flags indicating for which sections a hex dump
193 has been requested (via the -x switch) and/or a disassembly dump
194 (via the -i switch). */
195 char *cmdline_dump_sects
= NULL
;
196 unsigned num_cmdline_dump_sects
= 0;
198 /* A dynamic array of flags indicating for which sections a dump of
199 some kind has been requested. It is reset on a per-object file
200 basis and then initialised from the cmdline_dump_sects array,
201 the results of interpreting the -w switch, and the
202 dump_sects_byname list. */
203 char *dump_sects
= NULL
;
204 unsigned int num_dump_sects
= 0;
206 #define HEX_DUMP (1 << 0)
207 #define DISASS_DUMP (1 << 1)
208 #define DEBUG_DUMP (1 << 2)
210 /* How to print a vma value. */
211 typedef enum print_mode
223 static void (*byte_put
) (unsigned char *, bfd_vma
, int);
227 #define SECTION_NAME(X) \
228 ((X) == NULL ? "<none>" \
229 : string_table == NULL ? "<no-name>" \
230 : ((X)->sh_name >= string_table_length ? "<corrupt>" \
231 : string_table + (X)->sh_name))
233 /* Given st_shndx I, map to section_headers index. */
234 #define SECTION_HEADER_INDEX(I) \
235 ((I) < SHN_LORESERVE \
237 : ((I) <= SHN_HIRESERVE \
239 : (I) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))
241 /* Reverse of the above. */
242 #define SECTION_HEADER_NUM(N) \
243 ((N) < SHN_LORESERVE \
245 : (N) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))
247 #define SECTION_HEADER(I) (section_headers + SECTION_HEADER_INDEX (I))
249 #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
251 #define BYTE_GET(field) byte_get (field, sizeof (field))
253 #define NUM_ELEM(array) (sizeof (array) / sizeof ((array)[0]))
255 #define GET_ELF_SYMBOLS(file, section) \
256 (is_32bit_elf ? get_32bit_elf_symbols (file, section) \
257 : get_64bit_elf_symbols (file, section))
259 #define VALID_DYNAMIC_NAME(offset) ((dynamic_strings != NULL) && (offset < dynamic_strings_length))
260 /* GET_DYNAMIC_NAME asssumes that VALID_DYNAMIC_NAME has
261 already been called and verified that the string exists. */
262 #define GET_DYNAMIC_NAME(offset) (dynamic_strings + offset)
264 /* This is just a bit of syntatic sugar. */
265 #define streq(a,b) (strcmp ((a), (b)) == 0)
266 #define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
267 #define const_strneq(a,b) (strncmp ((a), (b), sizeof (b) - 1) == 0)
270 get_data (void *var
, FILE *file
, long offset
, size_t size
, size_t nmemb
,
275 if (size
== 0 || nmemb
== 0)
278 if (fseek (file
, archive_file_offset
+ offset
, SEEK_SET
))
280 error (_("Unable to seek to 0x%lx for %s\n"),
281 archive_file_offset
+ offset
, reason
);
288 /* Check for overflow. */
289 if (nmemb
< (~(size_t) 0 - 1) / size
)
290 /* + 1 so that we can '\0' terminate invalid string table sections. */
291 mvar
= malloc (size
* nmemb
+ 1);
295 error (_("Out of memory allocating 0x%lx bytes for %s\n"),
296 (unsigned long)(size
* nmemb
), reason
);
300 ((char *) mvar
)[size
* nmemb
] = '\0';
303 if (fread (mvar
, size
, nmemb
, file
) != nmemb
)
305 error (_("Unable to read in 0x%lx bytes of %s\n"),
306 (unsigned long)(size
* nmemb
), reason
);
316 byte_put_little_endian (unsigned char *field
, bfd_vma value
, int size
)
321 field
[7] = (((value
>> 24) >> 24) >> 8) & 0xff;
322 field
[6] = ((value
>> 24) >> 24) & 0xff;
323 field
[5] = ((value
>> 24) >> 16) & 0xff;
324 field
[4] = ((value
>> 24) >> 8) & 0xff;
327 field
[3] = (value
>> 24) & 0xff;
328 field
[2] = (value
>> 16) & 0xff;
331 field
[1] = (value
>> 8) & 0xff;
334 field
[0] = value
& 0xff;
338 error (_("Unhandled data length: %d\n"), size
);
343 #if defined BFD64 && !BFD_HOST_64BIT_LONG
345 print_dec_vma (bfd_vma vma
, int is_signed
)
351 if (is_signed
&& (bfd_signed_vma
) vma
< 0)
360 *bufp
++ = '0' + vma
% 10;
372 print_hex_vma (bfd_vma vma
)
380 char digit
= '0' + (vma
& 0x0f);
382 digit
+= 'a' - '0' - 10;
395 /* Print a VMA value. */
397 print_vma (bfd_vma vma
, print_mode mode
)
406 return printf ("0x%8.8lx", (unsigned long) vma
);
409 return printf ("%8.8lx", (unsigned long) vma
);
413 return printf ("%5ld", (long) vma
);
417 return printf ("0x%lx", (unsigned long) vma
);
420 return printf ("%lx", (unsigned long) vma
);
423 return printf ("%ld", (unsigned long) vma
);
426 return printf ("%lu", (unsigned long) vma
);
449 #if BFD_HOST_64BIT_LONG
450 return nc
+ printf ("%lx", vma
);
452 return nc
+ print_hex_vma (vma
);
456 #if BFD_HOST_64BIT_LONG
457 return printf ("%ld", vma
);
459 return print_dec_vma (vma
, 1);
463 #if BFD_HOST_64BIT_LONG
465 return printf ("%5ld", vma
);
467 return printf ("%#lx", vma
);
470 return printf ("%5ld", _bfd_int64_low (vma
));
472 return print_hex_vma (vma
);
476 #if BFD_HOST_64BIT_LONG
477 return printf ("%lu", vma
);
479 return print_dec_vma (vma
, 0);
487 /* Display a symbol on stdout. If do_wide is not true then
488 format the symbol to be at most WIDTH characters,
489 truncating as necessary. If WIDTH is negative then
490 format the string to be exactly - WIDTH characters,
491 truncating or padding as necessary. */
494 print_symbol (int width
, const char *symbol
)
497 printf ("%s", symbol
);
499 printf ("%-*.*s", width
, width
, symbol
);
501 printf ("%-.*s", width
, symbol
);
505 byte_put_big_endian (unsigned char *field
, bfd_vma value
, int size
)
510 field
[7] = value
& 0xff;
511 field
[6] = (value
>> 8) & 0xff;
512 field
[5] = (value
>> 16) & 0xff;
513 field
[4] = (value
>> 24) & 0xff;
518 field
[3] = value
& 0xff;
519 field
[2] = (value
>> 8) & 0xff;
523 field
[1] = value
& 0xff;
527 field
[0] = value
& 0xff;
531 error (_("Unhandled data length: %d\n"), size
);
536 /* Return a pointer to section NAME, or NULL if no such section exists. */
538 static Elf_Internal_Shdr
*
539 find_section (const char *name
)
543 for (i
= 0; i
< elf_header
.e_shnum
; i
++)
544 if (streq (SECTION_NAME (section_headers
+ i
), name
))
545 return section_headers
+ i
;
550 /* Guess the relocation size commonly used by the specific machines. */
553 guess_is_rela (unsigned long e_machine
)
557 /* Targets that use REL relocations. */
573 /* Targets that use RELA relocations. */
588 case EM_CYGNUS_MN10200
:
590 case EM_CYGNUS_MN10300
:
621 case EM_ALTERA_NIOS2
:
642 warn (_("Don't know about relocations on this machine architecture\n"));
648 slurp_rela_relocs (FILE *file
,
649 unsigned long rel_offset
,
650 unsigned long rel_size
,
651 Elf_Internal_Rela
**relasp
,
652 unsigned long *nrelasp
)
654 Elf_Internal_Rela
*relas
;
655 unsigned long nrelas
;
660 Elf32_External_Rela
*erelas
;
662 erelas
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
666 nrelas
= rel_size
/ sizeof (Elf32_External_Rela
);
668 relas
= cmalloc (nrelas
, sizeof (Elf_Internal_Rela
));
673 error (_("out of memory parsing relocs"));
677 for (i
= 0; i
< nrelas
; i
++)
679 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
680 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
681 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
688 Elf64_External_Rela
*erelas
;
690 erelas
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
694 nrelas
= rel_size
/ sizeof (Elf64_External_Rela
);
696 relas
= cmalloc (nrelas
, sizeof (Elf_Internal_Rela
));
701 error (_("out of memory parsing relocs"));
705 for (i
= 0; i
< nrelas
; i
++)
707 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
708 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
709 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
720 slurp_rel_relocs (FILE *file
,
721 unsigned long rel_offset
,
722 unsigned long rel_size
,
723 Elf_Internal_Rela
**relsp
,
724 unsigned long *nrelsp
)
726 Elf_Internal_Rela
*rels
;
732 Elf32_External_Rel
*erels
;
734 erels
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
738 nrels
= rel_size
/ sizeof (Elf32_External_Rel
);
740 rels
= cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
745 error (_("out of memory parsing relocs"));
749 for (i
= 0; i
< nrels
; i
++)
751 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
752 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
753 rels
[i
].r_addend
= 0;
760 Elf64_External_Rel
*erels
;
762 erels
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
766 nrels
= rel_size
/ sizeof (Elf64_External_Rel
);
768 rels
= cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
773 error (_("out of memory parsing relocs"));
777 for (i
= 0; i
< nrels
; i
++)
779 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
780 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
781 rels
[i
].r_addend
= 0;
791 /* Display the contents of the relocation data found at the specified
795 dump_relocations (FILE *file
,
796 unsigned long rel_offset
,
797 unsigned long rel_size
,
798 Elf_Internal_Sym
*symtab
,
801 unsigned long strtablen
,
805 Elf_Internal_Rela
*rels
;
808 if (is_rela
== UNKNOWN
)
809 is_rela
= guess_is_rela (elf_header
.e_machine
);
813 if (!slurp_rela_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
818 if (!slurp_rel_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
827 printf (_(" Offset Info Type Sym. Value Symbol's Name + Addend\n"));
829 printf (_(" Offset Info Type Sym.Value Sym. Name + Addend\n"));
834 printf (_(" Offset Info Type Sym. Value Symbol's Name\n"));
836 printf (_(" Offset Info Type Sym.Value Sym. Name\n"));
844 printf (_(" Offset Info Type Symbol's Value Symbol's Name + Addend\n"));
846 printf (_(" Offset Info Type Sym. Value Sym. Name + Addend\n"));
851 printf (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
853 printf (_(" Offset Info Type Sym. Value Sym. Name\n"));
857 for (i
= 0; i
< rel_size
; i
++)
860 const char *rtype2
= NULL
;
861 const char *rtype3
= NULL
;
864 bfd_vma symtab_index
;
869 offset
= rels
[i
].r_offset
;
870 info
= rels
[i
].r_info
;
874 type
= ELF32_R_TYPE (info
);
875 symtab_index
= ELF32_R_SYM (info
);
879 /* The #ifdef BFD64 below is to prevent a compile time warning.
880 We know that if we do not have a 64 bit data type that we
881 will never execute this code anyway. */
883 if (elf_header
.e_machine
== EM_MIPS
)
885 /* In little-endian objects, r_info isn't really a 64-bit
886 little-endian value: it has a 32-bit little-endian
887 symbol index followed by four individual byte fields.
888 Reorder INFO accordingly. */
889 if (elf_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
890 info
= (((info
& 0xffffffff) << 32)
891 | ((info
>> 56) & 0xff)
892 | ((info
>> 40) & 0xff00)
893 | ((info
>> 24) & 0xff0000)
894 | ((info
>> 8) & 0xff000000));
895 type
= ELF64_MIPS_R_TYPE (info
);
896 type2
= ELF64_MIPS_R_TYPE2 (info
);
897 type3
= ELF64_MIPS_R_TYPE3 (info
);
899 else if (elf_header
.e_machine
== EM_SPARCV9
)
900 type
= ELF64_R_TYPE_ID (info
);
902 type
= ELF64_R_TYPE (info
);
904 symtab_index
= ELF64_R_SYM (info
);
910 #ifdef _bfd_int64_low
911 printf ("%8.8lx %8.8lx ", _bfd_int64_low (offset
), _bfd_int64_low (info
));
913 printf ("%8.8lx %8.8lx ", offset
, info
);
918 #ifdef _bfd_int64_low
920 ? "%8.8lx%8.8lx %8.8lx%8.8lx "
921 : "%4.4lx%8.8lx %4.4lx%8.8lx ",
922 _bfd_int64_high (offset
),
923 _bfd_int64_low (offset
),
924 _bfd_int64_high (info
),
925 _bfd_int64_low (info
));
928 ? "%16.16lx %16.16lx "
929 : "%12.12lx %12.12lx ",
934 switch (elf_header
.e_machine
)
942 rtype
= elf_m32r_reloc_type (type
);
947 rtype
= elf_i386_reloc_type (type
);
952 rtype
= elf_m68hc11_reloc_type (type
);
956 rtype
= elf_m68k_reloc_type (type
);
960 rtype
= elf_i960_reloc_type (type
);
965 rtype
= elf_avr_reloc_type (type
);
972 rtype
= elf_sparc_reloc_type (type
);
977 rtype
= v850_reloc_type (type
);
982 rtype
= elf_d10v_reloc_type (type
);
987 rtype
= elf_d30v_reloc_type (type
);
991 rtype
= elf_dlx_reloc_type (type
);
995 rtype
= elf_sh_reloc_type (type
);
999 case EM_CYGNUS_MN10300
:
1000 rtype
= elf_mn10300_reloc_type (type
);
1004 case EM_CYGNUS_MN10200
:
1005 rtype
= elf_mn10200_reloc_type (type
);
1009 case EM_CYGNUS_FR30
:
1010 rtype
= elf_fr30_reloc_type (type
);
1014 rtype
= elf_frv_reloc_type (type
);
1018 rtype
= elf_mcore_reloc_type (type
);
1022 rtype
= elf_mmix_reloc_type (type
);
1027 rtype
= elf_msp430_reloc_type (type
);
1031 rtype
= elf_ppc_reloc_type (type
);
1035 rtype
= elf_ppc64_reloc_type (type
);
1039 case EM_MIPS_RS3_LE
:
1040 rtype
= elf_mips_reloc_type (type
);
1043 rtype2
= elf_mips_reloc_type (type2
);
1044 rtype3
= elf_mips_reloc_type (type3
);
1049 rtype
= elf_alpha_reloc_type (type
);
1053 rtype
= elf_arm_reloc_type (type
);
1057 rtype
= elf_arc_reloc_type (type
);
1061 rtype
= elf_hppa_reloc_type (type
);
1067 rtype
= elf_h8_reloc_type (type
);
1072 rtype
= elf_or32_reloc_type (type
);
1077 rtype
= elf_pj_reloc_type (type
);
1080 rtype
= elf_ia64_reloc_type (type
);
1084 rtype
= elf_cris_reloc_type (type
);
1088 rtype
= elf_i860_reloc_type (type
);
1092 rtype
= elf_x86_64_reloc_type (type
);
1096 rtype
= i370_reloc_type (type
);
1101 rtype
= elf_s390_reloc_type (type
);
1105 rtype
= elf_score_reloc_type (type
);
1109 rtype
= elf_xstormy16_reloc_type (type
);
1113 rtype
= elf_crx_reloc_type (type
);
1117 rtype
= elf_vax_reloc_type (type
);
1122 rtype
= elf_ip2k_reloc_type (type
);
1126 rtype
= elf_iq2000_reloc_type (type
);
1131 rtype
= elf_xtensa_reloc_type (type
);
1135 rtype
= elf_m32c_reloc_type (type
);
1139 rtype
= elf_mt_reloc_type (type
);
1143 rtype
= elf_bfin_reloc_type (type
);
1148 #ifdef _bfd_int64_low
1149 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type
));
1151 printf (_("unrecognized: %-7lx"), type
);
1154 printf (do_wide
? "%-22.22s" : "%-17.17s", rtype
);
1156 if (elf_header
.e_machine
== EM_ALPHA
1158 && streq (rtype
, "R_ALPHA_LITUSE")
1161 switch (rels
[i
].r_addend
)
1163 case LITUSE_ALPHA_ADDR
: rtype
= "ADDR"; break;
1164 case LITUSE_ALPHA_BASE
: rtype
= "BASE"; break;
1165 case LITUSE_ALPHA_BYTOFF
: rtype
= "BYTOFF"; break;
1166 case LITUSE_ALPHA_JSR
: rtype
= "JSR"; break;
1167 case LITUSE_ALPHA_TLSGD
: rtype
= "TLSGD"; break;
1168 case LITUSE_ALPHA_TLSLDM
: rtype
= "TLSLDM"; break;
1169 case LITUSE_ALPHA_JSRDIRECT
: rtype
= "JSRDIRECT"; break;
1170 default: rtype
= NULL
;
1173 printf (" (%s)", rtype
);
1177 printf (_("<unknown addend: %lx>"),
1178 (unsigned long) rels
[i
].r_addend
);
1181 else if (symtab_index
)
1183 if (symtab
== NULL
|| symtab_index
>= nsyms
)
1184 printf (" bad symbol index: %08lx", (unsigned long) symtab_index
);
1187 Elf_Internal_Sym
*psym
;
1189 psym
= symtab
+ symtab_index
;
1192 print_vma (psym
->st_value
, LONG_HEX
);
1193 printf (is_32bit_elf
? " " : " ");
1195 if (psym
->st_name
== 0)
1197 const char *sec_name
= "<null>";
1200 if (ELF_ST_TYPE (psym
->st_info
) == STT_SECTION
)
1202 bfd_vma sec_index
= (bfd_vma
) -1;
1204 if (psym
->st_shndx
< SHN_LORESERVE
)
1205 sec_index
= psym
->st_shndx
;
1206 else if (psym
->st_shndx
> SHN_HIRESERVE
)
1207 sec_index
= psym
->st_shndx
- (SHN_HIRESERVE
+ 1
1210 if (sec_index
!= (bfd_vma
) -1)
1211 sec_name
= SECTION_NAME (section_headers
+ sec_index
);
1212 else if (psym
->st_shndx
== SHN_ABS
)
1214 else if (psym
->st_shndx
== SHN_COMMON
)
1215 sec_name
= "COMMON";
1216 else if (elf_header
.e_machine
== EM_MIPS
1217 && psym
->st_shndx
== SHN_MIPS_SCOMMON
)
1218 sec_name
= "SCOMMON";
1219 else if (elf_header
.e_machine
== EM_MIPS
1220 && psym
->st_shndx
== SHN_MIPS_SUNDEFINED
)
1221 sec_name
= "SUNDEF";
1222 else if (elf_header
.e_machine
== EM_X86_64
1223 && psym
->st_shndx
== SHN_X86_64_LCOMMON
)
1224 sec_name
= "LARGE_COMMON";
1225 else if (elf_header
.e_machine
== EM_IA_64
1226 && elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
1227 && psym
->st_shndx
== SHN_IA_64_ANSI_COMMON
)
1228 sec_name
= "ANSI_COM";
1231 sprintf (name_buf
, "<section 0x%x>",
1232 (unsigned int) psym
->st_shndx
);
1233 sec_name
= name_buf
;
1236 print_symbol (22, sec_name
);
1238 else if (strtab
== NULL
)
1239 printf (_("<string table index: %3ld>"), psym
->st_name
);
1240 else if (psym
->st_name
>= strtablen
)
1241 printf (_("<corrupt string table index: %3ld>"), psym
->st_name
);
1243 print_symbol (22, strtab
+ psym
->st_name
);
1246 printf (" + %lx", (unsigned long) rels
[i
].r_addend
);
1251 printf ("%*c", is_32bit_elf
?
1252 (do_wide
? 34 : 28) : (do_wide
? 26 : 20), ' ');
1253 print_vma (rels
[i
].r_addend
, LONG_HEX
);
1256 if (elf_header
.e_machine
== EM_SPARCV9
1258 && streq (rtype
, "R_SPARC_OLO10"))
1259 printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (info
));
1263 if (! is_32bit_elf
&& elf_header
.e_machine
== EM_MIPS
)
1265 printf (" Type2: ");
1268 #ifdef _bfd_int64_low
1269 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type2
));
1271 printf (_("unrecognized: %-7lx"), type2
);
1274 printf ("%-17.17s", rtype2
);
1276 printf ("\n Type3: ");
1279 #ifdef _bfd_int64_low
1280 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type3
));
1282 printf (_("unrecognized: %-7lx"), type3
);
1285 printf ("%-17.17s", rtype3
);
1297 get_mips_dynamic_type (unsigned long type
)
1301 case DT_MIPS_RLD_VERSION
: return "MIPS_RLD_VERSION";
1302 case DT_MIPS_TIME_STAMP
: return "MIPS_TIME_STAMP";
1303 case DT_MIPS_ICHECKSUM
: return "MIPS_ICHECKSUM";
1304 case DT_MIPS_IVERSION
: return "MIPS_IVERSION";
1305 case DT_MIPS_FLAGS
: return "MIPS_FLAGS";
1306 case DT_MIPS_BASE_ADDRESS
: return "MIPS_BASE_ADDRESS";
1307 case DT_MIPS_MSYM
: return "MIPS_MSYM";
1308 case DT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
1309 case DT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
1310 case DT_MIPS_LOCAL_GOTNO
: return "MIPS_LOCAL_GOTNO";
1311 case DT_MIPS_CONFLICTNO
: return "MIPS_CONFLICTNO";
1312 case DT_MIPS_LIBLISTNO
: return "MIPS_LIBLISTNO";
1313 case DT_MIPS_SYMTABNO
: return "MIPS_SYMTABNO";
1314 case DT_MIPS_UNREFEXTNO
: return "MIPS_UNREFEXTNO";
1315 case DT_MIPS_GOTSYM
: return "MIPS_GOTSYM";
1316 case DT_MIPS_HIPAGENO
: return "MIPS_HIPAGENO";
1317 case DT_MIPS_RLD_MAP
: return "MIPS_RLD_MAP";
1318 case DT_MIPS_DELTA_CLASS
: return "MIPS_DELTA_CLASS";
1319 case DT_MIPS_DELTA_CLASS_NO
: return "MIPS_DELTA_CLASS_NO";
1320 case DT_MIPS_DELTA_INSTANCE
: return "MIPS_DELTA_INSTANCE";
1321 case DT_MIPS_DELTA_INSTANCE_NO
: return "MIPS_DELTA_INSTANCE_NO";
1322 case DT_MIPS_DELTA_RELOC
: return "MIPS_DELTA_RELOC";
1323 case DT_MIPS_DELTA_RELOC_NO
: return "MIPS_DELTA_RELOC_NO";
1324 case DT_MIPS_DELTA_SYM
: return "MIPS_DELTA_SYM";
1325 case DT_MIPS_DELTA_SYM_NO
: return "MIPS_DELTA_SYM_NO";
1326 case DT_MIPS_DELTA_CLASSSYM
: return "MIPS_DELTA_CLASSSYM";
1327 case DT_MIPS_DELTA_CLASSSYM_NO
: return "MIPS_DELTA_CLASSSYM_NO";
1328 case DT_MIPS_CXX_FLAGS
: return "MIPS_CXX_FLAGS";
1329 case DT_MIPS_PIXIE_INIT
: return "MIPS_PIXIE_INIT";
1330 case DT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
1331 case DT_MIPS_LOCALPAGE_GOTIDX
: return "MIPS_LOCALPAGE_GOTIDX";
1332 case DT_MIPS_LOCAL_GOTIDX
: return "MIPS_LOCAL_GOTIDX";
1333 case DT_MIPS_HIDDEN_GOTIDX
: return "MIPS_HIDDEN_GOTIDX";
1334 case DT_MIPS_PROTECTED_GOTIDX
: return "MIPS_PROTECTED_GOTIDX";
1335 case DT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
1336 case DT_MIPS_INTERFACE
: return "MIPS_INTERFACE";
1337 case DT_MIPS_DYNSTR_ALIGN
: return "MIPS_DYNSTR_ALIGN";
1338 case DT_MIPS_INTERFACE_SIZE
: return "MIPS_INTERFACE_SIZE";
1339 case DT_MIPS_RLD_TEXT_RESOLVE_ADDR
: return "MIPS_RLD_TEXT_RESOLVE_ADDR";
1340 case DT_MIPS_PERF_SUFFIX
: return "MIPS_PERF_SUFFIX";
1341 case DT_MIPS_COMPACT_SIZE
: return "MIPS_COMPACT_SIZE";
1342 case DT_MIPS_GP_VALUE
: return "MIPS_GP_VALUE";
1343 case DT_MIPS_AUX_DYNAMIC
: return "MIPS_AUX_DYNAMIC";
1350 get_sparc64_dynamic_type (unsigned long type
)
1354 case DT_SPARC_REGISTER
: return "SPARC_REGISTER";
1361 get_ppc_dynamic_type (unsigned long type
)
1365 case DT_PPC_GOT
: return "PPC_GOT";
1372 get_ppc64_dynamic_type (unsigned long type
)
1376 case DT_PPC64_GLINK
: return "PPC64_GLINK";
1377 case DT_PPC64_OPD
: return "PPC64_OPD";
1378 case DT_PPC64_OPDSZ
: return "PPC64_OPDSZ";
1385 get_parisc_dynamic_type (unsigned long type
)
1389 case DT_HP_LOAD_MAP
: return "HP_LOAD_MAP";
1390 case DT_HP_DLD_FLAGS
: return "HP_DLD_FLAGS";
1391 case DT_HP_DLD_HOOK
: return "HP_DLD_HOOK";
1392 case DT_HP_UX10_INIT
: return "HP_UX10_INIT";
1393 case DT_HP_UX10_INITSZ
: return "HP_UX10_INITSZ";
1394 case DT_HP_PREINIT
: return "HP_PREINIT";
1395 case DT_HP_PREINITSZ
: return "HP_PREINITSZ";
1396 case DT_HP_NEEDED
: return "HP_NEEDED";
1397 case DT_HP_TIME_STAMP
: return "HP_TIME_STAMP";
1398 case DT_HP_CHECKSUM
: return "HP_CHECKSUM";
1399 case DT_HP_GST_SIZE
: return "HP_GST_SIZE";
1400 case DT_HP_GST_VERSION
: return "HP_GST_VERSION";
1401 case DT_HP_GST_HASHVAL
: return "HP_GST_HASHVAL";
1402 case DT_HP_EPLTREL
: return "HP_GST_EPLTREL";
1403 case DT_HP_EPLTRELSZ
: return "HP_GST_EPLTRELSZ";
1404 case DT_HP_FILTERED
: return "HP_FILTERED";
1405 case DT_HP_FILTER_TLS
: return "HP_FILTER_TLS";
1406 case DT_HP_COMPAT_FILTERED
: return "HP_COMPAT_FILTERED";
1407 case DT_HP_LAZYLOAD
: return "HP_LAZYLOAD";
1408 case DT_HP_BIND_NOW_COUNT
: return "HP_BIND_NOW_COUNT";
1409 case DT_PLT
: return "PLT";
1410 case DT_PLT_SIZE
: return "PLT_SIZE";
1411 case DT_DLT
: return "DLT";
1412 case DT_DLT_SIZE
: return "DLT_SIZE";
1419 get_ia64_dynamic_type (unsigned long type
)
1423 case DT_IA_64_PLT_RESERVE
: return "IA_64_PLT_RESERVE";
1430 get_alpha_dynamic_type (unsigned long type
)
1434 case DT_ALPHA_PLTRO
: return "ALPHA_PLTRO";
1441 get_score_dynamic_type (unsigned long type
)
1445 case DT_SCORE_BASE_ADDRESS
: return "SCORE_BASE_ADDRESS";
1446 case DT_SCORE_LOCAL_GOTNO
: return "SCORE_LOCAL_GOTNO";
1447 case DT_SCORE_SYMTABNO
: return "SCORE_SYMTABNO";
1448 case DT_SCORE_GOTSYM
: return "SCORE_GOTSYM";
1449 case DT_SCORE_UNREFEXTNO
: return "SCORE_UNREFEXTNO";
1450 case DT_SCORE_HIPAGENO
: return "SCORE_HIPAGENO";
1458 get_dynamic_type (unsigned long type
)
1460 static char buff
[64];
1464 case DT_NULL
: return "NULL";
1465 case DT_NEEDED
: return "NEEDED";
1466 case DT_PLTRELSZ
: return "PLTRELSZ";
1467 case DT_PLTGOT
: return "PLTGOT";
1468 case DT_HASH
: return "HASH";
1469 case DT_STRTAB
: return "STRTAB";
1470 case DT_SYMTAB
: return "SYMTAB";
1471 case DT_RELA
: return "RELA";
1472 case DT_RELASZ
: return "RELASZ";
1473 case DT_RELAENT
: return "RELAENT";
1474 case DT_STRSZ
: return "STRSZ";
1475 case DT_SYMENT
: return "SYMENT";
1476 case DT_INIT
: return "INIT";
1477 case DT_FINI
: return "FINI";
1478 case DT_SONAME
: return "SONAME";
1479 case DT_RPATH
: return "RPATH";
1480 case DT_SYMBOLIC
: return "SYMBOLIC";
1481 case DT_REL
: return "REL";
1482 case DT_RELSZ
: return "RELSZ";
1483 case DT_RELENT
: return "RELENT";
1484 case DT_PLTREL
: return "PLTREL";
1485 case DT_DEBUG
: return "DEBUG";
1486 case DT_TEXTREL
: return "TEXTREL";
1487 case DT_JMPREL
: return "JMPREL";
1488 case DT_BIND_NOW
: return "BIND_NOW";
1489 case DT_INIT_ARRAY
: return "INIT_ARRAY";
1490 case DT_FINI_ARRAY
: return "FINI_ARRAY";
1491 case DT_INIT_ARRAYSZ
: return "INIT_ARRAYSZ";
1492 case DT_FINI_ARRAYSZ
: return "FINI_ARRAYSZ";
1493 case DT_RUNPATH
: return "RUNPATH";
1494 case DT_FLAGS
: return "FLAGS";
1496 case DT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
1497 case DT_PREINIT_ARRAYSZ
: return "PREINIT_ARRAYSZ";
1499 case DT_CHECKSUM
: return "CHECKSUM";
1500 case DT_PLTPADSZ
: return "PLTPADSZ";
1501 case DT_MOVEENT
: return "MOVEENT";
1502 case DT_MOVESZ
: return "MOVESZ";
1503 case DT_FEATURE
: return "FEATURE";
1504 case DT_POSFLAG_1
: return "POSFLAG_1";
1505 case DT_SYMINSZ
: return "SYMINSZ";
1506 case DT_SYMINENT
: return "SYMINENT"; /* aka VALRNGHI */
1508 case DT_ADDRRNGLO
: return "ADDRRNGLO";
1509 case DT_CONFIG
: return "CONFIG";
1510 case DT_DEPAUDIT
: return "DEPAUDIT";
1511 case DT_AUDIT
: return "AUDIT";
1512 case DT_PLTPAD
: return "PLTPAD";
1513 case DT_MOVETAB
: return "MOVETAB";
1514 case DT_SYMINFO
: return "SYMINFO"; /* aka ADDRRNGHI */
1516 case DT_VERSYM
: return "VERSYM";
1518 case DT_TLSDESC_GOT
: return "TLSDESC_GOT";
1519 case DT_TLSDESC_PLT
: return "TLSDESC_PLT";
1520 case DT_RELACOUNT
: return "RELACOUNT";
1521 case DT_RELCOUNT
: return "RELCOUNT";
1522 case DT_FLAGS_1
: return "FLAGS_1";
1523 case DT_VERDEF
: return "VERDEF";
1524 case DT_VERDEFNUM
: return "VERDEFNUM";
1525 case DT_VERNEED
: return "VERNEED";
1526 case DT_VERNEEDNUM
: return "VERNEEDNUM";
1528 case DT_AUXILIARY
: return "AUXILIARY";
1529 case DT_USED
: return "USED";
1530 case DT_FILTER
: return "FILTER";
1532 case DT_GNU_PRELINKED
: return "GNU_PRELINKED";
1533 case DT_GNU_CONFLICT
: return "GNU_CONFLICT";
1534 case DT_GNU_CONFLICTSZ
: return "GNU_CONFLICTSZ";
1535 case DT_GNU_LIBLIST
: return "GNU_LIBLIST";
1536 case DT_GNU_LIBLISTSZ
: return "GNU_LIBLISTSZ";
1537 case DT_GNU_HASH
: return "GNU_HASH";
1540 if ((type
>= DT_LOPROC
) && (type
<= DT_HIPROC
))
1544 switch (elf_header
.e_machine
)
1547 case EM_MIPS_RS3_LE
:
1548 result
= get_mips_dynamic_type (type
);
1551 result
= get_sparc64_dynamic_type (type
);
1554 result
= get_ppc_dynamic_type (type
);
1557 result
= get_ppc64_dynamic_type (type
);
1560 result
= get_ia64_dynamic_type (type
);
1563 result
= get_alpha_dynamic_type (type
);
1566 result
= get_score_dynamic_type (type
);
1576 snprintf (buff
, sizeof (buff
), _("Processor Specific: %lx"), type
);
1578 else if (((type
>= DT_LOOS
) && (type
<= DT_HIOS
))
1579 || (elf_header
.e_machine
== EM_PARISC
1580 && (type
>= OLD_DT_LOOS
) && (type
<= OLD_DT_HIOS
)))
1584 switch (elf_header
.e_machine
)
1587 result
= get_parisc_dynamic_type (type
);
1597 snprintf (buff
, sizeof (buff
), _("Operating System specific: %lx"),
1601 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), type
);
1608 get_file_type (unsigned e_type
)
1610 static char buff
[32];
1614 case ET_NONE
: return _("NONE (None)");
1615 case ET_REL
: return _("REL (Relocatable file)");
1616 case ET_EXEC
: return _("EXEC (Executable file)");
1617 case ET_DYN
: return _("DYN (Shared object file)");
1618 case ET_CORE
: return _("CORE (Core file)");
1621 if ((e_type
>= ET_LOPROC
) && (e_type
<= ET_HIPROC
))
1622 snprintf (buff
, sizeof (buff
), _("Processor Specific: (%x)"), e_type
);
1623 else if ((e_type
>= ET_LOOS
) && (e_type
<= ET_HIOS
))
1624 snprintf (buff
, sizeof (buff
), _("OS Specific: (%x)"), e_type
);
1626 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), e_type
);
1632 get_machine_name (unsigned e_machine
)
1634 static char buff
[64]; /* XXX */
1638 case EM_NONE
: return _("None");
1639 case EM_M32
: return "WE32100";
1640 case EM_SPARC
: return "Sparc";
1641 case EM_386
: return "Intel 80386";
1642 case EM_68K
: return "MC68000";
1643 case EM_88K
: return "MC88000";
1644 case EM_486
: return "Intel 80486";
1645 case EM_860
: return "Intel 80860";
1646 case EM_MIPS
: return "MIPS R3000";
1647 case EM_S370
: return "IBM System/370";
1648 case EM_MIPS_RS3_LE
: return "MIPS R4000 big-endian";
1649 case EM_OLD_SPARCV9
: return "Sparc v9 (old)";
1650 case EM_PARISC
: return "HPPA";
1651 case EM_PPC_OLD
: return "Power PC (old)";
1652 case EM_SPARC32PLUS
: return "Sparc v8+" ;
1653 case EM_960
: return "Intel 90860";
1654 case EM_PPC
: return "PowerPC";
1655 case EM_PPC64
: return "PowerPC64";
1656 case EM_V800
: return "NEC V800";
1657 case EM_FR20
: return "Fujitsu FR20";
1658 case EM_RH32
: return "TRW RH32";
1659 case EM_MCORE
: return "MCORE";
1660 case EM_ARM
: return "ARM";
1661 case EM_OLD_ALPHA
: return "Digital Alpha (old)";
1662 case EM_SH
: return "Renesas / SuperH SH";
1663 case EM_SPARCV9
: return "Sparc v9";
1664 case EM_TRICORE
: return "Siemens Tricore";
1665 case EM_ARC
: return "ARC";
1666 case EM_H8_300
: return "Renesas H8/300";
1667 case EM_H8_300H
: return "Renesas H8/300H";
1668 case EM_H8S
: return "Renesas H8S";
1669 case EM_H8_500
: return "Renesas H8/500";
1670 case EM_IA_64
: return "Intel IA-64";
1671 case EM_MIPS_X
: return "Stanford MIPS-X";
1672 case EM_COLDFIRE
: return "Motorola Coldfire";
1673 case EM_68HC12
: return "Motorola M68HC12";
1674 case EM_ALPHA
: return "Alpha";
1675 case EM_CYGNUS_D10V
:
1676 case EM_D10V
: return "d10v";
1677 case EM_CYGNUS_D30V
:
1678 case EM_D30V
: return "d30v";
1679 case EM_CYGNUS_M32R
:
1680 case EM_M32R
: return "Renesas M32R (formerly Mitsubishi M32r)";
1681 case EM_CYGNUS_V850
:
1682 case EM_V850
: return "NEC v850";
1683 case EM_CYGNUS_MN10300
:
1684 case EM_MN10300
: return "mn10300";
1685 case EM_CYGNUS_MN10200
:
1686 case EM_MN10200
: return "mn10200";
1687 case EM_CYGNUS_FR30
:
1688 case EM_FR30
: return "Fujitsu FR30";
1689 case EM_CYGNUS_FRV
: return "Fujitsu FR-V";
1691 case EM_PJ
: return "picoJava";
1692 case EM_MMA
: return "Fujitsu Multimedia Accelerator";
1693 case EM_PCP
: return "Siemens PCP";
1694 case EM_NCPU
: return "Sony nCPU embedded RISC processor";
1695 case EM_NDR1
: return "Denso NDR1 microprocesspr";
1696 case EM_STARCORE
: return "Motorola Star*Core processor";
1697 case EM_ME16
: return "Toyota ME16 processor";
1698 case EM_ST100
: return "STMicroelectronics ST100 processor";
1699 case EM_TINYJ
: return "Advanced Logic Corp. TinyJ embedded processor";
1700 case EM_FX66
: return "Siemens FX66 microcontroller";
1701 case EM_ST9PLUS
: return "STMicroelectronics ST9+ 8/16 bit microcontroller";
1702 case EM_ST7
: return "STMicroelectronics ST7 8-bit microcontroller";
1703 case EM_68HC16
: return "Motorola MC68HC16 Microcontroller";
1704 case EM_68HC11
: return "Motorola MC68HC11 Microcontroller";
1705 case EM_68HC08
: return "Motorola MC68HC08 Microcontroller";
1706 case EM_68HC05
: return "Motorola MC68HC05 Microcontroller";
1707 case EM_SVX
: return "Silicon Graphics SVx";
1708 case EM_ST19
: return "STMicroelectronics ST19 8-bit microcontroller";
1709 case EM_VAX
: return "Digital VAX";
1711 case EM_AVR
: return "Atmel AVR 8-bit microcontroller";
1712 case EM_CRIS
: return "Axis Communications 32-bit embedded processor";
1713 case EM_JAVELIN
: return "Infineon Technologies 32-bit embedded cpu";
1714 case EM_FIREPATH
: return "Element 14 64-bit DSP processor";
1715 case EM_ZSP
: return "LSI Logic's 16-bit DSP processor";
1716 case EM_MMIX
: return "Donald Knuth's educational 64-bit processor";
1717 case EM_HUANY
: return "Harvard Universitys's machine-independent object format";
1718 case EM_PRISM
: return "Vitesse Prism";
1719 case EM_X86_64
: return "Advanced Micro Devices X86-64";
1721 case EM_S390
: return "IBM S/390";
1722 case EM_SCORE
: return "SUNPLUS S+Core";
1723 case EM_XSTORMY16
: return "Sanyo Xstormy16 CPU core";
1725 case EM_OR32
: return "OpenRISC";
1726 case EM_CRX
: return "National Semiconductor CRX microprocessor";
1727 case EM_DLX
: return "OpenDLX";
1729 case EM_IP2K
: return "Ubicom IP2xxx 8-bit microcontrollers";
1730 case EM_IQ2000
: return "Vitesse IQ2000";
1732 case EM_XTENSA
: return "Tensilica Xtensa Processor";
1733 case EM_M32C
: return "Renesas M32c";
1734 case EM_MT
: return "Morpho Techologies MT processor";
1735 case EM_BLACKFIN
: return "Analog Devices Blackfin";
1736 case EM_NIOS32
: return "Altera Nios";
1737 case EM_ALTERA_NIOS2
: return "Altera Nios II";
1738 case EM_XC16X
: return "Infineon Technologies xc16x";
1740 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), e_machine
);
1746 decode_ARM_machine_flags (unsigned e_flags
, char buf
[])
1751 eabi
= EF_ARM_EABI_VERSION (e_flags
);
1752 e_flags
&= ~ EF_ARM_EABIMASK
;
1754 /* Handle "generic" ARM flags. */
1755 if (e_flags
& EF_ARM_RELEXEC
)
1757 strcat (buf
, ", relocatable executable");
1758 e_flags
&= ~ EF_ARM_RELEXEC
;
1761 if (e_flags
& EF_ARM_HASENTRY
)
1763 strcat (buf
, ", has entry point");
1764 e_flags
&= ~ EF_ARM_HASENTRY
;
1767 /* Now handle EABI specific flags. */
1771 strcat (buf
, ", <unrecognized EABI>");
1776 case EF_ARM_EABI_VER1
:
1777 strcat (buf
, ", Version1 EABI");
1782 /* Process flags one bit at a time. */
1783 flag
= e_flags
& - e_flags
;
1788 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1789 strcat (buf
, ", sorted symbol tables");
1799 case EF_ARM_EABI_VER2
:
1800 strcat (buf
, ", Version2 EABI");
1805 /* Process flags one bit at a time. */
1806 flag
= e_flags
& - e_flags
;
1811 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1812 strcat (buf
, ", sorted symbol tables");
1815 case EF_ARM_DYNSYMSUSESEGIDX
:
1816 strcat (buf
, ", dynamic symbols use segment index");
1819 case EF_ARM_MAPSYMSFIRST
:
1820 strcat (buf
, ", mapping symbols precede others");
1830 case EF_ARM_EABI_VER3
:
1831 strcat (buf
, ", Version3 EABI");
1834 case EF_ARM_EABI_VER4
:
1835 strcat (buf
, ", Version4 EABI");
1838 case EF_ARM_EABI_VER5
:
1839 strcat (buf
, ", Version5 EABI");
1845 /* Process flags one bit at a time. */
1846 flag
= e_flags
& - e_flags
;
1852 strcat (buf
, ", BE8");
1856 strcat (buf
, ", LE8");
1866 case EF_ARM_EABI_UNKNOWN
:
1867 strcat (buf
, ", GNU EABI");
1872 /* Process flags one bit at a time. */
1873 flag
= e_flags
& - e_flags
;
1878 case EF_ARM_INTERWORK
:
1879 strcat (buf
, ", interworking enabled");
1882 case EF_ARM_APCS_26
:
1883 strcat (buf
, ", uses APCS/26");
1886 case EF_ARM_APCS_FLOAT
:
1887 strcat (buf
, ", uses APCS/float");
1891 strcat (buf
, ", position independent");
1895 strcat (buf
, ", 8 bit structure alignment");
1898 case EF_ARM_NEW_ABI
:
1899 strcat (buf
, ", uses new ABI");
1902 case EF_ARM_OLD_ABI
:
1903 strcat (buf
, ", uses old ABI");
1906 case EF_ARM_SOFT_FLOAT
:
1907 strcat (buf
, ", software FP");
1910 case EF_ARM_VFP_FLOAT
:
1911 strcat (buf
, ", VFP");
1914 case EF_ARM_MAVERICK_FLOAT
:
1915 strcat (buf
, ", Maverick FP");
1926 strcat (buf
,", <unknown>");
1930 get_machine_flags (unsigned e_flags
, unsigned e_machine
)
1932 static char buf
[1024];
1944 decode_ARM_machine_flags (e_flags
, buf
);
1948 switch (e_flags
& EF_FRV_CPU_MASK
)
1950 case EF_FRV_CPU_GENERIC
:
1954 strcat (buf
, ", fr???");
1957 case EF_FRV_CPU_FR300
:
1958 strcat (buf
, ", fr300");
1961 case EF_FRV_CPU_FR400
:
1962 strcat (buf
, ", fr400");
1964 case EF_FRV_CPU_FR405
:
1965 strcat (buf
, ", fr405");
1968 case EF_FRV_CPU_FR450
:
1969 strcat (buf
, ", fr450");
1972 case EF_FRV_CPU_FR500
:
1973 strcat (buf
, ", fr500");
1975 case EF_FRV_CPU_FR550
:
1976 strcat (buf
, ", fr550");
1979 case EF_FRV_CPU_SIMPLE
:
1980 strcat (buf
, ", simple");
1982 case EF_FRV_CPU_TOMCAT
:
1983 strcat (buf
, ", tomcat");
1989 if (e_flags
& EF_M68K_CPU32
)
1990 strcat (buf
, ", cpu32");
1991 if (e_flags
& EF_M68K_M68000
)
1992 strcat (buf
, ", m68000");
1993 if (e_flags
& EF_M68K_ISA_MASK
)
1995 char const *isa
= _("unknown");
1996 char const *mac
= _("unknown mac");
1997 char const *additional
= NULL
;
1999 switch (e_flags
& EF_M68K_ISA_MASK
)
2001 case EF_M68K_ISA_A_NODIV
:
2003 additional
= ", nodiv";
2008 case EF_M68K_ISA_A_PLUS
:
2011 case EF_M68K_ISA_B_NOUSP
:
2013 additional
= ", nousp";
2019 strcat (buf
, ", cf, isa ");
2022 strcat (buf
, additional
);
2023 if (e_flags
& EF_M68K_FLOAT
)
2024 strcat (buf
, ", float");
2025 switch (e_flags
& EF_M68K_MAC_MASK
)
2046 if (e_flags
& EF_PPC_EMB
)
2047 strcat (buf
, ", emb");
2049 if (e_flags
& EF_PPC_RELOCATABLE
)
2050 strcat (buf
, ", relocatable");
2052 if (e_flags
& EF_PPC_RELOCATABLE_LIB
)
2053 strcat (buf
, ", relocatable-lib");
2057 case EM_CYGNUS_V850
:
2058 switch (e_flags
& EF_V850_ARCH
)
2061 strcat (buf
, ", v850e1");
2064 strcat (buf
, ", v850e");
2067 strcat (buf
, ", v850");
2070 strcat (buf
, ", unknown v850 architecture variant");
2076 case EM_CYGNUS_M32R
:
2077 if ((e_flags
& EF_M32R_ARCH
) == E_M32R_ARCH
)
2078 strcat (buf
, ", m32r");
2082 case EM_MIPS_RS3_LE
:
2083 if (e_flags
& EF_MIPS_NOREORDER
)
2084 strcat (buf
, ", noreorder");
2086 if (e_flags
& EF_MIPS_PIC
)
2087 strcat (buf
, ", pic");
2089 if (e_flags
& EF_MIPS_CPIC
)
2090 strcat (buf
, ", cpic");
2092 if (e_flags
& EF_MIPS_UCODE
)
2093 strcat (buf
, ", ugen_reserved");
2095 if (e_flags
& EF_MIPS_ABI2
)
2096 strcat (buf
, ", abi2");
2098 if (e_flags
& EF_MIPS_OPTIONS_FIRST
)
2099 strcat (buf
, ", odk first");
2101 if (e_flags
& EF_MIPS_32BITMODE
)
2102 strcat (buf
, ", 32bitmode");
2104 switch ((e_flags
& EF_MIPS_MACH
))
2106 case E_MIPS_MACH_3900
: strcat (buf
, ", 3900"); break;
2107 case E_MIPS_MACH_4010
: strcat (buf
, ", 4010"); break;
2108 case E_MIPS_MACH_4100
: strcat (buf
, ", 4100"); break;
2109 case E_MIPS_MACH_4111
: strcat (buf
, ", 4111"); break;
2110 case E_MIPS_MACH_4120
: strcat (buf
, ", 4120"); break;
2111 case E_MIPS_MACH_4650
: strcat (buf
, ", 4650"); break;
2112 case E_MIPS_MACH_5400
: strcat (buf
, ", 5400"); break;
2113 case E_MIPS_MACH_5500
: strcat (buf
, ", 5500"); break;
2114 case E_MIPS_MACH_SB1
: strcat (buf
, ", sb1"); break;
2115 case E_MIPS_MACH_9000
: strcat (buf
, ", 9000"); break;
2117 /* We simply ignore the field in this case to avoid confusion:
2118 MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
2121 default: strcat (buf
, ", unknown CPU"); break;
2124 switch ((e_flags
& EF_MIPS_ABI
))
2126 case E_MIPS_ABI_O32
: strcat (buf
, ", o32"); break;
2127 case E_MIPS_ABI_O64
: strcat (buf
, ", o64"); break;
2128 case E_MIPS_ABI_EABI32
: strcat (buf
, ", eabi32"); break;
2129 case E_MIPS_ABI_EABI64
: strcat (buf
, ", eabi64"); break;
2131 /* We simply ignore the field in this case to avoid confusion:
2132 MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension.
2133 This means it is likely to be an o32 file, but not for
2136 default: strcat (buf
, ", unknown ABI"); break;
2139 if (e_flags
& EF_MIPS_ARCH_ASE_MDMX
)
2140 strcat (buf
, ", mdmx");
2142 if (e_flags
& EF_MIPS_ARCH_ASE_M16
)
2143 strcat (buf
, ", mips16");
2145 switch ((e_flags
& EF_MIPS_ARCH
))
2147 case E_MIPS_ARCH_1
: strcat (buf
, ", mips1"); break;
2148 case E_MIPS_ARCH_2
: strcat (buf
, ", mips2"); break;
2149 case E_MIPS_ARCH_3
: strcat (buf
, ", mips3"); break;
2150 case E_MIPS_ARCH_4
: strcat (buf
, ", mips4"); break;
2151 case E_MIPS_ARCH_5
: strcat (buf
, ", mips5"); break;
2152 case E_MIPS_ARCH_32
: strcat (buf
, ", mips32"); break;
2153 case E_MIPS_ARCH_32R2
: strcat (buf
, ", mips32r2"); break;
2154 case E_MIPS_ARCH_64
: strcat (buf
, ", mips64"); break;
2155 case E_MIPS_ARCH_64R2
: strcat (buf
, ", mips64r2"); break;
2156 default: strcat (buf
, ", unknown ISA"); break;
2162 switch ((e_flags
& EF_SH_MACH_MASK
))
2164 case EF_SH1
: strcat (buf
, ", sh1"); break;
2165 case EF_SH2
: strcat (buf
, ", sh2"); break;
2166 case EF_SH3
: strcat (buf
, ", sh3"); break;
2167 case EF_SH_DSP
: strcat (buf
, ", sh-dsp"); break;
2168 case EF_SH3_DSP
: strcat (buf
, ", sh3-dsp"); break;
2169 case EF_SH4AL_DSP
: strcat (buf
, ", sh4al-dsp"); break;
2170 case EF_SH3E
: strcat (buf
, ", sh3e"); break;
2171 case EF_SH4
: strcat (buf
, ", sh4"); break;
2172 case EF_SH5
: strcat (buf
, ", sh5"); break;
2173 case EF_SH2E
: strcat (buf
, ", sh2e"); break;
2174 case EF_SH4A
: strcat (buf
, ", sh4a"); break;
2175 case EF_SH2A
: strcat (buf
, ", sh2a"); break;
2176 case EF_SH4_NOFPU
: strcat (buf
, ", sh4-nofpu"); break;
2177 case EF_SH4A_NOFPU
: strcat (buf
, ", sh4a-nofpu"); break;
2178 case EF_SH2A_NOFPU
: strcat (buf
, ", sh2a-nofpu"); break;
2179 case EF_SH3_NOMMU
: strcat (buf
, ", sh3-nommu"); break;
2180 case EF_SH4_NOMMU_NOFPU
: strcat (buf
, ", sh4-nommu-nofpu"); break;
2181 case EF_SH2A_SH4_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh4-nommu-nofpu"); break;
2182 case EF_SH2A_SH3_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh3-nommu"); break;
2183 case EF_SH2A_SH4
: strcat (buf
, ", sh2a-or-sh4"); break;
2184 case EF_SH2A_SH3E
: strcat (buf
, ", sh2a-or-sh3e"); break;
2185 default: strcat (buf
, ", unknown ISA"); break;
2191 if (e_flags
& EF_SPARC_32PLUS
)
2192 strcat (buf
, ", v8+");
2194 if (e_flags
& EF_SPARC_SUN_US1
)
2195 strcat (buf
, ", ultrasparcI");
2197 if (e_flags
& EF_SPARC_SUN_US3
)
2198 strcat (buf
, ", ultrasparcIII");
2200 if (e_flags
& EF_SPARC_HAL_R1
)
2201 strcat (buf
, ", halr1");
2203 if (e_flags
& EF_SPARC_LEDATA
)
2204 strcat (buf
, ", ledata");
2206 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_TSO
)
2207 strcat (buf
, ", tso");
2209 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_PSO
)
2210 strcat (buf
, ", pso");
2212 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_RMO
)
2213 strcat (buf
, ", rmo");
2217 switch (e_flags
& EF_PARISC_ARCH
)
2219 case EFA_PARISC_1_0
:
2220 strcpy (buf
, ", PA-RISC 1.0");
2222 case EFA_PARISC_1_1
:
2223 strcpy (buf
, ", PA-RISC 1.1");
2225 case EFA_PARISC_2_0
:
2226 strcpy (buf
, ", PA-RISC 2.0");
2231 if (e_flags
& EF_PARISC_TRAPNIL
)
2232 strcat (buf
, ", trapnil");
2233 if (e_flags
& EF_PARISC_EXT
)
2234 strcat (buf
, ", ext");
2235 if (e_flags
& EF_PARISC_LSB
)
2236 strcat (buf
, ", lsb");
2237 if (e_flags
& EF_PARISC_WIDE
)
2238 strcat (buf
, ", wide");
2239 if (e_flags
& EF_PARISC_NO_KABP
)
2240 strcat (buf
, ", no kabp");
2241 if (e_flags
& EF_PARISC_LAZYSWAP
)
2242 strcat (buf
, ", lazyswap");
2247 if ((e_flags
& EF_PICOJAVA_NEWCALLS
) == EF_PICOJAVA_NEWCALLS
)
2248 strcat (buf
, ", new calling convention");
2250 if ((e_flags
& EF_PICOJAVA_GNUCALLS
) == EF_PICOJAVA_GNUCALLS
)
2251 strcat (buf
, ", gnu calling convention");
2255 if ((e_flags
& EF_IA_64_ABI64
))
2256 strcat (buf
, ", 64-bit");
2258 strcat (buf
, ", 32-bit");
2259 if ((e_flags
& EF_IA_64_REDUCEDFP
))
2260 strcat (buf
, ", reduced fp model");
2261 if ((e_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
))
2262 strcat (buf
, ", no function descriptors, constant gp");
2263 else if ((e_flags
& EF_IA_64_CONS_GP
))
2264 strcat (buf
, ", constant gp");
2265 if ((e_flags
& EF_IA_64_ABSOLUTE
))
2266 strcat (buf
, ", absolute");
2270 if ((e_flags
& EF_VAX_NONPIC
))
2271 strcat (buf
, ", non-PIC");
2272 if ((e_flags
& EF_VAX_DFLOAT
))
2273 strcat (buf
, ", D-Float");
2274 if ((e_flags
& EF_VAX_GFLOAT
))
2275 strcat (buf
, ", G-Float");
2284 get_osabi_name (unsigned int osabi
)
2286 static char buff
[32];
2290 case ELFOSABI_NONE
: return "UNIX - System V";
2291 case ELFOSABI_HPUX
: return "UNIX - HP-UX";
2292 case ELFOSABI_NETBSD
: return "UNIX - NetBSD";
2293 case ELFOSABI_LINUX
: return "UNIX - Linux";
2294 case ELFOSABI_HURD
: return "GNU/Hurd";
2295 case ELFOSABI_SOLARIS
: return "UNIX - Solaris";
2296 case ELFOSABI_AIX
: return "UNIX - AIX";
2297 case ELFOSABI_IRIX
: return "UNIX - IRIX";
2298 case ELFOSABI_FREEBSD
: return "UNIX - FreeBSD";
2299 case ELFOSABI_TRU64
: return "UNIX - TRU64";
2300 case ELFOSABI_MODESTO
: return "Novell - Modesto";
2301 case ELFOSABI_OPENBSD
: return "UNIX - OpenBSD";
2302 case ELFOSABI_OPENVMS
: return "VMS - OpenVMS";
2303 case ELFOSABI_NSK
: return "HP - Non-Stop Kernel";
2304 case ELFOSABI_AROS
: return "Amiga Research OS";
2305 case ELFOSABI_STANDALONE
: return _("Standalone App");
2306 case ELFOSABI_ARM
: return "ARM";
2308 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), osabi
);
2314 get_arm_segment_type (unsigned long type
)
2328 get_mips_segment_type (unsigned long type
)
2332 case PT_MIPS_REGINFO
:
2334 case PT_MIPS_RTPROC
:
2336 case PT_MIPS_OPTIONS
:
2346 get_parisc_segment_type (unsigned long type
)
2350 case PT_HP_TLS
: return "HP_TLS";
2351 case PT_HP_CORE_NONE
: return "HP_CORE_NONE";
2352 case PT_HP_CORE_VERSION
: return "HP_CORE_VERSION";
2353 case PT_HP_CORE_KERNEL
: return "HP_CORE_KERNEL";
2354 case PT_HP_CORE_COMM
: return "HP_CORE_COMM";
2355 case PT_HP_CORE_PROC
: return "HP_CORE_PROC";
2356 case PT_HP_CORE_LOADABLE
: return "HP_CORE_LOADABLE";
2357 case PT_HP_CORE_STACK
: return "HP_CORE_STACK";
2358 case PT_HP_CORE_SHM
: return "HP_CORE_SHM";
2359 case PT_HP_CORE_MMF
: return "HP_CORE_MMF";
2360 case PT_HP_PARALLEL
: return "HP_PARALLEL";
2361 case PT_HP_FASTBIND
: return "HP_FASTBIND";
2362 case PT_HP_OPT_ANNOT
: return "HP_OPT_ANNOT";
2363 case PT_HP_HSL_ANNOT
: return "HP_HSL_ANNOT";
2364 case PT_HP_STACK
: return "HP_STACK";
2365 case PT_HP_CORE_UTSNAME
: return "HP_CORE_UTSNAME";
2366 case PT_PARISC_ARCHEXT
: return "PARISC_ARCHEXT";
2367 case PT_PARISC_UNWIND
: return "PARISC_UNWIND";
2368 case PT_PARISC_WEAKORDER
: return "PARISC_WEAKORDER";
2377 get_ia64_segment_type (unsigned long type
)
2381 case PT_IA_64_ARCHEXT
: return "IA_64_ARCHEXT";
2382 case PT_IA_64_UNWIND
: return "IA_64_UNWIND";
2383 case PT_HP_TLS
: return "HP_TLS";
2384 case PT_IA_64_HP_OPT_ANOT
: return "HP_OPT_ANNOT";
2385 case PT_IA_64_HP_HSL_ANOT
: return "HP_HSL_ANNOT";
2386 case PT_IA_64_HP_STACK
: return "HP_STACK";
2395 get_segment_type (unsigned long p_type
)
2397 static char buff
[32];
2401 case PT_NULL
: return "NULL";
2402 case PT_LOAD
: return "LOAD";
2403 case PT_DYNAMIC
: return "DYNAMIC";
2404 case PT_INTERP
: return "INTERP";
2405 case PT_NOTE
: return "NOTE";
2406 case PT_SHLIB
: return "SHLIB";
2407 case PT_PHDR
: return "PHDR";
2408 case PT_TLS
: return "TLS";
2410 case PT_GNU_EH_FRAME
:
2411 return "GNU_EH_FRAME";
2412 case PT_GNU_STACK
: return "GNU_STACK";
2413 case PT_GNU_RELRO
: return "GNU_RELRO";
2416 if ((p_type
>= PT_LOPROC
) && (p_type
<= PT_HIPROC
))
2420 switch (elf_header
.e_machine
)
2423 result
= get_arm_segment_type (p_type
);
2426 case EM_MIPS_RS3_LE
:
2427 result
= get_mips_segment_type (p_type
);
2430 result
= get_parisc_segment_type (p_type
);
2433 result
= get_ia64_segment_type (p_type
);
2443 sprintf (buff
, "LOPROC+%lx", p_type
- PT_LOPROC
);
2445 else if ((p_type
>= PT_LOOS
) && (p_type
<= PT_HIOS
))
2449 switch (elf_header
.e_machine
)
2452 result
= get_parisc_segment_type (p_type
);
2455 result
= get_ia64_segment_type (p_type
);
2465 sprintf (buff
, "LOOS+%lx", p_type
- PT_LOOS
);
2468 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), p_type
);
2475 get_mips_section_type_name (unsigned int sh_type
)
2479 case SHT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
2480 case SHT_MIPS_MSYM
: return "MIPS_MSYM";
2481 case SHT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
2482 case SHT_MIPS_GPTAB
: return "MIPS_GPTAB";
2483 case SHT_MIPS_UCODE
: return "MIPS_UCODE";
2484 case SHT_MIPS_DEBUG
: return "MIPS_DEBUG";
2485 case SHT_MIPS_REGINFO
: return "MIPS_REGINFO";
2486 case SHT_MIPS_PACKAGE
: return "MIPS_PACKAGE";
2487 case SHT_MIPS_PACKSYM
: return "MIPS_PACKSYM";
2488 case SHT_MIPS_RELD
: return "MIPS_RELD";
2489 case SHT_MIPS_IFACE
: return "MIPS_IFACE";
2490 case SHT_MIPS_CONTENT
: return "MIPS_CONTENT";
2491 case SHT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
2492 case SHT_MIPS_SHDR
: return "MIPS_SHDR";
2493 case SHT_MIPS_FDESC
: return "MIPS_FDESC";
2494 case SHT_MIPS_EXTSYM
: return "MIPS_EXTSYM";
2495 case SHT_MIPS_DENSE
: return "MIPS_DENSE";
2496 case SHT_MIPS_PDESC
: return "MIPS_PDESC";
2497 case SHT_MIPS_LOCSYM
: return "MIPS_LOCSYM";
2498 case SHT_MIPS_AUXSYM
: return "MIPS_AUXSYM";
2499 case SHT_MIPS_OPTSYM
: return "MIPS_OPTSYM";
2500 case SHT_MIPS_LOCSTR
: return "MIPS_LOCSTR";
2501 case SHT_MIPS_LINE
: return "MIPS_LINE";
2502 case SHT_MIPS_RFDESC
: return "MIPS_RFDESC";
2503 case SHT_MIPS_DELTASYM
: return "MIPS_DELTASYM";
2504 case SHT_MIPS_DELTAINST
: return "MIPS_DELTAINST";
2505 case SHT_MIPS_DELTACLASS
: return "MIPS_DELTACLASS";
2506 case SHT_MIPS_DWARF
: return "MIPS_DWARF";
2507 case SHT_MIPS_DELTADECL
: return "MIPS_DELTADECL";
2508 case SHT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
2509 case SHT_MIPS_EVENTS
: return "MIPS_EVENTS";
2510 case SHT_MIPS_TRANSLATE
: return "MIPS_TRANSLATE";
2511 case SHT_MIPS_PIXIE
: return "MIPS_PIXIE";
2512 case SHT_MIPS_XLATE
: return "MIPS_XLATE";
2513 case SHT_MIPS_XLATE_DEBUG
: return "MIPS_XLATE_DEBUG";
2514 case SHT_MIPS_WHIRL
: return "MIPS_WHIRL";
2515 case SHT_MIPS_EH_REGION
: return "MIPS_EH_REGION";
2516 case SHT_MIPS_XLATE_OLD
: return "MIPS_XLATE_OLD";
2517 case SHT_MIPS_PDR_EXCEPTION
: return "MIPS_PDR_EXCEPTION";
2525 get_parisc_section_type_name (unsigned int sh_type
)
2529 case SHT_PARISC_EXT
: return "PARISC_EXT";
2530 case SHT_PARISC_UNWIND
: return "PARISC_UNWIND";
2531 case SHT_PARISC_DOC
: return "PARISC_DOC";
2532 case SHT_PARISC_ANNOT
: return "PARISC_ANNOT";
2533 case SHT_PARISC_SYMEXTN
: return "PARISC_SYMEXTN";
2534 case SHT_PARISC_STUBS
: return "PARISC_STUBS";
2535 case SHT_PARISC_DLKM
: return "PARISC_DLKM";
2543 get_ia64_section_type_name (unsigned int sh_type
)
2545 /* If the top 8 bits are 0x78 the next 8 are the os/abi ID. */
2546 if ((sh_type
& 0xFF000000) == SHT_IA_64_LOPSREG
)
2547 return get_osabi_name ((sh_type
& 0x00FF0000) >> 16);
2551 case SHT_IA_64_EXT
: return "IA_64_EXT";
2552 case SHT_IA_64_UNWIND
: return "IA_64_UNWIND";
2553 case SHT_IA_64_PRIORITY_INIT
: return "IA_64_PRIORITY_INIT";
2561 get_x86_64_section_type_name (unsigned int sh_type
)
2565 case SHT_X86_64_UNWIND
: return "X86_64_UNWIND";
2573 get_arm_section_type_name (unsigned int sh_type
)
2579 case SHT_ARM_PREEMPTMAP
:
2580 return "ARM_PREEMPTMAP";
2581 case SHT_ARM_ATTRIBUTES
:
2582 return "ARM_ATTRIBUTES";
2590 get_section_type_name (unsigned int sh_type
)
2592 static char buff
[32];
2596 case SHT_NULL
: return "NULL";
2597 case SHT_PROGBITS
: return "PROGBITS";
2598 case SHT_SYMTAB
: return "SYMTAB";
2599 case SHT_STRTAB
: return "STRTAB";
2600 case SHT_RELA
: return "RELA";
2601 case SHT_HASH
: return "HASH";
2602 case SHT_DYNAMIC
: return "DYNAMIC";
2603 case SHT_NOTE
: return "NOTE";
2604 case SHT_NOBITS
: return "NOBITS";
2605 case SHT_REL
: return "REL";
2606 case SHT_SHLIB
: return "SHLIB";
2607 case SHT_DYNSYM
: return "DYNSYM";
2608 case SHT_INIT_ARRAY
: return "INIT_ARRAY";
2609 case SHT_FINI_ARRAY
: return "FINI_ARRAY";
2610 case SHT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
2611 case SHT_GNU_HASH
: return "GNU_HASH";
2612 case SHT_GROUP
: return "GROUP";
2613 case SHT_SYMTAB_SHNDX
: return "SYMTAB SECTION INDICIES";
2614 case SHT_GNU_verdef
: return "VERDEF";
2615 case SHT_GNU_verneed
: return "VERNEED";
2616 case SHT_GNU_versym
: return "VERSYM";
2617 case 0x6ffffff0: return "VERSYM";
2618 case 0x6ffffffc: return "VERDEF";
2619 case 0x7ffffffd: return "AUXILIARY";
2620 case 0x7fffffff: return "FILTER";
2621 case SHT_GNU_LIBLIST
: return "GNU_LIBLIST";
2624 if ((sh_type
>= SHT_LOPROC
) && (sh_type
<= SHT_HIPROC
))
2628 switch (elf_header
.e_machine
)
2631 case EM_MIPS_RS3_LE
:
2632 result
= get_mips_section_type_name (sh_type
);
2635 result
= get_parisc_section_type_name (sh_type
);
2638 result
= get_ia64_section_type_name (sh_type
);
2641 result
= get_x86_64_section_type_name (sh_type
);
2644 result
= get_arm_section_type_name (sh_type
);
2654 sprintf (buff
, "LOPROC+%x", sh_type
- SHT_LOPROC
);
2656 else if ((sh_type
>= SHT_LOOS
) && (sh_type
<= SHT_HIOS
))
2657 sprintf (buff
, "LOOS+%x", sh_type
- SHT_LOOS
);
2658 else if ((sh_type
>= SHT_LOUSER
) && (sh_type
<= SHT_HIUSER
))
2659 sprintf (buff
, "LOUSER+%x", sh_type
- SHT_LOUSER
);
2661 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), sh_type
);
2667 #define OPTION_DEBUG_DUMP 512
2669 static struct option options
[] =
2671 {"all", no_argument
, 0, 'a'},
2672 {"file-header", no_argument
, 0, 'h'},
2673 {"program-headers", no_argument
, 0, 'l'},
2674 {"headers", no_argument
, 0, 'e'},
2675 {"histogram", no_argument
, 0, 'I'},
2676 {"segments", no_argument
, 0, 'l'},
2677 {"sections", no_argument
, 0, 'S'},
2678 {"section-headers", no_argument
, 0, 'S'},
2679 {"section-groups", no_argument
, 0, 'g'},
2680 {"section-details", no_argument
, 0, 't'},
2681 {"full-section-name",no_argument
, 0, 'N'},
2682 {"symbols", no_argument
, 0, 's'},
2683 {"syms", no_argument
, 0, 's'},
2684 {"relocs", no_argument
, 0, 'r'},
2685 {"notes", no_argument
, 0, 'n'},
2686 {"dynamic", no_argument
, 0, 'd'},
2687 {"arch-specific", no_argument
, 0, 'A'},
2688 {"version-info", no_argument
, 0, 'V'},
2689 {"use-dynamic", no_argument
, 0, 'D'},
2690 {"hex-dump", required_argument
, 0, 'x'},
2691 {"debug-dump", optional_argument
, 0, OPTION_DEBUG_DUMP
},
2692 {"unwind", no_argument
, 0, 'u'},
2693 #ifdef SUPPORT_DISASSEMBLY
2694 {"instruction-dump", required_argument
, 0, 'i'},
2697 {"version", no_argument
, 0, 'v'},
2698 {"wide", no_argument
, 0, 'W'},
2699 {"help", no_argument
, 0, 'H'},
2700 {0, no_argument
, 0, 0}
2706 fprintf (stdout
, _("Usage: readelf <option(s)> elf-file(s)\n"));
2707 fprintf (stdout
, _(" Display information about the contents of ELF format files\n"));
2708 fprintf (stdout
, _(" Options are:\n\
2709 -a --all Equivalent to: -h -l -S -s -r -d -V -A -I\n\
2710 -h --file-header Display the ELF file header\n\
2711 -l --program-headers Display the program headers\n\
2712 --segments An alias for --program-headers\n\
2713 -S --section-headers Display the sections' header\n\
2714 --sections An alias for --section-headers\n\
2715 -g --section-groups Display the section groups\n\
2716 -t --section-details Display the section details\n\
2717 -e --headers Equivalent to: -h -l -S\n\
2718 -s --syms Display the symbol table\n\
2719 --symbols An alias for --syms\n\
2720 -n --notes Display the core notes (if present)\n\
2721 -r --relocs Display the relocations (if present)\n\
2722 -u --unwind Display the unwind info (if present)\n\
2723 -d --dynamic Display the dynamic section (if present)\n\
2724 -V --version-info Display the version sections (if present)\n\
2725 -A --arch-specific Display architecture specific information (if any).\n\
2726 -D --use-dynamic Use the dynamic section info when displaying symbols\n\
2727 -x --hex-dump=<number> Dump the contents of section <number>\n\
2728 -w[liaprmfFsoR] or\n\
2729 --debug-dump[=line,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges]\n\
2730 Display the contents of DWARF2 debug sections\n"));
2731 #ifdef SUPPORT_DISASSEMBLY
2732 fprintf (stdout
, _("\
2733 -i --instruction-dump=<number>\n\
2734 Disassemble the contents of section <number>\n"));
2736 fprintf (stdout
, _("\
2737 -I --histogram Display histogram of bucket list lengths\n\
2738 -W --wide Allow output width to exceed 80 characters\n\
2739 @<file> Read options from <file>\n\
2740 -H --help Display this information\n\
2741 -v --version Display the version number of readelf\n"));
2742 fprintf (stdout
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
2747 /* Record the fact that the user wants the contents of section number
2748 SECTION to be displayed using the method(s) encoded as flags bits
2749 in TYPE. Note, TYPE can be zero if we are creating the array for
2753 request_dump (unsigned int section
, int type
)
2755 if (section
>= num_dump_sects
)
2757 char *new_dump_sects
;
2759 new_dump_sects
= calloc (section
+ 1, 1);
2761 if (new_dump_sects
== NULL
)
2762 error (_("Out of memory allocating dump request table."));
2765 /* Copy current flag settings. */
2766 memcpy (new_dump_sects
, dump_sects
, num_dump_sects
);
2770 dump_sects
= new_dump_sects
;
2771 num_dump_sects
= section
+ 1;
2776 dump_sects
[section
] |= type
;
2781 /* Request a dump by section name. */
2784 request_dump_byname (const char *section
, int type
)
2786 struct dump_list_entry
*new_request
;
2788 new_request
= malloc (sizeof (struct dump_list_entry
));
2790 error (_("Out of memory allocating dump request table."));
2792 new_request
->name
= strdup (section
);
2793 if (!new_request
->name
)
2794 error (_("Out of memory allocating dump request table."));
2796 new_request
->type
= type
;
2798 new_request
->next
= dump_sects_byname
;
2799 dump_sects_byname
= new_request
;
2803 parse_args (int argc
, char **argv
)
2810 while ((c
= getopt_long
2811 (argc
, argv
, "ersuahnldSDAINtgw::x:i:vVWH", options
, NULL
)) != EOF
)
2832 do_section_groups
++;
2840 do_section_groups
++;
2845 do_section_details
++;
2887 section
= strtoul (optarg
, & cp
, 0);
2888 if (! *cp
&& section
>= 0)
2889 request_dump (section
, HEX_DUMP
);
2891 request_dump_byname (optarg
, HEX_DUMP
);
2899 unsigned int index
= 0;
2903 while (optarg
[index
])
2904 switch (optarg
[index
++])
2913 do_debug_abbrevs
= 1;
2923 do_debug_pubnames
= 1;
2927 do_debug_aranges
= 1;
2931 do_debug_ranges
= 1;
2935 do_debug_frames_interp
= 1;
2937 do_debug_frames
= 1;
2942 do_debug_macinfo
= 1;
2956 warn (_("Unrecognized debug option '%s'\n"), optarg
);
2961 case OPTION_DEBUG_DUMP
:
2969 const char * option
;
2972 debug_dump_long_opts
;
2974 debug_dump_long_opts opts_table
[] =
2976 /* Please keep this table alpha- sorted. */
2977 { "Ranges", & do_debug_ranges
},
2978 { "abbrev", & do_debug_abbrevs
},
2979 { "aranges", & do_debug_aranges
},
2980 { "frames", & do_debug_frames
},
2981 { "frames-interp", & do_debug_frames_interp
},
2982 { "info", & do_debug_info
},
2983 { "line", & do_debug_lines
},
2984 { "loc", & do_debug_loc
},
2985 { "macro", & do_debug_macinfo
},
2986 { "pubnames", & do_debug_pubnames
},
2987 /* This entry is for compatability
2988 with earlier versions of readelf. */
2989 { "ranges", & do_debug_aranges
},
2990 { "str", & do_debug_str
},
3001 debug_dump_long_opts
* entry
;
3003 for (entry
= opts_table
; entry
->option
; entry
++)
3005 size_t len
= strlen (entry
->option
);
3007 if (strneq (p
, entry
->option
, len
)
3008 && (p
[len
] == ',' || p
[len
] == '\0'))
3010 * entry
->variable
= 1;
3012 /* The --debug-dump=frames-interp option also
3013 enables the --debug-dump=frames option. */
3014 if (do_debug_frames_interp
)
3015 do_debug_frames
= 1;
3022 if (entry
->option
== NULL
)
3024 warn (_("Unrecognized debug option '%s'\n"), p
);
3025 p
= strchr (p
, ',');
3035 #ifdef SUPPORT_DISASSEMBLY
3038 section
= strtoul (optarg
, & cp
, 0);
3039 if (! *cp
&& section
>= 0)
3041 request_dump (section
, DISASS_DUMP
);
3047 print_version (program_name
);
3056 #ifdef SUPPORT_DISASSEMBLY
3059 /* xgettext:c-format */
3060 error (_("Invalid option '-%c'\n"), c
);
3067 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
3068 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
3069 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
3070 && !do_section_groups
)
3074 warn (_("Nothing to do.\n"));
3080 get_elf_class (unsigned int elf_class
)
3082 static char buff
[32];
3086 case ELFCLASSNONE
: return _("none");
3087 case ELFCLASS32
: return "ELF32";
3088 case ELFCLASS64
: return "ELF64";
3090 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), elf_class
);
3096 get_data_encoding (unsigned int encoding
)
3098 static char buff
[32];
3102 case ELFDATANONE
: return _("none");
3103 case ELFDATA2LSB
: return _("2's complement, little endian");
3104 case ELFDATA2MSB
: return _("2's complement, big endian");
3106 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), encoding
);
3111 /* Decode the data held in 'elf_header'. */
3114 process_file_header (void)
3116 if ( elf_header
.e_ident
[EI_MAG0
] != ELFMAG0
3117 || elf_header
.e_ident
[EI_MAG1
] != ELFMAG1
3118 || elf_header
.e_ident
[EI_MAG2
] != ELFMAG2
3119 || elf_header
.e_ident
[EI_MAG3
] != ELFMAG3
)
3122 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
3130 printf (_("ELF Header:\n"));
3131 printf (_(" Magic: "));
3132 for (i
= 0; i
< EI_NIDENT
; i
++)
3133 printf ("%2.2x ", elf_header
.e_ident
[i
]);
3135 printf (_(" Class: %s\n"),
3136 get_elf_class (elf_header
.e_ident
[EI_CLASS
]));
3137 printf (_(" Data: %s\n"),
3138 get_data_encoding (elf_header
.e_ident
[EI_DATA
]));
3139 printf (_(" Version: %d %s\n"),
3140 elf_header
.e_ident
[EI_VERSION
],
3141 (elf_header
.e_ident
[EI_VERSION
] == EV_CURRENT
3143 : (elf_header
.e_ident
[EI_VERSION
] != EV_NONE
3146 printf (_(" OS/ABI: %s\n"),
3147 get_osabi_name (elf_header
.e_ident
[EI_OSABI
]));
3148 printf (_(" ABI Version: %d\n"),
3149 elf_header
.e_ident
[EI_ABIVERSION
]);
3150 printf (_(" Type: %s\n"),
3151 get_file_type (elf_header
.e_type
));
3152 printf (_(" Machine: %s\n"),
3153 get_machine_name (elf_header
.e_machine
));
3154 printf (_(" Version: 0x%lx\n"),
3155 (unsigned long) elf_header
.e_version
);
3157 printf (_(" Entry point address: "));
3158 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3159 printf (_("\n Start of program headers: "));
3160 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3161 printf (_(" (bytes into file)\n Start of section headers: "));
3162 print_vma ((bfd_vma
) elf_header
.e_shoff
, DEC
);
3163 printf (_(" (bytes into file)\n"));
3165 printf (_(" Flags: 0x%lx%s\n"),
3166 (unsigned long) elf_header
.e_flags
,
3167 get_machine_flags (elf_header
.e_flags
, elf_header
.e_machine
));
3168 printf (_(" Size of this header: %ld (bytes)\n"),
3169 (long) elf_header
.e_ehsize
);
3170 printf (_(" Size of program headers: %ld (bytes)\n"),
3171 (long) elf_header
.e_phentsize
);
3172 printf (_(" Number of program headers: %ld\n"),
3173 (long) elf_header
.e_phnum
);
3174 printf (_(" Size of section headers: %ld (bytes)\n"),
3175 (long) elf_header
.e_shentsize
);
3176 printf (_(" Number of section headers: %ld"),
3177 (long) elf_header
.e_shnum
);
3178 if (section_headers
!= NULL
&& elf_header
.e_shnum
== 0)
3179 printf (" (%ld)", (long) section_headers
[0].sh_size
);
3180 putc ('\n', stdout
);
3181 printf (_(" Section header string table index: %ld"),
3182 (long) elf_header
.e_shstrndx
);
3183 if (section_headers
!= NULL
&& elf_header
.e_shstrndx
== SHN_XINDEX
)
3184 printf (" (%ld)", (long) section_headers
[0].sh_link
);
3185 else if (elf_header
.e_shstrndx
!= SHN_UNDEF
3186 && (elf_header
.e_shstrndx
>= elf_header
.e_shnum
3187 || (elf_header
.e_shstrndx
>= SHN_LORESERVE
3188 && elf_header
.e_shstrndx
<= SHN_HIRESERVE
)))
3189 printf (" <corrupt: out of range>");
3190 putc ('\n', stdout
);
3193 if (section_headers
!= NULL
)
3195 if (elf_header
.e_shnum
== 0)
3196 elf_header
.e_shnum
= section_headers
[0].sh_size
;
3197 if (elf_header
.e_shstrndx
== SHN_XINDEX
)
3198 elf_header
.e_shstrndx
= section_headers
[0].sh_link
;
3199 else if (elf_header
.e_shstrndx
!= SHN_UNDEF
3200 && (elf_header
.e_shstrndx
>= elf_header
.e_shnum
3201 || (elf_header
.e_shstrndx
>= SHN_LORESERVE
3202 && elf_header
.e_shstrndx
<= SHN_HIRESERVE
)))
3203 elf_header
.e_shstrndx
= SHN_UNDEF
;
3204 free (section_headers
);
3205 section_headers
= NULL
;
3213 get_32bit_program_headers (FILE *file
, Elf_Internal_Phdr
*program_headers
)
3215 Elf32_External_Phdr
*phdrs
;
3216 Elf32_External_Phdr
*external
;
3217 Elf_Internal_Phdr
*internal
;
3220 phdrs
= get_data (NULL
, file
, elf_header
.e_phoff
,
3221 elf_header
.e_phentsize
, elf_header
.e_phnum
,
3222 _("program headers"));
3226 for (i
= 0, internal
= program_headers
, external
= phdrs
;
3227 i
< elf_header
.e_phnum
;
3228 i
++, internal
++, external
++)
3230 internal
->p_type
= BYTE_GET (external
->p_type
);
3231 internal
->p_offset
= BYTE_GET (external
->p_offset
);
3232 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
3233 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
3234 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
3235 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
3236 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3237 internal
->p_align
= BYTE_GET (external
->p_align
);
3246 get_64bit_program_headers (FILE *file
, Elf_Internal_Phdr
*program_headers
)
3248 Elf64_External_Phdr
*phdrs
;
3249 Elf64_External_Phdr
*external
;
3250 Elf_Internal_Phdr
*internal
;
3253 phdrs
= get_data (NULL
, file
, elf_header
.e_phoff
,
3254 elf_header
.e_phentsize
, elf_header
.e_phnum
,
3255 _("program headers"));
3259 for (i
= 0, internal
= program_headers
, external
= phdrs
;
3260 i
< elf_header
.e_phnum
;
3261 i
++, internal
++, external
++)
3263 internal
->p_type
= BYTE_GET (external
->p_type
);
3264 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3265 internal
->p_offset
= BYTE_GET (external
->p_offset
);
3266 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
3267 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
3268 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
3269 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
3270 internal
->p_align
= BYTE_GET (external
->p_align
);
3278 /* Returns 1 if the program headers were read into `program_headers'. */
3281 get_program_headers (FILE *file
)
3283 Elf_Internal_Phdr
*phdrs
;
3285 /* Check cache of prior read. */
3286 if (program_headers
!= NULL
)
3289 phdrs
= cmalloc (elf_header
.e_phnum
, sizeof (Elf_Internal_Phdr
));
3293 error (_("Out of memory\n"));
3298 ? get_32bit_program_headers (file
, phdrs
)
3299 : get_64bit_program_headers (file
, phdrs
))
3301 program_headers
= phdrs
;
3309 /* Returns 1 if the program headers were loaded. */
3312 process_program_headers (FILE *file
)
3314 Elf_Internal_Phdr
*segment
;
3317 if (elf_header
.e_phnum
== 0)
3320 printf (_("\nThere are no program headers in this file.\n"));
3324 if (do_segments
&& !do_header
)
3326 printf (_("\nElf file type is %s\n"), get_file_type (elf_header
.e_type
));
3327 printf (_("Entry point "));
3328 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3329 printf (_("\nThere are %d program headers, starting at offset "),
3330 elf_header
.e_phnum
);
3331 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3335 if (! get_program_headers (file
))
3340 if (elf_header
.e_phnum
> 1)
3341 printf (_("\nProgram Headers:\n"));
3343 printf (_("\nProgram Headers:\n"));
3347 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3350 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3354 (_(" Type Offset VirtAddr PhysAddr\n"));
3356 (_(" FileSiz MemSiz Flags Align\n"));
3363 for (i
= 0, segment
= program_headers
;
3364 i
< elf_header
.e_phnum
;
3369 printf (" %-14.14s ", get_segment_type (segment
->p_type
));
3373 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3374 printf ("0x%8.8lx ", (unsigned long) segment
->p_vaddr
);
3375 printf ("0x%8.8lx ", (unsigned long) segment
->p_paddr
);
3376 printf ("0x%5.5lx ", (unsigned long) segment
->p_filesz
);
3377 printf ("0x%5.5lx ", (unsigned long) segment
->p_memsz
);
3379 (segment
->p_flags
& PF_R
? 'R' : ' '),
3380 (segment
->p_flags
& PF_W
? 'W' : ' '),
3381 (segment
->p_flags
& PF_X
? 'E' : ' '));
3382 printf ("%#lx", (unsigned long) segment
->p_align
);
3386 if ((unsigned long) segment
->p_offset
== segment
->p_offset
)
3387 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3390 print_vma (segment
->p_offset
, FULL_HEX
);
3394 print_vma (segment
->p_vaddr
, FULL_HEX
);
3396 print_vma (segment
->p_paddr
, FULL_HEX
);
3399 if ((unsigned long) segment
->p_filesz
== segment
->p_filesz
)
3400 printf ("0x%6.6lx ", (unsigned long) segment
->p_filesz
);
3403 print_vma (segment
->p_filesz
, FULL_HEX
);
3407 if ((unsigned long) segment
->p_memsz
== segment
->p_memsz
)
3408 printf ("0x%6.6lx", (unsigned long) segment
->p_memsz
);
3411 print_vma (segment
->p_offset
, FULL_HEX
);
3415 (segment
->p_flags
& PF_R
? 'R' : ' '),
3416 (segment
->p_flags
& PF_W
? 'W' : ' '),
3417 (segment
->p_flags
& PF_X
? 'E' : ' '));
3419 if ((unsigned long) segment
->p_align
== segment
->p_align
)
3420 printf ("%#lx", (unsigned long) segment
->p_align
);
3423 print_vma (segment
->p_align
, PREFIX_HEX
);
3428 print_vma (segment
->p_offset
, FULL_HEX
);
3430 print_vma (segment
->p_vaddr
, FULL_HEX
);
3432 print_vma (segment
->p_paddr
, FULL_HEX
);
3434 print_vma (segment
->p_filesz
, FULL_HEX
);
3436 print_vma (segment
->p_memsz
, FULL_HEX
);
3438 (segment
->p_flags
& PF_R
? 'R' : ' '),
3439 (segment
->p_flags
& PF_W
? 'W' : ' '),
3440 (segment
->p_flags
& PF_X
? 'E' : ' '));
3441 print_vma (segment
->p_align
, HEX
);
3445 switch (segment
->p_type
)
3449 error (_("more than one dynamic segment\n"));
3451 /* Try to locate the .dynamic section. If there is
3452 a section header table, we can easily locate it. */
3453 if (section_headers
!= NULL
)
3455 Elf_Internal_Shdr
*sec
;
3457 sec
= find_section (".dynamic");
3458 if (sec
== NULL
|| sec
->sh_size
== 0)
3460 error (_("no .dynamic section in the dynamic segment"));
3464 dynamic_addr
= sec
->sh_offset
;
3465 dynamic_size
= sec
->sh_size
;
3467 if (dynamic_addr
< segment
->p_offset
3468 || dynamic_addr
> segment
->p_offset
+ segment
->p_filesz
)
3469 warn (_("the .dynamic section is not contained within the dynamic segment"));
3470 else if (dynamic_addr
> segment
->p_offset
)
3471 warn (_("the .dynamic section is not the first section in the dynamic segment."));
3475 /* Otherwise, we can only assume that the .dynamic
3476 section is the first section in the DYNAMIC segment. */
3477 dynamic_addr
= segment
->p_offset
;
3478 dynamic_size
= segment
->p_filesz
;
3483 if (fseek (file
, archive_file_offset
+ (long) segment
->p_offset
,
3485 error (_("Unable to find program interpreter name\n"));
3488 program_interpreter
[0] = 0;
3489 fscanf (file
, "%63s", program_interpreter
);
3492 printf (_("\n [Requesting program interpreter: %s]"),
3493 program_interpreter
);
3499 putc ('\n', stdout
);
3502 if (do_segments
&& section_headers
!= NULL
&& string_table
!= NULL
)
3504 printf (_("\n Section to Segment mapping:\n"));
3505 printf (_(" Segment Sections...\n"));
3507 for (i
= 0; i
< elf_header
.e_phnum
; i
++)
3510 Elf_Internal_Shdr
*section
;
3512 segment
= program_headers
+ i
;
3513 section
= section_headers
;
3515 printf (" %2.2d ", i
);
3517 for (j
= 1; j
< elf_header
.e_shnum
; j
++, section
++)
3519 if (ELF_IS_SECTION_IN_SEGMENT_MEMORY(section
, segment
))
3520 printf ("%s ", SECTION_NAME (section
));
3531 /* Find the file offset corresponding to VMA by using the program headers. */
3534 offset_from_vma (FILE *file
, bfd_vma vma
, bfd_size_type size
)
3536 Elf_Internal_Phdr
*seg
;
3538 if (! get_program_headers (file
))
3540 warn (_("Cannot interpret virtual addresses without program headers.\n"));
3544 for (seg
= program_headers
;
3545 seg
< program_headers
+ elf_header
.e_phnum
;
3548 if (seg
->p_type
!= PT_LOAD
)
3551 if (vma
>= (seg
->p_vaddr
& -seg
->p_align
)
3552 && vma
+ size
<= seg
->p_vaddr
+ seg
->p_filesz
)
3553 return vma
- seg
->p_vaddr
+ seg
->p_offset
;
3556 warn (_("Virtual address 0x%lx not located in any PT_LOAD segment.\n"),
3563 get_32bit_section_headers (FILE *file
, unsigned int num
)
3565 Elf32_External_Shdr
*shdrs
;
3566 Elf_Internal_Shdr
*internal
;
3569 shdrs
= get_data (NULL
, file
, elf_header
.e_shoff
,
3570 elf_header
.e_shentsize
, num
, _("section headers"));
3574 section_headers
= cmalloc (num
, sizeof (Elf_Internal_Shdr
));
3576 if (section_headers
== NULL
)
3578 error (_("Out of memory\n"));
3582 for (i
= 0, internal
= section_headers
;
3586 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3587 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3588 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
3589 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
3590 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3591 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
3592 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3593 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3594 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3595 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
3604 get_64bit_section_headers (FILE *file
, unsigned int num
)
3606 Elf64_External_Shdr
*shdrs
;
3607 Elf_Internal_Shdr
*internal
;
3610 shdrs
= get_data (NULL
, file
, elf_header
.e_shoff
,
3611 elf_header
.e_shentsize
, num
, _("section headers"));
3615 section_headers
= cmalloc (num
, sizeof (Elf_Internal_Shdr
));
3617 if (section_headers
== NULL
)
3619 error (_("Out of memory\n"));
3623 for (i
= 0, internal
= section_headers
;
3627 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3628 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3629 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
3630 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
3631 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
3632 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
3633 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3634 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3635 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3636 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3644 static Elf_Internal_Sym
*
3645 get_32bit_elf_symbols (FILE *file
, Elf_Internal_Shdr
*section
)
3647 unsigned long number
;
3648 Elf32_External_Sym
*esyms
;
3649 Elf_External_Sym_Shndx
*shndx
;
3650 Elf_Internal_Sym
*isyms
;
3651 Elf_Internal_Sym
*psym
;
3654 esyms
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
3660 if (symtab_shndx_hdr
!= NULL
3661 && (symtab_shndx_hdr
->sh_link
3662 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3664 shndx
= get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3665 1, symtab_shndx_hdr
->sh_size
, _("symtab shndx"));
3673 number
= section
->sh_size
/ section
->sh_entsize
;
3674 isyms
= cmalloc (number
, sizeof (Elf_Internal_Sym
));
3678 error (_("Out of memory\n"));
3685 for (j
= 0, psym
= isyms
;
3689 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3690 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3691 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3692 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3693 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3695 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3696 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3697 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3707 static Elf_Internal_Sym
*
3708 get_64bit_elf_symbols (FILE *file
, Elf_Internal_Shdr
*section
)
3710 unsigned long number
;
3711 Elf64_External_Sym
*esyms
;
3712 Elf_External_Sym_Shndx
*shndx
;
3713 Elf_Internal_Sym
*isyms
;
3714 Elf_Internal_Sym
*psym
;
3717 esyms
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
3723 if (symtab_shndx_hdr
!= NULL
3724 && (symtab_shndx_hdr
->sh_link
3725 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3727 shndx
= get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3728 1, symtab_shndx_hdr
->sh_size
, _("symtab shndx"));
3736 number
= section
->sh_size
/ section
->sh_entsize
;
3737 isyms
= cmalloc (number
, sizeof (Elf_Internal_Sym
));
3741 error (_("Out of memory\n"));
3748 for (j
= 0, psym
= isyms
;
3752 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3753 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3754 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3755 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3756 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3758 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3759 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3760 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3771 get_elf_section_flags (bfd_vma sh_flags
)
3773 static char buff
[1024];
3775 int field_size
= is_32bit_elf
? 8 : 16;
3776 int index
, size
= sizeof (buff
) - (field_size
+ 4 + 1);
3777 bfd_vma os_flags
= 0;
3778 bfd_vma proc_flags
= 0;
3779 bfd_vma unknown_flags
= 0;
3793 { "LINK ORDER", 10 },
3794 { "OS NONCONF", 10 },
3799 if (do_section_details
)
3801 sprintf (buff
, "[%*.*lx]: ",
3802 field_size
, field_size
, (unsigned long) sh_flags
);
3803 p
+= field_size
+ 4;
3810 flag
= sh_flags
& - sh_flags
;
3813 if (do_section_details
)
3817 case SHF_WRITE
: index
= 0; break;
3818 case SHF_ALLOC
: index
= 1; break;
3819 case SHF_EXECINSTR
: index
= 2; break;
3820 case SHF_MERGE
: index
= 3; break;
3821 case SHF_STRINGS
: index
= 4; break;
3822 case SHF_INFO_LINK
: index
= 5; break;
3823 case SHF_LINK_ORDER
: index
= 6; break;
3824 case SHF_OS_NONCONFORMING
: index
= 7; break;
3825 case SHF_GROUP
: index
= 8; break;
3826 case SHF_TLS
: index
= 9; break;
3835 if (p
!= buff
+ field_size
+ 4)
3837 if (size
< (10 + 2))
3844 size
-= flags
[index
].len
;
3845 p
= stpcpy (p
, flags
[index
].str
);
3847 else if (flag
& SHF_MASKOS
)
3849 else if (flag
& SHF_MASKPROC
)
3852 unknown_flags
|= flag
;
3858 case SHF_WRITE
: *p
= 'W'; break;
3859 case SHF_ALLOC
: *p
= 'A'; break;
3860 case SHF_EXECINSTR
: *p
= 'X'; break;
3861 case SHF_MERGE
: *p
= 'M'; break;
3862 case SHF_STRINGS
: *p
= 'S'; break;
3863 case SHF_INFO_LINK
: *p
= 'I'; break;
3864 case SHF_LINK_ORDER
: *p
= 'L'; break;
3865 case SHF_OS_NONCONFORMING
: *p
= 'O'; break;
3866 case SHF_GROUP
: *p
= 'G'; break;
3867 case SHF_TLS
: *p
= 'T'; break;
3870 if (elf_header
.e_machine
== EM_X86_64
3871 && flag
== SHF_X86_64_LARGE
)
3873 else if (flag
& SHF_MASKOS
)
3876 sh_flags
&= ~ SHF_MASKOS
;
3878 else if (flag
& SHF_MASKPROC
)
3881 sh_flags
&= ~ SHF_MASKPROC
;
3891 if (do_section_details
)
3895 size
-= 5 + field_size
;
3896 if (p
!= buff
+ field_size
+ 4)
3904 sprintf (p
, "OS (%*.*lx)", field_size
, field_size
,
3905 (unsigned long) os_flags
);
3906 p
+= 5 + field_size
;
3910 size
-= 7 + field_size
;
3911 if (p
!= buff
+ field_size
+ 4)
3919 sprintf (p
, "PROC (%*.*lx)", field_size
, field_size
,
3920 (unsigned long) proc_flags
);
3921 p
+= 7 + field_size
;
3925 size
-= 10 + field_size
;
3926 if (p
!= buff
+ field_size
+ 4)
3934 sprintf (p
, "UNKNOWN (%*.*lx)", field_size
, field_size
,
3935 (unsigned long) unknown_flags
);
3936 p
+= 10 + field_size
;
3945 process_section_headers (FILE *file
)
3947 Elf_Internal_Shdr
*section
;
3950 section_headers
= NULL
;
3952 if (elf_header
.e_shnum
== 0)
3955 printf (_("\nThere are no sections in this file.\n"));
3960 if (do_sections
&& !do_header
)
3961 printf (_("There are %d section headers, starting at offset 0x%lx:\n"),
3962 elf_header
.e_shnum
, (unsigned long) elf_header
.e_shoff
);
3966 if (! get_32bit_section_headers (file
, elf_header
.e_shnum
))
3969 else if (! get_64bit_section_headers (file
, elf_header
.e_shnum
))
3972 /* Read in the string table, so that we have names to display. */
3973 if (elf_header
.e_shstrndx
!= SHN_UNDEF
3974 && SECTION_HEADER_INDEX (elf_header
.e_shstrndx
) < elf_header
.e_shnum
)
3976 section
= SECTION_HEADER (elf_header
.e_shstrndx
);
3978 if (section
->sh_size
!= 0)
3980 string_table
= get_data (NULL
, file
, section
->sh_offset
,
3981 1, section
->sh_size
, _("string table"));
3983 string_table_length
= string_table
!= NULL
? section
->sh_size
: 0;
3987 /* Scan the sections for the dynamic symbol table
3988 and dynamic string table and debug sections. */
3989 dynamic_symbols
= NULL
;
3990 dynamic_strings
= NULL
;
3991 dynamic_syminfo
= NULL
;
3992 symtab_shndx_hdr
= NULL
;
3994 eh_addr_size
= is_32bit_elf
? 4 : 8;
3995 switch (elf_header
.e_machine
)
3998 case EM_MIPS_RS3_LE
:
3999 /* The 64-bit MIPS EABI uses a combination of 32-bit ELF and 64-bit
4000 FDE addresses. However, the ABI also has a semi-official ILP32
4001 variant for which the normal FDE address size rules apply.
4003 GCC 4.0 marks EABI64 objects with a dummy .gcc_compiled_longXX
4004 section, where XX is the size of longs in bits. Unfortunately,
4005 earlier compilers provided no way of distinguishing ILP32 objects
4006 from LP64 objects, so if there's any doubt, we should assume that
4007 the official LP64 form is being used. */
4008 if ((elf_header
.e_flags
& EF_MIPS_ABI
) == E_MIPS_ABI_EABI64
4009 && find_section (".gcc_compiled_long32") == NULL
)
4015 switch (elf_header
.e_flags
& EF_H8_MACH
)
4017 case E_H8_MACH_H8300
:
4018 case E_H8_MACH_H8300HN
:
4019 case E_H8_MACH_H8300SN
:
4020 case E_H8_MACH_H8300SXN
:
4023 case E_H8_MACH_H8300H
:
4024 case E_H8_MACH_H8300S
:
4025 case E_H8_MACH_H8300SX
:
4031 #define CHECK_ENTSIZE_VALUES(section, i, size32, size64) \
4034 size_t expected_entsize \
4035 = is_32bit_elf ? size32 : size64; \
4036 if (section->sh_entsize != expected_entsize) \
4037 error (_("Section %d has invalid sh_entsize %lx (expected %lx)\n"), \
4038 i, (unsigned long int) section->sh_entsize, \
4039 (unsigned long int) expected_entsize); \
4040 section->sh_entsize = expected_entsize; \
4043 #define CHECK_ENTSIZE(section, i, type) \
4044 CHECK_ENTSIZE_VALUES (section, i, sizeof (Elf32_External_##type), \
4045 sizeof (Elf64_External_##type))
4047 for (i
= 0, section
= section_headers
;
4048 i
< elf_header
.e_shnum
;
4051 char *name
= SECTION_NAME (section
);
4053 if (section
->sh_type
== SHT_DYNSYM
)
4055 if (dynamic_symbols
!= NULL
)
4057 error (_("File contains multiple dynamic symbol tables\n"));
4061 CHECK_ENTSIZE (section
, i
, Sym
);
4062 num_dynamic_syms
= section
->sh_size
/ section
->sh_entsize
;
4063 dynamic_symbols
= GET_ELF_SYMBOLS (file
, section
);
4065 else if (section
->sh_type
== SHT_STRTAB
4066 && streq (name
, ".dynstr"))
4068 if (dynamic_strings
!= NULL
)
4070 error (_("File contains multiple dynamic string tables\n"));
4074 dynamic_strings
= get_data (NULL
, file
, section
->sh_offset
,
4075 1, section
->sh_size
, _("dynamic strings"));
4076 dynamic_strings_length
= section
->sh_size
;
4078 else if (section
->sh_type
== SHT_SYMTAB_SHNDX
)
4080 if (symtab_shndx_hdr
!= NULL
)
4082 error (_("File contains multiple symtab shndx tables\n"));
4085 symtab_shndx_hdr
= section
;
4087 else if (section
->sh_type
== SHT_SYMTAB
)
4088 CHECK_ENTSIZE (section
, i
, Sym
);
4089 else if (section
->sh_type
== SHT_GROUP
)
4090 CHECK_ENTSIZE_VALUES (section
, i
, GRP_ENTRY_SIZE
, GRP_ENTRY_SIZE
);
4091 else if (section
->sh_type
== SHT_REL
)
4092 CHECK_ENTSIZE (section
, i
, Rel
);
4093 else if (section
->sh_type
== SHT_RELA
)
4094 CHECK_ENTSIZE (section
, i
, Rela
);
4095 else if ((do_debugging
|| do_debug_info
|| do_debug_abbrevs
4096 || do_debug_lines
|| do_debug_pubnames
|| do_debug_aranges
4097 || do_debug_frames
|| do_debug_macinfo
|| do_debug_str
4098 || do_debug_loc
|| do_debug_ranges
)
4099 && const_strneq (name
, ".debug_"))
4104 || (do_debug_info
&& streq (name
, "info"))
4105 || (do_debug_abbrevs
&& streq (name
, "abbrev"))
4106 || (do_debug_lines
&& streq (name
, "line"))
4107 || (do_debug_pubnames
&& streq (name
, "pubnames"))
4108 || (do_debug_aranges
&& streq (name
, "aranges"))
4109 || (do_debug_ranges
&& streq (name
, "ranges"))
4110 || (do_debug_frames
&& streq (name
, "frame"))
4111 || (do_debug_macinfo
&& streq (name
, "macinfo"))
4112 || (do_debug_str
&& streq (name
, "str"))
4113 || (do_debug_loc
&& streq (name
, "loc"))
4115 request_dump (i
, DEBUG_DUMP
);
4117 /* linkonce section to be combined with .debug_info at link time. */
4118 else if ((do_debugging
|| do_debug_info
)
4119 && const_strneq (name
, ".gnu.linkonce.wi."))
4120 request_dump (i
, DEBUG_DUMP
);
4121 else if (do_debug_frames
&& streq (name
, ".eh_frame"))
4122 request_dump (i
, DEBUG_DUMP
);
4128 if (elf_header
.e_shnum
> 1)
4129 printf (_("\nSection Headers:\n"));
4131 printf (_("\nSection Header:\n"));
4135 if (do_section_details
)
4137 printf (_(" [Nr] Name\n"));
4138 printf (_(" Type Addr Off Size ES Lk Inf Al\n"));
4142 (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
4146 if (do_section_details
)
4148 printf (_(" [Nr] Name\n"));
4149 printf (_(" Type Address Off Size ES Lk Inf Al\n"));
4153 (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n"));
4157 if (do_section_details
)
4159 printf (_(" [Nr] Name\n"));
4160 printf (_(" Type Address Offset Link\n"));
4161 printf (_(" Size EntSize Info Align\n"));
4165 printf (_(" [Nr] Name Type Address Offset\n"));
4166 printf (_(" Size EntSize Flags Link Info Align\n"));
4170 if (do_section_details
)
4171 printf (_(" Flags\n"));
4173 for (i
= 0, section
= section_headers
;
4174 i
< elf_header
.e_shnum
;
4177 if (do_section_details
)
4179 printf (" [%2u] %s\n",
4180 SECTION_HEADER_NUM (i
),
4181 SECTION_NAME (section
));
4182 if (is_32bit_elf
|| do_wide
)
4183 printf (" %-15.15s ",
4184 get_section_type_name (section
->sh_type
));
4187 printf (" [%2u] %-17.17s %-15.15s ",
4188 SECTION_HEADER_NUM (i
),
4189 SECTION_NAME (section
),
4190 get_section_type_name (section
->sh_type
));
4194 print_vma (section
->sh_addr
, LONG_HEX
);
4196 printf ( " %6.6lx %6.6lx %2.2lx",
4197 (unsigned long) section
->sh_offset
,
4198 (unsigned long) section
->sh_size
,
4199 (unsigned long) section
->sh_entsize
);
4201 if (do_section_details
)
4202 fputs (" ", stdout
);
4204 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4206 printf ("%2ld %3lu %2ld\n",
4207 (unsigned long) section
->sh_link
,
4208 (unsigned long) section
->sh_info
,
4209 (unsigned long) section
->sh_addralign
);
4213 print_vma (section
->sh_addr
, LONG_HEX
);
4215 if ((long) section
->sh_offset
== section
->sh_offset
)
4216 printf (" %6.6lx", (unsigned long) section
->sh_offset
);
4220 print_vma (section
->sh_offset
, LONG_HEX
);
4223 if ((unsigned long) section
->sh_size
== section
->sh_size
)
4224 printf (" %6.6lx", (unsigned long) section
->sh_size
);
4228 print_vma (section
->sh_size
, LONG_HEX
);
4231 if ((unsigned long) section
->sh_entsize
== section
->sh_entsize
)
4232 printf (" %2.2lx", (unsigned long) section
->sh_entsize
);
4236 print_vma (section
->sh_entsize
, LONG_HEX
);
4239 if (do_section_details
)
4240 fputs (" ", stdout
);
4242 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4244 printf ("%2ld %3lu ",
4245 (unsigned long) section
->sh_link
,
4246 (unsigned long) section
->sh_info
);
4248 if ((unsigned long) section
->sh_addralign
== section
->sh_addralign
)
4249 printf ("%2ld\n", (unsigned long) section
->sh_addralign
);
4252 print_vma (section
->sh_addralign
, DEC
);
4256 else if (do_section_details
)
4258 printf (" %-15.15s ",
4259 get_section_type_name (section
->sh_type
));
4260 print_vma (section
->sh_addr
, LONG_HEX
);
4261 if ((long) section
->sh_offset
== section
->sh_offset
)
4262 printf (" %16.16lx", (unsigned long) section
->sh_offset
);
4266 print_vma (section
->sh_offset
, LONG_HEX
);
4268 printf (" %ld\n ", (unsigned long) section
->sh_link
);
4269 print_vma (section
->sh_size
, LONG_HEX
);
4271 print_vma (section
->sh_entsize
, LONG_HEX
);
4273 printf (" %-16lu %ld\n",
4274 (unsigned long) section
->sh_info
,
4275 (unsigned long) section
->sh_addralign
);
4280 print_vma (section
->sh_addr
, LONG_HEX
);
4281 if ((long) section
->sh_offset
== section
->sh_offset
)
4282 printf (" %8.8lx", (unsigned long) section
->sh_offset
);
4286 print_vma (section
->sh_offset
, LONG_HEX
);
4289 print_vma (section
->sh_size
, LONG_HEX
);
4291 print_vma (section
->sh_entsize
, LONG_HEX
);
4293 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4295 printf (" %2ld %3lu %ld\n",
4296 (unsigned long) section
->sh_link
,
4297 (unsigned long) section
->sh_info
,
4298 (unsigned long) section
->sh_addralign
);
4301 if (do_section_details
)
4302 printf (" %s\n", get_elf_section_flags (section
->sh_flags
));
4305 if (!do_section_details
)
4306 printf (_("Key to Flags:\n\
4307 W (write), A (alloc), X (execute), M (merge), S (strings)\n\
4308 I (info), L (link order), G (group), x (unknown)\n\
4309 O (extra OS processing required) o (OS specific), p (processor specific)\n"));
4315 get_group_flags (unsigned int flags
)
4317 static char buff
[32];
4324 snprintf (buff
, sizeof (buff
), _("[<unknown>: 0x%x]"), flags
);
4331 process_section_groups (FILE *file
)
4333 Elf_Internal_Shdr
*section
;
4335 struct group
*group
;
4336 Elf_Internal_Shdr
*symtab_sec
, *strtab_sec
;
4337 Elf_Internal_Sym
*symtab
;
4341 /* Don't process section groups unless needed. */
4342 if (!do_unwind
&& !do_section_groups
)
4345 if (elf_header
.e_shnum
== 0)
4347 if (do_section_groups
)
4348 printf (_("\nThere are no sections in this file.\n"));
4353 if (section_headers
== NULL
)
4355 error (_("Section headers are not available!\n"));
4359 section_headers_groups
= calloc (elf_header
.e_shnum
,
4360 sizeof (struct group
*));
4362 if (section_headers_groups
== NULL
)
4364 error (_("Out of memory\n"));
4368 /* Scan the sections for the group section. */
4370 for (i
= 0, section
= section_headers
;
4371 i
< elf_header
.e_shnum
;
4373 if (section
->sh_type
== SHT_GROUP
)
4376 if (group_count
== 0)
4378 if (do_section_groups
)
4379 printf (_("\nThere are no section groups in this file.\n"));
4384 section_groups
= calloc (group_count
, sizeof (struct group
));
4386 if (section_groups
== NULL
)
4388 error (_("Out of memory\n"));
4397 for (i
= 0, section
= section_headers
, group
= section_groups
;
4398 i
< elf_header
.e_shnum
;
4401 if (section
->sh_type
== SHT_GROUP
)
4403 char *name
= SECTION_NAME (section
);
4405 unsigned char *start
, *indices
;
4406 unsigned int entry
, j
, size
;
4407 Elf_Internal_Shdr
*sec
;
4408 Elf_Internal_Sym
*sym
;
4410 /* Get the symbol table. */
4411 if (SECTION_HEADER_INDEX (section
->sh_link
) >= elf_header
.e_shnum
4412 || ((sec
= SECTION_HEADER (section
->sh_link
))->sh_type
4415 error (_("Bad sh_link in group section `%s'\n"), name
);
4419 if (symtab_sec
!= sec
)
4424 symtab
= GET_ELF_SYMBOLS (file
, symtab_sec
);
4427 sym
= symtab
+ section
->sh_info
;
4429 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
4431 bfd_vma sec_index
= SECTION_HEADER_INDEX (sym
->st_shndx
);
4434 error (_("Bad sh_info in group section `%s'\n"), name
);
4438 group_name
= SECTION_NAME (section_headers
+ sec_index
);
4447 /* Get the string table. */
4448 if (SECTION_HEADER_INDEX (symtab_sec
->sh_link
)
4449 >= elf_header
.e_shnum
)
4458 != (sec
= SECTION_HEADER (symtab_sec
->sh_link
)))
4463 strtab
= get_data (NULL
, file
, strtab_sec
->sh_offset
,
4464 1, strtab_sec
->sh_size
,
4466 strtab_size
= strtab
!= NULL
? strtab_sec
->sh_size
: 0;
4468 group_name
= sym
->st_name
< strtab_size
4469 ? strtab
+ sym
->st_name
: "<corrupt>";
4472 start
= get_data (NULL
, file
, section
->sh_offset
,
4473 1, section
->sh_size
, _("section data"));
4476 size
= (section
->sh_size
/ section
->sh_entsize
) - 1;
4477 entry
= byte_get (indices
, 4);
4480 if (do_section_groups
)
4482 printf ("\n%s group section [%5u] `%s' [%s] contains %u sections:\n",
4483 get_group_flags (entry
), i
, name
, group_name
, size
);
4485 printf (_(" [Index] Name\n"));
4488 group
->group_index
= i
;
4490 for (j
= 0; j
< size
; j
++)
4492 struct group_list
*g
;
4494 entry
= byte_get (indices
, 4);
4497 if (SECTION_HEADER_INDEX (entry
) >= elf_header
.e_shnum
)
4499 error (_("section [%5u] in group section [%5u] > maximum section [%5u]\n"),
4500 entry
, i
, elf_header
.e_shnum
- 1);
4503 else if (entry
>= SHN_LORESERVE
&& entry
<= SHN_HIRESERVE
)
4505 error (_("invalid section [%5u] in group section [%5u]\n"),
4510 if (section_headers_groups
[SECTION_HEADER_INDEX (entry
)]
4515 error (_("section [%5u] in group section [%5u] already in group section [%5u]\n"),
4517 section_headers_groups
[SECTION_HEADER_INDEX (entry
)]->group_index
);
4522 /* Intel C/C++ compiler may put section 0 in a
4523 section group. We just warn it the first time
4524 and ignore it afterwards. */
4525 static int warned
= 0;
4528 error (_("section 0 in group section [%5u]\n"),
4529 section_headers_groups
[SECTION_HEADER_INDEX (entry
)]->group_index
);
4535 section_headers_groups
[SECTION_HEADER_INDEX (entry
)]
4538 if (do_section_groups
)
4540 sec
= SECTION_HEADER (entry
);
4541 printf (" [%5u] %s\n", entry
, SECTION_NAME (sec
));
4544 g
= xmalloc (sizeof (struct group_list
));
4545 g
->section_index
= entry
;
4546 g
->next
= group
->root
;
4570 } dynamic_relocations
[] =
4572 { "REL", DT_REL
, DT_RELSZ
, FALSE
},
4573 { "RELA", DT_RELA
, DT_RELASZ
, TRUE
},
4574 { "PLT", DT_JMPREL
, DT_PLTRELSZ
, UNKNOWN
}
4577 /* Process the reloc section. */
4580 process_relocs (FILE *file
)
4582 unsigned long rel_size
;
4583 unsigned long rel_offset
;
4589 if (do_using_dynamic
)
4593 int has_dynamic_reloc
;
4596 has_dynamic_reloc
= 0;
4598 for (i
= 0; i
< ARRAY_SIZE (dynamic_relocations
); i
++)
4600 is_rela
= dynamic_relocations
[i
].rela
;
4601 name
= dynamic_relocations
[i
].name
;
4602 rel_size
= dynamic_info
[dynamic_relocations
[i
].size
];
4603 rel_offset
= dynamic_info
[dynamic_relocations
[i
].reloc
];
4605 has_dynamic_reloc
|= rel_size
;
4607 if (is_rela
== UNKNOWN
)
4609 if (dynamic_relocations
[i
].reloc
== DT_JMPREL
)
4610 switch (dynamic_info
[DT_PLTREL
])
4624 (_("\n'%s' relocation section at offset 0x%lx contains %ld bytes:\n"),
4625 name
, rel_offset
, rel_size
);
4627 dump_relocations (file
,
4628 offset_from_vma (file
, rel_offset
, rel_size
),
4630 dynamic_symbols
, num_dynamic_syms
,
4631 dynamic_strings
, dynamic_strings_length
, is_rela
);
4635 if (! has_dynamic_reloc
)
4636 printf (_("\nThere are no dynamic relocations in this file.\n"));
4640 Elf_Internal_Shdr
*section
;
4644 for (i
= 0, section
= section_headers
;
4645 i
< elf_header
.e_shnum
;
4648 if ( section
->sh_type
!= SHT_RELA
4649 && section
->sh_type
!= SHT_REL
)
4652 rel_offset
= section
->sh_offset
;
4653 rel_size
= section
->sh_size
;
4657 Elf_Internal_Shdr
*strsec
;
4660 printf (_("\nRelocation section "));
4662 if (string_table
== NULL
)
4663 printf ("%d", section
->sh_name
);
4665 printf (_("'%s'"), SECTION_NAME (section
));
4667 printf (_(" at offset 0x%lx contains %lu entries:\n"),
4668 rel_offset
, (unsigned long) (rel_size
/ section
->sh_entsize
));
4670 is_rela
= section
->sh_type
== SHT_RELA
;
4672 if (section
->sh_link
4673 && SECTION_HEADER_INDEX (section
->sh_link
)
4674 < elf_header
.e_shnum
)
4676 Elf_Internal_Shdr
*symsec
;
4677 Elf_Internal_Sym
*symtab
;
4678 unsigned long nsyms
;
4679 unsigned long strtablen
= 0;
4680 char *strtab
= NULL
;
4682 symsec
= SECTION_HEADER (section
->sh_link
);
4683 if (symsec
->sh_type
!= SHT_SYMTAB
4684 && symsec
->sh_type
!= SHT_DYNSYM
)
4687 nsyms
= symsec
->sh_size
/ symsec
->sh_entsize
;
4688 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
4693 if (SECTION_HEADER_INDEX (symsec
->sh_link
)
4694 < elf_header
.e_shnum
)
4696 strsec
= SECTION_HEADER (symsec
->sh_link
);
4698 strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
4701 strtablen
= strtab
== NULL
? 0 : strsec
->sh_size
;
4704 dump_relocations (file
, rel_offset
, rel_size
,
4705 symtab
, nsyms
, strtab
, strtablen
, is_rela
);
4711 dump_relocations (file
, rel_offset
, rel_size
,
4712 NULL
, 0, NULL
, 0, is_rela
);
4719 printf (_("\nThere are no relocations in this file.\n"));
4725 /* Process the unwind section. */
4727 #include "unwind-ia64.h"
4729 /* An absolute address consists of a section and an offset. If the
4730 section is NULL, the offset itself is the address, otherwise, the
4731 address equals to LOAD_ADDRESS(section) + offset. */
4735 unsigned short section
;
4739 #define ABSADDR(a) \
4741 ? section_headers [(a).section].sh_addr + (a).offset \
4744 struct ia64_unw_aux_info
4746 struct ia64_unw_table_entry
4748 struct absaddr start
;
4750 struct absaddr info
;
4752 *table
; /* Unwind table. */
4753 unsigned long table_len
; /* Length of unwind table. */
4754 unsigned char *info
; /* Unwind info. */
4755 unsigned long info_size
; /* Size of unwind info. */
4756 bfd_vma info_addr
; /* starting address of unwind info. */
4757 bfd_vma seg_base
; /* Starting address of segment. */
4758 Elf_Internal_Sym
*symtab
; /* The symbol table. */
4759 unsigned long nsyms
; /* Number of symbols. */
4760 char *strtab
; /* The string table. */
4761 unsigned long strtab_size
; /* Size of string table. */
4765 find_symbol_for_address (Elf_Internal_Sym
*symtab
,
4766 unsigned long nsyms
,
4768 unsigned long strtab_size
,
4769 struct absaddr addr
,
4770 const char **symname
,
4773 bfd_vma dist
= 0x100000;
4774 Elf_Internal_Sym
*sym
, *best
= NULL
;
4777 for (i
= 0, sym
= symtab
; i
< nsyms
; ++i
, ++sym
)
4779 if (ELF_ST_TYPE (sym
->st_info
) == STT_FUNC
4780 && sym
->st_name
!= 0
4781 && (addr
.section
== SHN_UNDEF
|| addr
.section
== sym
->st_shndx
)
4782 && addr
.offset
>= sym
->st_value
4783 && addr
.offset
- sym
->st_value
< dist
)
4786 dist
= addr
.offset
- sym
->st_value
;
4793 *symname
= (best
->st_name
>= strtab_size
4794 ? "<corrupt>" : strtab
+ best
->st_name
);
4799 *offset
= addr
.offset
;
4803 dump_ia64_unwind (struct ia64_unw_aux_info
*aux
)
4805 struct ia64_unw_table_entry
*tp
;
4808 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
4812 const unsigned char *dp
;
4813 const unsigned char *head
;
4814 const char *procname
;
4816 find_symbol_for_address (aux
->symtab
, aux
->nsyms
, aux
->strtab
,
4817 aux
->strtab_size
, tp
->start
, &procname
, &offset
);
4819 fputs ("\n<", stdout
);
4823 fputs (procname
, stdout
);
4826 printf ("+%lx", (unsigned long) offset
);
4829 fputs (">: [", stdout
);
4830 print_vma (tp
->start
.offset
, PREFIX_HEX
);
4831 fputc ('-', stdout
);
4832 print_vma (tp
->end
.offset
, PREFIX_HEX
);
4833 printf ("], info at +0x%lx\n",
4834 (unsigned long) (tp
->info
.offset
- aux
->seg_base
));
4836 head
= aux
->info
+ (ABSADDR (tp
->info
) - aux
->info_addr
);
4837 stamp
= byte_get ((unsigned char *) head
, sizeof (stamp
));
4839 printf (" v%u, flags=0x%lx (%s%s), len=%lu bytes\n",
4840 (unsigned) UNW_VER (stamp
),
4841 (unsigned long) ((stamp
& UNW_FLAG_MASK
) >> 32),
4842 UNW_FLAG_EHANDLER (stamp
) ? " ehandler" : "",
4843 UNW_FLAG_UHANDLER (stamp
) ? " uhandler" : "",
4844 (unsigned long) (eh_addr_size
* UNW_LENGTH (stamp
)));
4846 if (UNW_VER (stamp
) != 1)
4848 printf ("\tUnknown version.\n");
4853 for (dp
= head
+ 8; dp
< head
+ 8 + eh_addr_size
* UNW_LENGTH (stamp
);)
4854 dp
= unw_decode (dp
, in_body
, & in_body
);
4859 slurp_ia64_unwind_table (FILE *file
,
4860 struct ia64_unw_aux_info
*aux
,
4861 Elf_Internal_Shdr
*sec
)
4863 unsigned long size
, nrelas
, i
;
4864 Elf_Internal_Phdr
*seg
;
4865 struct ia64_unw_table_entry
*tep
;
4866 Elf_Internal_Shdr
*relsec
;
4867 Elf_Internal_Rela
*rela
, *rp
;
4868 unsigned char *table
, *tp
;
4869 Elf_Internal_Sym
*sym
;
4870 const char *relname
;
4872 /* First, find the starting address of the segment that includes
4875 if (elf_header
.e_phnum
)
4877 if (! get_program_headers (file
))
4880 for (seg
= program_headers
;
4881 seg
< program_headers
+ elf_header
.e_phnum
;
4884 if (seg
->p_type
!= PT_LOAD
)
4887 if (sec
->sh_addr
>= seg
->p_vaddr
4888 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
4890 aux
->seg_base
= seg
->p_vaddr
;
4896 /* Second, build the unwind table from the contents of the unwind section: */
4897 size
= sec
->sh_size
;
4898 table
= get_data (NULL
, file
, sec
->sh_offset
, 1, size
, _("unwind table"));
4902 aux
->table
= xcmalloc (size
/ (3 * eh_addr_size
), sizeof (aux
->table
[0]));
4904 for (tp
= table
; tp
< table
+ size
; tp
+= 3 * eh_addr_size
, ++tep
)
4906 tep
->start
.section
= SHN_UNDEF
;
4907 tep
->end
.section
= SHN_UNDEF
;
4908 tep
->info
.section
= SHN_UNDEF
;
4911 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
4912 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
4913 tep
->info
.offset
= byte_get ((unsigned char *) tp
+ 8, 4);
4917 tep
->start
.offset
= BYTE_GET ((unsigned char *) tp
+ 0);
4918 tep
->end
.offset
= BYTE_GET ((unsigned char *) tp
+ 8);
4919 tep
->info
.offset
= BYTE_GET ((unsigned char *) tp
+ 16);
4921 tep
->start
.offset
+= aux
->seg_base
;
4922 tep
->end
.offset
+= aux
->seg_base
;
4923 tep
->info
.offset
+= aux
->seg_base
;
4927 /* Third, apply any relocations to the unwind table: */
4929 for (relsec
= section_headers
;
4930 relsec
< section_headers
+ elf_header
.e_shnum
;
4933 if (relsec
->sh_type
!= SHT_RELA
4934 || SECTION_HEADER_INDEX (relsec
->sh_info
) >= elf_header
.e_shnum
4935 || SECTION_HEADER (relsec
->sh_info
) != sec
)
4938 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
4942 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
4946 relname
= elf_ia64_reloc_type (ELF32_R_TYPE (rp
->r_info
));
4947 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
4951 relname
= elf_ia64_reloc_type (ELF64_R_TYPE (rp
->r_info
));
4952 sym
= aux
->symtab
+ ELF64_R_SYM (rp
->r_info
);
4955 if (! const_strneq (relname
, "R_IA64_SEGREL"))
4957 warn (_("Skipping unexpected relocation type %s\n"), relname
);
4961 i
= rp
->r_offset
/ (3 * eh_addr_size
);
4963 switch (rp
->r_offset
/eh_addr_size
% 3)
4966 aux
->table
[i
].start
.section
= sym
->st_shndx
;
4967 aux
->table
[i
].start
.offset
+= rp
->r_addend
+ sym
->st_value
;
4970 aux
->table
[i
].end
.section
= sym
->st_shndx
;
4971 aux
->table
[i
].end
.offset
+= rp
->r_addend
+ sym
->st_value
;
4974 aux
->table
[i
].info
.section
= sym
->st_shndx
;
4975 aux
->table
[i
].info
.offset
+= rp
->r_addend
+ sym
->st_value
;
4985 aux
->table_len
= size
/ (3 * eh_addr_size
);
4990 ia64_process_unwind (FILE *file
)
4992 Elf_Internal_Shdr
*sec
, *unwsec
= NULL
, *strsec
;
4993 unsigned long i
, unwcount
= 0, unwstart
= 0;
4994 struct ia64_unw_aux_info aux
;
4996 memset (& aux
, 0, sizeof (aux
));
4998 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5000 if (sec
->sh_type
== SHT_SYMTAB
5001 && SECTION_HEADER_INDEX (sec
->sh_link
) < elf_header
.e_shnum
)
5003 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
5004 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
5006 strsec
= SECTION_HEADER (sec
->sh_link
);
5007 aux
.strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
5008 1, strsec
->sh_size
, _("string table"));
5009 aux
.strtab_size
= aux
.strtab
!= NULL
? strsec
->sh_size
: 0;
5011 else if (sec
->sh_type
== SHT_IA_64_UNWIND
)
5016 printf (_("\nThere are no unwind sections in this file.\n"));
5018 while (unwcount
-- > 0)
5023 for (i
= unwstart
, sec
= section_headers
+ unwstart
;
5024 i
< elf_header
.e_shnum
; ++i
, ++sec
)
5025 if (sec
->sh_type
== SHT_IA_64_UNWIND
)
5032 len
= sizeof (ELF_STRING_ia64_unwind_once
) - 1;
5034 if ((unwsec
->sh_flags
& SHF_GROUP
) != 0)
5036 /* We need to find which section group it is in. */
5037 struct group_list
*g
= section_headers_groups
[i
]->root
;
5039 for (; g
!= NULL
; g
= g
->next
)
5041 sec
= SECTION_HEADER (g
->section_index
);
5043 if (streq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info
))
5048 i
= elf_header
.e_shnum
;
5050 else if (strneq (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind_once
, len
))
5052 /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO. */
5053 len2
= sizeof (ELF_STRING_ia64_unwind_info_once
) - 1;
5054 suffix
= SECTION_NAME (unwsec
) + len
;
5055 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
5057 if (strneq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info_once
, len2
)
5058 && streq (SECTION_NAME (sec
) + len2
, suffix
))
5063 /* .IA_64.unwindFOO -> .IA_64.unwind_infoFOO
5064 .IA_64.unwind or BAR -> .IA_64.unwind_info. */
5065 len
= sizeof (ELF_STRING_ia64_unwind
) - 1;
5066 len2
= sizeof (ELF_STRING_ia64_unwind_info
) - 1;
5068 if (strneq (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind
, len
))
5069 suffix
= SECTION_NAME (unwsec
) + len
;
5070 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
5072 if (strneq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info
, len2
)
5073 && streq (SECTION_NAME (sec
) + len2
, suffix
))
5077 if (i
== elf_header
.e_shnum
)
5079 printf (_("\nCould not find unwind info section for "));
5081 if (string_table
== NULL
)
5082 printf ("%d", unwsec
->sh_name
);
5084 printf (_("'%s'"), SECTION_NAME (unwsec
));
5088 aux
.info_size
= sec
->sh_size
;
5089 aux
.info_addr
= sec
->sh_addr
;
5090 aux
.info
= get_data (NULL
, file
, sec
->sh_offset
, 1, aux
.info_size
,
5093 printf (_("\nUnwind section "));
5095 if (string_table
== NULL
)
5096 printf ("%d", unwsec
->sh_name
);
5098 printf (_("'%s'"), SECTION_NAME (unwsec
));
5100 printf (_(" at offset 0x%lx contains %lu entries:\n"),
5101 (unsigned long) unwsec
->sh_offset
,
5102 (unsigned long) (unwsec
->sh_size
/ (3 * eh_addr_size
)));
5104 (void) slurp_ia64_unwind_table (file
, & aux
, unwsec
);
5106 if (aux
.table_len
> 0)
5107 dump_ia64_unwind (& aux
);
5110 free ((char *) aux
.table
);
5112 free ((char *) aux
.info
);
5121 free ((char *) aux
.strtab
);
5126 struct hppa_unw_aux_info
5128 struct hppa_unw_table_entry
5130 struct absaddr start
;
5132 unsigned int Cannot_unwind
:1; /* 0 */
5133 unsigned int Millicode
:1; /* 1 */
5134 unsigned int Millicode_save_sr0
:1; /* 2 */
5135 unsigned int Region_description
:2; /* 3..4 */
5136 unsigned int reserved1
:1; /* 5 */
5137 unsigned int Entry_SR
:1; /* 6 */
5138 unsigned int Entry_FR
:4; /* number saved */ /* 7..10 */
5139 unsigned int Entry_GR
:5; /* number saved */ /* 11..15 */
5140 unsigned int Args_stored
:1; /* 16 */
5141 unsigned int Variable_Frame
:1; /* 17 */
5142 unsigned int Separate_Package_Body
:1; /* 18 */
5143 unsigned int Frame_Extension_Millicode
:1; /* 19 */
5144 unsigned int Stack_Overflow_Check
:1; /* 20 */
5145 unsigned int Two_Instruction_SP_Increment
:1; /* 21 */
5146 unsigned int Ada_Region
:1; /* 22 */
5147 unsigned int cxx_info
:1; /* 23 */
5148 unsigned int cxx_try_catch
:1; /* 24 */
5149 unsigned int sched_entry_seq
:1; /* 25 */
5150 unsigned int reserved2
:1; /* 26 */
5151 unsigned int Save_SP
:1; /* 27 */
5152 unsigned int Save_RP
:1; /* 28 */
5153 unsigned int Save_MRP_in_frame
:1; /* 29 */
5154 unsigned int extn_ptr_defined
:1; /* 30 */
5155 unsigned int Cleanup_defined
:1; /* 31 */
5157 unsigned int MPE_XL_interrupt_marker
:1; /* 0 */
5158 unsigned int HP_UX_interrupt_marker
:1; /* 1 */
5159 unsigned int Large_frame
:1; /* 2 */
5160 unsigned int Pseudo_SP_Set
:1; /* 3 */
5161 unsigned int reserved4
:1; /* 4 */
5162 unsigned int Total_frame_size
:27; /* 5..31 */
5164 *table
; /* Unwind table. */
5165 unsigned long table_len
; /* Length of unwind table. */
5166 bfd_vma seg_base
; /* Starting address of segment. */
5167 Elf_Internal_Sym
*symtab
; /* The symbol table. */
5168 unsigned long nsyms
; /* Number of symbols. */
5169 char *strtab
; /* The string table. */
5170 unsigned long strtab_size
; /* Size of string table. */
5174 dump_hppa_unwind (struct hppa_unw_aux_info
*aux
)
5176 struct hppa_unw_table_entry
*tp
;
5178 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
5181 const char *procname
;
5183 find_symbol_for_address (aux
->symtab
, aux
->nsyms
, aux
->strtab
,
5184 aux
->strtab_size
, tp
->start
, &procname
,
5187 fputs ("\n<", stdout
);
5191 fputs (procname
, stdout
);
5194 printf ("+%lx", (unsigned long) offset
);
5197 fputs (">: [", stdout
);
5198 print_vma (tp
->start
.offset
, PREFIX_HEX
);
5199 fputc ('-', stdout
);
5200 print_vma (tp
->end
.offset
, PREFIX_HEX
);
5203 #define PF(_m) if (tp->_m) printf (#_m " ");
5204 #define PV(_m) if (tp->_m) printf (#_m "=%d ", tp->_m);
5207 PF(Millicode_save_sr0
);
5208 /* PV(Region_description); */
5214 PF(Separate_Package_Body
);
5215 PF(Frame_Extension_Millicode
);
5216 PF(Stack_Overflow_Check
);
5217 PF(Two_Instruction_SP_Increment
);
5221 PF(sched_entry_seq
);
5224 PF(Save_MRP_in_frame
);
5225 PF(extn_ptr_defined
);
5226 PF(Cleanup_defined
);
5227 PF(MPE_XL_interrupt_marker
);
5228 PF(HP_UX_interrupt_marker
);
5231 PV(Total_frame_size
);
5240 slurp_hppa_unwind_table (FILE *file
,
5241 struct hppa_unw_aux_info
*aux
,
5242 Elf_Internal_Shdr
*sec
)
5244 unsigned long size
, unw_ent_size
, nentries
, nrelas
, i
;
5245 Elf_Internal_Phdr
*seg
;
5246 struct hppa_unw_table_entry
*tep
;
5247 Elf_Internal_Shdr
*relsec
;
5248 Elf_Internal_Rela
*rela
, *rp
;
5249 unsigned char *table
, *tp
;
5250 Elf_Internal_Sym
*sym
;
5251 const char *relname
;
5253 /* First, find the starting address of the segment that includes
5256 if (elf_header
.e_phnum
)
5258 if (! get_program_headers (file
))
5261 for (seg
= program_headers
;
5262 seg
< program_headers
+ elf_header
.e_phnum
;
5265 if (seg
->p_type
!= PT_LOAD
)
5268 if (sec
->sh_addr
>= seg
->p_vaddr
5269 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
5271 aux
->seg_base
= seg
->p_vaddr
;
5277 /* Second, build the unwind table from the contents of the unwind
5279 size
= sec
->sh_size
;
5280 table
= get_data (NULL
, file
, sec
->sh_offset
, 1, size
, _("unwind table"));
5285 nentries
= size
/ unw_ent_size
;
5286 size
= unw_ent_size
* nentries
;
5288 tep
= aux
->table
= xcmalloc (nentries
, sizeof (aux
->table
[0]));
5290 for (tp
= table
; tp
< table
+ size
; tp
+= unw_ent_size
, ++tep
)
5292 unsigned int tmp1
, tmp2
;
5294 tep
->start
.section
= SHN_UNDEF
;
5295 tep
->end
.section
= SHN_UNDEF
;
5297 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
5298 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
5299 tmp1
= byte_get ((unsigned char *) tp
+ 8, 4);
5300 tmp2
= byte_get ((unsigned char *) tp
+ 12, 4);
5302 tep
->start
.offset
+= aux
->seg_base
;
5303 tep
->end
.offset
+= aux
->seg_base
;
5305 tep
->Cannot_unwind
= (tmp1
>> 31) & 0x1;
5306 tep
->Millicode
= (tmp1
>> 30) & 0x1;
5307 tep
->Millicode_save_sr0
= (tmp1
>> 29) & 0x1;
5308 tep
->Region_description
= (tmp1
>> 27) & 0x3;
5309 tep
->reserved1
= (tmp1
>> 26) & 0x1;
5310 tep
->Entry_SR
= (tmp1
>> 25) & 0x1;
5311 tep
->Entry_FR
= (tmp1
>> 21) & 0xf;
5312 tep
->Entry_GR
= (tmp1
>> 16) & 0x1f;
5313 tep
->Args_stored
= (tmp1
>> 15) & 0x1;
5314 tep
->Variable_Frame
= (tmp1
>> 14) & 0x1;
5315 tep
->Separate_Package_Body
= (tmp1
>> 13) & 0x1;
5316 tep
->Frame_Extension_Millicode
= (tmp1
>> 12) & 0x1;
5317 tep
->Stack_Overflow_Check
= (tmp1
>> 11) & 0x1;
5318 tep
->Two_Instruction_SP_Increment
= (tmp1
>> 10) & 0x1;
5319 tep
->Ada_Region
= (tmp1
>> 9) & 0x1;
5320 tep
->cxx_info
= (tmp1
>> 8) & 0x1;
5321 tep
->cxx_try_catch
= (tmp1
>> 7) & 0x1;
5322 tep
->sched_entry_seq
= (tmp1
>> 6) & 0x1;
5323 tep
->reserved2
= (tmp1
>> 5) & 0x1;
5324 tep
->Save_SP
= (tmp1
>> 4) & 0x1;
5325 tep
->Save_RP
= (tmp1
>> 3) & 0x1;
5326 tep
->Save_MRP_in_frame
= (tmp1
>> 2) & 0x1;
5327 tep
->extn_ptr_defined
= (tmp1
>> 1) & 0x1;
5328 tep
->Cleanup_defined
= tmp1
& 0x1;
5330 tep
->MPE_XL_interrupt_marker
= (tmp2
>> 31) & 0x1;
5331 tep
->HP_UX_interrupt_marker
= (tmp2
>> 30) & 0x1;
5332 tep
->Large_frame
= (tmp2
>> 29) & 0x1;
5333 tep
->Pseudo_SP_Set
= (tmp2
>> 28) & 0x1;
5334 tep
->reserved4
= (tmp2
>> 27) & 0x1;
5335 tep
->Total_frame_size
= tmp2
& 0x7ffffff;
5339 /* Third, apply any relocations to the unwind table. */
5341 for (relsec
= section_headers
;
5342 relsec
< section_headers
+ elf_header
.e_shnum
;
5345 if (relsec
->sh_type
!= SHT_RELA
5346 || SECTION_HEADER_INDEX (relsec
->sh_info
) >= elf_header
.e_shnum
5347 || SECTION_HEADER (relsec
->sh_info
) != sec
)
5350 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
5354 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
5358 relname
= elf_hppa_reloc_type (ELF32_R_TYPE (rp
->r_info
));
5359 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
5363 relname
= elf_hppa_reloc_type (ELF64_R_TYPE (rp
->r_info
));
5364 sym
= aux
->symtab
+ ELF64_R_SYM (rp
->r_info
);
5367 /* R_PARISC_SEGREL32 or R_PARISC_SEGREL64. */
5368 if (! const_strneq (relname
, "R_PARISC_SEGREL"))
5370 warn (_("Skipping unexpected relocation type %s\n"), relname
);
5374 i
= rp
->r_offset
/ unw_ent_size
;
5376 switch ((rp
->r_offset
% unw_ent_size
) / eh_addr_size
)
5379 aux
->table
[i
].start
.section
= sym
->st_shndx
;
5380 aux
->table
[i
].start
.offset
+= sym
->st_value
+ rp
->r_addend
;
5383 aux
->table
[i
].end
.section
= sym
->st_shndx
;
5384 aux
->table
[i
].end
.offset
+= sym
->st_value
+ rp
->r_addend
;
5394 aux
->table_len
= nentries
;
5400 hppa_process_unwind (FILE *file
)
5402 struct hppa_unw_aux_info aux
;
5403 Elf_Internal_Shdr
*unwsec
= NULL
;
5404 Elf_Internal_Shdr
*strsec
;
5405 Elf_Internal_Shdr
*sec
;
5408 memset (& aux
, 0, sizeof (aux
));
5410 if (string_table
== NULL
)
5413 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5415 if (sec
->sh_type
== SHT_SYMTAB
5416 && SECTION_HEADER_INDEX (sec
->sh_link
) < elf_header
.e_shnum
)
5418 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
5419 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
5421 strsec
= SECTION_HEADER (sec
->sh_link
);
5422 aux
.strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
5423 1, strsec
->sh_size
, _("string table"));
5424 aux
.strtab_size
= aux
.strtab
!= NULL
? strsec
->sh_size
: 0;
5426 else if (streq (SECTION_NAME (sec
), ".PARISC.unwind"))
5431 printf (_("\nThere are no unwind sections in this file.\n"));
5433 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5435 if (streq (SECTION_NAME (sec
), ".PARISC.unwind"))
5437 printf (_("\nUnwind section "));
5438 printf (_("'%s'"), SECTION_NAME (sec
));
5440 printf (_(" at offset 0x%lx contains %lu entries:\n"),
5441 (unsigned long) sec
->sh_offset
,
5442 (unsigned long) (sec
->sh_size
/ (2 * eh_addr_size
+ 8)));
5444 slurp_hppa_unwind_table (file
, &aux
, sec
);
5445 if (aux
.table_len
> 0)
5446 dump_hppa_unwind (&aux
);
5449 free ((char *) aux
.table
);
5457 free ((char *) aux
.strtab
);
5463 process_unwind (FILE *file
)
5465 struct unwind_handler
{
5467 int (*handler
)(FILE *file
);
5469 { EM_IA_64
, ia64_process_unwind
},
5470 { EM_PARISC
, hppa_process_unwind
},
5478 for (i
= 0; handlers
[i
].handler
!= NULL
; i
++)
5479 if (elf_header
.e_machine
== handlers
[i
].machtype
)
5480 return handlers
[i
].handler (file
);
5482 printf (_("\nThere are no unwind sections in this file.\n"));
5487 dynamic_section_mips_val (Elf_Internal_Dyn
*entry
)
5489 switch (entry
->d_tag
)
5492 if (entry
->d_un
.d_val
== 0)
5496 static const char * opts
[] =
5498 "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT",
5499 "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS",
5500 "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD",
5501 "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF",
5506 for (cnt
= 0; cnt
< NUM_ELEM (opts
); ++cnt
)
5507 if (entry
->d_un
.d_val
& (1 << cnt
))
5509 printf ("%s%s", first
? "" : " ", opts
[cnt
]);
5516 case DT_MIPS_IVERSION
:
5517 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
5518 printf ("Interface Version: %s\n", GET_DYNAMIC_NAME (entry
->d_un
.d_val
));
5520 printf ("<corrupt: %ld>\n", (long) entry
->d_un
.d_ptr
);
5523 case DT_MIPS_TIME_STAMP
:
5528 time_t time
= entry
->d_un
.d_val
;
5529 tmp
= gmtime (&time
);
5530 snprintf (timebuf
, sizeof (timebuf
), "%04u-%02u-%02uT%02u:%02u:%02u",
5531 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
5532 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
5533 printf ("Time Stamp: %s\n", timebuf
);
5537 case DT_MIPS_RLD_VERSION
:
5538 case DT_MIPS_LOCAL_GOTNO
:
5539 case DT_MIPS_CONFLICTNO
:
5540 case DT_MIPS_LIBLISTNO
:
5541 case DT_MIPS_SYMTABNO
:
5542 case DT_MIPS_UNREFEXTNO
:
5543 case DT_MIPS_HIPAGENO
:
5544 case DT_MIPS_DELTA_CLASS_NO
:
5545 case DT_MIPS_DELTA_INSTANCE_NO
:
5546 case DT_MIPS_DELTA_RELOC_NO
:
5547 case DT_MIPS_DELTA_SYM_NO
:
5548 case DT_MIPS_DELTA_CLASSSYM_NO
:
5549 case DT_MIPS_COMPACT_SIZE
:
5550 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
5554 printf ("%#lx\n", (long) entry
->d_un
.d_ptr
);
5560 dynamic_section_parisc_val (Elf_Internal_Dyn
*entry
)
5562 switch (entry
->d_tag
)
5564 case DT_HP_DLD_FLAGS
:
5573 { DT_HP_DEBUG_PRIVATE
, "HP_DEBUG_PRIVATE" },
5574 { DT_HP_DEBUG_CALLBACK
, "HP_DEBUG_CALLBACK" },
5575 { DT_HP_DEBUG_CALLBACK_BOR
, "HP_DEBUG_CALLBACK_BOR" },
5576 { DT_HP_NO_ENVVAR
, "HP_NO_ENVVAR" },
5577 { DT_HP_BIND_NOW
, "HP_BIND_NOW" },
5578 { DT_HP_BIND_NONFATAL
, "HP_BIND_NONFATAL" },
5579 { DT_HP_BIND_VERBOSE
, "HP_BIND_VERBOSE" },
5580 { DT_HP_BIND_RESTRICTED
, "HP_BIND_RESTRICTED" },
5581 { DT_HP_BIND_SYMBOLIC
, "HP_BIND_SYMBOLIC" },
5582 { DT_HP_RPATH_FIRST
, "HP_RPATH_FIRST" },
5583 { DT_HP_BIND_DEPTH_FIRST
, "HP_BIND_DEPTH_FIRST" },
5584 { DT_HP_GST
, "HP_GST" },
5585 { DT_HP_SHLIB_FIXED
, "HP_SHLIB_FIXED" },
5586 { DT_HP_MERGE_SHLIB_SEG
, "HP_MERGE_SHLIB_SEG" },
5587 { DT_HP_NODELETE
, "HP_NODELETE" },
5588 { DT_HP_GROUP
, "HP_GROUP" },
5589 { DT_HP_PROTECT_LINKAGE_TABLE
, "HP_PROTECT_LINKAGE_TABLE" }
5593 bfd_vma val
= entry
->d_un
.d_val
;
5595 for (cnt
= 0; cnt
< sizeof (flags
) / sizeof (flags
[0]); ++cnt
)
5596 if (val
& flags
[cnt
].bit
)
5600 fputs (flags
[cnt
].str
, stdout
);
5602 val
^= flags
[cnt
].bit
;
5605 if (val
!= 0 || first
)
5609 print_vma (val
, HEX
);
5615 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5622 dynamic_section_ia64_val (Elf_Internal_Dyn
*entry
)
5624 switch (entry
->d_tag
)
5626 case DT_IA_64_PLT_RESERVE
:
5627 /* First 3 slots reserved. */
5628 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5630 print_vma (entry
->d_un
.d_ptr
+ (3 * 8), PREFIX_HEX
);
5634 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5641 get_32bit_dynamic_section (FILE *file
)
5643 Elf32_External_Dyn
*edyn
, *ext
;
5644 Elf_Internal_Dyn
*entry
;
5646 edyn
= get_data (NULL
, file
, dynamic_addr
, 1, dynamic_size
,
5647 _("dynamic section"));
5651 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
5652 might not have the luxury of section headers. Look for the DT_NULL
5653 terminator to determine the number of entries. */
5654 for (ext
= edyn
, dynamic_nent
= 0;
5655 (char *) ext
< (char *) edyn
+ dynamic_size
;
5659 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
5663 dynamic_section
= cmalloc (dynamic_nent
, sizeof (*entry
));
5664 if (dynamic_section
== NULL
)
5666 error (_("Out of memory\n"));
5671 for (ext
= edyn
, entry
= dynamic_section
;
5672 entry
< dynamic_section
+ dynamic_nent
;
5675 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
5676 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
5685 get_64bit_dynamic_section (FILE *file
)
5687 Elf64_External_Dyn
*edyn
, *ext
;
5688 Elf_Internal_Dyn
*entry
;
5690 edyn
= get_data (NULL
, file
, dynamic_addr
, 1, dynamic_size
,
5691 _("dynamic section"));
5695 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
5696 might not have the luxury of section headers. Look for the DT_NULL
5697 terminator to determine the number of entries. */
5698 for (ext
= edyn
, dynamic_nent
= 0;
5699 (char *) ext
< (char *) edyn
+ dynamic_size
;
5703 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
5707 dynamic_section
= cmalloc (dynamic_nent
, sizeof (*entry
));
5708 if (dynamic_section
== NULL
)
5710 error (_("Out of memory\n"));
5715 for (ext
= edyn
, entry
= dynamic_section
;
5716 entry
< dynamic_section
+ dynamic_nent
;
5719 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
5720 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
5729 print_dynamic_flags (bfd_vma flags
)
5737 flag
= flags
& - flags
;
5747 case DF_ORIGIN
: fputs ("ORIGIN", stdout
); break;
5748 case DF_SYMBOLIC
: fputs ("SYMBOLIC", stdout
); break;
5749 case DF_TEXTREL
: fputs ("TEXTREL", stdout
); break;
5750 case DF_BIND_NOW
: fputs ("BIND_NOW", stdout
); break;
5751 case DF_STATIC_TLS
: fputs ("STATIC_TLS", stdout
); break;
5752 default: fputs ("unknown", stdout
); break;
5758 /* Parse and display the contents of the dynamic section. */
5761 process_dynamic_section (FILE *file
)
5763 Elf_Internal_Dyn
*entry
;
5765 if (dynamic_size
== 0)
5768 printf (_("\nThere is no dynamic section in this file.\n"));
5775 if (! get_32bit_dynamic_section (file
))
5778 else if (! get_64bit_dynamic_section (file
))
5781 /* Find the appropriate symbol table. */
5782 if (dynamic_symbols
== NULL
)
5784 for (entry
= dynamic_section
;
5785 entry
< dynamic_section
+ dynamic_nent
;
5788 Elf_Internal_Shdr section
;
5790 if (entry
->d_tag
!= DT_SYMTAB
)
5793 dynamic_info
[DT_SYMTAB
] = entry
->d_un
.d_val
;
5795 /* Since we do not know how big the symbol table is,
5796 we default to reading in the entire file (!) and
5797 processing that. This is overkill, I know, but it
5799 section
.sh_offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
5801 if (archive_file_offset
!= 0)
5802 section
.sh_size
= archive_file_size
- section
.sh_offset
;
5805 if (fseek (file
, 0, SEEK_END
))
5806 error (_("Unable to seek to end of file!"));
5808 section
.sh_size
= ftell (file
) - section
.sh_offset
;
5812 section
.sh_entsize
= sizeof (Elf32_External_Sym
);
5814 section
.sh_entsize
= sizeof (Elf64_External_Sym
);
5816 num_dynamic_syms
= section
.sh_size
/ section
.sh_entsize
;
5817 if (num_dynamic_syms
< 1)
5819 error (_("Unable to determine the number of symbols to load\n"));
5823 dynamic_symbols
= GET_ELF_SYMBOLS (file
, §ion
);
5827 /* Similarly find a string table. */
5828 if (dynamic_strings
== NULL
)
5830 for (entry
= dynamic_section
;
5831 entry
< dynamic_section
+ dynamic_nent
;
5834 unsigned long offset
;
5837 if (entry
->d_tag
!= DT_STRTAB
)
5840 dynamic_info
[DT_STRTAB
] = entry
->d_un
.d_val
;
5842 /* Since we do not know how big the string table is,
5843 we default to reading in the entire file (!) and
5844 processing that. This is overkill, I know, but it
5847 offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
5849 if (archive_file_offset
!= 0)
5850 str_tab_len
= archive_file_size
- offset
;
5853 if (fseek (file
, 0, SEEK_END
))
5854 error (_("Unable to seek to end of file\n"));
5855 str_tab_len
= ftell (file
) - offset
;
5858 if (str_tab_len
< 1)
5861 (_("Unable to determine the length of the dynamic string table\n"));
5865 dynamic_strings
= get_data (NULL
, file
, offset
, 1, str_tab_len
,
5866 _("dynamic string table"));
5867 dynamic_strings_length
= str_tab_len
;
5872 /* And find the syminfo section if available. */
5873 if (dynamic_syminfo
== NULL
)
5875 unsigned long syminsz
= 0;
5877 for (entry
= dynamic_section
;
5878 entry
< dynamic_section
+ dynamic_nent
;
5881 if (entry
->d_tag
== DT_SYMINENT
)
5883 /* Note: these braces are necessary to avoid a syntax
5884 error from the SunOS4 C compiler. */
5885 assert (sizeof (Elf_External_Syminfo
) == entry
->d_un
.d_val
);
5887 else if (entry
->d_tag
== DT_SYMINSZ
)
5888 syminsz
= entry
->d_un
.d_val
;
5889 else if (entry
->d_tag
== DT_SYMINFO
)
5890 dynamic_syminfo_offset
= offset_from_vma (file
, entry
->d_un
.d_val
,
5894 if (dynamic_syminfo_offset
!= 0 && syminsz
!= 0)
5896 Elf_External_Syminfo
*extsyminfo
, *extsym
;
5897 Elf_Internal_Syminfo
*syminfo
;
5899 /* There is a syminfo section. Read the data. */
5900 extsyminfo
= get_data (NULL
, file
, dynamic_syminfo_offset
, 1,
5901 syminsz
, _("symbol information"));
5905 dynamic_syminfo
= malloc (syminsz
);
5906 if (dynamic_syminfo
== NULL
)
5908 error (_("Out of memory\n"));
5912 dynamic_syminfo_nent
= syminsz
/ sizeof (Elf_External_Syminfo
);
5913 for (syminfo
= dynamic_syminfo
, extsym
= extsyminfo
;
5914 syminfo
< dynamic_syminfo
+ dynamic_syminfo_nent
;
5915 ++syminfo
, ++extsym
)
5917 syminfo
->si_boundto
= BYTE_GET (extsym
->si_boundto
);
5918 syminfo
->si_flags
= BYTE_GET (extsym
->si_flags
);
5925 if (do_dynamic
&& dynamic_addr
)
5926 printf (_("\nDynamic section at offset 0x%lx contains %u entries:\n"),
5927 dynamic_addr
, dynamic_nent
);
5929 printf (_(" Tag Type Name/Value\n"));
5931 for (entry
= dynamic_section
;
5932 entry
< dynamic_section
+ dynamic_nent
;
5940 print_vma (entry
->d_tag
, FULL_HEX
);
5941 dtype
= get_dynamic_type (entry
->d_tag
);
5942 printf (" (%s)%*s", dtype
,
5943 ((is_32bit_elf
? 27 : 19)
5944 - (int) strlen (dtype
)),
5948 switch (entry
->d_tag
)
5952 print_dynamic_flags (entry
->d_un
.d_val
);
5962 switch (entry
->d_tag
)
5965 printf (_("Auxiliary library"));
5969 printf (_("Filter library"));
5973 printf (_("Configuration file"));
5977 printf (_("Dependency audit library"));
5981 printf (_("Audit library"));
5985 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
5986 printf (": [%s]\n", GET_DYNAMIC_NAME (entry
->d_un
.d_val
));
5990 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
5999 printf (_("Flags:"));
6001 if (entry
->d_un
.d_val
== 0)
6002 printf (_(" None\n"));
6005 unsigned long int val
= entry
->d_un
.d_val
;
6007 if (val
& DTF_1_PARINIT
)
6009 printf (" PARINIT");
6010 val
^= DTF_1_PARINIT
;
6012 if (val
& DTF_1_CONFEXP
)
6014 printf (" CONFEXP");
6015 val
^= DTF_1_CONFEXP
;
6018 printf (" %lx", val
);
6027 printf (_("Flags:"));
6029 if (entry
->d_un
.d_val
== 0)
6030 printf (_(" None\n"));
6033 unsigned long int val
= entry
->d_un
.d_val
;
6035 if (val
& DF_P1_LAZYLOAD
)
6037 printf (" LAZYLOAD");
6038 val
^= DF_P1_LAZYLOAD
;
6040 if (val
& DF_P1_GROUPPERM
)
6042 printf (" GROUPPERM");
6043 val
^= DF_P1_GROUPPERM
;
6046 printf (" %lx", val
);
6055 printf (_("Flags:"));
6056 if (entry
->d_un
.d_val
== 0)
6057 printf (_(" None\n"));
6060 unsigned long int val
= entry
->d_un
.d_val
;
6067 if (val
& DF_1_GLOBAL
)
6072 if (val
& DF_1_GROUP
)
6077 if (val
& DF_1_NODELETE
)
6079 printf (" NODELETE");
6080 val
^= DF_1_NODELETE
;
6082 if (val
& DF_1_LOADFLTR
)
6084 printf (" LOADFLTR");
6085 val
^= DF_1_LOADFLTR
;
6087 if (val
& DF_1_INITFIRST
)
6089 printf (" INITFIRST");
6090 val
^= DF_1_INITFIRST
;
6092 if (val
& DF_1_NOOPEN
)
6097 if (val
& DF_1_ORIGIN
)
6102 if (val
& DF_1_DIRECT
)
6107 if (val
& DF_1_TRANS
)
6112 if (val
& DF_1_INTERPOSE
)
6114 printf (" INTERPOSE");
6115 val
^= DF_1_INTERPOSE
;
6117 if (val
& DF_1_NODEFLIB
)
6119 printf (" NODEFLIB");
6120 val
^= DF_1_NODEFLIB
;
6122 if (val
& DF_1_NODUMP
)
6127 if (val
& DF_1_CONLFAT
)
6129 printf (" CONLFAT");
6130 val
^= DF_1_CONLFAT
;
6133 printf (" %lx", val
);
6140 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6142 puts (get_dynamic_type (entry
->d_un
.d_val
));
6162 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6168 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
6169 name
= GET_DYNAMIC_NAME (entry
->d_un
.d_val
);
6175 switch (entry
->d_tag
)
6178 printf (_("Shared library: [%s]"), name
);
6180 if (streq (name
, program_interpreter
))
6181 printf (_(" program interpreter"));
6185 printf (_("Library soname: [%s]"), name
);
6189 printf (_("Library rpath: [%s]"), name
);
6193 printf (_("Library runpath: [%s]"), name
);
6197 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6202 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6215 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6219 case DT_INIT_ARRAYSZ
:
6220 case DT_FINI_ARRAYSZ
:
6221 case DT_GNU_CONFLICTSZ
:
6222 case DT_GNU_LIBLISTSZ
:
6225 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
6226 printf (" (bytes)\n");
6236 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
6249 if (entry
->d_tag
== DT_USED
6250 && VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
6252 char *name
= GET_DYNAMIC_NAME (entry
->d_un
.d_val
);
6256 printf (_("Not needed object: [%s]\n"), name
);
6261 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6267 /* The value of this entry is ignored. */
6272 case DT_GNU_PRELINKED
:
6276 time_t time
= entry
->d_un
.d_val
;
6278 tmp
= gmtime (&time
);
6279 printf ("%04u-%02u-%02uT%02u:%02u:%02u\n",
6280 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
6281 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
6287 dynamic_info_DT_GNU_HASH
= entry
->d_un
.d_val
;
6290 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6296 if ((entry
->d_tag
>= DT_VERSYM
) && (entry
->d_tag
<= DT_VERNEEDNUM
))
6297 version_info
[DT_VERSIONTAGIDX (entry
->d_tag
)] =
6302 switch (elf_header
.e_machine
)
6305 case EM_MIPS_RS3_LE
:
6306 dynamic_section_mips_val (entry
);
6309 dynamic_section_parisc_val (entry
);
6312 dynamic_section_ia64_val (entry
);
6315 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6327 get_ver_flags (unsigned int flags
)
6329 static char buff
[32];
6336 if (flags
& VER_FLG_BASE
)
6337 strcat (buff
, "BASE ");
6339 if (flags
& VER_FLG_WEAK
)
6341 if (flags
& VER_FLG_BASE
)
6342 strcat (buff
, "| ");
6344 strcat (buff
, "WEAK ");
6347 if (flags
& ~(VER_FLG_BASE
| VER_FLG_WEAK
))
6348 strcat (buff
, "| <unknown>");
6353 /* Display the contents of the version sections. */
6355 process_version_sections (FILE *file
)
6357 Elf_Internal_Shdr
*section
;
6364 for (i
= 0, section
= section_headers
;
6365 i
< elf_header
.e_shnum
;
6368 switch (section
->sh_type
)
6370 case SHT_GNU_verdef
:
6372 Elf_External_Verdef
*edefs
;
6379 (_("\nVersion definition section '%s' contains %ld entries:\n"),
6380 SECTION_NAME (section
), section
->sh_info
);
6382 printf (_(" Addr: 0x"));
6383 printf_vma (section
->sh_addr
);
6384 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
6385 (unsigned long) section
->sh_offset
, section
->sh_link
,
6386 SECTION_HEADER_INDEX (section
->sh_link
)
6387 < elf_header
.e_shnum
6388 ? SECTION_NAME (SECTION_HEADER (section
->sh_link
))
6391 edefs
= get_data (NULL
, file
, section
->sh_offset
, 1,
6393 _("version definition section"));
6397 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
6400 Elf_External_Verdef
*edef
;
6401 Elf_Internal_Verdef ent
;
6402 Elf_External_Verdaux
*eaux
;
6403 Elf_Internal_Verdaux aux
;
6407 vstart
= ((char *) edefs
) + idx
;
6409 edef
= (Elf_External_Verdef
*) vstart
;
6411 ent
.vd_version
= BYTE_GET (edef
->vd_version
);
6412 ent
.vd_flags
= BYTE_GET (edef
->vd_flags
);
6413 ent
.vd_ndx
= BYTE_GET (edef
->vd_ndx
);
6414 ent
.vd_cnt
= BYTE_GET (edef
->vd_cnt
);
6415 ent
.vd_hash
= BYTE_GET (edef
->vd_hash
);
6416 ent
.vd_aux
= BYTE_GET (edef
->vd_aux
);
6417 ent
.vd_next
= BYTE_GET (edef
->vd_next
);
6419 printf (_(" %#06x: Rev: %d Flags: %s"),
6420 idx
, ent
.vd_version
, get_ver_flags (ent
.vd_flags
));
6422 printf (_(" Index: %d Cnt: %d "),
6423 ent
.vd_ndx
, ent
.vd_cnt
);
6425 vstart
+= ent
.vd_aux
;
6427 eaux
= (Elf_External_Verdaux
*) vstart
;
6429 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
6430 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
6432 if (VALID_DYNAMIC_NAME (aux
.vda_name
))
6433 printf (_("Name: %s\n"), GET_DYNAMIC_NAME (aux
.vda_name
));
6435 printf (_("Name index: %ld\n"), aux
.vda_name
);
6437 isum
= idx
+ ent
.vd_aux
;
6439 for (j
= 1; j
< ent
.vd_cnt
; j
++)
6441 isum
+= aux
.vda_next
;
6442 vstart
+= aux
.vda_next
;
6444 eaux
= (Elf_External_Verdaux
*) vstart
;
6446 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
6447 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
6449 if (VALID_DYNAMIC_NAME (aux
.vda_name
))
6450 printf (_(" %#06x: Parent %d: %s\n"),
6451 isum
, j
, GET_DYNAMIC_NAME (aux
.vda_name
));
6453 printf (_(" %#06x: Parent %d, name index: %ld\n"),
6454 isum
, j
, aux
.vda_name
);
6464 case SHT_GNU_verneed
:
6466 Elf_External_Verneed
*eneed
;
6472 printf (_("\nVersion needs section '%s' contains %ld entries:\n"),
6473 SECTION_NAME (section
), section
->sh_info
);
6475 printf (_(" Addr: 0x"));
6476 printf_vma (section
->sh_addr
);
6477 printf (_(" Offset: %#08lx Link to section: %ld (%s)\n"),
6478 (unsigned long) section
->sh_offset
, section
->sh_link
,
6479 SECTION_HEADER_INDEX (section
->sh_link
)
6480 < elf_header
.e_shnum
6481 ? SECTION_NAME (SECTION_HEADER (section
->sh_link
))
6484 eneed
= get_data (NULL
, file
, section
->sh_offset
, 1,
6486 _("version need section"));
6490 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
6492 Elf_External_Verneed
*entry
;
6493 Elf_Internal_Verneed ent
;
6498 vstart
= ((char *) eneed
) + idx
;
6500 entry
= (Elf_External_Verneed
*) vstart
;
6502 ent
.vn_version
= BYTE_GET (entry
->vn_version
);
6503 ent
.vn_cnt
= BYTE_GET (entry
->vn_cnt
);
6504 ent
.vn_file
= BYTE_GET (entry
->vn_file
);
6505 ent
.vn_aux
= BYTE_GET (entry
->vn_aux
);
6506 ent
.vn_next
= BYTE_GET (entry
->vn_next
);
6508 printf (_(" %#06x: Version: %d"), idx
, ent
.vn_version
);
6510 if (VALID_DYNAMIC_NAME (ent
.vn_file
))
6511 printf (_(" File: %s"), GET_DYNAMIC_NAME (ent
.vn_file
));
6513 printf (_(" File: %lx"), ent
.vn_file
);
6515 printf (_(" Cnt: %d\n"), ent
.vn_cnt
);
6517 vstart
+= ent
.vn_aux
;
6519 for (j
= 0, isum
= idx
+ ent
.vn_aux
; j
< ent
.vn_cnt
; ++j
)
6521 Elf_External_Vernaux
*eaux
;
6522 Elf_Internal_Vernaux aux
;
6524 eaux
= (Elf_External_Vernaux
*) vstart
;
6526 aux
.vna_hash
= BYTE_GET (eaux
->vna_hash
);
6527 aux
.vna_flags
= BYTE_GET (eaux
->vna_flags
);
6528 aux
.vna_other
= BYTE_GET (eaux
->vna_other
);
6529 aux
.vna_name
= BYTE_GET (eaux
->vna_name
);
6530 aux
.vna_next
= BYTE_GET (eaux
->vna_next
);
6532 if (VALID_DYNAMIC_NAME (aux
.vna_name
))
6533 printf (_(" %#06x: Name: %s"),
6534 isum
, GET_DYNAMIC_NAME (aux
.vna_name
));
6536 printf (_(" %#06x: Name index: %lx"),
6537 isum
, aux
.vna_name
);
6539 printf (_(" Flags: %s Version: %d\n"),
6540 get_ver_flags (aux
.vna_flags
), aux
.vna_other
);
6542 isum
+= aux
.vna_next
;
6543 vstart
+= aux
.vna_next
;
6553 case SHT_GNU_versym
:
6555 Elf_Internal_Shdr
*link_section
;
6558 unsigned char *edata
;
6559 unsigned short *data
;
6561 Elf_Internal_Sym
*symbols
;
6562 Elf_Internal_Shdr
*string_sec
;
6565 if (SECTION_HEADER_INDEX (section
->sh_link
) >= elf_header
.e_shnum
)
6568 link_section
= SECTION_HEADER (section
->sh_link
);
6569 total
= section
->sh_size
/ sizeof (Elf_External_Versym
);
6571 if (SECTION_HEADER_INDEX (link_section
->sh_link
)
6572 >= elf_header
.e_shnum
)
6577 symbols
= GET_ELF_SYMBOLS (file
, link_section
);
6579 string_sec
= SECTION_HEADER (link_section
->sh_link
);
6581 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
, 1,
6582 string_sec
->sh_size
, _("version string table"));
6586 printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
6587 SECTION_NAME (section
), total
);
6589 printf (_(" Addr: "));
6590 printf_vma (section
->sh_addr
);
6591 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
6592 (unsigned long) section
->sh_offset
, section
->sh_link
,
6593 SECTION_NAME (link_section
));
6595 off
= offset_from_vma (file
,
6596 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
6597 total
* sizeof (short));
6598 edata
= get_data (NULL
, file
, off
, total
, sizeof (short),
6599 _("version symbol data"));
6606 data
= cmalloc (total
, sizeof (short));
6608 for (cnt
= total
; cnt
--;)
6609 data
[cnt
] = byte_get (edata
+ cnt
* sizeof (short),
6614 for (cnt
= 0; cnt
< total
; cnt
+= 4)
6617 int check_def
, check_need
;
6620 printf (" %03x:", cnt
);
6622 for (j
= 0; (j
< 4) && (cnt
+ j
) < total
; ++j
)
6623 switch (data
[cnt
+ j
])
6626 fputs (_(" 0 (*local*) "), stdout
);
6630 fputs (_(" 1 (*global*) "), stdout
);
6634 nn
= printf ("%4x%c", data
[cnt
+ j
] & 0x7fff,
6635 data
[cnt
+ j
] & 0x8000 ? 'h' : ' ');
6639 if (SECTION_HEADER_INDEX (symbols
[cnt
+ j
].st_shndx
)
6640 >= elf_header
.e_shnum
6641 || SECTION_HEADER (symbols
[cnt
+ j
].st_shndx
)->sh_type
6644 if (symbols
[cnt
+ j
].st_shndx
== SHN_UNDEF
)
6651 && version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)])
6653 Elf_Internal_Verneed ivn
;
6654 unsigned long offset
;
6656 offset
= offset_from_vma
6657 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
6658 sizeof (Elf_External_Verneed
));
6662 Elf_Internal_Vernaux ivna
;
6663 Elf_External_Verneed evn
;
6664 Elf_External_Vernaux evna
;
6665 unsigned long a_off
;
6667 get_data (&evn
, file
, offset
, sizeof (evn
), 1,
6670 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
6671 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
6673 a_off
= offset
+ ivn
.vn_aux
;
6677 get_data (&evna
, file
, a_off
, sizeof (evna
),
6678 1, _("version need aux (2)"));
6680 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
6681 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
6683 a_off
+= ivna
.vna_next
;
6685 while (ivna
.vna_other
!= data
[cnt
+ j
]
6686 && ivna
.vna_next
!= 0);
6688 if (ivna
.vna_other
== data
[cnt
+ j
])
6690 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
6692 name
= strtab
+ ivna
.vna_name
;
6693 nn
+= printf ("(%s%-*s",
6695 12 - (int) strlen (name
),
6701 offset
+= ivn
.vn_next
;
6703 while (ivn
.vn_next
);
6706 if (check_def
&& data
[cnt
+ j
] != 0x8001
6707 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
6709 Elf_Internal_Verdef ivd
;
6710 Elf_External_Verdef evd
;
6711 unsigned long offset
;
6713 offset
= offset_from_vma
6714 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
6719 get_data (&evd
, file
, offset
, sizeof (evd
), 1,
6722 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
6723 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
6725 offset
+= ivd
.vd_next
;
6727 while (ivd
.vd_ndx
!= (data
[cnt
+ j
] & 0x7fff)
6728 && ivd
.vd_next
!= 0);
6730 if (ivd
.vd_ndx
== (data
[cnt
+ j
] & 0x7fff))
6732 Elf_External_Verdaux evda
;
6733 Elf_Internal_Verdaux ivda
;
6735 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
6737 get_data (&evda
, file
,
6738 offset
- ivd
.vd_next
+ ivd
.vd_aux
,
6740 _("version def aux"));
6742 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
6744 name
= strtab
+ ivda
.vda_name
;
6745 nn
+= printf ("(%s%-*s",
6747 12 - (int) strlen (name
),
6753 printf ("%*c", 18 - nn
, ' ');
6771 printf (_("\nNo version information found in this file.\n"));
6777 get_symbol_binding (unsigned int binding
)
6779 static char buff
[32];
6783 case STB_LOCAL
: return "LOCAL";
6784 case STB_GLOBAL
: return "GLOBAL";
6785 case STB_WEAK
: return "WEAK";
6787 if (binding
>= STB_LOPROC
&& binding
<= STB_HIPROC
)
6788 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"),
6790 else if (binding
>= STB_LOOS
&& binding
<= STB_HIOS
)
6791 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), binding
);
6793 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), binding
);
6799 get_symbol_type (unsigned int type
)
6801 static char buff
[32];
6805 case STT_NOTYPE
: return "NOTYPE";
6806 case STT_OBJECT
: return "OBJECT";
6807 case STT_FUNC
: return "FUNC";
6808 case STT_SECTION
: return "SECTION";
6809 case STT_FILE
: return "FILE";
6810 case STT_COMMON
: return "COMMON";
6811 case STT_TLS
: return "TLS";
6813 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
6815 if (elf_header
.e_machine
== EM_ARM
&& type
== STT_ARM_TFUNC
)
6816 return "THUMB_FUNC";
6818 if (elf_header
.e_machine
== EM_SPARCV9
&& type
== STT_REGISTER
)
6821 if (elf_header
.e_machine
== EM_PARISC
&& type
== STT_PARISC_MILLI
)
6822 return "PARISC_MILLI";
6824 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"), type
);
6826 else if (type
>= STT_LOOS
&& type
<= STT_HIOS
)
6828 if (elf_header
.e_machine
== EM_PARISC
)
6830 if (type
== STT_HP_OPAQUE
)
6832 if (type
== STT_HP_STUB
)
6836 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), type
);
6839 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), type
);
6845 get_symbol_visibility (unsigned int visibility
)
6849 case STV_DEFAULT
: return "DEFAULT";
6850 case STV_INTERNAL
: return "INTERNAL";
6851 case STV_HIDDEN
: return "HIDDEN";
6852 case STV_PROTECTED
: return "PROTECTED";
6858 get_mips_symbol_other (unsigned int other
)
6862 case STO_OPTIONAL
: return "OPTIONAL";
6863 case STO_MIPS16
: return "MIPS16";
6864 default: return NULL
;
6869 get_symbol_other (unsigned int other
)
6871 const char * result
= NULL
;
6872 static char buff
[32];
6877 switch (elf_header
.e_machine
)
6880 result
= get_mips_symbol_other (other
);
6888 snprintf (buff
, sizeof buff
, _("<other>: %x"), other
);
6893 get_symbol_index_type (unsigned int type
)
6895 static char buff
[32];
6899 case SHN_UNDEF
: return "UND";
6900 case SHN_ABS
: return "ABS";
6901 case SHN_COMMON
: return "COM";
6903 if (type
== SHN_IA_64_ANSI_COMMON
6904 && elf_header
.e_machine
== EM_IA_64
6905 && elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
)
6907 else if (elf_header
.e_machine
== EM_X86_64
6908 && type
== SHN_X86_64_LCOMMON
)
6910 else if (type
== SHN_MIPS_SCOMMON
6911 && elf_header
.e_machine
== EM_MIPS
)
6913 else if (type
== SHN_MIPS_SUNDEFINED
6914 && elf_header
.e_machine
== EM_MIPS
)
6916 else if (type
>= SHN_LOPROC
&& type
<= SHN_HIPROC
)
6917 sprintf (buff
, "PRC[0x%04x]", type
);
6918 else if (type
>= SHN_LOOS
&& type
<= SHN_HIOS
)
6919 sprintf (buff
, "OS [0x%04x]", type
);
6920 else if (type
>= SHN_LORESERVE
&& type
<= SHN_HIRESERVE
)
6921 sprintf (buff
, "RSV[0x%04x]", type
);
6923 sprintf (buff
, "%3d", type
);
6931 get_dynamic_data (FILE *file
, unsigned int number
, unsigned int ent_size
)
6933 unsigned char *e_data
;
6936 e_data
= cmalloc (number
, ent_size
);
6940 error (_("Out of memory\n"));
6944 if (fread (e_data
, ent_size
, number
, file
) != number
)
6946 error (_("Unable to read in dynamic data\n"));
6950 i_data
= cmalloc (number
, sizeof (*i_data
));
6954 error (_("Out of memory\n"));
6960 i_data
[number
] = byte_get (e_data
+ number
* ent_size
, ent_size
);
6967 /* Dump the symbol table. */
6969 process_symbol_table (FILE *file
)
6971 Elf_Internal_Shdr
*section
;
6972 bfd_vma nbuckets
= 0;
6973 bfd_vma nchains
= 0;
6974 bfd_vma
*buckets
= NULL
;
6975 bfd_vma
*chains
= NULL
;
6976 bfd_vma ngnubuckets
= 0;
6977 bfd_vma
*gnubuckets
= NULL
;
6978 bfd_vma
*gnuchains
= NULL
;
6980 if (! do_syms
&& !do_histogram
)
6983 if (dynamic_info
[DT_HASH
] && ((do_using_dynamic
&& dynamic_strings
!= NULL
)
6986 unsigned char nb
[8];
6987 unsigned char nc
[8];
6988 int hash_ent_size
= 4;
6990 if ((elf_header
.e_machine
== EM_ALPHA
6991 || elf_header
.e_machine
== EM_S390
6992 || elf_header
.e_machine
== EM_S390_OLD
)
6993 && elf_header
.e_ident
[EI_CLASS
] == ELFCLASS64
)
6997 (archive_file_offset
6998 + offset_from_vma (file
, dynamic_info
[DT_HASH
],
6999 sizeof nb
+ sizeof nc
)),
7002 error (_("Unable to seek to start of dynamic information"));
7006 if (fread (nb
, hash_ent_size
, 1, file
) != 1)
7008 error (_("Failed to read in number of buckets\n"));
7012 if (fread (nc
, hash_ent_size
, 1, file
) != 1)
7014 error (_("Failed to read in number of chains\n"));
7018 nbuckets
= byte_get (nb
, hash_ent_size
);
7019 nchains
= byte_get (nc
, hash_ent_size
);
7021 buckets
= get_dynamic_data (file
, nbuckets
, hash_ent_size
);
7022 chains
= get_dynamic_data (file
, nchains
, hash_ent_size
);
7024 if (buckets
== NULL
|| chains
== NULL
)
7029 && dynamic_info
[DT_HASH
] && do_using_dynamic
&& dynamic_strings
!= NULL
)
7034 printf (_("\nSymbol table for image:\n"));
7036 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7038 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7040 for (hn
= 0; hn
< nbuckets
; hn
++)
7045 for (si
= buckets
[hn
]; si
< nchains
&& si
> 0; si
= chains
[si
])
7047 Elf_Internal_Sym
*psym
;
7050 psym
= dynamic_symbols
+ si
;
7052 n
= print_vma (si
, DEC_5
);
7054 fputs (" " + n
, stdout
);
7055 printf (" %3lu: ", hn
);
7056 print_vma (psym
->st_value
, LONG_HEX
);
7058 print_vma (psym
->st_size
, DEC_5
);
7060 printf (" %6s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
7061 printf (" %6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
7062 printf (" %3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
7063 /* Check to see if any other bits in the st_other field are set.
7064 Note - displaying this information disrupts the layout of the
7065 table being generated, but for the moment this case is very rare. */
7066 if (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
))
7067 printf (" [%s] ", get_symbol_other (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
)));
7068 printf (" %3.3s ", get_symbol_index_type (psym
->st_shndx
));
7069 if (VALID_DYNAMIC_NAME (psym
->st_name
))
7070 print_symbol (25, GET_DYNAMIC_NAME (psym
->st_name
));
7072 printf (" <corrupt: %14ld>", psym
->st_name
);
7077 else if (do_syms
&& !do_using_dynamic
)
7081 for (i
= 0, section
= section_headers
;
7082 i
< elf_header
.e_shnum
;
7086 char *strtab
= NULL
;
7087 unsigned long int strtab_size
= 0;
7088 Elf_Internal_Sym
*symtab
;
7089 Elf_Internal_Sym
*psym
;
7092 if ( section
->sh_type
!= SHT_SYMTAB
7093 && section
->sh_type
!= SHT_DYNSYM
)
7096 printf (_("\nSymbol table '%s' contains %lu entries:\n"),
7097 SECTION_NAME (section
),
7098 (unsigned long) (section
->sh_size
/ section
->sh_entsize
));
7100 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
7102 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
7104 symtab
= GET_ELF_SYMBOLS (file
, section
);
7108 if (section
->sh_link
== elf_header
.e_shstrndx
)
7110 strtab
= string_table
;
7111 strtab_size
= string_table_length
;
7113 else if (SECTION_HEADER_INDEX (section
->sh_link
) < elf_header
.e_shnum
)
7115 Elf_Internal_Shdr
*string_sec
;
7117 string_sec
= SECTION_HEADER (section
->sh_link
);
7119 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
,
7120 1, string_sec
->sh_size
, _("string table"));
7121 strtab_size
= strtab
!= NULL
? string_sec
->sh_size
: 0;
7124 for (si
= 0, psym
= symtab
;
7125 si
< section
->sh_size
/ section
->sh_entsize
;
7128 printf ("%6d: ", si
);
7129 print_vma (psym
->st_value
, LONG_HEX
);
7131 print_vma (psym
->st_size
, DEC_5
);
7132 printf (" %-7s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
7133 printf (" %-6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
7134 printf (" %-3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
7135 /* Check to see if any other bits in the st_other field are set.
7136 Note - displaying this information disrupts the layout of the
7137 table being generated, but for the moment this case is very rare. */
7138 if (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
))
7139 printf (" [%s] ", get_symbol_other (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
)));
7140 printf (" %4s ", get_symbol_index_type (psym
->st_shndx
));
7141 print_symbol (25, psym
->st_name
< strtab_size
7142 ? strtab
+ psym
->st_name
: "<corrupt>");
7144 if (section
->sh_type
== SHT_DYNSYM
&&
7145 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] != 0)
7147 unsigned char data
[2];
7148 unsigned short vers_data
;
7149 unsigned long offset
;
7153 offset
= offset_from_vma
7154 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
7155 sizeof data
+ si
* sizeof (vers_data
));
7157 get_data (&data
, file
, offset
+ si
* sizeof (vers_data
),
7158 sizeof (data
), 1, _("version data"));
7160 vers_data
= byte_get (data
, 2);
7162 is_nobits
= (SECTION_HEADER_INDEX (psym
->st_shndx
)
7163 < elf_header
.e_shnum
7164 && SECTION_HEADER (psym
->st_shndx
)->sh_type
7167 check_def
= (psym
->st_shndx
!= SHN_UNDEF
);
7169 if ((vers_data
& 0x8000) || vers_data
> 1)
7171 if (version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
7172 && (is_nobits
|| ! check_def
))
7174 Elf_External_Verneed evn
;
7175 Elf_Internal_Verneed ivn
;
7176 Elf_Internal_Vernaux ivna
;
7178 /* We must test both. */
7179 offset
= offset_from_vma
7180 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
7185 unsigned long vna_off
;
7187 get_data (&evn
, file
, offset
, sizeof (evn
), 1,
7190 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
7191 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
7193 vna_off
= offset
+ ivn
.vn_aux
;
7197 Elf_External_Vernaux evna
;
7199 get_data (&evna
, file
, vna_off
,
7201 _("version need aux (3)"));
7203 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
7204 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
7205 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
7207 vna_off
+= ivna
.vna_next
;
7209 while (ivna
.vna_other
!= vers_data
7210 && ivna
.vna_next
!= 0);
7212 if (ivna
.vna_other
== vers_data
)
7215 offset
+= ivn
.vn_next
;
7217 while (ivn
.vn_next
!= 0);
7219 if (ivna
.vna_other
== vers_data
)
7222 ivna
.vna_name
< strtab_size
7223 ? strtab
+ ivna
.vna_name
: "<corrupt>",
7227 else if (! is_nobits
)
7228 error (_("bad dynamic symbol"));
7235 if (vers_data
!= 0x8001
7236 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
7238 Elf_Internal_Verdef ivd
;
7239 Elf_Internal_Verdaux ivda
;
7240 Elf_External_Verdaux evda
;
7241 unsigned long offset
;
7243 offset
= offset_from_vma
7245 version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
7246 sizeof (Elf_External_Verdef
));
7250 Elf_External_Verdef evd
;
7252 get_data (&evd
, file
, offset
, sizeof (evd
),
7253 1, _("version def"));
7255 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
7256 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
7257 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
7259 offset
+= ivd
.vd_next
;
7261 while (ivd
.vd_ndx
!= (vers_data
& 0x7fff)
7262 && ivd
.vd_next
!= 0);
7264 offset
-= ivd
.vd_next
;
7265 offset
+= ivd
.vd_aux
;
7267 get_data (&evda
, file
, offset
, sizeof (evda
),
7268 1, _("version def aux"));
7270 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
7272 if (psym
->st_name
!= ivda
.vda_name
)
7273 printf ((vers_data
& 0x8000)
7275 ivda
.vda_name
< strtab_size
7276 ? strtab
+ ivda
.vda_name
: "<corrupt>");
7286 if (strtab
!= string_table
)
7292 (_("\nDynamic symbol information is not available for displaying symbols.\n"));
7294 if (do_histogram
&& buckets
!= NULL
)
7296 unsigned long *lengths
;
7297 unsigned long *counts
;
7300 unsigned long maxlength
= 0;
7301 unsigned long nzero_counts
= 0;
7302 unsigned long nsyms
= 0;
7304 printf (_("\nHistogram for bucket list length (total of %lu buckets):\n"),
7305 (unsigned long) nbuckets
);
7306 printf (_(" Length Number %% of total Coverage\n"));
7308 lengths
= calloc (nbuckets
, sizeof (*lengths
));
7309 if (lengths
== NULL
)
7311 error (_("Out of memory"));
7314 for (hn
= 0; hn
< nbuckets
; ++hn
)
7316 for (si
= buckets
[hn
]; si
> 0 && si
< nchains
; si
= chains
[si
])
7319 if (maxlength
< ++lengths
[hn
])
7324 counts
= calloc (maxlength
+ 1, sizeof (*counts
));
7327 error (_("Out of memory"));
7331 for (hn
= 0; hn
< nbuckets
; ++hn
)
7332 ++counts
[lengths
[hn
]];
7337 printf (" 0 %-10lu (%5.1f%%)\n",
7338 counts
[0], (counts
[0] * 100.0) / nbuckets
);
7339 for (i
= 1; i
<= maxlength
; ++i
)
7341 nzero_counts
+= counts
[i
] * i
;
7342 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
7343 i
, counts
[i
], (counts
[i
] * 100.0) / nbuckets
,
7344 (nzero_counts
* 100.0) / nsyms
);
7352 if (buckets
!= NULL
)
7358 if (do_histogram
&& dynamic_info_DT_GNU_HASH
)
7360 unsigned char nb
[16];
7361 bfd_vma i
, maxchain
= 0xffffffff, symidx
, bitmaskwords
;
7362 unsigned long *lengths
;
7363 unsigned long *counts
;
7365 unsigned long maxlength
= 0;
7366 unsigned long nzero_counts
= 0;
7367 unsigned long nsyms
= 0;
7368 bfd_vma buckets_vma
;
7371 (archive_file_offset
7372 + offset_from_vma (file
, dynamic_info_DT_GNU_HASH
,
7376 error (_("Unable to seek to start of dynamic information"));
7380 if (fread (nb
, 16, 1, file
) != 1)
7382 error (_("Failed to read in number of buckets\n"));
7386 ngnubuckets
= byte_get (nb
, 4);
7387 symidx
= byte_get (nb
+ 4, 4);
7388 bitmaskwords
= byte_get (nb
+ 8, 4);
7389 buckets_vma
= dynamic_info_DT_GNU_HASH
+ 16;
7391 buckets_vma
+= bitmaskwords
* 4;
7393 buckets_vma
+= bitmaskwords
* 8;
7396 (archive_file_offset
7397 + offset_from_vma (file
, buckets_vma
, 4)),
7400 error (_("Unable to seek to start of dynamic information"));
7404 gnubuckets
= get_dynamic_data (file
, ngnubuckets
, 4);
7406 if (gnubuckets
== NULL
)
7409 for (i
= 0; i
< ngnubuckets
; i
++)
7410 if (gnubuckets
[i
] != 0)
7412 if (gnubuckets
[i
] < symidx
)
7415 if (maxchain
== 0xffffffff || gnubuckets
[i
] > maxchain
)
7416 maxchain
= gnubuckets
[i
];
7419 if (maxchain
== 0xffffffff)
7425 (archive_file_offset
7426 + offset_from_vma (file
, buckets_vma
7427 + 4 * (ngnubuckets
+ maxchain
), 4)),
7430 error (_("Unable to seek to start of dynamic information"));
7436 if (fread (nb
, 4, 1, file
) != 1)
7438 error (_("Failed to determine last chain length\n"));
7442 if (maxchain
+ 1 == 0)
7447 while ((byte_get (nb
, 4) & 1) == 0);
7450 (archive_file_offset
7451 + offset_from_vma (file
, buckets_vma
+ 4 * ngnubuckets
, 4)),
7454 error (_("Unable to seek to start of dynamic information"));
7458 gnuchains
= get_dynamic_data (file
, maxchain
, 4);
7460 if (gnuchains
== NULL
)
7463 lengths
= calloc (ngnubuckets
, sizeof (*lengths
));
7464 if (lengths
== NULL
)
7466 error (_("Out of memory"));
7470 printf (_("\nHistogram for `.gnu.hash' bucket list length (total of %lu buckets):\n"),
7471 (unsigned long) ngnubuckets
);
7472 printf (_(" Length Number %% of total Coverage\n"));
7474 for (hn
= 0; hn
< ngnubuckets
; ++hn
)
7475 if (gnubuckets
[hn
] != 0)
7477 bfd_vma off
, length
= 1;
7479 for (off
= gnubuckets
[hn
] - symidx
;
7480 (gnuchains
[off
] & 1) == 0; ++off
)
7482 lengths
[hn
] = length
;
7483 if (length
> maxlength
)
7488 counts
= calloc (maxlength
+ 1, sizeof (*counts
));
7491 error (_("Out of memory"));
7495 for (hn
= 0; hn
< ngnubuckets
; ++hn
)
7496 ++counts
[lengths
[hn
]];
7498 if (ngnubuckets
> 0)
7501 printf (" 0 %-10lu (%5.1f%%)\n",
7502 counts
[0], (counts
[0] * 100.0) / ngnubuckets
);
7503 for (j
= 1; j
<= maxlength
; ++j
)
7505 nzero_counts
+= counts
[j
] * j
;
7506 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
7507 j
, counts
[j
], (counts
[j
] * 100.0) / ngnubuckets
,
7508 (nzero_counts
* 100.0) / nsyms
);
7522 process_syminfo (FILE *file ATTRIBUTE_UNUSED
)
7526 if (dynamic_syminfo
== NULL
7528 /* No syminfo, this is ok. */
7531 /* There better should be a dynamic symbol section. */
7532 if (dynamic_symbols
== NULL
|| dynamic_strings
== NULL
)
7536 printf (_("\nDynamic info segment at offset 0x%lx contains %d entries:\n"),
7537 dynamic_syminfo_offset
, dynamic_syminfo_nent
);
7539 printf (_(" Num: Name BoundTo Flags\n"));
7540 for (i
= 0; i
< dynamic_syminfo_nent
; ++i
)
7542 unsigned short int flags
= dynamic_syminfo
[i
].si_flags
;
7544 printf ("%4d: ", i
);
7545 if (VALID_DYNAMIC_NAME (dynamic_symbols
[i
].st_name
))
7546 print_symbol (30, GET_DYNAMIC_NAME (dynamic_symbols
[i
].st_name
));
7548 printf ("<corrupt: %19ld>", dynamic_symbols
[i
].st_name
);
7551 switch (dynamic_syminfo
[i
].si_boundto
)
7553 case SYMINFO_BT_SELF
:
7554 fputs ("SELF ", stdout
);
7556 case SYMINFO_BT_PARENT
:
7557 fputs ("PARENT ", stdout
);
7560 if (dynamic_syminfo
[i
].si_boundto
> 0
7561 && dynamic_syminfo
[i
].si_boundto
< dynamic_nent
7562 && VALID_DYNAMIC_NAME (dynamic_section
[dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
))
7564 print_symbol (10, GET_DYNAMIC_NAME (dynamic_section
[dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
));
7568 printf ("%-10d ", dynamic_syminfo
[i
].si_boundto
);
7572 if (flags
& SYMINFO_FLG_DIRECT
)
7574 if (flags
& SYMINFO_FLG_PASSTHRU
)
7575 printf (" PASSTHRU");
7576 if (flags
& SYMINFO_FLG_COPY
)
7578 if (flags
& SYMINFO_FLG_LAZYLOAD
)
7579 printf (" LAZYLOAD");
7587 #ifdef SUPPORT_DISASSEMBLY
7589 disassemble_section (Elf_Internal_Shdr
*section
, FILE *file
)
7591 printf (_("\nAssembly dump of section %s\n"),
7592 SECTION_NAME (section
));
7594 /* XXX -- to be done --- XXX */
7601 dump_section (Elf_Internal_Shdr
*section
, FILE *file
)
7603 bfd_size_type bytes
;
7605 unsigned char *data
;
7606 unsigned char *start
;
7608 bytes
= section
->sh_size
;
7610 if (bytes
== 0 || section
->sh_type
== SHT_NOBITS
)
7612 printf (_("\nSection '%s' has no data to dump.\n"),
7613 SECTION_NAME (section
));
7617 printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section
));
7619 addr
= section
->sh_addr
;
7621 start
= get_data (NULL
, file
, section
->sh_offset
, 1, bytes
,
7634 lbytes
= (bytes
> 16 ? 16 : bytes
);
7636 printf (" 0x%8.8lx ", (unsigned long) addr
);
7638 switch (elf_header
.e_ident
[EI_DATA
])
7642 for (j
= 15; j
>= 0; j
--)
7645 printf ("%2.2x", data
[j
]);
7655 for (j
= 0; j
< 16; j
++)
7658 printf ("%2.2x", data
[j
]);
7668 for (j
= 0; j
< lbytes
; j
++)
7671 if (k
>= ' ' && k
< 0x7f)
7689 /* Apply addends of RELA relocations. */
7692 debug_apply_rela_addends (void *file
,
7693 Elf_Internal_Shdr
*section
,
7694 unsigned char *start
)
7696 Elf_Internal_Shdr
*relsec
;
7697 unsigned char *end
= start
+ section
->sh_size
;
7698 /* FIXME: The relocation field size is relocation type dependent. */
7699 unsigned int reloc_size
= 4;
7701 if (!is_relocatable
)
7704 if (section
->sh_size
< reloc_size
)
7707 for (relsec
= section_headers
;
7708 relsec
< section_headers
+ elf_header
.e_shnum
;
7711 unsigned long nrelas
;
7712 Elf_Internal_Rela
*rela
, *rp
;
7713 Elf_Internal_Shdr
*symsec
;
7714 Elf_Internal_Sym
*symtab
;
7715 Elf_Internal_Sym
*sym
;
7717 if (relsec
->sh_type
!= SHT_RELA
7718 || SECTION_HEADER_INDEX (relsec
->sh_info
) >= elf_header
.e_shnum
7719 || SECTION_HEADER (relsec
->sh_info
) != section
7720 || relsec
->sh_size
== 0
7721 || SECTION_HEADER_INDEX (relsec
->sh_link
) >= elf_header
.e_shnum
)
7724 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
7728 symsec
= SECTION_HEADER (relsec
->sh_link
);
7729 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
7731 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
7735 loc
= start
+ rp
->r_offset
;
7736 if ((loc
+ reloc_size
) > end
)
7738 warn (_("skipping invalid relocation offset 0x%lx in section %s\n"),
7739 (unsigned long) rp
->r_offset
,
7740 SECTION_NAME (section
));
7746 sym
= symtab
+ ELF32_R_SYM (rp
->r_info
);
7748 if (ELF32_R_SYM (rp
->r_info
) != 0
7749 && ELF32_ST_TYPE (sym
->st_info
) != STT_SECTION
7750 /* Relocations against object symbols can happen,
7751 eg when referencing a global array. For an
7752 example of this see the _clz.o binary in libgcc.a. */
7753 && ELF32_ST_TYPE (sym
->st_info
) != STT_OBJECT
)
7755 warn (_("skipping unexpected symbol type %s in relocation in section .rela%s\n"),
7756 get_symbol_type (ELF32_ST_TYPE (sym
->st_info
)),
7757 SECTION_NAME (section
));
7763 /* In MIPS little-endian objects, r_info isn't really a
7764 64-bit little-endian value: it has a 32-bit little-endian
7765 symbol index followed by four individual byte fields.
7766 Reorder INFO accordingly. */
7767 if (elf_header
.e_machine
== EM_MIPS
7768 && elf_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
7769 rp
->r_info
= (((rp
->r_info
& 0xffffffff) << 32)
7770 | ((rp
->r_info
>> 56) & 0xff)
7771 | ((rp
->r_info
>> 40) & 0xff00)
7772 | ((rp
->r_info
>> 24) & 0xff0000)
7773 | ((rp
->r_info
>> 8) & 0xff000000));
7775 sym
= symtab
+ ELF64_R_SYM (rp
->r_info
);
7777 if (ELF64_R_SYM (rp
->r_info
) != 0
7778 && ELF64_ST_TYPE (sym
->st_info
) != STT_SECTION
7779 && ELF64_ST_TYPE (sym
->st_info
) != STT_OBJECT
)
7781 warn (_("skipping unexpected symbol type %s in relocation in section .rela.%s\n"),
7782 get_symbol_type (ELF64_ST_TYPE (sym
->st_info
)),
7783 SECTION_NAME (section
));
7788 byte_put (loc
, rp
->r_addend
, reloc_size
);
7799 load_debug_section (enum dwarf_section_display_enum debug
, void *file
)
7801 struct dwarf_section
*section
= &debug_displays
[debug
].section
;
7802 Elf_Internal_Shdr
*sec
;
7805 /* If it is already loaded, do nothing. */
7806 if (section
->start
!= NULL
)
7809 /* Locate the debug section. */
7810 sec
= find_section (section
->name
);
7814 snprintf (buf
, sizeof (buf
), _("%s section data"), section
->name
);
7815 section
->address
= sec
->sh_addr
;
7816 section
->size
= sec
->sh_size
;
7817 section
->start
= get_data (NULL
, file
, sec
->sh_offset
, 1,
7820 if (debug_displays
[debug
].relocate
)
7821 debug_apply_rela_addends (file
, sec
, section
->start
);
7823 return section
->start
!= NULL
;
7827 free_debug_section (enum dwarf_section_display_enum debug
)
7829 struct dwarf_section
*section
= &debug_displays
[debug
].section
;
7831 if (section
->start
== NULL
)
7834 free ((char *) section
->start
);
7835 section
->start
= NULL
;
7836 section
->address
= 0;
7841 display_debug_section (Elf_Internal_Shdr
*section
, FILE *file
)
7843 char *name
= SECTION_NAME (section
);
7844 bfd_size_type length
;
7846 enum dwarf_section_display_enum i
;
7848 length
= section
->sh_size
;
7851 printf (_("\nSection '%s' has no debugging data.\n"), name
);
7855 if (const_strneq (name
, ".gnu.linkonce.wi."))
7856 name
= ".debug_info";
7858 /* See if we know how to display the contents of this section. */
7859 for (i
= 0; i
< max
; i
++)
7860 if (streq (debug_displays
[i
].section
.name
, name
))
7862 struct dwarf_section
*sec
= &debug_displays
[i
].section
;
7864 if (load_debug_section (i
, file
))
7866 result
&= debug_displays
[i
].display (sec
, file
);
7868 if (i
!= info
&& i
!= abbrev
)
7869 free_debug_section (i
);
7877 printf (_("Unrecognized debug section: %s\n"), name
);
7884 /* Set DUMP_SECTS for all sections where dumps were requested
7885 based on section name. */
7888 initialise_dumps_byname (void)
7890 struct dump_list_entry
*cur
;
7892 for (cur
= dump_sects_byname
; cur
; cur
= cur
->next
)
7897 for (i
= 0, any
= 0; i
< elf_header
.e_shnum
; i
++)
7898 if (streq (SECTION_NAME (section_headers
+ i
), cur
->name
))
7900 request_dump (i
, cur
->type
);
7905 warn (_("Section '%s' was not dumped because it does not exist!\n"),
7911 process_section_contents (FILE *file
)
7913 Elf_Internal_Shdr
*section
;
7919 initialise_dumps_byname ();
7921 for (i
= 0, section
= section_headers
;
7922 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
7925 #ifdef SUPPORT_DISASSEMBLY
7926 if (dump_sects
[i
] & DISASS_DUMP
)
7927 disassemble_section (section
, file
);
7929 if (dump_sects
[i
] & HEX_DUMP
)
7930 dump_section (section
, file
);
7932 if (dump_sects
[i
] & DEBUG_DUMP
)
7933 display_debug_section (section
, file
);
7936 /* Check to see if the user requested a
7937 dump of a section that does not exist. */
7938 while (i
++ < num_dump_sects
)
7940 warn (_("Section %d was not dumped because it does not exist!\n"), i
);
7944 process_mips_fpe_exception (int mask
)
7949 if (mask
& OEX_FPU_INEX
)
7950 fputs ("INEX", stdout
), first
= 0;
7951 if (mask
& OEX_FPU_UFLO
)
7952 printf ("%sUFLO", first
? "" : "|"), first
= 0;
7953 if (mask
& OEX_FPU_OFLO
)
7954 printf ("%sOFLO", first
? "" : "|"), first
= 0;
7955 if (mask
& OEX_FPU_DIV0
)
7956 printf ("%sDIV0", first
? "" : "|"), first
= 0;
7957 if (mask
& OEX_FPU_INVAL
)
7958 printf ("%sINVAL", first
? "" : "|");
7961 fputs ("0", stdout
);
7964 /* ARM EABI attributes section. */
7969 /* 0 = special, 1 = string, 2 = uleb123, > 0x80 == table lookup. */
7972 } arm_attr_public_tag
;
7974 static const char *arm_attr_tag_CPU_arch
[] =
7975 {"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2",
7977 static const char *arm_attr_tag_ARM_ISA_use
[] = {"No", "Yes"};
7978 static const char *arm_attr_tag_THUMB_ISA_use
[] =
7979 {"No", "Thumb-1", "Thumb-2"};
7980 /* FIXME: VFPv3 encoding was extrapolated! */
7981 static const char *arm_attr_tag_VFP_arch
[] = {"No", "VFPv1", "VFPv2", "VFPv3"};
7982 static const char *arm_attr_tag_WMMX_arch
[] = {"No", "WMMXv1"};
7983 static const char *arm_attr_tag_NEON_arch
[] = {"No", "NEONv1"};
7984 static const char *arm_attr_tag_ABI_PCS_config
[] =
7985 {"None", "Bare platform", "Linux application", "Linux DSO", "PalmOS 2004",
7986 "PalmOS (reserved)", "SymbianOS 2004", "SymbianOS (reserved)"};
7987 static const char *arm_attr_tag_ABI_PCS_R9_use
[] =
7988 {"V6", "SB", "TLS", "Unused"};
7989 static const char *arm_attr_tag_ABI_PCS_RW_data
[] =
7990 {"Absolute", "PC-relative", "SB-relative", "None"};
7991 static const char *arm_attr_tag_ABI_PCS_RO_DATA
[] =
7992 {"Absolute", "PC-relative", "None"};
7993 static const char *arm_attr_tag_ABI_PCS_GOT_use
[] =
7994 {"None", "direct", "GOT-indirect"};
7995 static const char *arm_attr_tag_ABI_PCS_wchar_t
[] =
7996 {"None", "??? 1", "2", "??? 3", "4"};
7997 static const char *arm_attr_tag_ABI_FP_rounding
[] = {"Unused", "Needed"};
7998 static const char *arm_attr_tag_ABI_FP_denormal
[] = {"Unused", "Needed"};
7999 static const char *arm_attr_tag_ABI_FP_exceptions
[] = {"Unused", "Needed"};
8000 static const char *arm_attr_tag_ABI_FP_user_exceptions
[] = {"Unused", "Needed"};
8001 static const char *arm_attr_tag_ABI_FP_number_model
[] =
8002 {"Unused", "Finite", "RTABI", "IEEE 754"};
8003 static const char *arm_attr_tag_ABI_align8_needed
[] = {"No", "Yes", "4-byte"};
8004 static const char *arm_attr_tag_ABI_align8_preserved
[] =
8005 {"No", "Yes, except leaf SP", "Yes"};
8006 static const char *arm_attr_tag_ABI_enum_size
[] =
8007 {"Unused", "small", "int", "forced to int"};
8008 static const char *arm_attr_tag_ABI_HardFP_use
[] =
8009 {"As Tag_VFP_arch", "SP only", "DP only", "SP and DP"};
8010 static const char *arm_attr_tag_ABI_VFP_args
[] =
8011 {"AAPCS", "VFP registers", "custom"};
8012 static const char *arm_attr_tag_ABI_WMMX_args
[] =
8013 {"AAPCS", "WMMX registers", "custom"};
8014 static const char *arm_attr_tag_ABI_optimization_goals
[] =
8015 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
8016 "Aggressive Size", "Prefer Debug", "Aggressive Debug"};
8017 static const char *arm_attr_tag_ABI_FP_optimization_goals
[] =
8018 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
8019 "Aggressive Size", "Prefer Accuracy", "Aggressive Accuracy"};
8021 #define LOOKUP(id, name) \
8022 {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
8023 static arm_attr_public_tag arm_attr_public_tags
[] =
8025 {4, "CPU_raw_name", 1, NULL
},
8026 {5, "CPU_name", 1, NULL
},
8027 LOOKUP(6, CPU_arch
),
8028 {7, "CPU_arch_profile", 0, NULL
},
8029 LOOKUP(8, ARM_ISA_use
),
8030 LOOKUP(9, THUMB_ISA_use
),
8031 LOOKUP(10, VFP_arch
),
8032 LOOKUP(11, WMMX_arch
),
8033 LOOKUP(12, NEON_arch
),
8034 LOOKUP(13, ABI_PCS_config
),
8035 LOOKUP(14, ABI_PCS_R9_use
),
8036 LOOKUP(15, ABI_PCS_RW_data
),
8037 LOOKUP(16, ABI_PCS_RO_DATA
),
8038 LOOKUP(17, ABI_PCS_GOT_use
),
8039 LOOKUP(18, ABI_PCS_wchar_t
),
8040 LOOKUP(19, ABI_FP_rounding
),
8041 LOOKUP(20, ABI_FP_denormal
),
8042 LOOKUP(21, ABI_FP_exceptions
),
8043 LOOKUP(22, ABI_FP_user_exceptions
),
8044 LOOKUP(23, ABI_FP_number_model
),
8045 LOOKUP(24, ABI_align8_needed
),
8046 LOOKUP(25, ABI_align8_preserved
),
8047 LOOKUP(26, ABI_enum_size
),
8048 LOOKUP(27, ABI_HardFP_use
),
8049 LOOKUP(28, ABI_VFP_args
),
8050 LOOKUP(29, ABI_WMMX_args
),
8051 LOOKUP(30, ABI_optimization_goals
),
8052 LOOKUP(31, ABI_FP_optimization_goals
),
8053 {32, "compatibility", 0, NULL
}
8057 /* Read an unsigned LEB128 encoded value from p. Set *PLEN to the number of
8060 read_uleb128 (unsigned char *p
, unsigned int *plen
)
8074 val
|= ((unsigned int)c
& 0x7f) << shift
;
8083 static unsigned char *
8084 display_arm_attribute (unsigned char *p
)
8089 arm_attr_public_tag
*attr
;
8093 tag
= read_uleb128 (p
, &len
);
8096 for (i
= 0; i
< ARRAY_SIZE(arm_attr_public_tags
); i
++)
8098 if (arm_attr_public_tags
[i
].tag
== tag
)
8100 attr
= &arm_attr_public_tags
[i
];
8107 printf (" Tag_%s: ", attr
->name
);
8113 case 7: /* Tag_CPU_arch_profile. */
8114 val
= read_uleb128 (p
, &len
);
8118 case 0: printf ("None\n"); break;
8119 case 'A': printf ("Application\n"); break;
8120 case 'R': printf ("Realtime\n"); break;
8121 case 'M': printf ("Microcontroller\n"); break;
8122 default: printf ("??? (%d)\n", val
); break;
8126 case 32: /* Tag_compatibility. */
8127 val
= read_uleb128 (p
, &len
);
8129 printf ("flag = %d, vendor = %s\n", val
, p
);
8130 p
+= strlen((char *)p
) + 1;
8144 assert (attr
->type
& 0x80);
8145 val
= read_uleb128 (p
, &len
);
8147 type
= attr
->type
& 0x7f;
8149 printf ("??? (%d)\n", val
);
8151 printf ("%s\n", attr
->table
[val
]);
8158 type
= 1; /* String. */
8160 type
= 2; /* uleb128. */
8161 printf (" Tag_unknown_%d: ", tag
);
8166 printf ("\"%s\"\n", p
);
8167 p
+= strlen((char *)p
) + 1;
8171 val
= read_uleb128 (p
, &len
);
8173 printf ("%d (0x%x)\n", val
, val
);
8180 process_arm_specific (FILE *file
)
8182 Elf_Internal_Shdr
*sect
;
8183 unsigned char *contents
;
8186 bfd_vma section_len
;
8190 /* Find the section header so that we get the size. */
8191 for (i
= 0, sect
= section_headers
;
8192 i
< elf_header
.e_shnum
;
8195 if (sect
->sh_type
!= SHT_ARM_ATTRIBUTES
)
8198 contents
= get_data (NULL
, file
, sect
->sh_offset
, 1, sect
->sh_size
,
8206 len
= sect
->sh_size
- 1;
8211 bfd_boolean public_section
;
8213 section_len
= byte_get (p
, 4);
8215 if (section_len
> len
)
8217 printf (_("ERROR: Bad section length (%d > %d)\n"),
8218 (int)section_len
, (int)len
);
8222 printf ("Attribute Section: %s\n", p
);
8223 if (strcmp ((char *)p
, "aeabi") == 0)
8224 public_section
= TRUE
;
8226 public_section
= FALSE
;
8227 namelen
= strlen ((char *)p
) + 1;
8229 section_len
-= namelen
+ 4;
8230 while (section_len
> 0)
8235 size
= byte_get (p
, 4);
8236 if (size
> section_len
)
8238 printf (_("ERROR: Bad subsection length (%d > %d)\n"),
8239 (int)size
, (int)section_len
);
8242 section_len
-= size
;
8248 printf ("File Attributes\n");
8251 printf ("Section Attributes:");
8254 printf ("Symbol Attributes:");
8259 val
= read_uleb128 (p
, &i
);
8263 printf (" %d", val
);
8268 printf ("Unknown tag: %d\n", tag
);
8269 public_section
= FALSE
;
8275 p
= display_arm_attribute(p
);
8279 /* ??? Do something sensible, like dump hex. */
8280 printf (" Unknown section contexts\n");
8288 printf (_("Unknown format '%c'\n"), *p
);
8297 process_mips_specific (FILE *file
)
8299 Elf_Internal_Dyn
*entry
;
8300 size_t liblist_offset
= 0;
8301 size_t liblistno
= 0;
8302 size_t conflictsno
= 0;
8303 size_t options_offset
= 0;
8304 size_t conflicts_offset
= 0;
8306 /* We have a lot of special sections. Thanks SGI! */
8307 if (dynamic_section
== NULL
)
8308 /* No information available. */
8311 for (entry
= dynamic_section
; entry
->d_tag
!= DT_NULL
; ++entry
)
8312 switch (entry
->d_tag
)
8314 case DT_MIPS_LIBLIST
:
8316 = offset_from_vma (file
, entry
->d_un
.d_val
,
8317 liblistno
* sizeof (Elf32_External_Lib
));
8319 case DT_MIPS_LIBLISTNO
:
8320 liblistno
= entry
->d_un
.d_val
;
8322 case DT_MIPS_OPTIONS
:
8323 options_offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
8325 case DT_MIPS_CONFLICT
:
8327 = offset_from_vma (file
, entry
->d_un
.d_val
,
8328 conflictsno
* sizeof (Elf32_External_Conflict
));
8330 case DT_MIPS_CONFLICTNO
:
8331 conflictsno
= entry
->d_un
.d_val
;
8337 if (liblist_offset
!= 0 && liblistno
!= 0 && do_dynamic
)
8339 Elf32_External_Lib
*elib
;
8342 elib
= get_data (NULL
, file
, liblist_offset
,
8343 liblistno
, sizeof (Elf32_External_Lib
),
8347 printf ("\nSection '.liblist' contains %lu entries:\n",
8348 (unsigned long) liblistno
);
8349 fputs (" Library Time Stamp Checksum Version Flags\n",
8352 for (cnt
= 0; cnt
< liblistno
; ++cnt
)
8359 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
8360 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
8361 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
8362 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
8363 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
8365 tmp
= gmtime (&time
);
8366 snprintf (timebuf
, sizeof (timebuf
),
8367 "%04u-%02u-%02uT%02u:%02u:%02u",
8368 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
8369 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
8371 printf ("%3lu: ", (unsigned long) cnt
);
8372 if (VALID_DYNAMIC_NAME (liblist
.l_name
))
8373 print_symbol (20, GET_DYNAMIC_NAME (liblist
.l_name
));
8375 printf ("<corrupt: %9ld>", liblist
.l_name
);
8376 printf (" %s %#10lx %-7ld", timebuf
, liblist
.l_checksum
,
8379 if (liblist
.l_flags
== 0)
8390 { " EXACT_MATCH", LL_EXACT_MATCH
},
8391 { " IGNORE_INT_VER", LL_IGNORE_INT_VER
},
8392 { " REQUIRE_MINOR", LL_REQUIRE_MINOR
},
8393 { " EXPORTS", LL_EXPORTS
},
8394 { " DELAY_LOAD", LL_DELAY_LOAD
},
8395 { " DELTA", LL_DELTA
}
8397 int flags
= liblist
.l_flags
;
8401 fcnt
< sizeof (l_flags_vals
) / sizeof (l_flags_vals
[0]);
8403 if ((flags
& l_flags_vals
[fcnt
].bit
) != 0)
8405 fputs (l_flags_vals
[fcnt
].name
, stdout
);
8406 flags
^= l_flags_vals
[fcnt
].bit
;
8409 printf (" %#x", (unsigned int) flags
);
8419 if (options_offset
!= 0)
8421 Elf_External_Options
*eopt
;
8422 Elf_Internal_Shdr
*sect
= section_headers
;
8423 Elf_Internal_Options
*iopt
;
8424 Elf_Internal_Options
*option
;
8428 /* Find the section header so that we get the size. */
8429 while (sect
->sh_type
!= SHT_MIPS_OPTIONS
)
8432 eopt
= get_data (NULL
, file
, options_offset
, 1, sect
->sh_size
,
8436 iopt
= cmalloc ((sect
->sh_size
/ sizeof (eopt
)), sizeof (*iopt
));
8439 error (_("Out of memory"));
8446 while (offset
< sect
->sh_size
)
8448 Elf_External_Options
*eoption
;
8450 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
8452 option
->kind
= BYTE_GET (eoption
->kind
);
8453 option
->size
= BYTE_GET (eoption
->size
);
8454 option
->section
= BYTE_GET (eoption
->section
);
8455 option
->info
= BYTE_GET (eoption
->info
);
8457 offset
+= option
->size
;
8463 printf (_("\nSection '%s' contains %d entries:\n"),
8464 SECTION_NAME (sect
), cnt
);
8472 switch (option
->kind
)
8475 /* This shouldn't happen. */
8476 printf (" NULL %d %lx", option
->section
, option
->info
);
8479 printf (" REGINFO ");
8480 if (elf_header
.e_machine
== EM_MIPS
)
8483 Elf32_External_RegInfo
*ereg
;
8484 Elf32_RegInfo reginfo
;
8486 ereg
= (Elf32_External_RegInfo
*) (option
+ 1);
8487 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8488 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8489 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8490 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8491 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8492 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
8494 printf ("GPR %08lx GP 0x%lx\n",
8496 (unsigned long) reginfo
.ri_gp_value
);
8497 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8498 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8499 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8504 Elf64_External_RegInfo
*ereg
;
8505 Elf64_Internal_RegInfo reginfo
;
8507 ereg
= (Elf64_External_RegInfo
*) (option
+ 1);
8508 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8509 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8510 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8511 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8512 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8513 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
8515 printf ("GPR %08lx GP 0x",
8516 reginfo
.ri_gprmask
);
8517 printf_vma (reginfo
.ri_gp_value
);
8520 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8521 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8522 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8526 case ODK_EXCEPTIONS
:
8527 fputs (" EXCEPTIONS fpe_min(", stdout
);
8528 process_mips_fpe_exception (option
->info
& OEX_FPU_MIN
);
8529 fputs (") fpe_max(", stdout
);
8530 process_mips_fpe_exception ((option
->info
& OEX_FPU_MAX
) >> 8);
8531 fputs (")", stdout
);
8533 if (option
->info
& OEX_PAGE0
)
8534 fputs (" PAGE0", stdout
);
8535 if (option
->info
& OEX_SMM
)
8536 fputs (" SMM", stdout
);
8537 if (option
->info
& OEX_FPDBUG
)
8538 fputs (" FPDBUG", stdout
);
8539 if (option
->info
& OEX_DISMISS
)
8540 fputs (" DISMISS", stdout
);
8543 fputs (" PAD ", stdout
);
8544 if (option
->info
& OPAD_PREFIX
)
8545 fputs (" PREFIX", stdout
);
8546 if (option
->info
& OPAD_POSTFIX
)
8547 fputs (" POSTFIX", stdout
);
8548 if (option
->info
& OPAD_SYMBOL
)
8549 fputs (" SYMBOL", stdout
);
8552 fputs (" HWPATCH ", stdout
);
8553 if (option
->info
& OHW_R4KEOP
)
8554 fputs (" R4KEOP", stdout
);
8555 if (option
->info
& OHW_R8KPFETCH
)
8556 fputs (" R8KPFETCH", stdout
);
8557 if (option
->info
& OHW_R5KEOP
)
8558 fputs (" R5KEOP", stdout
);
8559 if (option
->info
& OHW_R5KCVTL
)
8560 fputs (" R5KCVTL", stdout
);
8563 fputs (" FILL ", stdout
);
8564 /* XXX Print content of info word? */
8567 fputs (" TAGS ", stdout
);
8568 /* XXX Print content of info word? */
8571 fputs (" HWAND ", stdout
);
8572 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8573 fputs (" R4KEOP_CHECKED", stdout
);
8574 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8575 fputs (" R4KEOP_CLEAN", stdout
);
8578 fputs (" HWOR ", stdout
);
8579 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8580 fputs (" R4KEOP_CHECKED", stdout
);
8581 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8582 fputs (" R4KEOP_CLEAN", stdout
);
8585 printf (" GP_GROUP %#06lx self-contained %#06lx",
8586 option
->info
& OGP_GROUP
,
8587 (option
->info
& OGP_SELF
) >> 16);
8590 printf (" IDENT %#06lx self-contained %#06lx",
8591 option
->info
& OGP_GROUP
,
8592 (option
->info
& OGP_SELF
) >> 16);
8595 /* This shouldn't happen. */
8596 printf (" %3d ??? %d %lx",
8597 option
->kind
, option
->section
, option
->info
);
8601 len
= sizeof (*eopt
);
8602 while (len
< option
->size
)
8603 if (((char *) option
)[len
] >= ' '
8604 && ((char *) option
)[len
] < 0x7f)
8605 printf ("%c", ((char *) option
)[len
++]);
8607 printf ("\\%03o", ((char *) option
)[len
++]);
8609 fputs ("\n", stdout
);
8617 if (conflicts_offset
!= 0 && conflictsno
!= 0)
8619 Elf32_Conflict
*iconf
;
8622 if (dynamic_symbols
== NULL
)
8624 error (_("conflict list found without a dynamic symbol table"));
8628 iconf
= cmalloc (conflictsno
, sizeof (*iconf
));
8631 error (_("Out of memory"));
8637 Elf32_External_Conflict
*econf32
;
8639 econf32
= get_data (NULL
, file
, conflicts_offset
,
8640 conflictsno
, sizeof (*econf32
), _("conflict"));
8644 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
8645 iconf
[cnt
] = BYTE_GET (econf32
[cnt
]);
8651 Elf64_External_Conflict
*econf64
;
8653 econf64
= get_data (NULL
, file
, conflicts_offset
,
8654 conflictsno
, sizeof (*econf64
), _("conflict"));
8658 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
8659 iconf
[cnt
] = BYTE_GET (econf64
[cnt
]);
8664 printf (_("\nSection '.conflict' contains %lu entries:\n"),
8665 (unsigned long) conflictsno
);
8666 puts (_(" Num: Index Value Name"));
8668 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
8670 Elf_Internal_Sym
*psym
= & dynamic_symbols
[iconf
[cnt
]];
8672 printf ("%5lu: %8lu ", (unsigned long) cnt
, iconf
[cnt
]);
8673 print_vma (psym
->st_value
, FULL_HEX
);
8675 if (VALID_DYNAMIC_NAME (psym
->st_name
))
8676 print_symbol (25, GET_DYNAMIC_NAME (psym
->st_name
));
8678 printf ("<corrupt: %14ld>", psym
->st_name
);
8689 process_gnu_liblist (FILE *file
)
8691 Elf_Internal_Shdr
*section
, *string_sec
;
8692 Elf32_External_Lib
*elib
;
8701 for (i
= 0, section
= section_headers
;
8702 i
< elf_header
.e_shnum
;
8705 switch (section
->sh_type
)
8707 case SHT_GNU_LIBLIST
:
8708 if (SECTION_HEADER_INDEX (section
->sh_link
) >= elf_header
.e_shnum
)
8711 elib
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
8716 string_sec
= SECTION_HEADER (section
->sh_link
);
8718 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
, 1,
8719 string_sec
->sh_size
, _("liblist string table"));
8720 strtab_size
= string_sec
->sh_size
;
8723 || section
->sh_entsize
!= sizeof (Elf32_External_Lib
))
8729 printf (_("\nLibrary list section '%s' contains %lu entries:\n"),
8730 SECTION_NAME (section
),
8731 (long) (section
->sh_size
/ sizeof (Elf32_External_Lib
)));
8733 puts (" Library Time Stamp Checksum Version Flags");
8735 for (cnt
= 0; cnt
< section
->sh_size
/ sizeof (Elf32_External_Lib
);
8743 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
8744 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
8745 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
8746 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
8747 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
8749 tmp
= gmtime (&time
);
8750 snprintf (timebuf
, sizeof (timebuf
),
8751 "%04u-%02u-%02uT%02u:%02u:%02u",
8752 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
8753 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
8755 printf ("%3lu: ", (unsigned long) cnt
);
8757 printf ("%-20s", liblist
.l_name
< strtab_size
8758 ? strtab
+ liblist
.l_name
: "<corrupt>");
8760 printf ("%-20.20s", liblist
.l_name
< strtab_size
8761 ? strtab
+ liblist
.l_name
: "<corrupt>");
8762 printf (" %s %#010lx %-7ld %-7ld\n", timebuf
, liblist
.l_checksum
,
8763 liblist
.l_version
, liblist
.l_flags
);
8774 get_note_type (unsigned e_type
)
8776 static char buff
[64];
8778 if (elf_header
.e_type
== ET_CORE
)
8782 return _("NT_AUXV (auxiliary vector)");
8784 return _("NT_PRSTATUS (prstatus structure)");
8786 return _("NT_FPREGSET (floating point registers)");
8788 return _("NT_PRPSINFO (prpsinfo structure)");
8790 return _("NT_TASKSTRUCT (task structure)");
8792 return _("NT_PRXFPREG (user_xfpregs structure)");
8794 return _("NT_PSTATUS (pstatus structure)");
8796 return _("NT_FPREGS (floating point registers)");
8798 return _("NT_PSINFO (psinfo structure)");
8800 return _("NT_LWPSTATUS (lwpstatus_t structure)");
8802 return _("NT_LWPSINFO (lwpsinfo_t structure)");
8803 case NT_WIN32PSTATUS
:
8804 return _("NT_WIN32PSTATUS (win32_pstatus structure)");
8812 return _("NT_VERSION (version)");
8814 return _("NT_ARCH (architecture)");
8819 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
8824 get_netbsd_elfcore_note_type (unsigned e_type
)
8826 static char buff
[64];
8828 if (e_type
== NT_NETBSDCORE_PROCINFO
)
8830 /* NetBSD core "procinfo" structure. */
8831 return _("NetBSD procinfo structure");
8834 /* As of Jan 2002 there are no other machine-independent notes
8835 defined for NetBSD core files. If the note type is less
8836 than the start of the machine-dependent note types, we don't
8839 if (e_type
< NT_NETBSDCORE_FIRSTMACH
)
8841 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
8845 switch (elf_header
.e_machine
)
8847 /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0
8848 and PT_GETFPREGS == mach+2. */
8853 case EM_SPARC32PLUS
:
8857 case NT_NETBSDCORE_FIRSTMACH
+0:
8858 return _("PT_GETREGS (reg structure)");
8859 case NT_NETBSDCORE_FIRSTMACH
+2:
8860 return _("PT_GETFPREGS (fpreg structure)");
8866 /* On all other arch's, PT_GETREGS == mach+1 and
8867 PT_GETFPREGS == mach+3. */
8871 case NT_NETBSDCORE_FIRSTMACH
+1:
8872 return _("PT_GETREGS (reg structure)");
8873 case NT_NETBSDCORE_FIRSTMACH
+3:
8874 return _("PT_GETFPREGS (fpreg structure)");
8880 snprintf (buff
, sizeof (buff
), _("PT_FIRSTMACH+%d"),
8881 e_type
- NT_NETBSDCORE_FIRSTMACH
);
8885 /* Note that by the ELF standard, the name field is already null byte
8886 terminated, and namesz includes the terminating null byte.
8887 I.E. the value of namesz for the name "FSF" is 4.
8889 If the value of namesz is zero, there is no name present. */
8891 process_note (Elf_Internal_Note
*pnote
)
8895 if (pnote
->namesz
== 0)
8896 /* If there is no note name, then use the default set of
8897 note type strings. */
8898 nt
= get_note_type (pnote
->type
);
8900 else if (const_strneq (pnote
->namedata
, "NetBSD-CORE"))
8901 /* NetBSD-specific core file notes. */
8902 nt
= get_netbsd_elfcore_note_type (pnote
->type
);
8905 /* Don't recognize this note name; just use the default set of
8906 note type strings. */
8907 nt
= get_note_type (pnote
->type
);
8909 printf (" %s\t\t0x%08lx\t%s\n",
8910 pnote
->namesz
? pnote
->namedata
: "(NONE)",
8917 process_corefile_note_segment (FILE *file
, bfd_vma offset
, bfd_vma length
)
8919 Elf_External_Note
*pnotes
;
8920 Elf_External_Note
*external
;
8926 pnotes
= get_data (NULL
, file
, offset
, 1, length
, _("notes"));
8932 printf (_("\nNotes at offset 0x%08lx with length 0x%08lx:\n"),
8933 (unsigned long) offset
, (unsigned long) length
);
8934 printf (_(" Owner\t\tData size\tDescription\n"));
8936 while (external
< (Elf_External_Note
*)((char *) pnotes
+ length
))
8938 Elf_External_Note
*next
;
8939 Elf_Internal_Note inote
;
8942 inote
.type
= BYTE_GET (external
->type
);
8943 inote
.namesz
= BYTE_GET (external
->namesz
);
8944 inote
.namedata
= external
->name
;
8945 inote
.descsz
= BYTE_GET (external
->descsz
);
8946 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 2);
8947 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
8949 next
= (Elf_External_Note
*)(inote
.descdata
+ align_power (inote
.descsz
, 2));
8951 if (((char *) next
) > (((char *) pnotes
) + length
))
8953 warn (_("corrupt note found at offset %lx into core notes\n"),
8954 (long)((char *)external
- (char *)pnotes
));
8955 warn (_(" type: %lx, namesize: %08lx, descsize: %08lx\n"),
8956 inote
.type
, inote
.namesz
, inote
.descsz
);
8962 /* Verify that name is null terminated. It appears that at least
8963 one version of Linux (RedHat 6.0) generates corefiles that don't
8964 comply with the ELF spec by failing to include the null byte in
8966 if (inote
.namedata
[inote
.namesz
] != '\0')
8968 temp
= malloc (inote
.namesz
+ 1);
8972 error (_("Out of memory\n"));
8977 strncpy (temp
, inote
.namedata
, inote
.namesz
);
8978 temp
[inote
.namesz
] = 0;
8980 /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */
8981 inote
.namedata
= temp
;
8984 res
&= process_note (& inote
);
8999 process_corefile_note_segments (FILE *file
)
9001 Elf_Internal_Phdr
*segment
;
9005 if (! get_program_headers (file
))
9008 for (i
= 0, segment
= program_headers
;
9009 i
< elf_header
.e_phnum
;
9012 if (segment
->p_type
== PT_NOTE
)
9013 res
&= process_corefile_note_segment (file
,
9014 (bfd_vma
) segment
->p_offset
,
9015 (bfd_vma
) segment
->p_filesz
);
9022 process_note_sections (FILE *file
)
9024 Elf_Internal_Shdr
*section
;
9028 for (i
= 0, section
= section_headers
;
9029 i
< elf_header
.e_shnum
;
9031 if (section
->sh_type
== SHT_NOTE
)
9032 res
&= process_corefile_note_segment (file
,
9033 (bfd_vma
) section
->sh_offset
,
9034 (bfd_vma
) section
->sh_size
);
9040 process_notes (FILE *file
)
9042 /* If we have not been asked to display the notes then do nothing. */
9046 if (elf_header
.e_type
!= ET_CORE
)
9047 return process_note_sections (file
);
9049 /* No program headers means no NOTE segment. */
9050 if (elf_header
.e_phnum
> 0)
9051 return process_corefile_note_segments (file
);
9053 printf (_("No note segments present in the core file.\n"));
9058 process_arch_specific (FILE *file
)
9063 switch (elf_header
.e_machine
)
9066 return process_arm_specific (file
);
9068 case EM_MIPS_RS3_LE
:
9069 return process_mips_specific (file
);
9078 get_file_header (FILE *file
)
9080 /* Read in the identity array. */
9081 if (fread (elf_header
.e_ident
, EI_NIDENT
, 1, file
) != 1)
9084 /* Determine how to read the rest of the header. */
9085 switch (elf_header
.e_ident
[EI_DATA
])
9087 default: /* fall through */
9088 case ELFDATANONE
: /* fall through */
9090 byte_get
= byte_get_little_endian
;
9091 byte_put
= byte_put_little_endian
;
9094 byte_get
= byte_get_big_endian
;
9095 byte_put
= byte_put_big_endian
;
9099 /* For now we only support 32 bit and 64 bit ELF files. */
9100 is_32bit_elf
= (elf_header
.e_ident
[EI_CLASS
] != ELFCLASS64
);
9102 /* Read in the rest of the header. */
9105 Elf32_External_Ehdr ehdr32
;
9107 if (fread (ehdr32
.e_type
, sizeof (ehdr32
) - EI_NIDENT
, 1, file
) != 1)
9110 elf_header
.e_type
= BYTE_GET (ehdr32
.e_type
);
9111 elf_header
.e_machine
= BYTE_GET (ehdr32
.e_machine
);
9112 elf_header
.e_version
= BYTE_GET (ehdr32
.e_version
);
9113 elf_header
.e_entry
= BYTE_GET (ehdr32
.e_entry
);
9114 elf_header
.e_phoff
= BYTE_GET (ehdr32
.e_phoff
);
9115 elf_header
.e_shoff
= BYTE_GET (ehdr32
.e_shoff
);
9116 elf_header
.e_flags
= BYTE_GET (ehdr32
.e_flags
);
9117 elf_header
.e_ehsize
= BYTE_GET (ehdr32
.e_ehsize
);
9118 elf_header
.e_phentsize
= BYTE_GET (ehdr32
.e_phentsize
);
9119 elf_header
.e_phnum
= BYTE_GET (ehdr32
.e_phnum
);
9120 elf_header
.e_shentsize
= BYTE_GET (ehdr32
.e_shentsize
);
9121 elf_header
.e_shnum
= BYTE_GET (ehdr32
.e_shnum
);
9122 elf_header
.e_shstrndx
= BYTE_GET (ehdr32
.e_shstrndx
);
9126 Elf64_External_Ehdr ehdr64
;
9128 /* If we have been compiled with sizeof (bfd_vma) == 4, then
9129 we will not be able to cope with the 64bit data found in
9130 64 ELF files. Detect this now and abort before we start
9131 overwriting things. */
9132 if (sizeof (bfd_vma
) < 8)
9134 error (_("This instance of readelf has been built without support for a\n\
9135 64 bit data type and so it cannot read 64 bit ELF files.\n"));
9139 if (fread (ehdr64
.e_type
, sizeof (ehdr64
) - EI_NIDENT
, 1, file
) != 1)
9142 elf_header
.e_type
= BYTE_GET (ehdr64
.e_type
);
9143 elf_header
.e_machine
= BYTE_GET (ehdr64
.e_machine
);
9144 elf_header
.e_version
= BYTE_GET (ehdr64
.e_version
);
9145 elf_header
.e_entry
= BYTE_GET (ehdr64
.e_entry
);
9146 elf_header
.e_phoff
= BYTE_GET (ehdr64
.e_phoff
);
9147 elf_header
.e_shoff
= BYTE_GET (ehdr64
.e_shoff
);
9148 elf_header
.e_flags
= BYTE_GET (ehdr64
.e_flags
);
9149 elf_header
.e_ehsize
= BYTE_GET (ehdr64
.e_ehsize
);
9150 elf_header
.e_phentsize
= BYTE_GET (ehdr64
.e_phentsize
);
9151 elf_header
.e_phnum
= BYTE_GET (ehdr64
.e_phnum
);
9152 elf_header
.e_shentsize
= BYTE_GET (ehdr64
.e_shentsize
);
9153 elf_header
.e_shnum
= BYTE_GET (ehdr64
.e_shnum
);
9154 elf_header
.e_shstrndx
= BYTE_GET (ehdr64
.e_shstrndx
);
9157 if (elf_header
.e_shoff
)
9159 /* There may be some extensions in the first section header. Don't
9160 bomb if we can't read it. */
9162 get_32bit_section_headers (file
, 1);
9164 get_64bit_section_headers (file
, 1);
9167 is_relocatable
= elf_header
.e_type
== ET_REL
;
9172 /* Process one ELF object file according to the command line options.
9173 This file may actually be stored in an archive. The file is
9174 positioned at the start of the ELF object. */
9177 process_object (char *file_name
, FILE *file
)
9181 if (! get_file_header (file
))
9183 error (_("%s: Failed to read file header\n"), file_name
);
9187 /* Initialise per file variables. */
9188 for (i
= NUM_ELEM (version_info
); i
--;)
9189 version_info
[i
] = 0;
9191 for (i
= NUM_ELEM (dynamic_info
); i
--;)
9192 dynamic_info
[i
] = 0;
9194 /* Process the file. */
9196 printf (_("\nFile: %s\n"), file_name
);
9198 /* Initialise the dump_sects array from the cmdline_dump_sects array.
9199 Note we do this even if cmdline_dump_sects is empty because we
9200 must make sure that the dump_sets array is zeroed out before each
9201 object file is processed. */
9202 if (num_dump_sects
> num_cmdline_dump_sects
)
9203 memset (dump_sects
, 0, num_dump_sects
);
9205 if (num_cmdline_dump_sects
> 0)
9207 if (num_dump_sects
== 0)
9208 /* A sneaky way of allocating the dump_sects array. */
9209 request_dump (num_cmdline_dump_sects
, 0);
9211 assert (num_dump_sects
>= num_cmdline_dump_sects
);
9212 memcpy (dump_sects
, cmdline_dump_sects
, num_cmdline_dump_sects
);
9215 if (! process_file_header ())
9218 if (! process_section_headers (file
))
9220 /* Without loaded section headers we cannot process lots of
9222 do_unwind
= do_version
= do_dump
= do_arch
= 0;
9224 if (! do_using_dynamic
)
9225 do_syms
= do_reloc
= 0;
9228 if (! process_section_groups (file
))
9230 /* Without loaded section groups we cannot process unwind. */
9234 if (process_program_headers (file
))
9235 process_dynamic_section (file
);
9237 process_relocs (file
);
9239 process_unwind (file
);
9241 process_symbol_table (file
);
9243 process_syminfo (file
);
9245 process_version_sections (file
);
9247 process_section_contents (file
);
9249 process_notes (file
);
9251 process_gnu_liblist (file
);
9253 process_arch_specific (file
);
9255 if (program_headers
)
9257 free (program_headers
);
9258 program_headers
= NULL
;
9261 if (section_headers
)
9263 free (section_headers
);
9264 section_headers
= NULL
;
9269 free (string_table
);
9270 string_table
= NULL
;
9271 string_table_length
= 0;
9274 if (dynamic_strings
)
9276 free (dynamic_strings
);
9277 dynamic_strings
= NULL
;
9278 dynamic_strings_length
= 0;
9281 if (dynamic_symbols
)
9283 free (dynamic_symbols
);
9284 dynamic_symbols
= NULL
;
9285 num_dynamic_syms
= 0;
9288 if (dynamic_syminfo
)
9290 free (dynamic_syminfo
);
9291 dynamic_syminfo
= NULL
;
9294 if (section_headers_groups
)
9296 free (section_headers_groups
);
9297 section_headers_groups
= NULL
;
9302 struct group_list
*g
, *next
;
9304 for (i
= 0; i
< group_count
; i
++)
9306 for (g
= section_groups
[i
].root
; g
!= NULL
; g
= next
)
9313 free (section_groups
);
9314 section_groups
= NULL
;
9317 free_debug_memory ();
9322 /* Process an ELF archive. The file is positioned just after the
9326 process_archive (char *file_name
, FILE *file
)
9328 struct ar_hdr arhdr
;
9331 char *longnames
= NULL
;
9332 unsigned long longnames_size
= 0;
9333 size_t file_name_size
;
9338 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9339 if (got
!= sizeof arhdr
)
9344 error (_("%s: failed to read archive header\n"), file_name
);
9348 if (const_strneq (arhdr
.ar_name
, "/ "))
9350 /* This is the archive symbol table. Skip it.
9351 FIXME: We should have an option to dump it. */
9352 size
= strtoul (arhdr
.ar_size
, NULL
, 10);
9353 if (fseek (file
, size
+ (size
& 1), SEEK_CUR
) != 0)
9355 error (_("%s: failed to skip archive symbol table\n"), file_name
);
9359 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9360 if (got
!= sizeof arhdr
)
9365 error (_("%s: failed to read archive header\n"), file_name
);
9370 if (const_strneq (arhdr
.ar_name
, "// "))
9372 /* This is the archive string table holding long member
9375 longnames_size
= strtoul (arhdr
.ar_size
, NULL
, 10);
9377 longnames
= malloc (longnames_size
);
9378 if (longnames
== NULL
)
9380 error (_("Out of memory\n"));
9384 if (fread (longnames
, longnames_size
, 1, file
) != 1)
9387 error (_("%s: failed to read string table\n"), file_name
);
9391 if ((longnames_size
& 1) != 0)
9394 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9395 if (got
!= sizeof arhdr
)
9402 error (_("%s: failed to read archive header\n"), file_name
);
9407 file_name_size
= strlen (file_name
);
9416 if (arhdr
.ar_name
[0] == '/')
9420 off
= strtoul (arhdr
.ar_name
+ 1, NULL
, 10);
9421 if (off
>= longnames_size
)
9423 error (_("%s: invalid archive string table offset %lu\n"), file_name
, off
);
9428 name
= longnames
+ off
;
9429 nameend
= memchr (name
, '/', longnames_size
- off
);
9433 name
= arhdr
.ar_name
;
9434 nameend
= memchr (name
, '/', 16);
9437 if (nameend
== NULL
)
9439 error (_("%s: bad archive file name\n"), file_name
);
9444 namealc
= malloc (file_name_size
+ (nameend
- name
) + 3);
9445 if (namealc
== NULL
)
9447 error (_("Out of memory\n"));
9452 memcpy (namealc
, file_name
, file_name_size
);
9453 namealc
[file_name_size
] = '(';
9454 memcpy (namealc
+ file_name_size
+ 1, name
, nameend
- name
);
9455 namealc
[file_name_size
+ 1 + (nameend
- name
)] = ')';
9456 namealc
[file_name_size
+ 2 + (nameend
- name
)] = '\0';
9458 archive_file_offset
= ftell (file
);
9459 archive_file_size
= strtoul (arhdr
.ar_size
, NULL
, 10);
9461 ret
|= process_object (namealc
, file
);
9466 (archive_file_offset
9468 + (archive_file_size
& 1)),
9471 error (_("%s: failed to seek to next archive header\n"), file_name
);
9476 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9477 if (got
!= sizeof arhdr
)
9482 error (_("%s: failed to read archive header\n"), file_name
);
9495 process_file (char *file_name
)
9498 struct stat statbuf
;
9502 if (stat (file_name
, &statbuf
) < 0)
9504 if (errno
== ENOENT
)
9505 error (_("'%s': No such file\n"), file_name
);
9507 error (_("Could not locate '%s'. System error message: %s\n"),
9508 file_name
, strerror (errno
));
9512 if (! S_ISREG (statbuf
.st_mode
))
9514 error (_("'%s' is not an ordinary file\n"), file_name
);
9518 file
= fopen (file_name
, "rb");
9521 error (_("Input file '%s' is not readable.\n"), file_name
);
9525 if (fread (armag
, SARMAG
, 1, file
) != 1)
9527 error (_("%s: Failed to read file header\n"), file_name
);
9532 if (memcmp (armag
, ARMAG
, SARMAG
) == 0)
9533 ret
= process_archive (file_name
, file
);
9537 archive_file_size
= archive_file_offset
= 0;
9538 ret
= process_object (file_name
, file
);
9546 #ifdef SUPPORT_DISASSEMBLY
9547 /* Needed by the i386 disassembler. For extra credit, someone could
9548 fix this so that we insert symbolic addresses here, esp for GOT/PLT
9552 print_address (unsigned int addr
, FILE *outfile
)
9554 fprintf (outfile
,"0x%8.8x", addr
);
9557 /* Needed by the i386 disassembler. */
9559 db_task_printsym (unsigned int addr
)
9561 print_address (addr
, stderr
);
9566 main (int argc
, char **argv
)
9570 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
9571 setlocale (LC_MESSAGES
, "");
9573 #if defined (HAVE_SETLOCALE)
9574 setlocale (LC_CTYPE
, "");
9576 bindtextdomain (PACKAGE
, LOCALEDIR
);
9577 textdomain (PACKAGE
);
9579 expandargv (&argc
, &argv
);
9581 parse_args (argc
, argv
);
9583 if (num_dump_sects
> 0)
9585 /* Make a copy of the dump_sects array. */
9586 cmdline_dump_sects
= malloc (num_dump_sects
);
9587 if (cmdline_dump_sects
== NULL
)
9588 error (_("Out of memory allocating dump request table."));
9591 memcpy (cmdline_dump_sects
, dump_sects
, num_dump_sects
);
9592 num_cmdline_dump_sects
= num_dump_sects
;
9596 if (optind
< (argc
- 1))
9600 while (optind
< argc
)
9601 err
|= process_file (argv
[optind
++]);
9603 if (dump_sects
!= NULL
)
9605 if (cmdline_dump_sects
!= NULL
)
9606 free (cmdline_dump_sects
);