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"
92 #include "elf/m68hc11.h"
93 #include "elf/mcore.h"
96 #include "elf/mn10200.h"
97 #include "elf/mn10300.h"
99 #include "elf/msp430.h"
100 #include "elf/or32.h"
103 #include "elf/ppc64.h"
104 #include "elf/s390.h"
106 #include "elf/sparc.h"
107 #include "elf/v850.h"
109 #include "elf/x86-64.h"
110 #include "elf/xstormy16.h"
112 #include "elf/iq2000.h"
113 #include "elf/xtensa.h"
119 #include "libiberty.h"
121 char *program_name
= "readelf";
122 static long archive_file_offset
;
123 static unsigned long archive_file_size
;
124 static unsigned long dynamic_addr
;
125 static bfd_size_type dynamic_size
;
126 static unsigned int dynamic_nent
;
127 static char *dynamic_strings
;
128 static unsigned long dynamic_strings_length
;
129 static char *string_table
;
130 static unsigned long string_table_length
;
131 static unsigned long num_dynamic_syms
;
132 static Elf_Internal_Sym
*dynamic_symbols
;
133 static Elf_Internal_Syminfo
*dynamic_syminfo
;
134 static unsigned long dynamic_syminfo_offset
;
135 static unsigned int dynamic_syminfo_nent
;
136 static char program_interpreter
[64];
137 static bfd_vma dynamic_info
[DT_JMPREL
+ 1];
138 static bfd_vma dynamic_info_DT_GNU_HASH
;
139 static bfd_vma version_info
[16];
140 static Elf_Internal_Ehdr elf_header
;
141 static Elf_Internal_Shdr
*section_headers
;
142 static Elf_Internal_Phdr
*program_headers
;
143 static Elf_Internal_Dyn
*dynamic_section
;
144 static Elf_Internal_Shdr
*symtab_shndx_hdr
;
145 static int show_name
;
146 static int do_dynamic
;
149 static int do_sections
;
150 static int do_section_groups
;
151 static int do_section_details
;
152 static int do_segments
;
153 static int do_unwind
;
154 static int do_using_dynamic
;
155 static int do_header
;
157 static int do_version
;
159 static int do_histogram
;
160 static int do_debugging
;
163 static int is_32bit_elf
;
167 struct group_list
*next
;
168 unsigned int section_index
;
173 struct group_list
*root
;
174 unsigned int group_index
;
177 static size_t group_count
;
178 static struct group
*section_groups
;
179 static struct group
**section_headers_groups
;
181 /* A linked list of the section names for which dumps were requested
183 struct dump_list_entry
187 struct dump_list_entry
*next
;
189 static struct dump_list_entry
*dump_sects_byname
;
191 /* A dynamic array of flags indicating for which sections a hex dump
192 has been requested (via the -x switch) and/or a disassembly dump
193 (via the -i switch). */
194 char *cmdline_dump_sects
= NULL
;
195 unsigned num_cmdline_dump_sects
= 0;
197 /* A dynamic array of flags indicating for which sections a dump of
198 some kind has been requested. It is reset on a per-object file
199 basis and then initialised from the cmdline_dump_sects array,
200 the results of interpreting the -w switch, and the
201 dump_sects_byname list. */
202 char *dump_sects
= NULL
;
203 unsigned int num_dump_sects
= 0;
205 #define HEX_DUMP (1 << 0)
206 #define DISASS_DUMP (1 << 1)
207 #define DEBUG_DUMP (1 << 2)
209 /* How to print a vma value. */
210 typedef enum print_mode
222 static void (*byte_put
) (unsigned char *, bfd_vma
, int);
226 #define SECTION_NAME(X) \
227 ((X) == NULL ? "<none>" \
228 : string_table == NULL ? "<no-name>" \
229 : ((X)->sh_name >= string_table_length ? "<corrupt>" \
230 : string_table + (X)->sh_name))
232 /* Given st_shndx I, map to section_headers index. */
233 #define SECTION_HEADER_INDEX(I) \
234 ((I) < SHN_LORESERVE \
236 : ((I) <= SHN_HIRESERVE \
238 : (I) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))
240 /* Reverse of the above. */
241 #define SECTION_HEADER_NUM(N) \
242 ((N) < SHN_LORESERVE \
244 : (N) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))
246 #define SECTION_HEADER(I) (section_headers + SECTION_HEADER_INDEX (I))
248 #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
250 #define BYTE_GET(field) byte_get (field, sizeof (field))
252 #define NUM_ELEM(array) (sizeof (array) / sizeof ((array)[0]))
254 #define GET_ELF_SYMBOLS(file, section) \
255 (is_32bit_elf ? get_32bit_elf_symbols (file, section) \
256 : get_64bit_elf_symbols (file, section))
258 #define VALID_DYNAMIC_NAME(offset) ((dynamic_strings != NULL) && (offset < dynamic_strings_length))
259 /* GET_DYNAMIC_NAME asssumes that VALID_DYNAMIC_NAME has
260 already been called and verified that the string exists. */
261 #define GET_DYNAMIC_NAME(offset) (dynamic_strings + offset)
263 /* This is just a bit of syntatic sugar. */
264 #define streq(a,b) (strcmp ((a), (b)) == 0)
265 #define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
268 get_data (void *var
, FILE *file
, long offset
, size_t size
, size_t nmemb
,
273 if (size
== 0 || nmemb
== 0)
276 if (fseek (file
, archive_file_offset
+ offset
, SEEK_SET
))
278 error (_("Unable to seek to 0x%lx for %s\n"),
279 archive_file_offset
+ offset
, reason
);
286 /* Check for overflow. */
287 if (nmemb
< (~(size_t) 0 - 1) / size
)
288 /* + 1 so that we can '\0' terminate invalid string table sections. */
289 mvar
= malloc (size
* nmemb
+ 1);
293 error (_("Out of memory allocating 0x%lx bytes for %s\n"),
294 (unsigned long)(size
* nmemb
), reason
);
298 ((char *) mvar
)[size
* nmemb
] = '\0';
301 if (fread (mvar
, size
, nmemb
, file
) != nmemb
)
303 error (_("Unable to read in 0x%lx bytes of %s\n"),
304 (unsigned long)(size
* nmemb
), reason
);
314 byte_put_little_endian (unsigned char *field
, bfd_vma value
, int size
)
319 field
[7] = (((value
>> 24) >> 24) >> 8) & 0xff;
320 field
[6] = ((value
>> 24) >> 24) & 0xff;
321 field
[5] = ((value
>> 24) >> 16) & 0xff;
322 field
[4] = ((value
>> 24) >> 8) & 0xff;
325 field
[3] = (value
>> 24) & 0xff;
326 field
[2] = (value
>> 16) & 0xff;
329 field
[1] = (value
>> 8) & 0xff;
332 field
[0] = value
& 0xff;
336 error (_("Unhandled data length: %d\n"), size
);
341 #if defined BFD64 && !BFD_HOST_64BIT_LONG
343 print_dec_vma (bfd_vma vma
, int is_signed
)
349 if (is_signed
&& (bfd_signed_vma
) vma
< 0)
358 *bufp
++ = '0' + vma
% 10;
370 print_hex_vma (bfd_vma vma
)
378 char digit
= '0' + (vma
& 0x0f);
380 digit
+= 'a' - '0' - 10;
393 /* Print a VMA value. */
395 print_vma (bfd_vma vma
, print_mode mode
)
404 return printf ("0x%8.8lx", (unsigned long) vma
);
407 return printf ("%8.8lx", (unsigned long) vma
);
411 return printf ("%5ld", (long) vma
);
415 return printf ("0x%lx", (unsigned long) vma
);
418 return printf ("%lx", (unsigned long) vma
);
421 return printf ("%ld", (unsigned long) vma
);
424 return printf ("%lu", (unsigned long) vma
);
447 #if BFD_HOST_64BIT_LONG
448 return nc
+ printf ("%lx", vma
);
450 return nc
+ print_hex_vma (vma
);
454 #if BFD_HOST_64BIT_LONG
455 return printf ("%ld", vma
);
457 return print_dec_vma (vma
, 1);
461 #if BFD_HOST_64BIT_LONG
463 return printf ("%5ld", vma
);
465 return printf ("%#lx", vma
);
468 return printf ("%5ld", _bfd_int64_low (vma
));
470 return print_hex_vma (vma
);
474 #if BFD_HOST_64BIT_LONG
475 return printf ("%lu", vma
);
477 return print_dec_vma (vma
, 0);
485 /* Display a symbol on stdout. If do_wide is not true then
486 format the symbol to be at most WIDTH characters,
487 truncating as necessary. If WIDTH is negative then
488 format the string to be exactly - WIDTH characters,
489 truncating or padding as necessary. */
492 print_symbol (int width
, const char *symbol
)
495 printf ("%s", symbol
);
497 printf ("%-*.*s", width
, width
, symbol
);
499 printf ("%-.*s", width
, symbol
);
503 byte_put_big_endian (unsigned char *field
, bfd_vma value
, int size
)
508 field
[7] = value
& 0xff;
509 field
[6] = (value
>> 8) & 0xff;
510 field
[5] = (value
>> 16) & 0xff;
511 field
[4] = (value
>> 24) & 0xff;
516 field
[3] = value
& 0xff;
517 field
[2] = (value
>> 8) & 0xff;
521 field
[1] = value
& 0xff;
525 field
[0] = value
& 0xff;
529 error (_("Unhandled data length: %d\n"), size
);
534 /* Return a pointer to section NAME, or NULL if no such section exists. */
536 static Elf_Internal_Shdr
*
537 find_section (const char *name
)
541 for (i
= 0; i
< elf_header
.e_shnum
; i
++)
542 if (streq (SECTION_NAME (section_headers
+ i
), name
))
543 return section_headers
+ i
;
548 /* Guess the relocation size commonly used by the specific machines. */
551 guess_is_rela (unsigned long e_machine
)
555 /* Targets that use REL relocations. */
570 /* Targets that use RELA relocations. */
585 case EM_CYGNUS_MN10200
:
587 case EM_CYGNUS_MN10300
:
618 case EM_ALTERA_NIOS2
:
639 warn (_("Don't know about relocations on this machine architecture\n"));
645 slurp_rela_relocs (FILE *file
,
646 unsigned long rel_offset
,
647 unsigned long rel_size
,
648 Elf_Internal_Rela
**relasp
,
649 unsigned long *nrelasp
)
651 Elf_Internal_Rela
*relas
;
652 unsigned long nrelas
;
657 Elf32_External_Rela
*erelas
;
659 erelas
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
663 nrelas
= rel_size
/ sizeof (Elf32_External_Rela
);
665 relas
= cmalloc (nrelas
, sizeof (Elf_Internal_Rela
));
670 error (_("out of memory parsing relocs"));
674 for (i
= 0; i
< nrelas
; i
++)
676 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
677 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
678 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
685 Elf64_External_Rela
*erelas
;
687 erelas
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
691 nrelas
= rel_size
/ sizeof (Elf64_External_Rela
);
693 relas
= cmalloc (nrelas
, sizeof (Elf_Internal_Rela
));
698 error (_("out of memory parsing relocs"));
702 for (i
= 0; i
< nrelas
; i
++)
704 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
705 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
706 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
717 slurp_rel_relocs (FILE *file
,
718 unsigned long rel_offset
,
719 unsigned long rel_size
,
720 Elf_Internal_Rela
**relsp
,
721 unsigned long *nrelsp
)
723 Elf_Internal_Rela
*rels
;
729 Elf32_External_Rel
*erels
;
731 erels
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
735 nrels
= rel_size
/ sizeof (Elf32_External_Rel
);
737 rels
= cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
742 error (_("out of memory parsing relocs"));
746 for (i
= 0; i
< nrels
; i
++)
748 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
749 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
750 rels
[i
].r_addend
= 0;
757 Elf64_External_Rel
*erels
;
759 erels
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
763 nrels
= rel_size
/ sizeof (Elf64_External_Rel
);
765 rels
= cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
770 error (_("out of memory parsing relocs"));
774 for (i
= 0; i
< nrels
; i
++)
776 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
777 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
778 rels
[i
].r_addend
= 0;
788 /* Display the contents of the relocation data found at the specified
792 dump_relocations (FILE *file
,
793 unsigned long rel_offset
,
794 unsigned long rel_size
,
795 Elf_Internal_Sym
*symtab
,
798 unsigned long strtablen
,
802 Elf_Internal_Rela
*rels
;
805 if (is_rela
== UNKNOWN
)
806 is_rela
= guess_is_rela (elf_header
.e_machine
);
810 if (!slurp_rela_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
815 if (!slurp_rel_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
824 printf (_(" Offset Info Type Sym. Value Symbol's Name + Addend\n"));
826 printf (_(" Offset Info Type Sym.Value Sym. Name + Addend\n"));
831 printf (_(" Offset Info Type Sym. Value Symbol's Name\n"));
833 printf (_(" Offset Info Type Sym.Value Sym. Name\n"));
841 printf (_(" Offset Info Type Symbol's Value Symbol's Name + Addend\n"));
843 printf (_(" Offset Info Type Sym. Value Sym. Name + Addend\n"));
848 printf (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
850 printf (_(" Offset Info Type Sym. Value Sym. Name\n"));
854 for (i
= 0; i
< rel_size
; i
++)
857 const char *rtype2
= NULL
;
858 const char *rtype3
= NULL
;
861 bfd_vma symtab_index
;
866 offset
= rels
[i
].r_offset
;
867 info
= rels
[i
].r_info
;
871 type
= ELF32_R_TYPE (info
);
872 symtab_index
= ELF32_R_SYM (info
);
876 /* The #ifdef BFD64 below is to prevent a compile time warning.
877 We know that if we do not have a 64 bit data type that we
878 will never execute this code anyway. */
880 if (elf_header
.e_machine
== EM_MIPS
)
882 /* In little-endian objects, r_info isn't really a 64-bit
883 little-endian value: it has a 32-bit little-endian
884 symbol index followed by four individual byte fields.
885 Reorder INFO accordingly. */
886 if (elf_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
887 info
= (((info
& 0xffffffff) << 32)
888 | ((info
>> 56) & 0xff)
889 | ((info
>> 40) & 0xff00)
890 | ((info
>> 24) & 0xff0000)
891 | ((info
>> 8) & 0xff000000));
892 type
= ELF64_MIPS_R_TYPE (info
);
893 type2
= ELF64_MIPS_R_TYPE2 (info
);
894 type3
= ELF64_MIPS_R_TYPE3 (info
);
896 else if (elf_header
.e_machine
== EM_SPARCV9
)
897 type
= ELF64_R_TYPE_ID (info
);
899 type
= ELF64_R_TYPE (info
);
901 symtab_index
= ELF64_R_SYM (info
);
907 #ifdef _bfd_int64_low
908 printf ("%8.8lx %8.8lx ", _bfd_int64_low (offset
), _bfd_int64_low (info
));
910 printf ("%8.8lx %8.8lx ", offset
, info
);
915 #ifdef _bfd_int64_low
917 ? "%8.8lx%8.8lx %8.8lx%8.8lx "
918 : "%4.4lx%8.8lx %4.4lx%8.8lx ",
919 _bfd_int64_high (offset
),
920 _bfd_int64_low (offset
),
921 _bfd_int64_high (info
),
922 _bfd_int64_low (info
));
925 ? "%16.16lx %16.16lx "
926 : "%12.12lx %12.12lx ",
931 switch (elf_header
.e_machine
)
939 rtype
= elf_m32r_reloc_type (type
);
944 rtype
= elf_i386_reloc_type (type
);
949 rtype
= elf_m68hc11_reloc_type (type
);
953 rtype
= elf_m68k_reloc_type (type
);
957 rtype
= elf_i960_reloc_type (type
);
962 rtype
= elf_avr_reloc_type (type
);
969 rtype
= elf_sparc_reloc_type (type
);
974 rtype
= v850_reloc_type (type
);
979 rtype
= elf_d10v_reloc_type (type
);
984 rtype
= elf_d30v_reloc_type (type
);
988 rtype
= elf_dlx_reloc_type (type
);
992 rtype
= elf_sh_reloc_type (type
);
996 case EM_CYGNUS_MN10300
:
997 rtype
= elf_mn10300_reloc_type (type
);
1001 case EM_CYGNUS_MN10200
:
1002 rtype
= elf_mn10200_reloc_type (type
);
1006 case EM_CYGNUS_FR30
:
1007 rtype
= elf_fr30_reloc_type (type
);
1011 rtype
= elf_frv_reloc_type (type
);
1015 rtype
= elf_mcore_reloc_type (type
);
1019 rtype
= elf_mmix_reloc_type (type
);
1024 rtype
= elf_msp430_reloc_type (type
);
1028 rtype
= elf_ppc_reloc_type (type
);
1032 rtype
= elf_ppc64_reloc_type (type
);
1036 case EM_MIPS_RS3_LE
:
1037 rtype
= elf_mips_reloc_type (type
);
1040 rtype2
= elf_mips_reloc_type (type2
);
1041 rtype3
= elf_mips_reloc_type (type3
);
1046 rtype
= elf_alpha_reloc_type (type
);
1050 rtype
= elf_arm_reloc_type (type
);
1054 rtype
= elf_arc_reloc_type (type
);
1058 rtype
= elf_hppa_reloc_type (type
);
1064 rtype
= elf_h8_reloc_type (type
);
1069 rtype
= elf_or32_reloc_type (type
);
1074 rtype
= elf_pj_reloc_type (type
);
1077 rtype
= elf_ia64_reloc_type (type
);
1081 rtype
= elf_cris_reloc_type (type
);
1085 rtype
= elf_i860_reloc_type (type
);
1089 rtype
= elf_x86_64_reloc_type (type
);
1093 rtype
= i370_reloc_type (type
);
1098 rtype
= elf_s390_reloc_type (type
);
1102 rtype
= elf_xstormy16_reloc_type (type
);
1106 rtype
= elf_crx_reloc_type (type
);
1110 rtype
= elf_vax_reloc_type (type
);
1115 rtype
= elf_ip2k_reloc_type (type
);
1119 rtype
= elf_iq2000_reloc_type (type
);
1124 rtype
= elf_xtensa_reloc_type (type
);
1128 rtype
= elf_m32c_reloc_type (type
);
1132 rtype
= elf_mt_reloc_type (type
);
1136 rtype
= elf_bfin_reloc_type (type
);
1142 #ifdef _bfd_int64_low
1143 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type
));
1145 printf (_("unrecognized: %-7lx"), type
);
1148 printf (do_wide
? "%-22.22s" : "%-17.17s", rtype
);
1150 if (elf_header
.e_machine
== EM_ALPHA
1152 && streq (rtype
, "R_ALPHA_LITUSE")
1155 switch (rels
[i
].r_addend
)
1157 case LITUSE_ALPHA_ADDR
: rtype
= "ADDR"; break;
1158 case LITUSE_ALPHA_BASE
: rtype
= "BASE"; break;
1159 case LITUSE_ALPHA_BYTOFF
: rtype
= "BYTOFF"; break;
1160 case LITUSE_ALPHA_JSR
: rtype
= "JSR"; break;
1161 case LITUSE_ALPHA_TLSGD
: rtype
= "TLSGD"; break;
1162 case LITUSE_ALPHA_TLSLDM
: rtype
= "TLSLDM"; break;
1163 case LITUSE_ALPHA_JSRDIRECT
: rtype
= "JSRDIRECT"; break;
1164 default: rtype
= NULL
;
1167 printf (" (%s)", rtype
);
1171 printf (_("<unknown addend: %lx>"),
1172 (unsigned long) rels
[i
].r_addend
);
1175 else if (symtab_index
)
1177 if (symtab
== NULL
|| symtab_index
>= nsyms
)
1178 printf (" bad symbol index: %08lx", (unsigned long) symtab_index
);
1181 Elf_Internal_Sym
*psym
;
1183 psym
= symtab
+ symtab_index
;
1186 print_vma (psym
->st_value
, LONG_HEX
);
1187 printf (is_32bit_elf
? " " : " ");
1189 if (psym
->st_name
== 0)
1191 const char *sec_name
= "<null>";
1194 if (ELF_ST_TYPE (psym
->st_info
) == STT_SECTION
)
1196 bfd_vma sec_index
= (bfd_vma
) -1;
1198 if (psym
->st_shndx
< SHN_LORESERVE
)
1199 sec_index
= psym
->st_shndx
;
1200 else if (psym
->st_shndx
> SHN_HIRESERVE
)
1201 sec_index
= psym
->st_shndx
- (SHN_HIRESERVE
+ 1
1204 if (sec_index
!= (bfd_vma
) -1)
1205 sec_name
= SECTION_NAME (section_headers
+ sec_index
);
1206 else if (psym
->st_shndx
== SHN_ABS
)
1208 else if (psym
->st_shndx
== SHN_COMMON
)
1209 sec_name
= "COMMON";
1210 else if (elf_header
.e_machine
== EM_MIPS
1211 && psym
->st_shndx
== SHN_MIPS_SCOMMON
)
1212 sec_name
= "SCOMMON";
1213 else if (elf_header
.e_machine
== EM_MIPS
1214 && psym
->st_shndx
== SHN_MIPS_SUNDEFINED
)
1215 sec_name
= "SUNDEF";
1216 else if (elf_header
.e_machine
== EM_X86_64
1217 && psym
->st_shndx
== SHN_X86_64_LCOMMON
)
1218 sec_name
= "LARGE_COMMON";
1219 else if (elf_header
.e_machine
== EM_IA_64
1220 && elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
1221 && psym
->st_shndx
== SHN_IA_64_ANSI_COMMON
)
1222 sec_name
= "ANSI_COM";
1225 sprintf (name_buf
, "<section 0x%x>",
1226 (unsigned int) psym
->st_shndx
);
1227 sec_name
= name_buf
;
1230 print_symbol (22, sec_name
);
1232 else if (strtab
== NULL
)
1233 printf (_("<string table index: %3ld>"), psym
->st_name
);
1234 else if (psym
->st_name
>= strtablen
)
1235 printf (_("<corrupt string table index: %3ld>"), psym
->st_name
);
1237 print_symbol (22, strtab
+ psym
->st_name
);
1240 printf (" + %lx", (unsigned long) rels
[i
].r_addend
);
1245 printf ("%*c", is_32bit_elf
?
1246 (do_wide
? 34 : 28) : (do_wide
? 26 : 20), ' ');
1247 print_vma (rels
[i
].r_addend
, LONG_HEX
);
1250 if (elf_header
.e_machine
== EM_SPARCV9
1252 && streq (rtype
, "R_SPARC_OLO10"))
1253 printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (info
));
1257 if (! is_32bit_elf
&& elf_header
.e_machine
== EM_MIPS
)
1259 printf (" Type2: ");
1262 #ifdef _bfd_int64_low
1263 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type2
));
1265 printf (_("unrecognized: %-7lx"), type2
);
1268 printf ("%-17.17s", rtype2
);
1270 printf ("\n Type3: ");
1273 #ifdef _bfd_int64_low
1274 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type3
));
1276 printf (_("unrecognized: %-7lx"), type3
);
1279 printf ("%-17.17s", rtype3
);
1291 get_mips_dynamic_type (unsigned long type
)
1295 case DT_MIPS_RLD_VERSION
: return "MIPS_RLD_VERSION";
1296 case DT_MIPS_TIME_STAMP
: return "MIPS_TIME_STAMP";
1297 case DT_MIPS_ICHECKSUM
: return "MIPS_ICHECKSUM";
1298 case DT_MIPS_IVERSION
: return "MIPS_IVERSION";
1299 case DT_MIPS_FLAGS
: return "MIPS_FLAGS";
1300 case DT_MIPS_BASE_ADDRESS
: return "MIPS_BASE_ADDRESS";
1301 case DT_MIPS_MSYM
: return "MIPS_MSYM";
1302 case DT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
1303 case DT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
1304 case DT_MIPS_LOCAL_GOTNO
: return "MIPS_LOCAL_GOTNO";
1305 case DT_MIPS_CONFLICTNO
: return "MIPS_CONFLICTNO";
1306 case DT_MIPS_LIBLISTNO
: return "MIPS_LIBLISTNO";
1307 case DT_MIPS_SYMTABNO
: return "MIPS_SYMTABNO";
1308 case DT_MIPS_UNREFEXTNO
: return "MIPS_UNREFEXTNO";
1309 case DT_MIPS_GOTSYM
: return "MIPS_GOTSYM";
1310 case DT_MIPS_HIPAGENO
: return "MIPS_HIPAGENO";
1311 case DT_MIPS_RLD_MAP
: return "MIPS_RLD_MAP";
1312 case DT_MIPS_DELTA_CLASS
: return "MIPS_DELTA_CLASS";
1313 case DT_MIPS_DELTA_CLASS_NO
: return "MIPS_DELTA_CLASS_NO";
1314 case DT_MIPS_DELTA_INSTANCE
: return "MIPS_DELTA_INSTANCE";
1315 case DT_MIPS_DELTA_INSTANCE_NO
: return "MIPS_DELTA_INSTANCE_NO";
1316 case DT_MIPS_DELTA_RELOC
: return "MIPS_DELTA_RELOC";
1317 case DT_MIPS_DELTA_RELOC_NO
: return "MIPS_DELTA_RELOC_NO";
1318 case DT_MIPS_DELTA_SYM
: return "MIPS_DELTA_SYM";
1319 case DT_MIPS_DELTA_SYM_NO
: return "MIPS_DELTA_SYM_NO";
1320 case DT_MIPS_DELTA_CLASSSYM
: return "MIPS_DELTA_CLASSSYM";
1321 case DT_MIPS_DELTA_CLASSSYM_NO
: return "MIPS_DELTA_CLASSSYM_NO";
1322 case DT_MIPS_CXX_FLAGS
: return "MIPS_CXX_FLAGS";
1323 case DT_MIPS_PIXIE_INIT
: return "MIPS_PIXIE_INIT";
1324 case DT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
1325 case DT_MIPS_LOCALPAGE_GOTIDX
: return "MIPS_LOCALPAGE_GOTIDX";
1326 case DT_MIPS_LOCAL_GOTIDX
: return "MIPS_LOCAL_GOTIDX";
1327 case DT_MIPS_HIDDEN_GOTIDX
: return "MIPS_HIDDEN_GOTIDX";
1328 case DT_MIPS_PROTECTED_GOTIDX
: return "MIPS_PROTECTED_GOTIDX";
1329 case DT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
1330 case DT_MIPS_INTERFACE
: return "MIPS_INTERFACE";
1331 case DT_MIPS_DYNSTR_ALIGN
: return "MIPS_DYNSTR_ALIGN";
1332 case DT_MIPS_INTERFACE_SIZE
: return "MIPS_INTERFACE_SIZE";
1333 case DT_MIPS_RLD_TEXT_RESOLVE_ADDR
: return "MIPS_RLD_TEXT_RESOLVE_ADDR";
1334 case DT_MIPS_PERF_SUFFIX
: return "MIPS_PERF_SUFFIX";
1335 case DT_MIPS_COMPACT_SIZE
: return "MIPS_COMPACT_SIZE";
1336 case DT_MIPS_GP_VALUE
: return "MIPS_GP_VALUE";
1337 case DT_MIPS_AUX_DYNAMIC
: return "MIPS_AUX_DYNAMIC";
1344 get_sparc64_dynamic_type (unsigned long type
)
1348 case DT_SPARC_REGISTER
: return "SPARC_REGISTER";
1355 get_ppc_dynamic_type (unsigned long type
)
1359 case DT_PPC_GOT
: return "PPC_GOT";
1366 get_ppc64_dynamic_type (unsigned long type
)
1370 case DT_PPC64_GLINK
: return "PPC64_GLINK";
1371 case DT_PPC64_OPD
: return "PPC64_OPD";
1372 case DT_PPC64_OPDSZ
: return "PPC64_OPDSZ";
1379 get_parisc_dynamic_type (unsigned long type
)
1383 case DT_HP_LOAD_MAP
: return "HP_LOAD_MAP";
1384 case DT_HP_DLD_FLAGS
: return "HP_DLD_FLAGS";
1385 case DT_HP_DLD_HOOK
: return "HP_DLD_HOOK";
1386 case DT_HP_UX10_INIT
: return "HP_UX10_INIT";
1387 case DT_HP_UX10_INITSZ
: return "HP_UX10_INITSZ";
1388 case DT_HP_PREINIT
: return "HP_PREINIT";
1389 case DT_HP_PREINITSZ
: return "HP_PREINITSZ";
1390 case DT_HP_NEEDED
: return "HP_NEEDED";
1391 case DT_HP_TIME_STAMP
: return "HP_TIME_STAMP";
1392 case DT_HP_CHECKSUM
: return "HP_CHECKSUM";
1393 case DT_HP_GST_SIZE
: return "HP_GST_SIZE";
1394 case DT_HP_GST_VERSION
: return "HP_GST_VERSION";
1395 case DT_HP_GST_HASHVAL
: return "HP_GST_HASHVAL";
1396 case DT_HP_EPLTREL
: return "HP_GST_EPLTREL";
1397 case DT_HP_EPLTRELSZ
: return "HP_GST_EPLTRELSZ";
1398 case DT_HP_FILTERED
: return "HP_FILTERED";
1399 case DT_HP_FILTER_TLS
: return "HP_FILTER_TLS";
1400 case DT_HP_COMPAT_FILTERED
: return "HP_COMPAT_FILTERED";
1401 case DT_HP_LAZYLOAD
: return "HP_LAZYLOAD";
1402 case DT_HP_BIND_NOW_COUNT
: return "HP_BIND_NOW_COUNT";
1403 case DT_PLT
: return "PLT";
1404 case DT_PLT_SIZE
: return "PLT_SIZE";
1405 case DT_DLT
: return "DLT";
1406 case DT_DLT_SIZE
: return "DLT_SIZE";
1413 get_ia64_dynamic_type (unsigned long type
)
1417 case DT_IA_64_PLT_RESERVE
: return "IA_64_PLT_RESERVE";
1424 get_alpha_dynamic_type (unsigned long type
)
1428 case DT_ALPHA_PLTRO
: return "ALPHA_PLTRO";
1435 get_dynamic_type (unsigned long type
)
1437 static char buff
[64];
1441 case DT_NULL
: return "NULL";
1442 case DT_NEEDED
: return "NEEDED";
1443 case DT_PLTRELSZ
: return "PLTRELSZ";
1444 case DT_PLTGOT
: return "PLTGOT";
1445 case DT_HASH
: return "HASH";
1446 case DT_STRTAB
: return "STRTAB";
1447 case DT_SYMTAB
: return "SYMTAB";
1448 case DT_RELA
: return "RELA";
1449 case DT_RELASZ
: return "RELASZ";
1450 case DT_RELAENT
: return "RELAENT";
1451 case DT_STRSZ
: return "STRSZ";
1452 case DT_SYMENT
: return "SYMENT";
1453 case DT_INIT
: return "INIT";
1454 case DT_FINI
: return "FINI";
1455 case DT_SONAME
: return "SONAME";
1456 case DT_RPATH
: return "RPATH";
1457 case DT_SYMBOLIC
: return "SYMBOLIC";
1458 case DT_REL
: return "REL";
1459 case DT_RELSZ
: return "RELSZ";
1460 case DT_RELENT
: return "RELENT";
1461 case DT_PLTREL
: return "PLTREL";
1462 case DT_DEBUG
: return "DEBUG";
1463 case DT_TEXTREL
: return "TEXTREL";
1464 case DT_JMPREL
: return "JMPREL";
1465 case DT_BIND_NOW
: return "BIND_NOW";
1466 case DT_INIT_ARRAY
: return "INIT_ARRAY";
1467 case DT_FINI_ARRAY
: return "FINI_ARRAY";
1468 case DT_INIT_ARRAYSZ
: return "INIT_ARRAYSZ";
1469 case DT_FINI_ARRAYSZ
: return "FINI_ARRAYSZ";
1470 case DT_RUNPATH
: return "RUNPATH";
1471 case DT_FLAGS
: return "FLAGS";
1473 case DT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
1474 case DT_PREINIT_ARRAYSZ
: return "PREINIT_ARRAYSZ";
1476 case DT_CHECKSUM
: return "CHECKSUM";
1477 case DT_PLTPADSZ
: return "PLTPADSZ";
1478 case DT_MOVEENT
: return "MOVEENT";
1479 case DT_MOVESZ
: return "MOVESZ";
1480 case DT_FEATURE
: return "FEATURE";
1481 case DT_POSFLAG_1
: return "POSFLAG_1";
1482 case DT_SYMINSZ
: return "SYMINSZ";
1483 case DT_SYMINENT
: return "SYMINENT"; /* aka VALRNGHI */
1485 case DT_ADDRRNGLO
: return "ADDRRNGLO";
1486 case DT_CONFIG
: return "CONFIG";
1487 case DT_DEPAUDIT
: return "DEPAUDIT";
1488 case DT_AUDIT
: return "AUDIT";
1489 case DT_PLTPAD
: return "PLTPAD";
1490 case DT_MOVETAB
: return "MOVETAB";
1491 case DT_SYMINFO
: return "SYMINFO"; /* aka ADDRRNGHI */
1493 case DT_VERSYM
: return "VERSYM";
1495 case DT_TLSDESC_GOT
: return "TLSDESC_GOT";
1496 case DT_TLSDESC_PLT
: return "TLSDESC_PLT";
1497 case DT_RELACOUNT
: return "RELACOUNT";
1498 case DT_RELCOUNT
: return "RELCOUNT";
1499 case DT_FLAGS_1
: return "FLAGS_1";
1500 case DT_VERDEF
: return "VERDEF";
1501 case DT_VERDEFNUM
: return "VERDEFNUM";
1502 case DT_VERNEED
: return "VERNEED";
1503 case DT_VERNEEDNUM
: return "VERNEEDNUM";
1505 case DT_AUXILIARY
: return "AUXILIARY";
1506 case DT_USED
: return "USED";
1507 case DT_FILTER
: return "FILTER";
1509 case DT_GNU_PRELINKED
: return "GNU_PRELINKED";
1510 case DT_GNU_CONFLICT
: return "GNU_CONFLICT";
1511 case DT_GNU_CONFLICTSZ
: return "GNU_CONFLICTSZ";
1512 case DT_GNU_LIBLIST
: return "GNU_LIBLIST";
1513 case DT_GNU_LIBLISTSZ
: return "GNU_LIBLISTSZ";
1514 case DT_GNU_HASH
: return "GNU_HASH";
1517 if ((type
>= DT_LOPROC
) && (type
<= DT_HIPROC
))
1521 switch (elf_header
.e_machine
)
1524 case EM_MIPS_RS3_LE
:
1525 result
= get_mips_dynamic_type (type
);
1528 result
= get_sparc64_dynamic_type (type
);
1531 result
= get_ppc_dynamic_type (type
);
1534 result
= get_ppc64_dynamic_type (type
);
1537 result
= get_ia64_dynamic_type (type
);
1540 result
= get_alpha_dynamic_type (type
);
1550 snprintf (buff
, sizeof (buff
), _("Processor Specific: %lx"), type
);
1552 else if (((type
>= DT_LOOS
) && (type
<= DT_HIOS
))
1553 || (elf_header
.e_machine
== EM_PARISC
1554 && (type
>= OLD_DT_LOOS
) && (type
<= OLD_DT_HIOS
)))
1558 switch (elf_header
.e_machine
)
1561 result
= get_parisc_dynamic_type (type
);
1571 snprintf (buff
, sizeof (buff
), _("Operating System specific: %lx"),
1575 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), type
);
1582 get_file_type (unsigned e_type
)
1584 static char buff
[32];
1588 case ET_NONE
: return _("NONE (None)");
1589 case ET_REL
: return _("REL (Relocatable file)");
1590 case ET_EXEC
: return _("EXEC (Executable file)");
1591 case ET_DYN
: return _("DYN (Shared object file)");
1592 case ET_CORE
: return _("CORE (Core file)");
1595 if ((e_type
>= ET_LOPROC
) && (e_type
<= ET_HIPROC
))
1596 snprintf (buff
, sizeof (buff
), _("Processor Specific: (%x)"), e_type
);
1597 else if ((e_type
>= ET_LOOS
) && (e_type
<= ET_HIOS
))
1598 snprintf (buff
, sizeof (buff
), _("OS Specific: (%x)"), e_type
);
1600 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), e_type
);
1606 get_machine_name (unsigned e_machine
)
1608 static char buff
[64]; /* XXX */
1612 case EM_NONE
: return _("None");
1613 case EM_M32
: return "WE32100";
1614 case EM_SPARC
: return "Sparc";
1615 case EM_386
: return "Intel 80386";
1616 case EM_68K
: return "MC68000";
1617 case EM_88K
: return "MC88000";
1618 case EM_486
: return "Intel 80486";
1619 case EM_860
: return "Intel 80860";
1620 case EM_MIPS
: return "MIPS R3000";
1621 case EM_S370
: return "IBM System/370";
1622 case EM_MIPS_RS3_LE
: return "MIPS R4000 big-endian";
1623 case EM_OLD_SPARCV9
: return "Sparc v9 (old)";
1624 case EM_PARISC
: return "HPPA";
1625 case EM_PPC_OLD
: return "Power PC (old)";
1626 case EM_SPARC32PLUS
: return "Sparc v8+" ;
1627 case EM_960
: return "Intel 90860";
1628 case EM_PPC
: return "PowerPC";
1629 case EM_PPC64
: return "PowerPC64";
1630 case EM_V800
: return "NEC V800";
1631 case EM_FR20
: return "Fujitsu FR20";
1632 case EM_RH32
: return "TRW RH32";
1633 case EM_MCORE
: return "MCORE";
1634 case EM_ARM
: return "ARM";
1635 case EM_OLD_ALPHA
: return "Digital Alpha (old)";
1636 case EM_SH
: return "Renesas / SuperH SH";
1637 case EM_SPARCV9
: return "Sparc v9";
1638 case EM_TRICORE
: return "Siemens Tricore";
1639 case EM_ARC
: return "ARC";
1640 case EM_H8_300
: return "Renesas H8/300";
1641 case EM_H8_300H
: return "Renesas H8/300H";
1642 case EM_H8S
: return "Renesas H8S";
1643 case EM_H8_500
: return "Renesas H8/500";
1644 case EM_IA_64
: return "Intel IA-64";
1645 case EM_MIPS_X
: return "Stanford MIPS-X";
1646 case EM_COLDFIRE
: return "Motorola Coldfire";
1647 case EM_68HC12
: return "Motorola M68HC12";
1648 case EM_ALPHA
: return "Alpha";
1649 case EM_CYGNUS_D10V
:
1650 case EM_D10V
: return "d10v";
1651 case EM_CYGNUS_D30V
:
1652 case EM_D30V
: return "d30v";
1653 case EM_CYGNUS_M32R
:
1654 case EM_M32R
: return "Renesas M32R (formerly Mitsubishi M32r)";
1655 case EM_CYGNUS_V850
:
1656 case EM_V850
: return "NEC v850";
1657 case EM_CYGNUS_MN10300
:
1658 case EM_MN10300
: return "mn10300";
1659 case EM_CYGNUS_MN10200
:
1660 case EM_MN10200
: return "mn10200";
1661 case EM_CYGNUS_FR30
:
1662 case EM_FR30
: return "Fujitsu FR30";
1663 case EM_CYGNUS_FRV
: return "Fujitsu FR-V";
1665 case EM_PJ
: return "picoJava";
1666 case EM_MMA
: return "Fujitsu Multimedia Accelerator";
1667 case EM_PCP
: return "Siemens PCP";
1668 case EM_NCPU
: return "Sony nCPU embedded RISC processor";
1669 case EM_NDR1
: return "Denso NDR1 microprocesspr";
1670 case EM_STARCORE
: return "Motorola Star*Core processor";
1671 case EM_ME16
: return "Toyota ME16 processor";
1672 case EM_ST100
: return "STMicroelectronics ST100 processor";
1673 case EM_TINYJ
: return "Advanced Logic Corp. TinyJ embedded processor";
1674 case EM_FX66
: return "Siemens FX66 microcontroller";
1675 case EM_ST9PLUS
: return "STMicroelectronics ST9+ 8/16 bit microcontroller";
1676 case EM_ST7
: return "STMicroelectronics ST7 8-bit microcontroller";
1677 case EM_68HC16
: return "Motorola MC68HC16 Microcontroller";
1678 case EM_68HC11
: return "Motorola MC68HC11 Microcontroller";
1679 case EM_68HC08
: return "Motorola MC68HC08 Microcontroller";
1680 case EM_68HC05
: return "Motorola MC68HC05 Microcontroller";
1681 case EM_SVX
: return "Silicon Graphics SVx";
1682 case EM_ST19
: return "STMicroelectronics ST19 8-bit microcontroller";
1683 case EM_VAX
: return "Digital VAX";
1685 case EM_AVR
: return "Atmel AVR 8-bit microcontroller";
1686 case EM_CRIS
: return "Axis Communications 32-bit embedded processor";
1687 case EM_JAVELIN
: return "Infineon Technologies 32-bit embedded cpu";
1688 case EM_FIREPATH
: return "Element 14 64-bit DSP processor";
1689 case EM_ZSP
: return "LSI Logic's 16-bit DSP processor";
1690 case EM_MMIX
: return "Donald Knuth's educational 64-bit processor";
1691 case EM_HUANY
: return "Harvard Universitys's machine-independent object format";
1692 case EM_PRISM
: return "Vitesse Prism";
1693 case EM_X86_64
: return "Advanced Micro Devices X86-64";
1695 case EM_S390
: return "IBM S/390";
1696 case EM_XSTORMY16
: return "Sanyo Xstormy16 CPU core";
1698 case EM_OR32
: return "OpenRISC";
1699 case EM_CRX
: return "National Semiconductor CRX microprocessor";
1700 case EM_DLX
: return "OpenDLX";
1702 case EM_IP2K
: return "Ubicom IP2xxx 8-bit microcontrollers";
1703 case EM_IQ2000
: return "Vitesse IQ2000";
1705 case EM_XTENSA
: return "Tensilica Xtensa Processor";
1706 case EM_M32C
: return "Renesas M32c";
1707 case EM_MT
: return "Morpho Techologies MT processor";
1708 case EM_BLACKFIN
: return "Analog Devices Blackfin";
1709 case EM_NIOS32
: return "Altera Nios";
1710 case EM_ALTERA_NIOS2
: return "Altera Nios II";
1711 case EM_XC16X
: return "Infineon Technologies xc16x";
1713 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), e_machine
);
1719 decode_ARM_machine_flags (unsigned e_flags
, char buf
[])
1724 eabi
= EF_ARM_EABI_VERSION (e_flags
);
1725 e_flags
&= ~ EF_ARM_EABIMASK
;
1727 /* Handle "generic" ARM flags. */
1728 if (e_flags
& EF_ARM_RELEXEC
)
1730 strcat (buf
, ", relocatable executable");
1731 e_flags
&= ~ EF_ARM_RELEXEC
;
1734 if (e_flags
& EF_ARM_HASENTRY
)
1736 strcat (buf
, ", has entry point");
1737 e_flags
&= ~ EF_ARM_HASENTRY
;
1740 /* Now handle EABI specific flags. */
1744 strcat (buf
, ", <unrecognized EABI>");
1749 case EF_ARM_EABI_VER1
:
1750 strcat (buf
, ", Version1 EABI");
1755 /* Process flags one bit at a time. */
1756 flag
= e_flags
& - e_flags
;
1761 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1762 strcat (buf
, ", sorted symbol tables");
1772 case EF_ARM_EABI_VER2
:
1773 strcat (buf
, ", Version2 EABI");
1778 /* Process flags one bit at a time. */
1779 flag
= e_flags
& - e_flags
;
1784 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1785 strcat (buf
, ", sorted symbol tables");
1788 case EF_ARM_DYNSYMSUSESEGIDX
:
1789 strcat (buf
, ", dynamic symbols use segment index");
1792 case EF_ARM_MAPSYMSFIRST
:
1793 strcat (buf
, ", mapping symbols precede others");
1803 case EF_ARM_EABI_VER3
:
1804 strcat (buf
, ", Version3 EABI");
1807 case EF_ARM_EABI_VER4
:
1808 strcat (buf
, ", Version4 EABI");
1811 case EF_ARM_EABI_VER5
:
1812 strcat (buf
, ", Version5 EABI");
1818 /* Process flags one bit at a time. */
1819 flag
= e_flags
& - e_flags
;
1825 strcat (buf
, ", BE8");
1829 strcat (buf
, ", LE8");
1839 case EF_ARM_EABI_UNKNOWN
:
1840 strcat (buf
, ", GNU EABI");
1845 /* Process flags one bit at a time. */
1846 flag
= e_flags
& - e_flags
;
1851 case EF_ARM_INTERWORK
:
1852 strcat (buf
, ", interworking enabled");
1855 case EF_ARM_APCS_26
:
1856 strcat (buf
, ", uses APCS/26");
1859 case EF_ARM_APCS_FLOAT
:
1860 strcat (buf
, ", uses APCS/float");
1864 strcat (buf
, ", position independent");
1868 strcat (buf
, ", 8 bit structure alignment");
1871 case EF_ARM_NEW_ABI
:
1872 strcat (buf
, ", uses new ABI");
1875 case EF_ARM_OLD_ABI
:
1876 strcat (buf
, ", uses old ABI");
1879 case EF_ARM_SOFT_FLOAT
:
1880 strcat (buf
, ", software FP");
1883 case EF_ARM_VFP_FLOAT
:
1884 strcat (buf
, ", VFP");
1887 case EF_ARM_MAVERICK_FLOAT
:
1888 strcat (buf
, ", Maverick FP");
1899 strcat (buf
,", <unknown>");
1903 get_machine_flags (unsigned e_flags
, unsigned e_machine
)
1905 static char buf
[1024];
1917 decode_ARM_machine_flags (e_flags
, buf
);
1921 switch (e_flags
& EF_FRV_CPU_MASK
)
1923 case EF_FRV_CPU_GENERIC
:
1927 strcat (buf
, ", fr???");
1930 case EF_FRV_CPU_FR300
:
1931 strcat (buf
, ", fr300");
1934 case EF_FRV_CPU_FR400
:
1935 strcat (buf
, ", fr400");
1937 case EF_FRV_CPU_FR405
:
1938 strcat (buf
, ", fr405");
1941 case EF_FRV_CPU_FR450
:
1942 strcat (buf
, ", fr450");
1945 case EF_FRV_CPU_FR500
:
1946 strcat (buf
, ", fr500");
1948 case EF_FRV_CPU_FR550
:
1949 strcat (buf
, ", fr550");
1952 case EF_FRV_CPU_SIMPLE
:
1953 strcat (buf
, ", simple");
1955 case EF_FRV_CPU_TOMCAT
:
1956 strcat (buf
, ", tomcat");
1962 if (e_flags
& EF_M68K_CPU32
)
1963 strcat (buf
, ", cpu32");
1964 if (e_flags
& EF_M68K_M68000
)
1965 strcat (buf
, ", m68000");
1966 if (e_flags
& EF_M68K_ISA_MASK
)
1968 char const *isa
= _("unknown");
1969 char const *mac
= _("unknown mac");
1970 char const *additional
= NULL
;
1972 switch (e_flags
& EF_M68K_ISA_MASK
)
1974 case EF_M68K_ISA_A_NODIV
:
1976 additional
= ", nodiv";
1981 case EF_M68K_ISA_A_PLUS
:
1984 case EF_M68K_ISA_B_NOUSP
:
1986 additional
= ", nousp";
1992 strcat (buf
, ", cf, isa ");
1995 strcat (buf
, additional
);
1996 if (e_flags
& EF_M68K_FLOAT
)
1997 strcat (buf
, ", float");
1998 switch (e_flags
& EF_M68K_MAC_MASK
)
2019 if (e_flags
& EF_PPC_EMB
)
2020 strcat (buf
, ", emb");
2022 if (e_flags
& EF_PPC_RELOCATABLE
)
2023 strcat (buf
, ", relocatable");
2025 if (e_flags
& EF_PPC_RELOCATABLE_LIB
)
2026 strcat (buf
, ", relocatable-lib");
2030 case EM_CYGNUS_V850
:
2031 switch (e_flags
& EF_V850_ARCH
)
2034 strcat (buf
, ", v850e1");
2037 strcat (buf
, ", v850e");
2040 strcat (buf
, ", v850");
2043 strcat (buf
, ", unknown v850 architecture variant");
2049 case EM_CYGNUS_M32R
:
2050 if ((e_flags
& EF_M32R_ARCH
) == E_M32R_ARCH
)
2051 strcat (buf
, ", m32r");
2056 case EM_MIPS_RS3_LE
:
2057 if (e_flags
& EF_MIPS_NOREORDER
)
2058 strcat (buf
, ", noreorder");
2060 if (e_flags
& EF_MIPS_PIC
)
2061 strcat (buf
, ", pic");
2063 if (e_flags
& EF_MIPS_CPIC
)
2064 strcat (buf
, ", cpic");
2066 if (e_flags
& EF_MIPS_UCODE
)
2067 strcat (buf
, ", ugen_reserved");
2069 if (e_flags
& EF_MIPS_ABI2
)
2070 strcat (buf
, ", abi2");
2072 if (e_flags
& EF_MIPS_OPTIONS_FIRST
)
2073 strcat (buf
, ", odk first");
2075 if (e_flags
& EF_MIPS_32BITMODE
)
2076 strcat (buf
, ", 32bitmode");
2078 switch ((e_flags
& EF_MIPS_MACH
))
2080 case E_MIPS_MACH_3900
: strcat (buf
, ", 3900"); break;
2081 case E_MIPS_MACH_4010
: strcat (buf
, ", 4010"); break;
2082 case E_MIPS_MACH_4100
: strcat (buf
, ", 4100"); break;
2083 case E_MIPS_MACH_4111
: strcat (buf
, ", 4111"); break;
2084 case E_MIPS_MACH_4120
: strcat (buf
, ", 4120"); break;
2085 case E_MIPS_MACH_4650
: strcat (buf
, ", 4650"); break;
2086 case E_MIPS_MACH_5400
: strcat (buf
, ", 5400"); break;
2087 case E_MIPS_MACH_5500
: strcat (buf
, ", 5500"); break;
2088 case E_MIPS_MACH_SB1
: strcat (buf
, ", sb1"); break;
2089 case E_MIPS_MACH_9000
: strcat (buf
, ", 9000"); break;
2091 /* We simply ignore the field in this case to avoid confusion:
2092 MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
2095 default: strcat (buf
, ", unknown CPU"); break;
2098 switch ((e_flags
& EF_MIPS_ABI
))
2100 case E_MIPS_ABI_O32
: strcat (buf
, ", o32"); break;
2101 case E_MIPS_ABI_O64
: strcat (buf
, ", o64"); break;
2102 case E_MIPS_ABI_EABI32
: strcat (buf
, ", eabi32"); break;
2103 case E_MIPS_ABI_EABI64
: strcat (buf
, ", eabi64"); break;
2105 /* We simply ignore the field in this case to avoid confusion:
2106 MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension.
2107 This means it is likely to be an o32 file, but not for
2110 default: strcat (buf
, ", unknown ABI"); break;
2113 if (e_flags
& EF_MIPS_ARCH_ASE_MDMX
)
2114 strcat (buf
, ", mdmx");
2116 if (e_flags
& EF_MIPS_ARCH_ASE_M16
)
2117 strcat (buf
, ", mips16");
2119 switch ((e_flags
& EF_MIPS_ARCH
))
2121 case E_MIPS_ARCH_1
: strcat (buf
, ", mips1"); break;
2122 case E_MIPS_ARCH_2
: strcat (buf
, ", mips2"); break;
2123 case E_MIPS_ARCH_3
: strcat (buf
, ", mips3"); break;
2124 case E_MIPS_ARCH_4
: strcat (buf
, ", mips4"); break;
2125 case E_MIPS_ARCH_5
: strcat (buf
, ", mips5"); break;
2126 case E_MIPS_ARCH_32
: strcat (buf
, ", mips32"); break;
2127 case E_MIPS_ARCH_32R2
: strcat (buf
, ", mips32r2"); break;
2128 case E_MIPS_ARCH_64
: strcat (buf
, ", mips64"); break;
2129 case E_MIPS_ARCH_64R2
: strcat (buf
, ", mips64r2"); break;
2130 default: strcat (buf
, ", unknown ISA"); break;
2136 switch ((e_flags
& EF_SH_MACH_MASK
))
2138 case EF_SH1
: strcat (buf
, ", sh1"); break;
2139 case EF_SH2
: strcat (buf
, ", sh2"); break;
2140 case EF_SH3
: strcat (buf
, ", sh3"); break;
2141 case EF_SH_DSP
: strcat (buf
, ", sh-dsp"); break;
2142 case EF_SH3_DSP
: strcat (buf
, ", sh3-dsp"); break;
2143 case EF_SH4AL_DSP
: strcat (buf
, ", sh4al-dsp"); break;
2144 case EF_SH3E
: strcat (buf
, ", sh3e"); break;
2145 case EF_SH4
: strcat (buf
, ", sh4"); break;
2146 case EF_SH5
: strcat (buf
, ", sh5"); break;
2147 case EF_SH2E
: strcat (buf
, ", sh2e"); break;
2148 case EF_SH4A
: strcat (buf
, ", sh4a"); break;
2149 case EF_SH2A
: strcat (buf
, ", sh2a"); break;
2150 case EF_SH4_NOFPU
: strcat (buf
, ", sh4-nofpu"); break;
2151 case EF_SH4A_NOFPU
: strcat (buf
, ", sh4a-nofpu"); break;
2152 case EF_SH2A_NOFPU
: strcat (buf
, ", sh2a-nofpu"); break;
2153 case EF_SH3_NOMMU
: strcat (buf
, ", sh3-nommu"); break;
2154 case EF_SH4_NOMMU_NOFPU
: strcat (buf
, ", sh4-nommu-nofpu"); break;
2155 case EF_SH2A_SH4_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh4-nommu-nofpu"); break;
2156 case EF_SH2A_SH3_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh3-nommu"); break;
2157 case EF_SH2A_SH4
: strcat (buf
, ", sh2a-or-sh4"); break;
2158 case EF_SH2A_SH3E
: strcat (buf
, ", sh2a-or-sh3e"); break;
2159 default: strcat (buf
, ", unknown ISA"); break;
2165 if (e_flags
& EF_SPARC_32PLUS
)
2166 strcat (buf
, ", v8+");
2168 if (e_flags
& EF_SPARC_SUN_US1
)
2169 strcat (buf
, ", ultrasparcI");
2171 if (e_flags
& EF_SPARC_SUN_US3
)
2172 strcat (buf
, ", ultrasparcIII");
2174 if (e_flags
& EF_SPARC_HAL_R1
)
2175 strcat (buf
, ", halr1");
2177 if (e_flags
& EF_SPARC_LEDATA
)
2178 strcat (buf
, ", ledata");
2180 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_TSO
)
2181 strcat (buf
, ", tso");
2183 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_PSO
)
2184 strcat (buf
, ", pso");
2186 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_RMO
)
2187 strcat (buf
, ", rmo");
2191 switch (e_flags
& EF_PARISC_ARCH
)
2193 case EFA_PARISC_1_0
:
2194 strcpy (buf
, ", PA-RISC 1.0");
2196 case EFA_PARISC_1_1
:
2197 strcpy (buf
, ", PA-RISC 1.1");
2199 case EFA_PARISC_2_0
:
2200 strcpy (buf
, ", PA-RISC 2.0");
2205 if (e_flags
& EF_PARISC_TRAPNIL
)
2206 strcat (buf
, ", trapnil");
2207 if (e_flags
& EF_PARISC_EXT
)
2208 strcat (buf
, ", ext");
2209 if (e_flags
& EF_PARISC_LSB
)
2210 strcat (buf
, ", lsb");
2211 if (e_flags
& EF_PARISC_WIDE
)
2212 strcat (buf
, ", wide");
2213 if (e_flags
& EF_PARISC_NO_KABP
)
2214 strcat (buf
, ", no kabp");
2215 if (e_flags
& EF_PARISC_LAZYSWAP
)
2216 strcat (buf
, ", lazyswap");
2221 if ((e_flags
& EF_PICOJAVA_NEWCALLS
) == EF_PICOJAVA_NEWCALLS
)
2222 strcat (buf
, ", new calling convention");
2224 if ((e_flags
& EF_PICOJAVA_GNUCALLS
) == EF_PICOJAVA_GNUCALLS
)
2225 strcat (buf
, ", gnu calling convention");
2229 if ((e_flags
& EF_IA_64_ABI64
))
2230 strcat (buf
, ", 64-bit");
2232 strcat (buf
, ", 32-bit");
2233 if ((e_flags
& EF_IA_64_REDUCEDFP
))
2234 strcat (buf
, ", reduced fp model");
2235 if ((e_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
))
2236 strcat (buf
, ", no function descriptors, constant gp");
2237 else if ((e_flags
& EF_IA_64_CONS_GP
))
2238 strcat (buf
, ", constant gp");
2239 if ((e_flags
& EF_IA_64_ABSOLUTE
))
2240 strcat (buf
, ", absolute");
2244 if ((e_flags
& EF_VAX_NONPIC
))
2245 strcat (buf
, ", non-PIC");
2246 if ((e_flags
& EF_VAX_DFLOAT
))
2247 strcat (buf
, ", D-Float");
2248 if ((e_flags
& EF_VAX_GFLOAT
))
2249 strcat (buf
, ", G-Float");
2258 get_osabi_name (unsigned int osabi
)
2260 static char buff
[32];
2264 case ELFOSABI_NONE
: return "UNIX - System V";
2265 case ELFOSABI_HPUX
: return "UNIX - HP-UX";
2266 case ELFOSABI_NETBSD
: return "UNIX - NetBSD";
2267 case ELFOSABI_LINUX
: return "UNIX - Linux";
2268 case ELFOSABI_HURD
: return "GNU/Hurd";
2269 case ELFOSABI_SOLARIS
: return "UNIX - Solaris";
2270 case ELFOSABI_AIX
: return "UNIX - AIX";
2271 case ELFOSABI_IRIX
: return "UNIX - IRIX";
2272 case ELFOSABI_FREEBSD
: return "UNIX - FreeBSD";
2273 case ELFOSABI_TRU64
: return "UNIX - TRU64";
2274 case ELFOSABI_MODESTO
: return "Novell - Modesto";
2275 case ELFOSABI_OPENBSD
: return "UNIX - OpenBSD";
2276 case ELFOSABI_OPENVMS
: return "VMS - OpenVMS";
2277 case ELFOSABI_NSK
: return "HP - Non-Stop Kernel";
2278 case ELFOSABI_AROS
: return "Amiga Research OS";
2279 case ELFOSABI_STANDALONE
: return _("Standalone App");
2280 case ELFOSABI_ARM
: return "ARM";
2282 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), osabi
);
2288 get_arm_segment_type (unsigned long type
)
2302 get_mips_segment_type (unsigned long type
)
2306 case PT_MIPS_REGINFO
:
2308 case PT_MIPS_RTPROC
:
2310 case PT_MIPS_OPTIONS
:
2320 get_parisc_segment_type (unsigned long type
)
2324 case PT_HP_TLS
: return "HP_TLS";
2325 case PT_HP_CORE_NONE
: return "HP_CORE_NONE";
2326 case PT_HP_CORE_VERSION
: return "HP_CORE_VERSION";
2327 case PT_HP_CORE_KERNEL
: return "HP_CORE_KERNEL";
2328 case PT_HP_CORE_COMM
: return "HP_CORE_COMM";
2329 case PT_HP_CORE_PROC
: return "HP_CORE_PROC";
2330 case PT_HP_CORE_LOADABLE
: return "HP_CORE_LOADABLE";
2331 case PT_HP_CORE_STACK
: return "HP_CORE_STACK";
2332 case PT_HP_CORE_SHM
: return "HP_CORE_SHM";
2333 case PT_HP_CORE_MMF
: return "HP_CORE_MMF";
2334 case PT_HP_PARALLEL
: return "HP_PARALLEL";
2335 case PT_HP_FASTBIND
: return "HP_FASTBIND";
2336 case PT_HP_OPT_ANNOT
: return "HP_OPT_ANNOT";
2337 case PT_HP_HSL_ANNOT
: return "HP_HSL_ANNOT";
2338 case PT_HP_STACK
: return "HP_STACK";
2339 case PT_HP_CORE_UTSNAME
: return "HP_CORE_UTSNAME";
2340 case PT_PARISC_ARCHEXT
: return "PARISC_ARCHEXT";
2341 case PT_PARISC_UNWIND
: return "PARISC_UNWIND";
2342 case PT_PARISC_WEAKORDER
: return "PARISC_WEAKORDER";
2351 get_ia64_segment_type (unsigned long type
)
2355 case PT_IA_64_ARCHEXT
: return "IA_64_ARCHEXT";
2356 case PT_IA_64_UNWIND
: return "IA_64_UNWIND";
2357 case PT_HP_TLS
: return "HP_TLS";
2358 case PT_IA_64_HP_OPT_ANOT
: return "HP_OPT_ANNOT";
2359 case PT_IA_64_HP_HSL_ANOT
: return "HP_HSL_ANNOT";
2360 case PT_IA_64_HP_STACK
: return "HP_STACK";
2369 get_segment_type (unsigned long p_type
)
2371 static char buff
[32];
2375 case PT_NULL
: return "NULL";
2376 case PT_LOAD
: return "LOAD";
2377 case PT_DYNAMIC
: return "DYNAMIC";
2378 case PT_INTERP
: return "INTERP";
2379 case PT_NOTE
: return "NOTE";
2380 case PT_SHLIB
: return "SHLIB";
2381 case PT_PHDR
: return "PHDR";
2382 case PT_TLS
: return "TLS";
2384 case PT_GNU_EH_FRAME
:
2385 return "GNU_EH_FRAME";
2386 case PT_GNU_STACK
: return "GNU_STACK";
2387 case PT_GNU_RELRO
: return "GNU_RELRO";
2390 if ((p_type
>= PT_LOPROC
) && (p_type
<= PT_HIPROC
))
2394 switch (elf_header
.e_machine
)
2397 result
= get_arm_segment_type (p_type
);
2400 case EM_MIPS_RS3_LE
:
2401 result
= get_mips_segment_type (p_type
);
2404 result
= get_parisc_segment_type (p_type
);
2407 result
= get_ia64_segment_type (p_type
);
2417 sprintf (buff
, "LOPROC+%lx", p_type
- PT_LOPROC
);
2419 else if ((p_type
>= PT_LOOS
) && (p_type
<= PT_HIOS
))
2423 switch (elf_header
.e_machine
)
2426 result
= get_parisc_segment_type (p_type
);
2429 result
= get_ia64_segment_type (p_type
);
2439 sprintf (buff
, "LOOS+%lx", p_type
- PT_LOOS
);
2442 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), p_type
);
2449 get_mips_section_type_name (unsigned int sh_type
)
2453 case SHT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
2454 case SHT_MIPS_MSYM
: return "MIPS_MSYM";
2455 case SHT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
2456 case SHT_MIPS_GPTAB
: return "MIPS_GPTAB";
2457 case SHT_MIPS_UCODE
: return "MIPS_UCODE";
2458 case SHT_MIPS_DEBUG
: return "MIPS_DEBUG";
2459 case SHT_MIPS_REGINFO
: return "MIPS_REGINFO";
2460 case SHT_MIPS_PACKAGE
: return "MIPS_PACKAGE";
2461 case SHT_MIPS_PACKSYM
: return "MIPS_PACKSYM";
2462 case SHT_MIPS_RELD
: return "MIPS_RELD";
2463 case SHT_MIPS_IFACE
: return "MIPS_IFACE";
2464 case SHT_MIPS_CONTENT
: return "MIPS_CONTENT";
2465 case SHT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
2466 case SHT_MIPS_SHDR
: return "MIPS_SHDR";
2467 case SHT_MIPS_FDESC
: return "MIPS_FDESC";
2468 case SHT_MIPS_EXTSYM
: return "MIPS_EXTSYM";
2469 case SHT_MIPS_DENSE
: return "MIPS_DENSE";
2470 case SHT_MIPS_PDESC
: return "MIPS_PDESC";
2471 case SHT_MIPS_LOCSYM
: return "MIPS_LOCSYM";
2472 case SHT_MIPS_AUXSYM
: return "MIPS_AUXSYM";
2473 case SHT_MIPS_OPTSYM
: return "MIPS_OPTSYM";
2474 case SHT_MIPS_LOCSTR
: return "MIPS_LOCSTR";
2475 case SHT_MIPS_LINE
: return "MIPS_LINE";
2476 case SHT_MIPS_RFDESC
: return "MIPS_RFDESC";
2477 case SHT_MIPS_DELTASYM
: return "MIPS_DELTASYM";
2478 case SHT_MIPS_DELTAINST
: return "MIPS_DELTAINST";
2479 case SHT_MIPS_DELTACLASS
: return "MIPS_DELTACLASS";
2480 case SHT_MIPS_DWARF
: return "MIPS_DWARF";
2481 case SHT_MIPS_DELTADECL
: return "MIPS_DELTADECL";
2482 case SHT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
2483 case SHT_MIPS_EVENTS
: return "MIPS_EVENTS";
2484 case SHT_MIPS_TRANSLATE
: return "MIPS_TRANSLATE";
2485 case SHT_MIPS_PIXIE
: return "MIPS_PIXIE";
2486 case SHT_MIPS_XLATE
: return "MIPS_XLATE";
2487 case SHT_MIPS_XLATE_DEBUG
: return "MIPS_XLATE_DEBUG";
2488 case SHT_MIPS_WHIRL
: return "MIPS_WHIRL";
2489 case SHT_MIPS_EH_REGION
: return "MIPS_EH_REGION";
2490 case SHT_MIPS_XLATE_OLD
: return "MIPS_XLATE_OLD";
2491 case SHT_MIPS_PDR_EXCEPTION
: return "MIPS_PDR_EXCEPTION";
2499 get_parisc_section_type_name (unsigned int sh_type
)
2503 case SHT_PARISC_EXT
: return "PARISC_EXT";
2504 case SHT_PARISC_UNWIND
: return "PARISC_UNWIND";
2505 case SHT_PARISC_DOC
: return "PARISC_DOC";
2506 case SHT_PARISC_ANNOT
: return "PARISC_ANNOT";
2507 case SHT_PARISC_SYMEXTN
: return "PARISC_SYMEXTN";
2508 case SHT_PARISC_STUBS
: return "PARISC_STUBS";
2509 case SHT_PARISC_DLKM
: return "PARISC_DLKM";
2517 get_ia64_section_type_name (unsigned int sh_type
)
2519 /* If the top 8 bits are 0x78 the next 8 are the os/abi ID. */
2520 if ((sh_type
& 0xFF000000) == SHT_IA_64_LOPSREG
)
2521 return get_osabi_name ((sh_type
& 0x00FF0000) >> 16);
2525 case SHT_IA_64_EXT
: return "IA_64_EXT";
2526 case SHT_IA_64_UNWIND
: return "IA_64_UNWIND";
2527 case SHT_IA_64_PRIORITY_INIT
: return "IA_64_PRIORITY_INIT";
2535 get_x86_64_section_type_name (unsigned int sh_type
)
2539 case SHT_X86_64_UNWIND
: return "X86_64_UNWIND";
2547 get_arm_section_type_name (unsigned int sh_type
)
2553 case SHT_ARM_PREEMPTMAP
:
2554 return "ARM_PREEMPTMAP";
2555 case SHT_ARM_ATTRIBUTES
:
2556 return "ARM_ATTRIBUTES";
2564 get_section_type_name (unsigned int sh_type
)
2566 static char buff
[32];
2570 case SHT_NULL
: return "NULL";
2571 case SHT_PROGBITS
: return "PROGBITS";
2572 case SHT_SYMTAB
: return "SYMTAB";
2573 case SHT_STRTAB
: return "STRTAB";
2574 case SHT_RELA
: return "RELA";
2575 case SHT_HASH
: return "HASH";
2576 case SHT_DYNAMIC
: return "DYNAMIC";
2577 case SHT_NOTE
: return "NOTE";
2578 case SHT_NOBITS
: return "NOBITS";
2579 case SHT_REL
: return "REL";
2580 case SHT_SHLIB
: return "SHLIB";
2581 case SHT_DYNSYM
: return "DYNSYM";
2582 case SHT_INIT_ARRAY
: return "INIT_ARRAY";
2583 case SHT_FINI_ARRAY
: return "FINI_ARRAY";
2584 case SHT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
2585 case SHT_GNU_HASH
: return "GNU_HASH";
2586 case SHT_GROUP
: return "GROUP";
2587 case SHT_SYMTAB_SHNDX
: return "SYMTAB SECTION INDICIES";
2588 case SHT_GNU_verdef
: return "VERDEF";
2589 case SHT_GNU_verneed
: return "VERNEED";
2590 case SHT_GNU_versym
: return "VERSYM";
2591 case 0x6ffffff0: return "VERSYM";
2592 case 0x6ffffffc: return "VERDEF";
2593 case 0x7ffffffd: return "AUXILIARY";
2594 case 0x7fffffff: return "FILTER";
2595 case SHT_GNU_LIBLIST
: return "GNU_LIBLIST";
2598 if ((sh_type
>= SHT_LOPROC
) && (sh_type
<= SHT_HIPROC
))
2602 switch (elf_header
.e_machine
)
2605 case EM_MIPS_RS3_LE
:
2606 result
= get_mips_section_type_name (sh_type
);
2609 result
= get_parisc_section_type_name (sh_type
);
2612 result
= get_ia64_section_type_name (sh_type
);
2615 result
= get_x86_64_section_type_name (sh_type
);
2618 result
= get_arm_section_type_name (sh_type
);
2628 sprintf (buff
, "LOPROC+%x", sh_type
- SHT_LOPROC
);
2630 else if ((sh_type
>= SHT_LOOS
) && (sh_type
<= SHT_HIOS
))
2631 sprintf (buff
, "LOOS+%x", sh_type
- SHT_LOOS
);
2632 else if ((sh_type
>= SHT_LOUSER
) && (sh_type
<= SHT_HIUSER
))
2633 sprintf (buff
, "LOUSER+%x", sh_type
- SHT_LOUSER
);
2635 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), sh_type
);
2641 #define OPTION_DEBUG_DUMP 512
2643 static struct option options
[] =
2645 {"all", no_argument
, 0, 'a'},
2646 {"file-header", no_argument
, 0, 'h'},
2647 {"program-headers", no_argument
, 0, 'l'},
2648 {"headers", no_argument
, 0, 'e'},
2649 {"histogram", no_argument
, 0, 'I'},
2650 {"segments", no_argument
, 0, 'l'},
2651 {"sections", no_argument
, 0, 'S'},
2652 {"section-headers", no_argument
, 0, 'S'},
2653 {"section-groups", no_argument
, 0, 'g'},
2654 {"section-details", no_argument
, 0, 't'},
2655 {"full-section-name",no_argument
, 0, 'N'},
2656 {"symbols", no_argument
, 0, 's'},
2657 {"syms", no_argument
, 0, 's'},
2658 {"relocs", no_argument
, 0, 'r'},
2659 {"notes", no_argument
, 0, 'n'},
2660 {"dynamic", no_argument
, 0, 'd'},
2661 {"arch-specific", no_argument
, 0, 'A'},
2662 {"version-info", no_argument
, 0, 'V'},
2663 {"use-dynamic", no_argument
, 0, 'D'},
2664 {"hex-dump", required_argument
, 0, 'x'},
2665 {"debug-dump", optional_argument
, 0, OPTION_DEBUG_DUMP
},
2666 {"unwind", no_argument
, 0, 'u'},
2667 #ifdef SUPPORT_DISASSEMBLY
2668 {"instruction-dump", required_argument
, 0, 'i'},
2671 {"version", no_argument
, 0, 'v'},
2672 {"wide", no_argument
, 0, 'W'},
2673 {"help", no_argument
, 0, 'H'},
2674 {0, no_argument
, 0, 0}
2680 fprintf (stdout
, _("Usage: readelf <option(s)> elf-file(s)\n"));
2681 fprintf (stdout
, _(" Display information about the contents of ELF format files\n"));
2682 fprintf (stdout
, _(" Options are:\n\
2683 -a --all Equivalent to: -h -l -S -s -r -d -V -A -I\n\
2684 -h --file-header Display the ELF file header\n\
2685 -l --program-headers Display the program headers\n\
2686 --segments An alias for --program-headers\n\
2687 -S --section-headers Display the sections' header\n\
2688 --sections An alias for --section-headers\n\
2689 -g --section-groups Display the section groups\n\
2690 -t --section-details Display the section details\n\
2691 -e --headers Equivalent to: -h -l -S\n\
2692 -s --syms Display the symbol table\n\
2693 --symbols An alias for --syms\n\
2694 -n --notes Display the core notes (if present)\n\
2695 -r --relocs Display the relocations (if present)\n\
2696 -u --unwind Display the unwind info (if present)\n\
2697 -d --dynamic Display the dynamic section (if present)\n\
2698 -V --version-info Display the version sections (if present)\n\
2699 -A --arch-specific Display architecture specific information (if any).\n\
2700 -D --use-dynamic Use the dynamic section info when displaying symbols\n\
2701 -x --hex-dump=<number> Dump the contents of section <number>\n\
2702 -w[liaprmfFsoR] or\n\
2703 --debug-dump[=line,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges]\n\
2704 Display the contents of DWARF2 debug sections\n"));
2705 #ifdef SUPPORT_DISASSEMBLY
2706 fprintf (stdout
, _("\
2707 -i --instruction-dump=<number>\n\
2708 Disassemble the contents of section <number>\n"));
2710 fprintf (stdout
, _("\
2711 -I --histogram Display histogram of bucket list lengths\n\
2712 -W --wide Allow output width to exceed 80 characters\n\
2713 @<file> Read options from <file>\n\
2714 -H --help Display this information\n\
2715 -v --version Display the version number of readelf\n"));
2716 fprintf (stdout
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
2721 /* Record the fact that the user wants the contents of section number
2722 SECTION to be displayed using the method(s) encoded as flags bits
2723 in TYPE. Note, TYPE can be zero if we are creating the array for
2727 request_dump (unsigned int section
, int type
)
2729 if (section
>= num_dump_sects
)
2731 char *new_dump_sects
;
2733 new_dump_sects
= calloc (section
+ 1, 1);
2735 if (new_dump_sects
== NULL
)
2736 error (_("Out of memory allocating dump request table."));
2739 /* Copy current flag settings. */
2740 memcpy (new_dump_sects
, dump_sects
, num_dump_sects
);
2744 dump_sects
= new_dump_sects
;
2745 num_dump_sects
= section
+ 1;
2750 dump_sects
[section
] |= type
;
2755 /* Request a dump by section name. */
2758 request_dump_byname (const char *section
, int type
)
2760 struct dump_list_entry
*new_request
;
2762 new_request
= malloc (sizeof (struct dump_list_entry
));
2764 error (_("Out of memory allocating dump request table."));
2766 new_request
->name
= strdup (section
);
2767 if (!new_request
->name
)
2768 error (_("Out of memory allocating dump request table."));
2770 new_request
->type
= type
;
2772 new_request
->next
= dump_sects_byname
;
2773 dump_sects_byname
= new_request
;
2777 parse_args (int argc
, char **argv
)
2784 while ((c
= getopt_long
2785 (argc
, argv
, "ersuahnldSDAINtgw::x:i:vVWH", options
, NULL
)) != EOF
)
2806 do_section_groups
++;
2814 do_section_groups
++;
2819 do_section_details
++;
2861 section
= strtoul (optarg
, & cp
, 0);
2862 if (! *cp
&& section
>= 0)
2863 request_dump (section
, HEX_DUMP
);
2865 request_dump_byname (optarg
, HEX_DUMP
);
2873 unsigned int index
= 0;
2877 while (optarg
[index
])
2878 switch (optarg
[index
++])
2887 do_debug_abbrevs
= 1;
2897 do_debug_pubnames
= 1;
2901 do_debug_aranges
= 1;
2905 do_debug_ranges
= 1;
2909 do_debug_frames_interp
= 1;
2911 do_debug_frames
= 1;
2916 do_debug_macinfo
= 1;
2930 warn (_("Unrecognized debug option '%s'\n"), optarg
);
2935 case OPTION_DEBUG_DUMP
:
2943 const char * option
;
2946 debug_dump_long_opts
;
2948 debug_dump_long_opts opts_table
[] =
2950 /* Please keep this table alpha- sorted. */
2951 { "Ranges", & do_debug_ranges
},
2952 { "abbrev", & do_debug_abbrevs
},
2953 { "aranges", & do_debug_aranges
},
2954 { "frames", & do_debug_frames
},
2955 { "frames-interp", & do_debug_frames_interp
},
2956 { "info", & do_debug_info
},
2957 { "line", & do_debug_lines
},
2958 { "loc", & do_debug_loc
},
2959 { "macro", & do_debug_macinfo
},
2960 { "pubnames", & do_debug_pubnames
},
2961 /* This entry is for compatability
2962 with earlier versions of readelf. */
2963 { "ranges", & do_debug_aranges
},
2964 { "str", & do_debug_str
},
2975 debug_dump_long_opts
* entry
;
2977 for (entry
= opts_table
; entry
->option
; entry
++)
2979 size_t len
= strlen (entry
->option
);
2981 if (strneq (p
, entry
->option
, len
)
2982 && (p
[len
] == ',' || p
[len
] == '\0'))
2984 * entry
->variable
= 1;
2986 /* The --debug-dump=frames-interp option also
2987 enables the --debug-dump=frames option. */
2988 if (do_debug_frames_interp
)
2989 do_debug_frames
= 1;
2996 if (entry
->option
== NULL
)
2998 warn (_("Unrecognized debug option '%s'\n"), p
);
2999 p
= strchr (p
, ',');
3009 #ifdef SUPPORT_DISASSEMBLY
3012 section
= strtoul (optarg
, & cp
, 0);
3013 if (! *cp
&& section
>= 0)
3015 request_dump (section
, DISASS_DUMP
);
3021 print_version (program_name
);
3030 #ifdef SUPPORT_DISASSEMBLY
3033 /* xgettext:c-format */
3034 error (_("Invalid option '-%c'\n"), c
);
3041 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
3042 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
3043 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
3044 && !do_section_groups
)
3048 warn (_("Nothing to do.\n"));
3054 get_elf_class (unsigned int elf_class
)
3056 static char buff
[32];
3060 case ELFCLASSNONE
: return _("none");
3061 case ELFCLASS32
: return "ELF32";
3062 case ELFCLASS64
: return "ELF64";
3064 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), elf_class
);
3070 get_data_encoding (unsigned int encoding
)
3072 static char buff
[32];
3076 case ELFDATANONE
: return _("none");
3077 case ELFDATA2LSB
: return _("2's complement, little endian");
3078 case ELFDATA2MSB
: return _("2's complement, big endian");
3080 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), encoding
);
3085 /* Decode the data held in 'elf_header'. */
3088 process_file_header (void)
3090 if ( elf_header
.e_ident
[EI_MAG0
] != ELFMAG0
3091 || elf_header
.e_ident
[EI_MAG1
] != ELFMAG1
3092 || elf_header
.e_ident
[EI_MAG2
] != ELFMAG2
3093 || elf_header
.e_ident
[EI_MAG3
] != ELFMAG3
)
3096 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
3104 printf (_("ELF Header:\n"));
3105 printf (_(" Magic: "));
3106 for (i
= 0; i
< EI_NIDENT
; i
++)
3107 printf ("%2.2x ", elf_header
.e_ident
[i
]);
3109 printf (_(" Class: %s\n"),
3110 get_elf_class (elf_header
.e_ident
[EI_CLASS
]));
3111 printf (_(" Data: %s\n"),
3112 get_data_encoding (elf_header
.e_ident
[EI_DATA
]));
3113 printf (_(" Version: %d %s\n"),
3114 elf_header
.e_ident
[EI_VERSION
],
3115 (elf_header
.e_ident
[EI_VERSION
] == EV_CURRENT
3117 : (elf_header
.e_ident
[EI_VERSION
] != EV_NONE
3120 printf (_(" OS/ABI: %s\n"),
3121 get_osabi_name (elf_header
.e_ident
[EI_OSABI
]));
3122 printf (_(" ABI Version: %d\n"),
3123 elf_header
.e_ident
[EI_ABIVERSION
]);
3124 printf (_(" Type: %s\n"),
3125 get_file_type (elf_header
.e_type
));
3126 printf (_(" Machine: %s\n"),
3127 get_machine_name (elf_header
.e_machine
));
3128 printf (_(" Version: 0x%lx\n"),
3129 (unsigned long) elf_header
.e_version
);
3131 printf (_(" Entry point address: "));
3132 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3133 printf (_("\n Start of program headers: "));
3134 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3135 printf (_(" (bytes into file)\n Start of section headers: "));
3136 print_vma ((bfd_vma
) elf_header
.e_shoff
, DEC
);
3137 printf (_(" (bytes into file)\n"));
3139 printf (_(" Flags: 0x%lx%s\n"),
3140 (unsigned long) elf_header
.e_flags
,
3141 get_machine_flags (elf_header
.e_flags
, elf_header
.e_machine
));
3142 printf (_(" Size of this header: %ld (bytes)\n"),
3143 (long) elf_header
.e_ehsize
);
3144 printf (_(" Size of program headers: %ld (bytes)\n"),
3145 (long) elf_header
.e_phentsize
);
3146 printf (_(" Number of program headers: %ld\n"),
3147 (long) elf_header
.e_phnum
);
3148 printf (_(" Size of section headers: %ld (bytes)\n"),
3149 (long) elf_header
.e_shentsize
);
3150 printf (_(" Number of section headers: %ld"),
3151 (long) elf_header
.e_shnum
);
3152 if (section_headers
!= NULL
&& elf_header
.e_shnum
== 0)
3153 printf (" (%ld)", (long) section_headers
[0].sh_size
);
3154 putc ('\n', stdout
);
3155 printf (_(" Section header string table index: %ld"),
3156 (long) elf_header
.e_shstrndx
);
3157 if (section_headers
!= NULL
&& elf_header
.e_shstrndx
== SHN_XINDEX
)
3158 printf (" (%ld)", (long) section_headers
[0].sh_link
);
3159 else if (elf_header
.e_shstrndx
!= SHN_UNDEF
3160 && (elf_header
.e_shstrndx
>= elf_header
.e_shnum
3161 || (elf_header
.e_shstrndx
>= SHN_LORESERVE
3162 && elf_header
.e_shstrndx
<= SHN_HIRESERVE
)))
3163 printf (" <corrupt: out of range>");
3164 putc ('\n', stdout
);
3167 if (section_headers
!= NULL
)
3169 if (elf_header
.e_shnum
== 0)
3170 elf_header
.e_shnum
= section_headers
[0].sh_size
;
3171 if (elf_header
.e_shstrndx
== SHN_XINDEX
)
3172 elf_header
.e_shstrndx
= section_headers
[0].sh_link
;
3173 else if (elf_header
.e_shstrndx
!= SHN_UNDEF
3174 && (elf_header
.e_shstrndx
>= elf_header
.e_shnum
3175 || (elf_header
.e_shstrndx
>= SHN_LORESERVE
3176 && elf_header
.e_shstrndx
<= SHN_HIRESERVE
)))
3177 elf_header
.e_shstrndx
= SHN_UNDEF
;
3178 free (section_headers
);
3179 section_headers
= NULL
;
3187 get_32bit_program_headers (FILE *file
, Elf_Internal_Phdr
*program_headers
)
3189 Elf32_External_Phdr
*phdrs
;
3190 Elf32_External_Phdr
*external
;
3191 Elf_Internal_Phdr
*internal
;
3194 phdrs
= get_data (NULL
, file
, elf_header
.e_phoff
,
3195 elf_header
.e_phentsize
, elf_header
.e_phnum
,
3196 _("program headers"));
3200 for (i
= 0, internal
= program_headers
, external
= phdrs
;
3201 i
< elf_header
.e_phnum
;
3202 i
++, internal
++, external
++)
3204 internal
->p_type
= BYTE_GET (external
->p_type
);
3205 internal
->p_offset
= BYTE_GET (external
->p_offset
);
3206 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
3207 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
3208 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
3209 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
3210 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3211 internal
->p_align
= BYTE_GET (external
->p_align
);
3220 get_64bit_program_headers (FILE *file
, Elf_Internal_Phdr
*program_headers
)
3222 Elf64_External_Phdr
*phdrs
;
3223 Elf64_External_Phdr
*external
;
3224 Elf_Internal_Phdr
*internal
;
3227 phdrs
= get_data (NULL
, file
, elf_header
.e_phoff
,
3228 elf_header
.e_phentsize
, elf_header
.e_phnum
,
3229 _("program headers"));
3233 for (i
= 0, internal
= program_headers
, external
= phdrs
;
3234 i
< elf_header
.e_phnum
;
3235 i
++, internal
++, external
++)
3237 internal
->p_type
= BYTE_GET (external
->p_type
);
3238 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3239 internal
->p_offset
= BYTE_GET (external
->p_offset
);
3240 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
3241 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
3242 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
3243 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
3244 internal
->p_align
= BYTE_GET (external
->p_align
);
3252 /* Returns 1 if the program headers were read into `program_headers'. */
3255 get_program_headers (FILE *file
)
3257 Elf_Internal_Phdr
*phdrs
;
3259 /* Check cache of prior read. */
3260 if (program_headers
!= NULL
)
3263 phdrs
= cmalloc (elf_header
.e_phnum
, sizeof (Elf_Internal_Phdr
));
3267 error (_("Out of memory\n"));
3272 ? get_32bit_program_headers (file
, phdrs
)
3273 : get_64bit_program_headers (file
, phdrs
))
3275 program_headers
= phdrs
;
3283 /* Returns 1 if the program headers were loaded. */
3286 process_program_headers (FILE *file
)
3288 Elf_Internal_Phdr
*segment
;
3291 if (elf_header
.e_phnum
== 0)
3294 printf (_("\nThere are no program headers in this file.\n"));
3298 if (do_segments
&& !do_header
)
3300 printf (_("\nElf file type is %s\n"), get_file_type (elf_header
.e_type
));
3301 printf (_("Entry point "));
3302 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3303 printf (_("\nThere are %d program headers, starting at offset "),
3304 elf_header
.e_phnum
);
3305 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3309 if (! get_program_headers (file
))
3314 if (elf_header
.e_phnum
> 1)
3315 printf (_("\nProgram Headers:\n"));
3317 printf (_("\nProgram Headers:\n"));
3321 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3324 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3328 (_(" Type Offset VirtAddr PhysAddr\n"));
3330 (_(" FileSiz MemSiz Flags Align\n"));
3337 for (i
= 0, segment
= program_headers
;
3338 i
< elf_header
.e_phnum
;
3343 printf (" %-14.14s ", get_segment_type (segment
->p_type
));
3347 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3348 printf ("0x%8.8lx ", (unsigned long) segment
->p_vaddr
);
3349 printf ("0x%8.8lx ", (unsigned long) segment
->p_paddr
);
3350 printf ("0x%5.5lx ", (unsigned long) segment
->p_filesz
);
3351 printf ("0x%5.5lx ", (unsigned long) segment
->p_memsz
);
3353 (segment
->p_flags
& PF_R
? 'R' : ' '),
3354 (segment
->p_flags
& PF_W
? 'W' : ' '),
3355 (segment
->p_flags
& PF_X
? 'E' : ' '));
3356 printf ("%#lx", (unsigned long) segment
->p_align
);
3360 if ((unsigned long) segment
->p_offset
== segment
->p_offset
)
3361 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3364 print_vma (segment
->p_offset
, FULL_HEX
);
3368 print_vma (segment
->p_vaddr
, FULL_HEX
);
3370 print_vma (segment
->p_paddr
, FULL_HEX
);
3373 if ((unsigned long) segment
->p_filesz
== segment
->p_filesz
)
3374 printf ("0x%6.6lx ", (unsigned long) segment
->p_filesz
);
3377 print_vma (segment
->p_filesz
, FULL_HEX
);
3381 if ((unsigned long) segment
->p_memsz
== segment
->p_memsz
)
3382 printf ("0x%6.6lx", (unsigned long) segment
->p_memsz
);
3385 print_vma (segment
->p_offset
, FULL_HEX
);
3389 (segment
->p_flags
& PF_R
? 'R' : ' '),
3390 (segment
->p_flags
& PF_W
? 'W' : ' '),
3391 (segment
->p_flags
& PF_X
? 'E' : ' '));
3393 if ((unsigned long) segment
->p_align
== segment
->p_align
)
3394 printf ("%#lx", (unsigned long) segment
->p_align
);
3397 print_vma (segment
->p_align
, PREFIX_HEX
);
3402 print_vma (segment
->p_offset
, FULL_HEX
);
3404 print_vma (segment
->p_vaddr
, FULL_HEX
);
3406 print_vma (segment
->p_paddr
, FULL_HEX
);
3408 print_vma (segment
->p_filesz
, FULL_HEX
);
3410 print_vma (segment
->p_memsz
, FULL_HEX
);
3412 (segment
->p_flags
& PF_R
? 'R' : ' '),
3413 (segment
->p_flags
& PF_W
? 'W' : ' '),
3414 (segment
->p_flags
& PF_X
? 'E' : ' '));
3415 print_vma (segment
->p_align
, HEX
);
3419 switch (segment
->p_type
)
3423 error (_("more than one dynamic segment\n"));
3425 /* Try to locate the .dynamic section. If there is
3426 a section header table, we can easily locate it. */
3427 if (section_headers
!= NULL
)
3429 Elf_Internal_Shdr
*sec
;
3431 sec
= find_section (".dynamic");
3432 if (sec
== NULL
|| sec
->sh_size
== 0)
3434 error (_("no .dynamic section in the dynamic segment"));
3438 dynamic_addr
= sec
->sh_offset
;
3439 dynamic_size
= sec
->sh_size
;
3441 if (dynamic_addr
< segment
->p_offset
3442 || dynamic_addr
> segment
->p_offset
+ segment
->p_filesz
)
3443 warn (_("the .dynamic section is not contained within the dynamic segment"));
3444 else if (dynamic_addr
> segment
->p_offset
)
3445 warn (_("the .dynamic section is not the first section in the dynamic segment."));
3449 /* Otherwise, we can only assume that the .dynamic
3450 section is the first section in the DYNAMIC segment. */
3451 dynamic_addr
= segment
->p_offset
;
3452 dynamic_size
= segment
->p_filesz
;
3457 if (fseek (file
, archive_file_offset
+ (long) segment
->p_offset
,
3459 error (_("Unable to find program interpreter name\n"));
3462 program_interpreter
[0] = 0;
3463 fscanf (file
, "%63s", program_interpreter
);
3466 printf (_("\n [Requesting program interpreter: %s]"),
3467 program_interpreter
);
3473 putc ('\n', stdout
);
3476 if (do_segments
&& section_headers
!= NULL
&& string_table
!= NULL
)
3478 printf (_("\n Section to Segment mapping:\n"));
3479 printf (_(" Segment Sections...\n"));
3481 for (i
= 0; i
< elf_header
.e_phnum
; i
++)
3484 Elf_Internal_Shdr
*section
;
3486 segment
= program_headers
+ i
;
3487 section
= section_headers
;
3489 printf (" %2.2d ", i
);
3491 for (j
= 1; j
< elf_header
.e_shnum
; j
++, section
++)
3493 if (ELF_IS_SECTION_IN_SEGMENT_MEMORY(section
, segment
))
3494 printf ("%s ", SECTION_NAME (section
));
3505 /* Find the file offset corresponding to VMA by using the program headers. */
3508 offset_from_vma (FILE *file
, bfd_vma vma
, bfd_size_type size
)
3510 Elf_Internal_Phdr
*seg
;
3512 if (! get_program_headers (file
))
3514 warn (_("Cannot interpret virtual addresses without program headers.\n"));
3518 for (seg
= program_headers
;
3519 seg
< program_headers
+ elf_header
.e_phnum
;
3522 if (seg
->p_type
!= PT_LOAD
)
3525 if (vma
>= (seg
->p_vaddr
& -seg
->p_align
)
3526 && vma
+ size
<= seg
->p_vaddr
+ seg
->p_filesz
)
3527 return vma
- seg
->p_vaddr
+ seg
->p_offset
;
3530 warn (_("Virtual address 0x%lx not located in any PT_LOAD segment.\n"),
3537 get_32bit_section_headers (FILE *file
, unsigned int num
)
3539 Elf32_External_Shdr
*shdrs
;
3540 Elf_Internal_Shdr
*internal
;
3543 shdrs
= get_data (NULL
, file
, elf_header
.e_shoff
,
3544 elf_header
.e_shentsize
, num
, _("section headers"));
3548 section_headers
= cmalloc (num
, sizeof (Elf_Internal_Shdr
));
3550 if (section_headers
== NULL
)
3552 error (_("Out of memory\n"));
3556 for (i
= 0, internal
= section_headers
;
3560 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3561 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3562 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
3563 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
3564 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3565 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
3566 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3567 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3568 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3569 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
3578 get_64bit_section_headers (FILE *file
, unsigned int num
)
3580 Elf64_External_Shdr
*shdrs
;
3581 Elf_Internal_Shdr
*internal
;
3584 shdrs
= get_data (NULL
, file
, elf_header
.e_shoff
,
3585 elf_header
.e_shentsize
, num
, _("section headers"));
3589 section_headers
= cmalloc (num
, sizeof (Elf_Internal_Shdr
));
3591 if (section_headers
== NULL
)
3593 error (_("Out of memory\n"));
3597 for (i
= 0, internal
= section_headers
;
3601 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3602 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3603 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
3604 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
3605 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
3606 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
3607 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3608 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3609 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3610 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3618 static Elf_Internal_Sym
*
3619 get_32bit_elf_symbols (FILE *file
, Elf_Internal_Shdr
*section
)
3621 unsigned long number
;
3622 Elf32_External_Sym
*esyms
;
3623 Elf_External_Sym_Shndx
*shndx
;
3624 Elf_Internal_Sym
*isyms
;
3625 Elf_Internal_Sym
*psym
;
3628 esyms
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
3634 if (symtab_shndx_hdr
!= NULL
3635 && (symtab_shndx_hdr
->sh_link
3636 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3638 shndx
= get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3639 1, symtab_shndx_hdr
->sh_size
, _("symtab shndx"));
3647 number
= section
->sh_size
/ section
->sh_entsize
;
3648 isyms
= cmalloc (number
, sizeof (Elf_Internal_Sym
));
3652 error (_("Out of memory\n"));
3659 for (j
= 0, psym
= isyms
;
3663 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3664 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3665 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3666 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3667 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3669 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3670 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3671 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3681 static Elf_Internal_Sym
*
3682 get_64bit_elf_symbols (FILE *file
, Elf_Internal_Shdr
*section
)
3684 unsigned long number
;
3685 Elf64_External_Sym
*esyms
;
3686 Elf_External_Sym_Shndx
*shndx
;
3687 Elf_Internal_Sym
*isyms
;
3688 Elf_Internal_Sym
*psym
;
3691 esyms
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
3697 if (symtab_shndx_hdr
!= NULL
3698 && (symtab_shndx_hdr
->sh_link
3699 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3701 shndx
= get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3702 1, symtab_shndx_hdr
->sh_size
, _("symtab shndx"));
3710 number
= section
->sh_size
/ section
->sh_entsize
;
3711 isyms
= cmalloc (number
, sizeof (Elf_Internal_Sym
));
3715 error (_("Out of memory\n"));
3722 for (j
= 0, psym
= isyms
;
3726 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3727 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3728 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3729 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3730 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3732 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3733 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3734 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3745 get_elf_section_flags (bfd_vma sh_flags
)
3747 static char buff
[1024];
3749 int field_size
= is_32bit_elf
? 8 : 16;
3750 int index
, size
= sizeof (buff
) - (field_size
+ 4 + 1);
3751 bfd_vma os_flags
= 0;
3752 bfd_vma proc_flags
= 0;
3753 bfd_vma unknown_flags
= 0;
3767 { "LINK ORDER", 10 },
3768 { "OS NONCONF", 10 },
3773 if (do_section_details
)
3775 sprintf (buff
, "[%*.*lx]: ",
3776 field_size
, field_size
, (unsigned long) sh_flags
);
3777 p
+= field_size
+ 4;
3784 flag
= sh_flags
& - sh_flags
;
3787 if (do_section_details
)
3791 case SHF_WRITE
: index
= 0; break;
3792 case SHF_ALLOC
: index
= 1; break;
3793 case SHF_EXECINSTR
: index
= 2; break;
3794 case SHF_MERGE
: index
= 3; break;
3795 case SHF_STRINGS
: index
= 4; break;
3796 case SHF_INFO_LINK
: index
= 5; break;
3797 case SHF_LINK_ORDER
: index
= 6; break;
3798 case SHF_OS_NONCONFORMING
: index
= 7; break;
3799 case SHF_GROUP
: index
= 8; break;
3800 case SHF_TLS
: index
= 9; break;
3809 if (p
!= buff
+ field_size
+ 4)
3811 if (size
< (10 + 2))
3818 size
-= flags
[index
].len
;
3819 p
= stpcpy (p
, flags
[index
].str
);
3821 else if (flag
& SHF_MASKOS
)
3823 else if (flag
& SHF_MASKPROC
)
3826 unknown_flags
|= flag
;
3832 case SHF_WRITE
: *p
= 'W'; break;
3833 case SHF_ALLOC
: *p
= 'A'; break;
3834 case SHF_EXECINSTR
: *p
= 'X'; break;
3835 case SHF_MERGE
: *p
= 'M'; break;
3836 case SHF_STRINGS
: *p
= 'S'; break;
3837 case SHF_INFO_LINK
: *p
= 'I'; break;
3838 case SHF_LINK_ORDER
: *p
= 'L'; break;
3839 case SHF_OS_NONCONFORMING
: *p
= 'O'; break;
3840 case SHF_GROUP
: *p
= 'G'; break;
3841 case SHF_TLS
: *p
= 'T'; break;
3844 if (elf_header
.e_machine
== EM_X86_64
3845 && flag
== SHF_X86_64_LARGE
)
3847 else if (flag
& SHF_MASKOS
)
3850 sh_flags
&= ~ SHF_MASKOS
;
3852 else if (flag
& SHF_MASKPROC
)
3855 sh_flags
&= ~ SHF_MASKPROC
;
3865 if (do_section_details
)
3869 size
-= 5 + field_size
;
3870 if (p
!= buff
+ field_size
+ 4)
3878 sprintf (p
, "OS (%*.*lx)", field_size
, field_size
,
3879 (unsigned long) os_flags
);
3880 p
+= 5 + field_size
;
3884 size
-= 7 + field_size
;
3885 if (p
!= buff
+ field_size
+ 4)
3893 sprintf (p
, "PROC (%*.*lx)", field_size
, field_size
,
3894 (unsigned long) proc_flags
);
3895 p
+= 7 + field_size
;
3899 size
-= 10 + field_size
;
3900 if (p
!= buff
+ field_size
+ 4)
3908 sprintf (p
, "UNKNOWN (%*.*lx)", field_size
, field_size
,
3909 (unsigned long) unknown_flags
);
3910 p
+= 10 + field_size
;
3919 process_section_headers (FILE *file
)
3921 Elf_Internal_Shdr
*section
;
3924 section_headers
= NULL
;
3926 if (elf_header
.e_shnum
== 0)
3929 printf (_("\nThere are no sections in this file.\n"));
3934 if (do_sections
&& !do_header
)
3935 printf (_("There are %d section headers, starting at offset 0x%lx:\n"),
3936 elf_header
.e_shnum
, (unsigned long) elf_header
.e_shoff
);
3940 if (! get_32bit_section_headers (file
, elf_header
.e_shnum
))
3943 else if (! get_64bit_section_headers (file
, elf_header
.e_shnum
))
3946 /* Read in the string table, so that we have names to display. */
3947 if (elf_header
.e_shstrndx
!= SHN_UNDEF
3948 && SECTION_HEADER_INDEX (elf_header
.e_shstrndx
) < elf_header
.e_shnum
)
3950 section
= SECTION_HEADER (elf_header
.e_shstrndx
);
3952 if (section
->sh_size
!= 0)
3954 string_table
= get_data (NULL
, file
, section
->sh_offset
,
3955 1, section
->sh_size
, _("string table"));
3957 string_table_length
= string_table
!= NULL
? section
->sh_size
: 0;
3961 /* Scan the sections for the dynamic symbol table
3962 and dynamic string table and debug sections. */
3963 dynamic_symbols
= NULL
;
3964 dynamic_strings
= NULL
;
3965 dynamic_syminfo
= NULL
;
3966 symtab_shndx_hdr
= NULL
;
3968 eh_addr_size
= is_32bit_elf
? 4 : 8;
3969 switch (elf_header
.e_machine
)
3972 case EM_MIPS_RS3_LE
:
3973 /* The 64-bit MIPS EABI uses a combination of 32-bit ELF and 64-bit
3974 FDE addresses. However, the ABI also has a semi-official ILP32
3975 variant for which the normal FDE address size rules apply.
3977 GCC 4.0 marks EABI64 objects with a dummy .gcc_compiled_longXX
3978 section, where XX is the size of longs in bits. Unfortunately,
3979 earlier compilers provided no way of distinguishing ILP32 objects
3980 from LP64 objects, so if there's any doubt, we should assume that
3981 the official LP64 form is being used. */
3982 if ((elf_header
.e_flags
& EF_MIPS_ABI
) == E_MIPS_ABI_EABI64
3983 && find_section (".gcc_compiled_long32") == NULL
)
3989 switch (elf_header
.e_flags
& EF_H8_MACH
)
3991 case E_H8_MACH_H8300
:
3992 case E_H8_MACH_H8300HN
:
3993 case E_H8_MACH_H8300SN
:
3994 case E_H8_MACH_H8300SXN
:
3997 case E_H8_MACH_H8300H
:
3998 case E_H8_MACH_H8300S
:
3999 case E_H8_MACH_H8300SX
:
4005 #define CHECK_ENTSIZE_VALUES(section, i, size32, size64) \
4008 size_t expected_entsize \
4009 = is_32bit_elf ? size32 : size64; \
4010 if (section->sh_entsize != expected_entsize) \
4011 error (_("Section %d has invalid sh_entsize %lx (expected %lx)\n"), \
4012 i, (unsigned long int) section->sh_entsize, \
4013 (unsigned long int) expected_entsize); \
4014 section->sh_entsize = expected_entsize; \
4017 #define CHECK_ENTSIZE(section, i, type) \
4018 CHECK_ENTSIZE_VALUES (section, i, sizeof (Elf32_External_##type), \
4019 sizeof (Elf64_External_##type))
4021 for (i
= 0, section
= section_headers
;
4022 i
< elf_header
.e_shnum
;
4025 char *name
= SECTION_NAME (section
);
4027 if (section
->sh_type
== SHT_DYNSYM
)
4029 if (dynamic_symbols
!= NULL
)
4031 error (_("File contains multiple dynamic symbol tables\n"));
4035 CHECK_ENTSIZE (section
, i
, Sym
);
4036 num_dynamic_syms
= section
->sh_size
/ section
->sh_entsize
;
4037 dynamic_symbols
= GET_ELF_SYMBOLS (file
, section
);
4039 else if (section
->sh_type
== SHT_STRTAB
4040 && streq (name
, ".dynstr"))
4042 if (dynamic_strings
!= NULL
)
4044 error (_("File contains multiple dynamic string tables\n"));
4048 dynamic_strings
= get_data (NULL
, file
, section
->sh_offset
,
4049 1, section
->sh_size
, _("dynamic strings"));
4050 dynamic_strings_length
= section
->sh_size
;
4052 else if (section
->sh_type
== SHT_SYMTAB_SHNDX
)
4054 if (symtab_shndx_hdr
!= NULL
)
4056 error (_("File contains multiple symtab shndx tables\n"));
4059 symtab_shndx_hdr
= section
;
4061 else if (section
->sh_type
== SHT_SYMTAB
)
4062 CHECK_ENTSIZE (section
, i
, Sym
);
4063 else if (section
->sh_type
== SHT_GROUP
)
4064 CHECK_ENTSIZE_VALUES (section
, i
, GRP_ENTRY_SIZE
, GRP_ENTRY_SIZE
);
4065 else if (section
->sh_type
== SHT_REL
)
4066 CHECK_ENTSIZE (section
, i
, Rel
);
4067 else if (section
->sh_type
== SHT_RELA
)
4068 CHECK_ENTSIZE (section
, i
, Rela
);
4069 else if ((do_debugging
|| do_debug_info
|| do_debug_abbrevs
4070 || do_debug_lines
|| do_debug_pubnames
|| do_debug_aranges
4071 || do_debug_frames
|| do_debug_macinfo
|| do_debug_str
4072 || do_debug_loc
|| do_debug_ranges
)
4073 && strneq (name
, ".debug_", 7))
4078 || (do_debug_info
&& streq (name
, "info"))
4079 || (do_debug_abbrevs
&& streq (name
, "abbrev"))
4080 || (do_debug_lines
&& streq (name
, "line"))
4081 || (do_debug_pubnames
&& streq (name
, "pubnames"))
4082 || (do_debug_aranges
&& streq (name
, "aranges"))
4083 || (do_debug_ranges
&& streq (name
, "ranges"))
4084 || (do_debug_frames
&& streq (name
, "frame"))
4085 || (do_debug_macinfo
&& streq (name
, "macinfo"))
4086 || (do_debug_str
&& streq (name
, "str"))
4087 || (do_debug_loc
&& streq (name
, "loc"))
4089 request_dump (i
, DEBUG_DUMP
);
4091 /* linkonce section to be combined with .debug_info at link time. */
4092 else if ((do_debugging
|| do_debug_info
)
4093 && strneq (name
, ".gnu.linkonce.wi.", 17))
4094 request_dump (i
, DEBUG_DUMP
);
4095 else if (do_debug_frames
&& streq (name
, ".eh_frame"))
4096 request_dump (i
, DEBUG_DUMP
);
4102 if (elf_header
.e_shnum
> 1)
4103 printf (_("\nSection Headers:\n"));
4105 printf (_("\nSection Header:\n"));
4109 if (do_section_details
)
4111 printf (_(" [Nr] Name\n"));
4112 printf (_(" Type Addr Off Size ES Lk Inf Al\n"));
4116 (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
4120 if (do_section_details
)
4122 printf (_(" [Nr] Name\n"));
4123 printf (_(" Type Address Off Size ES Lk Inf Al\n"));
4127 (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n"));
4131 if (do_section_details
)
4133 printf (_(" [Nr] Name\n"));
4134 printf (_(" Type Address Offset Link\n"));
4135 printf (_(" Size EntSize Info Align\n"));
4139 printf (_(" [Nr] Name Type Address Offset\n"));
4140 printf (_(" Size EntSize Flags Link Info Align\n"));
4144 if (do_section_details
)
4145 printf (_(" Flags\n"));
4147 for (i
= 0, section
= section_headers
;
4148 i
< elf_header
.e_shnum
;
4151 if (do_section_details
)
4153 printf (" [%2u] %s\n",
4154 SECTION_HEADER_NUM (i
),
4155 SECTION_NAME (section
));
4156 if (is_32bit_elf
|| do_wide
)
4157 printf (" %-15.15s ",
4158 get_section_type_name (section
->sh_type
));
4161 printf (" [%2u] %-17.17s %-15.15s ",
4162 SECTION_HEADER_NUM (i
),
4163 SECTION_NAME (section
),
4164 get_section_type_name (section
->sh_type
));
4168 print_vma (section
->sh_addr
, LONG_HEX
);
4170 printf ( " %6.6lx %6.6lx %2.2lx",
4171 (unsigned long) section
->sh_offset
,
4172 (unsigned long) section
->sh_size
,
4173 (unsigned long) section
->sh_entsize
);
4175 if (do_section_details
)
4176 fputs (" ", stdout
);
4178 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4180 printf ("%2ld %3lu %2ld\n",
4181 (unsigned long) section
->sh_link
,
4182 (unsigned long) section
->sh_info
,
4183 (unsigned long) section
->sh_addralign
);
4187 print_vma (section
->sh_addr
, LONG_HEX
);
4189 if ((long) section
->sh_offset
== section
->sh_offset
)
4190 printf (" %6.6lx", (unsigned long) section
->sh_offset
);
4194 print_vma (section
->sh_offset
, LONG_HEX
);
4197 if ((unsigned long) section
->sh_size
== section
->sh_size
)
4198 printf (" %6.6lx", (unsigned long) section
->sh_size
);
4202 print_vma (section
->sh_size
, LONG_HEX
);
4205 if ((unsigned long) section
->sh_entsize
== section
->sh_entsize
)
4206 printf (" %2.2lx", (unsigned long) section
->sh_entsize
);
4210 print_vma (section
->sh_entsize
, LONG_HEX
);
4213 if (do_section_details
)
4214 fputs (" ", stdout
);
4216 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4218 printf ("%2ld %3lu ",
4219 (unsigned long) section
->sh_link
,
4220 (unsigned long) section
->sh_info
);
4222 if ((unsigned long) section
->sh_addralign
== section
->sh_addralign
)
4223 printf ("%2ld\n", (unsigned long) section
->sh_addralign
);
4226 print_vma (section
->sh_addralign
, DEC
);
4230 else if (do_section_details
)
4232 printf (" %-15.15s ",
4233 get_section_type_name (section
->sh_type
));
4234 print_vma (section
->sh_addr
, LONG_HEX
);
4235 if ((long) section
->sh_offset
== section
->sh_offset
)
4236 printf (" %16.16lx", (unsigned long) section
->sh_offset
);
4240 print_vma (section
->sh_offset
, LONG_HEX
);
4242 printf (" %ld\n ", (unsigned long) section
->sh_link
);
4243 print_vma (section
->sh_size
, LONG_HEX
);
4245 print_vma (section
->sh_entsize
, LONG_HEX
);
4247 printf (" %-16lu %ld\n",
4248 (unsigned long) section
->sh_info
,
4249 (unsigned long) section
->sh_addralign
);
4254 print_vma (section
->sh_addr
, LONG_HEX
);
4255 if ((long) section
->sh_offset
== section
->sh_offset
)
4256 printf (" %8.8lx", (unsigned long) section
->sh_offset
);
4260 print_vma (section
->sh_offset
, LONG_HEX
);
4263 print_vma (section
->sh_size
, LONG_HEX
);
4265 print_vma (section
->sh_entsize
, LONG_HEX
);
4267 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4269 printf (" %2ld %3lu %ld\n",
4270 (unsigned long) section
->sh_link
,
4271 (unsigned long) section
->sh_info
,
4272 (unsigned long) section
->sh_addralign
);
4275 if (do_section_details
)
4276 printf (" %s\n", get_elf_section_flags (section
->sh_flags
));
4279 if (!do_section_details
)
4280 printf (_("Key to Flags:\n\
4281 W (write), A (alloc), X (execute), M (merge), S (strings)\n\
4282 I (info), L (link order), G (group), x (unknown)\n\
4283 O (extra OS processing required) o (OS specific), p (processor specific)\n"));
4289 get_group_flags (unsigned int flags
)
4291 static char buff
[32];
4298 snprintf (buff
, sizeof (buff
), _("[<unknown>: 0x%x]"), flags
);
4305 process_section_groups (FILE *file
)
4307 Elf_Internal_Shdr
*section
;
4309 struct group
*group
;
4310 Elf_Internal_Shdr
*symtab_sec
, *strtab_sec
;
4311 Elf_Internal_Sym
*symtab
;
4315 /* Don't process section groups unless needed. */
4316 if (!do_unwind
&& !do_section_groups
)
4319 if (elf_header
.e_shnum
== 0)
4321 if (do_section_groups
)
4322 printf (_("\nThere are no sections in this file.\n"));
4327 if (section_headers
== NULL
)
4329 error (_("Section headers are not available!\n"));
4333 section_headers_groups
= calloc (elf_header
.e_shnum
,
4334 sizeof (struct group
*));
4336 if (section_headers_groups
== NULL
)
4338 error (_("Out of memory\n"));
4342 /* Scan the sections for the group section. */
4344 for (i
= 0, section
= section_headers
;
4345 i
< elf_header
.e_shnum
;
4347 if (section
->sh_type
== SHT_GROUP
)
4350 if (group_count
== 0)
4352 if (do_section_groups
)
4353 printf (_("\nThere are no section groups in this file.\n"));
4358 section_groups
= calloc (group_count
, sizeof (struct group
));
4360 if (section_groups
== NULL
)
4362 error (_("Out of memory\n"));
4371 for (i
= 0, section
= section_headers
, group
= section_groups
;
4372 i
< elf_header
.e_shnum
;
4375 if (section
->sh_type
== SHT_GROUP
)
4377 char *name
= SECTION_NAME (section
);
4379 unsigned char *start
, *indices
;
4380 unsigned int entry
, j
, size
;
4381 Elf_Internal_Shdr
*sec
;
4382 Elf_Internal_Sym
*sym
;
4384 /* Get the symbol table. */
4385 if (SECTION_HEADER_INDEX (section
->sh_link
) >= elf_header
.e_shnum
4386 || ((sec
= SECTION_HEADER (section
->sh_link
))->sh_type
4389 error (_("Bad sh_link in group section `%s'\n"), name
);
4393 if (symtab_sec
!= sec
)
4398 symtab
= GET_ELF_SYMBOLS (file
, symtab_sec
);
4401 sym
= symtab
+ section
->sh_info
;
4403 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
4405 bfd_vma sec_index
= SECTION_HEADER_INDEX (sym
->st_shndx
);
4408 error (_("Bad sh_info in group section `%s'\n"), name
);
4412 group_name
= SECTION_NAME (section_headers
+ sec_index
);
4421 /* Get the string table. */
4422 if (SECTION_HEADER_INDEX (symtab_sec
->sh_link
)
4423 >= elf_header
.e_shnum
)
4432 != (sec
= SECTION_HEADER (symtab_sec
->sh_link
)))
4437 strtab
= get_data (NULL
, file
, strtab_sec
->sh_offset
,
4438 1, strtab_sec
->sh_size
,
4440 strtab_size
= strtab
!= NULL
? strtab_sec
->sh_size
: 0;
4442 group_name
= sym
->st_name
< strtab_size
4443 ? strtab
+ sym
->st_name
: "<corrupt>";
4446 start
= get_data (NULL
, file
, section
->sh_offset
,
4447 1, section
->sh_size
, _("section data"));
4450 size
= (section
->sh_size
/ section
->sh_entsize
) - 1;
4451 entry
= byte_get (indices
, 4);
4454 if (do_section_groups
)
4456 printf ("\n%s group section [%5u] `%s' [%s] contains %u sections:\n",
4457 get_group_flags (entry
), i
, name
, group_name
, size
);
4459 printf (_(" [Index] Name\n"));
4462 group
->group_index
= i
;
4464 for (j
= 0; j
< size
; j
++)
4466 struct group_list
*g
;
4468 entry
= byte_get (indices
, 4);
4471 if (SECTION_HEADER_INDEX (entry
) >= elf_header
.e_shnum
)
4473 error (_("section [%5u] in group section [%5u] > maximum section [%5u]\n"),
4474 entry
, i
, elf_header
.e_shnum
- 1);
4477 else if (entry
>= SHN_LORESERVE
&& entry
<= SHN_HIRESERVE
)
4479 error (_("invalid section [%5u] in group section [%5u]\n"),
4484 if (section_headers_groups
[SECTION_HEADER_INDEX (entry
)]
4489 error (_("section [%5u] in group section [%5u] already in group section [%5u]\n"),
4491 section_headers_groups
[SECTION_HEADER_INDEX (entry
)]->group_index
);
4496 /* Intel C/C++ compiler may put section 0 in a
4497 section group. We just warn it the first time
4498 and ignore it afterwards. */
4499 static int warned
= 0;
4502 error (_("section 0 in group section [%5u]\n"),
4503 section_headers_groups
[SECTION_HEADER_INDEX (entry
)]->group_index
);
4509 section_headers_groups
[SECTION_HEADER_INDEX (entry
)]
4512 if (do_section_groups
)
4514 sec
= SECTION_HEADER (entry
);
4515 printf (" [%5u] %s\n", entry
, SECTION_NAME (sec
));
4518 g
= xmalloc (sizeof (struct group_list
));
4519 g
->section_index
= entry
;
4520 g
->next
= group
->root
;
4544 } dynamic_relocations
[] =
4546 { "REL", DT_REL
, DT_RELSZ
, FALSE
},
4547 { "RELA", DT_RELA
, DT_RELASZ
, TRUE
},
4548 { "PLT", DT_JMPREL
, DT_PLTRELSZ
, UNKNOWN
}
4551 /* Process the reloc section. */
4554 process_relocs (FILE *file
)
4556 unsigned long rel_size
;
4557 unsigned long rel_offset
;
4563 if (do_using_dynamic
)
4567 int has_dynamic_reloc
;
4570 has_dynamic_reloc
= 0;
4572 for (i
= 0; i
< ARRAY_SIZE (dynamic_relocations
); i
++)
4574 is_rela
= dynamic_relocations
[i
].rela
;
4575 name
= dynamic_relocations
[i
].name
;
4576 rel_size
= dynamic_info
[dynamic_relocations
[i
].size
];
4577 rel_offset
= dynamic_info
[dynamic_relocations
[i
].reloc
];
4579 has_dynamic_reloc
|= rel_size
;
4581 if (is_rela
== UNKNOWN
)
4583 if (dynamic_relocations
[i
].reloc
== DT_JMPREL
)
4584 switch (dynamic_info
[DT_PLTREL
])
4598 (_("\n'%s' relocation section at offset 0x%lx contains %ld bytes:\n"),
4599 name
, rel_offset
, rel_size
);
4601 dump_relocations (file
,
4602 offset_from_vma (file
, rel_offset
, rel_size
),
4604 dynamic_symbols
, num_dynamic_syms
,
4605 dynamic_strings
, dynamic_strings_length
, is_rela
);
4609 if (! has_dynamic_reloc
)
4610 printf (_("\nThere are no dynamic relocations in this file.\n"));
4614 Elf_Internal_Shdr
*section
;
4618 for (i
= 0, section
= section_headers
;
4619 i
< elf_header
.e_shnum
;
4622 if ( section
->sh_type
!= SHT_RELA
4623 && section
->sh_type
!= SHT_REL
)
4626 rel_offset
= section
->sh_offset
;
4627 rel_size
= section
->sh_size
;
4631 Elf_Internal_Shdr
*strsec
;
4634 printf (_("\nRelocation section "));
4636 if (string_table
== NULL
)
4637 printf ("%d", section
->sh_name
);
4639 printf (_("'%s'"), SECTION_NAME (section
));
4641 printf (_(" at offset 0x%lx contains %lu entries:\n"),
4642 rel_offset
, (unsigned long) (rel_size
/ section
->sh_entsize
));
4644 is_rela
= section
->sh_type
== SHT_RELA
;
4646 if (section
->sh_link
4647 && SECTION_HEADER_INDEX (section
->sh_link
)
4648 < elf_header
.e_shnum
)
4650 Elf_Internal_Shdr
*symsec
;
4651 Elf_Internal_Sym
*symtab
;
4652 unsigned long nsyms
;
4653 unsigned long strtablen
= 0;
4654 char *strtab
= NULL
;
4656 symsec
= SECTION_HEADER (section
->sh_link
);
4657 if (symsec
->sh_type
!= SHT_SYMTAB
4658 && symsec
->sh_type
!= SHT_DYNSYM
)
4661 nsyms
= symsec
->sh_size
/ symsec
->sh_entsize
;
4662 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
4667 if (SECTION_HEADER_INDEX (symsec
->sh_link
)
4668 < elf_header
.e_shnum
)
4670 strsec
= SECTION_HEADER (symsec
->sh_link
);
4672 strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
4675 strtablen
= strtab
== NULL
? 0 : strsec
->sh_size
;
4678 dump_relocations (file
, rel_offset
, rel_size
,
4679 symtab
, nsyms
, strtab
, strtablen
, is_rela
);
4685 dump_relocations (file
, rel_offset
, rel_size
,
4686 NULL
, 0, NULL
, 0, is_rela
);
4693 printf (_("\nThere are no relocations in this file.\n"));
4699 /* Process the unwind section. */
4701 #include "unwind-ia64.h"
4703 /* An absolute address consists of a section and an offset. If the
4704 section is NULL, the offset itself is the address, otherwise, the
4705 address equals to LOAD_ADDRESS(section) + offset. */
4709 unsigned short section
;
4713 #define ABSADDR(a) \
4715 ? section_headers [(a).section].sh_addr + (a).offset \
4718 struct ia64_unw_aux_info
4720 struct ia64_unw_table_entry
4722 struct absaddr start
;
4724 struct absaddr info
;
4726 *table
; /* Unwind table. */
4727 unsigned long table_len
; /* Length of unwind table. */
4728 unsigned char *info
; /* Unwind info. */
4729 unsigned long info_size
; /* Size of unwind info. */
4730 bfd_vma info_addr
; /* starting address of unwind info. */
4731 bfd_vma seg_base
; /* Starting address of segment. */
4732 Elf_Internal_Sym
*symtab
; /* The symbol table. */
4733 unsigned long nsyms
; /* Number of symbols. */
4734 char *strtab
; /* The string table. */
4735 unsigned long strtab_size
; /* Size of string table. */
4739 find_symbol_for_address (Elf_Internal_Sym
*symtab
,
4740 unsigned long nsyms
,
4742 unsigned long strtab_size
,
4743 struct absaddr addr
,
4744 const char **symname
,
4747 bfd_vma dist
= 0x100000;
4748 Elf_Internal_Sym
*sym
, *best
= NULL
;
4751 for (i
= 0, sym
= symtab
; i
< nsyms
; ++i
, ++sym
)
4753 if (ELF_ST_TYPE (sym
->st_info
) == STT_FUNC
4754 && sym
->st_name
!= 0
4755 && (addr
.section
== SHN_UNDEF
|| addr
.section
== sym
->st_shndx
)
4756 && addr
.offset
>= sym
->st_value
4757 && addr
.offset
- sym
->st_value
< dist
)
4760 dist
= addr
.offset
- sym
->st_value
;
4767 *symname
= (best
->st_name
>= strtab_size
4768 ? "<corrupt>" : strtab
+ best
->st_name
);
4773 *offset
= addr
.offset
;
4777 dump_ia64_unwind (struct ia64_unw_aux_info
*aux
)
4779 struct ia64_unw_table_entry
*tp
;
4782 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
4786 const unsigned char *dp
;
4787 const unsigned char *head
;
4788 const char *procname
;
4790 find_symbol_for_address (aux
->symtab
, aux
->nsyms
, aux
->strtab
,
4791 aux
->strtab_size
, tp
->start
, &procname
, &offset
);
4793 fputs ("\n<", stdout
);
4797 fputs (procname
, stdout
);
4800 printf ("+%lx", (unsigned long) offset
);
4803 fputs (">: [", stdout
);
4804 print_vma (tp
->start
.offset
, PREFIX_HEX
);
4805 fputc ('-', stdout
);
4806 print_vma (tp
->end
.offset
, PREFIX_HEX
);
4807 printf ("], info at +0x%lx\n",
4808 (unsigned long) (tp
->info
.offset
- aux
->seg_base
));
4810 head
= aux
->info
+ (ABSADDR (tp
->info
) - aux
->info_addr
);
4811 stamp
= byte_get ((unsigned char *) head
, sizeof (stamp
));
4813 printf (" v%u, flags=0x%lx (%s%s), len=%lu bytes\n",
4814 (unsigned) UNW_VER (stamp
),
4815 (unsigned long) ((stamp
& UNW_FLAG_MASK
) >> 32),
4816 UNW_FLAG_EHANDLER (stamp
) ? " ehandler" : "",
4817 UNW_FLAG_UHANDLER (stamp
) ? " uhandler" : "",
4818 (unsigned long) (eh_addr_size
* UNW_LENGTH (stamp
)));
4820 if (UNW_VER (stamp
) != 1)
4822 printf ("\tUnknown version.\n");
4827 for (dp
= head
+ 8; dp
< head
+ 8 + eh_addr_size
* UNW_LENGTH (stamp
);)
4828 dp
= unw_decode (dp
, in_body
, & in_body
);
4833 slurp_ia64_unwind_table (FILE *file
,
4834 struct ia64_unw_aux_info
*aux
,
4835 Elf_Internal_Shdr
*sec
)
4837 unsigned long size
, nrelas
, i
;
4838 Elf_Internal_Phdr
*seg
;
4839 struct ia64_unw_table_entry
*tep
;
4840 Elf_Internal_Shdr
*relsec
;
4841 Elf_Internal_Rela
*rela
, *rp
;
4842 unsigned char *table
, *tp
;
4843 Elf_Internal_Sym
*sym
;
4844 const char *relname
;
4846 /* First, find the starting address of the segment that includes
4849 if (elf_header
.e_phnum
)
4851 if (! get_program_headers (file
))
4854 for (seg
= program_headers
;
4855 seg
< program_headers
+ elf_header
.e_phnum
;
4858 if (seg
->p_type
!= PT_LOAD
)
4861 if (sec
->sh_addr
>= seg
->p_vaddr
4862 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
4864 aux
->seg_base
= seg
->p_vaddr
;
4870 /* Second, build the unwind table from the contents of the unwind section: */
4871 size
= sec
->sh_size
;
4872 table
= get_data (NULL
, file
, sec
->sh_offset
, 1, size
, _("unwind table"));
4876 aux
->table
= xcmalloc (size
/ (3 * eh_addr_size
), sizeof (aux
->table
[0]));
4878 for (tp
= table
; tp
< table
+ size
; tp
+= 3 * eh_addr_size
, ++tep
)
4880 tep
->start
.section
= SHN_UNDEF
;
4881 tep
->end
.section
= SHN_UNDEF
;
4882 tep
->info
.section
= SHN_UNDEF
;
4885 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
4886 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
4887 tep
->info
.offset
= byte_get ((unsigned char *) tp
+ 8, 4);
4891 tep
->start
.offset
= BYTE_GET ((unsigned char *) tp
+ 0);
4892 tep
->end
.offset
= BYTE_GET ((unsigned char *) tp
+ 8);
4893 tep
->info
.offset
= BYTE_GET ((unsigned char *) tp
+ 16);
4895 tep
->start
.offset
+= aux
->seg_base
;
4896 tep
->end
.offset
+= aux
->seg_base
;
4897 tep
->info
.offset
+= aux
->seg_base
;
4901 /* Third, apply any relocations to the unwind table: */
4903 for (relsec
= section_headers
;
4904 relsec
< section_headers
+ elf_header
.e_shnum
;
4907 if (relsec
->sh_type
!= SHT_RELA
4908 || SECTION_HEADER_INDEX (relsec
->sh_info
) >= elf_header
.e_shnum
4909 || SECTION_HEADER (relsec
->sh_info
) != sec
)
4912 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
4916 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
4920 relname
= elf_ia64_reloc_type (ELF32_R_TYPE (rp
->r_info
));
4921 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
4925 relname
= elf_ia64_reloc_type (ELF64_R_TYPE (rp
->r_info
));
4926 sym
= aux
->symtab
+ ELF64_R_SYM (rp
->r_info
);
4929 if (! strneq (relname
, "R_IA64_SEGREL", 13))
4931 warn (_("Skipping unexpected relocation type %s\n"), relname
);
4935 i
= rp
->r_offset
/ (3 * eh_addr_size
);
4937 switch (rp
->r_offset
/eh_addr_size
% 3)
4940 aux
->table
[i
].start
.section
= sym
->st_shndx
;
4941 aux
->table
[i
].start
.offset
+= rp
->r_addend
+ sym
->st_value
;
4944 aux
->table
[i
].end
.section
= sym
->st_shndx
;
4945 aux
->table
[i
].end
.offset
+= rp
->r_addend
+ sym
->st_value
;
4948 aux
->table
[i
].info
.section
= sym
->st_shndx
;
4949 aux
->table
[i
].info
.offset
+= rp
->r_addend
+ sym
->st_value
;
4959 aux
->table_len
= size
/ (3 * eh_addr_size
);
4964 ia64_process_unwind (FILE *file
)
4966 Elf_Internal_Shdr
*sec
, *unwsec
= NULL
, *strsec
;
4967 unsigned long i
, unwcount
= 0, unwstart
= 0;
4968 struct ia64_unw_aux_info aux
;
4970 memset (& aux
, 0, sizeof (aux
));
4972 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
4974 if (sec
->sh_type
== SHT_SYMTAB
4975 && SECTION_HEADER_INDEX (sec
->sh_link
) < elf_header
.e_shnum
)
4977 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
4978 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
4980 strsec
= SECTION_HEADER (sec
->sh_link
);
4981 aux
.strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
4982 1, strsec
->sh_size
, _("string table"));
4983 aux
.strtab_size
= aux
.strtab
!= NULL
? strsec
->sh_size
: 0;
4985 else if (sec
->sh_type
== SHT_IA_64_UNWIND
)
4990 printf (_("\nThere are no unwind sections in this file.\n"));
4992 while (unwcount
-- > 0)
4997 for (i
= unwstart
, sec
= section_headers
+ unwstart
;
4998 i
< elf_header
.e_shnum
; ++i
, ++sec
)
4999 if (sec
->sh_type
== SHT_IA_64_UNWIND
)
5006 len
= sizeof (ELF_STRING_ia64_unwind_once
) - 1;
5008 if ((unwsec
->sh_flags
& SHF_GROUP
) != 0)
5010 /* We need to find which section group it is in. */
5011 struct group_list
*g
= section_headers_groups
[i
]->root
;
5013 for (; g
!= NULL
; g
= g
->next
)
5015 sec
= SECTION_HEADER (g
->section_index
);
5017 if (streq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info
))
5022 i
= elf_header
.e_shnum
;
5024 else if (strneq (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind_once
, len
))
5026 /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO. */
5027 len2
= sizeof (ELF_STRING_ia64_unwind_info_once
) - 1;
5028 suffix
= SECTION_NAME (unwsec
) + len
;
5029 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
5031 if (strneq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info_once
, len2
)
5032 && streq (SECTION_NAME (sec
) + len2
, suffix
))
5037 /* .IA_64.unwindFOO -> .IA_64.unwind_infoFOO
5038 .IA_64.unwind or BAR -> .IA_64.unwind_info. */
5039 len
= sizeof (ELF_STRING_ia64_unwind
) - 1;
5040 len2
= sizeof (ELF_STRING_ia64_unwind_info
) - 1;
5042 if (strneq (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind
, len
))
5043 suffix
= SECTION_NAME (unwsec
) + len
;
5044 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
5046 if (strneq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info
, len2
)
5047 && streq (SECTION_NAME (sec
) + len2
, suffix
))
5051 if (i
== elf_header
.e_shnum
)
5053 printf (_("\nCould not find unwind info section for "));
5055 if (string_table
== NULL
)
5056 printf ("%d", unwsec
->sh_name
);
5058 printf (_("'%s'"), SECTION_NAME (unwsec
));
5062 aux
.info_size
= sec
->sh_size
;
5063 aux
.info_addr
= sec
->sh_addr
;
5064 aux
.info
= get_data (NULL
, file
, sec
->sh_offset
, 1, aux
.info_size
,
5067 printf (_("\nUnwind section "));
5069 if (string_table
== NULL
)
5070 printf ("%d", unwsec
->sh_name
);
5072 printf (_("'%s'"), SECTION_NAME (unwsec
));
5074 printf (_(" at offset 0x%lx contains %lu entries:\n"),
5075 (unsigned long) unwsec
->sh_offset
,
5076 (unsigned long) (unwsec
->sh_size
/ (3 * eh_addr_size
)));
5078 (void) slurp_ia64_unwind_table (file
, & aux
, unwsec
);
5080 if (aux
.table_len
> 0)
5081 dump_ia64_unwind (& aux
);
5084 free ((char *) aux
.table
);
5086 free ((char *) aux
.info
);
5095 free ((char *) aux
.strtab
);
5100 struct hppa_unw_aux_info
5102 struct hppa_unw_table_entry
5104 struct absaddr start
;
5106 unsigned int Cannot_unwind
:1; /* 0 */
5107 unsigned int Millicode
:1; /* 1 */
5108 unsigned int Millicode_save_sr0
:1; /* 2 */
5109 unsigned int Region_description
:2; /* 3..4 */
5110 unsigned int reserved1
:1; /* 5 */
5111 unsigned int Entry_SR
:1; /* 6 */
5112 unsigned int Entry_FR
:4; /* number saved */ /* 7..10 */
5113 unsigned int Entry_GR
:5; /* number saved */ /* 11..15 */
5114 unsigned int Args_stored
:1; /* 16 */
5115 unsigned int Variable_Frame
:1; /* 17 */
5116 unsigned int Separate_Package_Body
:1; /* 18 */
5117 unsigned int Frame_Extension_Millicode
:1; /* 19 */
5118 unsigned int Stack_Overflow_Check
:1; /* 20 */
5119 unsigned int Two_Instruction_SP_Increment
:1; /* 21 */
5120 unsigned int Ada_Region
:1; /* 22 */
5121 unsigned int cxx_info
:1; /* 23 */
5122 unsigned int cxx_try_catch
:1; /* 24 */
5123 unsigned int sched_entry_seq
:1; /* 25 */
5124 unsigned int reserved2
:1; /* 26 */
5125 unsigned int Save_SP
:1; /* 27 */
5126 unsigned int Save_RP
:1; /* 28 */
5127 unsigned int Save_MRP_in_frame
:1; /* 29 */
5128 unsigned int extn_ptr_defined
:1; /* 30 */
5129 unsigned int Cleanup_defined
:1; /* 31 */
5131 unsigned int MPE_XL_interrupt_marker
:1; /* 0 */
5132 unsigned int HP_UX_interrupt_marker
:1; /* 1 */
5133 unsigned int Large_frame
:1; /* 2 */
5134 unsigned int Pseudo_SP_Set
:1; /* 3 */
5135 unsigned int reserved4
:1; /* 4 */
5136 unsigned int Total_frame_size
:27; /* 5..31 */
5138 *table
; /* Unwind table. */
5139 unsigned long table_len
; /* Length of unwind table. */
5140 bfd_vma seg_base
; /* Starting address of segment. */
5141 Elf_Internal_Sym
*symtab
; /* The symbol table. */
5142 unsigned long nsyms
; /* Number of symbols. */
5143 char *strtab
; /* The string table. */
5144 unsigned long strtab_size
; /* Size of string table. */
5148 dump_hppa_unwind (struct hppa_unw_aux_info
*aux
)
5150 struct hppa_unw_table_entry
*tp
;
5152 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
5155 const char *procname
;
5157 find_symbol_for_address (aux
->symtab
, aux
->nsyms
, aux
->strtab
,
5158 aux
->strtab_size
, tp
->start
, &procname
,
5161 fputs ("\n<", stdout
);
5165 fputs (procname
, stdout
);
5168 printf ("+%lx", (unsigned long) offset
);
5171 fputs (">: [", stdout
);
5172 print_vma (tp
->start
.offset
, PREFIX_HEX
);
5173 fputc ('-', stdout
);
5174 print_vma (tp
->end
.offset
, PREFIX_HEX
);
5177 #define PF(_m) if (tp->_m) printf (#_m " ");
5178 #define PV(_m) if (tp->_m) printf (#_m "=%d ", tp->_m);
5181 PF(Millicode_save_sr0
);
5182 /* PV(Region_description); */
5188 PF(Separate_Package_Body
);
5189 PF(Frame_Extension_Millicode
);
5190 PF(Stack_Overflow_Check
);
5191 PF(Two_Instruction_SP_Increment
);
5195 PF(sched_entry_seq
);
5198 PF(Save_MRP_in_frame
);
5199 PF(extn_ptr_defined
);
5200 PF(Cleanup_defined
);
5201 PF(MPE_XL_interrupt_marker
);
5202 PF(HP_UX_interrupt_marker
);
5205 PV(Total_frame_size
);
5214 slurp_hppa_unwind_table (FILE *file
,
5215 struct hppa_unw_aux_info
*aux
,
5216 Elf_Internal_Shdr
*sec
)
5218 unsigned long size
, unw_ent_size
, nentries
, nrelas
, i
;
5219 Elf_Internal_Phdr
*seg
;
5220 struct hppa_unw_table_entry
*tep
;
5221 Elf_Internal_Shdr
*relsec
;
5222 Elf_Internal_Rela
*rela
, *rp
;
5223 unsigned char *table
, *tp
;
5224 Elf_Internal_Sym
*sym
;
5225 const char *relname
;
5227 /* First, find the starting address of the segment that includes
5230 if (elf_header
.e_phnum
)
5232 if (! get_program_headers (file
))
5235 for (seg
= program_headers
;
5236 seg
< program_headers
+ elf_header
.e_phnum
;
5239 if (seg
->p_type
!= PT_LOAD
)
5242 if (sec
->sh_addr
>= seg
->p_vaddr
5243 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
5245 aux
->seg_base
= seg
->p_vaddr
;
5251 /* Second, build the unwind table from the contents of the unwind
5253 size
= sec
->sh_size
;
5254 table
= get_data (NULL
, file
, sec
->sh_offset
, 1, size
, _("unwind table"));
5259 nentries
= size
/ unw_ent_size
;
5260 size
= unw_ent_size
* nentries
;
5262 tep
= aux
->table
= xcmalloc (nentries
, sizeof (aux
->table
[0]));
5264 for (tp
= table
; tp
< table
+ size
; tp
+= unw_ent_size
, ++tep
)
5266 unsigned int tmp1
, tmp2
;
5268 tep
->start
.section
= SHN_UNDEF
;
5269 tep
->end
.section
= SHN_UNDEF
;
5271 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
5272 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
5273 tmp1
= byte_get ((unsigned char *) tp
+ 8, 4);
5274 tmp2
= byte_get ((unsigned char *) tp
+ 12, 4);
5276 tep
->start
.offset
+= aux
->seg_base
;
5277 tep
->end
.offset
+= aux
->seg_base
;
5279 tep
->Cannot_unwind
= (tmp1
>> 31) & 0x1;
5280 tep
->Millicode
= (tmp1
>> 30) & 0x1;
5281 tep
->Millicode_save_sr0
= (tmp1
>> 29) & 0x1;
5282 tep
->Region_description
= (tmp1
>> 27) & 0x3;
5283 tep
->reserved1
= (tmp1
>> 26) & 0x1;
5284 tep
->Entry_SR
= (tmp1
>> 25) & 0x1;
5285 tep
->Entry_FR
= (tmp1
>> 21) & 0xf;
5286 tep
->Entry_GR
= (tmp1
>> 16) & 0x1f;
5287 tep
->Args_stored
= (tmp1
>> 15) & 0x1;
5288 tep
->Variable_Frame
= (tmp1
>> 14) & 0x1;
5289 tep
->Separate_Package_Body
= (tmp1
>> 13) & 0x1;
5290 tep
->Frame_Extension_Millicode
= (tmp1
>> 12) & 0x1;
5291 tep
->Stack_Overflow_Check
= (tmp1
>> 11) & 0x1;
5292 tep
->Two_Instruction_SP_Increment
= (tmp1
>> 10) & 0x1;
5293 tep
->Ada_Region
= (tmp1
>> 9) & 0x1;
5294 tep
->cxx_info
= (tmp1
>> 8) & 0x1;
5295 tep
->cxx_try_catch
= (tmp1
>> 7) & 0x1;
5296 tep
->sched_entry_seq
= (tmp1
>> 6) & 0x1;
5297 tep
->reserved2
= (tmp1
>> 5) & 0x1;
5298 tep
->Save_SP
= (tmp1
>> 4) & 0x1;
5299 tep
->Save_RP
= (tmp1
>> 3) & 0x1;
5300 tep
->Save_MRP_in_frame
= (tmp1
>> 2) & 0x1;
5301 tep
->extn_ptr_defined
= (tmp1
>> 1) & 0x1;
5302 tep
->Cleanup_defined
= tmp1
& 0x1;
5304 tep
->MPE_XL_interrupt_marker
= (tmp2
>> 31) & 0x1;
5305 tep
->HP_UX_interrupt_marker
= (tmp2
>> 30) & 0x1;
5306 tep
->Large_frame
= (tmp2
>> 29) & 0x1;
5307 tep
->Pseudo_SP_Set
= (tmp2
>> 28) & 0x1;
5308 tep
->reserved4
= (tmp2
>> 27) & 0x1;
5309 tep
->Total_frame_size
= tmp2
& 0x7ffffff;
5313 /* Third, apply any relocations to the unwind table. */
5315 for (relsec
= section_headers
;
5316 relsec
< section_headers
+ elf_header
.e_shnum
;
5319 if (relsec
->sh_type
!= SHT_RELA
5320 || SECTION_HEADER_INDEX (relsec
->sh_info
) >= elf_header
.e_shnum
5321 || SECTION_HEADER (relsec
->sh_info
) != sec
)
5324 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
5328 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
5332 relname
= elf_hppa_reloc_type (ELF32_R_TYPE (rp
->r_info
));
5333 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
5337 relname
= elf_hppa_reloc_type (ELF64_R_TYPE (rp
->r_info
));
5338 sym
= aux
->symtab
+ ELF64_R_SYM (rp
->r_info
);
5341 /* R_PARISC_SEGREL32 or R_PARISC_SEGREL64. */
5342 if (strncmp (relname
, "R_PARISC_SEGREL", 15) != 0)
5344 warn (_("Skipping unexpected relocation type %s\n"), relname
);
5348 i
= rp
->r_offset
/ unw_ent_size
;
5350 switch ((rp
->r_offset
% unw_ent_size
) / eh_addr_size
)
5353 aux
->table
[i
].start
.section
= sym
->st_shndx
;
5354 aux
->table
[i
].start
.offset
+= sym
->st_value
+ rp
->r_addend
;
5357 aux
->table
[i
].end
.section
= sym
->st_shndx
;
5358 aux
->table
[i
].end
.offset
+= sym
->st_value
+ rp
->r_addend
;
5368 aux
->table_len
= nentries
;
5374 hppa_process_unwind (FILE *file
)
5376 struct hppa_unw_aux_info aux
;
5377 Elf_Internal_Shdr
*unwsec
= NULL
;
5378 Elf_Internal_Shdr
*strsec
;
5379 Elf_Internal_Shdr
*sec
;
5382 memset (& aux
, 0, sizeof (aux
));
5384 if (string_table
== NULL
)
5387 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5389 if (sec
->sh_type
== SHT_SYMTAB
5390 && SECTION_HEADER_INDEX (sec
->sh_link
) < elf_header
.e_shnum
)
5392 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
5393 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
5395 strsec
= SECTION_HEADER (sec
->sh_link
);
5396 aux
.strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
5397 1, strsec
->sh_size
, _("string table"));
5398 aux
.strtab_size
= aux
.strtab
!= NULL
? strsec
->sh_size
: 0;
5400 else if (streq (SECTION_NAME (sec
), ".PARISC.unwind"))
5405 printf (_("\nThere are no unwind sections in this file.\n"));
5407 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5409 if (streq (SECTION_NAME (sec
), ".PARISC.unwind"))
5411 printf (_("\nUnwind section "));
5412 printf (_("'%s'"), SECTION_NAME (sec
));
5414 printf (_(" at offset 0x%lx contains %lu entries:\n"),
5415 (unsigned long) sec
->sh_offset
,
5416 (unsigned long) (sec
->sh_size
/ (2 * eh_addr_size
+ 8)));
5418 slurp_hppa_unwind_table (file
, &aux
, sec
);
5419 if (aux
.table_len
> 0)
5420 dump_hppa_unwind (&aux
);
5423 free ((char *) aux
.table
);
5431 free ((char *) aux
.strtab
);
5437 process_unwind (FILE *file
)
5439 struct unwind_handler
{
5441 int (*handler
)(FILE *file
);
5443 { EM_IA_64
, ia64_process_unwind
},
5444 { EM_PARISC
, hppa_process_unwind
},
5452 for (i
= 0; handlers
[i
].handler
!= NULL
; i
++)
5453 if (elf_header
.e_machine
== handlers
[i
].machtype
)
5454 return handlers
[i
].handler (file
);
5456 printf (_("\nThere are no unwind sections in this file.\n"));
5461 dynamic_section_mips_val (Elf_Internal_Dyn
*entry
)
5463 switch (entry
->d_tag
)
5466 if (entry
->d_un
.d_val
== 0)
5470 static const char * opts
[] =
5472 "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT",
5473 "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS",
5474 "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD",
5475 "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF",
5480 for (cnt
= 0; cnt
< NUM_ELEM (opts
); ++cnt
)
5481 if (entry
->d_un
.d_val
& (1 << cnt
))
5483 printf ("%s%s", first
? "" : " ", opts
[cnt
]);
5490 case DT_MIPS_IVERSION
:
5491 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
5492 printf ("Interface Version: %s\n", GET_DYNAMIC_NAME (entry
->d_un
.d_val
));
5494 printf ("<corrupt: %ld>\n", (long) entry
->d_un
.d_ptr
);
5497 case DT_MIPS_TIME_STAMP
:
5502 time_t time
= entry
->d_un
.d_val
;
5503 tmp
= gmtime (&time
);
5504 snprintf (timebuf
, sizeof (timebuf
), "%04u-%02u-%02uT%02u:%02u:%02u",
5505 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
5506 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
5507 printf ("Time Stamp: %s\n", timebuf
);
5511 case DT_MIPS_RLD_VERSION
:
5512 case DT_MIPS_LOCAL_GOTNO
:
5513 case DT_MIPS_CONFLICTNO
:
5514 case DT_MIPS_LIBLISTNO
:
5515 case DT_MIPS_SYMTABNO
:
5516 case DT_MIPS_UNREFEXTNO
:
5517 case DT_MIPS_HIPAGENO
:
5518 case DT_MIPS_DELTA_CLASS_NO
:
5519 case DT_MIPS_DELTA_INSTANCE_NO
:
5520 case DT_MIPS_DELTA_RELOC_NO
:
5521 case DT_MIPS_DELTA_SYM_NO
:
5522 case DT_MIPS_DELTA_CLASSSYM_NO
:
5523 case DT_MIPS_COMPACT_SIZE
:
5524 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
5528 printf ("%#lx\n", (long) entry
->d_un
.d_ptr
);
5534 dynamic_section_parisc_val (Elf_Internal_Dyn
*entry
)
5536 switch (entry
->d_tag
)
5538 case DT_HP_DLD_FLAGS
:
5547 { DT_HP_DEBUG_PRIVATE
, "HP_DEBUG_PRIVATE" },
5548 { DT_HP_DEBUG_CALLBACK
, "HP_DEBUG_CALLBACK" },
5549 { DT_HP_DEBUG_CALLBACK_BOR
, "HP_DEBUG_CALLBACK_BOR" },
5550 { DT_HP_NO_ENVVAR
, "HP_NO_ENVVAR" },
5551 { DT_HP_BIND_NOW
, "HP_BIND_NOW" },
5552 { DT_HP_BIND_NONFATAL
, "HP_BIND_NONFATAL" },
5553 { DT_HP_BIND_VERBOSE
, "HP_BIND_VERBOSE" },
5554 { DT_HP_BIND_RESTRICTED
, "HP_BIND_RESTRICTED" },
5555 { DT_HP_BIND_SYMBOLIC
, "HP_BIND_SYMBOLIC" },
5556 { DT_HP_RPATH_FIRST
, "HP_RPATH_FIRST" },
5557 { DT_HP_BIND_DEPTH_FIRST
, "HP_BIND_DEPTH_FIRST" },
5558 { DT_HP_GST
, "HP_GST" },
5559 { DT_HP_SHLIB_FIXED
, "HP_SHLIB_FIXED" },
5560 { DT_HP_MERGE_SHLIB_SEG
, "HP_MERGE_SHLIB_SEG" },
5561 { DT_HP_NODELETE
, "HP_NODELETE" },
5562 { DT_HP_GROUP
, "HP_GROUP" },
5563 { DT_HP_PROTECT_LINKAGE_TABLE
, "HP_PROTECT_LINKAGE_TABLE" }
5567 bfd_vma val
= entry
->d_un
.d_val
;
5569 for (cnt
= 0; cnt
< sizeof (flags
) / sizeof (flags
[0]); ++cnt
)
5570 if (val
& flags
[cnt
].bit
)
5574 fputs (flags
[cnt
].str
, stdout
);
5576 val
^= flags
[cnt
].bit
;
5579 if (val
!= 0 || first
)
5583 print_vma (val
, HEX
);
5589 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5596 dynamic_section_ia64_val (Elf_Internal_Dyn
*entry
)
5598 switch (entry
->d_tag
)
5600 case DT_IA_64_PLT_RESERVE
:
5601 /* First 3 slots reserved. */
5602 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5604 print_vma (entry
->d_un
.d_ptr
+ (3 * 8), PREFIX_HEX
);
5608 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5615 get_32bit_dynamic_section (FILE *file
)
5617 Elf32_External_Dyn
*edyn
, *ext
;
5618 Elf_Internal_Dyn
*entry
;
5620 edyn
= get_data (NULL
, file
, dynamic_addr
, 1, dynamic_size
,
5621 _("dynamic section"));
5625 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
5626 might not have the luxury of section headers. Look for the DT_NULL
5627 terminator to determine the number of entries. */
5628 for (ext
= edyn
, dynamic_nent
= 0;
5629 (char *) ext
< (char *) edyn
+ dynamic_size
;
5633 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
5637 dynamic_section
= cmalloc (dynamic_nent
, sizeof (*entry
));
5638 if (dynamic_section
== NULL
)
5640 error (_("Out of memory\n"));
5645 for (ext
= edyn
, entry
= dynamic_section
;
5646 entry
< dynamic_section
+ dynamic_nent
;
5649 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
5650 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
5659 get_64bit_dynamic_section (FILE *file
)
5661 Elf64_External_Dyn
*edyn
, *ext
;
5662 Elf_Internal_Dyn
*entry
;
5664 edyn
= get_data (NULL
, file
, dynamic_addr
, 1, dynamic_size
,
5665 _("dynamic section"));
5669 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
5670 might not have the luxury of section headers. Look for the DT_NULL
5671 terminator to determine the number of entries. */
5672 for (ext
= edyn
, dynamic_nent
= 0;
5673 (char *) ext
< (char *) edyn
+ dynamic_size
;
5677 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
5681 dynamic_section
= cmalloc (dynamic_nent
, sizeof (*entry
));
5682 if (dynamic_section
== NULL
)
5684 error (_("Out of memory\n"));
5689 for (ext
= edyn
, entry
= dynamic_section
;
5690 entry
< dynamic_section
+ dynamic_nent
;
5693 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
5694 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
5703 print_dynamic_flags (bfd_vma flags
)
5711 flag
= flags
& - flags
;
5721 case DF_ORIGIN
: fputs ("ORIGIN", stdout
); break;
5722 case DF_SYMBOLIC
: fputs ("SYMBOLIC", stdout
); break;
5723 case DF_TEXTREL
: fputs ("TEXTREL", stdout
); break;
5724 case DF_BIND_NOW
: fputs ("BIND_NOW", stdout
); break;
5725 case DF_STATIC_TLS
: fputs ("STATIC_TLS", stdout
); break;
5726 default: fputs ("unknown", stdout
); break;
5732 /* Parse and display the contents of the dynamic section. */
5735 process_dynamic_section (FILE *file
)
5737 Elf_Internal_Dyn
*entry
;
5739 if (dynamic_size
== 0)
5742 printf (_("\nThere is no dynamic section in this file.\n"));
5749 if (! get_32bit_dynamic_section (file
))
5752 else if (! get_64bit_dynamic_section (file
))
5755 /* Find the appropriate symbol table. */
5756 if (dynamic_symbols
== NULL
)
5758 for (entry
= dynamic_section
;
5759 entry
< dynamic_section
+ dynamic_nent
;
5762 Elf_Internal_Shdr section
;
5764 if (entry
->d_tag
!= DT_SYMTAB
)
5767 dynamic_info
[DT_SYMTAB
] = entry
->d_un
.d_val
;
5769 /* Since we do not know how big the symbol table is,
5770 we default to reading in the entire file (!) and
5771 processing that. This is overkill, I know, but it
5773 section
.sh_offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
5775 if (archive_file_offset
!= 0)
5776 section
.sh_size
= archive_file_size
- section
.sh_offset
;
5779 if (fseek (file
, 0, SEEK_END
))
5780 error (_("Unable to seek to end of file!"));
5782 section
.sh_size
= ftell (file
) - section
.sh_offset
;
5786 section
.sh_entsize
= sizeof (Elf32_External_Sym
);
5788 section
.sh_entsize
= sizeof (Elf64_External_Sym
);
5790 num_dynamic_syms
= section
.sh_size
/ section
.sh_entsize
;
5791 if (num_dynamic_syms
< 1)
5793 error (_("Unable to determine the number of symbols to load\n"));
5797 dynamic_symbols
= GET_ELF_SYMBOLS (file
, §ion
);
5801 /* Similarly find a string table. */
5802 if (dynamic_strings
== NULL
)
5804 for (entry
= dynamic_section
;
5805 entry
< dynamic_section
+ dynamic_nent
;
5808 unsigned long offset
;
5811 if (entry
->d_tag
!= DT_STRTAB
)
5814 dynamic_info
[DT_STRTAB
] = entry
->d_un
.d_val
;
5816 /* Since we do not know how big the string table is,
5817 we default to reading in the entire file (!) and
5818 processing that. This is overkill, I know, but it
5821 offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
5823 if (archive_file_offset
!= 0)
5824 str_tab_len
= archive_file_size
- offset
;
5827 if (fseek (file
, 0, SEEK_END
))
5828 error (_("Unable to seek to end of file\n"));
5829 str_tab_len
= ftell (file
) - offset
;
5832 if (str_tab_len
< 1)
5835 (_("Unable to determine the length of the dynamic string table\n"));
5839 dynamic_strings
= get_data (NULL
, file
, offset
, 1, str_tab_len
,
5840 _("dynamic string table"));
5841 dynamic_strings_length
= str_tab_len
;
5846 /* And find the syminfo section if available. */
5847 if (dynamic_syminfo
== NULL
)
5849 unsigned long syminsz
= 0;
5851 for (entry
= dynamic_section
;
5852 entry
< dynamic_section
+ dynamic_nent
;
5855 if (entry
->d_tag
== DT_SYMINENT
)
5857 /* Note: these braces are necessary to avoid a syntax
5858 error from the SunOS4 C compiler. */
5859 assert (sizeof (Elf_External_Syminfo
) == entry
->d_un
.d_val
);
5861 else if (entry
->d_tag
== DT_SYMINSZ
)
5862 syminsz
= entry
->d_un
.d_val
;
5863 else if (entry
->d_tag
== DT_SYMINFO
)
5864 dynamic_syminfo_offset
= offset_from_vma (file
, entry
->d_un
.d_val
,
5868 if (dynamic_syminfo_offset
!= 0 && syminsz
!= 0)
5870 Elf_External_Syminfo
*extsyminfo
, *extsym
;
5871 Elf_Internal_Syminfo
*syminfo
;
5873 /* There is a syminfo section. Read the data. */
5874 extsyminfo
= get_data (NULL
, file
, dynamic_syminfo_offset
, 1,
5875 syminsz
, _("symbol information"));
5879 dynamic_syminfo
= malloc (syminsz
);
5880 if (dynamic_syminfo
== NULL
)
5882 error (_("Out of memory\n"));
5886 dynamic_syminfo_nent
= syminsz
/ sizeof (Elf_External_Syminfo
);
5887 for (syminfo
= dynamic_syminfo
, extsym
= extsyminfo
;
5888 syminfo
< dynamic_syminfo
+ dynamic_syminfo_nent
;
5889 ++syminfo
, ++extsym
)
5891 syminfo
->si_boundto
= BYTE_GET (extsym
->si_boundto
);
5892 syminfo
->si_flags
= BYTE_GET (extsym
->si_flags
);
5899 if (do_dynamic
&& dynamic_addr
)
5900 printf (_("\nDynamic section at offset 0x%lx contains %u entries:\n"),
5901 dynamic_addr
, dynamic_nent
);
5903 printf (_(" Tag Type Name/Value\n"));
5905 for (entry
= dynamic_section
;
5906 entry
< dynamic_section
+ dynamic_nent
;
5914 print_vma (entry
->d_tag
, FULL_HEX
);
5915 dtype
= get_dynamic_type (entry
->d_tag
);
5916 printf (" (%s)%*s", dtype
,
5917 ((is_32bit_elf
? 27 : 19)
5918 - (int) strlen (dtype
)),
5922 switch (entry
->d_tag
)
5926 print_dynamic_flags (entry
->d_un
.d_val
);
5936 switch (entry
->d_tag
)
5939 printf (_("Auxiliary library"));
5943 printf (_("Filter library"));
5947 printf (_("Configuration file"));
5951 printf (_("Dependency audit library"));
5955 printf (_("Audit library"));
5959 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
5960 printf (": [%s]\n", GET_DYNAMIC_NAME (entry
->d_un
.d_val
));
5964 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
5973 printf (_("Flags:"));
5975 if (entry
->d_un
.d_val
== 0)
5976 printf (_(" None\n"));
5979 unsigned long int val
= entry
->d_un
.d_val
;
5981 if (val
& DTF_1_PARINIT
)
5983 printf (" PARINIT");
5984 val
^= DTF_1_PARINIT
;
5986 if (val
& DTF_1_CONFEXP
)
5988 printf (" CONFEXP");
5989 val
^= DTF_1_CONFEXP
;
5992 printf (" %lx", val
);
6001 printf (_("Flags:"));
6003 if (entry
->d_un
.d_val
== 0)
6004 printf (_(" None\n"));
6007 unsigned long int val
= entry
->d_un
.d_val
;
6009 if (val
& DF_P1_LAZYLOAD
)
6011 printf (" LAZYLOAD");
6012 val
^= DF_P1_LAZYLOAD
;
6014 if (val
& DF_P1_GROUPPERM
)
6016 printf (" GROUPPERM");
6017 val
^= DF_P1_GROUPPERM
;
6020 printf (" %lx", val
);
6029 printf (_("Flags:"));
6030 if (entry
->d_un
.d_val
== 0)
6031 printf (_(" None\n"));
6034 unsigned long int val
= entry
->d_un
.d_val
;
6041 if (val
& DF_1_GLOBAL
)
6046 if (val
& DF_1_GROUP
)
6051 if (val
& DF_1_NODELETE
)
6053 printf (" NODELETE");
6054 val
^= DF_1_NODELETE
;
6056 if (val
& DF_1_LOADFLTR
)
6058 printf (" LOADFLTR");
6059 val
^= DF_1_LOADFLTR
;
6061 if (val
& DF_1_INITFIRST
)
6063 printf (" INITFIRST");
6064 val
^= DF_1_INITFIRST
;
6066 if (val
& DF_1_NOOPEN
)
6071 if (val
& DF_1_ORIGIN
)
6076 if (val
& DF_1_DIRECT
)
6081 if (val
& DF_1_TRANS
)
6086 if (val
& DF_1_INTERPOSE
)
6088 printf (" INTERPOSE");
6089 val
^= DF_1_INTERPOSE
;
6091 if (val
& DF_1_NODEFLIB
)
6093 printf (" NODEFLIB");
6094 val
^= DF_1_NODEFLIB
;
6096 if (val
& DF_1_NODUMP
)
6101 if (val
& DF_1_CONLFAT
)
6103 printf (" CONLFAT");
6104 val
^= DF_1_CONLFAT
;
6107 printf (" %lx", val
);
6114 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6116 puts (get_dynamic_type (entry
->d_un
.d_val
));
6136 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6142 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
6143 name
= GET_DYNAMIC_NAME (entry
->d_un
.d_val
);
6149 switch (entry
->d_tag
)
6152 printf (_("Shared library: [%s]"), name
);
6154 if (streq (name
, program_interpreter
))
6155 printf (_(" program interpreter"));
6159 printf (_("Library soname: [%s]"), name
);
6163 printf (_("Library rpath: [%s]"), name
);
6167 printf (_("Library runpath: [%s]"), name
);
6171 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6176 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6189 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6193 case DT_INIT_ARRAYSZ
:
6194 case DT_FINI_ARRAYSZ
:
6195 case DT_GNU_CONFLICTSZ
:
6196 case DT_GNU_LIBLISTSZ
:
6199 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
6200 printf (" (bytes)\n");
6210 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
6223 if (entry
->d_tag
== DT_USED
6224 && VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
6226 char *name
= GET_DYNAMIC_NAME (entry
->d_un
.d_val
);
6230 printf (_("Not needed object: [%s]\n"), name
);
6235 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6241 /* The value of this entry is ignored. */
6246 case DT_GNU_PRELINKED
:
6250 time_t time
= entry
->d_un
.d_val
;
6252 tmp
= gmtime (&time
);
6253 printf ("%04u-%02u-%02uT%02u:%02u:%02u\n",
6254 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
6255 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
6261 dynamic_info_DT_GNU_HASH
= entry
->d_un
.d_val
;
6264 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6270 if ((entry
->d_tag
>= DT_VERSYM
) && (entry
->d_tag
<= DT_VERNEEDNUM
))
6271 version_info
[DT_VERSIONTAGIDX (entry
->d_tag
)] =
6276 switch (elf_header
.e_machine
)
6279 case EM_MIPS_RS3_LE
:
6280 dynamic_section_mips_val (entry
);
6283 dynamic_section_parisc_val (entry
);
6286 dynamic_section_ia64_val (entry
);
6289 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6301 get_ver_flags (unsigned int flags
)
6303 static char buff
[32];
6310 if (flags
& VER_FLG_BASE
)
6311 strcat (buff
, "BASE ");
6313 if (flags
& VER_FLG_WEAK
)
6315 if (flags
& VER_FLG_BASE
)
6316 strcat (buff
, "| ");
6318 strcat (buff
, "WEAK ");
6321 if (flags
& ~(VER_FLG_BASE
| VER_FLG_WEAK
))
6322 strcat (buff
, "| <unknown>");
6327 /* Display the contents of the version sections. */
6329 process_version_sections (FILE *file
)
6331 Elf_Internal_Shdr
*section
;
6338 for (i
= 0, section
= section_headers
;
6339 i
< elf_header
.e_shnum
;
6342 switch (section
->sh_type
)
6344 case SHT_GNU_verdef
:
6346 Elf_External_Verdef
*edefs
;
6353 (_("\nVersion definition section '%s' contains %ld entries:\n"),
6354 SECTION_NAME (section
), section
->sh_info
);
6356 printf (_(" Addr: 0x"));
6357 printf_vma (section
->sh_addr
);
6358 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
6359 (unsigned long) section
->sh_offset
, section
->sh_link
,
6360 SECTION_HEADER_INDEX (section
->sh_link
)
6361 < elf_header
.e_shnum
6362 ? SECTION_NAME (SECTION_HEADER (section
->sh_link
))
6365 edefs
= get_data (NULL
, file
, section
->sh_offset
, 1,
6367 _("version definition section"));
6371 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
6374 Elf_External_Verdef
*edef
;
6375 Elf_Internal_Verdef ent
;
6376 Elf_External_Verdaux
*eaux
;
6377 Elf_Internal_Verdaux aux
;
6381 vstart
= ((char *) edefs
) + idx
;
6383 edef
= (Elf_External_Verdef
*) vstart
;
6385 ent
.vd_version
= BYTE_GET (edef
->vd_version
);
6386 ent
.vd_flags
= BYTE_GET (edef
->vd_flags
);
6387 ent
.vd_ndx
= BYTE_GET (edef
->vd_ndx
);
6388 ent
.vd_cnt
= BYTE_GET (edef
->vd_cnt
);
6389 ent
.vd_hash
= BYTE_GET (edef
->vd_hash
);
6390 ent
.vd_aux
= BYTE_GET (edef
->vd_aux
);
6391 ent
.vd_next
= BYTE_GET (edef
->vd_next
);
6393 printf (_(" %#06x: Rev: %d Flags: %s"),
6394 idx
, ent
.vd_version
, get_ver_flags (ent
.vd_flags
));
6396 printf (_(" Index: %d Cnt: %d "),
6397 ent
.vd_ndx
, ent
.vd_cnt
);
6399 vstart
+= ent
.vd_aux
;
6401 eaux
= (Elf_External_Verdaux
*) vstart
;
6403 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
6404 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
6406 if (VALID_DYNAMIC_NAME (aux
.vda_name
))
6407 printf (_("Name: %s\n"), GET_DYNAMIC_NAME (aux
.vda_name
));
6409 printf (_("Name index: %ld\n"), aux
.vda_name
);
6411 isum
= idx
+ ent
.vd_aux
;
6413 for (j
= 1; j
< ent
.vd_cnt
; j
++)
6415 isum
+= aux
.vda_next
;
6416 vstart
+= aux
.vda_next
;
6418 eaux
= (Elf_External_Verdaux
*) vstart
;
6420 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
6421 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
6423 if (VALID_DYNAMIC_NAME (aux
.vda_name
))
6424 printf (_(" %#06x: Parent %d: %s\n"),
6425 isum
, j
, GET_DYNAMIC_NAME (aux
.vda_name
));
6427 printf (_(" %#06x: Parent %d, name index: %ld\n"),
6428 isum
, j
, aux
.vda_name
);
6438 case SHT_GNU_verneed
:
6440 Elf_External_Verneed
*eneed
;
6446 printf (_("\nVersion needs section '%s' contains %ld entries:\n"),
6447 SECTION_NAME (section
), section
->sh_info
);
6449 printf (_(" Addr: 0x"));
6450 printf_vma (section
->sh_addr
);
6451 printf (_(" Offset: %#08lx Link to section: %ld (%s)\n"),
6452 (unsigned long) section
->sh_offset
, section
->sh_link
,
6453 SECTION_HEADER_INDEX (section
->sh_link
)
6454 < elf_header
.e_shnum
6455 ? SECTION_NAME (SECTION_HEADER (section
->sh_link
))
6458 eneed
= get_data (NULL
, file
, section
->sh_offset
, 1,
6460 _("version need section"));
6464 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
6466 Elf_External_Verneed
*entry
;
6467 Elf_Internal_Verneed ent
;
6472 vstart
= ((char *) eneed
) + idx
;
6474 entry
= (Elf_External_Verneed
*) vstart
;
6476 ent
.vn_version
= BYTE_GET (entry
->vn_version
);
6477 ent
.vn_cnt
= BYTE_GET (entry
->vn_cnt
);
6478 ent
.vn_file
= BYTE_GET (entry
->vn_file
);
6479 ent
.vn_aux
= BYTE_GET (entry
->vn_aux
);
6480 ent
.vn_next
= BYTE_GET (entry
->vn_next
);
6482 printf (_(" %#06x: Version: %d"), idx
, ent
.vn_version
);
6484 if (VALID_DYNAMIC_NAME (ent
.vn_file
))
6485 printf (_(" File: %s"), GET_DYNAMIC_NAME (ent
.vn_file
));
6487 printf (_(" File: %lx"), ent
.vn_file
);
6489 printf (_(" Cnt: %d\n"), ent
.vn_cnt
);
6491 vstart
+= ent
.vn_aux
;
6493 for (j
= 0, isum
= idx
+ ent
.vn_aux
; j
< ent
.vn_cnt
; ++j
)
6495 Elf_External_Vernaux
*eaux
;
6496 Elf_Internal_Vernaux aux
;
6498 eaux
= (Elf_External_Vernaux
*) vstart
;
6500 aux
.vna_hash
= BYTE_GET (eaux
->vna_hash
);
6501 aux
.vna_flags
= BYTE_GET (eaux
->vna_flags
);
6502 aux
.vna_other
= BYTE_GET (eaux
->vna_other
);
6503 aux
.vna_name
= BYTE_GET (eaux
->vna_name
);
6504 aux
.vna_next
= BYTE_GET (eaux
->vna_next
);
6506 if (VALID_DYNAMIC_NAME (aux
.vna_name
))
6507 printf (_(" %#06x: Name: %s"),
6508 isum
, GET_DYNAMIC_NAME (aux
.vna_name
));
6510 printf (_(" %#06x: Name index: %lx"),
6511 isum
, aux
.vna_name
);
6513 printf (_(" Flags: %s Version: %d\n"),
6514 get_ver_flags (aux
.vna_flags
), aux
.vna_other
);
6516 isum
+= aux
.vna_next
;
6517 vstart
+= aux
.vna_next
;
6527 case SHT_GNU_versym
:
6529 Elf_Internal_Shdr
*link_section
;
6532 unsigned char *edata
;
6533 unsigned short *data
;
6535 Elf_Internal_Sym
*symbols
;
6536 Elf_Internal_Shdr
*string_sec
;
6539 if (SECTION_HEADER_INDEX (section
->sh_link
) >= elf_header
.e_shnum
)
6542 link_section
= SECTION_HEADER (section
->sh_link
);
6543 total
= section
->sh_size
/ sizeof (Elf_External_Versym
);
6545 if (SECTION_HEADER_INDEX (link_section
->sh_link
)
6546 >= elf_header
.e_shnum
)
6551 symbols
= GET_ELF_SYMBOLS (file
, link_section
);
6553 string_sec
= SECTION_HEADER (link_section
->sh_link
);
6555 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
, 1,
6556 string_sec
->sh_size
, _("version string table"));
6560 printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
6561 SECTION_NAME (section
), total
);
6563 printf (_(" Addr: "));
6564 printf_vma (section
->sh_addr
);
6565 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
6566 (unsigned long) section
->sh_offset
, section
->sh_link
,
6567 SECTION_NAME (link_section
));
6569 off
= offset_from_vma (file
,
6570 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
6571 total
* sizeof (short));
6572 edata
= get_data (NULL
, file
, off
, total
, sizeof (short),
6573 _("version symbol data"));
6580 data
= cmalloc (total
, sizeof (short));
6582 for (cnt
= total
; cnt
--;)
6583 data
[cnt
] = byte_get (edata
+ cnt
* sizeof (short),
6588 for (cnt
= 0; cnt
< total
; cnt
+= 4)
6591 int check_def
, check_need
;
6594 printf (" %03x:", cnt
);
6596 for (j
= 0; (j
< 4) && (cnt
+ j
) < total
; ++j
)
6597 switch (data
[cnt
+ j
])
6600 fputs (_(" 0 (*local*) "), stdout
);
6604 fputs (_(" 1 (*global*) "), stdout
);
6608 nn
= printf ("%4x%c", data
[cnt
+ j
] & 0x7fff,
6609 data
[cnt
+ j
] & 0x8000 ? 'h' : ' ');
6613 if (SECTION_HEADER_INDEX (symbols
[cnt
+ j
].st_shndx
)
6614 >= elf_header
.e_shnum
6615 || SECTION_HEADER (symbols
[cnt
+ j
].st_shndx
)->sh_type
6618 if (symbols
[cnt
+ j
].st_shndx
== SHN_UNDEF
)
6625 && version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)])
6627 Elf_Internal_Verneed ivn
;
6628 unsigned long offset
;
6630 offset
= offset_from_vma
6631 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
6632 sizeof (Elf_External_Verneed
));
6636 Elf_Internal_Vernaux ivna
;
6637 Elf_External_Verneed evn
;
6638 Elf_External_Vernaux evna
;
6639 unsigned long a_off
;
6641 get_data (&evn
, file
, offset
, sizeof (evn
), 1,
6644 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
6645 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
6647 a_off
= offset
+ ivn
.vn_aux
;
6651 get_data (&evna
, file
, a_off
, sizeof (evna
),
6652 1, _("version need aux (2)"));
6654 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
6655 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
6657 a_off
+= ivna
.vna_next
;
6659 while (ivna
.vna_other
!= data
[cnt
+ j
]
6660 && ivna
.vna_next
!= 0);
6662 if (ivna
.vna_other
== data
[cnt
+ j
])
6664 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
6666 name
= strtab
+ ivna
.vna_name
;
6667 nn
+= printf ("(%s%-*s",
6669 12 - (int) strlen (name
),
6675 offset
+= ivn
.vn_next
;
6677 while (ivn
.vn_next
);
6680 if (check_def
&& data
[cnt
+ j
] != 0x8001
6681 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
6683 Elf_Internal_Verdef ivd
;
6684 Elf_External_Verdef evd
;
6685 unsigned long offset
;
6687 offset
= offset_from_vma
6688 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
6693 get_data (&evd
, file
, offset
, sizeof (evd
), 1,
6696 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
6697 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
6699 offset
+= ivd
.vd_next
;
6701 while (ivd
.vd_ndx
!= (data
[cnt
+ j
] & 0x7fff)
6702 && ivd
.vd_next
!= 0);
6704 if (ivd
.vd_ndx
== (data
[cnt
+ j
] & 0x7fff))
6706 Elf_External_Verdaux evda
;
6707 Elf_Internal_Verdaux ivda
;
6709 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
6711 get_data (&evda
, file
,
6712 offset
- ivd
.vd_next
+ ivd
.vd_aux
,
6714 _("version def aux"));
6716 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
6718 name
= strtab
+ ivda
.vda_name
;
6719 nn
+= printf ("(%s%-*s",
6721 12 - (int) strlen (name
),
6727 printf ("%*c", 18 - nn
, ' ');
6745 printf (_("\nNo version information found in this file.\n"));
6751 get_symbol_binding (unsigned int binding
)
6753 static char buff
[32];
6757 case STB_LOCAL
: return "LOCAL";
6758 case STB_GLOBAL
: return "GLOBAL";
6759 case STB_WEAK
: return "WEAK";
6761 if (binding
>= STB_LOPROC
&& binding
<= STB_HIPROC
)
6762 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"),
6764 else if (binding
>= STB_LOOS
&& binding
<= STB_HIOS
)
6765 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), binding
);
6767 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), binding
);
6773 get_symbol_type (unsigned int type
)
6775 static char buff
[32];
6779 case STT_NOTYPE
: return "NOTYPE";
6780 case STT_OBJECT
: return "OBJECT";
6781 case STT_FUNC
: return "FUNC";
6782 case STT_SECTION
: return "SECTION";
6783 case STT_FILE
: return "FILE";
6784 case STT_COMMON
: return "COMMON";
6785 case STT_TLS
: return "TLS";
6787 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
6789 if (elf_header
.e_machine
== EM_ARM
&& type
== STT_ARM_TFUNC
)
6790 return "THUMB_FUNC";
6792 if (elf_header
.e_machine
== EM_SPARCV9
&& type
== STT_REGISTER
)
6795 if (elf_header
.e_machine
== EM_PARISC
&& type
== STT_PARISC_MILLI
)
6796 return "PARISC_MILLI";
6798 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"), type
);
6800 else if (type
>= STT_LOOS
&& type
<= STT_HIOS
)
6802 if (elf_header
.e_machine
== EM_PARISC
)
6804 if (type
== STT_HP_OPAQUE
)
6806 if (type
== STT_HP_STUB
)
6810 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), type
);
6813 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), type
);
6819 get_symbol_visibility (unsigned int visibility
)
6823 case STV_DEFAULT
: return "DEFAULT";
6824 case STV_INTERNAL
: return "INTERNAL";
6825 case STV_HIDDEN
: return "HIDDEN";
6826 case STV_PROTECTED
: return "PROTECTED";
6832 get_mips_symbol_other (unsigned int other
)
6836 case STO_OPTIONAL
: return "OPTIONAL";
6837 case STO_MIPS16
: return "MIPS16";
6838 default: return NULL
;
6843 get_symbol_other (unsigned int other
)
6845 const char * result
= NULL
;
6846 static char buff
[32];
6851 switch (elf_header
.e_machine
)
6854 result
= get_mips_symbol_other (other
);
6862 snprintf (buff
, sizeof buff
, _("<other>: %x"), other
);
6867 get_symbol_index_type (unsigned int type
)
6869 static char buff
[32];
6873 case SHN_UNDEF
: return "UND";
6874 case SHN_ABS
: return "ABS";
6875 case SHN_COMMON
: return "COM";
6877 if (type
== SHN_IA_64_ANSI_COMMON
6878 && elf_header
.e_machine
== EM_IA_64
6879 && elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
)
6881 else if (elf_header
.e_machine
== EM_X86_64
6882 && type
== SHN_X86_64_LCOMMON
)
6884 else if (type
== SHN_MIPS_SCOMMON
6885 && elf_header
.e_machine
== EM_MIPS
)
6887 else if (type
== SHN_MIPS_SUNDEFINED
6888 && elf_header
.e_machine
== EM_MIPS
)
6890 else if (type
>= SHN_LOPROC
&& type
<= SHN_HIPROC
)
6891 sprintf (buff
, "PRC[0x%04x]", type
);
6892 else if (type
>= SHN_LOOS
&& type
<= SHN_HIOS
)
6893 sprintf (buff
, "OS [0x%04x]", type
);
6894 else if (type
>= SHN_LORESERVE
&& type
<= SHN_HIRESERVE
)
6895 sprintf (buff
, "RSV[0x%04x]", type
);
6897 sprintf (buff
, "%3d", type
);
6905 get_dynamic_data (FILE *file
, unsigned int number
, unsigned int ent_size
)
6907 unsigned char *e_data
;
6910 e_data
= cmalloc (number
, ent_size
);
6914 error (_("Out of memory\n"));
6918 if (fread (e_data
, ent_size
, number
, file
) != number
)
6920 error (_("Unable to read in dynamic data\n"));
6924 i_data
= cmalloc (number
, sizeof (*i_data
));
6928 error (_("Out of memory\n"));
6934 i_data
[number
] = byte_get (e_data
+ number
* ent_size
, ent_size
);
6941 /* Dump the symbol table. */
6943 process_symbol_table (FILE *file
)
6945 Elf_Internal_Shdr
*section
;
6946 bfd_vma nbuckets
= 0;
6947 bfd_vma nchains
= 0;
6948 bfd_vma
*buckets
= NULL
;
6949 bfd_vma
*chains
= NULL
;
6950 bfd_vma ngnubuckets
= 0;
6951 bfd_vma
*gnubuckets
= NULL
;
6952 bfd_vma
*gnuchains
= NULL
;
6954 if (! do_syms
&& !do_histogram
)
6957 if (dynamic_info
[DT_HASH
] && ((do_using_dynamic
&& dynamic_strings
!= NULL
)
6960 unsigned char nb
[8];
6961 unsigned char nc
[8];
6962 int hash_ent_size
= 4;
6964 if ((elf_header
.e_machine
== EM_ALPHA
6965 || elf_header
.e_machine
== EM_S390
6966 || elf_header
.e_machine
== EM_S390_OLD
)
6967 && elf_header
.e_ident
[EI_CLASS
] == ELFCLASS64
)
6971 (archive_file_offset
6972 + offset_from_vma (file
, dynamic_info
[DT_HASH
],
6973 sizeof nb
+ sizeof nc
)),
6976 error (_("Unable to seek to start of dynamic information"));
6980 if (fread (nb
, hash_ent_size
, 1, file
) != 1)
6982 error (_("Failed to read in number of buckets\n"));
6986 if (fread (nc
, hash_ent_size
, 1, file
) != 1)
6988 error (_("Failed to read in number of chains\n"));
6992 nbuckets
= byte_get (nb
, hash_ent_size
);
6993 nchains
= byte_get (nc
, hash_ent_size
);
6995 buckets
= get_dynamic_data (file
, nbuckets
, hash_ent_size
);
6996 chains
= get_dynamic_data (file
, nchains
, hash_ent_size
);
6998 if (buckets
== NULL
|| chains
== NULL
)
7003 && dynamic_info
[DT_HASH
] && do_using_dynamic
&& dynamic_strings
!= NULL
)
7008 printf (_("\nSymbol table for image:\n"));
7010 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7012 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7014 for (hn
= 0; hn
< nbuckets
; hn
++)
7019 for (si
= buckets
[hn
]; si
< nchains
&& si
> 0; si
= chains
[si
])
7021 Elf_Internal_Sym
*psym
;
7024 psym
= dynamic_symbols
+ si
;
7026 n
= print_vma (si
, DEC_5
);
7028 fputs (" " + n
, stdout
);
7029 printf (" %3lu: ", hn
);
7030 print_vma (psym
->st_value
, LONG_HEX
);
7032 print_vma (psym
->st_size
, DEC_5
);
7034 printf (" %6s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
7035 printf (" %6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
7036 printf (" %3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
7037 /* Check to see if any other bits in the st_other field are set.
7038 Note - displaying this information disrupts the layout of the
7039 table being generated, but for the moment this case is very rare. */
7040 if (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
))
7041 printf (" [%s] ", get_symbol_other (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
)));
7042 printf (" %3.3s ", get_symbol_index_type (psym
->st_shndx
));
7043 if (VALID_DYNAMIC_NAME (psym
->st_name
))
7044 print_symbol (25, GET_DYNAMIC_NAME (psym
->st_name
));
7046 printf (" <corrupt: %14ld>", psym
->st_name
);
7051 else if (do_syms
&& !do_using_dynamic
)
7055 for (i
= 0, section
= section_headers
;
7056 i
< elf_header
.e_shnum
;
7060 char *strtab
= NULL
;
7061 unsigned long int strtab_size
= 0;
7062 Elf_Internal_Sym
*symtab
;
7063 Elf_Internal_Sym
*psym
;
7066 if ( section
->sh_type
!= SHT_SYMTAB
7067 && section
->sh_type
!= SHT_DYNSYM
)
7070 printf (_("\nSymbol table '%s' contains %lu entries:\n"),
7071 SECTION_NAME (section
),
7072 (unsigned long) (section
->sh_size
/ section
->sh_entsize
));
7074 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
7076 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
7078 symtab
= GET_ELF_SYMBOLS (file
, section
);
7082 if (section
->sh_link
== elf_header
.e_shstrndx
)
7084 strtab
= string_table
;
7085 strtab_size
= string_table_length
;
7087 else if (SECTION_HEADER_INDEX (section
->sh_link
) < elf_header
.e_shnum
)
7089 Elf_Internal_Shdr
*string_sec
;
7091 string_sec
= SECTION_HEADER (section
->sh_link
);
7093 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
,
7094 1, string_sec
->sh_size
, _("string table"));
7095 strtab_size
= strtab
!= NULL
? string_sec
->sh_size
: 0;
7098 for (si
= 0, psym
= symtab
;
7099 si
< section
->sh_size
/ section
->sh_entsize
;
7102 printf ("%6d: ", si
);
7103 print_vma (psym
->st_value
, LONG_HEX
);
7105 print_vma (psym
->st_size
, DEC_5
);
7106 printf (" %-7s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
7107 printf (" %-6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
7108 printf (" %-3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
7109 /* Check to see if any other bits in the st_other field are set.
7110 Note - displaying this information disrupts the layout of the
7111 table being generated, but for the moment this case is very rare. */
7112 if (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
))
7113 printf (" [%s] ", get_symbol_other (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
)));
7114 printf (" %4s ", get_symbol_index_type (psym
->st_shndx
));
7115 print_symbol (25, psym
->st_name
< strtab_size
7116 ? strtab
+ psym
->st_name
: "<corrupt>");
7118 if (section
->sh_type
== SHT_DYNSYM
&&
7119 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] != 0)
7121 unsigned char data
[2];
7122 unsigned short vers_data
;
7123 unsigned long offset
;
7127 offset
= offset_from_vma
7128 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
7129 sizeof data
+ si
* sizeof (vers_data
));
7131 get_data (&data
, file
, offset
+ si
* sizeof (vers_data
),
7132 sizeof (data
), 1, _("version data"));
7134 vers_data
= byte_get (data
, 2);
7136 is_nobits
= (SECTION_HEADER_INDEX (psym
->st_shndx
)
7137 < elf_header
.e_shnum
7138 && SECTION_HEADER (psym
->st_shndx
)->sh_type
7141 check_def
= (psym
->st_shndx
!= SHN_UNDEF
);
7143 if ((vers_data
& 0x8000) || vers_data
> 1)
7145 if (version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
7146 && (is_nobits
|| ! check_def
))
7148 Elf_External_Verneed evn
;
7149 Elf_Internal_Verneed ivn
;
7150 Elf_Internal_Vernaux ivna
;
7152 /* We must test both. */
7153 offset
= offset_from_vma
7154 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
7159 unsigned long vna_off
;
7161 get_data (&evn
, file
, offset
, sizeof (evn
), 1,
7164 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
7165 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
7167 vna_off
= offset
+ ivn
.vn_aux
;
7171 Elf_External_Vernaux evna
;
7173 get_data (&evna
, file
, vna_off
,
7175 _("version need aux (3)"));
7177 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
7178 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
7179 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
7181 vna_off
+= ivna
.vna_next
;
7183 while (ivna
.vna_other
!= vers_data
7184 && ivna
.vna_next
!= 0);
7186 if (ivna
.vna_other
== vers_data
)
7189 offset
+= ivn
.vn_next
;
7191 while (ivn
.vn_next
!= 0);
7193 if (ivna
.vna_other
== vers_data
)
7196 ivna
.vna_name
< strtab_size
7197 ? strtab
+ ivna
.vna_name
: "<corrupt>",
7201 else if (! is_nobits
)
7202 error (_("bad dynamic symbol"));
7209 if (vers_data
!= 0x8001
7210 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
7212 Elf_Internal_Verdef ivd
;
7213 Elf_Internal_Verdaux ivda
;
7214 Elf_External_Verdaux evda
;
7215 unsigned long offset
;
7217 offset
= offset_from_vma
7219 version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
7220 sizeof (Elf_External_Verdef
));
7224 Elf_External_Verdef evd
;
7226 get_data (&evd
, file
, offset
, sizeof (evd
),
7227 1, _("version def"));
7229 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
7230 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
7231 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
7233 offset
+= ivd
.vd_next
;
7235 while (ivd
.vd_ndx
!= (vers_data
& 0x7fff)
7236 && ivd
.vd_next
!= 0);
7238 offset
-= ivd
.vd_next
;
7239 offset
+= ivd
.vd_aux
;
7241 get_data (&evda
, file
, offset
, sizeof (evda
),
7242 1, _("version def aux"));
7244 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
7246 if (psym
->st_name
!= ivda
.vda_name
)
7247 printf ((vers_data
& 0x8000)
7249 ivda
.vda_name
< strtab_size
7250 ? strtab
+ ivda
.vda_name
: "<corrupt>");
7260 if (strtab
!= string_table
)
7266 (_("\nDynamic symbol information is not available for displaying symbols.\n"));
7268 if (do_histogram
&& buckets
!= NULL
)
7270 unsigned long *lengths
;
7271 unsigned long *counts
;
7274 unsigned long maxlength
= 0;
7275 unsigned long nzero_counts
= 0;
7276 unsigned long nsyms
= 0;
7278 printf (_("\nHistogram for bucket list length (total of %lu buckets):\n"),
7279 (unsigned long) nbuckets
);
7280 printf (_(" Length Number %% of total Coverage\n"));
7282 lengths
= calloc (nbuckets
, sizeof (*lengths
));
7283 if (lengths
== NULL
)
7285 error (_("Out of memory"));
7288 for (hn
= 0; hn
< nbuckets
; ++hn
)
7290 for (si
= buckets
[hn
]; si
> 0 && si
< nchains
; si
= chains
[si
])
7293 if (maxlength
< ++lengths
[hn
])
7298 counts
= calloc (maxlength
+ 1, sizeof (*counts
));
7301 error (_("Out of memory"));
7305 for (hn
= 0; hn
< nbuckets
; ++hn
)
7306 ++counts
[lengths
[hn
]];
7311 printf (" 0 %-10lu (%5.1f%%)\n",
7312 counts
[0], (counts
[0] * 100.0) / nbuckets
);
7313 for (i
= 1; i
<= maxlength
; ++i
)
7315 nzero_counts
+= counts
[i
] * i
;
7316 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
7317 i
, counts
[i
], (counts
[i
] * 100.0) / nbuckets
,
7318 (nzero_counts
* 100.0) / nsyms
);
7326 if (buckets
!= NULL
)
7332 if (do_histogram
&& dynamic_info_DT_GNU_HASH
)
7334 unsigned char nb
[16];
7335 bfd_vma i
, maxchain
= 0xffffffff, symidx
, bitmaskwords
;
7336 unsigned long *lengths
;
7337 unsigned long *counts
;
7339 unsigned long maxlength
= 0;
7340 unsigned long nzero_counts
= 0;
7341 unsigned long nsyms
= 0;
7342 bfd_vma buckets_vma
;
7345 (archive_file_offset
7346 + offset_from_vma (file
, dynamic_info_DT_GNU_HASH
,
7350 error (_("Unable to seek to start of dynamic information"));
7354 if (fread (nb
, 16, 1, file
) != 1)
7356 error (_("Failed to read in number of buckets\n"));
7360 ngnubuckets
= byte_get (nb
, 4);
7361 symidx
= byte_get (nb
+ 4, 4);
7362 bitmaskwords
= byte_get (nb
+ 8, 4);
7363 buckets_vma
= dynamic_info_DT_GNU_HASH
+ 16;
7365 buckets_vma
+= bitmaskwords
* 4;
7367 buckets_vma
+= bitmaskwords
* 8;
7370 (archive_file_offset
7371 + offset_from_vma (file
, buckets_vma
, 4)),
7374 error (_("Unable to seek to start of dynamic information"));
7378 gnubuckets
= get_dynamic_data (file
, ngnubuckets
, 4);
7380 if (gnubuckets
== NULL
)
7383 for (i
= 0; i
< ngnubuckets
; i
++)
7384 if (gnubuckets
[i
] != 0)
7386 if (gnubuckets
[i
] < symidx
)
7389 if (maxchain
== 0xffffffff || gnubuckets
[i
] > maxchain
)
7390 maxchain
= gnubuckets
[i
];
7393 if (maxchain
== 0xffffffff)
7399 (archive_file_offset
7400 + offset_from_vma (file
, buckets_vma
7401 + 4 * (ngnubuckets
+ maxchain
), 4)),
7404 error (_("Unable to seek to start of dynamic information"));
7410 if (fread (nb
, 4, 1, file
) != 1)
7412 error (_("Failed to determine last chain length\n"));
7416 if (maxchain
+ 1 == 0)
7421 while ((byte_get (nb
, 4) & 1) == 0);
7424 (archive_file_offset
7425 + offset_from_vma (file
, buckets_vma
+ 4 * ngnubuckets
, 4)),
7428 error (_("Unable to seek to start of dynamic information"));
7432 gnuchains
= get_dynamic_data (file
, maxchain
, 4);
7434 if (gnuchains
== NULL
)
7437 lengths
= calloc (ngnubuckets
, sizeof (*lengths
));
7438 if (lengths
== NULL
)
7440 error (_("Out of memory"));
7444 printf (_("\nHistogram for `.gnu.hash' bucket list length (total of %lu buckets):\n"),
7445 (unsigned long) ngnubuckets
);
7446 printf (_(" Length Number %% of total Coverage\n"));
7448 for (hn
= 0; hn
< ngnubuckets
; ++hn
)
7449 if (gnubuckets
[hn
] != 0)
7451 bfd_vma off
, length
= 1;
7453 for (off
= gnubuckets
[hn
] - symidx
;
7454 (gnuchains
[off
] & 1) == 0; ++off
)
7456 lengths
[hn
] = length
;
7457 if (length
> maxlength
)
7462 counts
= calloc (maxlength
+ 1, sizeof (*counts
));
7465 error (_("Out of memory"));
7469 for (hn
= 0; hn
< ngnubuckets
; ++hn
)
7470 ++counts
[lengths
[hn
]];
7472 if (ngnubuckets
> 0)
7475 printf (" 0 %-10lu (%5.1f%%)\n",
7476 counts
[0], (counts
[0] * 100.0) / ngnubuckets
);
7477 for (j
= 1; j
<= maxlength
; ++j
)
7479 nzero_counts
+= counts
[j
] * j
;
7480 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
7481 j
, counts
[j
], (counts
[j
] * 100.0) / ngnubuckets
,
7482 (nzero_counts
* 100.0) / nsyms
);
7496 process_syminfo (FILE *file ATTRIBUTE_UNUSED
)
7500 if (dynamic_syminfo
== NULL
7502 /* No syminfo, this is ok. */
7505 /* There better should be a dynamic symbol section. */
7506 if (dynamic_symbols
== NULL
|| dynamic_strings
== NULL
)
7510 printf (_("\nDynamic info segment at offset 0x%lx contains %d entries:\n"),
7511 dynamic_syminfo_offset
, dynamic_syminfo_nent
);
7513 printf (_(" Num: Name BoundTo Flags\n"));
7514 for (i
= 0; i
< dynamic_syminfo_nent
; ++i
)
7516 unsigned short int flags
= dynamic_syminfo
[i
].si_flags
;
7518 printf ("%4d: ", i
);
7519 if (VALID_DYNAMIC_NAME (dynamic_symbols
[i
].st_name
))
7520 print_symbol (30, GET_DYNAMIC_NAME (dynamic_symbols
[i
].st_name
));
7522 printf ("<corrupt: %19ld>", dynamic_symbols
[i
].st_name
);
7525 switch (dynamic_syminfo
[i
].si_boundto
)
7527 case SYMINFO_BT_SELF
:
7528 fputs ("SELF ", stdout
);
7530 case SYMINFO_BT_PARENT
:
7531 fputs ("PARENT ", stdout
);
7534 if (dynamic_syminfo
[i
].si_boundto
> 0
7535 && dynamic_syminfo
[i
].si_boundto
< dynamic_nent
7536 && VALID_DYNAMIC_NAME (dynamic_section
[dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
))
7538 print_symbol (10, GET_DYNAMIC_NAME (dynamic_section
[dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
));
7542 printf ("%-10d ", dynamic_syminfo
[i
].si_boundto
);
7546 if (flags
& SYMINFO_FLG_DIRECT
)
7548 if (flags
& SYMINFO_FLG_PASSTHRU
)
7549 printf (" PASSTHRU");
7550 if (flags
& SYMINFO_FLG_COPY
)
7552 if (flags
& SYMINFO_FLG_LAZYLOAD
)
7553 printf (" LAZYLOAD");
7561 #ifdef SUPPORT_DISASSEMBLY
7563 disassemble_section (Elf_Internal_Shdr
*section
, FILE *file
)
7565 printf (_("\nAssembly dump of section %s\n"),
7566 SECTION_NAME (section
));
7568 /* XXX -- to be done --- XXX */
7575 dump_section (Elf_Internal_Shdr
*section
, FILE *file
)
7577 bfd_size_type bytes
;
7579 unsigned char *data
;
7580 unsigned char *start
;
7582 bytes
= section
->sh_size
;
7584 if (bytes
== 0 || section
->sh_type
== SHT_NOBITS
)
7586 printf (_("\nSection '%s' has no data to dump.\n"),
7587 SECTION_NAME (section
));
7591 printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section
));
7593 addr
= section
->sh_addr
;
7595 start
= get_data (NULL
, file
, section
->sh_offset
, 1, bytes
,
7608 lbytes
= (bytes
> 16 ? 16 : bytes
);
7610 printf (" 0x%8.8lx ", (unsigned long) addr
);
7612 switch (elf_header
.e_ident
[EI_DATA
])
7616 for (j
= 15; j
>= 0; j
--)
7619 printf ("%2.2x", data
[j
]);
7629 for (j
= 0; j
< 16; j
++)
7632 printf ("%2.2x", data
[j
]);
7642 for (j
= 0; j
< lbytes
; j
++)
7645 if (k
>= ' ' && k
< 0x7f)
7663 /* Apply addends of RELA relocations. */
7666 debug_apply_rela_addends (void *file
,
7667 Elf_Internal_Shdr
*section
,
7668 unsigned char *start
)
7670 Elf_Internal_Shdr
*relsec
;
7671 unsigned char *end
= start
+ section
->sh_size
;
7672 /* FIXME: The relocation field size is relocation type dependent. */
7673 unsigned int reloc_size
= 4;
7675 if (!is_relocatable
)
7678 if (section
->sh_size
< reloc_size
)
7681 for (relsec
= section_headers
;
7682 relsec
< section_headers
+ elf_header
.e_shnum
;
7685 unsigned long nrelas
;
7686 Elf_Internal_Rela
*rela
, *rp
;
7687 Elf_Internal_Shdr
*symsec
;
7688 Elf_Internal_Sym
*symtab
;
7689 Elf_Internal_Sym
*sym
;
7691 if (relsec
->sh_type
!= SHT_RELA
7692 || SECTION_HEADER_INDEX (relsec
->sh_info
) >= elf_header
.e_shnum
7693 || SECTION_HEADER (relsec
->sh_info
) != section
7694 || relsec
->sh_size
== 0
7695 || SECTION_HEADER_INDEX (relsec
->sh_link
) >= elf_header
.e_shnum
)
7698 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
7702 symsec
= SECTION_HEADER (relsec
->sh_link
);
7703 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
7705 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
7709 loc
= start
+ rp
->r_offset
;
7710 if ((loc
+ reloc_size
) > end
)
7712 warn (_("skipping invalid relocation offset 0x%lx in section %s\n"),
7713 (unsigned long) rp
->r_offset
,
7714 SECTION_NAME (section
));
7720 sym
= symtab
+ ELF32_R_SYM (rp
->r_info
);
7722 if (ELF32_R_SYM (rp
->r_info
) != 0
7723 && ELF32_ST_TYPE (sym
->st_info
) != STT_SECTION
7724 /* Relocations against object symbols can happen,
7725 eg when referencing a global array. For an
7726 example of this see the _clz.o binary in libgcc.a. */
7727 && ELF32_ST_TYPE (sym
->st_info
) != STT_OBJECT
)
7729 warn (_("skipping unexpected symbol type %s in relocation in section .rela%s\n"),
7730 get_symbol_type (ELF32_ST_TYPE (sym
->st_info
)),
7731 SECTION_NAME (section
));
7737 /* In MIPS little-endian objects, r_info isn't really a
7738 64-bit little-endian value: it has a 32-bit little-endian
7739 symbol index followed by four individual byte fields.
7740 Reorder INFO accordingly. */
7741 if (elf_header
.e_machine
== EM_MIPS
7742 && elf_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
7743 rp
->r_info
= (((rp
->r_info
& 0xffffffff) << 32)
7744 | ((rp
->r_info
>> 56) & 0xff)
7745 | ((rp
->r_info
>> 40) & 0xff00)
7746 | ((rp
->r_info
>> 24) & 0xff0000)
7747 | ((rp
->r_info
>> 8) & 0xff000000));
7749 sym
= symtab
+ ELF64_R_SYM (rp
->r_info
);
7751 if (ELF64_R_SYM (rp
->r_info
) != 0
7752 && ELF64_ST_TYPE (sym
->st_info
) != STT_SECTION
7753 && ELF64_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 (ELF64_ST_TYPE (sym
->st_info
)),
7757 SECTION_NAME (section
));
7762 byte_put (loc
, rp
->r_addend
, reloc_size
);
7773 load_debug_section (enum dwarf_section_display_enum debug
, void *file
)
7775 struct dwarf_section
*section
= &debug_displays
[debug
].section
;
7776 Elf_Internal_Shdr
*sec
;
7779 /* If it is already loaded, do nothing. */
7780 if (section
->start
!= NULL
)
7783 /* Locate the debug section. */
7784 sec
= find_section (section
->name
);
7788 snprintf (buf
, sizeof (buf
), _("%s section data"), section
->name
);
7789 section
->address
= sec
->sh_addr
;
7790 section
->size
= sec
->sh_size
;
7791 section
->start
= get_data (NULL
, file
, sec
->sh_offset
, 1,
7794 if (debug_displays
[debug
].relocate
)
7795 debug_apply_rela_addends (file
, sec
, section
->start
);
7797 return section
->start
!= NULL
;
7801 free_debug_section (enum dwarf_section_display_enum debug
)
7803 struct dwarf_section
*section
= &debug_displays
[debug
].section
;
7805 if (section
->start
== NULL
)
7808 free ((char *) section
->start
);
7809 section
->start
= NULL
;
7810 section
->address
= 0;
7815 display_debug_section (Elf_Internal_Shdr
*section
, FILE *file
)
7817 char *name
= SECTION_NAME (section
);
7818 bfd_size_type length
;
7820 enum dwarf_section_display_enum i
;
7822 length
= section
->sh_size
;
7825 printf (_("\nSection '%s' has no debugging data.\n"), name
);
7829 if (strneq (name
, ".gnu.linkonce.wi.", 17))
7830 name
= ".debug_info";
7832 /* See if we know how to display the contents of this section. */
7833 for (i
= 0; i
< max
; i
++)
7834 if (streq (debug_displays
[i
].section
.name
, name
))
7836 struct dwarf_section
*sec
= &debug_displays
[i
].section
;
7838 if (load_debug_section (i
, file
))
7840 result
&= debug_displays
[i
].display (sec
, file
);
7842 if (i
!= info
&& i
!= abbrev
)
7843 free_debug_section (i
);
7851 printf (_("Unrecognized debug section: %s\n"), name
);
7858 /* Set DUMP_SECTS for all sections where dumps were requested
7859 based on section name. */
7862 initialise_dumps_byname (void)
7864 struct dump_list_entry
*cur
;
7866 for (cur
= dump_sects_byname
; cur
; cur
= cur
->next
)
7871 for (i
= 0, any
= 0; i
< elf_header
.e_shnum
; i
++)
7872 if (streq (SECTION_NAME (section_headers
+ i
), cur
->name
))
7874 request_dump (i
, cur
->type
);
7879 warn (_("Section '%s' was not dumped because it does not exist!\n"),
7885 process_section_contents (FILE *file
)
7887 Elf_Internal_Shdr
*section
;
7893 initialise_dumps_byname ();
7895 for (i
= 0, section
= section_headers
;
7896 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
7899 #ifdef SUPPORT_DISASSEMBLY
7900 if (dump_sects
[i
] & DISASS_DUMP
)
7901 disassemble_section (section
, file
);
7903 if (dump_sects
[i
] & HEX_DUMP
)
7904 dump_section (section
, file
);
7906 if (dump_sects
[i
] & DEBUG_DUMP
)
7907 display_debug_section (section
, file
);
7910 /* Check to see if the user requested a
7911 dump of a section that does not exist. */
7912 while (i
++ < num_dump_sects
)
7914 warn (_("Section %d was not dumped because it does not exist!\n"), i
);
7918 process_mips_fpe_exception (int mask
)
7923 if (mask
& OEX_FPU_INEX
)
7924 fputs ("INEX", stdout
), first
= 0;
7925 if (mask
& OEX_FPU_UFLO
)
7926 printf ("%sUFLO", first
? "" : "|"), first
= 0;
7927 if (mask
& OEX_FPU_OFLO
)
7928 printf ("%sOFLO", first
? "" : "|"), first
= 0;
7929 if (mask
& OEX_FPU_DIV0
)
7930 printf ("%sDIV0", first
? "" : "|"), first
= 0;
7931 if (mask
& OEX_FPU_INVAL
)
7932 printf ("%sINVAL", first
? "" : "|");
7935 fputs ("0", stdout
);
7938 /* ARM EABI attributes section. */
7943 /* 0 = special, 1 = string, 2 = uleb123, > 0x80 == table lookup. */
7946 } arm_attr_public_tag
;
7948 static const char *arm_attr_tag_CPU_arch
[] =
7949 {"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2",
7951 static const char *arm_attr_tag_ARM_ISA_use
[] = {"No", "Yes"};
7952 static const char *arm_attr_tag_THUMB_ISA_use
[] =
7953 {"No", "Thumb-1", "Thumb-2"};
7954 /* FIXME: VFPv3 encoding was extrapolated! */
7955 static const char *arm_attr_tag_VFP_arch
[] = {"No", "VFPv1", "VFPv2", "VFPv3"};
7956 static const char *arm_attr_tag_WMMX_arch
[] = {"No", "WMMXv1"};
7957 static const char *arm_attr_tag_NEON_arch
[] = {"No", "NEONv1"};
7958 static const char *arm_attr_tag_ABI_PCS_config
[] =
7959 {"None", "Bare platform", "Linux application", "Linux DSO", "PalmOS 2004",
7960 "PalmOS (reserved)", "SymbianOS 2004", "SymbianOS (reserved)"};
7961 static const char *arm_attr_tag_ABI_PCS_R9_use
[] =
7962 {"V6", "SB", "TLS", "Unused"};
7963 static const char *arm_attr_tag_ABI_PCS_RW_data
[] =
7964 {"Absolute", "PC-relative", "SB-relative", "None"};
7965 static const char *arm_attr_tag_ABI_PCS_RO_DATA
[] =
7966 {"Absolute", "PC-relative", "None"};
7967 static const char *arm_attr_tag_ABI_PCS_GOT_use
[] =
7968 {"None", "direct", "GOT-indirect"};
7969 static const char *arm_attr_tag_ABI_PCS_wchar_t
[] =
7970 {"None", "??? 1", "2", "??? 3", "4"};
7971 static const char *arm_attr_tag_ABI_FP_rounding
[] = {"Unused", "Needed"};
7972 static const char *arm_attr_tag_ABI_FP_denormal
[] = {"Unused", "Needed"};
7973 static const char *arm_attr_tag_ABI_FP_exceptions
[] = {"Unused", "Needed"};
7974 static const char *arm_attr_tag_ABI_FP_user_exceptions
[] = {"Unused", "Needed"};
7975 static const char *arm_attr_tag_ABI_FP_number_model
[] =
7976 {"Unused", "Finite", "RTABI", "IEEE 754"};
7977 static const char *arm_attr_tag_ABI_align8_needed
[] = {"No", "Yes", "4-byte"};
7978 static const char *arm_attr_tag_ABI_align8_preserved
[] =
7979 {"No", "Yes, except leaf SP", "Yes"};
7980 static const char *arm_attr_tag_ABI_enum_size
[] =
7981 {"Unused", "small", "int", "forced to int"};
7982 static const char *arm_attr_tag_ABI_HardFP_use
[] =
7983 {"As Tag_VFP_arch", "SP only", "DP only", "SP and DP"};
7984 static const char *arm_attr_tag_ABI_VFP_args
[] =
7985 {"AAPCS", "VFP registers", "custom"};
7986 static const char *arm_attr_tag_ABI_WMMX_args
[] =
7987 {"AAPCS", "WMMX registers", "custom"};
7988 static const char *arm_attr_tag_ABI_optimization_goals
[] =
7989 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
7990 "Aggressive Size", "Prefer Debug", "Aggressive Debug"};
7991 static const char *arm_attr_tag_ABI_FP_optimization_goals
[] =
7992 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
7993 "Aggressive Size", "Prefer Accuracy", "Aggressive Accuracy"};
7995 #define LOOKUP(id, name) \
7996 {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
7997 static arm_attr_public_tag arm_attr_public_tags
[] =
7999 {4, "CPU_raw_name", 1, NULL
},
8000 {5, "CPU_name", 1, NULL
},
8001 LOOKUP(6, CPU_arch
),
8002 {7, "CPU_arch_profile", 0, NULL
},
8003 LOOKUP(8, ARM_ISA_use
),
8004 LOOKUP(9, THUMB_ISA_use
),
8005 LOOKUP(10, VFP_arch
),
8006 LOOKUP(11, WMMX_arch
),
8007 LOOKUP(12, NEON_arch
),
8008 LOOKUP(13, ABI_PCS_config
),
8009 LOOKUP(14, ABI_PCS_R9_use
),
8010 LOOKUP(15, ABI_PCS_RW_data
),
8011 LOOKUP(16, ABI_PCS_RO_DATA
),
8012 LOOKUP(17, ABI_PCS_GOT_use
),
8013 LOOKUP(18, ABI_PCS_wchar_t
),
8014 LOOKUP(19, ABI_FP_rounding
),
8015 LOOKUP(20, ABI_FP_denormal
),
8016 LOOKUP(21, ABI_FP_exceptions
),
8017 LOOKUP(22, ABI_FP_user_exceptions
),
8018 LOOKUP(23, ABI_FP_number_model
),
8019 LOOKUP(24, ABI_align8_needed
),
8020 LOOKUP(25, ABI_align8_preserved
),
8021 LOOKUP(26, ABI_enum_size
),
8022 LOOKUP(27, ABI_HardFP_use
),
8023 LOOKUP(28, ABI_VFP_args
),
8024 LOOKUP(29, ABI_WMMX_args
),
8025 LOOKUP(30, ABI_optimization_goals
),
8026 LOOKUP(31, ABI_FP_optimization_goals
),
8027 {32, "compatibility", 0, NULL
}
8031 /* Read an unsigned LEB128 encoded value from p. Set *PLEN to the number of
8034 read_uleb128 (unsigned char *p
, unsigned int *plen
)
8048 val
|= ((unsigned int)c
& 0x7f) << shift
;
8057 static unsigned char *
8058 display_arm_attribute (unsigned char *p
)
8063 arm_attr_public_tag
*attr
;
8067 tag
= read_uleb128 (p
, &len
);
8070 for (i
= 0; i
< ARRAY_SIZE(arm_attr_public_tags
); i
++)
8072 if (arm_attr_public_tags
[i
].tag
== tag
)
8074 attr
= &arm_attr_public_tags
[i
];
8081 printf (" Tag_%s: ", attr
->name
);
8087 case 7: /* Tag_CPU_arch_profile. */
8088 val
= read_uleb128 (p
, &len
);
8092 case 0: printf ("None\n"); break;
8093 case 'A': printf ("Application\n"); break;
8094 case 'R': printf ("Realtime\n"); break;
8095 case 'M': printf ("Microcontroller\n"); break;
8096 default: printf ("??? (%d)\n", val
); break;
8100 case 32: /* Tag_compatibility. */
8101 val
= read_uleb128 (p
, &len
);
8103 printf ("flag = %d, vendor = %s\n", val
, p
);
8104 p
+= strlen((char *)p
) + 1;
8118 assert (attr
->type
& 0x80);
8119 val
= read_uleb128 (p
, &len
);
8121 type
= attr
->type
& 0x7f;
8123 printf ("??? (%d)\n", val
);
8125 printf ("%s\n", attr
->table
[val
]);
8132 type
= 1; /* String. */
8134 type
= 2; /* uleb128. */
8135 printf (" Tag_unknown_%d: ", tag
);
8140 printf ("\"%s\"\n", p
);
8141 p
+= strlen((char *)p
) + 1;
8145 val
= read_uleb128 (p
, &len
);
8147 printf ("%d (0x%x)\n", val
, val
);
8154 process_arm_specific (FILE *file
)
8156 Elf_Internal_Shdr
*sect
;
8157 unsigned char *contents
;
8160 bfd_vma section_len
;
8164 /* Find the section header so that we get the size. */
8165 for (i
= 0, sect
= section_headers
;
8166 i
< elf_header
.e_shnum
;
8169 if (sect
->sh_type
!= SHT_ARM_ATTRIBUTES
)
8172 contents
= get_data (NULL
, file
, sect
->sh_offset
, 1, sect
->sh_size
,
8180 len
= sect
->sh_size
- 1;
8185 bfd_boolean public_section
;
8187 section_len
= byte_get (p
, 4);
8189 if (section_len
> len
)
8191 printf (_("ERROR: Bad section length (%d > %d)\n"),
8192 (int)section_len
, (int)len
);
8196 printf ("Attribute Section: %s\n", p
);
8197 if (strcmp ((char *)p
, "aeabi") == 0)
8198 public_section
= TRUE
;
8200 public_section
= FALSE
;
8201 namelen
= strlen ((char *)p
) + 1;
8203 section_len
-= namelen
+ 4;
8204 while (section_len
> 0)
8209 size
= byte_get (p
, 4);
8210 if (size
> section_len
)
8212 printf (_("ERROR: Bad subsection length (%d > %d)\n"),
8213 (int)size
, (int)section_len
);
8216 section_len
-= size
;
8222 printf ("File Attributes\n");
8225 printf ("Section Attributes:");
8228 printf ("Symbol Attributes:");
8233 val
= read_uleb128 (p
, &i
);
8237 printf (" %d", val
);
8242 printf ("Unknown tag: %d\n", tag
);
8243 public_section
= FALSE
;
8249 p
= display_arm_attribute(p
);
8253 /* ??? Do something sensible, like dump hex. */
8254 printf (" Unknown section contexts\n");
8262 printf (_("Unknown format '%c'\n"), *p
);
8271 process_mips_specific (FILE *file
)
8273 Elf_Internal_Dyn
*entry
;
8274 size_t liblist_offset
= 0;
8275 size_t liblistno
= 0;
8276 size_t conflictsno
= 0;
8277 size_t options_offset
= 0;
8278 size_t conflicts_offset
= 0;
8280 /* We have a lot of special sections. Thanks SGI! */
8281 if (dynamic_section
== NULL
)
8282 /* No information available. */
8285 for (entry
= dynamic_section
; entry
->d_tag
!= DT_NULL
; ++entry
)
8286 switch (entry
->d_tag
)
8288 case DT_MIPS_LIBLIST
:
8290 = offset_from_vma (file
, entry
->d_un
.d_val
,
8291 liblistno
* sizeof (Elf32_External_Lib
));
8293 case DT_MIPS_LIBLISTNO
:
8294 liblistno
= entry
->d_un
.d_val
;
8296 case DT_MIPS_OPTIONS
:
8297 options_offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
8299 case DT_MIPS_CONFLICT
:
8301 = offset_from_vma (file
, entry
->d_un
.d_val
,
8302 conflictsno
* sizeof (Elf32_External_Conflict
));
8304 case DT_MIPS_CONFLICTNO
:
8305 conflictsno
= entry
->d_un
.d_val
;
8311 if (liblist_offset
!= 0 && liblistno
!= 0 && do_dynamic
)
8313 Elf32_External_Lib
*elib
;
8316 elib
= get_data (NULL
, file
, liblist_offset
,
8317 liblistno
, sizeof (Elf32_External_Lib
),
8321 printf ("\nSection '.liblist' contains %lu entries:\n",
8322 (unsigned long) liblistno
);
8323 fputs (" Library Time Stamp Checksum Version Flags\n",
8326 for (cnt
= 0; cnt
< liblistno
; ++cnt
)
8333 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
8334 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
8335 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
8336 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
8337 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
8339 tmp
= gmtime (&time
);
8340 snprintf (timebuf
, sizeof (timebuf
),
8341 "%04u-%02u-%02uT%02u:%02u:%02u",
8342 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
8343 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
8345 printf ("%3lu: ", (unsigned long) cnt
);
8346 if (VALID_DYNAMIC_NAME (liblist
.l_name
))
8347 print_symbol (20, GET_DYNAMIC_NAME (liblist
.l_name
));
8349 printf ("<corrupt: %9ld>", liblist
.l_name
);
8350 printf (" %s %#10lx %-7ld", timebuf
, liblist
.l_checksum
,
8353 if (liblist
.l_flags
== 0)
8364 { " EXACT_MATCH", LL_EXACT_MATCH
},
8365 { " IGNORE_INT_VER", LL_IGNORE_INT_VER
},
8366 { " REQUIRE_MINOR", LL_REQUIRE_MINOR
},
8367 { " EXPORTS", LL_EXPORTS
},
8368 { " DELAY_LOAD", LL_DELAY_LOAD
},
8369 { " DELTA", LL_DELTA
}
8371 int flags
= liblist
.l_flags
;
8375 fcnt
< sizeof (l_flags_vals
) / sizeof (l_flags_vals
[0]);
8377 if ((flags
& l_flags_vals
[fcnt
].bit
) != 0)
8379 fputs (l_flags_vals
[fcnt
].name
, stdout
);
8380 flags
^= l_flags_vals
[fcnt
].bit
;
8383 printf (" %#x", (unsigned int) flags
);
8393 if (options_offset
!= 0)
8395 Elf_External_Options
*eopt
;
8396 Elf_Internal_Shdr
*sect
= section_headers
;
8397 Elf_Internal_Options
*iopt
;
8398 Elf_Internal_Options
*option
;
8402 /* Find the section header so that we get the size. */
8403 while (sect
->sh_type
!= SHT_MIPS_OPTIONS
)
8406 eopt
= get_data (NULL
, file
, options_offset
, 1, sect
->sh_size
,
8410 iopt
= cmalloc ((sect
->sh_size
/ sizeof (eopt
)), sizeof (*iopt
));
8413 error (_("Out of memory"));
8420 while (offset
< sect
->sh_size
)
8422 Elf_External_Options
*eoption
;
8424 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
8426 option
->kind
= BYTE_GET (eoption
->kind
);
8427 option
->size
= BYTE_GET (eoption
->size
);
8428 option
->section
= BYTE_GET (eoption
->section
);
8429 option
->info
= BYTE_GET (eoption
->info
);
8431 offset
+= option
->size
;
8437 printf (_("\nSection '%s' contains %d entries:\n"),
8438 SECTION_NAME (sect
), cnt
);
8446 switch (option
->kind
)
8449 /* This shouldn't happen. */
8450 printf (" NULL %d %lx", option
->section
, option
->info
);
8453 printf (" REGINFO ");
8454 if (elf_header
.e_machine
== EM_MIPS
)
8457 Elf32_External_RegInfo
*ereg
;
8458 Elf32_RegInfo reginfo
;
8460 ereg
= (Elf32_External_RegInfo
*) (option
+ 1);
8461 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8462 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8463 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8464 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8465 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8466 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
8468 printf ("GPR %08lx GP 0x%lx\n",
8470 (unsigned long) reginfo
.ri_gp_value
);
8471 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8472 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8473 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8478 Elf64_External_RegInfo
*ereg
;
8479 Elf64_Internal_RegInfo reginfo
;
8481 ereg
= (Elf64_External_RegInfo
*) (option
+ 1);
8482 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8483 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8484 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8485 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8486 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8487 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
8489 printf ("GPR %08lx GP 0x",
8490 reginfo
.ri_gprmask
);
8491 printf_vma (reginfo
.ri_gp_value
);
8494 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8495 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8496 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8500 case ODK_EXCEPTIONS
:
8501 fputs (" EXCEPTIONS fpe_min(", stdout
);
8502 process_mips_fpe_exception (option
->info
& OEX_FPU_MIN
);
8503 fputs (") fpe_max(", stdout
);
8504 process_mips_fpe_exception ((option
->info
& OEX_FPU_MAX
) >> 8);
8505 fputs (")", stdout
);
8507 if (option
->info
& OEX_PAGE0
)
8508 fputs (" PAGE0", stdout
);
8509 if (option
->info
& OEX_SMM
)
8510 fputs (" SMM", stdout
);
8511 if (option
->info
& OEX_FPDBUG
)
8512 fputs (" FPDBUG", stdout
);
8513 if (option
->info
& OEX_DISMISS
)
8514 fputs (" DISMISS", stdout
);
8517 fputs (" PAD ", stdout
);
8518 if (option
->info
& OPAD_PREFIX
)
8519 fputs (" PREFIX", stdout
);
8520 if (option
->info
& OPAD_POSTFIX
)
8521 fputs (" POSTFIX", stdout
);
8522 if (option
->info
& OPAD_SYMBOL
)
8523 fputs (" SYMBOL", stdout
);
8526 fputs (" HWPATCH ", stdout
);
8527 if (option
->info
& OHW_R4KEOP
)
8528 fputs (" R4KEOP", stdout
);
8529 if (option
->info
& OHW_R8KPFETCH
)
8530 fputs (" R8KPFETCH", stdout
);
8531 if (option
->info
& OHW_R5KEOP
)
8532 fputs (" R5KEOP", stdout
);
8533 if (option
->info
& OHW_R5KCVTL
)
8534 fputs (" R5KCVTL", stdout
);
8537 fputs (" FILL ", stdout
);
8538 /* XXX Print content of info word? */
8541 fputs (" TAGS ", stdout
);
8542 /* XXX Print content of info word? */
8545 fputs (" HWAND ", stdout
);
8546 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8547 fputs (" R4KEOP_CHECKED", stdout
);
8548 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8549 fputs (" R4KEOP_CLEAN", stdout
);
8552 fputs (" HWOR ", stdout
);
8553 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8554 fputs (" R4KEOP_CHECKED", stdout
);
8555 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8556 fputs (" R4KEOP_CLEAN", stdout
);
8559 printf (" GP_GROUP %#06lx self-contained %#06lx",
8560 option
->info
& OGP_GROUP
,
8561 (option
->info
& OGP_SELF
) >> 16);
8564 printf (" IDENT %#06lx self-contained %#06lx",
8565 option
->info
& OGP_GROUP
,
8566 (option
->info
& OGP_SELF
) >> 16);
8569 /* This shouldn't happen. */
8570 printf (" %3d ??? %d %lx",
8571 option
->kind
, option
->section
, option
->info
);
8575 len
= sizeof (*eopt
);
8576 while (len
< option
->size
)
8577 if (((char *) option
)[len
] >= ' '
8578 && ((char *) option
)[len
] < 0x7f)
8579 printf ("%c", ((char *) option
)[len
++]);
8581 printf ("\\%03o", ((char *) option
)[len
++]);
8583 fputs ("\n", stdout
);
8591 if (conflicts_offset
!= 0 && conflictsno
!= 0)
8593 Elf32_Conflict
*iconf
;
8596 if (dynamic_symbols
== NULL
)
8598 error (_("conflict list found without a dynamic symbol table"));
8602 iconf
= cmalloc (conflictsno
, sizeof (*iconf
));
8605 error (_("Out of memory"));
8611 Elf32_External_Conflict
*econf32
;
8613 econf32
= get_data (NULL
, file
, conflicts_offset
,
8614 conflictsno
, sizeof (*econf32
), _("conflict"));
8618 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
8619 iconf
[cnt
] = BYTE_GET (econf32
[cnt
]);
8625 Elf64_External_Conflict
*econf64
;
8627 econf64
= get_data (NULL
, file
, conflicts_offset
,
8628 conflictsno
, sizeof (*econf64
), _("conflict"));
8632 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
8633 iconf
[cnt
] = BYTE_GET (econf64
[cnt
]);
8638 printf (_("\nSection '.conflict' contains %lu entries:\n"),
8639 (unsigned long) conflictsno
);
8640 puts (_(" Num: Index Value Name"));
8642 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
8644 Elf_Internal_Sym
*psym
= & dynamic_symbols
[iconf
[cnt
]];
8646 printf ("%5lu: %8lu ", (unsigned long) cnt
, iconf
[cnt
]);
8647 print_vma (psym
->st_value
, FULL_HEX
);
8649 if (VALID_DYNAMIC_NAME (psym
->st_name
))
8650 print_symbol (25, GET_DYNAMIC_NAME (psym
->st_name
));
8652 printf ("<corrupt: %14ld>", psym
->st_name
);
8663 process_gnu_liblist (FILE *file
)
8665 Elf_Internal_Shdr
*section
, *string_sec
;
8666 Elf32_External_Lib
*elib
;
8675 for (i
= 0, section
= section_headers
;
8676 i
< elf_header
.e_shnum
;
8679 switch (section
->sh_type
)
8681 case SHT_GNU_LIBLIST
:
8682 if (SECTION_HEADER_INDEX (section
->sh_link
) >= elf_header
.e_shnum
)
8685 elib
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
8690 string_sec
= SECTION_HEADER (section
->sh_link
);
8692 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
, 1,
8693 string_sec
->sh_size
, _("liblist string table"));
8694 strtab_size
= string_sec
->sh_size
;
8697 || section
->sh_entsize
!= sizeof (Elf32_External_Lib
))
8703 printf (_("\nLibrary list section '%s' contains %lu entries:\n"),
8704 SECTION_NAME (section
),
8705 (long) (section
->sh_size
/ sizeof (Elf32_External_Lib
)));
8707 puts (" Library Time Stamp Checksum Version Flags");
8709 for (cnt
= 0; cnt
< section
->sh_size
/ sizeof (Elf32_External_Lib
);
8717 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
8718 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
8719 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
8720 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
8721 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
8723 tmp
= gmtime (&time
);
8724 snprintf (timebuf
, sizeof (timebuf
),
8725 "%04u-%02u-%02uT%02u:%02u:%02u",
8726 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
8727 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
8729 printf ("%3lu: ", (unsigned long) cnt
);
8731 printf ("%-20s", liblist
.l_name
< strtab_size
8732 ? strtab
+ liblist
.l_name
: "<corrupt>");
8734 printf ("%-20.20s", liblist
.l_name
< strtab_size
8735 ? strtab
+ liblist
.l_name
: "<corrupt>");
8736 printf (" %s %#010lx %-7ld %-7ld\n", timebuf
, liblist
.l_checksum
,
8737 liblist
.l_version
, liblist
.l_flags
);
8748 get_note_type (unsigned e_type
)
8750 static char buff
[64];
8752 if (elf_header
.e_type
== ET_CORE
)
8756 return _("NT_AUXV (auxiliary vector)");
8758 return _("NT_PRSTATUS (prstatus structure)");
8760 return _("NT_FPREGSET (floating point registers)");
8762 return _("NT_PRPSINFO (prpsinfo structure)");
8764 return _("NT_TASKSTRUCT (task structure)");
8766 return _("NT_PRXFPREG (user_xfpregs structure)");
8768 return _("NT_PSTATUS (pstatus structure)");
8770 return _("NT_FPREGS (floating point registers)");
8772 return _("NT_PSINFO (psinfo structure)");
8774 return _("NT_LWPSTATUS (lwpstatus_t structure)");
8776 return _("NT_LWPSINFO (lwpsinfo_t structure)");
8777 case NT_WIN32PSTATUS
:
8778 return _("NT_WIN32PSTATUS (win32_pstatus structure)");
8786 return _("NT_VERSION (version)");
8788 return _("NT_ARCH (architecture)");
8793 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
8798 get_netbsd_elfcore_note_type (unsigned e_type
)
8800 static char buff
[64];
8802 if (e_type
== NT_NETBSDCORE_PROCINFO
)
8804 /* NetBSD core "procinfo" structure. */
8805 return _("NetBSD procinfo structure");
8808 /* As of Jan 2002 there are no other machine-independent notes
8809 defined for NetBSD core files. If the note type is less
8810 than the start of the machine-dependent note types, we don't
8813 if (e_type
< NT_NETBSDCORE_FIRSTMACH
)
8815 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
8819 switch (elf_header
.e_machine
)
8821 /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0
8822 and PT_GETFPREGS == mach+2. */
8827 case EM_SPARC32PLUS
:
8831 case NT_NETBSDCORE_FIRSTMACH
+0:
8832 return _("PT_GETREGS (reg structure)");
8833 case NT_NETBSDCORE_FIRSTMACH
+2:
8834 return _("PT_GETFPREGS (fpreg structure)");
8840 /* On all other arch's, PT_GETREGS == mach+1 and
8841 PT_GETFPREGS == mach+3. */
8845 case NT_NETBSDCORE_FIRSTMACH
+1:
8846 return _("PT_GETREGS (reg structure)");
8847 case NT_NETBSDCORE_FIRSTMACH
+3:
8848 return _("PT_GETFPREGS (fpreg structure)");
8854 snprintf (buff
, sizeof (buff
), _("PT_FIRSTMACH+%d"),
8855 e_type
- NT_NETBSDCORE_FIRSTMACH
);
8859 /* Note that by the ELF standard, the name field is already null byte
8860 terminated, and namesz includes the terminating null byte.
8861 I.E. the value of namesz for the name "FSF" is 4.
8863 If the value of namesz is zero, there is no name present. */
8865 process_note (Elf_Internal_Note
*pnote
)
8869 if (pnote
->namesz
== 0)
8870 /* If there is no note name, then use the default set of
8871 note type strings. */
8872 nt
= get_note_type (pnote
->type
);
8874 else if (strneq (pnote
->namedata
, "NetBSD-CORE", 11))
8875 /* NetBSD-specific core file notes. */
8876 nt
= get_netbsd_elfcore_note_type (pnote
->type
);
8879 /* Don't recognize this note name; just use the default set of
8880 note type strings. */
8881 nt
= get_note_type (pnote
->type
);
8883 printf (" %s\t\t0x%08lx\t%s\n",
8884 pnote
->namesz
? pnote
->namedata
: "(NONE)",
8891 process_corefile_note_segment (FILE *file
, bfd_vma offset
, bfd_vma length
)
8893 Elf_External_Note
*pnotes
;
8894 Elf_External_Note
*external
;
8900 pnotes
= get_data (NULL
, file
, offset
, 1, length
, _("notes"));
8906 printf (_("\nNotes at offset 0x%08lx with length 0x%08lx:\n"),
8907 (unsigned long) offset
, (unsigned long) length
);
8908 printf (_(" Owner\t\tData size\tDescription\n"));
8910 while (external
< (Elf_External_Note
*)((char *) pnotes
+ length
))
8912 Elf_External_Note
*next
;
8913 Elf_Internal_Note inote
;
8916 inote
.type
= BYTE_GET (external
->type
);
8917 inote
.namesz
= BYTE_GET (external
->namesz
);
8918 inote
.namedata
= external
->name
;
8919 inote
.descsz
= BYTE_GET (external
->descsz
);
8920 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 2);
8921 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
8923 next
= (Elf_External_Note
*)(inote
.descdata
+ align_power (inote
.descsz
, 2));
8925 if (((char *) next
) > (((char *) pnotes
) + length
))
8927 warn (_("corrupt note found at offset %lx into core notes\n"),
8928 (long)((char *)external
- (char *)pnotes
));
8929 warn (_(" type: %lx, namesize: %08lx, descsize: %08lx\n"),
8930 inote
.type
, inote
.namesz
, inote
.descsz
);
8936 /* Verify that name is null terminated. It appears that at least
8937 one version of Linux (RedHat 6.0) generates corefiles that don't
8938 comply with the ELF spec by failing to include the null byte in
8940 if (inote
.namedata
[inote
.namesz
] != '\0')
8942 temp
= malloc (inote
.namesz
+ 1);
8946 error (_("Out of memory\n"));
8951 strncpy (temp
, inote
.namedata
, inote
.namesz
);
8952 temp
[inote
.namesz
] = 0;
8954 /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */
8955 inote
.namedata
= temp
;
8958 res
&= process_note (& inote
);
8973 process_corefile_note_segments (FILE *file
)
8975 Elf_Internal_Phdr
*segment
;
8979 if (! get_program_headers (file
))
8982 for (i
= 0, segment
= program_headers
;
8983 i
< elf_header
.e_phnum
;
8986 if (segment
->p_type
== PT_NOTE
)
8987 res
&= process_corefile_note_segment (file
,
8988 (bfd_vma
) segment
->p_offset
,
8989 (bfd_vma
) segment
->p_filesz
);
8996 process_note_sections (FILE *file
)
8998 Elf_Internal_Shdr
*section
;
9002 for (i
= 0, section
= section_headers
;
9003 i
< elf_header
.e_shnum
;
9005 if (section
->sh_type
== SHT_NOTE
)
9006 res
&= process_corefile_note_segment (file
,
9007 (bfd_vma
) section
->sh_offset
,
9008 (bfd_vma
) section
->sh_size
);
9014 process_notes (FILE *file
)
9016 /* If we have not been asked to display the notes then do nothing. */
9020 if (elf_header
.e_type
!= ET_CORE
)
9021 return process_note_sections (file
);
9023 /* No program headers means no NOTE segment. */
9024 if (elf_header
.e_phnum
> 0)
9025 return process_corefile_note_segments (file
);
9027 printf (_("No note segments present in the core file.\n"));
9032 process_arch_specific (FILE *file
)
9037 switch (elf_header
.e_machine
)
9040 return process_arm_specific (file
);
9042 case EM_MIPS_RS3_LE
:
9043 return process_mips_specific (file
);
9052 get_file_header (FILE *file
)
9054 /* Read in the identity array. */
9055 if (fread (elf_header
.e_ident
, EI_NIDENT
, 1, file
) != 1)
9058 /* Determine how to read the rest of the header. */
9059 switch (elf_header
.e_ident
[EI_DATA
])
9061 default: /* fall through */
9062 case ELFDATANONE
: /* fall through */
9064 byte_get
= byte_get_little_endian
;
9065 byte_put
= byte_put_little_endian
;
9068 byte_get
= byte_get_big_endian
;
9069 byte_put
= byte_put_big_endian
;
9073 /* For now we only support 32 bit and 64 bit ELF files. */
9074 is_32bit_elf
= (elf_header
.e_ident
[EI_CLASS
] != ELFCLASS64
);
9076 /* Read in the rest of the header. */
9079 Elf32_External_Ehdr ehdr32
;
9081 if (fread (ehdr32
.e_type
, sizeof (ehdr32
) - EI_NIDENT
, 1, file
) != 1)
9084 elf_header
.e_type
= BYTE_GET (ehdr32
.e_type
);
9085 elf_header
.e_machine
= BYTE_GET (ehdr32
.e_machine
);
9086 elf_header
.e_version
= BYTE_GET (ehdr32
.e_version
);
9087 elf_header
.e_entry
= BYTE_GET (ehdr32
.e_entry
);
9088 elf_header
.e_phoff
= BYTE_GET (ehdr32
.e_phoff
);
9089 elf_header
.e_shoff
= BYTE_GET (ehdr32
.e_shoff
);
9090 elf_header
.e_flags
= BYTE_GET (ehdr32
.e_flags
);
9091 elf_header
.e_ehsize
= BYTE_GET (ehdr32
.e_ehsize
);
9092 elf_header
.e_phentsize
= BYTE_GET (ehdr32
.e_phentsize
);
9093 elf_header
.e_phnum
= BYTE_GET (ehdr32
.e_phnum
);
9094 elf_header
.e_shentsize
= BYTE_GET (ehdr32
.e_shentsize
);
9095 elf_header
.e_shnum
= BYTE_GET (ehdr32
.e_shnum
);
9096 elf_header
.e_shstrndx
= BYTE_GET (ehdr32
.e_shstrndx
);
9100 Elf64_External_Ehdr ehdr64
;
9102 /* If we have been compiled with sizeof (bfd_vma) == 4, then
9103 we will not be able to cope with the 64bit data found in
9104 64 ELF files. Detect this now and abort before we start
9105 overwriting things. */
9106 if (sizeof (bfd_vma
) < 8)
9108 error (_("This instance of readelf has been built without support for a\n\
9109 64 bit data type and so it cannot read 64 bit ELF files.\n"));
9113 if (fread (ehdr64
.e_type
, sizeof (ehdr64
) - EI_NIDENT
, 1, file
) != 1)
9116 elf_header
.e_type
= BYTE_GET (ehdr64
.e_type
);
9117 elf_header
.e_machine
= BYTE_GET (ehdr64
.e_machine
);
9118 elf_header
.e_version
= BYTE_GET (ehdr64
.e_version
);
9119 elf_header
.e_entry
= BYTE_GET (ehdr64
.e_entry
);
9120 elf_header
.e_phoff
= BYTE_GET (ehdr64
.e_phoff
);
9121 elf_header
.e_shoff
= BYTE_GET (ehdr64
.e_shoff
);
9122 elf_header
.e_flags
= BYTE_GET (ehdr64
.e_flags
);
9123 elf_header
.e_ehsize
= BYTE_GET (ehdr64
.e_ehsize
);
9124 elf_header
.e_phentsize
= BYTE_GET (ehdr64
.e_phentsize
);
9125 elf_header
.e_phnum
= BYTE_GET (ehdr64
.e_phnum
);
9126 elf_header
.e_shentsize
= BYTE_GET (ehdr64
.e_shentsize
);
9127 elf_header
.e_shnum
= BYTE_GET (ehdr64
.e_shnum
);
9128 elf_header
.e_shstrndx
= BYTE_GET (ehdr64
.e_shstrndx
);
9131 if (elf_header
.e_shoff
)
9133 /* There may be some extensions in the first section header. Don't
9134 bomb if we can't read it. */
9136 get_32bit_section_headers (file
, 1);
9138 get_64bit_section_headers (file
, 1);
9141 is_relocatable
= elf_header
.e_type
== ET_REL
;
9146 /* Process one ELF object file according to the command line options.
9147 This file may actually be stored in an archive. The file is
9148 positioned at the start of the ELF object. */
9151 process_object (char *file_name
, FILE *file
)
9155 if (! get_file_header (file
))
9157 error (_("%s: Failed to read file header\n"), file_name
);
9161 /* Initialise per file variables. */
9162 for (i
= NUM_ELEM (version_info
); i
--;)
9163 version_info
[i
] = 0;
9165 for (i
= NUM_ELEM (dynamic_info
); i
--;)
9166 dynamic_info
[i
] = 0;
9168 /* Process the file. */
9170 printf (_("\nFile: %s\n"), file_name
);
9172 /* Initialise the dump_sects array from the cmdline_dump_sects array.
9173 Note we do this even if cmdline_dump_sects is empty because we
9174 must make sure that the dump_sets array is zeroed out before each
9175 object file is processed. */
9176 if (num_dump_sects
> num_cmdline_dump_sects
)
9177 memset (dump_sects
, 0, num_dump_sects
);
9179 if (num_cmdline_dump_sects
> 0)
9181 if (num_dump_sects
== 0)
9182 /* A sneaky way of allocating the dump_sects array. */
9183 request_dump (num_cmdline_dump_sects
, 0);
9185 assert (num_dump_sects
>= num_cmdline_dump_sects
);
9186 memcpy (dump_sects
, cmdline_dump_sects
, num_cmdline_dump_sects
);
9189 if (! process_file_header ())
9192 if (! process_section_headers (file
))
9194 /* Without loaded section headers we cannot process lots of
9196 do_unwind
= do_version
= do_dump
= do_arch
= 0;
9198 if (! do_using_dynamic
)
9199 do_syms
= do_reloc
= 0;
9202 if (! process_section_groups (file
))
9204 /* Without loaded section groups we cannot process unwind. */
9208 if (process_program_headers (file
))
9209 process_dynamic_section (file
);
9211 process_relocs (file
);
9213 process_unwind (file
);
9215 process_symbol_table (file
);
9217 process_syminfo (file
);
9219 process_version_sections (file
);
9221 process_section_contents (file
);
9223 process_notes (file
);
9225 process_gnu_liblist (file
);
9227 process_arch_specific (file
);
9229 if (program_headers
)
9231 free (program_headers
);
9232 program_headers
= NULL
;
9235 if (section_headers
)
9237 free (section_headers
);
9238 section_headers
= NULL
;
9243 free (string_table
);
9244 string_table
= NULL
;
9245 string_table_length
= 0;
9248 if (dynamic_strings
)
9250 free (dynamic_strings
);
9251 dynamic_strings
= NULL
;
9252 dynamic_strings_length
= 0;
9255 if (dynamic_symbols
)
9257 free (dynamic_symbols
);
9258 dynamic_symbols
= NULL
;
9259 num_dynamic_syms
= 0;
9262 if (dynamic_syminfo
)
9264 free (dynamic_syminfo
);
9265 dynamic_syminfo
= NULL
;
9268 if (section_headers_groups
)
9270 free (section_headers_groups
);
9271 section_headers_groups
= NULL
;
9276 struct group_list
*g
, *next
;
9278 for (i
= 0; i
< group_count
; i
++)
9280 for (g
= section_groups
[i
].root
; g
!= NULL
; g
= next
)
9287 free (section_groups
);
9288 section_groups
= NULL
;
9291 free_debug_memory ();
9296 /* Process an ELF archive. The file is positioned just after the
9300 process_archive (char *file_name
, FILE *file
)
9302 struct ar_hdr arhdr
;
9305 char *longnames
= NULL
;
9306 unsigned long longnames_size
= 0;
9307 size_t file_name_size
;
9312 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9313 if (got
!= sizeof arhdr
)
9318 error (_("%s: failed to read archive header\n"), file_name
);
9322 if (memcmp (arhdr
.ar_name
, "/ ", 16) == 0)
9324 /* This is the archive symbol table. Skip it.
9325 FIXME: We should have an option to dump it. */
9326 size
= strtoul (arhdr
.ar_size
, NULL
, 10);
9327 if (fseek (file
, size
+ (size
& 1), SEEK_CUR
) != 0)
9329 error (_("%s: failed to skip archive symbol table\n"), file_name
);
9333 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9334 if (got
!= sizeof arhdr
)
9339 error (_("%s: failed to read archive header\n"), file_name
);
9344 if (memcmp (arhdr
.ar_name
, "// ", 16) == 0)
9346 /* This is the archive string table holding long member
9349 longnames_size
= strtoul (arhdr
.ar_size
, NULL
, 10);
9351 longnames
= malloc (longnames_size
);
9352 if (longnames
== NULL
)
9354 error (_("Out of memory\n"));
9358 if (fread (longnames
, longnames_size
, 1, file
) != 1)
9361 error (_("%s: failed to read string table\n"), file_name
);
9365 if ((longnames_size
& 1) != 0)
9368 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9369 if (got
!= sizeof arhdr
)
9376 error (_("%s: failed to read archive header\n"), file_name
);
9381 file_name_size
= strlen (file_name
);
9390 if (arhdr
.ar_name
[0] == '/')
9394 off
= strtoul (arhdr
.ar_name
+ 1, NULL
, 10);
9395 if (off
>= longnames_size
)
9397 error (_("%s: invalid archive string table offset %lu\n"), file_name
, off
);
9402 name
= longnames
+ off
;
9403 nameend
= memchr (name
, '/', longnames_size
- off
);
9407 name
= arhdr
.ar_name
;
9408 nameend
= memchr (name
, '/', 16);
9411 if (nameend
== NULL
)
9413 error (_("%s: bad archive file name\n"), file_name
);
9418 namealc
= malloc (file_name_size
+ (nameend
- name
) + 3);
9419 if (namealc
== NULL
)
9421 error (_("Out of memory\n"));
9426 memcpy (namealc
, file_name
, file_name_size
);
9427 namealc
[file_name_size
] = '(';
9428 memcpy (namealc
+ file_name_size
+ 1, name
, nameend
- name
);
9429 namealc
[file_name_size
+ 1 + (nameend
- name
)] = ')';
9430 namealc
[file_name_size
+ 2 + (nameend
- name
)] = '\0';
9432 archive_file_offset
= ftell (file
);
9433 archive_file_size
= strtoul (arhdr
.ar_size
, NULL
, 10);
9435 ret
|= process_object (namealc
, file
);
9440 (archive_file_offset
9442 + (archive_file_size
& 1)),
9445 error (_("%s: failed to seek to next archive header\n"), file_name
);
9450 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9451 if (got
!= sizeof arhdr
)
9456 error (_("%s: failed to read archive header\n"), file_name
);
9469 process_file (char *file_name
)
9472 struct stat statbuf
;
9476 if (stat (file_name
, &statbuf
) < 0)
9478 if (errno
== ENOENT
)
9479 error (_("'%s': No such file\n"), file_name
);
9481 error (_("Could not locate '%s'. System error message: %s\n"),
9482 file_name
, strerror (errno
));
9486 if (! S_ISREG (statbuf
.st_mode
))
9488 error (_("'%s' is not an ordinary file\n"), file_name
);
9492 file
= fopen (file_name
, "rb");
9495 error (_("Input file '%s' is not readable.\n"), file_name
);
9499 if (fread (armag
, SARMAG
, 1, file
) != 1)
9501 error (_("%s: Failed to read file header\n"), file_name
);
9506 if (memcmp (armag
, ARMAG
, SARMAG
) == 0)
9507 ret
= process_archive (file_name
, file
);
9511 archive_file_size
= archive_file_offset
= 0;
9512 ret
= process_object (file_name
, file
);
9520 #ifdef SUPPORT_DISASSEMBLY
9521 /* Needed by the i386 disassembler. For extra credit, someone could
9522 fix this so that we insert symbolic addresses here, esp for GOT/PLT
9526 print_address (unsigned int addr
, FILE *outfile
)
9528 fprintf (outfile
,"0x%8.8x", addr
);
9531 /* Needed by the i386 disassembler. */
9533 db_task_printsym (unsigned int addr
)
9535 print_address (addr
, stderr
);
9540 main (int argc
, char **argv
)
9544 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
9545 setlocale (LC_MESSAGES
, "");
9547 #if defined (HAVE_SETLOCALE)
9548 setlocale (LC_CTYPE
, "");
9550 bindtextdomain (PACKAGE
, LOCALEDIR
);
9551 textdomain (PACKAGE
);
9553 expandargv (&argc
, &argv
);
9555 parse_args (argc
, argv
);
9557 if (num_dump_sects
> 0)
9559 /* Make a copy of the dump_sects array. */
9560 cmdline_dump_sects
= malloc (num_dump_sects
);
9561 if (cmdline_dump_sects
== NULL
)
9562 error (_("Out of memory allocating dump request table."));
9565 memcpy (cmdline_dump_sects
, dump_sects
, num_dump_sects
);
9566 num_cmdline_dump_sects
= num_dump_sects
;
9570 if (optind
< (argc
- 1))
9574 while (optind
< argc
)
9575 err
|= process_file (argv
[optind
++]);
9577 if (dump_sects
!= NULL
)
9579 if (cmdline_dump_sects
!= NULL
)
9580 free (cmdline_dump_sects
);