1 /* readelf.c -- display contents of an ELF format file
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
3 Free Software Foundation, Inc.
5 Originally developed by Eric Youngdale <eric@andante.jic.com>
6 Modifications by Nick Clifton <nickc@redhat.com>
8 This file is part of GNU Binutils.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
25 /* The difference between readelf and objdump:
27 Both programs are capable of displaying the contents of ELF format files,
28 so why does the binutils project have two file dumpers ?
30 The reason is that objdump sees an ELF file through a BFD filter of the
31 world; if BFD has a bug where, say, it disagrees about a machine constant
32 in e_flags, then the odds are good that it will remain internally
33 consistent. The linker sees it the BFD way, objdump sees it the BFD way,
34 GAS sees it the BFD way. There was need for a tool to go find out what
35 the file actually says.
37 This is why the readelf program does not link against the BFD library - it
38 exists as an independent program to help verify the correct working of BFD.
40 There is also the case that readelf can provide more information about an
41 ELF file than is provided by objdump. In particular it can display DWARF
42 debugging information which (at the moment) objdump cannot. */
45 #include <sys/types.h>
51 /* Define BFD64 here, even if our default architecture is 32 bit ELF
52 as this will allow us to read in and parse 64bit and 32bit ELF files.
53 Only do this if we believe that the compiler can support a 64 bit
54 data type. For now we only rely on GCC being able to do this. */
60 #include "elf/common.h"
61 #include "elf/external.h"
62 #include "elf/internal.h"
64 /* The following headers use the elf/reloc-macros.h file to
65 automatically generate relocation recognition functions
66 such as elf_mips_reloc_type() */
68 #define RELOC_MACROS_GEN_FUNC
70 #include "elf/alpha.h"
90 #include "elf/iq2000.h"
94 #include "elf/m68hc11.h"
95 #include "elf/mcore.h"
98 #include "elf/mn10200.h"
99 #include "elf/mn10300.h"
101 #include "elf/msp430.h"
102 #include "elf/or32.h"
105 #include "elf/ppc64.h"
106 #include "elf/s390.h"
107 #include "elf/score.h"
109 #include "elf/sparc.h"
111 #include "elf/v850.h"
113 #include "elf/x86-64.h"
114 #include "elf/xstormy16.h"
115 #include "elf/xtensa.h"
121 #include "libiberty.h"
123 char *program_name
= "readelf";
124 static long archive_file_offset
;
125 static unsigned long archive_file_size
;
126 static unsigned long dynamic_addr
;
127 static bfd_size_type dynamic_size
;
128 static unsigned int dynamic_nent
;
129 static char *dynamic_strings
;
130 static unsigned long dynamic_strings_length
;
131 static char *string_table
;
132 static unsigned long string_table_length
;
133 static unsigned long num_dynamic_syms
;
134 static Elf_Internal_Sym
*dynamic_symbols
;
135 static Elf_Internal_Syminfo
*dynamic_syminfo
;
136 static unsigned long dynamic_syminfo_offset
;
137 static unsigned int dynamic_syminfo_nent
;
138 static char program_interpreter
[64];
139 static bfd_vma dynamic_info
[DT_JMPREL
+ 1];
140 static bfd_vma dynamic_info_DT_GNU_HASH
;
141 static bfd_vma version_info
[16];
142 static Elf_Internal_Ehdr elf_header
;
143 static Elf_Internal_Shdr
*section_headers
;
144 static Elf_Internal_Phdr
*program_headers
;
145 static Elf_Internal_Dyn
*dynamic_section
;
146 static Elf_Internal_Shdr
*symtab_shndx_hdr
;
147 static int show_name
;
148 static int do_dynamic
;
151 static int do_sections
;
152 static int do_section_groups
;
153 static int do_section_details
;
154 static int do_segments
;
155 static int do_unwind
;
156 static int do_using_dynamic
;
157 static int do_header
;
159 static int do_version
;
161 static int do_histogram
;
162 static int do_debugging
;
165 static int is_32bit_elf
;
169 struct group_list
*next
;
170 unsigned int section_index
;
175 struct group_list
*root
;
176 unsigned int group_index
;
179 static size_t group_count
;
180 static struct group
*section_groups
;
181 static struct group
**section_headers_groups
;
183 /* A linked list of the section names for which dumps were requested
185 struct dump_list_entry
189 struct dump_list_entry
*next
;
191 static struct dump_list_entry
*dump_sects_byname
;
193 /* A dynamic array of flags indicating for which sections a hex dump
194 has been requested (via the -x switch) and/or a disassembly dump
195 (via the -i switch). */
196 char *cmdline_dump_sects
= NULL
;
197 unsigned num_cmdline_dump_sects
= 0;
199 /* A dynamic array of flags indicating for which sections a dump of
200 some kind has been requested. It is reset on a per-object file
201 basis and then initialised from the cmdline_dump_sects array,
202 the results of interpreting the -w switch, and the
203 dump_sects_byname list. */
204 char *dump_sects
= NULL
;
205 unsigned int num_dump_sects
= 0;
207 #define HEX_DUMP (1 << 0)
208 #define DISASS_DUMP (1 << 1)
209 #define DEBUG_DUMP (1 << 2)
211 /* How to print a vma value. */
212 typedef enum print_mode
224 static void (*byte_put
) (unsigned char *, bfd_vma
, int);
228 #define SECTION_NAME(X) \
229 ((X) == NULL ? "<none>" \
230 : string_table == NULL ? "<no-name>" \
231 : ((X)->sh_name >= string_table_length ? "<corrupt>" \
232 : string_table + (X)->sh_name))
234 /* Given st_shndx I, map to section_headers index. */
235 #define SECTION_HEADER_INDEX(I) \
236 ((I) < SHN_LORESERVE \
238 : ((I) <= SHN_HIRESERVE \
240 : (I) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))
242 /* Reverse of the above. */
243 #define SECTION_HEADER_NUM(N) \
244 ((N) < SHN_LORESERVE \
246 : (N) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))
248 #define SECTION_HEADER(I) (section_headers + SECTION_HEADER_INDEX (I))
250 #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
252 #define BYTE_GET(field) byte_get (field, sizeof (field))
254 #define NUM_ELEM(array) (sizeof (array) / sizeof ((array)[0]))
256 #define GET_ELF_SYMBOLS(file, section) \
257 (is_32bit_elf ? get_32bit_elf_symbols (file, section) \
258 : get_64bit_elf_symbols (file, section))
260 #define VALID_DYNAMIC_NAME(offset) ((dynamic_strings != NULL) && (offset < dynamic_strings_length))
261 /* GET_DYNAMIC_NAME asssumes that VALID_DYNAMIC_NAME has
262 already been called and verified that the string exists. */
263 #define GET_DYNAMIC_NAME(offset) (dynamic_strings + offset)
265 /* This is just a bit of syntatic sugar. */
266 #define streq(a,b) (strcmp ((a), (b)) == 0)
267 #define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
268 #define const_strneq(a,b) (strncmp ((a), (b), sizeof (b) - 1) == 0)
271 get_data (void *var
, FILE *file
, long offset
, size_t size
, size_t nmemb
,
276 if (size
== 0 || nmemb
== 0)
279 if (fseek (file
, archive_file_offset
+ offset
, SEEK_SET
))
281 error (_("Unable to seek to 0x%lx for %s\n"),
282 archive_file_offset
+ offset
, reason
);
289 /* Check for overflow. */
290 if (nmemb
< (~(size_t) 0 - 1) / size
)
291 /* + 1 so that we can '\0' terminate invalid string table sections. */
292 mvar
= malloc (size
* nmemb
+ 1);
296 error (_("Out of memory allocating 0x%lx bytes for %s\n"),
297 (unsigned long)(size
* nmemb
), reason
);
301 ((char *) mvar
)[size
* nmemb
] = '\0';
304 if (fread (mvar
, size
, nmemb
, file
) != nmemb
)
306 error (_("Unable to read in 0x%lx bytes of %s\n"),
307 (unsigned long)(size
* nmemb
), reason
);
317 byte_put_little_endian (unsigned char *field
, bfd_vma value
, int size
)
322 field
[7] = (((value
>> 24) >> 24) >> 8) & 0xff;
323 field
[6] = ((value
>> 24) >> 24) & 0xff;
324 field
[5] = ((value
>> 24) >> 16) & 0xff;
325 field
[4] = ((value
>> 24) >> 8) & 0xff;
328 field
[3] = (value
>> 24) & 0xff;
329 field
[2] = (value
>> 16) & 0xff;
332 field
[1] = (value
>> 8) & 0xff;
335 field
[0] = value
& 0xff;
339 error (_("Unhandled data length: %d\n"), size
);
344 #if defined BFD64 && !BFD_HOST_64BIT_LONG
346 print_dec_vma (bfd_vma vma
, int is_signed
)
352 if (is_signed
&& (bfd_signed_vma
) vma
< 0)
361 *bufp
++ = '0' + vma
% 10;
373 print_hex_vma (bfd_vma vma
)
381 char digit
= '0' + (vma
& 0x0f);
383 digit
+= 'a' - '0' - 10;
396 /* Print a VMA value. */
398 print_vma (bfd_vma vma
, print_mode mode
)
407 return printf ("0x%8.8lx", (unsigned long) vma
);
410 return printf ("%8.8lx", (unsigned long) vma
);
414 return printf ("%5ld", (long) vma
);
418 return printf ("0x%lx", (unsigned long) vma
);
421 return printf ("%lx", (unsigned long) vma
);
424 return printf ("%ld", (unsigned long) vma
);
427 return printf ("%lu", (unsigned long) vma
);
450 #if BFD_HOST_64BIT_LONG
451 return nc
+ printf ("%lx", vma
);
453 return nc
+ print_hex_vma (vma
);
457 #if BFD_HOST_64BIT_LONG
458 return printf ("%ld", vma
);
460 return print_dec_vma (vma
, 1);
464 #if BFD_HOST_64BIT_LONG
466 return printf ("%5ld", vma
);
468 return printf ("%#lx", vma
);
471 return printf ("%5ld", _bfd_int64_low (vma
));
473 return print_hex_vma (vma
);
477 #if BFD_HOST_64BIT_LONG
478 return printf ("%lu", vma
);
480 return print_dec_vma (vma
, 0);
488 /* Display a symbol on stdout. If do_wide is not true then
489 format the symbol to be at most WIDTH characters,
490 truncating as necessary. If WIDTH is negative then
491 format the string to be exactly - WIDTH characters,
492 truncating or padding as necessary. */
495 print_symbol (int width
, const char *symbol
)
498 printf ("%s", symbol
);
500 printf ("%-*.*s", width
, width
, symbol
);
502 printf ("%-.*s", width
, symbol
);
506 byte_put_big_endian (unsigned char *field
, bfd_vma value
, int size
)
511 field
[7] = value
& 0xff;
512 field
[6] = (value
>> 8) & 0xff;
513 field
[5] = (value
>> 16) & 0xff;
514 field
[4] = (value
>> 24) & 0xff;
519 field
[3] = value
& 0xff;
520 field
[2] = (value
>> 8) & 0xff;
524 field
[1] = value
& 0xff;
528 field
[0] = value
& 0xff;
532 error (_("Unhandled data length: %d\n"), size
);
537 /* Return a pointer to section NAME, or NULL if no such section exists. */
539 static Elf_Internal_Shdr
*
540 find_section (const char *name
)
544 for (i
= 0; i
< elf_header
.e_shnum
; i
++)
545 if (streq (SECTION_NAME (section_headers
+ i
), name
))
546 return section_headers
+ i
;
551 /* Guess the relocation size commonly used by the specific machines. */
554 guess_is_rela (unsigned long e_machine
)
558 /* Targets that use REL relocations. */
574 /* Targets that use RELA relocations. */
578 case EM_ALTERA_NIOS2
:
601 case EM_CYGNUS_MN10200
:
603 case EM_CYGNUS_MN10300
:
644 warn (_("Don't know about relocations on this machine architecture\n"));
650 slurp_rela_relocs (FILE *file
,
651 unsigned long rel_offset
,
652 unsigned long rel_size
,
653 Elf_Internal_Rela
**relasp
,
654 unsigned long *nrelasp
)
656 Elf_Internal_Rela
*relas
;
657 unsigned long nrelas
;
662 Elf32_External_Rela
*erelas
;
664 erelas
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
668 nrelas
= rel_size
/ sizeof (Elf32_External_Rela
);
670 relas
= cmalloc (nrelas
, sizeof (Elf_Internal_Rela
));
675 error (_("out of memory parsing relocs"));
679 for (i
= 0; i
< nrelas
; i
++)
681 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
682 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
683 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
690 Elf64_External_Rela
*erelas
;
692 erelas
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
696 nrelas
= rel_size
/ sizeof (Elf64_External_Rela
);
698 relas
= cmalloc (nrelas
, sizeof (Elf_Internal_Rela
));
703 error (_("out of memory parsing relocs"));
707 for (i
= 0; i
< nrelas
; i
++)
709 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
710 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
711 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
722 slurp_rel_relocs (FILE *file
,
723 unsigned long rel_offset
,
724 unsigned long rel_size
,
725 Elf_Internal_Rela
**relsp
,
726 unsigned long *nrelsp
)
728 Elf_Internal_Rela
*rels
;
734 Elf32_External_Rel
*erels
;
736 erels
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
740 nrels
= rel_size
/ sizeof (Elf32_External_Rel
);
742 rels
= cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
747 error (_("out of memory parsing relocs"));
751 for (i
= 0; i
< nrels
; i
++)
753 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
754 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
755 rels
[i
].r_addend
= 0;
762 Elf64_External_Rel
*erels
;
764 erels
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
768 nrels
= rel_size
/ sizeof (Elf64_External_Rel
);
770 rels
= cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
775 error (_("out of memory parsing relocs"));
779 for (i
= 0; i
< nrels
; i
++)
781 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
782 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
783 rels
[i
].r_addend
= 0;
793 /* Display the contents of the relocation data found at the specified
797 dump_relocations (FILE *file
,
798 unsigned long rel_offset
,
799 unsigned long rel_size
,
800 Elf_Internal_Sym
*symtab
,
803 unsigned long strtablen
,
807 Elf_Internal_Rela
*rels
;
810 if (is_rela
== UNKNOWN
)
811 is_rela
= guess_is_rela (elf_header
.e_machine
);
815 if (!slurp_rela_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
820 if (!slurp_rel_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
829 printf (_(" Offset Info Type Sym. Value Symbol's Name + Addend\n"));
831 printf (_(" Offset Info Type Sym.Value Sym. Name + Addend\n"));
836 printf (_(" Offset Info Type Sym. Value Symbol's Name\n"));
838 printf (_(" Offset Info Type Sym.Value Sym. Name\n"));
846 printf (_(" Offset Info Type Symbol's Value Symbol's Name + Addend\n"));
848 printf (_(" Offset Info Type Sym. Value Sym. Name + Addend\n"));
853 printf (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
855 printf (_(" Offset Info Type Sym. Value Sym. Name\n"));
859 for (i
= 0; i
< rel_size
; i
++)
862 const char *rtype2
= NULL
;
863 const char *rtype3
= NULL
;
866 bfd_vma symtab_index
;
871 offset
= rels
[i
].r_offset
;
872 info
= rels
[i
].r_info
;
876 type
= ELF32_R_TYPE (info
);
877 symtab_index
= ELF32_R_SYM (info
);
881 /* The #ifdef BFD64 below is to prevent a compile time warning.
882 We know that if we do not have a 64 bit data type that we
883 will never execute this code anyway. */
885 if (elf_header
.e_machine
== EM_MIPS
)
887 /* In little-endian objects, r_info isn't really a 64-bit
888 little-endian value: it has a 32-bit little-endian
889 symbol index followed by four individual byte fields.
890 Reorder INFO accordingly. */
891 if (elf_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
892 info
= (((info
& 0xffffffff) << 32)
893 | ((info
>> 56) & 0xff)
894 | ((info
>> 40) & 0xff00)
895 | ((info
>> 24) & 0xff0000)
896 | ((info
>> 8) & 0xff000000));
897 type
= ELF64_MIPS_R_TYPE (info
);
898 type2
= ELF64_MIPS_R_TYPE2 (info
);
899 type3
= ELF64_MIPS_R_TYPE3 (info
);
901 else if (elf_header
.e_machine
== EM_SPARCV9
)
902 type
= ELF64_R_TYPE_ID (info
);
904 type
= ELF64_R_TYPE (info
);
906 symtab_index
= ELF64_R_SYM (info
);
912 #ifdef _bfd_int64_low
913 printf ("%8.8lx %8.8lx ", _bfd_int64_low (offset
), _bfd_int64_low (info
));
915 printf ("%8.8lx %8.8lx ", offset
, info
);
920 #ifdef _bfd_int64_low
922 ? "%8.8lx%8.8lx %8.8lx%8.8lx "
923 : "%4.4lx%8.8lx %4.4lx%8.8lx ",
924 _bfd_int64_high (offset
),
925 _bfd_int64_low (offset
),
926 _bfd_int64_high (info
),
927 _bfd_int64_low (info
));
930 ? "%16.16lx %16.16lx "
931 : "%12.12lx %12.12lx ",
936 switch (elf_header
.e_machine
)
944 rtype
= elf_m32r_reloc_type (type
);
949 rtype
= elf_i386_reloc_type (type
);
954 rtype
= elf_m68hc11_reloc_type (type
);
958 rtype
= elf_m68k_reloc_type (type
);
962 rtype
= elf_i960_reloc_type (type
);
967 rtype
= elf_avr_reloc_type (type
);
974 rtype
= elf_sparc_reloc_type (type
);
978 rtype
= elf_spu_reloc_type (type
);
983 rtype
= v850_reloc_type (type
);
988 rtype
= elf_d10v_reloc_type (type
);
993 rtype
= elf_d30v_reloc_type (type
);
997 rtype
= elf_dlx_reloc_type (type
);
1001 rtype
= elf_sh_reloc_type (type
);
1005 case EM_CYGNUS_MN10300
:
1006 rtype
= elf_mn10300_reloc_type (type
);
1010 case EM_CYGNUS_MN10200
:
1011 rtype
= elf_mn10200_reloc_type (type
);
1015 case EM_CYGNUS_FR30
:
1016 rtype
= elf_fr30_reloc_type (type
);
1020 rtype
= elf_frv_reloc_type (type
);
1024 rtype
= elf_mcore_reloc_type (type
);
1028 rtype
= elf_mmix_reloc_type (type
);
1033 rtype
= elf_msp430_reloc_type (type
);
1037 rtype
= elf_ppc_reloc_type (type
);
1041 rtype
= elf_ppc64_reloc_type (type
);
1045 case EM_MIPS_RS3_LE
:
1046 rtype
= elf_mips_reloc_type (type
);
1049 rtype2
= elf_mips_reloc_type (type2
);
1050 rtype3
= elf_mips_reloc_type (type3
);
1055 rtype
= elf_alpha_reloc_type (type
);
1059 rtype
= elf_arm_reloc_type (type
);
1063 rtype
= elf_arc_reloc_type (type
);
1067 rtype
= elf_hppa_reloc_type (type
);
1073 rtype
= elf_h8_reloc_type (type
);
1078 rtype
= elf_or32_reloc_type (type
);
1083 rtype
= elf_pj_reloc_type (type
);
1086 rtype
= elf_ia64_reloc_type (type
);
1090 rtype
= elf_cris_reloc_type (type
);
1094 rtype
= elf_i860_reloc_type (type
);
1098 rtype
= elf_x86_64_reloc_type (type
);
1102 rtype
= i370_reloc_type (type
);
1107 rtype
= elf_s390_reloc_type (type
);
1111 rtype
= elf_score_reloc_type (type
);
1115 rtype
= elf_xstormy16_reloc_type (type
);
1119 rtype
= elf_crx_reloc_type (type
);
1123 rtype
= elf_vax_reloc_type (type
);
1128 rtype
= elf_ip2k_reloc_type (type
);
1132 rtype
= elf_iq2000_reloc_type (type
);
1137 rtype
= elf_xtensa_reloc_type (type
);
1141 rtype
= elf_m32c_reloc_type (type
);
1145 rtype
= elf_mt_reloc_type (type
);
1149 rtype
= elf_bfin_reloc_type (type
);
1154 #ifdef _bfd_int64_low
1155 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type
));
1157 printf (_("unrecognized: %-7lx"), type
);
1160 printf (do_wide
? "%-22.22s" : "%-17.17s", rtype
);
1162 if (elf_header
.e_machine
== EM_ALPHA
1164 && streq (rtype
, "R_ALPHA_LITUSE")
1167 switch (rels
[i
].r_addend
)
1169 case LITUSE_ALPHA_ADDR
: rtype
= "ADDR"; break;
1170 case LITUSE_ALPHA_BASE
: rtype
= "BASE"; break;
1171 case LITUSE_ALPHA_BYTOFF
: rtype
= "BYTOFF"; break;
1172 case LITUSE_ALPHA_JSR
: rtype
= "JSR"; break;
1173 case LITUSE_ALPHA_TLSGD
: rtype
= "TLSGD"; break;
1174 case LITUSE_ALPHA_TLSLDM
: rtype
= "TLSLDM"; break;
1175 case LITUSE_ALPHA_JSRDIRECT
: rtype
= "JSRDIRECT"; break;
1176 default: rtype
= NULL
;
1179 printf (" (%s)", rtype
);
1183 printf (_("<unknown addend: %lx>"),
1184 (unsigned long) rels
[i
].r_addend
);
1187 else if (symtab_index
)
1189 if (symtab
== NULL
|| symtab_index
>= nsyms
)
1190 printf (" bad symbol index: %08lx", (unsigned long) symtab_index
);
1193 Elf_Internal_Sym
*psym
;
1195 psym
= symtab
+ symtab_index
;
1198 print_vma (psym
->st_value
, LONG_HEX
);
1199 printf (is_32bit_elf
? " " : " ");
1201 if (psym
->st_name
== 0)
1203 const char *sec_name
= "<null>";
1206 if (ELF_ST_TYPE (psym
->st_info
) == STT_SECTION
)
1208 bfd_vma sec_index
= (bfd_vma
) -1;
1210 if (psym
->st_shndx
< SHN_LORESERVE
)
1211 sec_index
= psym
->st_shndx
;
1212 else if (psym
->st_shndx
> SHN_HIRESERVE
)
1213 sec_index
= psym
->st_shndx
- (SHN_HIRESERVE
+ 1
1216 if (sec_index
!= (bfd_vma
) -1)
1217 sec_name
= SECTION_NAME (section_headers
+ sec_index
);
1218 else if (psym
->st_shndx
== SHN_ABS
)
1220 else if (psym
->st_shndx
== SHN_COMMON
)
1221 sec_name
= "COMMON";
1222 else if (elf_header
.e_machine
== EM_MIPS
1223 && psym
->st_shndx
== SHN_MIPS_SCOMMON
)
1224 sec_name
= "SCOMMON";
1225 else if (elf_header
.e_machine
== EM_MIPS
1226 && psym
->st_shndx
== SHN_MIPS_SUNDEFINED
)
1227 sec_name
= "SUNDEF";
1228 else if (elf_header
.e_machine
== EM_X86_64
1229 && psym
->st_shndx
== SHN_X86_64_LCOMMON
)
1230 sec_name
= "LARGE_COMMON";
1231 else if (elf_header
.e_machine
== EM_IA_64
1232 && elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
1233 && psym
->st_shndx
== SHN_IA_64_ANSI_COMMON
)
1234 sec_name
= "ANSI_COM";
1237 sprintf (name_buf
, "<section 0x%x>",
1238 (unsigned int) psym
->st_shndx
);
1239 sec_name
= name_buf
;
1242 print_symbol (22, sec_name
);
1244 else if (strtab
== NULL
)
1245 printf (_("<string table index: %3ld>"), psym
->st_name
);
1246 else if (psym
->st_name
>= strtablen
)
1247 printf (_("<corrupt string table index: %3ld>"), psym
->st_name
);
1249 print_symbol (22, strtab
+ psym
->st_name
);
1252 printf (" + %lx", (unsigned long) rels
[i
].r_addend
);
1257 printf ("%*c", is_32bit_elf
?
1258 (do_wide
? 34 : 28) : (do_wide
? 26 : 20), ' ');
1259 print_vma (rels
[i
].r_addend
, LONG_HEX
);
1262 if (elf_header
.e_machine
== EM_SPARCV9
1264 && streq (rtype
, "R_SPARC_OLO10"))
1265 printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (info
));
1269 if (! is_32bit_elf
&& elf_header
.e_machine
== EM_MIPS
)
1271 printf (" Type2: ");
1274 #ifdef _bfd_int64_low
1275 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type2
));
1277 printf (_("unrecognized: %-7lx"), type2
);
1280 printf ("%-17.17s", rtype2
);
1282 printf ("\n Type3: ");
1285 #ifdef _bfd_int64_low
1286 printf (_("unrecognized: %-7lx"), _bfd_int64_low (type3
));
1288 printf (_("unrecognized: %-7lx"), type3
);
1291 printf ("%-17.17s", rtype3
);
1303 get_mips_dynamic_type (unsigned long type
)
1307 case DT_MIPS_RLD_VERSION
: return "MIPS_RLD_VERSION";
1308 case DT_MIPS_TIME_STAMP
: return "MIPS_TIME_STAMP";
1309 case DT_MIPS_ICHECKSUM
: return "MIPS_ICHECKSUM";
1310 case DT_MIPS_IVERSION
: return "MIPS_IVERSION";
1311 case DT_MIPS_FLAGS
: return "MIPS_FLAGS";
1312 case DT_MIPS_BASE_ADDRESS
: return "MIPS_BASE_ADDRESS";
1313 case DT_MIPS_MSYM
: return "MIPS_MSYM";
1314 case DT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
1315 case DT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
1316 case DT_MIPS_LOCAL_GOTNO
: return "MIPS_LOCAL_GOTNO";
1317 case DT_MIPS_CONFLICTNO
: return "MIPS_CONFLICTNO";
1318 case DT_MIPS_LIBLISTNO
: return "MIPS_LIBLISTNO";
1319 case DT_MIPS_SYMTABNO
: return "MIPS_SYMTABNO";
1320 case DT_MIPS_UNREFEXTNO
: return "MIPS_UNREFEXTNO";
1321 case DT_MIPS_GOTSYM
: return "MIPS_GOTSYM";
1322 case DT_MIPS_HIPAGENO
: return "MIPS_HIPAGENO";
1323 case DT_MIPS_RLD_MAP
: return "MIPS_RLD_MAP";
1324 case DT_MIPS_DELTA_CLASS
: return "MIPS_DELTA_CLASS";
1325 case DT_MIPS_DELTA_CLASS_NO
: return "MIPS_DELTA_CLASS_NO";
1326 case DT_MIPS_DELTA_INSTANCE
: return "MIPS_DELTA_INSTANCE";
1327 case DT_MIPS_DELTA_INSTANCE_NO
: return "MIPS_DELTA_INSTANCE_NO";
1328 case DT_MIPS_DELTA_RELOC
: return "MIPS_DELTA_RELOC";
1329 case DT_MIPS_DELTA_RELOC_NO
: return "MIPS_DELTA_RELOC_NO";
1330 case DT_MIPS_DELTA_SYM
: return "MIPS_DELTA_SYM";
1331 case DT_MIPS_DELTA_SYM_NO
: return "MIPS_DELTA_SYM_NO";
1332 case DT_MIPS_DELTA_CLASSSYM
: return "MIPS_DELTA_CLASSSYM";
1333 case DT_MIPS_DELTA_CLASSSYM_NO
: return "MIPS_DELTA_CLASSSYM_NO";
1334 case DT_MIPS_CXX_FLAGS
: return "MIPS_CXX_FLAGS";
1335 case DT_MIPS_PIXIE_INIT
: return "MIPS_PIXIE_INIT";
1336 case DT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
1337 case DT_MIPS_LOCALPAGE_GOTIDX
: return "MIPS_LOCALPAGE_GOTIDX";
1338 case DT_MIPS_LOCAL_GOTIDX
: return "MIPS_LOCAL_GOTIDX";
1339 case DT_MIPS_HIDDEN_GOTIDX
: return "MIPS_HIDDEN_GOTIDX";
1340 case DT_MIPS_PROTECTED_GOTIDX
: return "MIPS_PROTECTED_GOTIDX";
1341 case DT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
1342 case DT_MIPS_INTERFACE
: return "MIPS_INTERFACE";
1343 case DT_MIPS_DYNSTR_ALIGN
: return "MIPS_DYNSTR_ALIGN";
1344 case DT_MIPS_INTERFACE_SIZE
: return "MIPS_INTERFACE_SIZE";
1345 case DT_MIPS_RLD_TEXT_RESOLVE_ADDR
: return "MIPS_RLD_TEXT_RESOLVE_ADDR";
1346 case DT_MIPS_PERF_SUFFIX
: return "MIPS_PERF_SUFFIX";
1347 case DT_MIPS_COMPACT_SIZE
: return "MIPS_COMPACT_SIZE";
1348 case DT_MIPS_GP_VALUE
: return "MIPS_GP_VALUE";
1349 case DT_MIPS_AUX_DYNAMIC
: return "MIPS_AUX_DYNAMIC";
1356 get_sparc64_dynamic_type (unsigned long type
)
1360 case DT_SPARC_REGISTER
: return "SPARC_REGISTER";
1367 get_ppc_dynamic_type (unsigned long type
)
1371 case DT_PPC_GOT
: return "PPC_GOT";
1378 get_ppc64_dynamic_type (unsigned long type
)
1382 case DT_PPC64_GLINK
: return "PPC64_GLINK";
1383 case DT_PPC64_OPD
: return "PPC64_OPD";
1384 case DT_PPC64_OPDSZ
: return "PPC64_OPDSZ";
1391 get_parisc_dynamic_type (unsigned long type
)
1395 case DT_HP_LOAD_MAP
: return "HP_LOAD_MAP";
1396 case DT_HP_DLD_FLAGS
: return "HP_DLD_FLAGS";
1397 case DT_HP_DLD_HOOK
: return "HP_DLD_HOOK";
1398 case DT_HP_UX10_INIT
: return "HP_UX10_INIT";
1399 case DT_HP_UX10_INITSZ
: return "HP_UX10_INITSZ";
1400 case DT_HP_PREINIT
: return "HP_PREINIT";
1401 case DT_HP_PREINITSZ
: return "HP_PREINITSZ";
1402 case DT_HP_NEEDED
: return "HP_NEEDED";
1403 case DT_HP_TIME_STAMP
: return "HP_TIME_STAMP";
1404 case DT_HP_CHECKSUM
: return "HP_CHECKSUM";
1405 case DT_HP_GST_SIZE
: return "HP_GST_SIZE";
1406 case DT_HP_GST_VERSION
: return "HP_GST_VERSION";
1407 case DT_HP_GST_HASHVAL
: return "HP_GST_HASHVAL";
1408 case DT_HP_EPLTREL
: return "HP_GST_EPLTREL";
1409 case DT_HP_EPLTRELSZ
: return "HP_GST_EPLTRELSZ";
1410 case DT_HP_FILTERED
: return "HP_FILTERED";
1411 case DT_HP_FILTER_TLS
: return "HP_FILTER_TLS";
1412 case DT_HP_COMPAT_FILTERED
: return "HP_COMPAT_FILTERED";
1413 case DT_HP_LAZYLOAD
: return "HP_LAZYLOAD";
1414 case DT_HP_BIND_NOW_COUNT
: return "HP_BIND_NOW_COUNT";
1415 case DT_PLT
: return "PLT";
1416 case DT_PLT_SIZE
: return "PLT_SIZE";
1417 case DT_DLT
: return "DLT";
1418 case DT_DLT_SIZE
: return "DLT_SIZE";
1425 get_ia64_dynamic_type (unsigned long type
)
1429 case DT_IA_64_PLT_RESERVE
: return "IA_64_PLT_RESERVE";
1436 get_alpha_dynamic_type (unsigned long type
)
1440 case DT_ALPHA_PLTRO
: return "ALPHA_PLTRO";
1447 get_score_dynamic_type (unsigned long type
)
1451 case DT_SCORE_BASE_ADDRESS
: return "SCORE_BASE_ADDRESS";
1452 case DT_SCORE_LOCAL_GOTNO
: return "SCORE_LOCAL_GOTNO";
1453 case DT_SCORE_SYMTABNO
: return "SCORE_SYMTABNO";
1454 case DT_SCORE_GOTSYM
: return "SCORE_GOTSYM";
1455 case DT_SCORE_UNREFEXTNO
: return "SCORE_UNREFEXTNO";
1456 case DT_SCORE_HIPAGENO
: return "SCORE_HIPAGENO";
1464 get_dynamic_type (unsigned long type
)
1466 static char buff
[64];
1470 case DT_NULL
: return "NULL";
1471 case DT_NEEDED
: return "NEEDED";
1472 case DT_PLTRELSZ
: return "PLTRELSZ";
1473 case DT_PLTGOT
: return "PLTGOT";
1474 case DT_HASH
: return "HASH";
1475 case DT_STRTAB
: return "STRTAB";
1476 case DT_SYMTAB
: return "SYMTAB";
1477 case DT_RELA
: return "RELA";
1478 case DT_RELASZ
: return "RELASZ";
1479 case DT_RELAENT
: return "RELAENT";
1480 case DT_STRSZ
: return "STRSZ";
1481 case DT_SYMENT
: return "SYMENT";
1482 case DT_INIT
: return "INIT";
1483 case DT_FINI
: return "FINI";
1484 case DT_SONAME
: return "SONAME";
1485 case DT_RPATH
: return "RPATH";
1486 case DT_SYMBOLIC
: return "SYMBOLIC";
1487 case DT_REL
: return "REL";
1488 case DT_RELSZ
: return "RELSZ";
1489 case DT_RELENT
: return "RELENT";
1490 case DT_PLTREL
: return "PLTREL";
1491 case DT_DEBUG
: return "DEBUG";
1492 case DT_TEXTREL
: return "TEXTREL";
1493 case DT_JMPREL
: return "JMPREL";
1494 case DT_BIND_NOW
: return "BIND_NOW";
1495 case DT_INIT_ARRAY
: return "INIT_ARRAY";
1496 case DT_FINI_ARRAY
: return "FINI_ARRAY";
1497 case DT_INIT_ARRAYSZ
: return "INIT_ARRAYSZ";
1498 case DT_FINI_ARRAYSZ
: return "FINI_ARRAYSZ";
1499 case DT_RUNPATH
: return "RUNPATH";
1500 case DT_FLAGS
: return "FLAGS";
1502 case DT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
1503 case DT_PREINIT_ARRAYSZ
: return "PREINIT_ARRAYSZ";
1505 case DT_CHECKSUM
: return "CHECKSUM";
1506 case DT_PLTPADSZ
: return "PLTPADSZ";
1507 case DT_MOVEENT
: return "MOVEENT";
1508 case DT_MOVESZ
: return "MOVESZ";
1509 case DT_FEATURE
: return "FEATURE";
1510 case DT_POSFLAG_1
: return "POSFLAG_1";
1511 case DT_SYMINSZ
: return "SYMINSZ";
1512 case DT_SYMINENT
: return "SYMINENT"; /* aka VALRNGHI */
1514 case DT_ADDRRNGLO
: return "ADDRRNGLO";
1515 case DT_CONFIG
: return "CONFIG";
1516 case DT_DEPAUDIT
: return "DEPAUDIT";
1517 case DT_AUDIT
: return "AUDIT";
1518 case DT_PLTPAD
: return "PLTPAD";
1519 case DT_MOVETAB
: return "MOVETAB";
1520 case DT_SYMINFO
: return "SYMINFO"; /* aka ADDRRNGHI */
1522 case DT_VERSYM
: return "VERSYM";
1524 case DT_TLSDESC_GOT
: return "TLSDESC_GOT";
1525 case DT_TLSDESC_PLT
: return "TLSDESC_PLT";
1526 case DT_RELACOUNT
: return "RELACOUNT";
1527 case DT_RELCOUNT
: return "RELCOUNT";
1528 case DT_FLAGS_1
: return "FLAGS_1";
1529 case DT_VERDEF
: return "VERDEF";
1530 case DT_VERDEFNUM
: return "VERDEFNUM";
1531 case DT_VERNEED
: return "VERNEED";
1532 case DT_VERNEEDNUM
: return "VERNEEDNUM";
1534 case DT_AUXILIARY
: return "AUXILIARY";
1535 case DT_USED
: return "USED";
1536 case DT_FILTER
: return "FILTER";
1538 case DT_GNU_PRELINKED
: return "GNU_PRELINKED";
1539 case DT_GNU_CONFLICT
: return "GNU_CONFLICT";
1540 case DT_GNU_CONFLICTSZ
: return "GNU_CONFLICTSZ";
1541 case DT_GNU_LIBLIST
: return "GNU_LIBLIST";
1542 case DT_GNU_LIBLISTSZ
: return "GNU_LIBLISTSZ";
1543 case DT_GNU_HASH
: return "GNU_HASH";
1546 if ((type
>= DT_LOPROC
) && (type
<= DT_HIPROC
))
1550 switch (elf_header
.e_machine
)
1553 case EM_MIPS_RS3_LE
:
1554 result
= get_mips_dynamic_type (type
);
1557 result
= get_sparc64_dynamic_type (type
);
1560 result
= get_ppc_dynamic_type (type
);
1563 result
= get_ppc64_dynamic_type (type
);
1566 result
= get_ia64_dynamic_type (type
);
1569 result
= get_alpha_dynamic_type (type
);
1572 result
= get_score_dynamic_type (type
);
1582 snprintf (buff
, sizeof (buff
), _("Processor Specific: %lx"), type
);
1584 else if (((type
>= DT_LOOS
) && (type
<= DT_HIOS
))
1585 || (elf_header
.e_machine
== EM_PARISC
1586 && (type
>= OLD_DT_LOOS
) && (type
<= OLD_DT_HIOS
)))
1590 switch (elf_header
.e_machine
)
1593 result
= get_parisc_dynamic_type (type
);
1603 snprintf (buff
, sizeof (buff
), _("Operating System specific: %lx"),
1607 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), type
);
1614 get_file_type (unsigned e_type
)
1616 static char buff
[32];
1620 case ET_NONE
: return _("NONE (None)");
1621 case ET_REL
: return _("REL (Relocatable file)");
1622 case ET_EXEC
: return _("EXEC (Executable file)");
1623 case ET_DYN
: return _("DYN (Shared object file)");
1624 case ET_CORE
: return _("CORE (Core file)");
1627 if ((e_type
>= ET_LOPROC
) && (e_type
<= ET_HIPROC
))
1628 snprintf (buff
, sizeof (buff
), _("Processor Specific: (%x)"), e_type
);
1629 else if ((e_type
>= ET_LOOS
) && (e_type
<= ET_HIOS
))
1630 snprintf (buff
, sizeof (buff
), _("OS Specific: (%x)"), e_type
);
1632 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), e_type
);
1638 get_machine_name (unsigned e_machine
)
1640 static char buff
[64]; /* XXX */
1644 case EM_NONE
: return _("None");
1645 case EM_M32
: return "WE32100";
1646 case EM_SPARC
: return "Sparc";
1647 case EM_SPU
: return "SPU";
1648 case EM_386
: return "Intel 80386";
1649 case EM_68K
: return "MC68000";
1650 case EM_88K
: return "MC88000";
1651 case EM_486
: return "Intel 80486";
1652 case EM_860
: return "Intel 80860";
1653 case EM_MIPS
: return "MIPS R3000";
1654 case EM_S370
: return "IBM System/370";
1655 case EM_MIPS_RS3_LE
: return "MIPS R4000 big-endian";
1656 case EM_OLD_SPARCV9
: return "Sparc v9 (old)";
1657 case EM_PARISC
: return "HPPA";
1658 case EM_PPC_OLD
: return "Power PC (old)";
1659 case EM_SPARC32PLUS
: return "Sparc v8+" ;
1660 case EM_960
: return "Intel 90860";
1661 case EM_PPC
: return "PowerPC";
1662 case EM_PPC64
: return "PowerPC64";
1663 case EM_V800
: return "NEC V800";
1664 case EM_FR20
: return "Fujitsu FR20";
1665 case EM_RH32
: return "TRW RH32";
1666 case EM_MCORE
: return "MCORE";
1667 case EM_ARM
: return "ARM";
1668 case EM_OLD_ALPHA
: return "Digital Alpha (old)";
1669 case EM_SH
: return "Renesas / SuperH SH";
1670 case EM_SPARCV9
: return "Sparc v9";
1671 case EM_TRICORE
: return "Siemens Tricore";
1672 case EM_ARC
: return "ARC";
1673 case EM_H8_300
: return "Renesas H8/300";
1674 case EM_H8_300H
: return "Renesas H8/300H";
1675 case EM_H8S
: return "Renesas H8S";
1676 case EM_H8_500
: return "Renesas H8/500";
1677 case EM_IA_64
: return "Intel IA-64";
1678 case EM_MIPS_X
: return "Stanford MIPS-X";
1679 case EM_COLDFIRE
: return "Motorola Coldfire";
1680 case EM_68HC12
: return "Motorola M68HC12";
1681 case EM_ALPHA
: return "Alpha";
1682 case EM_CYGNUS_D10V
:
1683 case EM_D10V
: return "d10v";
1684 case EM_CYGNUS_D30V
:
1685 case EM_D30V
: return "d30v";
1686 case EM_CYGNUS_M32R
:
1687 case EM_M32R
: return "Renesas M32R (formerly Mitsubishi M32r)";
1688 case EM_CYGNUS_V850
:
1689 case EM_V850
: return "NEC v850";
1690 case EM_CYGNUS_MN10300
:
1691 case EM_MN10300
: return "mn10300";
1692 case EM_CYGNUS_MN10200
:
1693 case EM_MN10200
: return "mn10200";
1694 case EM_CYGNUS_FR30
:
1695 case EM_FR30
: return "Fujitsu FR30";
1696 case EM_CYGNUS_FRV
: return "Fujitsu FR-V";
1698 case EM_PJ
: return "picoJava";
1699 case EM_MMA
: return "Fujitsu Multimedia Accelerator";
1700 case EM_PCP
: return "Siemens PCP";
1701 case EM_NCPU
: return "Sony nCPU embedded RISC processor";
1702 case EM_NDR1
: return "Denso NDR1 microprocesspr";
1703 case EM_STARCORE
: return "Motorola Star*Core processor";
1704 case EM_ME16
: return "Toyota ME16 processor";
1705 case EM_ST100
: return "STMicroelectronics ST100 processor";
1706 case EM_TINYJ
: return "Advanced Logic Corp. TinyJ embedded processor";
1707 case EM_FX66
: return "Siemens FX66 microcontroller";
1708 case EM_ST9PLUS
: return "STMicroelectronics ST9+ 8/16 bit microcontroller";
1709 case EM_ST7
: return "STMicroelectronics ST7 8-bit microcontroller";
1710 case EM_68HC16
: return "Motorola MC68HC16 Microcontroller";
1711 case EM_68HC11
: return "Motorola MC68HC11 Microcontroller";
1712 case EM_68HC08
: return "Motorola MC68HC08 Microcontroller";
1713 case EM_68HC05
: return "Motorola MC68HC05 Microcontroller";
1714 case EM_SVX
: return "Silicon Graphics SVx";
1715 case EM_ST19
: return "STMicroelectronics ST19 8-bit microcontroller";
1716 case EM_VAX
: return "Digital VAX";
1718 case EM_AVR
: return "Atmel AVR 8-bit microcontroller";
1719 case EM_CRIS
: return "Axis Communications 32-bit embedded processor";
1720 case EM_JAVELIN
: return "Infineon Technologies 32-bit embedded cpu";
1721 case EM_FIREPATH
: return "Element 14 64-bit DSP processor";
1722 case EM_ZSP
: return "LSI Logic's 16-bit DSP processor";
1723 case EM_MMIX
: return "Donald Knuth's educational 64-bit processor";
1724 case EM_HUANY
: return "Harvard Universitys's machine-independent object format";
1725 case EM_PRISM
: return "Vitesse Prism";
1726 case EM_X86_64
: return "Advanced Micro Devices X86-64";
1728 case EM_S390
: return "IBM S/390";
1729 case EM_SCORE
: return "SUNPLUS S+Core";
1730 case EM_XSTORMY16
: return "Sanyo Xstormy16 CPU core";
1732 case EM_OR32
: return "OpenRISC";
1733 case EM_CRX
: return "National Semiconductor CRX microprocessor";
1734 case EM_DLX
: return "OpenDLX";
1736 case EM_IP2K
: return "Ubicom IP2xxx 8-bit microcontrollers";
1737 case EM_IQ2000
: return "Vitesse IQ2000";
1739 case EM_XTENSA
: return "Tensilica Xtensa Processor";
1740 case EM_M32C
: return "Renesas M32c";
1741 case EM_MT
: return "Morpho Techologies MT processor";
1742 case EM_BLACKFIN
: return "Analog Devices Blackfin";
1743 case EM_NIOS32
: return "Altera Nios";
1744 case EM_ALTERA_NIOS2
: return "Altera Nios II";
1745 case EM_XC16X
: return "Infineon Technologies xc16x";
1747 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), e_machine
);
1753 decode_ARM_machine_flags (unsigned e_flags
, char buf
[])
1758 eabi
= EF_ARM_EABI_VERSION (e_flags
);
1759 e_flags
&= ~ EF_ARM_EABIMASK
;
1761 /* Handle "generic" ARM flags. */
1762 if (e_flags
& EF_ARM_RELEXEC
)
1764 strcat (buf
, ", relocatable executable");
1765 e_flags
&= ~ EF_ARM_RELEXEC
;
1768 if (e_flags
& EF_ARM_HASENTRY
)
1770 strcat (buf
, ", has entry point");
1771 e_flags
&= ~ EF_ARM_HASENTRY
;
1774 /* Now handle EABI specific flags. */
1778 strcat (buf
, ", <unrecognized EABI>");
1783 case EF_ARM_EABI_VER1
:
1784 strcat (buf
, ", Version1 EABI");
1789 /* Process flags one bit at a time. */
1790 flag
= e_flags
& - e_flags
;
1795 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1796 strcat (buf
, ", sorted symbol tables");
1806 case EF_ARM_EABI_VER2
:
1807 strcat (buf
, ", Version2 EABI");
1812 /* Process flags one bit at a time. */
1813 flag
= e_flags
& - e_flags
;
1818 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1819 strcat (buf
, ", sorted symbol tables");
1822 case EF_ARM_DYNSYMSUSESEGIDX
:
1823 strcat (buf
, ", dynamic symbols use segment index");
1826 case EF_ARM_MAPSYMSFIRST
:
1827 strcat (buf
, ", mapping symbols precede others");
1837 case EF_ARM_EABI_VER3
:
1838 strcat (buf
, ", Version3 EABI");
1841 case EF_ARM_EABI_VER4
:
1842 strcat (buf
, ", Version4 EABI");
1845 case EF_ARM_EABI_VER5
:
1846 strcat (buf
, ", Version5 EABI");
1852 /* Process flags one bit at a time. */
1853 flag
= e_flags
& - e_flags
;
1859 strcat (buf
, ", BE8");
1863 strcat (buf
, ", LE8");
1873 case EF_ARM_EABI_UNKNOWN
:
1874 strcat (buf
, ", GNU EABI");
1879 /* Process flags one bit at a time. */
1880 flag
= e_flags
& - e_flags
;
1885 case EF_ARM_INTERWORK
:
1886 strcat (buf
, ", interworking enabled");
1889 case EF_ARM_APCS_26
:
1890 strcat (buf
, ", uses APCS/26");
1893 case EF_ARM_APCS_FLOAT
:
1894 strcat (buf
, ", uses APCS/float");
1898 strcat (buf
, ", position independent");
1902 strcat (buf
, ", 8 bit structure alignment");
1905 case EF_ARM_NEW_ABI
:
1906 strcat (buf
, ", uses new ABI");
1909 case EF_ARM_OLD_ABI
:
1910 strcat (buf
, ", uses old ABI");
1913 case EF_ARM_SOFT_FLOAT
:
1914 strcat (buf
, ", software FP");
1917 case EF_ARM_VFP_FLOAT
:
1918 strcat (buf
, ", VFP");
1921 case EF_ARM_MAVERICK_FLOAT
:
1922 strcat (buf
, ", Maverick FP");
1933 strcat (buf
,", <unknown>");
1937 get_machine_flags (unsigned e_flags
, unsigned e_machine
)
1939 static char buf
[1024];
1951 decode_ARM_machine_flags (e_flags
, buf
);
1955 switch (e_flags
& EF_FRV_CPU_MASK
)
1957 case EF_FRV_CPU_GENERIC
:
1961 strcat (buf
, ", fr???");
1964 case EF_FRV_CPU_FR300
:
1965 strcat (buf
, ", fr300");
1968 case EF_FRV_CPU_FR400
:
1969 strcat (buf
, ", fr400");
1971 case EF_FRV_CPU_FR405
:
1972 strcat (buf
, ", fr405");
1975 case EF_FRV_CPU_FR450
:
1976 strcat (buf
, ", fr450");
1979 case EF_FRV_CPU_FR500
:
1980 strcat (buf
, ", fr500");
1982 case EF_FRV_CPU_FR550
:
1983 strcat (buf
, ", fr550");
1986 case EF_FRV_CPU_SIMPLE
:
1987 strcat (buf
, ", simple");
1989 case EF_FRV_CPU_TOMCAT
:
1990 strcat (buf
, ", tomcat");
1996 if (e_flags
& EF_M68K_CPU32
)
1997 strcat (buf
, ", cpu32");
1998 if (e_flags
& EF_M68K_M68000
)
1999 strcat (buf
, ", m68000");
2000 if (e_flags
& EF_M68K_ISA_MASK
)
2002 char const *isa
= _("unknown");
2003 char const *mac
= _("unknown mac");
2004 char const *additional
= NULL
;
2006 switch (e_flags
& EF_M68K_ISA_MASK
)
2008 case EF_M68K_ISA_A_NODIV
:
2010 additional
= ", nodiv";
2015 case EF_M68K_ISA_A_PLUS
:
2018 case EF_M68K_ISA_B_NOUSP
:
2020 additional
= ", nousp";
2026 strcat (buf
, ", cf, isa ");
2029 strcat (buf
, additional
);
2030 if (e_flags
& EF_M68K_FLOAT
)
2031 strcat (buf
, ", float");
2032 switch (e_flags
& EF_M68K_MAC_MASK
)
2053 if (e_flags
& EF_PPC_EMB
)
2054 strcat (buf
, ", emb");
2056 if (e_flags
& EF_PPC_RELOCATABLE
)
2057 strcat (buf
, ", relocatable");
2059 if (e_flags
& EF_PPC_RELOCATABLE_LIB
)
2060 strcat (buf
, ", relocatable-lib");
2064 case EM_CYGNUS_V850
:
2065 switch (e_flags
& EF_V850_ARCH
)
2068 strcat (buf
, ", v850e1");
2071 strcat (buf
, ", v850e");
2074 strcat (buf
, ", v850");
2077 strcat (buf
, ", unknown v850 architecture variant");
2083 case EM_CYGNUS_M32R
:
2084 if ((e_flags
& EF_M32R_ARCH
) == E_M32R_ARCH
)
2085 strcat (buf
, ", m32r");
2089 case EM_MIPS_RS3_LE
:
2090 if (e_flags
& EF_MIPS_NOREORDER
)
2091 strcat (buf
, ", noreorder");
2093 if (e_flags
& EF_MIPS_PIC
)
2094 strcat (buf
, ", pic");
2096 if (e_flags
& EF_MIPS_CPIC
)
2097 strcat (buf
, ", cpic");
2099 if (e_flags
& EF_MIPS_UCODE
)
2100 strcat (buf
, ", ugen_reserved");
2102 if (e_flags
& EF_MIPS_ABI2
)
2103 strcat (buf
, ", abi2");
2105 if (e_flags
& EF_MIPS_OPTIONS_FIRST
)
2106 strcat (buf
, ", odk first");
2108 if (e_flags
& EF_MIPS_32BITMODE
)
2109 strcat (buf
, ", 32bitmode");
2111 switch ((e_flags
& EF_MIPS_MACH
))
2113 case E_MIPS_MACH_3900
: strcat (buf
, ", 3900"); break;
2114 case E_MIPS_MACH_4010
: strcat (buf
, ", 4010"); break;
2115 case E_MIPS_MACH_4100
: strcat (buf
, ", 4100"); break;
2116 case E_MIPS_MACH_4111
: strcat (buf
, ", 4111"); break;
2117 case E_MIPS_MACH_4120
: strcat (buf
, ", 4120"); break;
2118 case E_MIPS_MACH_4650
: strcat (buf
, ", 4650"); break;
2119 case E_MIPS_MACH_5400
: strcat (buf
, ", 5400"); break;
2120 case E_MIPS_MACH_5500
: strcat (buf
, ", 5500"); break;
2121 case E_MIPS_MACH_SB1
: strcat (buf
, ", sb1"); break;
2122 case E_MIPS_MACH_9000
: strcat (buf
, ", 9000"); break;
2124 /* We simply ignore the field in this case to avoid confusion:
2125 MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
2128 default: strcat (buf
, ", unknown CPU"); break;
2131 switch ((e_flags
& EF_MIPS_ABI
))
2133 case E_MIPS_ABI_O32
: strcat (buf
, ", o32"); break;
2134 case E_MIPS_ABI_O64
: strcat (buf
, ", o64"); break;
2135 case E_MIPS_ABI_EABI32
: strcat (buf
, ", eabi32"); break;
2136 case E_MIPS_ABI_EABI64
: strcat (buf
, ", eabi64"); break;
2138 /* We simply ignore the field in this case to avoid confusion:
2139 MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension.
2140 This means it is likely to be an o32 file, but not for
2143 default: strcat (buf
, ", unknown ABI"); break;
2146 if (e_flags
& EF_MIPS_ARCH_ASE_MDMX
)
2147 strcat (buf
, ", mdmx");
2149 if (e_flags
& EF_MIPS_ARCH_ASE_M16
)
2150 strcat (buf
, ", mips16");
2152 switch ((e_flags
& EF_MIPS_ARCH
))
2154 case E_MIPS_ARCH_1
: strcat (buf
, ", mips1"); break;
2155 case E_MIPS_ARCH_2
: strcat (buf
, ", mips2"); break;
2156 case E_MIPS_ARCH_3
: strcat (buf
, ", mips3"); break;
2157 case E_MIPS_ARCH_4
: strcat (buf
, ", mips4"); break;
2158 case E_MIPS_ARCH_5
: strcat (buf
, ", mips5"); break;
2159 case E_MIPS_ARCH_32
: strcat (buf
, ", mips32"); break;
2160 case E_MIPS_ARCH_32R2
: strcat (buf
, ", mips32r2"); break;
2161 case E_MIPS_ARCH_64
: strcat (buf
, ", mips64"); break;
2162 case E_MIPS_ARCH_64R2
: strcat (buf
, ", mips64r2"); break;
2163 default: strcat (buf
, ", unknown ISA"); break;
2169 switch ((e_flags
& EF_SH_MACH_MASK
))
2171 case EF_SH1
: strcat (buf
, ", sh1"); break;
2172 case EF_SH2
: strcat (buf
, ", sh2"); break;
2173 case EF_SH3
: strcat (buf
, ", sh3"); break;
2174 case EF_SH_DSP
: strcat (buf
, ", sh-dsp"); break;
2175 case EF_SH3_DSP
: strcat (buf
, ", sh3-dsp"); break;
2176 case EF_SH4AL_DSP
: strcat (buf
, ", sh4al-dsp"); break;
2177 case EF_SH3E
: strcat (buf
, ", sh3e"); break;
2178 case EF_SH4
: strcat (buf
, ", sh4"); break;
2179 case EF_SH5
: strcat (buf
, ", sh5"); break;
2180 case EF_SH2E
: strcat (buf
, ", sh2e"); break;
2181 case EF_SH4A
: strcat (buf
, ", sh4a"); break;
2182 case EF_SH2A
: strcat (buf
, ", sh2a"); break;
2183 case EF_SH4_NOFPU
: strcat (buf
, ", sh4-nofpu"); break;
2184 case EF_SH4A_NOFPU
: strcat (buf
, ", sh4a-nofpu"); break;
2185 case EF_SH2A_NOFPU
: strcat (buf
, ", sh2a-nofpu"); break;
2186 case EF_SH3_NOMMU
: strcat (buf
, ", sh3-nommu"); break;
2187 case EF_SH4_NOMMU_NOFPU
: strcat (buf
, ", sh4-nommu-nofpu"); break;
2188 case EF_SH2A_SH4_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh4-nommu-nofpu"); break;
2189 case EF_SH2A_SH3_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh3-nommu"); break;
2190 case EF_SH2A_SH4
: strcat (buf
, ", sh2a-or-sh4"); break;
2191 case EF_SH2A_SH3E
: strcat (buf
, ", sh2a-or-sh3e"); break;
2192 default: strcat (buf
, ", unknown ISA"); break;
2198 if (e_flags
& EF_SPARC_32PLUS
)
2199 strcat (buf
, ", v8+");
2201 if (e_flags
& EF_SPARC_SUN_US1
)
2202 strcat (buf
, ", ultrasparcI");
2204 if (e_flags
& EF_SPARC_SUN_US3
)
2205 strcat (buf
, ", ultrasparcIII");
2207 if (e_flags
& EF_SPARC_HAL_R1
)
2208 strcat (buf
, ", halr1");
2210 if (e_flags
& EF_SPARC_LEDATA
)
2211 strcat (buf
, ", ledata");
2213 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_TSO
)
2214 strcat (buf
, ", tso");
2216 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_PSO
)
2217 strcat (buf
, ", pso");
2219 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_RMO
)
2220 strcat (buf
, ", rmo");
2224 switch (e_flags
& EF_PARISC_ARCH
)
2226 case EFA_PARISC_1_0
:
2227 strcpy (buf
, ", PA-RISC 1.0");
2229 case EFA_PARISC_1_1
:
2230 strcpy (buf
, ", PA-RISC 1.1");
2232 case EFA_PARISC_2_0
:
2233 strcpy (buf
, ", PA-RISC 2.0");
2238 if (e_flags
& EF_PARISC_TRAPNIL
)
2239 strcat (buf
, ", trapnil");
2240 if (e_flags
& EF_PARISC_EXT
)
2241 strcat (buf
, ", ext");
2242 if (e_flags
& EF_PARISC_LSB
)
2243 strcat (buf
, ", lsb");
2244 if (e_flags
& EF_PARISC_WIDE
)
2245 strcat (buf
, ", wide");
2246 if (e_flags
& EF_PARISC_NO_KABP
)
2247 strcat (buf
, ", no kabp");
2248 if (e_flags
& EF_PARISC_LAZYSWAP
)
2249 strcat (buf
, ", lazyswap");
2254 if ((e_flags
& EF_PICOJAVA_NEWCALLS
) == EF_PICOJAVA_NEWCALLS
)
2255 strcat (buf
, ", new calling convention");
2257 if ((e_flags
& EF_PICOJAVA_GNUCALLS
) == EF_PICOJAVA_GNUCALLS
)
2258 strcat (buf
, ", gnu calling convention");
2262 if ((e_flags
& EF_IA_64_ABI64
))
2263 strcat (buf
, ", 64-bit");
2265 strcat (buf
, ", 32-bit");
2266 if ((e_flags
& EF_IA_64_REDUCEDFP
))
2267 strcat (buf
, ", reduced fp model");
2268 if ((e_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
))
2269 strcat (buf
, ", no function descriptors, constant gp");
2270 else if ((e_flags
& EF_IA_64_CONS_GP
))
2271 strcat (buf
, ", constant gp");
2272 if ((e_flags
& EF_IA_64_ABSOLUTE
))
2273 strcat (buf
, ", absolute");
2277 if ((e_flags
& EF_VAX_NONPIC
))
2278 strcat (buf
, ", non-PIC");
2279 if ((e_flags
& EF_VAX_DFLOAT
))
2280 strcat (buf
, ", D-Float");
2281 if ((e_flags
& EF_VAX_GFLOAT
))
2282 strcat (buf
, ", G-Float");
2291 get_osabi_name (unsigned int osabi
)
2293 static char buff
[32];
2297 case ELFOSABI_NONE
: return "UNIX - System V";
2298 case ELFOSABI_HPUX
: return "UNIX - HP-UX";
2299 case ELFOSABI_NETBSD
: return "UNIX - NetBSD";
2300 case ELFOSABI_LINUX
: return "UNIX - Linux";
2301 case ELFOSABI_HURD
: return "GNU/Hurd";
2302 case ELFOSABI_SOLARIS
: return "UNIX - Solaris";
2303 case ELFOSABI_AIX
: return "UNIX - AIX";
2304 case ELFOSABI_IRIX
: return "UNIX - IRIX";
2305 case ELFOSABI_FREEBSD
: return "UNIX - FreeBSD";
2306 case ELFOSABI_TRU64
: return "UNIX - TRU64";
2307 case ELFOSABI_MODESTO
: return "Novell - Modesto";
2308 case ELFOSABI_OPENBSD
: return "UNIX - OpenBSD";
2309 case ELFOSABI_OPENVMS
: return "VMS - OpenVMS";
2310 case ELFOSABI_NSK
: return "HP - Non-Stop Kernel";
2311 case ELFOSABI_AROS
: return "Amiga Research OS";
2312 case ELFOSABI_STANDALONE
: return _("Standalone App");
2313 case ELFOSABI_ARM
: return "ARM";
2315 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), osabi
);
2321 get_arm_segment_type (unsigned long type
)
2335 get_mips_segment_type (unsigned long type
)
2339 case PT_MIPS_REGINFO
:
2341 case PT_MIPS_RTPROC
:
2343 case PT_MIPS_OPTIONS
:
2353 get_parisc_segment_type (unsigned long type
)
2357 case PT_HP_TLS
: return "HP_TLS";
2358 case PT_HP_CORE_NONE
: return "HP_CORE_NONE";
2359 case PT_HP_CORE_VERSION
: return "HP_CORE_VERSION";
2360 case PT_HP_CORE_KERNEL
: return "HP_CORE_KERNEL";
2361 case PT_HP_CORE_COMM
: return "HP_CORE_COMM";
2362 case PT_HP_CORE_PROC
: return "HP_CORE_PROC";
2363 case PT_HP_CORE_LOADABLE
: return "HP_CORE_LOADABLE";
2364 case PT_HP_CORE_STACK
: return "HP_CORE_STACK";
2365 case PT_HP_CORE_SHM
: return "HP_CORE_SHM";
2366 case PT_HP_CORE_MMF
: return "HP_CORE_MMF";
2367 case PT_HP_PARALLEL
: return "HP_PARALLEL";
2368 case PT_HP_FASTBIND
: return "HP_FASTBIND";
2369 case PT_HP_OPT_ANNOT
: return "HP_OPT_ANNOT";
2370 case PT_HP_HSL_ANNOT
: return "HP_HSL_ANNOT";
2371 case PT_HP_STACK
: return "HP_STACK";
2372 case PT_HP_CORE_UTSNAME
: return "HP_CORE_UTSNAME";
2373 case PT_PARISC_ARCHEXT
: return "PARISC_ARCHEXT";
2374 case PT_PARISC_UNWIND
: return "PARISC_UNWIND";
2375 case PT_PARISC_WEAKORDER
: return "PARISC_WEAKORDER";
2384 get_ia64_segment_type (unsigned long type
)
2388 case PT_IA_64_ARCHEXT
: return "IA_64_ARCHEXT";
2389 case PT_IA_64_UNWIND
: return "IA_64_UNWIND";
2390 case PT_HP_TLS
: return "HP_TLS";
2391 case PT_IA_64_HP_OPT_ANOT
: return "HP_OPT_ANNOT";
2392 case PT_IA_64_HP_HSL_ANOT
: return "HP_HSL_ANNOT";
2393 case PT_IA_64_HP_STACK
: return "HP_STACK";
2402 get_segment_type (unsigned long p_type
)
2404 static char buff
[32];
2408 case PT_NULL
: return "NULL";
2409 case PT_LOAD
: return "LOAD";
2410 case PT_DYNAMIC
: return "DYNAMIC";
2411 case PT_INTERP
: return "INTERP";
2412 case PT_NOTE
: return "NOTE";
2413 case PT_SHLIB
: return "SHLIB";
2414 case PT_PHDR
: return "PHDR";
2415 case PT_TLS
: return "TLS";
2417 case PT_GNU_EH_FRAME
:
2418 return "GNU_EH_FRAME";
2419 case PT_GNU_STACK
: return "GNU_STACK";
2420 case PT_GNU_RELRO
: return "GNU_RELRO";
2423 if ((p_type
>= PT_LOPROC
) && (p_type
<= PT_HIPROC
))
2427 switch (elf_header
.e_machine
)
2430 result
= get_arm_segment_type (p_type
);
2433 case EM_MIPS_RS3_LE
:
2434 result
= get_mips_segment_type (p_type
);
2437 result
= get_parisc_segment_type (p_type
);
2440 result
= get_ia64_segment_type (p_type
);
2450 sprintf (buff
, "LOPROC+%lx", p_type
- PT_LOPROC
);
2452 else if ((p_type
>= PT_LOOS
) && (p_type
<= PT_HIOS
))
2456 switch (elf_header
.e_machine
)
2459 result
= get_parisc_segment_type (p_type
);
2462 result
= get_ia64_segment_type (p_type
);
2472 sprintf (buff
, "LOOS+%lx", p_type
- PT_LOOS
);
2475 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), p_type
);
2482 get_mips_section_type_name (unsigned int sh_type
)
2486 case SHT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
2487 case SHT_MIPS_MSYM
: return "MIPS_MSYM";
2488 case SHT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
2489 case SHT_MIPS_GPTAB
: return "MIPS_GPTAB";
2490 case SHT_MIPS_UCODE
: return "MIPS_UCODE";
2491 case SHT_MIPS_DEBUG
: return "MIPS_DEBUG";
2492 case SHT_MIPS_REGINFO
: return "MIPS_REGINFO";
2493 case SHT_MIPS_PACKAGE
: return "MIPS_PACKAGE";
2494 case SHT_MIPS_PACKSYM
: return "MIPS_PACKSYM";
2495 case SHT_MIPS_RELD
: return "MIPS_RELD";
2496 case SHT_MIPS_IFACE
: return "MIPS_IFACE";
2497 case SHT_MIPS_CONTENT
: return "MIPS_CONTENT";
2498 case SHT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
2499 case SHT_MIPS_SHDR
: return "MIPS_SHDR";
2500 case SHT_MIPS_FDESC
: return "MIPS_FDESC";
2501 case SHT_MIPS_EXTSYM
: return "MIPS_EXTSYM";
2502 case SHT_MIPS_DENSE
: return "MIPS_DENSE";
2503 case SHT_MIPS_PDESC
: return "MIPS_PDESC";
2504 case SHT_MIPS_LOCSYM
: return "MIPS_LOCSYM";
2505 case SHT_MIPS_AUXSYM
: return "MIPS_AUXSYM";
2506 case SHT_MIPS_OPTSYM
: return "MIPS_OPTSYM";
2507 case SHT_MIPS_LOCSTR
: return "MIPS_LOCSTR";
2508 case SHT_MIPS_LINE
: return "MIPS_LINE";
2509 case SHT_MIPS_RFDESC
: return "MIPS_RFDESC";
2510 case SHT_MIPS_DELTASYM
: return "MIPS_DELTASYM";
2511 case SHT_MIPS_DELTAINST
: return "MIPS_DELTAINST";
2512 case SHT_MIPS_DELTACLASS
: return "MIPS_DELTACLASS";
2513 case SHT_MIPS_DWARF
: return "MIPS_DWARF";
2514 case SHT_MIPS_DELTADECL
: return "MIPS_DELTADECL";
2515 case SHT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
2516 case SHT_MIPS_EVENTS
: return "MIPS_EVENTS";
2517 case SHT_MIPS_TRANSLATE
: return "MIPS_TRANSLATE";
2518 case SHT_MIPS_PIXIE
: return "MIPS_PIXIE";
2519 case SHT_MIPS_XLATE
: return "MIPS_XLATE";
2520 case SHT_MIPS_XLATE_DEBUG
: return "MIPS_XLATE_DEBUG";
2521 case SHT_MIPS_WHIRL
: return "MIPS_WHIRL";
2522 case SHT_MIPS_EH_REGION
: return "MIPS_EH_REGION";
2523 case SHT_MIPS_XLATE_OLD
: return "MIPS_XLATE_OLD";
2524 case SHT_MIPS_PDR_EXCEPTION
: return "MIPS_PDR_EXCEPTION";
2532 get_parisc_section_type_name (unsigned int sh_type
)
2536 case SHT_PARISC_EXT
: return "PARISC_EXT";
2537 case SHT_PARISC_UNWIND
: return "PARISC_UNWIND";
2538 case SHT_PARISC_DOC
: return "PARISC_DOC";
2539 case SHT_PARISC_ANNOT
: return "PARISC_ANNOT";
2540 case SHT_PARISC_SYMEXTN
: return "PARISC_SYMEXTN";
2541 case SHT_PARISC_STUBS
: return "PARISC_STUBS";
2542 case SHT_PARISC_DLKM
: return "PARISC_DLKM";
2550 get_ia64_section_type_name (unsigned int sh_type
)
2552 /* If the top 8 bits are 0x78 the next 8 are the os/abi ID. */
2553 if ((sh_type
& 0xFF000000) == SHT_IA_64_LOPSREG
)
2554 return get_osabi_name ((sh_type
& 0x00FF0000) >> 16);
2558 case SHT_IA_64_EXT
: return "IA_64_EXT";
2559 case SHT_IA_64_UNWIND
: return "IA_64_UNWIND";
2560 case SHT_IA_64_PRIORITY_INIT
: return "IA_64_PRIORITY_INIT";
2568 get_x86_64_section_type_name (unsigned int sh_type
)
2572 case SHT_X86_64_UNWIND
: return "X86_64_UNWIND";
2580 get_arm_section_type_name (unsigned int sh_type
)
2586 case SHT_ARM_PREEMPTMAP
:
2587 return "ARM_PREEMPTMAP";
2588 case SHT_ARM_ATTRIBUTES
:
2589 return "ARM_ATTRIBUTES";
2597 get_section_type_name (unsigned int sh_type
)
2599 static char buff
[32];
2603 case SHT_NULL
: return "NULL";
2604 case SHT_PROGBITS
: return "PROGBITS";
2605 case SHT_SYMTAB
: return "SYMTAB";
2606 case SHT_STRTAB
: return "STRTAB";
2607 case SHT_RELA
: return "RELA";
2608 case SHT_HASH
: return "HASH";
2609 case SHT_DYNAMIC
: return "DYNAMIC";
2610 case SHT_NOTE
: return "NOTE";
2611 case SHT_NOBITS
: return "NOBITS";
2612 case SHT_REL
: return "REL";
2613 case SHT_SHLIB
: return "SHLIB";
2614 case SHT_DYNSYM
: return "DYNSYM";
2615 case SHT_INIT_ARRAY
: return "INIT_ARRAY";
2616 case SHT_FINI_ARRAY
: return "FINI_ARRAY";
2617 case SHT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
2618 case SHT_GNU_HASH
: return "GNU_HASH";
2619 case SHT_GROUP
: return "GROUP";
2620 case SHT_SYMTAB_SHNDX
: return "SYMTAB SECTION INDICIES";
2621 case SHT_GNU_verdef
: return "VERDEF";
2622 case SHT_GNU_verneed
: return "VERNEED";
2623 case SHT_GNU_versym
: return "VERSYM";
2624 case 0x6ffffff0: return "VERSYM";
2625 case 0x6ffffffc: return "VERDEF";
2626 case 0x7ffffffd: return "AUXILIARY";
2627 case 0x7fffffff: return "FILTER";
2628 case SHT_GNU_LIBLIST
: return "GNU_LIBLIST";
2631 if ((sh_type
>= SHT_LOPROC
) && (sh_type
<= SHT_HIPROC
))
2635 switch (elf_header
.e_machine
)
2638 case EM_MIPS_RS3_LE
:
2639 result
= get_mips_section_type_name (sh_type
);
2642 result
= get_parisc_section_type_name (sh_type
);
2645 result
= get_ia64_section_type_name (sh_type
);
2648 result
= get_x86_64_section_type_name (sh_type
);
2651 result
= get_arm_section_type_name (sh_type
);
2661 sprintf (buff
, "LOPROC+%x", sh_type
- SHT_LOPROC
);
2663 else if ((sh_type
>= SHT_LOOS
) && (sh_type
<= SHT_HIOS
))
2664 sprintf (buff
, "LOOS+%x", sh_type
- SHT_LOOS
);
2665 else if ((sh_type
>= SHT_LOUSER
) && (sh_type
<= SHT_HIUSER
))
2666 sprintf (buff
, "LOUSER+%x", sh_type
- SHT_LOUSER
);
2668 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), sh_type
);
2674 #define OPTION_DEBUG_DUMP 512
2676 static struct option options
[] =
2678 {"all", no_argument
, 0, 'a'},
2679 {"file-header", no_argument
, 0, 'h'},
2680 {"program-headers", no_argument
, 0, 'l'},
2681 {"headers", no_argument
, 0, 'e'},
2682 {"histogram", no_argument
, 0, 'I'},
2683 {"segments", no_argument
, 0, 'l'},
2684 {"sections", no_argument
, 0, 'S'},
2685 {"section-headers", no_argument
, 0, 'S'},
2686 {"section-groups", no_argument
, 0, 'g'},
2687 {"section-details", no_argument
, 0, 't'},
2688 {"full-section-name",no_argument
, 0, 'N'},
2689 {"symbols", no_argument
, 0, 's'},
2690 {"syms", no_argument
, 0, 's'},
2691 {"relocs", no_argument
, 0, 'r'},
2692 {"notes", no_argument
, 0, 'n'},
2693 {"dynamic", no_argument
, 0, 'd'},
2694 {"arch-specific", no_argument
, 0, 'A'},
2695 {"version-info", no_argument
, 0, 'V'},
2696 {"use-dynamic", no_argument
, 0, 'D'},
2697 {"hex-dump", required_argument
, 0, 'x'},
2698 {"debug-dump", optional_argument
, 0, OPTION_DEBUG_DUMP
},
2699 {"unwind", no_argument
, 0, 'u'},
2700 #ifdef SUPPORT_DISASSEMBLY
2701 {"instruction-dump", required_argument
, 0, 'i'},
2704 {"version", no_argument
, 0, 'v'},
2705 {"wide", no_argument
, 0, 'W'},
2706 {"help", no_argument
, 0, 'H'},
2707 {0, no_argument
, 0, 0}
2713 fprintf (stdout
, _("Usage: readelf <option(s)> elf-file(s)\n"));
2714 fprintf (stdout
, _(" Display information about the contents of ELF format files\n"));
2715 fprintf (stdout
, _(" Options are:\n\
2716 -a --all Equivalent to: -h -l -S -s -r -d -V -A -I\n\
2717 -h --file-header Display the ELF file header\n\
2718 -l --program-headers Display the program headers\n\
2719 --segments An alias for --program-headers\n\
2720 -S --section-headers Display the sections' header\n\
2721 --sections An alias for --section-headers\n\
2722 -g --section-groups Display the section groups\n\
2723 -t --section-details Display the section details\n\
2724 -e --headers Equivalent to: -h -l -S\n\
2725 -s --syms Display the symbol table\n\
2726 --symbols An alias for --syms\n\
2727 -n --notes Display the core notes (if present)\n\
2728 -r --relocs Display the relocations (if present)\n\
2729 -u --unwind Display the unwind info (if present)\n\
2730 -d --dynamic Display the dynamic section (if present)\n\
2731 -V --version-info Display the version sections (if present)\n\
2732 -A --arch-specific Display architecture specific information (if any).\n\
2733 -D --use-dynamic Use the dynamic section info when displaying symbols\n\
2734 -x --hex-dump=<number> Dump the contents of section <number>\n\
2735 -w[liaprmfFsoR] or\n\
2736 --debug-dump[=line,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges]\n\
2737 Display the contents of DWARF2 debug sections\n"));
2738 #ifdef SUPPORT_DISASSEMBLY
2739 fprintf (stdout
, _("\
2740 -i --instruction-dump=<number>\n\
2741 Disassemble the contents of section <number>\n"));
2743 fprintf (stdout
, _("\
2744 -I --histogram Display histogram of bucket list lengths\n\
2745 -W --wide Allow output width to exceed 80 characters\n\
2746 @<file> Read options from <file>\n\
2747 -H --help Display this information\n\
2748 -v --version Display the version number of readelf\n"));
2749 fprintf (stdout
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
2754 /* Record the fact that the user wants the contents of section number
2755 SECTION to be displayed using the method(s) encoded as flags bits
2756 in TYPE. Note, TYPE can be zero if we are creating the array for
2760 request_dump (unsigned int section
, int type
)
2762 if (section
>= num_dump_sects
)
2764 char *new_dump_sects
;
2766 new_dump_sects
= calloc (section
+ 1, 1);
2768 if (new_dump_sects
== NULL
)
2769 error (_("Out of memory allocating dump request table."));
2772 /* Copy current flag settings. */
2773 memcpy (new_dump_sects
, dump_sects
, num_dump_sects
);
2777 dump_sects
= new_dump_sects
;
2778 num_dump_sects
= section
+ 1;
2783 dump_sects
[section
] |= type
;
2788 /* Request a dump by section name. */
2791 request_dump_byname (const char *section
, int type
)
2793 struct dump_list_entry
*new_request
;
2795 new_request
= malloc (sizeof (struct dump_list_entry
));
2797 error (_("Out of memory allocating dump request table."));
2799 new_request
->name
= strdup (section
);
2800 if (!new_request
->name
)
2801 error (_("Out of memory allocating dump request table."));
2803 new_request
->type
= type
;
2805 new_request
->next
= dump_sects_byname
;
2806 dump_sects_byname
= new_request
;
2810 parse_args (int argc
, char **argv
)
2817 while ((c
= getopt_long
2818 (argc
, argv
, "ersuahnldSDAINtgw::x:i:vVWH", options
, NULL
)) != EOF
)
2839 do_section_groups
++;
2847 do_section_groups
++;
2852 do_section_details
++;
2894 section
= strtoul (optarg
, & cp
, 0);
2895 if (! *cp
&& section
>= 0)
2896 request_dump (section
, HEX_DUMP
);
2898 request_dump_byname (optarg
, HEX_DUMP
);
2906 unsigned int index
= 0;
2910 while (optarg
[index
])
2911 switch (optarg
[index
++])
2920 do_debug_abbrevs
= 1;
2930 do_debug_pubnames
= 1;
2934 do_debug_aranges
= 1;
2938 do_debug_ranges
= 1;
2942 do_debug_frames_interp
= 1;
2944 do_debug_frames
= 1;
2949 do_debug_macinfo
= 1;
2963 warn (_("Unrecognized debug option '%s'\n"), optarg
);
2968 case OPTION_DEBUG_DUMP
:
2976 const char * option
;
2979 debug_dump_long_opts
;
2981 debug_dump_long_opts opts_table
[] =
2983 /* Please keep this table alpha- sorted. */
2984 { "Ranges", & do_debug_ranges
},
2985 { "abbrev", & do_debug_abbrevs
},
2986 { "aranges", & do_debug_aranges
},
2987 { "frames", & do_debug_frames
},
2988 { "frames-interp", & do_debug_frames_interp
},
2989 { "info", & do_debug_info
},
2990 { "line", & do_debug_lines
},
2991 { "loc", & do_debug_loc
},
2992 { "macro", & do_debug_macinfo
},
2993 { "pubnames", & do_debug_pubnames
},
2994 /* This entry is for compatability
2995 with earlier versions of readelf. */
2996 { "ranges", & do_debug_aranges
},
2997 { "str", & do_debug_str
},
3008 debug_dump_long_opts
* entry
;
3010 for (entry
= opts_table
; entry
->option
; entry
++)
3012 size_t len
= strlen (entry
->option
);
3014 if (strneq (p
, entry
->option
, len
)
3015 && (p
[len
] == ',' || p
[len
] == '\0'))
3017 * entry
->variable
= 1;
3019 /* The --debug-dump=frames-interp option also
3020 enables the --debug-dump=frames option. */
3021 if (do_debug_frames_interp
)
3022 do_debug_frames
= 1;
3029 if (entry
->option
== NULL
)
3031 warn (_("Unrecognized debug option '%s'\n"), p
);
3032 p
= strchr (p
, ',');
3042 #ifdef SUPPORT_DISASSEMBLY
3045 section
= strtoul (optarg
, & cp
, 0);
3046 if (! *cp
&& section
>= 0)
3048 request_dump (section
, DISASS_DUMP
);
3054 print_version (program_name
);
3063 #ifdef SUPPORT_DISASSEMBLY
3066 /* xgettext:c-format */
3067 error (_("Invalid option '-%c'\n"), c
);
3074 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
3075 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
3076 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
3077 && !do_section_groups
)
3081 warn (_("Nothing to do.\n"));
3087 get_elf_class (unsigned int elf_class
)
3089 static char buff
[32];
3093 case ELFCLASSNONE
: return _("none");
3094 case ELFCLASS32
: return "ELF32";
3095 case ELFCLASS64
: return "ELF64";
3097 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), elf_class
);
3103 get_data_encoding (unsigned int encoding
)
3105 static char buff
[32];
3109 case ELFDATANONE
: return _("none");
3110 case ELFDATA2LSB
: return _("2's complement, little endian");
3111 case ELFDATA2MSB
: return _("2's complement, big endian");
3113 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), encoding
);
3118 /* Decode the data held in 'elf_header'. */
3121 process_file_header (void)
3123 if ( elf_header
.e_ident
[EI_MAG0
] != ELFMAG0
3124 || elf_header
.e_ident
[EI_MAG1
] != ELFMAG1
3125 || elf_header
.e_ident
[EI_MAG2
] != ELFMAG2
3126 || elf_header
.e_ident
[EI_MAG3
] != ELFMAG3
)
3129 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
3137 printf (_("ELF Header:\n"));
3138 printf (_(" Magic: "));
3139 for (i
= 0; i
< EI_NIDENT
; i
++)
3140 printf ("%2.2x ", elf_header
.e_ident
[i
]);
3142 printf (_(" Class: %s\n"),
3143 get_elf_class (elf_header
.e_ident
[EI_CLASS
]));
3144 printf (_(" Data: %s\n"),
3145 get_data_encoding (elf_header
.e_ident
[EI_DATA
]));
3146 printf (_(" Version: %d %s\n"),
3147 elf_header
.e_ident
[EI_VERSION
],
3148 (elf_header
.e_ident
[EI_VERSION
] == EV_CURRENT
3150 : (elf_header
.e_ident
[EI_VERSION
] != EV_NONE
3153 printf (_(" OS/ABI: %s\n"),
3154 get_osabi_name (elf_header
.e_ident
[EI_OSABI
]));
3155 printf (_(" ABI Version: %d\n"),
3156 elf_header
.e_ident
[EI_ABIVERSION
]);
3157 printf (_(" Type: %s\n"),
3158 get_file_type (elf_header
.e_type
));
3159 printf (_(" Machine: %s\n"),
3160 get_machine_name (elf_header
.e_machine
));
3161 printf (_(" Version: 0x%lx\n"),
3162 (unsigned long) elf_header
.e_version
);
3164 printf (_(" Entry point address: "));
3165 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3166 printf (_("\n Start of program headers: "));
3167 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3168 printf (_(" (bytes into file)\n Start of section headers: "));
3169 print_vma ((bfd_vma
) elf_header
.e_shoff
, DEC
);
3170 printf (_(" (bytes into file)\n"));
3172 printf (_(" Flags: 0x%lx%s\n"),
3173 (unsigned long) elf_header
.e_flags
,
3174 get_machine_flags (elf_header
.e_flags
, elf_header
.e_machine
));
3175 printf (_(" Size of this header: %ld (bytes)\n"),
3176 (long) elf_header
.e_ehsize
);
3177 printf (_(" Size of program headers: %ld (bytes)\n"),
3178 (long) elf_header
.e_phentsize
);
3179 printf (_(" Number of program headers: %ld\n"),
3180 (long) elf_header
.e_phnum
);
3181 printf (_(" Size of section headers: %ld (bytes)\n"),
3182 (long) elf_header
.e_shentsize
);
3183 printf (_(" Number of section headers: %ld"),
3184 (long) elf_header
.e_shnum
);
3185 if (section_headers
!= NULL
&& elf_header
.e_shnum
== 0)
3186 printf (" (%ld)", (long) section_headers
[0].sh_size
);
3187 putc ('\n', stdout
);
3188 printf (_(" Section header string table index: %ld"),
3189 (long) elf_header
.e_shstrndx
);
3190 if (section_headers
!= NULL
&& elf_header
.e_shstrndx
== SHN_XINDEX
)
3191 printf (" (%ld)", (long) section_headers
[0].sh_link
);
3192 else if (elf_header
.e_shstrndx
!= SHN_UNDEF
3193 && (elf_header
.e_shstrndx
>= elf_header
.e_shnum
3194 || (elf_header
.e_shstrndx
>= SHN_LORESERVE
3195 && elf_header
.e_shstrndx
<= SHN_HIRESERVE
)))
3196 printf (" <corrupt: out of range>");
3197 putc ('\n', stdout
);
3200 if (section_headers
!= NULL
)
3202 if (elf_header
.e_shnum
== 0)
3203 elf_header
.e_shnum
= section_headers
[0].sh_size
;
3204 if (elf_header
.e_shstrndx
== SHN_XINDEX
)
3205 elf_header
.e_shstrndx
= section_headers
[0].sh_link
;
3206 else if (elf_header
.e_shstrndx
!= SHN_UNDEF
3207 && (elf_header
.e_shstrndx
>= elf_header
.e_shnum
3208 || (elf_header
.e_shstrndx
>= SHN_LORESERVE
3209 && elf_header
.e_shstrndx
<= SHN_HIRESERVE
)))
3210 elf_header
.e_shstrndx
= SHN_UNDEF
;
3211 free (section_headers
);
3212 section_headers
= NULL
;
3220 get_32bit_program_headers (FILE *file
, Elf_Internal_Phdr
*program_headers
)
3222 Elf32_External_Phdr
*phdrs
;
3223 Elf32_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_offset
= BYTE_GET (external
->p_offset
);
3239 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
3240 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
3241 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
3242 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
3243 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3244 internal
->p_align
= BYTE_GET (external
->p_align
);
3253 get_64bit_program_headers (FILE *file
, Elf_Internal_Phdr
*program_headers
)
3255 Elf64_External_Phdr
*phdrs
;
3256 Elf64_External_Phdr
*external
;
3257 Elf_Internal_Phdr
*internal
;
3260 phdrs
= get_data (NULL
, file
, elf_header
.e_phoff
,
3261 elf_header
.e_phentsize
, elf_header
.e_phnum
,
3262 _("program headers"));
3266 for (i
= 0, internal
= program_headers
, external
= phdrs
;
3267 i
< elf_header
.e_phnum
;
3268 i
++, internal
++, external
++)
3270 internal
->p_type
= BYTE_GET (external
->p_type
);
3271 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3272 internal
->p_offset
= BYTE_GET (external
->p_offset
);
3273 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
3274 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
3275 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
3276 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
3277 internal
->p_align
= BYTE_GET (external
->p_align
);
3285 /* Returns 1 if the program headers were read into `program_headers'. */
3288 get_program_headers (FILE *file
)
3290 Elf_Internal_Phdr
*phdrs
;
3292 /* Check cache of prior read. */
3293 if (program_headers
!= NULL
)
3296 phdrs
= cmalloc (elf_header
.e_phnum
, sizeof (Elf_Internal_Phdr
));
3300 error (_("Out of memory\n"));
3305 ? get_32bit_program_headers (file
, phdrs
)
3306 : get_64bit_program_headers (file
, phdrs
))
3308 program_headers
= phdrs
;
3316 /* Returns 1 if the program headers were loaded. */
3319 process_program_headers (FILE *file
)
3321 Elf_Internal_Phdr
*segment
;
3324 if (elf_header
.e_phnum
== 0)
3327 printf (_("\nThere are no program headers in this file.\n"));
3331 if (do_segments
&& !do_header
)
3333 printf (_("\nElf file type is %s\n"), get_file_type (elf_header
.e_type
));
3334 printf (_("Entry point "));
3335 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3336 printf (_("\nThere are %d program headers, starting at offset "),
3337 elf_header
.e_phnum
);
3338 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3342 if (! get_program_headers (file
))
3347 if (elf_header
.e_phnum
> 1)
3348 printf (_("\nProgram Headers:\n"));
3350 printf (_("\nProgram Headers:\n"));
3354 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3357 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3361 (_(" Type Offset VirtAddr PhysAddr\n"));
3363 (_(" FileSiz MemSiz Flags Align\n"));
3370 for (i
= 0, segment
= program_headers
;
3371 i
< elf_header
.e_phnum
;
3376 printf (" %-14.14s ", get_segment_type (segment
->p_type
));
3380 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3381 printf ("0x%8.8lx ", (unsigned long) segment
->p_vaddr
);
3382 printf ("0x%8.8lx ", (unsigned long) segment
->p_paddr
);
3383 printf ("0x%5.5lx ", (unsigned long) segment
->p_filesz
);
3384 printf ("0x%5.5lx ", (unsigned long) segment
->p_memsz
);
3386 (segment
->p_flags
& PF_R
? 'R' : ' '),
3387 (segment
->p_flags
& PF_W
? 'W' : ' '),
3388 (segment
->p_flags
& PF_X
? 'E' : ' '));
3389 printf ("%#lx", (unsigned long) segment
->p_align
);
3393 if ((unsigned long) segment
->p_offset
== segment
->p_offset
)
3394 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3397 print_vma (segment
->p_offset
, FULL_HEX
);
3401 print_vma (segment
->p_vaddr
, FULL_HEX
);
3403 print_vma (segment
->p_paddr
, FULL_HEX
);
3406 if ((unsigned long) segment
->p_filesz
== segment
->p_filesz
)
3407 printf ("0x%6.6lx ", (unsigned long) segment
->p_filesz
);
3410 print_vma (segment
->p_filesz
, FULL_HEX
);
3414 if ((unsigned long) segment
->p_memsz
== segment
->p_memsz
)
3415 printf ("0x%6.6lx", (unsigned long) segment
->p_memsz
);
3418 print_vma (segment
->p_offset
, FULL_HEX
);
3422 (segment
->p_flags
& PF_R
? 'R' : ' '),
3423 (segment
->p_flags
& PF_W
? 'W' : ' '),
3424 (segment
->p_flags
& PF_X
? 'E' : ' '));
3426 if ((unsigned long) segment
->p_align
== segment
->p_align
)
3427 printf ("%#lx", (unsigned long) segment
->p_align
);
3430 print_vma (segment
->p_align
, PREFIX_HEX
);
3435 print_vma (segment
->p_offset
, FULL_HEX
);
3437 print_vma (segment
->p_vaddr
, FULL_HEX
);
3439 print_vma (segment
->p_paddr
, FULL_HEX
);
3441 print_vma (segment
->p_filesz
, FULL_HEX
);
3443 print_vma (segment
->p_memsz
, FULL_HEX
);
3445 (segment
->p_flags
& PF_R
? 'R' : ' '),
3446 (segment
->p_flags
& PF_W
? 'W' : ' '),
3447 (segment
->p_flags
& PF_X
? 'E' : ' '));
3448 print_vma (segment
->p_align
, HEX
);
3452 switch (segment
->p_type
)
3456 error (_("more than one dynamic segment\n"));
3458 /* Try to locate the .dynamic section. If there is
3459 a section header table, we can easily locate it. */
3460 if (section_headers
!= NULL
)
3462 Elf_Internal_Shdr
*sec
;
3464 sec
= find_section (".dynamic");
3465 if (sec
== NULL
|| sec
->sh_size
== 0)
3467 error (_("no .dynamic section in the dynamic segment"));
3471 dynamic_addr
= sec
->sh_offset
;
3472 dynamic_size
= sec
->sh_size
;
3474 if (dynamic_addr
< segment
->p_offset
3475 || dynamic_addr
> segment
->p_offset
+ segment
->p_filesz
)
3476 warn (_("the .dynamic section is not contained within the dynamic segment"));
3477 else if (dynamic_addr
> segment
->p_offset
)
3478 warn (_("the .dynamic section is not the first section in the dynamic segment."));
3482 /* Otherwise, we can only assume that the .dynamic
3483 section is the first section in the DYNAMIC segment. */
3484 dynamic_addr
= segment
->p_offset
;
3485 dynamic_size
= segment
->p_filesz
;
3490 if (fseek (file
, archive_file_offset
+ (long) segment
->p_offset
,
3492 error (_("Unable to find program interpreter name\n"));
3495 program_interpreter
[0] = 0;
3496 fscanf (file
, "%63s", program_interpreter
);
3499 printf (_("\n [Requesting program interpreter: %s]"),
3500 program_interpreter
);
3506 putc ('\n', stdout
);
3509 if (do_segments
&& section_headers
!= NULL
&& string_table
!= NULL
)
3511 printf (_("\n Section to Segment mapping:\n"));
3512 printf (_(" Segment Sections...\n"));
3514 for (i
= 0; i
< elf_header
.e_phnum
; i
++)
3517 Elf_Internal_Shdr
*section
;
3519 segment
= program_headers
+ i
;
3520 section
= section_headers
;
3522 printf (" %2.2d ", i
);
3524 for (j
= 1; j
< elf_header
.e_shnum
; j
++, section
++)
3526 if (ELF_IS_SECTION_IN_SEGMENT_MEMORY(section
, segment
))
3527 printf ("%s ", SECTION_NAME (section
));
3538 /* Find the file offset corresponding to VMA by using the program headers. */
3541 offset_from_vma (FILE *file
, bfd_vma vma
, bfd_size_type size
)
3543 Elf_Internal_Phdr
*seg
;
3545 if (! get_program_headers (file
))
3547 warn (_("Cannot interpret virtual addresses without program headers.\n"));
3551 for (seg
= program_headers
;
3552 seg
< program_headers
+ elf_header
.e_phnum
;
3555 if (seg
->p_type
!= PT_LOAD
)
3558 if (vma
>= (seg
->p_vaddr
& -seg
->p_align
)
3559 && vma
+ size
<= seg
->p_vaddr
+ seg
->p_filesz
)
3560 return vma
- seg
->p_vaddr
+ seg
->p_offset
;
3563 warn (_("Virtual address 0x%lx not located in any PT_LOAD segment.\n"),
3570 get_32bit_section_headers (FILE *file
, unsigned int num
)
3572 Elf32_External_Shdr
*shdrs
;
3573 Elf_Internal_Shdr
*internal
;
3576 shdrs
= get_data (NULL
, file
, elf_header
.e_shoff
,
3577 elf_header
.e_shentsize
, num
, _("section headers"));
3581 section_headers
= cmalloc (num
, sizeof (Elf_Internal_Shdr
));
3583 if (section_headers
== NULL
)
3585 error (_("Out of memory\n"));
3589 for (i
= 0, internal
= section_headers
;
3593 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3594 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3595 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
3596 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
3597 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3598 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
3599 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3600 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3601 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3602 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
3611 get_64bit_section_headers (FILE *file
, unsigned int num
)
3613 Elf64_External_Shdr
*shdrs
;
3614 Elf_Internal_Shdr
*internal
;
3617 shdrs
= get_data (NULL
, file
, elf_header
.e_shoff
,
3618 elf_header
.e_shentsize
, num
, _("section headers"));
3622 section_headers
= cmalloc (num
, sizeof (Elf_Internal_Shdr
));
3624 if (section_headers
== NULL
)
3626 error (_("Out of memory\n"));
3630 for (i
= 0, internal
= section_headers
;
3634 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3635 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3636 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
3637 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
3638 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
3639 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
3640 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3641 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3642 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3643 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3651 static Elf_Internal_Sym
*
3652 get_32bit_elf_symbols (FILE *file
, Elf_Internal_Shdr
*section
)
3654 unsigned long number
;
3655 Elf32_External_Sym
*esyms
;
3656 Elf_External_Sym_Shndx
*shndx
;
3657 Elf_Internal_Sym
*isyms
;
3658 Elf_Internal_Sym
*psym
;
3661 esyms
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
3667 if (symtab_shndx_hdr
!= NULL
3668 && (symtab_shndx_hdr
->sh_link
3669 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3671 shndx
= get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3672 1, symtab_shndx_hdr
->sh_size
, _("symtab shndx"));
3680 number
= section
->sh_size
/ section
->sh_entsize
;
3681 isyms
= cmalloc (number
, sizeof (Elf_Internal_Sym
));
3685 error (_("Out of memory\n"));
3692 for (j
= 0, psym
= isyms
;
3696 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3697 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3698 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3699 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3700 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3702 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3703 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3704 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3714 static Elf_Internal_Sym
*
3715 get_64bit_elf_symbols (FILE *file
, Elf_Internal_Shdr
*section
)
3717 unsigned long number
;
3718 Elf64_External_Sym
*esyms
;
3719 Elf_External_Sym_Shndx
*shndx
;
3720 Elf_Internal_Sym
*isyms
;
3721 Elf_Internal_Sym
*psym
;
3724 esyms
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
3730 if (symtab_shndx_hdr
!= NULL
3731 && (symtab_shndx_hdr
->sh_link
3732 == (unsigned long) SECTION_HEADER_NUM (section
- section_headers
)))
3734 shndx
= get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3735 1, symtab_shndx_hdr
->sh_size
, _("symtab shndx"));
3743 number
= section
->sh_size
/ section
->sh_entsize
;
3744 isyms
= cmalloc (number
, sizeof (Elf_Internal_Sym
));
3748 error (_("Out of memory\n"));
3755 for (j
= 0, psym
= isyms
;
3759 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3760 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3761 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3762 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3763 if (psym
->st_shndx
== SHN_XINDEX
&& shndx
!= NULL
)
3765 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3766 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3767 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3778 get_elf_section_flags (bfd_vma sh_flags
)
3780 static char buff
[1024];
3782 int field_size
= is_32bit_elf
? 8 : 16;
3783 int index
, size
= sizeof (buff
) - (field_size
+ 4 + 1);
3784 bfd_vma os_flags
= 0;
3785 bfd_vma proc_flags
= 0;
3786 bfd_vma unknown_flags
= 0;
3800 { "LINK ORDER", 10 },
3801 { "OS NONCONF", 10 },
3806 if (do_section_details
)
3808 sprintf (buff
, "[%*.*lx]: ",
3809 field_size
, field_size
, (unsigned long) sh_flags
);
3810 p
+= field_size
+ 4;
3817 flag
= sh_flags
& - sh_flags
;
3820 if (do_section_details
)
3824 case SHF_WRITE
: index
= 0; break;
3825 case SHF_ALLOC
: index
= 1; break;
3826 case SHF_EXECINSTR
: index
= 2; break;
3827 case SHF_MERGE
: index
= 3; break;
3828 case SHF_STRINGS
: index
= 4; break;
3829 case SHF_INFO_LINK
: index
= 5; break;
3830 case SHF_LINK_ORDER
: index
= 6; break;
3831 case SHF_OS_NONCONFORMING
: index
= 7; break;
3832 case SHF_GROUP
: index
= 8; break;
3833 case SHF_TLS
: index
= 9; break;
3842 if (p
!= buff
+ field_size
+ 4)
3844 if (size
< (10 + 2))
3851 size
-= flags
[index
].len
;
3852 p
= stpcpy (p
, flags
[index
].str
);
3854 else if (flag
& SHF_MASKOS
)
3856 else if (flag
& SHF_MASKPROC
)
3859 unknown_flags
|= flag
;
3865 case SHF_WRITE
: *p
= 'W'; break;
3866 case SHF_ALLOC
: *p
= 'A'; break;
3867 case SHF_EXECINSTR
: *p
= 'X'; break;
3868 case SHF_MERGE
: *p
= 'M'; break;
3869 case SHF_STRINGS
: *p
= 'S'; break;
3870 case SHF_INFO_LINK
: *p
= 'I'; break;
3871 case SHF_LINK_ORDER
: *p
= 'L'; break;
3872 case SHF_OS_NONCONFORMING
: *p
= 'O'; break;
3873 case SHF_GROUP
: *p
= 'G'; break;
3874 case SHF_TLS
: *p
= 'T'; break;
3877 if (elf_header
.e_machine
== EM_X86_64
3878 && flag
== SHF_X86_64_LARGE
)
3880 else if (flag
& SHF_MASKOS
)
3883 sh_flags
&= ~ SHF_MASKOS
;
3885 else if (flag
& SHF_MASKPROC
)
3888 sh_flags
&= ~ SHF_MASKPROC
;
3898 if (do_section_details
)
3902 size
-= 5 + field_size
;
3903 if (p
!= buff
+ field_size
+ 4)
3911 sprintf (p
, "OS (%*.*lx)", field_size
, field_size
,
3912 (unsigned long) os_flags
);
3913 p
+= 5 + field_size
;
3917 size
-= 7 + field_size
;
3918 if (p
!= buff
+ field_size
+ 4)
3926 sprintf (p
, "PROC (%*.*lx)", field_size
, field_size
,
3927 (unsigned long) proc_flags
);
3928 p
+= 7 + field_size
;
3932 size
-= 10 + field_size
;
3933 if (p
!= buff
+ field_size
+ 4)
3941 sprintf (p
, "UNKNOWN (%*.*lx)", field_size
, field_size
,
3942 (unsigned long) unknown_flags
);
3943 p
+= 10 + field_size
;
3952 process_section_headers (FILE *file
)
3954 Elf_Internal_Shdr
*section
;
3957 section_headers
= NULL
;
3959 if (elf_header
.e_shnum
== 0)
3962 printf (_("\nThere are no sections in this file.\n"));
3967 if (do_sections
&& !do_header
)
3968 printf (_("There are %d section headers, starting at offset 0x%lx:\n"),
3969 elf_header
.e_shnum
, (unsigned long) elf_header
.e_shoff
);
3973 if (! get_32bit_section_headers (file
, elf_header
.e_shnum
))
3976 else if (! get_64bit_section_headers (file
, elf_header
.e_shnum
))
3979 /* Read in the string table, so that we have names to display. */
3980 if (elf_header
.e_shstrndx
!= SHN_UNDEF
3981 && SECTION_HEADER_INDEX (elf_header
.e_shstrndx
) < elf_header
.e_shnum
)
3983 section
= SECTION_HEADER (elf_header
.e_shstrndx
);
3985 if (section
->sh_size
!= 0)
3987 string_table
= get_data (NULL
, file
, section
->sh_offset
,
3988 1, section
->sh_size
, _("string table"));
3990 string_table_length
= string_table
!= NULL
? section
->sh_size
: 0;
3994 /* Scan the sections for the dynamic symbol table
3995 and dynamic string table and debug sections. */
3996 dynamic_symbols
= NULL
;
3997 dynamic_strings
= NULL
;
3998 dynamic_syminfo
= NULL
;
3999 symtab_shndx_hdr
= NULL
;
4001 eh_addr_size
= is_32bit_elf
? 4 : 8;
4002 switch (elf_header
.e_machine
)
4005 case EM_MIPS_RS3_LE
:
4006 /* The 64-bit MIPS EABI uses a combination of 32-bit ELF and 64-bit
4007 FDE addresses. However, the ABI also has a semi-official ILP32
4008 variant for which the normal FDE address size rules apply.
4010 GCC 4.0 marks EABI64 objects with a dummy .gcc_compiled_longXX
4011 section, where XX is the size of longs in bits. Unfortunately,
4012 earlier compilers provided no way of distinguishing ILP32 objects
4013 from LP64 objects, so if there's any doubt, we should assume that
4014 the official LP64 form is being used. */
4015 if ((elf_header
.e_flags
& EF_MIPS_ABI
) == E_MIPS_ABI_EABI64
4016 && find_section (".gcc_compiled_long32") == NULL
)
4022 switch (elf_header
.e_flags
& EF_H8_MACH
)
4024 case E_H8_MACH_H8300
:
4025 case E_H8_MACH_H8300HN
:
4026 case E_H8_MACH_H8300SN
:
4027 case E_H8_MACH_H8300SXN
:
4030 case E_H8_MACH_H8300H
:
4031 case E_H8_MACH_H8300S
:
4032 case E_H8_MACH_H8300SX
:
4038 #define CHECK_ENTSIZE_VALUES(section, i, size32, size64) \
4041 size_t expected_entsize \
4042 = is_32bit_elf ? size32 : size64; \
4043 if (section->sh_entsize != expected_entsize) \
4044 error (_("Section %d has invalid sh_entsize %lx (expected %lx)\n"), \
4045 i, (unsigned long int) section->sh_entsize, \
4046 (unsigned long int) expected_entsize); \
4047 section->sh_entsize = expected_entsize; \
4050 #define CHECK_ENTSIZE(section, i, type) \
4051 CHECK_ENTSIZE_VALUES (section, i, sizeof (Elf32_External_##type), \
4052 sizeof (Elf64_External_##type))
4054 for (i
= 0, section
= section_headers
;
4055 i
< elf_header
.e_shnum
;
4058 char *name
= SECTION_NAME (section
);
4060 if (section
->sh_type
== SHT_DYNSYM
)
4062 if (dynamic_symbols
!= NULL
)
4064 error (_("File contains multiple dynamic symbol tables\n"));
4068 CHECK_ENTSIZE (section
, i
, Sym
);
4069 num_dynamic_syms
= section
->sh_size
/ section
->sh_entsize
;
4070 dynamic_symbols
= GET_ELF_SYMBOLS (file
, section
);
4072 else if (section
->sh_type
== SHT_STRTAB
4073 && streq (name
, ".dynstr"))
4075 if (dynamic_strings
!= NULL
)
4077 error (_("File contains multiple dynamic string tables\n"));
4081 dynamic_strings
= get_data (NULL
, file
, section
->sh_offset
,
4082 1, section
->sh_size
, _("dynamic strings"));
4083 dynamic_strings_length
= section
->sh_size
;
4085 else if (section
->sh_type
== SHT_SYMTAB_SHNDX
)
4087 if (symtab_shndx_hdr
!= NULL
)
4089 error (_("File contains multiple symtab shndx tables\n"));
4092 symtab_shndx_hdr
= section
;
4094 else if (section
->sh_type
== SHT_SYMTAB
)
4095 CHECK_ENTSIZE (section
, i
, Sym
);
4096 else if (section
->sh_type
== SHT_GROUP
)
4097 CHECK_ENTSIZE_VALUES (section
, i
, GRP_ENTRY_SIZE
, GRP_ENTRY_SIZE
);
4098 else if (section
->sh_type
== SHT_REL
)
4099 CHECK_ENTSIZE (section
, i
, Rel
);
4100 else if (section
->sh_type
== SHT_RELA
)
4101 CHECK_ENTSIZE (section
, i
, Rela
);
4102 else if ((do_debugging
|| do_debug_info
|| do_debug_abbrevs
4103 || do_debug_lines
|| do_debug_pubnames
|| do_debug_aranges
4104 || do_debug_frames
|| do_debug_macinfo
|| do_debug_str
4105 || do_debug_loc
|| do_debug_ranges
)
4106 && const_strneq (name
, ".debug_"))
4111 || (do_debug_info
&& streq (name
, "info"))
4112 || (do_debug_abbrevs
&& streq (name
, "abbrev"))
4113 || (do_debug_lines
&& streq (name
, "line"))
4114 || (do_debug_pubnames
&& streq (name
, "pubnames"))
4115 || (do_debug_aranges
&& streq (name
, "aranges"))
4116 || (do_debug_ranges
&& streq (name
, "ranges"))
4117 || (do_debug_frames
&& streq (name
, "frame"))
4118 || (do_debug_macinfo
&& streq (name
, "macinfo"))
4119 || (do_debug_str
&& streq (name
, "str"))
4120 || (do_debug_loc
&& streq (name
, "loc"))
4122 request_dump (i
, DEBUG_DUMP
);
4124 /* linkonce section to be combined with .debug_info at link time. */
4125 else if ((do_debugging
|| do_debug_info
)
4126 && const_strneq (name
, ".gnu.linkonce.wi."))
4127 request_dump (i
, DEBUG_DUMP
);
4128 else if (do_debug_frames
&& streq (name
, ".eh_frame"))
4129 request_dump (i
, DEBUG_DUMP
);
4135 if (elf_header
.e_shnum
> 1)
4136 printf (_("\nSection Headers:\n"));
4138 printf (_("\nSection Header:\n"));
4142 if (do_section_details
)
4144 printf (_(" [Nr] Name\n"));
4145 printf (_(" Type Addr Off Size ES Lk Inf Al\n"));
4149 (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
4153 if (do_section_details
)
4155 printf (_(" [Nr] Name\n"));
4156 printf (_(" Type Address Off Size ES Lk Inf Al\n"));
4160 (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n"));
4164 if (do_section_details
)
4166 printf (_(" [Nr] Name\n"));
4167 printf (_(" Type Address Offset Link\n"));
4168 printf (_(" Size EntSize Info Align\n"));
4172 printf (_(" [Nr] Name Type Address Offset\n"));
4173 printf (_(" Size EntSize Flags Link Info Align\n"));
4177 if (do_section_details
)
4178 printf (_(" Flags\n"));
4180 for (i
= 0, section
= section_headers
;
4181 i
< elf_header
.e_shnum
;
4184 if (do_section_details
)
4186 printf (" [%2u] %s\n",
4187 SECTION_HEADER_NUM (i
),
4188 SECTION_NAME (section
));
4189 if (is_32bit_elf
|| do_wide
)
4190 printf (" %-15.15s ",
4191 get_section_type_name (section
->sh_type
));
4194 printf (" [%2u] %-17.17s %-15.15s ",
4195 SECTION_HEADER_NUM (i
),
4196 SECTION_NAME (section
),
4197 get_section_type_name (section
->sh_type
));
4201 print_vma (section
->sh_addr
, LONG_HEX
);
4203 printf ( " %6.6lx %6.6lx %2.2lx",
4204 (unsigned long) section
->sh_offset
,
4205 (unsigned long) section
->sh_size
,
4206 (unsigned long) section
->sh_entsize
);
4208 if (do_section_details
)
4209 fputs (" ", stdout
);
4211 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4213 printf ("%2ld %3lu %2ld\n",
4214 (unsigned long) section
->sh_link
,
4215 (unsigned long) section
->sh_info
,
4216 (unsigned long) section
->sh_addralign
);
4220 print_vma (section
->sh_addr
, LONG_HEX
);
4222 if ((long) section
->sh_offset
== section
->sh_offset
)
4223 printf (" %6.6lx", (unsigned long) section
->sh_offset
);
4227 print_vma (section
->sh_offset
, LONG_HEX
);
4230 if ((unsigned long) section
->sh_size
== section
->sh_size
)
4231 printf (" %6.6lx", (unsigned long) section
->sh_size
);
4235 print_vma (section
->sh_size
, LONG_HEX
);
4238 if ((unsigned long) section
->sh_entsize
== section
->sh_entsize
)
4239 printf (" %2.2lx", (unsigned long) section
->sh_entsize
);
4243 print_vma (section
->sh_entsize
, LONG_HEX
);
4246 if (do_section_details
)
4247 fputs (" ", stdout
);
4249 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4251 printf ("%2ld %3lu ",
4252 (unsigned long) section
->sh_link
,
4253 (unsigned long) section
->sh_info
);
4255 if ((unsigned long) section
->sh_addralign
== section
->sh_addralign
)
4256 printf ("%2ld\n", (unsigned long) section
->sh_addralign
);
4259 print_vma (section
->sh_addralign
, DEC
);
4263 else if (do_section_details
)
4265 printf (" %-15.15s ",
4266 get_section_type_name (section
->sh_type
));
4267 print_vma (section
->sh_addr
, LONG_HEX
);
4268 if ((long) section
->sh_offset
== section
->sh_offset
)
4269 printf (" %16.16lx", (unsigned long) section
->sh_offset
);
4273 print_vma (section
->sh_offset
, LONG_HEX
);
4275 printf (" %ld\n ", (unsigned long) section
->sh_link
);
4276 print_vma (section
->sh_size
, LONG_HEX
);
4278 print_vma (section
->sh_entsize
, LONG_HEX
);
4280 printf (" %-16lu %ld\n",
4281 (unsigned long) section
->sh_info
,
4282 (unsigned long) section
->sh_addralign
);
4287 print_vma (section
->sh_addr
, LONG_HEX
);
4288 if ((long) section
->sh_offset
== section
->sh_offset
)
4289 printf (" %8.8lx", (unsigned long) section
->sh_offset
);
4293 print_vma (section
->sh_offset
, LONG_HEX
);
4296 print_vma (section
->sh_size
, LONG_HEX
);
4298 print_vma (section
->sh_entsize
, LONG_HEX
);
4300 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4302 printf (" %2ld %3lu %ld\n",
4303 (unsigned long) section
->sh_link
,
4304 (unsigned long) section
->sh_info
,
4305 (unsigned long) section
->sh_addralign
);
4308 if (do_section_details
)
4309 printf (" %s\n", get_elf_section_flags (section
->sh_flags
));
4312 if (!do_section_details
)
4313 printf (_("Key to Flags:\n\
4314 W (write), A (alloc), X (execute), M (merge), S (strings)\n\
4315 I (info), L (link order), G (group), x (unknown)\n\
4316 O (extra OS processing required) o (OS specific), p (processor specific)\n"));
4322 get_group_flags (unsigned int flags
)
4324 static char buff
[32];
4331 snprintf (buff
, sizeof (buff
), _("[<unknown>: 0x%x]"), flags
);
4338 process_section_groups (FILE *file
)
4340 Elf_Internal_Shdr
*section
;
4342 struct group
*group
;
4343 Elf_Internal_Shdr
*symtab_sec
, *strtab_sec
;
4344 Elf_Internal_Sym
*symtab
;
4348 /* Don't process section groups unless needed. */
4349 if (!do_unwind
&& !do_section_groups
)
4352 if (elf_header
.e_shnum
== 0)
4354 if (do_section_groups
)
4355 printf (_("\nThere are no sections in this file.\n"));
4360 if (section_headers
== NULL
)
4362 error (_("Section headers are not available!\n"));
4366 section_headers_groups
= calloc (elf_header
.e_shnum
,
4367 sizeof (struct group
*));
4369 if (section_headers_groups
== NULL
)
4371 error (_("Out of memory\n"));
4375 /* Scan the sections for the group section. */
4377 for (i
= 0, section
= section_headers
;
4378 i
< elf_header
.e_shnum
;
4380 if (section
->sh_type
== SHT_GROUP
)
4383 if (group_count
== 0)
4385 if (do_section_groups
)
4386 printf (_("\nThere are no section groups in this file.\n"));
4391 section_groups
= calloc (group_count
, sizeof (struct group
));
4393 if (section_groups
== NULL
)
4395 error (_("Out of memory\n"));
4404 for (i
= 0, section
= section_headers
, group
= section_groups
;
4405 i
< elf_header
.e_shnum
;
4408 if (section
->sh_type
== SHT_GROUP
)
4410 char *name
= SECTION_NAME (section
);
4412 unsigned char *start
, *indices
;
4413 unsigned int entry
, j
, size
;
4414 Elf_Internal_Shdr
*sec
;
4415 Elf_Internal_Sym
*sym
;
4417 /* Get the symbol table. */
4418 if (SECTION_HEADER_INDEX (section
->sh_link
) >= elf_header
.e_shnum
4419 || ((sec
= SECTION_HEADER (section
->sh_link
))->sh_type
4422 error (_("Bad sh_link in group section `%s'\n"), name
);
4426 if (symtab_sec
!= sec
)
4431 symtab
= GET_ELF_SYMBOLS (file
, symtab_sec
);
4434 sym
= symtab
+ section
->sh_info
;
4436 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
4438 bfd_vma sec_index
= SECTION_HEADER_INDEX (sym
->st_shndx
);
4441 error (_("Bad sh_info in group section `%s'\n"), name
);
4445 group_name
= SECTION_NAME (section_headers
+ sec_index
);
4454 /* Get the string table. */
4455 if (SECTION_HEADER_INDEX (symtab_sec
->sh_link
)
4456 >= elf_header
.e_shnum
)
4465 != (sec
= SECTION_HEADER (symtab_sec
->sh_link
)))
4470 strtab
= get_data (NULL
, file
, strtab_sec
->sh_offset
,
4471 1, strtab_sec
->sh_size
,
4473 strtab_size
= strtab
!= NULL
? strtab_sec
->sh_size
: 0;
4475 group_name
= sym
->st_name
< strtab_size
4476 ? strtab
+ sym
->st_name
: "<corrupt>";
4479 start
= get_data (NULL
, file
, section
->sh_offset
,
4480 1, section
->sh_size
, _("section data"));
4483 size
= (section
->sh_size
/ section
->sh_entsize
) - 1;
4484 entry
= byte_get (indices
, 4);
4487 if (do_section_groups
)
4489 printf ("\n%s group section [%5u] `%s' [%s] contains %u sections:\n",
4490 get_group_flags (entry
), i
, name
, group_name
, size
);
4492 printf (_(" [Index] Name\n"));
4495 group
->group_index
= i
;
4497 for (j
= 0; j
< size
; j
++)
4499 struct group_list
*g
;
4501 entry
= byte_get (indices
, 4);
4504 if (SECTION_HEADER_INDEX (entry
) >= elf_header
.e_shnum
)
4506 error (_("section [%5u] in group section [%5u] > maximum section [%5u]\n"),
4507 entry
, i
, elf_header
.e_shnum
- 1);
4510 else if (entry
>= SHN_LORESERVE
&& entry
<= SHN_HIRESERVE
)
4512 error (_("invalid section [%5u] in group section [%5u]\n"),
4517 if (section_headers_groups
[SECTION_HEADER_INDEX (entry
)]
4522 error (_("section [%5u] in group section [%5u] already in group section [%5u]\n"),
4524 section_headers_groups
[SECTION_HEADER_INDEX (entry
)]->group_index
);
4529 /* Intel C/C++ compiler may put section 0 in a
4530 section group. We just warn it the first time
4531 and ignore it afterwards. */
4532 static int warned
= 0;
4535 error (_("section 0 in group section [%5u]\n"),
4536 section_headers_groups
[SECTION_HEADER_INDEX (entry
)]->group_index
);
4542 section_headers_groups
[SECTION_HEADER_INDEX (entry
)]
4545 if (do_section_groups
)
4547 sec
= SECTION_HEADER (entry
);
4548 printf (" [%5u] %s\n", entry
, SECTION_NAME (sec
));
4551 g
= xmalloc (sizeof (struct group_list
));
4552 g
->section_index
= entry
;
4553 g
->next
= group
->root
;
4577 } dynamic_relocations
[] =
4579 { "REL", DT_REL
, DT_RELSZ
, FALSE
},
4580 { "RELA", DT_RELA
, DT_RELASZ
, TRUE
},
4581 { "PLT", DT_JMPREL
, DT_PLTRELSZ
, UNKNOWN
}
4584 /* Process the reloc section. */
4587 process_relocs (FILE *file
)
4589 unsigned long rel_size
;
4590 unsigned long rel_offset
;
4596 if (do_using_dynamic
)
4600 int has_dynamic_reloc
;
4603 has_dynamic_reloc
= 0;
4605 for (i
= 0; i
< ARRAY_SIZE (dynamic_relocations
); i
++)
4607 is_rela
= dynamic_relocations
[i
].rela
;
4608 name
= dynamic_relocations
[i
].name
;
4609 rel_size
= dynamic_info
[dynamic_relocations
[i
].size
];
4610 rel_offset
= dynamic_info
[dynamic_relocations
[i
].reloc
];
4612 has_dynamic_reloc
|= rel_size
;
4614 if (is_rela
== UNKNOWN
)
4616 if (dynamic_relocations
[i
].reloc
== DT_JMPREL
)
4617 switch (dynamic_info
[DT_PLTREL
])
4631 (_("\n'%s' relocation section at offset 0x%lx contains %ld bytes:\n"),
4632 name
, rel_offset
, rel_size
);
4634 dump_relocations (file
,
4635 offset_from_vma (file
, rel_offset
, rel_size
),
4637 dynamic_symbols
, num_dynamic_syms
,
4638 dynamic_strings
, dynamic_strings_length
, is_rela
);
4642 if (! has_dynamic_reloc
)
4643 printf (_("\nThere are no dynamic relocations in this file.\n"));
4647 Elf_Internal_Shdr
*section
;
4651 for (i
= 0, section
= section_headers
;
4652 i
< elf_header
.e_shnum
;
4655 if ( section
->sh_type
!= SHT_RELA
4656 && section
->sh_type
!= SHT_REL
)
4659 rel_offset
= section
->sh_offset
;
4660 rel_size
= section
->sh_size
;
4664 Elf_Internal_Shdr
*strsec
;
4667 printf (_("\nRelocation section "));
4669 if (string_table
== NULL
)
4670 printf ("%d", section
->sh_name
);
4672 printf (_("'%s'"), SECTION_NAME (section
));
4674 printf (_(" at offset 0x%lx contains %lu entries:\n"),
4675 rel_offset
, (unsigned long) (rel_size
/ section
->sh_entsize
));
4677 is_rela
= section
->sh_type
== SHT_RELA
;
4679 if (section
->sh_link
4680 && SECTION_HEADER_INDEX (section
->sh_link
)
4681 < elf_header
.e_shnum
)
4683 Elf_Internal_Shdr
*symsec
;
4684 Elf_Internal_Sym
*symtab
;
4685 unsigned long nsyms
;
4686 unsigned long strtablen
= 0;
4687 char *strtab
= NULL
;
4689 symsec
= SECTION_HEADER (section
->sh_link
);
4690 if (symsec
->sh_type
!= SHT_SYMTAB
4691 && symsec
->sh_type
!= SHT_DYNSYM
)
4694 nsyms
= symsec
->sh_size
/ symsec
->sh_entsize
;
4695 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
4700 if (SECTION_HEADER_INDEX (symsec
->sh_link
)
4701 < elf_header
.e_shnum
)
4703 strsec
= SECTION_HEADER (symsec
->sh_link
);
4705 strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
4708 strtablen
= strtab
== NULL
? 0 : strsec
->sh_size
;
4711 dump_relocations (file
, rel_offset
, rel_size
,
4712 symtab
, nsyms
, strtab
, strtablen
, is_rela
);
4718 dump_relocations (file
, rel_offset
, rel_size
,
4719 NULL
, 0, NULL
, 0, is_rela
);
4726 printf (_("\nThere are no relocations in this file.\n"));
4732 /* Process the unwind section. */
4734 #include "unwind-ia64.h"
4736 /* An absolute address consists of a section and an offset. If the
4737 section is NULL, the offset itself is the address, otherwise, the
4738 address equals to LOAD_ADDRESS(section) + offset. */
4742 unsigned short section
;
4746 #define ABSADDR(a) \
4748 ? section_headers [(a).section].sh_addr + (a).offset \
4751 struct ia64_unw_aux_info
4753 struct ia64_unw_table_entry
4755 struct absaddr start
;
4757 struct absaddr info
;
4759 *table
; /* Unwind table. */
4760 unsigned long table_len
; /* Length of unwind table. */
4761 unsigned char *info
; /* Unwind info. */
4762 unsigned long info_size
; /* Size of unwind info. */
4763 bfd_vma info_addr
; /* starting address of unwind info. */
4764 bfd_vma seg_base
; /* Starting address of segment. */
4765 Elf_Internal_Sym
*symtab
; /* The symbol table. */
4766 unsigned long nsyms
; /* Number of symbols. */
4767 char *strtab
; /* The string table. */
4768 unsigned long strtab_size
; /* Size of string table. */
4772 find_symbol_for_address (Elf_Internal_Sym
*symtab
,
4773 unsigned long nsyms
,
4775 unsigned long strtab_size
,
4776 struct absaddr addr
,
4777 const char **symname
,
4780 bfd_vma dist
= 0x100000;
4781 Elf_Internal_Sym
*sym
, *best
= NULL
;
4784 for (i
= 0, sym
= symtab
; i
< nsyms
; ++i
, ++sym
)
4786 if (ELF_ST_TYPE (sym
->st_info
) == STT_FUNC
4787 && sym
->st_name
!= 0
4788 && (addr
.section
== SHN_UNDEF
|| addr
.section
== sym
->st_shndx
)
4789 && addr
.offset
>= sym
->st_value
4790 && addr
.offset
- sym
->st_value
< dist
)
4793 dist
= addr
.offset
- sym
->st_value
;
4800 *symname
= (best
->st_name
>= strtab_size
4801 ? "<corrupt>" : strtab
+ best
->st_name
);
4806 *offset
= addr
.offset
;
4810 dump_ia64_unwind (struct ia64_unw_aux_info
*aux
)
4812 struct ia64_unw_table_entry
*tp
;
4815 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
4819 const unsigned char *dp
;
4820 const unsigned char *head
;
4821 const char *procname
;
4823 find_symbol_for_address (aux
->symtab
, aux
->nsyms
, aux
->strtab
,
4824 aux
->strtab_size
, tp
->start
, &procname
, &offset
);
4826 fputs ("\n<", stdout
);
4830 fputs (procname
, stdout
);
4833 printf ("+%lx", (unsigned long) offset
);
4836 fputs (">: [", stdout
);
4837 print_vma (tp
->start
.offset
, PREFIX_HEX
);
4838 fputc ('-', stdout
);
4839 print_vma (tp
->end
.offset
, PREFIX_HEX
);
4840 printf ("], info at +0x%lx\n",
4841 (unsigned long) (tp
->info
.offset
- aux
->seg_base
));
4843 head
= aux
->info
+ (ABSADDR (tp
->info
) - aux
->info_addr
);
4844 stamp
= byte_get ((unsigned char *) head
, sizeof (stamp
));
4846 printf (" v%u, flags=0x%lx (%s%s), len=%lu bytes\n",
4847 (unsigned) UNW_VER (stamp
),
4848 (unsigned long) ((stamp
& UNW_FLAG_MASK
) >> 32),
4849 UNW_FLAG_EHANDLER (stamp
) ? " ehandler" : "",
4850 UNW_FLAG_UHANDLER (stamp
) ? " uhandler" : "",
4851 (unsigned long) (eh_addr_size
* UNW_LENGTH (stamp
)));
4853 if (UNW_VER (stamp
) != 1)
4855 printf ("\tUnknown version.\n");
4860 for (dp
= head
+ 8; dp
< head
+ 8 + eh_addr_size
* UNW_LENGTH (stamp
);)
4861 dp
= unw_decode (dp
, in_body
, & in_body
);
4866 slurp_ia64_unwind_table (FILE *file
,
4867 struct ia64_unw_aux_info
*aux
,
4868 Elf_Internal_Shdr
*sec
)
4870 unsigned long size
, nrelas
, i
;
4871 Elf_Internal_Phdr
*seg
;
4872 struct ia64_unw_table_entry
*tep
;
4873 Elf_Internal_Shdr
*relsec
;
4874 Elf_Internal_Rela
*rela
, *rp
;
4875 unsigned char *table
, *tp
;
4876 Elf_Internal_Sym
*sym
;
4877 const char *relname
;
4879 /* First, find the starting address of the segment that includes
4882 if (elf_header
.e_phnum
)
4884 if (! get_program_headers (file
))
4887 for (seg
= program_headers
;
4888 seg
< program_headers
+ elf_header
.e_phnum
;
4891 if (seg
->p_type
!= PT_LOAD
)
4894 if (sec
->sh_addr
>= seg
->p_vaddr
4895 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
4897 aux
->seg_base
= seg
->p_vaddr
;
4903 /* Second, build the unwind table from the contents of the unwind section: */
4904 size
= sec
->sh_size
;
4905 table
= get_data (NULL
, file
, sec
->sh_offset
, 1, size
, _("unwind table"));
4909 aux
->table
= xcmalloc (size
/ (3 * eh_addr_size
), sizeof (aux
->table
[0]));
4911 for (tp
= table
; tp
< table
+ size
; tp
+= 3 * eh_addr_size
, ++tep
)
4913 tep
->start
.section
= SHN_UNDEF
;
4914 tep
->end
.section
= SHN_UNDEF
;
4915 tep
->info
.section
= SHN_UNDEF
;
4918 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
4919 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
4920 tep
->info
.offset
= byte_get ((unsigned char *) tp
+ 8, 4);
4924 tep
->start
.offset
= BYTE_GET ((unsigned char *) tp
+ 0);
4925 tep
->end
.offset
= BYTE_GET ((unsigned char *) tp
+ 8);
4926 tep
->info
.offset
= BYTE_GET ((unsigned char *) tp
+ 16);
4928 tep
->start
.offset
+= aux
->seg_base
;
4929 tep
->end
.offset
+= aux
->seg_base
;
4930 tep
->info
.offset
+= aux
->seg_base
;
4934 /* Third, apply any relocations to the unwind table: */
4936 for (relsec
= section_headers
;
4937 relsec
< section_headers
+ elf_header
.e_shnum
;
4940 if (relsec
->sh_type
!= SHT_RELA
4941 || SECTION_HEADER_INDEX (relsec
->sh_info
) >= elf_header
.e_shnum
4942 || SECTION_HEADER (relsec
->sh_info
) != sec
)
4945 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
4949 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
4953 relname
= elf_ia64_reloc_type (ELF32_R_TYPE (rp
->r_info
));
4954 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
4958 relname
= elf_ia64_reloc_type (ELF64_R_TYPE (rp
->r_info
));
4959 sym
= aux
->symtab
+ ELF64_R_SYM (rp
->r_info
);
4962 if (! const_strneq (relname
, "R_IA64_SEGREL"))
4964 warn (_("Skipping unexpected relocation type %s\n"), relname
);
4968 i
= rp
->r_offset
/ (3 * eh_addr_size
);
4970 switch (rp
->r_offset
/eh_addr_size
% 3)
4973 aux
->table
[i
].start
.section
= sym
->st_shndx
;
4974 aux
->table
[i
].start
.offset
+= rp
->r_addend
+ sym
->st_value
;
4977 aux
->table
[i
].end
.section
= sym
->st_shndx
;
4978 aux
->table
[i
].end
.offset
+= rp
->r_addend
+ sym
->st_value
;
4981 aux
->table
[i
].info
.section
= sym
->st_shndx
;
4982 aux
->table
[i
].info
.offset
+= rp
->r_addend
+ sym
->st_value
;
4992 aux
->table_len
= size
/ (3 * eh_addr_size
);
4997 ia64_process_unwind (FILE *file
)
4999 Elf_Internal_Shdr
*sec
, *unwsec
= NULL
, *strsec
;
5000 unsigned long i
, unwcount
= 0, unwstart
= 0;
5001 struct ia64_unw_aux_info aux
;
5003 memset (& aux
, 0, sizeof (aux
));
5005 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5007 if (sec
->sh_type
== SHT_SYMTAB
5008 && SECTION_HEADER_INDEX (sec
->sh_link
) < elf_header
.e_shnum
)
5010 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
5011 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
5013 strsec
= SECTION_HEADER (sec
->sh_link
);
5014 aux
.strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
5015 1, strsec
->sh_size
, _("string table"));
5016 aux
.strtab_size
= aux
.strtab
!= NULL
? strsec
->sh_size
: 0;
5018 else if (sec
->sh_type
== SHT_IA_64_UNWIND
)
5023 printf (_("\nThere are no unwind sections in this file.\n"));
5025 while (unwcount
-- > 0)
5030 for (i
= unwstart
, sec
= section_headers
+ unwstart
;
5031 i
< elf_header
.e_shnum
; ++i
, ++sec
)
5032 if (sec
->sh_type
== SHT_IA_64_UNWIND
)
5039 len
= sizeof (ELF_STRING_ia64_unwind_once
) - 1;
5041 if ((unwsec
->sh_flags
& SHF_GROUP
) != 0)
5043 /* We need to find which section group it is in. */
5044 struct group_list
*g
= section_headers_groups
[i
]->root
;
5046 for (; g
!= NULL
; g
= g
->next
)
5048 sec
= SECTION_HEADER (g
->section_index
);
5050 if (streq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info
))
5055 i
= elf_header
.e_shnum
;
5057 else if (strneq (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind_once
, len
))
5059 /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO. */
5060 len2
= sizeof (ELF_STRING_ia64_unwind_info_once
) - 1;
5061 suffix
= SECTION_NAME (unwsec
) + len
;
5062 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
5064 if (strneq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info_once
, len2
)
5065 && streq (SECTION_NAME (sec
) + len2
, suffix
))
5070 /* .IA_64.unwindFOO -> .IA_64.unwind_infoFOO
5071 .IA_64.unwind or BAR -> .IA_64.unwind_info. */
5072 len
= sizeof (ELF_STRING_ia64_unwind
) - 1;
5073 len2
= sizeof (ELF_STRING_ia64_unwind_info
) - 1;
5075 if (strneq (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind
, len
))
5076 suffix
= SECTION_NAME (unwsec
) + len
;
5077 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
5079 if (strneq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info
, len2
)
5080 && streq (SECTION_NAME (sec
) + len2
, suffix
))
5084 if (i
== elf_header
.e_shnum
)
5086 printf (_("\nCould not find unwind info section for "));
5088 if (string_table
== NULL
)
5089 printf ("%d", unwsec
->sh_name
);
5091 printf (_("'%s'"), SECTION_NAME (unwsec
));
5095 aux
.info_size
= sec
->sh_size
;
5096 aux
.info_addr
= sec
->sh_addr
;
5097 aux
.info
= get_data (NULL
, file
, sec
->sh_offset
, 1, aux
.info_size
,
5100 printf (_("\nUnwind section "));
5102 if (string_table
== NULL
)
5103 printf ("%d", unwsec
->sh_name
);
5105 printf (_("'%s'"), SECTION_NAME (unwsec
));
5107 printf (_(" at offset 0x%lx contains %lu entries:\n"),
5108 (unsigned long) unwsec
->sh_offset
,
5109 (unsigned long) (unwsec
->sh_size
/ (3 * eh_addr_size
)));
5111 (void) slurp_ia64_unwind_table (file
, & aux
, unwsec
);
5113 if (aux
.table_len
> 0)
5114 dump_ia64_unwind (& aux
);
5117 free ((char *) aux
.table
);
5119 free ((char *) aux
.info
);
5128 free ((char *) aux
.strtab
);
5133 struct hppa_unw_aux_info
5135 struct hppa_unw_table_entry
5137 struct absaddr start
;
5139 unsigned int Cannot_unwind
:1; /* 0 */
5140 unsigned int Millicode
:1; /* 1 */
5141 unsigned int Millicode_save_sr0
:1; /* 2 */
5142 unsigned int Region_description
:2; /* 3..4 */
5143 unsigned int reserved1
:1; /* 5 */
5144 unsigned int Entry_SR
:1; /* 6 */
5145 unsigned int Entry_FR
:4; /* number saved */ /* 7..10 */
5146 unsigned int Entry_GR
:5; /* number saved */ /* 11..15 */
5147 unsigned int Args_stored
:1; /* 16 */
5148 unsigned int Variable_Frame
:1; /* 17 */
5149 unsigned int Separate_Package_Body
:1; /* 18 */
5150 unsigned int Frame_Extension_Millicode
:1; /* 19 */
5151 unsigned int Stack_Overflow_Check
:1; /* 20 */
5152 unsigned int Two_Instruction_SP_Increment
:1; /* 21 */
5153 unsigned int Ada_Region
:1; /* 22 */
5154 unsigned int cxx_info
:1; /* 23 */
5155 unsigned int cxx_try_catch
:1; /* 24 */
5156 unsigned int sched_entry_seq
:1; /* 25 */
5157 unsigned int reserved2
:1; /* 26 */
5158 unsigned int Save_SP
:1; /* 27 */
5159 unsigned int Save_RP
:1; /* 28 */
5160 unsigned int Save_MRP_in_frame
:1; /* 29 */
5161 unsigned int extn_ptr_defined
:1; /* 30 */
5162 unsigned int Cleanup_defined
:1; /* 31 */
5164 unsigned int MPE_XL_interrupt_marker
:1; /* 0 */
5165 unsigned int HP_UX_interrupt_marker
:1; /* 1 */
5166 unsigned int Large_frame
:1; /* 2 */
5167 unsigned int Pseudo_SP_Set
:1; /* 3 */
5168 unsigned int reserved4
:1; /* 4 */
5169 unsigned int Total_frame_size
:27; /* 5..31 */
5171 *table
; /* Unwind table. */
5172 unsigned long table_len
; /* Length of unwind table. */
5173 bfd_vma seg_base
; /* Starting address of segment. */
5174 Elf_Internal_Sym
*symtab
; /* The symbol table. */
5175 unsigned long nsyms
; /* Number of symbols. */
5176 char *strtab
; /* The string table. */
5177 unsigned long strtab_size
; /* Size of string table. */
5181 dump_hppa_unwind (struct hppa_unw_aux_info
*aux
)
5183 struct hppa_unw_table_entry
*tp
;
5185 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
5188 const char *procname
;
5190 find_symbol_for_address (aux
->symtab
, aux
->nsyms
, aux
->strtab
,
5191 aux
->strtab_size
, tp
->start
, &procname
,
5194 fputs ("\n<", stdout
);
5198 fputs (procname
, stdout
);
5201 printf ("+%lx", (unsigned long) offset
);
5204 fputs (">: [", stdout
);
5205 print_vma (tp
->start
.offset
, PREFIX_HEX
);
5206 fputc ('-', stdout
);
5207 print_vma (tp
->end
.offset
, PREFIX_HEX
);
5210 #define PF(_m) if (tp->_m) printf (#_m " ");
5211 #define PV(_m) if (tp->_m) printf (#_m "=%d ", tp->_m);
5214 PF(Millicode_save_sr0
);
5215 /* PV(Region_description); */
5221 PF(Separate_Package_Body
);
5222 PF(Frame_Extension_Millicode
);
5223 PF(Stack_Overflow_Check
);
5224 PF(Two_Instruction_SP_Increment
);
5228 PF(sched_entry_seq
);
5231 PF(Save_MRP_in_frame
);
5232 PF(extn_ptr_defined
);
5233 PF(Cleanup_defined
);
5234 PF(MPE_XL_interrupt_marker
);
5235 PF(HP_UX_interrupt_marker
);
5238 PV(Total_frame_size
);
5247 slurp_hppa_unwind_table (FILE *file
,
5248 struct hppa_unw_aux_info
*aux
,
5249 Elf_Internal_Shdr
*sec
)
5251 unsigned long size
, unw_ent_size
, nentries
, nrelas
, i
;
5252 Elf_Internal_Phdr
*seg
;
5253 struct hppa_unw_table_entry
*tep
;
5254 Elf_Internal_Shdr
*relsec
;
5255 Elf_Internal_Rela
*rela
, *rp
;
5256 unsigned char *table
, *tp
;
5257 Elf_Internal_Sym
*sym
;
5258 const char *relname
;
5260 /* First, find the starting address of the segment that includes
5263 if (elf_header
.e_phnum
)
5265 if (! get_program_headers (file
))
5268 for (seg
= program_headers
;
5269 seg
< program_headers
+ elf_header
.e_phnum
;
5272 if (seg
->p_type
!= PT_LOAD
)
5275 if (sec
->sh_addr
>= seg
->p_vaddr
5276 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
5278 aux
->seg_base
= seg
->p_vaddr
;
5284 /* Second, build the unwind table from the contents of the unwind
5286 size
= sec
->sh_size
;
5287 table
= get_data (NULL
, file
, sec
->sh_offset
, 1, size
, _("unwind table"));
5292 nentries
= size
/ unw_ent_size
;
5293 size
= unw_ent_size
* nentries
;
5295 tep
= aux
->table
= xcmalloc (nentries
, sizeof (aux
->table
[0]));
5297 for (tp
= table
; tp
< table
+ size
; tp
+= unw_ent_size
, ++tep
)
5299 unsigned int tmp1
, tmp2
;
5301 tep
->start
.section
= SHN_UNDEF
;
5302 tep
->end
.section
= SHN_UNDEF
;
5304 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
5305 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
5306 tmp1
= byte_get ((unsigned char *) tp
+ 8, 4);
5307 tmp2
= byte_get ((unsigned char *) tp
+ 12, 4);
5309 tep
->start
.offset
+= aux
->seg_base
;
5310 tep
->end
.offset
+= aux
->seg_base
;
5312 tep
->Cannot_unwind
= (tmp1
>> 31) & 0x1;
5313 tep
->Millicode
= (tmp1
>> 30) & 0x1;
5314 tep
->Millicode_save_sr0
= (tmp1
>> 29) & 0x1;
5315 tep
->Region_description
= (tmp1
>> 27) & 0x3;
5316 tep
->reserved1
= (tmp1
>> 26) & 0x1;
5317 tep
->Entry_SR
= (tmp1
>> 25) & 0x1;
5318 tep
->Entry_FR
= (tmp1
>> 21) & 0xf;
5319 tep
->Entry_GR
= (tmp1
>> 16) & 0x1f;
5320 tep
->Args_stored
= (tmp1
>> 15) & 0x1;
5321 tep
->Variable_Frame
= (tmp1
>> 14) & 0x1;
5322 tep
->Separate_Package_Body
= (tmp1
>> 13) & 0x1;
5323 tep
->Frame_Extension_Millicode
= (tmp1
>> 12) & 0x1;
5324 tep
->Stack_Overflow_Check
= (tmp1
>> 11) & 0x1;
5325 tep
->Two_Instruction_SP_Increment
= (tmp1
>> 10) & 0x1;
5326 tep
->Ada_Region
= (tmp1
>> 9) & 0x1;
5327 tep
->cxx_info
= (tmp1
>> 8) & 0x1;
5328 tep
->cxx_try_catch
= (tmp1
>> 7) & 0x1;
5329 tep
->sched_entry_seq
= (tmp1
>> 6) & 0x1;
5330 tep
->reserved2
= (tmp1
>> 5) & 0x1;
5331 tep
->Save_SP
= (tmp1
>> 4) & 0x1;
5332 tep
->Save_RP
= (tmp1
>> 3) & 0x1;
5333 tep
->Save_MRP_in_frame
= (tmp1
>> 2) & 0x1;
5334 tep
->extn_ptr_defined
= (tmp1
>> 1) & 0x1;
5335 tep
->Cleanup_defined
= tmp1
& 0x1;
5337 tep
->MPE_XL_interrupt_marker
= (tmp2
>> 31) & 0x1;
5338 tep
->HP_UX_interrupt_marker
= (tmp2
>> 30) & 0x1;
5339 tep
->Large_frame
= (tmp2
>> 29) & 0x1;
5340 tep
->Pseudo_SP_Set
= (tmp2
>> 28) & 0x1;
5341 tep
->reserved4
= (tmp2
>> 27) & 0x1;
5342 tep
->Total_frame_size
= tmp2
& 0x7ffffff;
5346 /* Third, apply any relocations to the unwind table. */
5348 for (relsec
= section_headers
;
5349 relsec
< section_headers
+ elf_header
.e_shnum
;
5352 if (relsec
->sh_type
!= SHT_RELA
5353 || SECTION_HEADER_INDEX (relsec
->sh_info
) >= elf_header
.e_shnum
5354 || SECTION_HEADER (relsec
->sh_info
) != sec
)
5357 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
5361 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
5365 relname
= elf_hppa_reloc_type (ELF32_R_TYPE (rp
->r_info
));
5366 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
5370 relname
= elf_hppa_reloc_type (ELF64_R_TYPE (rp
->r_info
));
5371 sym
= aux
->symtab
+ ELF64_R_SYM (rp
->r_info
);
5374 /* R_PARISC_SEGREL32 or R_PARISC_SEGREL64. */
5375 if (! const_strneq (relname
, "R_PARISC_SEGREL"))
5377 warn (_("Skipping unexpected relocation type %s\n"), relname
);
5381 i
= rp
->r_offset
/ unw_ent_size
;
5383 switch ((rp
->r_offset
% unw_ent_size
) / eh_addr_size
)
5386 aux
->table
[i
].start
.section
= sym
->st_shndx
;
5387 aux
->table
[i
].start
.offset
+= sym
->st_value
+ rp
->r_addend
;
5390 aux
->table
[i
].end
.section
= sym
->st_shndx
;
5391 aux
->table
[i
].end
.offset
+= sym
->st_value
+ rp
->r_addend
;
5401 aux
->table_len
= nentries
;
5407 hppa_process_unwind (FILE *file
)
5409 struct hppa_unw_aux_info aux
;
5410 Elf_Internal_Shdr
*unwsec
= NULL
;
5411 Elf_Internal_Shdr
*strsec
;
5412 Elf_Internal_Shdr
*sec
;
5415 memset (& aux
, 0, sizeof (aux
));
5417 if (string_table
== NULL
)
5420 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5422 if (sec
->sh_type
== SHT_SYMTAB
5423 && SECTION_HEADER_INDEX (sec
->sh_link
) < elf_header
.e_shnum
)
5425 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
5426 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
5428 strsec
= SECTION_HEADER (sec
->sh_link
);
5429 aux
.strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
5430 1, strsec
->sh_size
, _("string table"));
5431 aux
.strtab_size
= aux
.strtab
!= NULL
? strsec
->sh_size
: 0;
5433 else if (streq (SECTION_NAME (sec
), ".PARISC.unwind"))
5438 printf (_("\nThere are no unwind sections in this file.\n"));
5440 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5442 if (streq (SECTION_NAME (sec
), ".PARISC.unwind"))
5444 printf (_("\nUnwind section "));
5445 printf (_("'%s'"), SECTION_NAME (sec
));
5447 printf (_(" at offset 0x%lx contains %lu entries:\n"),
5448 (unsigned long) sec
->sh_offset
,
5449 (unsigned long) (sec
->sh_size
/ (2 * eh_addr_size
+ 8)));
5451 slurp_hppa_unwind_table (file
, &aux
, sec
);
5452 if (aux
.table_len
> 0)
5453 dump_hppa_unwind (&aux
);
5456 free ((char *) aux
.table
);
5464 free ((char *) aux
.strtab
);
5470 process_unwind (FILE *file
)
5472 struct unwind_handler
{
5474 int (*handler
)(FILE *file
);
5476 { EM_IA_64
, ia64_process_unwind
},
5477 { EM_PARISC
, hppa_process_unwind
},
5485 for (i
= 0; handlers
[i
].handler
!= NULL
; i
++)
5486 if (elf_header
.e_machine
== handlers
[i
].machtype
)
5487 return handlers
[i
].handler (file
);
5489 printf (_("\nThere are no unwind sections in this file.\n"));
5494 dynamic_section_mips_val (Elf_Internal_Dyn
*entry
)
5496 switch (entry
->d_tag
)
5499 if (entry
->d_un
.d_val
== 0)
5503 static const char * opts
[] =
5505 "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT",
5506 "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS",
5507 "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD",
5508 "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF",
5513 for (cnt
= 0; cnt
< NUM_ELEM (opts
); ++cnt
)
5514 if (entry
->d_un
.d_val
& (1 << cnt
))
5516 printf ("%s%s", first
? "" : " ", opts
[cnt
]);
5523 case DT_MIPS_IVERSION
:
5524 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
5525 printf ("Interface Version: %s\n", GET_DYNAMIC_NAME (entry
->d_un
.d_val
));
5527 printf ("<corrupt: %ld>\n", (long) entry
->d_un
.d_ptr
);
5530 case DT_MIPS_TIME_STAMP
:
5535 time_t time
= entry
->d_un
.d_val
;
5536 tmp
= gmtime (&time
);
5537 snprintf (timebuf
, sizeof (timebuf
), "%04u-%02u-%02uT%02u:%02u:%02u",
5538 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
5539 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
5540 printf ("Time Stamp: %s\n", timebuf
);
5544 case DT_MIPS_RLD_VERSION
:
5545 case DT_MIPS_LOCAL_GOTNO
:
5546 case DT_MIPS_CONFLICTNO
:
5547 case DT_MIPS_LIBLISTNO
:
5548 case DT_MIPS_SYMTABNO
:
5549 case DT_MIPS_UNREFEXTNO
:
5550 case DT_MIPS_HIPAGENO
:
5551 case DT_MIPS_DELTA_CLASS_NO
:
5552 case DT_MIPS_DELTA_INSTANCE_NO
:
5553 case DT_MIPS_DELTA_RELOC_NO
:
5554 case DT_MIPS_DELTA_SYM_NO
:
5555 case DT_MIPS_DELTA_CLASSSYM_NO
:
5556 case DT_MIPS_COMPACT_SIZE
:
5557 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
5561 printf ("%#lx\n", (long) entry
->d_un
.d_ptr
);
5567 dynamic_section_parisc_val (Elf_Internal_Dyn
*entry
)
5569 switch (entry
->d_tag
)
5571 case DT_HP_DLD_FLAGS
:
5580 { DT_HP_DEBUG_PRIVATE
, "HP_DEBUG_PRIVATE" },
5581 { DT_HP_DEBUG_CALLBACK
, "HP_DEBUG_CALLBACK" },
5582 { DT_HP_DEBUG_CALLBACK_BOR
, "HP_DEBUG_CALLBACK_BOR" },
5583 { DT_HP_NO_ENVVAR
, "HP_NO_ENVVAR" },
5584 { DT_HP_BIND_NOW
, "HP_BIND_NOW" },
5585 { DT_HP_BIND_NONFATAL
, "HP_BIND_NONFATAL" },
5586 { DT_HP_BIND_VERBOSE
, "HP_BIND_VERBOSE" },
5587 { DT_HP_BIND_RESTRICTED
, "HP_BIND_RESTRICTED" },
5588 { DT_HP_BIND_SYMBOLIC
, "HP_BIND_SYMBOLIC" },
5589 { DT_HP_RPATH_FIRST
, "HP_RPATH_FIRST" },
5590 { DT_HP_BIND_DEPTH_FIRST
, "HP_BIND_DEPTH_FIRST" },
5591 { DT_HP_GST
, "HP_GST" },
5592 { DT_HP_SHLIB_FIXED
, "HP_SHLIB_FIXED" },
5593 { DT_HP_MERGE_SHLIB_SEG
, "HP_MERGE_SHLIB_SEG" },
5594 { DT_HP_NODELETE
, "HP_NODELETE" },
5595 { DT_HP_GROUP
, "HP_GROUP" },
5596 { DT_HP_PROTECT_LINKAGE_TABLE
, "HP_PROTECT_LINKAGE_TABLE" }
5600 bfd_vma val
= entry
->d_un
.d_val
;
5602 for (cnt
= 0; cnt
< sizeof (flags
) / sizeof (flags
[0]); ++cnt
)
5603 if (val
& flags
[cnt
].bit
)
5607 fputs (flags
[cnt
].str
, stdout
);
5609 val
^= flags
[cnt
].bit
;
5612 if (val
!= 0 || first
)
5616 print_vma (val
, HEX
);
5622 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5629 dynamic_section_ia64_val (Elf_Internal_Dyn
*entry
)
5631 switch (entry
->d_tag
)
5633 case DT_IA_64_PLT_RESERVE
:
5634 /* First 3 slots reserved. */
5635 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5637 print_vma (entry
->d_un
.d_ptr
+ (3 * 8), PREFIX_HEX
);
5641 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5648 get_32bit_dynamic_section (FILE *file
)
5650 Elf32_External_Dyn
*edyn
, *ext
;
5651 Elf_Internal_Dyn
*entry
;
5653 edyn
= get_data (NULL
, file
, dynamic_addr
, 1, dynamic_size
,
5654 _("dynamic section"));
5658 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
5659 might not have the luxury of section headers. Look for the DT_NULL
5660 terminator to determine the number of entries. */
5661 for (ext
= edyn
, dynamic_nent
= 0;
5662 (char *) ext
< (char *) edyn
+ dynamic_size
;
5666 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
5670 dynamic_section
= cmalloc (dynamic_nent
, sizeof (*entry
));
5671 if (dynamic_section
== NULL
)
5673 error (_("Out of memory\n"));
5678 for (ext
= edyn
, entry
= dynamic_section
;
5679 entry
< dynamic_section
+ dynamic_nent
;
5682 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
5683 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
5692 get_64bit_dynamic_section (FILE *file
)
5694 Elf64_External_Dyn
*edyn
, *ext
;
5695 Elf_Internal_Dyn
*entry
;
5697 edyn
= get_data (NULL
, file
, dynamic_addr
, 1, dynamic_size
,
5698 _("dynamic section"));
5702 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
5703 might not have the luxury of section headers. Look for the DT_NULL
5704 terminator to determine the number of entries. */
5705 for (ext
= edyn
, dynamic_nent
= 0;
5706 (char *) ext
< (char *) edyn
+ dynamic_size
;
5710 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
5714 dynamic_section
= cmalloc (dynamic_nent
, sizeof (*entry
));
5715 if (dynamic_section
== NULL
)
5717 error (_("Out of memory\n"));
5722 for (ext
= edyn
, entry
= dynamic_section
;
5723 entry
< dynamic_section
+ dynamic_nent
;
5726 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
5727 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
5736 print_dynamic_flags (bfd_vma flags
)
5744 flag
= flags
& - flags
;
5754 case DF_ORIGIN
: fputs ("ORIGIN", stdout
); break;
5755 case DF_SYMBOLIC
: fputs ("SYMBOLIC", stdout
); break;
5756 case DF_TEXTREL
: fputs ("TEXTREL", stdout
); break;
5757 case DF_BIND_NOW
: fputs ("BIND_NOW", stdout
); break;
5758 case DF_STATIC_TLS
: fputs ("STATIC_TLS", stdout
); break;
5759 default: fputs ("unknown", stdout
); break;
5765 /* Parse and display the contents of the dynamic section. */
5768 process_dynamic_section (FILE *file
)
5770 Elf_Internal_Dyn
*entry
;
5772 if (dynamic_size
== 0)
5775 printf (_("\nThere is no dynamic section in this file.\n"));
5782 if (! get_32bit_dynamic_section (file
))
5785 else if (! get_64bit_dynamic_section (file
))
5788 /* Find the appropriate symbol table. */
5789 if (dynamic_symbols
== NULL
)
5791 for (entry
= dynamic_section
;
5792 entry
< dynamic_section
+ dynamic_nent
;
5795 Elf_Internal_Shdr section
;
5797 if (entry
->d_tag
!= DT_SYMTAB
)
5800 dynamic_info
[DT_SYMTAB
] = entry
->d_un
.d_val
;
5802 /* Since we do not know how big the symbol table is,
5803 we default to reading in the entire file (!) and
5804 processing that. This is overkill, I know, but it
5806 section
.sh_offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
5808 if (archive_file_offset
!= 0)
5809 section
.sh_size
= archive_file_size
- section
.sh_offset
;
5812 if (fseek (file
, 0, SEEK_END
))
5813 error (_("Unable to seek to end of file!"));
5815 section
.sh_size
= ftell (file
) - section
.sh_offset
;
5819 section
.sh_entsize
= sizeof (Elf32_External_Sym
);
5821 section
.sh_entsize
= sizeof (Elf64_External_Sym
);
5823 num_dynamic_syms
= section
.sh_size
/ section
.sh_entsize
;
5824 if (num_dynamic_syms
< 1)
5826 error (_("Unable to determine the number of symbols to load\n"));
5830 dynamic_symbols
= GET_ELF_SYMBOLS (file
, §ion
);
5834 /* Similarly find a string table. */
5835 if (dynamic_strings
== NULL
)
5837 for (entry
= dynamic_section
;
5838 entry
< dynamic_section
+ dynamic_nent
;
5841 unsigned long offset
;
5844 if (entry
->d_tag
!= DT_STRTAB
)
5847 dynamic_info
[DT_STRTAB
] = entry
->d_un
.d_val
;
5849 /* Since we do not know how big the string table is,
5850 we default to reading in the entire file (!) and
5851 processing that. This is overkill, I know, but it
5854 offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
5856 if (archive_file_offset
!= 0)
5857 str_tab_len
= archive_file_size
- offset
;
5860 if (fseek (file
, 0, SEEK_END
))
5861 error (_("Unable to seek to end of file\n"));
5862 str_tab_len
= ftell (file
) - offset
;
5865 if (str_tab_len
< 1)
5868 (_("Unable to determine the length of the dynamic string table\n"));
5872 dynamic_strings
= get_data (NULL
, file
, offset
, 1, str_tab_len
,
5873 _("dynamic string table"));
5874 dynamic_strings_length
= str_tab_len
;
5879 /* And find the syminfo section if available. */
5880 if (dynamic_syminfo
== NULL
)
5882 unsigned long syminsz
= 0;
5884 for (entry
= dynamic_section
;
5885 entry
< dynamic_section
+ dynamic_nent
;
5888 if (entry
->d_tag
== DT_SYMINENT
)
5890 /* Note: these braces are necessary to avoid a syntax
5891 error from the SunOS4 C compiler. */
5892 assert (sizeof (Elf_External_Syminfo
) == entry
->d_un
.d_val
);
5894 else if (entry
->d_tag
== DT_SYMINSZ
)
5895 syminsz
= entry
->d_un
.d_val
;
5896 else if (entry
->d_tag
== DT_SYMINFO
)
5897 dynamic_syminfo_offset
= offset_from_vma (file
, entry
->d_un
.d_val
,
5901 if (dynamic_syminfo_offset
!= 0 && syminsz
!= 0)
5903 Elf_External_Syminfo
*extsyminfo
, *extsym
;
5904 Elf_Internal_Syminfo
*syminfo
;
5906 /* There is a syminfo section. Read the data. */
5907 extsyminfo
= get_data (NULL
, file
, dynamic_syminfo_offset
, 1,
5908 syminsz
, _("symbol information"));
5912 dynamic_syminfo
= malloc (syminsz
);
5913 if (dynamic_syminfo
== NULL
)
5915 error (_("Out of memory\n"));
5919 dynamic_syminfo_nent
= syminsz
/ sizeof (Elf_External_Syminfo
);
5920 for (syminfo
= dynamic_syminfo
, extsym
= extsyminfo
;
5921 syminfo
< dynamic_syminfo
+ dynamic_syminfo_nent
;
5922 ++syminfo
, ++extsym
)
5924 syminfo
->si_boundto
= BYTE_GET (extsym
->si_boundto
);
5925 syminfo
->si_flags
= BYTE_GET (extsym
->si_flags
);
5932 if (do_dynamic
&& dynamic_addr
)
5933 printf (_("\nDynamic section at offset 0x%lx contains %u entries:\n"),
5934 dynamic_addr
, dynamic_nent
);
5936 printf (_(" Tag Type Name/Value\n"));
5938 for (entry
= dynamic_section
;
5939 entry
< dynamic_section
+ dynamic_nent
;
5947 print_vma (entry
->d_tag
, FULL_HEX
);
5948 dtype
= get_dynamic_type (entry
->d_tag
);
5949 printf (" (%s)%*s", dtype
,
5950 ((is_32bit_elf
? 27 : 19)
5951 - (int) strlen (dtype
)),
5955 switch (entry
->d_tag
)
5959 print_dynamic_flags (entry
->d_un
.d_val
);
5969 switch (entry
->d_tag
)
5972 printf (_("Auxiliary library"));
5976 printf (_("Filter library"));
5980 printf (_("Configuration file"));
5984 printf (_("Dependency audit library"));
5988 printf (_("Audit library"));
5992 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
5993 printf (": [%s]\n", GET_DYNAMIC_NAME (entry
->d_un
.d_val
));
5997 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6006 printf (_("Flags:"));
6008 if (entry
->d_un
.d_val
== 0)
6009 printf (_(" None\n"));
6012 unsigned long int val
= entry
->d_un
.d_val
;
6014 if (val
& DTF_1_PARINIT
)
6016 printf (" PARINIT");
6017 val
^= DTF_1_PARINIT
;
6019 if (val
& DTF_1_CONFEXP
)
6021 printf (" CONFEXP");
6022 val
^= DTF_1_CONFEXP
;
6025 printf (" %lx", val
);
6034 printf (_("Flags:"));
6036 if (entry
->d_un
.d_val
== 0)
6037 printf (_(" None\n"));
6040 unsigned long int val
= entry
->d_un
.d_val
;
6042 if (val
& DF_P1_LAZYLOAD
)
6044 printf (" LAZYLOAD");
6045 val
^= DF_P1_LAZYLOAD
;
6047 if (val
& DF_P1_GROUPPERM
)
6049 printf (" GROUPPERM");
6050 val
^= DF_P1_GROUPPERM
;
6053 printf (" %lx", val
);
6062 printf (_("Flags:"));
6063 if (entry
->d_un
.d_val
== 0)
6064 printf (_(" None\n"));
6067 unsigned long int val
= entry
->d_un
.d_val
;
6074 if (val
& DF_1_GLOBAL
)
6079 if (val
& DF_1_GROUP
)
6084 if (val
& DF_1_NODELETE
)
6086 printf (" NODELETE");
6087 val
^= DF_1_NODELETE
;
6089 if (val
& DF_1_LOADFLTR
)
6091 printf (" LOADFLTR");
6092 val
^= DF_1_LOADFLTR
;
6094 if (val
& DF_1_INITFIRST
)
6096 printf (" INITFIRST");
6097 val
^= DF_1_INITFIRST
;
6099 if (val
& DF_1_NOOPEN
)
6104 if (val
& DF_1_ORIGIN
)
6109 if (val
& DF_1_DIRECT
)
6114 if (val
& DF_1_TRANS
)
6119 if (val
& DF_1_INTERPOSE
)
6121 printf (" INTERPOSE");
6122 val
^= DF_1_INTERPOSE
;
6124 if (val
& DF_1_NODEFLIB
)
6126 printf (" NODEFLIB");
6127 val
^= DF_1_NODEFLIB
;
6129 if (val
& DF_1_NODUMP
)
6134 if (val
& DF_1_CONLFAT
)
6136 printf (" CONLFAT");
6137 val
^= DF_1_CONLFAT
;
6140 printf (" %lx", val
);
6147 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6149 puts (get_dynamic_type (entry
->d_un
.d_val
));
6169 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6175 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
6176 name
= GET_DYNAMIC_NAME (entry
->d_un
.d_val
);
6182 switch (entry
->d_tag
)
6185 printf (_("Shared library: [%s]"), name
);
6187 if (streq (name
, program_interpreter
))
6188 printf (_(" program interpreter"));
6192 printf (_("Library soname: [%s]"), name
);
6196 printf (_("Library rpath: [%s]"), name
);
6200 printf (_("Library runpath: [%s]"), name
);
6204 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6209 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6222 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6226 case DT_INIT_ARRAYSZ
:
6227 case DT_FINI_ARRAYSZ
:
6228 case DT_GNU_CONFLICTSZ
:
6229 case DT_GNU_LIBLISTSZ
:
6232 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
6233 printf (" (bytes)\n");
6243 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
6256 if (entry
->d_tag
== DT_USED
6257 && VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
6259 char *name
= GET_DYNAMIC_NAME (entry
->d_un
.d_val
);
6263 printf (_("Not needed object: [%s]\n"), name
);
6268 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6274 /* The value of this entry is ignored. */
6279 case DT_GNU_PRELINKED
:
6283 time_t time
= entry
->d_un
.d_val
;
6285 tmp
= gmtime (&time
);
6286 printf ("%04u-%02u-%02uT%02u:%02u:%02u\n",
6287 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
6288 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
6294 dynamic_info_DT_GNU_HASH
= entry
->d_un
.d_val
;
6297 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6303 if ((entry
->d_tag
>= DT_VERSYM
) && (entry
->d_tag
<= DT_VERNEEDNUM
))
6304 version_info
[DT_VERSIONTAGIDX (entry
->d_tag
)] =
6309 switch (elf_header
.e_machine
)
6312 case EM_MIPS_RS3_LE
:
6313 dynamic_section_mips_val (entry
);
6316 dynamic_section_parisc_val (entry
);
6319 dynamic_section_ia64_val (entry
);
6322 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6334 get_ver_flags (unsigned int flags
)
6336 static char buff
[32];
6343 if (flags
& VER_FLG_BASE
)
6344 strcat (buff
, "BASE ");
6346 if (flags
& VER_FLG_WEAK
)
6348 if (flags
& VER_FLG_BASE
)
6349 strcat (buff
, "| ");
6351 strcat (buff
, "WEAK ");
6354 if (flags
& ~(VER_FLG_BASE
| VER_FLG_WEAK
))
6355 strcat (buff
, "| <unknown>");
6360 /* Display the contents of the version sections. */
6362 process_version_sections (FILE *file
)
6364 Elf_Internal_Shdr
*section
;
6371 for (i
= 0, section
= section_headers
;
6372 i
< elf_header
.e_shnum
;
6375 switch (section
->sh_type
)
6377 case SHT_GNU_verdef
:
6379 Elf_External_Verdef
*edefs
;
6386 (_("\nVersion definition section '%s' contains %ld entries:\n"),
6387 SECTION_NAME (section
), section
->sh_info
);
6389 printf (_(" Addr: 0x"));
6390 printf_vma (section
->sh_addr
);
6391 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
6392 (unsigned long) section
->sh_offset
, section
->sh_link
,
6393 SECTION_HEADER_INDEX (section
->sh_link
)
6394 < elf_header
.e_shnum
6395 ? SECTION_NAME (SECTION_HEADER (section
->sh_link
))
6398 edefs
= get_data (NULL
, file
, section
->sh_offset
, 1,
6400 _("version definition section"));
6404 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
6407 Elf_External_Verdef
*edef
;
6408 Elf_Internal_Verdef ent
;
6409 Elf_External_Verdaux
*eaux
;
6410 Elf_Internal_Verdaux aux
;
6414 vstart
= ((char *) edefs
) + idx
;
6416 edef
= (Elf_External_Verdef
*) vstart
;
6418 ent
.vd_version
= BYTE_GET (edef
->vd_version
);
6419 ent
.vd_flags
= BYTE_GET (edef
->vd_flags
);
6420 ent
.vd_ndx
= BYTE_GET (edef
->vd_ndx
);
6421 ent
.vd_cnt
= BYTE_GET (edef
->vd_cnt
);
6422 ent
.vd_hash
= BYTE_GET (edef
->vd_hash
);
6423 ent
.vd_aux
= BYTE_GET (edef
->vd_aux
);
6424 ent
.vd_next
= BYTE_GET (edef
->vd_next
);
6426 printf (_(" %#06x: Rev: %d Flags: %s"),
6427 idx
, ent
.vd_version
, get_ver_flags (ent
.vd_flags
));
6429 printf (_(" Index: %d Cnt: %d "),
6430 ent
.vd_ndx
, ent
.vd_cnt
);
6432 vstart
+= ent
.vd_aux
;
6434 eaux
= (Elf_External_Verdaux
*) vstart
;
6436 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
6437 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
6439 if (VALID_DYNAMIC_NAME (aux
.vda_name
))
6440 printf (_("Name: %s\n"), GET_DYNAMIC_NAME (aux
.vda_name
));
6442 printf (_("Name index: %ld\n"), aux
.vda_name
);
6444 isum
= idx
+ ent
.vd_aux
;
6446 for (j
= 1; j
< ent
.vd_cnt
; j
++)
6448 isum
+= aux
.vda_next
;
6449 vstart
+= aux
.vda_next
;
6451 eaux
= (Elf_External_Verdaux
*) vstart
;
6453 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
6454 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
6456 if (VALID_DYNAMIC_NAME (aux
.vda_name
))
6457 printf (_(" %#06x: Parent %d: %s\n"),
6458 isum
, j
, GET_DYNAMIC_NAME (aux
.vda_name
));
6460 printf (_(" %#06x: Parent %d, name index: %ld\n"),
6461 isum
, j
, aux
.vda_name
);
6471 case SHT_GNU_verneed
:
6473 Elf_External_Verneed
*eneed
;
6479 printf (_("\nVersion needs section '%s' contains %ld entries:\n"),
6480 SECTION_NAME (section
), section
->sh_info
);
6482 printf (_(" Addr: 0x"));
6483 printf_vma (section
->sh_addr
);
6484 printf (_(" Offset: %#08lx Link to section: %ld (%s)\n"),
6485 (unsigned long) section
->sh_offset
, section
->sh_link
,
6486 SECTION_HEADER_INDEX (section
->sh_link
)
6487 < elf_header
.e_shnum
6488 ? SECTION_NAME (SECTION_HEADER (section
->sh_link
))
6491 eneed
= get_data (NULL
, file
, section
->sh_offset
, 1,
6493 _("version need section"));
6497 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
6499 Elf_External_Verneed
*entry
;
6500 Elf_Internal_Verneed ent
;
6505 vstart
= ((char *) eneed
) + idx
;
6507 entry
= (Elf_External_Verneed
*) vstart
;
6509 ent
.vn_version
= BYTE_GET (entry
->vn_version
);
6510 ent
.vn_cnt
= BYTE_GET (entry
->vn_cnt
);
6511 ent
.vn_file
= BYTE_GET (entry
->vn_file
);
6512 ent
.vn_aux
= BYTE_GET (entry
->vn_aux
);
6513 ent
.vn_next
= BYTE_GET (entry
->vn_next
);
6515 printf (_(" %#06x: Version: %d"), idx
, ent
.vn_version
);
6517 if (VALID_DYNAMIC_NAME (ent
.vn_file
))
6518 printf (_(" File: %s"), GET_DYNAMIC_NAME (ent
.vn_file
));
6520 printf (_(" File: %lx"), ent
.vn_file
);
6522 printf (_(" Cnt: %d\n"), ent
.vn_cnt
);
6524 vstart
+= ent
.vn_aux
;
6526 for (j
= 0, isum
= idx
+ ent
.vn_aux
; j
< ent
.vn_cnt
; ++j
)
6528 Elf_External_Vernaux
*eaux
;
6529 Elf_Internal_Vernaux aux
;
6531 eaux
= (Elf_External_Vernaux
*) vstart
;
6533 aux
.vna_hash
= BYTE_GET (eaux
->vna_hash
);
6534 aux
.vna_flags
= BYTE_GET (eaux
->vna_flags
);
6535 aux
.vna_other
= BYTE_GET (eaux
->vna_other
);
6536 aux
.vna_name
= BYTE_GET (eaux
->vna_name
);
6537 aux
.vna_next
= BYTE_GET (eaux
->vna_next
);
6539 if (VALID_DYNAMIC_NAME (aux
.vna_name
))
6540 printf (_(" %#06x: Name: %s"),
6541 isum
, GET_DYNAMIC_NAME (aux
.vna_name
));
6543 printf (_(" %#06x: Name index: %lx"),
6544 isum
, aux
.vna_name
);
6546 printf (_(" Flags: %s Version: %d\n"),
6547 get_ver_flags (aux
.vna_flags
), aux
.vna_other
);
6549 isum
+= aux
.vna_next
;
6550 vstart
+= aux
.vna_next
;
6560 case SHT_GNU_versym
:
6562 Elf_Internal_Shdr
*link_section
;
6565 unsigned char *edata
;
6566 unsigned short *data
;
6568 Elf_Internal_Sym
*symbols
;
6569 Elf_Internal_Shdr
*string_sec
;
6572 if (SECTION_HEADER_INDEX (section
->sh_link
) >= elf_header
.e_shnum
)
6575 link_section
= SECTION_HEADER (section
->sh_link
);
6576 total
= section
->sh_size
/ sizeof (Elf_External_Versym
);
6578 if (SECTION_HEADER_INDEX (link_section
->sh_link
)
6579 >= elf_header
.e_shnum
)
6584 symbols
= GET_ELF_SYMBOLS (file
, link_section
);
6586 string_sec
= SECTION_HEADER (link_section
->sh_link
);
6588 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
, 1,
6589 string_sec
->sh_size
, _("version string table"));
6593 printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
6594 SECTION_NAME (section
), total
);
6596 printf (_(" Addr: "));
6597 printf_vma (section
->sh_addr
);
6598 printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
6599 (unsigned long) section
->sh_offset
, section
->sh_link
,
6600 SECTION_NAME (link_section
));
6602 off
= offset_from_vma (file
,
6603 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
6604 total
* sizeof (short));
6605 edata
= get_data (NULL
, file
, off
, total
, sizeof (short),
6606 _("version symbol data"));
6613 data
= cmalloc (total
, sizeof (short));
6615 for (cnt
= total
; cnt
--;)
6616 data
[cnt
] = byte_get (edata
+ cnt
* sizeof (short),
6621 for (cnt
= 0; cnt
< total
; cnt
+= 4)
6624 int check_def
, check_need
;
6627 printf (" %03x:", cnt
);
6629 for (j
= 0; (j
< 4) && (cnt
+ j
) < total
; ++j
)
6630 switch (data
[cnt
+ j
])
6633 fputs (_(" 0 (*local*) "), stdout
);
6637 fputs (_(" 1 (*global*) "), stdout
);
6641 nn
= printf ("%4x%c", data
[cnt
+ j
] & 0x7fff,
6642 data
[cnt
+ j
] & 0x8000 ? 'h' : ' ');
6646 if (SECTION_HEADER_INDEX (symbols
[cnt
+ j
].st_shndx
)
6647 >= elf_header
.e_shnum
6648 || SECTION_HEADER (symbols
[cnt
+ j
].st_shndx
)->sh_type
6651 if (symbols
[cnt
+ j
].st_shndx
== SHN_UNDEF
)
6658 && version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)])
6660 Elf_Internal_Verneed ivn
;
6661 unsigned long offset
;
6663 offset
= offset_from_vma
6664 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
6665 sizeof (Elf_External_Verneed
));
6669 Elf_Internal_Vernaux ivna
;
6670 Elf_External_Verneed evn
;
6671 Elf_External_Vernaux evna
;
6672 unsigned long a_off
;
6674 get_data (&evn
, file
, offset
, sizeof (evn
), 1,
6677 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
6678 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
6680 a_off
= offset
+ ivn
.vn_aux
;
6684 get_data (&evna
, file
, a_off
, sizeof (evna
),
6685 1, _("version need aux (2)"));
6687 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
6688 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
6690 a_off
+= ivna
.vna_next
;
6692 while (ivna
.vna_other
!= data
[cnt
+ j
]
6693 && ivna
.vna_next
!= 0);
6695 if (ivna
.vna_other
== data
[cnt
+ j
])
6697 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
6699 name
= strtab
+ ivna
.vna_name
;
6700 nn
+= printf ("(%s%-*s",
6702 12 - (int) strlen (name
),
6708 offset
+= ivn
.vn_next
;
6710 while (ivn
.vn_next
);
6713 if (check_def
&& data
[cnt
+ j
] != 0x8001
6714 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
6716 Elf_Internal_Verdef ivd
;
6717 Elf_External_Verdef evd
;
6718 unsigned long offset
;
6720 offset
= offset_from_vma
6721 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
6726 get_data (&evd
, file
, offset
, sizeof (evd
), 1,
6729 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
6730 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
6732 offset
+= ivd
.vd_next
;
6734 while (ivd
.vd_ndx
!= (data
[cnt
+ j
] & 0x7fff)
6735 && ivd
.vd_next
!= 0);
6737 if (ivd
.vd_ndx
== (data
[cnt
+ j
] & 0x7fff))
6739 Elf_External_Verdaux evda
;
6740 Elf_Internal_Verdaux ivda
;
6742 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
6744 get_data (&evda
, file
,
6745 offset
- ivd
.vd_next
+ ivd
.vd_aux
,
6747 _("version def aux"));
6749 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
6751 name
= strtab
+ ivda
.vda_name
;
6752 nn
+= printf ("(%s%-*s",
6754 12 - (int) strlen (name
),
6760 printf ("%*c", 18 - nn
, ' ');
6778 printf (_("\nNo version information found in this file.\n"));
6784 get_symbol_binding (unsigned int binding
)
6786 static char buff
[32];
6790 case STB_LOCAL
: return "LOCAL";
6791 case STB_GLOBAL
: return "GLOBAL";
6792 case STB_WEAK
: return "WEAK";
6794 if (binding
>= STB_LOPROC
&& binding
<= STB_HIPROC
)
6795 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"),
6797 else if (binding
>= STB_LOOS
&& binding
<= STB_HIOS
)
6798 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), binding
);
6800 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), binding
);
6806 get_symbol_type (unsigned int type
)
6808 static char buff
[32];
6812 case STT_NOTYPE
: return "NOTYPE";
6813 case STT_OBJECT
: return "OBJECT";
6814 case STT_FUNC
: return "FUNC";
6815 case STT_SECTION
: return "SECTION";
6816 case STT_FILE
: return "FILE";
6817 case STT_COMMON
: return "COMMON";
6818 case STT_TLS
: return "TLS";
6820 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
6822 if (elf_header
.e_machine
== EM_ARM
&& type
== STT_ARM_TFUNC
)
6823 return "THUMB_FUNC";
6825 if (elf_header
.e_machine
== EM_SPARCV9
&& type
== STT_REGISTER
)
6828 if (elf_header
.e_machine
== EM_PARISC
&& type
== STT_PARISC_MILLI
)
6829 return "PARISC_MILLI";
6831 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"), type
);
6833 else if (type
>= STT_LOOS
&& type
<= STT_HIOS
)
6835 if (elf_header
.e_machine
== EM_PARISC
)
6837 if (type
== STT_HP_OPAQUE
)
6839 if (type
== STT_HP_STUB
)
6843 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), type
);
6846 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), type
);
6852 get_symbol_visibility (unsigned int visibility
)
6856 case STV_DEFAULT
: return "DEFAULT";
6857 case STV_INTERNAL
: return "INTERNAL";
6858 case STV_HIDDEN
: return "HIDDEN";
6859 case STV_PROTECTED
: return "PROTECTED";
6865 get_mips_symbol_other (unsigned int other
)
6869 case STO_OPTIONAL
: return "OPTIONAL";
6870 case STO_MIPS16
: return "MIPS16";
6871 default: return NULL
;
6876 get_symbol_other (unsigned int other
)
6878 const char * result
= NULL
;
6879 static char buff
[32];
6884 switch (elf_header
.e_machine
)
6887 result
= get_mips_symbol_other (other
);
6895 snprintf (buff
, sizeof buff
, _("<other>: %x"), other
);
6900 get_symbol_index_type (unsigned int type
)
6902 static char buff
[32];
6906 case SHN_UNDEF
: return "UND";
6907 case SHN_ABS
: return "ABS";
6908 case SHN_COMMON
: return "COM";
6910 if (type
== SHN_IA_64_ANSI_COMMON
6911 && elf_header
.e_machine
== EM_IA_64
6912 && elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
)
6914 else if (elf_header
.e_machine
== EM_X86_64
6915 && type
== SHN_X86_64_LCOMMON
)
6917 else if (type
== SHN_MIPS_SCOMMON
6918 && elf_header
.e_machine
== EM_MIPS
)
6920 else if (type
== SHN_MIPS_SUNDEFINED
6921 && elf_header
.e_machine
== EM_MIPS
)
6923 else if (type
>= SHN_LOPROC
&& type
<= SHN_HIPROC
)
6924 sprintf (buff
, "PRC[0x%04x]", type
);
6925 else if (type
>= SHN_LOOS
&& type
<= SHN_HIOS
)
6926 sprintf (buff
, "OS [0x%04x]", type
);
6927 else if (type
>= SHN_LORESERVE
&& type
<= SHN_HIRESERVE
)
6928 sprintf (buff
, "RSV[0x%04x]", type
);
6930 sprintf (buff
, "%3d", type
);
6938 get_dynamic_data (FILE *file
, unsigned int number
, unsigned int ent_size
)
6940 unsigned char *e_data
;
6943 e_data
= cmalloc (number
, ent_size
);
6947 error (_("Out of memory\n"));
6951 if (fread (e_data
, ent_size
, number
, file
) != number
)
6953 error (_("Unable to read in dynamic data\n"));
6957 i_data
= cmalloc (number
, sizeof (*i_data
));
6961 error (_("Out of memory\n"));
6967 i_data
[number
] = byte_get (e_data
+ number
* ent_size
, ent_size
);
6974 /* Dump the symbol table. */
6976 process_symbol_table (FILE *file
)
6978 Elf_Internal_Shdr
*section
;
6979 bfd_vma nbuckets
= 0;
6980 bfd_vma nchains
= 0;
6981 bfd_vma
*buckets
= NULL
;
6982 bfd_vma
*chains
= NULL
;
6983 bfd_vma ngnubuckets
= 0;
6984 bfd_vma
*gnubuckets
= NULL
;
6985 bfd_vma
*gnuchains
= NULL
;
6987 if (! do_syms
&& !do_histogram
)
6990 if (dynamic_info
[DT_HASH
] && ((do_using_dynamic
&& dynamic_strings
!= NULL
)
6993 unsigned char nb
[8];
6994 unsigned char nc
[8];
6995 int hash_ent_size
= 4;
6997 if ((elf_header
.e_machine
== EM_ALPHA
6998 || elf_header
.e_machine
== EM_S390
6999 || elf_header
.e_machine
== EM_S390_OLD
)
7000 && elf_header
.e_ident
[EI_CLASS
] == ELFCLASS64
)
7004 (archive_file_offset
7005 + offset_from_vma (file
, dynamic_info
[DT_HASH
],
7006 sizeof nb
+ sizeof nc
)),
7009 error (_("Unable to seek to start of dynamic information"));
7013 if (fread (nb
, hash_ent_size
, 1, file
) != 1)
7015 error (_("Failed to read in number of buckets\n"));
7019 if (fread (nc
, hash_ent_size
, 1, file
) != 1)
7021 error (_("Failed to read in number of chains\n"));
7025 nbuckets
= byte_get (nb
, hash_ent_size
);
7026 nchains
= byte_get (nc
, hash_ent_size
);
7028 buckets
= get_dynamic_data (file
, nbuckets
, hash_ent_size
);
7029 chains
= get_dynamic_data (file
, nchains
, hash_ent_size
);
7031 if (buckets
== NULL
|| chains
== NULL
)
7036 && dynamic_info
[DT_HASH
] && do_using_dynamic
&& dynamic_strings
!= NULL
)
7041 printf (_("\nSymbol table for image:\n"));
7043 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7045 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7047 for (hn
= 0; hn
< nbuckets
; hn
++)
7052 for (si
= buckets
[hn
]; si
< nchains
&& si
> 0; si
= chains
[si
])
7054 Elf_Internal_Sym
*psym
;
7057 psym
= dynamic_symbols
+ si
;
7059 n
= print_vma (si
, DEC_5
);
7061 fputs (" " + n
, stdout
);
7062 printf (" %3lu: ", hn
);
7063 print_vma (psym
->st_value
, LONG_HEX
);
7065 print_vma (psym
->st_size
, DEC_5
);
7067 printf (" %6s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
7068 printf (" %6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
7069 printf (" %3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
7070 /* Check to see if any other bits in the st_other field are set.
7071 Note - displaying this information disrupts the layout of the
7072 table being generated, but for the moment this case is very rare. */
7073 if (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
))
7074 printf (" [%s] ", get_symbol_other (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
)));
7075 printf (" %3.3s ", get_symbol_index_type (psym
->st_shndx
));
7076 if (VALID_DYNAMIC_NAME (psym
->st_name
))
7077 print_symbol (25, GET_DYNAMIC_NAME (psym
->st_name
));
7079 printf (" <corrupt: %14ld>", psym
->st_name
);
7084 else if (do_syms
&& !do_using_dynamic
)
7088 for (i
= 0, section
= section_headers
;
7089 i
< elf_header
.e_shnum
;
7093 char *strtab
= NULL
;
7094 unsigned long int strtab_size
= 0;
7095 Elf_Internal_Sym
*symtab
;
7096 Elf_Internal_Sym
*psym
;
7099 if ( section
->sh_type
!= SHT_SYMTAB
7100 && section
->sh_type
!= SHT_DYNSYM
)
7103 printf (_("\nSymbol table '%s' contains %lu entries:\n"),
7104 SECTION_NAME (section
),
7105 (unsigned long) (section
->sh_size
/ section
->sh_entsize
));
7107 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
7109 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
7111 symtab
= GET_ELF_SYMBOLS (file
, section
);
7115 if (section
->sh_link
== elf_header
.e_shstrndx
)
7117 strtab
= string_table
;
7118 strtab_size
= string_table_length
;
7120 else if (SECTION_HEADER_INDEX (section
->sh_link
) < elf_header
.e_shnum
)
7122 Elf_Internal_Shdr
*string_sec
;
7124 string_sec
= SECTION_HEADER (section
->sh_link
);
7126 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
,
7127 1, string_sec
->sh_size
, _("string table"));
7128 strtab_size
= strtab
!= NULL
? string_sec
->sh_size
: 0;
7131 for (si
= 0, psym
= symtab
;
7132 si
< section
->sh_size
/ section
->sh_entsize
;
7135 printf ("%6d: ", si
);
7136 print_vma (psym
->st_value
, LONG_HEX
);
7138 print_vma (psym
->st_size
, DEC_5
);
7139 printf (" %-7s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
7140 printf (" %-6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
7141 printf (" %-3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
7142 /* Check to see if any other bits in the st_other field are set.
7143 Note - displaying this information disrupts the layout of the
7144 table being generated, but for the moment this case is very rare. */
7145 if (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
))
7146 printf (" [%s] ", get_symbol_other (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
)));
7147 printf (" %4s ", get_symbol_index_type (psym
->st_shndx
));
7148 print_symbol (25, psym
->st_name
< strtab_size
7149 ? strtab
+ psym
->st_name
: "<corrupt>");
7151 if (section
->sh_type
== SHT_DYNSYM
&&
7152 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] != 0)
7154 unsigned char data
[2];
7155 unsigned short vers_data
;
7156 unsigned long offset
;
7160 offset
= offset_from_vma
7161 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
7162 sizeof data
+ si
* sizeof (vers_data
));
7164 get_data (&data
, file
, offset
+ si
* sizeof (vers_data
),
7165 sizeof (data
), 1, _("version data"));
7167 vers_data
= byte_get (data
, 2);
7169 is_nobits
= (SECTION_HEADER_INDEX (psym
->st_shndx
)
7170 < elf_header
.e_shnum
7171 && SECTION_HEADER (psym
->st_shndx
)->sh_type
7174 check_def
= (psym
->st_shndx
!= SHN_UNDEF
);
7176 if ((vers_data
& 0x8000) || vers_data
> 1)
7178 if (version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
7179 && (is_nobits
|| ! check_def
))
7181 Elf_External_Verneed evn
;
7182 Elf_Internal_Verneed ivn
;
7183 Elf_Internal_Vernaux ivna
;
7185 /* We must test both. */
7186 offset
= offset_from_vma
7187 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
7192 unsigned long vna_off
;
7194 get_data (&evn
, file
, offset
, sizeof (evn
), 1,
7197 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
7198 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
7200 vna_off
= offset
+ ivn
.vn_aux
;
7204 Elf_External_Vernaux evna
;
7206 get_data (&evna
, file
, vna_off
,
7208 _("version need aux (3)"));
7210 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
7211 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
7212 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
7214 vna_off
+= ivna
.vna_next
;
7216 while (ivna
.vna_other
!= vers_data
7217 && ivna
.vna_next
!= 0);
7219 if (ivna
.vna_other
== vers_data
)
7222 offset
+= ivn
.vn_next
;
7224 while (ivn
.vn_next
!= 0);
7226 if (ivna
.vna_other
== vers_data
)
7229 ivna
.vna_name
< strtab_size
7230 ? strtab
+ ivna
.vna_name
: "<corrupt>",
7234 else if (! is_nobits
)
7235 error (_("bad dynamic symbol"));
7242 if (vers_data
!= 0x8001
7243 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
7245 Elf_Internal_Verdef ivd
;
7246 Elf_Internal_Verdaux ivda
;
7247 Elf_External_Verdaux evda
;
7248 unsigned long offset
;
7250 offset
= offset_from_vma
7252 version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
7253 sizeof (Elf_External_Verdef
));
7257 Elf_External_Verdef evd
;
7259 get_data (&evd
, file
, offset
, sizeof (evd
),
7260 1, _("version def"));
7262 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
7263 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
7264 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
7266 offset
+= ivd
.vd_next
;
7268 while (ivd
.vd_ndx
!= (vers_data
& 0x7fff)
7269 && ivd
.vd_next
!= 0);
7271 offset
-= ivd
.vd_next
;
7272 offset
+= ivd
.vd_aux
;
7274 get_data (&evda
, file
, offset
, sizeof (evda
),
7275 1, _("version def aux"));
7277 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
7279 if (psym
->st_name
!= ivda
.vda_name
)
7280 printf ((vers_data
& 0x8000)
7282 ivda
.vda_name
< strtab_size
7283 ? strtab
+ ivda
.vda_name
: "<corrupt>");
7293 if (strtab
!= string_table
)
7299 (_("\nDynamic symbol information is not available for displaying symbols.\n"));
7301 if (do_histogram
&& buckets
!= NULL
)
7303 unsigned long *lengths
;
7304 unsigned long *counts
;
7307 unsigned long maxlength
= 0;
7308 unsigned long nzero_counts
= 0;
7309 unsigned long nsyms
= 0;
7311 printf (_("\nHistogram for bucket list length (total of %lu buckets):\n"),
7312 (unsigned long) nbuckets
);
7313 printf (_(" Length Number %% of total Coverage\n"));
7315 lengths
= calloc (nbuckets
, sizeof (*lengths
));
7316 if (lengths
== NULL
)
7318 error (_("Out of memory"));
7321 for (hn
= 0; hn
< nbuckets
; ++hn
)
7323 for (si
= buckets
[hn
]; si
> 0 && si
< nchains
; si
= chains
[si
])
7326 if (maxlength
< ++lengths
[hn
])
7331 counts
= calloc (maxlength
+ 1, sizeof (*counts
));
7334 error (_("Out of memory"));
7338 for (hn
= 0; hn
< nbuckets
; ++hn
)
7339 ++counts
[lengths
[hn
]];
7344 printf (" 0 %-10lu (%5.1f%%)\n",
7345 counts
[0], (counts
[0] * 100.0) / nbuckets
);
7346 for (i
= 1; i
<= maxlength
; ++i
)
7348 nzero_counts
+= counts
[i
] * i
;
7349 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
7350 i
, counts
[i
], (counts
[i
] * 100.0) / nbuckets
,
7351 (nzero_counts
* 100.0) / nsyms
);
7359 if (buckets
!= NULL
)
7365 if (do_histogram
&& dynamic_info_DT_GNU_HASH
)
7367 unsigned char nb
[16];
7368 bfd_vma i
, maxchain
= 0xffffffff, symidx
, bitmaskwords
;
7369 unsigned long *lengths
;
7370 unsigned long *counts
;
7372 unsigned long maxlength
= 0;
7373 unsigned long nzero_counts
= 0;
7374 unsigned long nsyms
= 0;
7375 bfd_vma buckets_vma
;
7378 (archive_file_offset
7379 + offset_from_vma (file
, dynamic_info_DT_GNU_HASH
,
7383 error (_("Unable to seek to start of dynamic information"));
7387 if (fread (nb
, 16, 1, file
) != 1)
7389 error (_("Failed to read in number of buckets\n"));
7393 ngnubuckets
= byte_get (nb
, 4);
7394 symidx
= byte_get (nb
+ 4, 4);
7395 bitmaskwords
= byte_get (nb
+ 8, 4);
7396 buckets_vma
= dynamic_info_DT_GNU_HASH
+ 16;
7398 buckets_vma
+= bitmaskwords
* 4;
7400 buckets_vma
+= bitmaskwords
* 8;
7403 (archive_file_offset
7404 + offset_from_vma (file
, buckets_vma
, 4)),
7407 error (_("Unable to seek to start of dynamic information"));
7411 gnubuckets
= get_dynamic_data (file
, ngnubuckets
, 4);
7413 if (gnubuckets
== NULL
)
7416 for (i
= 0; i
< ngnubuckets
; i
++)
7417 if (gnubuckets
[i
] != 0)
7419 if (gnubuckets
[i
] < symidx
)
7422 if (maxchain
== 0xffffffff || gnubuckets
[i
] > maxchain
)
7423 maxchain
= gnubuckets
[i
];
7426 if (maxchain
== 0xffffffff)
7432 (archive_file_offset
7433 + offset_from_vma (file
, buckets_vma
7434 + 4 * (ngnubuckets
+ maxchain
), 4)),
7437 error (_("Unable to seek to start of dynamic information"));
7443 if (fread (nb
, 4, 1, file
) != 1)
7445 error (_("Failed to determine last chain length\n"));
7449 if (maxchain
+ 1 == 0)
7454 while ((byte_get (nb
, 4) & 1) == 0);
7457 (archive_file_offset
7458 + offset_from_vma (file
, buckets_vma
+ 4 * ngnubuckets
, 4)),
7461 error (_("Unable to seek to start of dynamic information"));
7465 gnuchains
= get_dynamic_data (file
, maxchain
, 4);
7467 if (gnuchains
== NULL
)
7470 lengths
= calloc (ngnubuckets
, sizeof (*lengths
));
7471 if (lengths
== NULL
)
7473 error (_("Out of memory"));
7477 printf (_("\nHistogram for `.gnu.hash' bucket list length (total of %lu buckets):\n"),
7478 (unsigned long) ngnubuckets
);
7479 printf (_(" Length Number %% of total Coverage\n"));
7481 for (hn
= 0; hn
< ngnubuckets
; ++hn
)
7482 if (gnubuckets
[hn
] != 0)
7484 bfd_vma off
, length
= 1;
7486 for (off
= gnubuckets
[hn
] - symidx
;
7487 (gnuchains
[off
] & 1) == 0; ++off
)
7489 lengths
[hn
] = length
;
7490 if (length
> maxlength
)
7495 counts
= calloc (maxlength
+ 1, sizeof (*counts
));
7498 error (_("Out of memory"));
7502 for (hn
= 0; hn
< ngnubuckets
; ++hn
)
7503 ++counts
[lengths
[hn
]];
7505 if (ngnubuckets
> 0)
7508 printf (" 0 %-10lu (%5.1f%%)\n",
7509 counts
[0], (counts
[0] * 100.0) / ngnubuckets
);
7510 for (j
= 1; j
<= maxlength
; ++j
)
7512 nzero_counts
+= counts
[j
] * j
;
7513 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
7514 j
, counts
[j
], (counts
[j
] * 100.0) / ngnubuckets
,
7515 (nzero_counts
* 100.0) / nsyms
);
7529 process_syminfo (FILE *file ATTRIBUTE_UNUSED
)
7533 if (dynamic_syminfo
== NULL
7535 /* No syminfo, this is ok. */
7538 /* There better should be a dynamic symbol section. */
7539 if (dynamic_symbols
== NULL
|| dynamic_strings
== NULL
)
7543 printf (_("\nDynamic info segment at offset 0x%lx contains %d entries:\n"),
7544 dynamic_syminfo_offset
, dynamic_syminfo_nent
);
7546 printf (_(" Num: Name BoundTo Flags\n"));
7547 for (i
= 0; i
< dynamic_syminfo_nent
; ++i
)
7549 unsigned short int flags
= dynamic_syminfo
[i
].si_flags
;
7551 printf ("%4d: ", i
);
7552 if (VALID_DYNAMIC_NAME (dynamic_symbols
[i
].st_name
))
7553 print_symbol (30, GET_DYNAMIC_NAME (dynamic_symbols
[i
].st_name
));
7555 printf ("<corrupt: %19ld>", dynamic_symbols
[i
].st_name
);
7558 switch (dynamic_syminfo
[i
].si_boundto
)
7560 case SYMINFO_BT_SELF
:
7561 fputs ("SELF ", stdout
);
7563 case SYMINFO_BT_PARENT
:
7564 fputs ("PARENT ", stdout
);
7567 if (dynamic_syminfo
[i
].si_boundto
> 0
7568 && dynamic_syminfo
[i
].si_boundto
< dynamic_nent
7569 && VALID_DYNAMIC_NAME (dynamic_section
[dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
))
7571 print_symbol (10, GET_DYNAMIC_NAME (dynamic_section
[dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
));
7575 printf ("%-10d ", dynamic_syminfo
[i
].si_boundto
);
7579 if (flags
& SYMINFO_FLG_DIRECT
)
7581 if (flags
& SYMINFO_FLG_PASSTHRU
)
7582 printf (" PASSTHRU");
7583 if (flags
& SYMINFO_FLG_COPY
)
7585 if (flags
& SYMINFO_FLG_LAZYLOAD
)
7586 printf (" LAZYLOAD");
7594 #ifdef SUPPORT_DISASSEMBLY
7596 disassemble_section (Elf_Internal_Shdr
*section
, FILE *file
)
7598 printf (_("\nAssembly dump of section %s\n"),
7599 SECTION_NAME (section
));
7601 /* XXX -- to be done --- XXX */
7608 dump_section (Elf_Internal_Shdr
*section
, FILE *file
)
7610 bfd_size_type bytes
;
7612 unsigned char *data
;
7613 unsigned char *start
;
7615 bytes
= section
->sh_size
;
7617 if (bytes
== 0 || section
->sh_type
== SHT_NOBITS
)
7619 printf (_("\nSection '%s' has no data to dump.\n"),
7620 SECTION_NAME (section
));
7624 printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section
));
7626 addr
= section
->sh_addr
;
7628 start
= get_data (NULL
, file
, section
->sh_offset
, 1, bytes
,
7641 lbytes
= (bytes
> 16 ? 16 : bytes
);
7643 printf (" 0x%8.8lx ", (unsigned long) addr
);
7645 switch (elf_header
.e_ident
[EI_DATA
])
7649 for (j
= 15; j
>= 0; j
--)
7652 printf ("%2.2x", data
[j
]);
7662 for (j
= 0; j
< 16; j
++)
7665 printf ("%2.2x", data
[j
]);
7675 for (j
= 0; j
< lbytes
; j
++)
7678 if (k
>= ' ' && k
< 0x7f)
7696 /* Apply addends of RELA relocations. */
7699 debug_apply_rela_addends (void *file
,
7700 Elf_Internal_Shdr
*section
,
7701 unsigned char *start
)
7703 Elf_Internal_Shdr
*relsec
;
7704 unsigned char *end
= start
+ section
->sh_size
;
7705 /* FIXME: The relocation field size is relocation type dependent. */
7706 unsigned int reloc_size
= 4;
7708 if (!is_relocatable
)
7711 if (section
->sh_size
< reloc_size
)
7714 for (relsec
= section_headers
;
7715 relsec
< section_headers
+ elf_header
.e_shnum
;
7718 unsigned long nrelas
;
7719 Elf_Internal_Rela
*rela
, *rp
;
7720 Elf_Internal_Shdr
*symsec
;
7721 Elf_Internal_Sym
*symtab
;
7722 Elf_Internal_Sym
*sym
;
7724 if (relsec
->sh_type
!= SHT_RELA
7725 || SECTION_HEADER_INDEX (relsec
->sh_info
) >= elf_header
.e_shnum
7726 || SECTION_HEADER (relsec
->sh_info
) != section
7727 || relsec
->sh_size
== 0
7728 || SECTION_HEADER_INDEX (relsec
->sh_link
) >= elf_header
.e_shnum
)
7731 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
7735 symsec
= SECTION_HEADER (relsec
->sh_link
);
7736 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
7738 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
7742 loc
= start
+ rp
->r_offset
;
7743 if ((loc
+ reloc_size
) > end
)
7745 warn (_("skipping invalid relocation offset 0x%lx in section %s\n"),
7746 (unsigned long) rp
->r_offset
,
7747 SECTION_NAME (section
));
7753 sym
= symtab
+ ELF32_R_SYM (rp
->r_info
);
7755 if (ELF32_R_SYM (rp
->r_info
) != 0
7756 && ELF32_ST_TYPE (sym
->st_info
) != STT_SECTION
7757 /* Relocations against symbols without type can happen.
7758 Gcc -feliminate-dwarf2-dups may generate symbols
7759 without type for debug info. */
7760 && ELF32_ST_TYPE (sym
->st_info
) != STT_NOTYPE
7761 /* Relocations against object symbols can happen,
7762 eg when referencing a global array. For an
7763 example of this see the _clz.o binary in libgcc.a. */
7764 && ELF32_ST_TYPE (sym
->st_info
) != STT_OBJECT
)
7766 warn (_("skipping unexpected symbol type %s in relocation in section .rela%s\n"),
7767 get_symbol_type (ELF32_ST_TYPE (sym
->st_info
)),
7768 SECTION_NAME (section
));
7774 /* In MIPS little-endian objects, r_info isn't really a
7775 64-bit little-endian value: it has a 32-bit little-endian
7776 symbol index followed by four individual byte fields.
7777 Reorder INFO accordingly. */
7778 if (elf_header
.e_machine
== EM_MIPS
7779 && elf_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
7780 rp
->r_info
= (((rp
->r_info
& 0xffffffff) << 32)
7781 | ((rp
->r_info
>> 56) & 0xff)
7782 | ((rp
->r_info
>> 40) & 0xff00)
7783 | ((rp
->r_info
>> 24) & 0xff0000)
7784 | ((rp
->r_info
>> 8) & 0xff000000));
7786 sym
= symtab
+ ELF64_R_SYM (rp
->r_info
);
7788 if (ELF64_R_SYM (rp
->r_info
) != 0
7789 && ELF64_ST_TYPE (sym
->st_info
) != STT_SECTION
7790 && ELF64_ST_TYPE (sym
->st_info
) != STT_NOTYPE
7791 && ELF64_ST_TYPE (sym
->st_info
) != STT_OBJECT
)
7793 warn (_("skipping unexpected symbol type %s in relocation in section .rela.%s\n"),
7794 get_symbol_type (ELF64_ST_TYPE (sym
->st_info
)),
7795 SECTION_NAME (section
));
7800 byte_put (loc
, rp
->r_addend
, reloc_size
);
7811 load_debug_section (enum dwarf_section_display_enum debug
, void *file
)
7813 struct dwarf_section
*section
= &debug_displays
[debug
].section
;
7814 Elf_Internal_Shdr
*sec
;
7817 /* If it is already loaded, do nothing. */
7818 if (section
->start
!= NULL
)
7821 /* Locate the debug section. */
7822 sec
= find_section (section
->name
);
7826 snprintf (buf
, sizeof (buf
), _("%s section data"), section
->name
);
7827 section
->address
= sec
->sh_addr
;
7828 section
->size
= sec
->sh_size
;
7829 section
->start
= get_data (NULL
, file
, sec
->sh_offset
, 1,
7832 if (debug_displays
[debug
].relocate
)
7833 debug_apply_rela_addends (file
, sec
, section
->start
);
7835 return section
->start
!= NULL
;
7839 free_debug_section (enum dwarf_section_display_enum debug
)
7841 struct dwarf_section
*section
= &debug_displays
[debug
].section
;
7843 if (section
->start
== NULL
)
7846 free ((char *) section
->start
);
7847 section
->start
= NULL
;
7848 section
->address
= 0;
7853 display_debug_section (Elf_Internal_Shdr
*section
, FILE *file
)
7855 char *name
= SECTION_NAME (section
);
7856 bfd_size_type length
;
7858 enum dwarf_section_display_enum i
;
7860 length
= section
->sh_size
;
7863 printf (_("\nSection '%s' has no debugging data.\n"), name
);
7867 if (const_strneq (name
, ".gnu.linkonce.wi."))
7868 name
= ".debug_info";
7870 /* See if we know how to display the contents of this section. */
7871 for (i
= 0; i
< max
; i
++)
7872 if (streq (debug_displays
[i
].section
.name
, name
))
7874 struct dwarf_section
*sec
= &debug_displays
[i
].section
;
7876 if (load_debug_section (i
, file
))
7878 result
&= debug_displays
[i
].display (sec
, file
);
7880 if (i
!= info
&& i
!= abbrev
)
7881 free_debug_section (i
);
7889 printf (_("Unrecognized debug section: %s\n"), name
);
7896 /* Set DUMP_SECTS for all sections where dumps were requested
7897 based on section name. */
7900 initialise_dumps_byname (void)
7902 struct dump_list_entry
*cur
;
7904 for (cur
= dump_sects_byname
; cur
; cur
= cur
->next
)
7909 for (i
= 0, any
= 0; i
< elf_header
.e_shnum
; i
++)
7910 if (streq (SECTION_NAME (section_headers
+ i
), cur
->name
))
7912 request_dump (i
, cur
->type
);
7917 warn (_("Section '%s' was not dumped because it does not exist!\n"),
7923 process_section_contents (FILE *file
)
7925 Elf_Internal_Shdr
*section
;
7931 initialise_dumps_byname ();
7933 for (i
= 0, section
= section_headers
;
7934 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
7937 #ifdef SUPPORT_DISASSEMBLY
7938 if (dump_sects
[i
] & DISASS_DUMP
)
7939 disassemble_section (section
, file
);
7941 if (dump_sects
[i
] & HEX_DUMP
)
7942 dump_section (section
, file
);
7944 if (dump_sects
[i
] & DEBUG_DUMP
)
7945 display_debug_section (section
, file
);
7948 /* Check to see if the user requested a
7949 dump of a section that does not exist. */
7950 while (i
++ < num_dump_sects
)
7952 warn (_("Section %d was not dumped because it does not exist!\n"), i
);
7956 process_mips_fpe_exception (int mask
)
7961 if (mask
& OEX_FPU_INEX
)
7962 fputs ("INEX", stdout
), first
= 0;
7963 if (mask
& OEX_FPU_UFLO
)
7964 printf ("%sUFLO", first
? "" : "|"), first
= 0;
7965 if (mask
& OEX_FPU_OFLO
)
7966 printf ("%sOFLO", first
? "" : "|"), first
= 0;
7967 if (mask
& OEX_FPU_DIV0
)
7968 printf ("%sDIV0", first
? "" : "|"), first
= 0;
7969 if (mask
& OEX_FPU_INVAL
)
7970 printf ("%sINVAL", first
? "" : "|");
7973 fputs ("0", stdout
);
7976 /* ARM EABI attributes section. */
7981 /* 0 = special, 1 = string, 2 = uleb123, > 0x80 == table lookup. */
7984 } arm_attr_public_tag
;
7986 static const char *arm_attr_tag_CPU_arch
[] =
7987 {"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2",
7989 static const char *arm_attr_tag_ARM_ISA_use
[] = {"No", "Yes"};
7990 static const char *arm_attr_tag_THUMB_ISA_use
[] =
7991 {"No", "Thumb-1", "Thumb-2"};
7992 /* FIXME: VFPv3 encoding was extrapolated! */
7993 static const char *arm_attr_tag_VFP_arch
[] = {"No", "VFPv1", "VFPv2", "VFPv3"};
7994 static const char *arm_attr_tag_WMMX_arch
[] = {"No", "WMMXv1"};
7995 static const char *arm_attr_tag_NEON_arch
[] = {"No", "NEONv1"};
7996 static const char *arm_attr_tag_ABI_PCS_config
[] =
7997 {"None", "Bare platform", "Linux application", "Linux DSO", "PalmOS 2004",
7998 "PalmOS (reserved)", "SymbianOS 2004", "SymbianOS (reserved)"};
7999 static const char *arm_attr_tag_ABI_PCS_R9_use
[] =
8000 {"V6", "SB", "TLS", "Unused"};
8001 static const char *arm_attr_tag_ABI_PCS_RW_data
[] =
8002 {"Absolute", "PC-relative", "SB-relative", "None"};
8003 static const char *arm_attr_tag_ABI_PCS_RO_DATA
[] =
8004 {"Absolute", "PC-relative", "None"};
8005 static const char *arm_attr_tag_ABI_PCS_GOT_use
[] =
8006 {"None", "direct", "GOT-indirect"};
8007 static const char *arm_attr_tag_ABI_PCS_wchar_t
[] =
8008 {"None", "??? 1", "2", "??? 3", "4"};
8009 static const char *arm_attr_tag_ABI_FP_rounding
[] = {"Unused", "Needed"};
8010 static const char *arm_attr_tag_ABI_FP_denormal
[] = {"Unused", "Needed"};
8011 static const char *arm_attr_tag_ABI_FP_exceptions
[] = {"Unused", "Needed"};
8012 static const char *arm_attr_tag_ABI_FP_user_exceptions
[] = {"Unused", "Needed"};
8013 static const char *arm_attr_tag_ABI_FP_number_model
[] =
8014 {"Unused", "Finite", "RTABI", "IEEE 754"};
8015 static const char *arm_attr_tag_ABI_align8_needed
[] = {"No", "Yes", "4-byte"};
8016 static const char *arm_attr_tag_ABI_align8_preserved
[] =
8017 {"No", "Yes, except leaf SP", "Yes"};
8018 static const char *arm_attr_tag_ABI_enum_size
[] =
8019 {"Unused", "small", "int", "forced to int"};
8020 static const char *arm_attr_tag_ABI_HardFP_use
[] =
8021 {"As Tag_VFP_arch", "SP only", "DP only", "SP and DP"};
8022 static const char *arm_attr_tag_ABI_VFP_args
[] =
8023 {"AAPCS", "VFP registers", "custom"};
8024 static const char *arm_attr_tag_ABI_WMMX_args
[] =
8025 {"AAPCS", "WMMX registers", "custom"};
8026 static const char *arm_attr_tag_ABI_optimization_goals
[] =
8027 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
8028 "Aggressive Size", "Prefer Debug", "Aggressive Debug"};
8029 static const char *arm_attr_tag_ABI_FP_optimization_goals
[] =
8030 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
8031 "Aggressive Size", "Prefer Accuracy", "Aggressive Accuracy"};
8033 #define LOOKUP(id, name) \
8034 {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
8035 static arm_attr_public_tag arm_attr_public_tags
[] =
8037 {4, "CPU_raw_name", 1, NULL
},
8038 {5, "CPU_name", 1, NULL
},
8039 LOOKUP(6, CPU_arch
),
8040 {7, "CPU_arch_profile", 0, NULL
},
8041 LOOKUP(8, ARM_ISA_use
),
8042 LOOKUP(9, THUMB_ISA_use
),
8043 LOOKUP(10, VFP_arch
),
8044 LOOKUP(11, WMMX_arch
),
8045 LOOKUP(12, NEON_arch
),
8046 LOOKUP(13, ABI_PCS_config
),
8047 LOOKUP(14, ABI_PCS_R9_use
),
8048 LOOKUP(15, ABI_PCS_RW_data
),
8049 LOOKUP(16, ABI_PCS_RO_DATA
),
8050 LOOKUP(17, ABI_PCS_GOT_use
),
8051 LOOKUP(18, ABI_PCS_wchar_t
),
8052 LOOKUP(19, ABI_FP_rounding
),
8053 LOOKUP(20, ABI_FP_denormal
),
8054 LOOKUP(21, ABI_FP_exceptions
),
8055 LOOKUP(22, ABI_FP_user_exceptions
),
8056 LOOKUP(23, ABI_FP_number_model
),
8057 LOOKUP(24, ABI_align8_needed
),
8058 LOOKUP(25, ABI_align8_preserved
),
8059 LOOKUP(26, ABI_enum_size
),
8060 LOOKUP(27, ABI_HardFP_use
),
8061 LOOKUP(28, ABI_VFP_args
),
8062 LOOKUP(29, ABI_WMMX_args
),
8063 LOOKUP(30, ABI_optimization_goals
),
8064 LOOKUP(31, ABI_FP_optimization_goals
),
8065 {32, "compatibility", 0, NULL
}
8069 /* Read an unsigned LEB128 encoded value from p. Set *PLEN to the number of
8072 read_uleb128 (unsigned char *p
, unsigned int *plen
)
8086 val
|= ((unsigned int)c
& 0x7f) << shift
;
8095 static unsigned char *
8096 display_arm_attribute (unsigned char *p
)
8101 arm_attr_public_tag
*attr
;
8105 tag
= read_uleb128 (p
, &len
);
8108 for (i
= 0; i
< ARRAY_SIZE(arm_attr_public_tags
); i
++)
8110 if (arm_attr_public_tags
[i
].tag
== tag
)
8112 attr
= &arm_attr_public_tags
[i
];
8119 printf (" Tag_%s: ", attr
->name
);
8125 case 7: /* Tag_CPU_arch_profile. */
8126 val
= read_uleb128 (p
, &len
);
8130 case 0: printf ("None\n"); break;
8131 case 'A': printf ("Application\n"); break;
8132 case 'R': printf ("Realtime\n"); break;
8133 case 'M': printf ("Microcontroller\n"); break;
8134 default: printf ("??? (%d)\n", val
); break;
8138 case 32: /* Tag_compatibility. */
8139 val
= read_uleb128 (p
, &len
);
8141 printf ("flag = %d, vendor = %s\n", val
, p
);
8142 p
+= strlen((char *)p
) + 1;
8156 assert (attr
->type
& 0x80);
8157 val
= read_uleb128 (p
, &len
);
8159 type
= attr
->type
& 0x7f;
8161 printf ("??? (%d)\n", val
);
8163 printf ("%s\n", attr
->table
[val
]);
8170 type
= 1; /* String. */
8172 type
= 2; /* uleb128. */
8173 printf (" Tag_unknown_%d: ", tag
);
8178 printf ("\"%s\"\n", p
);
8179 p
+= strlen((char *)p
) + 1;
8183 val
= read_uleb128 (p
, &len
);
8185 printf ("%d (0x%x)\n", val
, val
);
8192 process_arm_specific (FILE *file
)
8194 Elf_Internal_Shdr
*sect
;
8195 unsigned char *contents
;
8198 bfd_vma section_len
;
8202 /* Find the section header so that we get the size. */
8203 for (i
= 0, sect
= section_headers
;
8204 i
< elf_header
.e_shnum
;
8207 if (sect
->sh_type
!= SHT_ARM_ATTRIBUTES
)
8210 contents
= get_data (NULL
, file
, sect
->sh_offset
, 1, sect
->sh_size
,
8218 len
= sect
->sh_size
- 1;
8223 bfd_boolean public_section
;
8225 section_len
= byte_get (p
, 4);
8227 if (section_len
> len
)
8229 printf (_("ERROR: Bad section length (%d > %d)\n"),
8230 (int)section_len
, (int)len
);
8234 printf ("Attribute Section: %s\n", p
);
8235 if (strcmp ((char *)p
, "aeabi") == 0)
8236 public_section
= TRUE
;
8238 public_section
= FALSE
;
8239 namelen
= strlen ((char *)p
) + 1;
8241 section_len
-= namelen
+ 4;
8242 while (section_len
> 0)
8247 size
= byte_get (p
, 4);
8248 if (size
> section_len
)
8250 printf (_("ERROR: Bad subsection length (%d > %d)\n"),
8251 (int)size
, (int)section_len
);
8254 section_len
-= size
;
8260 printf ("File Attributes\n");
8263 printf ("Section Attributes:");
8266 printf ("Symbol Attributes:");
8271 val
= read_uleb128 (p
, &i
);
8275 printf (" %d", val
);
8280 printf ("Unknown tag: %d\n", tag
);
8281 public_section
= FALSE
;
8287 p
= display_arm_attribute(p
);
8291 /* ??? Do something sensible, like dump hex. */
8292 printf (" Unknown section contexts\n");
8300 printf (_("Unknown format '%c'\n"), *p
);
8309 process_mips_specific (FILE *file
)
8311 Elf_Internal_Dyn
*entry
;
8312 size_t liblist_offset
= 0;
8313 size_t liblistno
= 0;
8314 size_t conflictsno
= 0;
8315 size_t options_offset
= 0;
8316 size_t conflicts_offset
= 0;
8318 /* We have a lot of special sections. Thanks SGI! */
8319 if (dynamic_section
== NULL
)
8320 /* No information available. */
8323 for (entry
= dynamic_section
; entry
->d_tag
!= DT_NULL
; ++entry
)
8324 switch (entry
->d_tag
)
8326 case DT_MIPS_LIBLIST
:
8328 = offset_from_vma (file
, entry
->d_un
.d_val
,
8329 liblistno
* sizeof (Elf32_External_Lib
));
8331 case DT_MIPS_LIBLISTNO
:
8332 liblistno
= entry
->d_un
.d_val
;
8334 case DT_MIPS_OPTIONS
:
8335 options_offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
8337 case DT_MIPS_CONFLICT
:
8339 = offset_from_vma (file
, entry
->d_un
.d_val
,
8340 conflictsno
* sizeof (Elf32_External_Conflict
));
8342 case DT_MIPS_CONFLICTNO
:
8343 conflictsno
= entry
->d_un
.d_val
;
8349 if (liblist_offset
!= 0 && liblistno
!= 0 && do_dynamic
)
8351 Elf32_External_Lib
*elib
;
8354 elib
= get_data (NULL
, file
, liblist_offset
,
8355 liblistno
, sizeof (Elf32_External_Lib
),
8359 printf ("\nSection '.liblist' contains %lu entries:\n",
8360 (unsigned long) liblistno
);
8361 fputs (" Library Time Stamp Checksum Version Flags\n",
8364 for (cnt
= 0; cnt
< liblistno
; ++cnt
)
8371 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
8372 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
8373 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
8374 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
8375 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
8377 tmp
= gmtime (&time
);
8378 snprintf (timebuf
, sizeof (timebuf
),
8379 "%04u-%02u-%02uT%02u:%02u:%02u",
8380 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
8381 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
8383 printf ("%3lu: ", (unsigned long) cnt
);
8384 if (VALID_DYNAMIC_NAME (liblist
.l_name
))
8385 print_symbol (20, GET_DYNAMIC_NAME (liblist
.l_name
));
8387 printf ("<corrupt: %9ld>", liblist
.l_name
);
8388 printf (" %s %#10lx %-7ld", timebuf
, liblist
.l_checksum
,
8391 if (liblist
.l_flags
== 0)
8402 { " EXACT_MATCH", LL_EXACT_MATCH
},
8403 { " IGNORE_INT_VER", LL_IGNORE_INT_VER
},
8404 { " REQUIRE_MINOR", LL_REQUIRE_MINOR
},
8405 { " EXPORTS", LL_EXPORTS
},
8406 { " DELAY_LOAD", LL_DELAY_LOAD
},
8407 { " DELTA", LL_DELTA
}
8409 int flags
= liblist
.l_flags
;
8413 fcnt
< sizeof (l_flags_vals
) / sizeof (l_flags_vals
[0]);
8415 if ((flags
& l_flags_vals
[fcnt
].bit
) != 0)
8417 fputs (l_flags_vals
[fcnt
].name
, stdout
);
8418 flags
^= l_flags_vals
[fcnt
].bit
;
8421 printf (" %#x", (unsigned int) flags
);
8431 if (options_offset
!= 0)
8433 Elf_External_Options
*eopt
;
8434 Elf_Internal_Shdr
*sect
= section_headers
;
8435 Elf_Internal_Options
*iopt
;
8436 Elf_Internal_Options
*option
;
8440 /* Find the section header so that we get the size. */
8441 while (sect
->sh_type
!= SHT_MIPS_OPTIONS
)
8444 eopt
= get_data (NULL
, file
, options_offset
, 1, sect
->sh_size
,
8448 iopt
= cmalloc ((sect
->sh_size
/ sizeof (eopt
)), sizeof (*iopt
));
8451 error (_("Out of memory"));
8458 while (offset
< sect
->sh_size
)
8460 Elf_External_Options
*eoption
;
8462 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
8464 option
->kind
= BYTE_GET (eoption
->kind
);
8465 option
->size
= BYTE_GET (eoption
->size
);
8466 option
->section
= BYTE_GET (eoption
->section
);
8467 option
->info
= BYTE_GET (eoption
->info
);
8469 offset
+= option
->size
;
8475 printf (_("\nSection '%s' contains %d entries:\n"),
8476 SECTION_NAME (sect
), cnt
);
8484 switch (option
->kind
)
8487 /* This shouldn't happen. */
8488 printf (" NULL %d %lx", option
->section
, option
->info
);
8491 printf (" REGINFO ");
8492 if (elf_header
.e_machine
== EM_MIPS
)
8495 Elf32_External_RegInfo
*ereg
;
8496 Elf32_RegInfo reginfo
;
8498 ereg
= (Elf32_External_RegInfo
*) (option
+ 1);
8499 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8500 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8501 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8502 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8503 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8504 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
8506 printf ("GPR %08lx GP 0x%lx\n",
8508 (unsigned long) reginfo
.ri_gp_value
);
8509 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8510 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8511 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8516 Elf64_External_RegInfo
*ereg
;
8517 Elf64_Internal_RegInfo reginfo
;
8519 ereg
= (Elf64_External_RegInfo
*) (option
+ 1);
8520 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
8521 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
8522 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
8523 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
8524 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
8525 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
8527 printf ("GPR %08lx GP 0x",
8528 reginfo
.ri_gprmask
);
8529 printf_vma (reginfo
.ri_gp_value
);
8532 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
8533 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
8534 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
8538 case ODK_EXCEPTIONS
:
8539 fputs (" EXCEPTIONS fpe_min(", stdout
);
8540 process_mips_fpe_exception (option
->info
& OEX_FPU_MIN
);
8541 fputs (") fpe_max(", stdout
);
8542 process_mips_fpe_exception ((option
->info
& OEX_FPU_MAX
) >> 8);
8543 fputs (")", stdout
);
8545 if (option
->info
& OEX_PAGE0
)
8546 fputs (" PAGE0", stdout
);
8547 if (option
->info
& OEX_SMM
)
8548 fputs (" SMM", stdout
);
8549 if (option
->info
& OEX_FPDBUG
)
8550 fputs (" FPDBUG", stdout
);
8551 if (option
->info
& OEX_DISMISS
)
8552 fputs (" DISMISS", stdout
);
8555 fputs (" PAD ", stdout
);
8556 if (option
->info
& OPAD_PREFIX
)
8557 fputs (" PREFIX", stdout
);
8558 if (option
->info
& OPAD_POSTFIX
)
8559 fputs (" POSTFIX", stdout
);
8560 if (option
->info
& OPAD_SYMBOL
)
8561 fputs (" SYMBOL", stdout
);
8564 fputs (" HWPATCH ", stdout
);
8565 if (option
->info
& OHW_R4KEOP
)
8566 fputs (" R4KEOP", stdout
);
8567 if (option
->info
& OHW_R8KPFETCH
)
8568 fputs (" R8KPFETCH", stdout
);
8569 if (option
->info
& OHW_R5KEOP
)
8570 fputs (" R5KEOP", stdout
);
8571 if (option
->info
& OHW_R5KCVTL
)
8572 fputs (" R5KCVTL", stdout
);
8575 fputs (" FILL ", stdout
);
8576 /* XXX Print content of info word? */
8579 fputs (" TAGS ", stdout
);
8580 /* XXX Print content of info word? */
8583 fputs (" HWAND ", stdout
);
8584 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8585 fputs (" R4KEOP_CHECKED", stdout
);
8586 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8587 fputs (" R4KEOP_CLEAN", stdout
);
8590 fputs (" HWOR ", stdout
);
8591 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
8592 fputs (" R4KEOP_CHECKED", stdout
);
8593 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
8594 fputs (" R4KEOP_CLEAN", stdout
);
8597 printf (" GP_GROUP %#06lx self-contained %#06lx",
8598 option
->info
& OGP_GROUP
,
8599 (option
->info
& OGP_SELF
) >> 16);
8602 printf (" IDENT %#06lx self-contained %#06lx",
8603 option
->info
& OGP_GROUP
,
8604 (option
->info
& OGP_SELF
) >> 16);
8607 /* This shouldn't happen. */
8608 printf (" %3d ??? %d %lx",
8609 option
->kind
, option
->section
, option
->info
);
8613 len
= sizeof (*eopt
);
8614 while (len
< option
->size
)
8615 if (((char *) option
)[len
] >= ' '
8616 && ((char *) option
)[len
] < 0x7f)
8617 printf ("%c", ((char *) option
)[len
++]);
8619 printf ("\\%03o", ((char *) option
)[len
++]);
8621 fputs ("\n", stdout
);
8629 if (conflicts_offset
!= 0 && conflictsno
!= 0)
8631 Elf32_Conflict
*iconf
;
8634 if (dynamic_symbols
== NULL
)
8636 error (_("conflict list found without a dynamic symbol table"));
8640 iconf
= cmalloc (conflictsno
, sizeof (*iconf
));
8643 error (_("Out of memory"));
8649 Elf32_External_Conflict
*econf32
;
8651 econf32
= get_data (NULL
, file
, conflicts_offset
,
8652 conflictsno
, sizeof (*econf32
), _("conflict"));
8656 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
8657 iconf
[cnt
] = BYTE_GET (econf32
[cnt
]);
8663 Elf64_External_Conflict
*econf64
;
8665 econf64
= get_data (NULL
, file
, conflicts_offset
,
8666 conflictsno
, sizeof (*econf64
), _("conflict"));
8670 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
8671 iconf
[cnt
] = BYTE_GET (econf64
[cnt
]);
8676 printf (_("\nSection '.conflict' contains %lu entries:\n"),
8677 (unsigned long) conflictsno
);
8678 puts (_(" Num: Index Value Name"));
8680 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
8682 Elf_Internal_Sym
*psym
= & dynamic_symbols
[iconf
[cnt
]];
8684 printf ("%5lu: %8lu ", (unsigned long) cnt
, iconf
[cnt
]);
8685 print_vma (psym
->st_value
, FULL_HEX
);
8687 if (VALID_DYNAMIC_NAME (psym
->st_name
))
8688 print_symbol (25, GET_DYNAMIC_NAME (psym
->st_name
));
8690 printf ("<corrupt: %14ld>", psym
->st_name
);
8701 process_gnu_liblist (FILE *file
)
8703 Elf_Internal_Shdr
*section
, *string_sec
;
8704 Elf32_External_Lib
*elib
;
8713 for (i
= 0, section
= section_headers
;
8714 i
< elf_header
.e_shnum
;
8717 switch (section
->sh_type
)
8719 case SHT_GNU_LIBLIST
:
8720 if (SECTION_HEADER_INDEX (section
->sh_link
) >= elf_header
.e_shnum
)
8723 elib
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
8728 string_sec
= SECTION_HEADER (section
->sh_link
);
8730 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
, 1,
8731 string_sec
->sh_size
, _("liblist string table"));
8732 strtab_size
= string_sec
->sh_size
;
8735 || section
->sh_entsize
!= sizeof (Elf32_External_Lib
))
8741 printf (_("\nLibrary list section '%s' contains %lu entries:\n"),
8742 SECTION_NAME (section
),
8743 (long) (section
->sh_size
/ sizeof (Elf32_External_Lib
)));
8745 puts (" Library Time Stamp Checksum Version Flags");
8747 for (cnt
= 0; cnt
< section
->sh_size
/ sizeof (Elf32_External_Lib
);
8755 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
8756 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
8757 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
8758 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
8759 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
8761 tmp
= gmtime (&time
);
8762 snprintf (timebuf
, sizeof (timebuf
),
8763 "%04u-%02u-%02uT%02u:%02u:%02u",
8764 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
8765 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
8767 printf ("%3lu: ", (unsigned long) cnt
);
8769 printf ("%-20s", liblist
.l_name
< strtab_size
8770 ? strtab
+ liblist
.l_name
: "<corrupt>");
8772 printf ("%-20.20s", liblist
.l_name
< strtab_size
8773 ? strtab
+ liblist
.l_name
: "<corrupt>");
8774 printf (" %s %#010lx %-7ld %-7ld\n", timebuf
, liblist
.l_checksum
,
8775 liblist
.l_version
, liblist
.l_flags
);
8786 get_note_type (unsigned e_type
)
8788 static char buff
[64];
8790 if (elf_header
.e_type
== ET_CORE
)
8794 return _("NT_AUXV (auxiliary vector)");
8796 return _("NT_PRSTATUS (prstatus structure)");
8798 return _("NT_FPREGSET (floating point registers)");
8800 return _("NT_PRPSINFO (prpsinfo structure)");
8802 return _("NT_TASKSTRUCT (task structure)");
8804 return _("NT_PRXFPREG (user_xfpregs structure)");
8806 return _("NT_PSTATUS (pstatus structure)");
8808 return _("NT_FPREGS (floating point registers)");
8810 return _("NT_PSINFO (psinfo structure)");
8812 return _("NT_LWPSTATUS (lwpstatus_t structure)");
8814 return _("NT_LWPSINFO (lwpsinfo_t structure)");
8815 case NT_WIN32PSTATUS
:
8816 return _("NT_WIN32PSTATUS (win32_pstatus structure)");
8824 return _("NT_VERSION (version)");
8826 return _("NT_ARCH (architecture)");
8831 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
8836 get_netbsd_elfcore_note_type (unsigned e_type
)
8838 static char buff
[64];
8840 if (e_type
== NT_NETBSDCORE_PROCINFO
)
8842 /* NetBSD core "procinfo" structure. */
8843 return _("NetBSD procinfo structure");
8846 /* As of Jan 2002 there are no other machine-independent notes
8847 defined for NetBSD core files. If the note type is less
8848 than the start of the machine-dependent note types, we don't
8851 if (e_type
< NT_NETBSDCORE_FIRSTMACH
)
8853 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
8857 switch (elf_header
.e_machine
)
8859 /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0
8860 and PT_GETFPREGS == mach+2. */
8865 case EM_SPARC32PLUS
:
8869 case NT_NETBSDCORE_FIRSTMACH
+0:
8870 return _("PT_GETREGS (reg structure)");
8871 case NT_NETBSDCORE_FIRSTMACH
+2:
8872 return _("PT_GETFPREGS (fpreg structure)");
8878 /* On all other arch's, PT_GETREGS == mach+1 and
8879 PT_GETFPREGS == mach+3. */
8883 case NT_NETBSDCORE_FIRSTMACH
+1:
8884 return _("PT_GETREGS (reg structure)");
8885 case NT_NETBSDCORE_FIRSTMACH
+3:
8886 return _("PT_GETFPREGS (fpreg structure)");
8892 snprintf (buff
, sizeof (buff
), _("PT_FIRSTMACH+%d"),
8893 e_type
- NT_NETBSDCORE_FIRSTMACH
);
8897 /* Note that by the ELF standard, the name field is already null byte
8898 terminated, and namesz includes the terminating null byte.
8899 I.E. the value of namesz for the name "FSF" is 4.
8901 If the value of namesz is zero, there is no name present. */
8903 process_note (Elf_Internal_Note
*pnote
)
8907 if (pnote
->namesz
== 0)
8908 /* If there is no note name, then use the default set of
8909 note type strings. */
8910 nt
= get_note_type (pnote
->type
);
8912 else if (const_strneq (pnote
->namedata
, "NetBSD-CORE"))
8913 /* NetBSD-specific core file notes. */
8914 nt
= get_netbsd_elfcore_note_type (pnote
->type
);
8917 /* Don't recognize this note name; just use the default set of
8918 note type strings. */
8919 nt
= get_note_type (pnote
->type
);
8921 printf (" %s\t\t0x%08lx\t%s\n",
8922 pnote
->namesz
? pnote
->namedata
: "(NONE)",
8929 process_corefile_note_segment (FILE *file
, bfd_vma offset
, bfd_vma length
)
8931 Elf_External_Note
*pnotes
;
8932 Elf_External_Note
*external
;
8938 pnotes
= get_data (NULL
, file
, offset
, 1, length
, _("notes"));
8944 printf (_("\nNotes at offset 0x%08lx with length 0x%08lx:\n"),
8945 (unsigned long) offset
, (unsigned long) length
);
8946 printf (_(" Owner\t\tData size\tDescription\n"));
8948 while (external
< (Elf_External_Note
*)((char *) pnotes
+ length
))
8950 Elf_External_Note
*next
;
8951 Elf_Internal_Note inote
;
8954 inote
.type
= BYTE_GET (external
->type
);
8955 inote
.namesz
= BYTE_GET (external
->namesz
);
8956 inote
.namedata
= external
->name
;
8957 inote
.descsz
= BYTE_GET (external
->descsz
);
8958 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 2);
8959 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
8961 next
= (Elf_External_Note
*)(inote
.descdata
+ align_power (inote
.descsz
, 2));
8963 if (((char *) next
) > (((char *) pnotes
) + length
))
8965 warn (_("corrupt note found at offset %lx into core notes\n"),
8966 (long)((char *)external
- (char *)pnotes
));
8967 warn (_(" type: %lx, namesize: %08lx, descsize: %08lx\n"),
8968 inote
.type
, inote
.namesz
, inote
.descsz
);
8974 /* Verify that name is null terminated. It appears that at least
8975 one version of Linux (RedHat 6.0) generates corefiles that don't
8976 comply with the ELF spec by failing to include the null byte in
8978 if (inote
.namedata
[inote
.namesz
] != '\0')
8980 temp
= malloc (inote
.namesz
+ 1);
8984 error (_("Out of memory\n"));
8989 strncpy (temp
, inote
.namedata
, inote
.namesz
);
8990 temp
[inote
.namesz
] = 0;
8992 /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */
8993 inote
.namedata
= temp
;
8996 res
&= process_note (& inote
);
9011 process_corefile_note_segments (FILE *file
)
9013 Elf_Internal_Phdr
*segment
;
9017 if (! get_program_headers (file
))
9020 for (i
= 0, segment
= program_headers
;
9021 i
< elf_header
.e_phnum
;
9024 if (segment
->p_type
== PT_NOTE
)
9025 res
&= process_corefile_note_segment (file
,
9026 (bfd_vma
) segment
->p_offset
,
9027 (bfd_vma
) segment
->p_filesz
);
9034 process_note_sections (FILE *file
)
9036 Elf_Internal_Shdr
*section
;
9040 for (i
= 0, section
= section_headers
;
9041 i
< elf_header
.e_shnum
;
9043 if (section
->sh_type
== SHT_NOTE
)
9044 res
&= process_corefile_note_segment (file
,
9045 (bfd_vma
) section
->sh_offset
,
9046 (bfd_vma
) section
->sh_size
);
9052 process_notes (FILE *file
)
9054 /* If we have not been asked to display the notes then do nothing. */
9058 if (elf_header
.e_type
!= ET_CORE
)
9059 return process_note_sections (file
);
9061 /* No program headers means no NOTE segment. */
9062 if (elf_header
.e_phnum
> 0)
9063 return process_corefile_note_segments (file
);
9065 printf (_("No note segments present in the core file.\n"));
9070 process_arch_specific (FILE *file
)
9075 switch (elf_header
.e_machine
)
9078 return process_arm_specific (file
);
9080 case EM_MIPS_RS3_LE
:
9081 return process_mips_specific (file
);
9090 get_file_header (FILE *file
)
9092 /* Read in the identity array. */
9093 if (fread (elf_header
.e_ident
, EI_NIDENT
, 1, file
) != 1)
9096 /* Determine how to read the rest of the header. */
9097 switch (elf_header
.e_ident
[EI_DATA
])
9099 default: /* fall through */
9100 case ELFDATANONE
: /* fall through */
9102 byte_get
= byte_get_little_endian
;
9103 byte_put
= byte_put_little_endian
;
9106 byte_get
= byte_get_big_endian
;
9107 byte_put
= byte_put_big_endian
;
9111 /* For now we only support 32 bit and 64 bit ELF files. */
9112 is_32bit_elf
= (elf_header
.e_ident
[EI_CLASS
] != ELFCLASS64
);
9114 /* Read in the rest of the header. */
9117 Elf32_External_Ehdr ehdr32
;
9119 if (fread (ehdr32
.e_type
, sizeof (ehdr32
) - EI_NIDENT
, 1, file
) != 1)
9122 elf_header
.e_type
= BYTE_GET (ehdr32
.e_type
);
9123 elf_header
.e_machine
= BYTE_GET (ehdr32
.e_machine
);
9124 elf_header
.e_version
= BYTE_GET (ehdr32
.e_version
);
9125 elf_header
.e_entry
= BYTE_GET (ehdr32
.e_entry
);
9126 elf_header
.e_phoff
= BYTE_GET (ehdr32
.e_phoff
);
9127 elf_header
.e_shoff
= BYTE_GET (ehdr32
.e_shoff
);
9128 elf_header
.e_flags
= BYTE_GET (ehdr32
.e_flags
);
9129 elf_header
.e_ehsize
= BYTE_GET (ehdr32
.e_ehsize
);
9130 elf_header
.e_phentsize
= BYTE_GET (ehdr32
.e_phentsize
);
9131 elf_header
.e_phnum
= BYTE_GET (ehdr32
.e_phnum
);
9132 elf_header
.e_shentsize
= BYTE_GET (ehdr32
.e_shentsize
);
9133 elf_header
.e_shnum
= BYTE_GET (ehdr32
.e_shnum
);
9134 elf_header
.e_shstrndx
= BYTE_GET (ehdr32
.e_shstrndx
);
9138 Elf64_External_Ehdr ehdr64
;
9140 /* If we have been compiled with sizeof (bfd_vma) == 4, then
9141 we will not be able to cope with the 64bit data found in
9142 64 ELF files. Detect this now and abort before we start
9143 overwriting things. */
9144 if (sizeof (bfd_vma
) < 8)
9146 error (_("This instance of readelf has been built without support for a\n\
9147 64 bit data type and so it cannot read 64 bit ELF files.\n"));
9151 if (fread (ehdr64
.e_type
, sizeof (ehdr64
) - EI_NIDENT
, 1, file
) != 1)
9154 elf_header
.e_type
= BYTE_GET (ehdr64
.e_type
);
9155 elf_header
.e_machine
= BYTE_GET (ehdr64
.e_machine
);
9156 elf_header
.e_version
= BYTE_GET (ehdr64
.e_version
);
9157 elf_header
.e_entry
= BYTE_GET (ehdr64
.e_entry
);
9158 elf_header
.e_phoff
= BYTE_GET (ehdr64
.e_phoff
);
9159 elf_header
.e_shoff
= BYTE_GET (ehdr64
.e_shoff
);
9160 elf_header
.e_flags
= BYTE_GET (ehdr64
.e_flags
);
9161 elf_header
.e_ehsize
= BYTE_GET (ehdr64
.e_ehsize
);
9162 elf_header
.e_phentsize
= BYTE_GET (ehdr64
.e_phentsize
);
9163 elf_header
.e_phnum
= BYTE_GET (ehdr64
.e_phnum
);
9164 elf_header
.e_shentsize
= BYTE_GET (ehdr64
.e_shentsize
);
9165 elf_header
.e_shnum
= BYTE_GET (ehdr64
.e_shnum
);
9166 elf_header
.e_shstrndx
= BYTE_GET (ehdr64
.e_shstrndx
);
9169 if (elf_header
.e_shoff
)
9171 /* There may be some extensions in the first section header. Don't
9172 bomb if we can't read it. */
9174 get_32bit_section_headers (file
, 1);
9176 get_64bit_section_headers (file
, 1);
9179 is_relocatable
= elf_header
.e_type
== ET_REL
;
9184 /* Process one ELF object file according to the command line options.
9185 This file may actually be stored in an archive. The file is
9186 positioned at the start of the ELF object. */
9189 process_object (char *file_name
, FILE *file
)
9193 if (! get_file_header (file
))
9195 error (_("%s: Failed to read file header\n"), file_name
);
9199 /* Initialise per file variables. */
9200 for (i
= NUM_ELEM (version_info
); i
--;)
9201 version_info
[i
] = 0;
9203 for (i
= NUM_ELEM (dynamic_info
); i
--;)
9204 dynamic_info
[i
] = 0;
9206 /* Process the file. */
9208 printf (_("\nFile: %s\n"), file_name
);
9210 /* Initialise the dump_sects array from the cmdline_dump_sects array.
9211 Note we do this even if cmdline_dump_sects is empty because we
9212 must make sure that the dump_sets array is zeroed out before each
9213 object file is processed. */
9214 if (num_dump_sects
> num_cmdline_dump_sects
)
9215 memset (dump_sects
, 0, num_dump_sects
);
9217 if (num_cmdline_dump_sects
> 0)
9219 if (num_dump_sects
== 0)
9220 /* A sneaky way of allocating the dump_sects array. */
9221 request_dump (num_cmdline_dump_sects
, 0);
9223 assert (num_dump_sects
>= num_cmdline_dump_sects
);
9224 memcpy (dump_sects
, cmdline_dump_sects
, num_cmdline_dump_sects
);
9227 if (! process_file_header ())
9230 if (! process_section_headers (file
))
9232 /* Without loaded section headers we cannot process lots of
9234 do_unwind
= do_version
= do_dump
= do_arch
= 0;
9236 if (! do_using_dynamic
)
9237 do_syms
= do_reloc
= 0;
9240 if (! process_section_groups (file
))
9242 /* Without loaded section groups we cannot process unwind. */
9246 if (process_program_headers (file
))
9247 process_dynamic_section (file
);
9249 process_relocs (file
);
9251 process_unwind (file
);
9253 process_symbol_table (file
);
9255 process_syminfo (file
);
9257 process_version_sections (file
);
9259 process_section_contents (file
);
9261 process_notes (file
);
9263 process_gnu_liblist (file
);
9265 process_arch_specific (file
);
9267 if (program_headers
)
9269 free (program_headers
);
9270 program_headers
= NULL
;
9273 if (section_headers
)
9275 free (section_headers
);
9276 section_headers
= NULL
;
9281 free (string_table
);
9282 string_table
= NULL
;
9283 string_table_length
= 0;
9286 if (dynamic_strings
)
9288 free (dynamic_strings
);
9289 dynamic_strings
= NULL
;
9290 dynamic_strings_length
= 0;
9293 if (dynamic_symbols
)
9295 free (dynamic_symbols
);
9296 dynamic_symbols
= NULL
;
9297 num_dynamic_syms
= 0;
9300 if (dynamic_syminfo
)
9302 free (dynamic_syminfo
);
9303 dynamic_syminfo
= NULL
;
9306 if (section_headers_groups
)
9308 free (section_headers_groups
);
9309 section_headers_groups
= NULL
;
9314 struct group_list
*g
, *next
;
9316 for (i
= 0; i
< group_count
; i
++)
9318 for (g
= section_groups
[i
].root
; g
!= NULL
; g
= next
)
9325 free (section_groups
);
9326 section_groups
= NULL
;
9329 free_debug_memory ();
9334 /* Process an ELF archive. The file is positioned just after the
9338 process_archive (char *file_name
, FILE *file
)
9340 struct ar_hdr arhdr
;
9343 char *longnames
= NULL
;
9344 unsigned long longnames_size
= 0;
9345 size_t file_name_size
;
9350 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9351 if (got
!= sizeof arhdr
)
9356 error (_("%s: failed to read archive header\n"), file_name
);
9360 if (const_strneq (arhdr
.ar_name
, "/ "))
9362 /* This is the archive symbol table. Skip it.
9363 FIXME: We should have an option to dump it. */
9364 size
= strtoul (arhdr
.ar_size
, NULL
, 10);
9365 if (fseek (file
, size
+ (size
& 1), SEEK_CUR
) != 0)
9367 error (_("%s: failed to skip archive symbol table\n"), file_name
);
9371 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9372 if (got
!= sizeof arhdr
)
9377 error (_("%s: failed to read archive header\n"), file_name
);
9382 if (const_strneq (arhdr
.ar_name
, "// "))
9384 /* This is the archive string table holding long member
9387 longnames_size
= strtoul (arhdr
.ar_size
, NULL
, 10);
9389 longnames
= malloc (longnames_size
);
9390 if (longnames
== NULL
)
9392 error (_("Out of memory\n"));
9396 if (fread (longnames
, longnames_size
, 1, file
) != 1)
9399 error (_("%s: failed to read string table\n"), file_name
);
9403 if ((longnames_size
& 1) != 0)
9406 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9407 if (got
!= sizeof arhdr
)
9414 error (_("%s: failed to read archive header\n"), file_name
);
9419 file_name_size
= strlen (file_name
);
9428 if (arhdr
.ar_name
[0] == '/')
9432 off
= strtoul (arhdr
.ar_name
+ 1, NULL
, 10);
9433 if (off
>= longnames_size
)
9435 error (_("%s: invalid archive string table offset %lu\n"), file_name
, off
);
9440 name
= longnames
+ off
;
9441 nameend
= memchr (name
, '/', longnames_size
- off
);
9445 name
= arhdr
.ar_name
;
9446 nameend
= memchr (name
, '/', 16);
9449 if (nameend
== NULL
)
9451 error (_("%s: bad archive file name\n"), file_name
);
9456 namealc
= malloc (file_name_size
+ (nameend
- name
) + 3);
9457 if (namealc
== NULL
)
9459 error (_("Out of memory\n"));
9464 memcpy (namealc
, file_name
, file_name_size
);
9465 namealc
[file_name_size
] = '(';
9466 memcpy (namealc
+ file_name_size
+ 1, name
, nameend
- name
);
9467 namealc
[file_name_size
+ 1 + (nameend
- name
)] = ')';
9468 namealc
[file_name_size
+ 2 + (nameend
- name
)] = '\0';
9470 archive_file_offset
= ftell (file
);
9471 archive_file_size
= strtoul (arhdr
.ar_size
, NULL
, 10);
9473 ret
|= process_object (namealc
, file
);
9478 (archive_file_offset
9480 + (archive_file_size
& 1)),
9483 error (_("%s: failed to seek to next archive header\n"), file_name
);
9488 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
9489 if (got
!= sizeof arhdr
)
9494 error (_("%s: failed to read archive header\n"), file_name
);
9507 process_file (char *file_name
)
9510 struct stat statbuf
;
9514 if (stat (file_name
, &statbuf
) < 0)
9516 if (errno
== ENOENT
)
9517 error (_("'%s': No such file\n"), file_name
);
9519 error (_("Could not locate '%s'. System error message: %s\n"),
9520 file_name
, strerror (errno
));
9524 if (! S_ISREG (statbuf
.st_mode
))
9526 error (_("'%s' is not an ordinary file\n"), file_name
);
9530 file
= fopen (file_name
, "rb");
9533 error (_("Input file '%s' is not readable.\n"), file_name
);
9537 if (fread (armag
, SARMAG
, 1, file
) != 1)
9539 error (_("%s: Failed to read file header\n"), file_name
);
9544 if (memcmp (armag
, ARMAG
, SARMAG
) == 0)
9545 ret
= process_archive (file_name
, file
);
9549 archive_file_size
= archive_file_offset
= 0;
9550 ret
= process_object (file_name
, file
);
9558 #ifdef SUPPORT_DISASSEMBLY
9559 /* Needed by the i386 disassembler. For extra credit, someone could
9560 fix this so that we insert symbolic addresses here, esp for GOT/PLT
9564 print_address (unsigned int addr
, FILE *outfile
)
9566 fprintf (outfile
,"0x%8.8x", addr
);
9569 /* Needed by the i386 disassembler. */
9571 db_task_printsym (unsigned int addr
)
9573 print_address (addr
, stderr
);
9578 main (int argc
, char **argv
)
9582 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
9583 setlocale (LC_MESSAGES
, "");
9585 #if defined (HAVE_SETLOCALE)
9586 setlocale (LC_CTYPE
, "");
9588 bindtextdomain (PACKAGE
, LOCALEDIR
);
9589 textdomain (PACKAGE
);
9591 expandargv (&argc
, &argv
);
9593 parse_args (argc
, argv
);
9595 if (num_dump_sects
> 0)
9597 /* Make a copy of the dump_sects array. */
9598 cmdline_dump_sects
= malloc (num_dump_sects
);
9599 if (cmdline_dump_sects
== NULL
)
9600 error (_("Out of memory allocating dump request table."));
9603 memcpy (cmdline_dump_sects
, dump_sects
, num_dump_sects
);
9604 num_cmdline_dump_sects
= num_dump_sects
;
9608 if (optind
< (argc
- 1))
9612 while (optind
< argc
)
9613 err
|= process_file (argv
[optind
++]);
9615 if (dump_sects
!= NULL
)
9617 if (cmdline_dump_sects
!= NULL
)
9618 free (cmdline_dump_sects
);