1 /* readelf.c -- display contents of an ELF format file
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3 2008 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 3 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. */
60 # ifdef HAVE_SYS_PARAM_H
61 # include <sys/param.h>
65 # define PATH_MAX MAXPATHLEN
67 # define PATH_MAX 1024
73 /* Define BFD64 here, even if our default architecture is 32 bit ELF
74 as this will allow us to read in and parse 64bit and 32bit ELF files.
75 Only do this if we believe that the compiler can support a 64 bit
76 data type. For now we only rely on GCC being able to do this. */
84 #include "elf/common.h"
85 #include "elf/external.h"
86 #include "elf/internal.h"
89 /* Included here, before RELOC_MACROS_GEN_FUNC is defined, so that
90 we can obtain the H8 reloc numbers. We need these for the
91 get_reloc_size() function. We include h8.h again after defining
92 RELOC_MACROS_GEN_FUNC so that we get the naming function as well. */
97 /* Undo the effects of #including reloc-macros.h. */
99 #undef START_RELOC_NUMBERS
103 #undef END_RELOC_NUMBERS
104 #undef _RELOC_MACROS_H
106 /* The following headers use the elf/reloc-macros.h file to
107 automatically generate relocation recognition functions
108 such as elf_mips_reloc_type() */
110 #define RELOC_MACROS_GEN_FUNC
112 #include "elf/alpha.h"
116 #include "elf/bfin.h"
117 #include "elf/cr16.h"
118 #include "elf/cris.h"
120 #include "elf/d10v.h"
121 #include "elf/d30v.h"
123 #include "elf/fr30.h"
126 #include "elf/hppa.h"
127 #include "elf/i386.h"
128 #include "elf/i370.h"
129 #include "elf/i860.h"
130 #include "elf/i960.h"
131 #include "elf/ia64.h"
132 #include "elf/ip2k.h"
133 #include "elf/iq2000.h"
134 #include "elf/m32c.h"
135 #include "elf/m32r.h"
136 #include "elf/m68k.h"
137 #include "elf/m68hc11.h"
138 #include "elf/mcore.h"
140 #include "elf/mips.h"
141 #include "elf/mmix.h"
142 #include "elf/mn10200.h"
143 #include "elf/mn10300.h"
145 #include "elf/msp430.h"
146 #include "elf/or32.h"
149 #include "elf/ppc64.h"
150 #include "elf/s390.h"
151 #include "elf/score.h"
153 #include "elf/sparc.h"
155 #include "elf/v850.h"
157 #include "elf/x86-64.h"
158 #include "elf/xstormy16.h"
159 #include "elf/xtensa.h"
164 #include "libiberty.h"
165 #include "safe-ctype.h"
167 char *program_name
= "readelf";
169 static long archive_file_offset
;
170 static unsigned long archive_file_size
;
171 static unsigned long dynamic_addr
;
172 static bfd_size_type dynamic_size
;
173 static unsigned int dynamic_nent
;
174 static char *dynamic_strings
;
175 static unsigned long dynamic_strings_length
;
176 static char *string_table
;
177 static unsigned long string_table_length
;
178 static unsigned long num_dynamic_syms
;
179 static Elf_Internal_Sym
*dynamic_symbols
;
180 static Elf_Internal_Syminfo
*dynamic_syminfo
;
181 static unsigned long dynamic_syminfo_offset
;
182 static unsigned int dynamic_syminfo_nent
;
183 static char program_interpreter
[PATH_MAX
];
184 static bfd_vma dynamic_info
[DT_JMPREL
+ 1];
185 static bfd_vma dynamic_info_DT_GNU_HASH
;
186 static bfd_vma version_info
[16];
187 static Elf_Internal_Ehdr elf_header
;
188 static Elf_Internal_Shdr
*section_headers
;
189 static Elf_Internal_Phdr
*program_headers
;
190 static Elf_Internal_Dyn
*dynamic_section
;
191 static Elf_Internal_Shdr
*symtab_shndx_hdr
;
192 static int show_name
;
193 static int do_dynamic
;
196 static int do_sections
;
197 static int do_section_groups
;
198 static int do_section_details
;
199 static int do_segments
;
200 static int do_unwind
;
201 static int do_using_dynamic
;
202 static int do_header
;
204 static int do_version
;
205 static int do_histogram
;
206 static int do_debugging
;
209 static int do_archive_index
;
210 static int is_32bit_elf
;
214 struct group_list
*next
;
215 unsigned int section_index
;
220 struct group_list
*root
;
221 unsigned int group_index
;
224 static size_t group_count
;
225 static struct group
*section_groups
;
226 static struct group
**section_headers_groups
;
229 /* Flag bits indicating particular types of dump. */
230 #define HEX_DUMP (1 << 0) /* The -x command line switch. */
231 #define DISASS_DUMP (1 << 1) /* The -i command line switch. */
232 #define DEBUG_DUMP (1 << 2) /* The -w command line switch. */
233 #define STRING_DUMP (1 << 3) /* The -p command line switch. */
235 typedef unsigned char dump_type
;
237 /* A linked list of the section names for which dumps were requested. */
238 struct dump_list_entry
242 struct dump_list_entry
*next
;
244 static struct dump_list_entry
*dump_sects_byname
;
246 /* A dynamic array of flags indicating for which sections a dump
247 has been requested via command line switches. */
248 static dump_type
* cmdline_dump_sects
= NULL
;
249 static unsigned int num_cmdline_dump_sects
= 0;
251 /* A dynamic array of flags indicating for which sections a dump of
252 some kind has been requested. It is reset on a per-object file
253 basis and then initialised from the cmdline_dump_sects array,
254 the results of interpreting the -w switch, and the
255 dump_sects_byname list. */
256 static dump_type
* dump_sects
= NULL
;
257 static unsigned int num_dump_sects
= 0;
260 /* How to print a vma value. */
261 typedef enum print_mode
273 static void (*byte_put
) (unsigned char *, bfd_vma
, int);
277 #define SECTION_NAME(X) \
278 ((X) == NULL ? "<none>" \
279 : string_table == NULL ? "<no-name>" \
280 : ((X)->sh_name >= string_table_length ? "<corrupt>" \
281 : string_table + (X)->sh_name))
283 #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
285 #define BYTE_GET(field) byte_get (field, sizeof (field))
287 #define GET_ELF_SYMBOLS(file, section) \
288 (is_32bit_elf ? get_32bit_elf_symbols (file, section) \
289 : get_64bit_elf_symbols (file, section))
291 #define VALID_DYNAMIC_NAME(offset) ((dynamic_strings != NULL) && (offset < dynamic_strings_length))
292 /* GET_DYNAMIC_NAME asssumes that VALID_DYNAMIC_NAME has
293 already been called and verified that the string exists. */
294 #define GET_DYNAMIC_NAME(offset) (dynamic_strings + offset)
296 /* This is just a bit of syntatic sugar. */
297 #define streq(a,b) (strcmp ((a), (b)) == 0)
298 #define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
299 #define const_strneq(a,b) (strncmp ((a), (b), sizeof (b) - 1) == 0)
302 get_data (void *var
, FILE *file
, long offset
, size_t size
, size_t nmemb
,
307 if (size
== 0 || nmemb
== 0)
310 if (fseek (file
, archive_file_offset
+ offset
, SEEK_SET
))
312 error (_("Unable to seek to 0x%lx for %s\n"),
313 (unsigned long) archive_file_offset
+ offset
, reason
);
320 /* Check for overflow. */
321 if (nmemb
< (~(size_t) 0 - 1) / size
)
322 /* + 1 so that we can '\0' terminate invalid string table sections. */
323 mvar
= malloc (size
* nmemb
+ 1);
327 error (_("Out of memory allocating 0x%lx bytes for %s\n"),
328 (unsigned long)(size
* nmemb
), reason
);
332 ((char *) mvar
)[size
* nmemb
] = '\0';
335 if (fread (mvar
, size
, nmemb
, file
) != nmemb
)
337 error (_("Unable to read in 0x%lx bytes of %s\n"),
338 (unsigned long)(size
* nmemb
), reason
);
348 byte_put_little_endian (unsigned char *field
, bfd_vma value
, int size
)
353 field
[7] = (((value
>> 24) >> 24) >> 8) & 0xff;
354 field
[6] = ((value
>> 24) >> 24) & 0xff;
355 field
[5] = ((value
>> 24) >> 16) & 0xff;
356 field
[4] = ((value
>> 24) >> 8) & 0xff;
359 field
[3] = (value
>> 24) & 0xff;
360 field
[2] = (value
>> 16) & 0xff;
363 field
[1] = (value
>> 8) & 0xff;
366 field
[0] = value
& 0xff;
370 error (_("Unhandled data length: %d\n"), size
);
375 /* Print a VMA value. */
378 print_vma (bfd_vma vma
, print_mode mode
)
391 return nc
+ printf ("%8.8" BFD_VMA_FMT
"x", vma
);
398 return printf ("%5" BFD_VMA_FMT
"d", vma
);
406 return nc
+ printf ("%" BFD_VMA_FMT
"x", vma
);
409 return printf ("%" BFD_VMA_FMT
"d", vma
);
412 return printf ("%" BFD_VMA_FMT
"u", vma
);
417 /* Display a symbol on stdout. Handles the display of non-printing characters.
419 If DO_WIDE is not true then format the symbol to be at most WIDTH characters,
420 truncating as necessary. If WIDTH is negative then format the string to be
421 exactly - WIDTH characters, truncating or padding as necessary.
423 Returns the number of emitted characters. */
426 print_symbol (int width
, const char *symbol
)
429 bfd_boolean extra_padding
= FALSE
;
430 unsigned int num_printed
= 0;
434 /* Set the width to a very large value. This simplifies the code below. */
439 /* Keep the width positive. This also helps. */
441 extra_padding
= TRUE
;
450 /* Look for non-printing symbols inside the symbol's name.
451 This test is triggered in particular by the names generated
452 by the assembler for local labels. */
453 while (ISPRINT (* c
))
463 printf ("%.*s", len
, symbol
);
469 if (* c
== 0 || width
== 0)
472 /* Now display the non-printing character, if
473 there is room left in which to dipslay it. */
479 printf ("^%c", *c
+ 0x40);
489 printf ("<0x%.2x>", *c
);
498 if (extra_padding
&& width
> 0)
500 /* Fill in the remaining spaces. */
501 printf ("%-*s", width
, " ");
509 byte_put_big_endian (unsigned char *field
, bfd_vma value
, int size
)
514 field
[7] = value
& 0xff;
515 field
[6] = (value
>> 8) & 0xff;
516 field
[5] = (value
>> 16) & 0xff;
517 field
[4] = (value
>> 24) & 0xff;
522 field
[3] = value
& 0xff;
523 field
[2] = (value
>> 8) & 0xff;
527 field
[1] = value
& 0xff;
531 field
[0] = value
& 0xff;
535 error (_("Unhandled data length: %d\n"), size
);
540 /* Return a pointer to section NAME, or NULL if no such section exists. */
542 static Elf_Internal_Shdr
*
543 find_section (const char *name
)
547 for (i
= 0; i
< elf_header
.e_shnum
; i
++)
548 if (streq (SECTION_NAME (section_headers
+ i
), name
))
549 return section_headers
+ i
;
554 /* Guess the relocation size commonly used by the specific machines. */
557 guess_is_rela (unsigned int e_machine
)
561 /* Targets that use REL relocations. */
577 /* Targets that use RELA relocations. */
581 case EM_ALTERA_NIOS2
:
608 case EM_CYGNUS_MN10200
:
610 case EM_CYGNUS_MN10300
:
651 warn (_("Don't know about relocations on this machine architecture\n"));
657 slurp_rela_relocs (FILE *file
,
658 unsigned long rel_offset
,
659 unsigned long rel_size
,
660 Elf_Internal_Rela
**relasp
,
661 unsigned long *nrelasp
)
663 Elf_Internal_Rela
*relas
;
664 unsigned long nrelas
;
669 Elf32_External_Rela
*erelas
;
671 erelas
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
675 nrelas
= rel_size
/ sizeof (Elf32_External_Rela
);
677 relas
= cmalloc (nrelas
, sizeof (Elf_Internal_Rela
));
682 error (_("out of memory parsing relocs\n"));
686 for (i
= 0; i
< nrelas
; i
++)
688 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
689 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
690 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
697 Elf64_External_Rela
*erelas
;
699 erelas
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
703 nrelas
= rel_size
/ sizeof (Elf64_External_Rela
);
705 relas
= cmalloc (nrelas
, sizeof (Elf_Internal_Rela
));
710 error (_("out of memory parsing relocs\n"));
714 for (i
= 0; i
< nrelas
; i
++)
716 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
717 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
718 relas
[i
].r_addend
= BYTE_GET (erelas
[i
].r_addend
);
720 /* The #ifdef BFD64 below is to prevent a compile time
721 warning. We know that if we do not have a 64 bit data
722 type that we will never execute this code anyway. */
724 if (elf_header
.e_machine
== EM_MIPS
725 && elf_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
727 /* In little-endian objects, r_info isn't really a
728 64-bit little-endian value: it has a 32-bit
729 little-endian symbol index followed by four
730 individual byte fields. Reorder INFO
732 bfd_vma info
= relas
[i
].r_info
;
733 info
= (((info
& 0xffffffff) << 32)
734 | ((info
>> 56) & 0xff)
735 | ((info
>> 40) & 0xff00)
736 | ((info
>> 24) & 0xff0000)
737 | ((info
>> 8) & 0xff000000));
738 relas
[i
].r_info
= info
;
751 slurp_rel_relocs (FILE *file
,
752 unsigned long rel_offset
,
753 unsigned long rel_size
,
754 Elf_Internal_Rela
**relsp
,
755 unsigned long *nrelsp
)
757 Elf_Internal_Rela
*rels
;
763 Elf32_External_Rel
*erels
;
765 erels
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
769 nrels
= rel_size
/ sizeof (Elf32_External_Rel
);
771 rels
= cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
776 error (_("out of memory parsing relocs\n"));
780 for (i
= 0; i
< nrels
; i
++)
782 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
783 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
784 rels
[i
].r_addend
= 0;
791 Elf64_External_Rel
*erels
;
793 erels
= get_data (NULL
, file
, rel_offset
, 1, rel_size
, _("relocs"));
797 nrels
= rel_size
/ sizeof (Elf64_External_Rel
);
799 rels
= cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
804 error (_("out of memory parsing relocs\n"));
808 for (i
= 0; i
< nrels
; i
++)
810 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
811 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
812 rels
[i
].r_addend
= 0;
814 /* The #ifdef BFD64 below is to prevent a compile time
815 warning. We know that if we do not have a 64 bit data
816 type that we will never execute this code anyway. */
818 if (elf_header
.e_machine
== EM_MIPS
819 && elf_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
821 /* In little-endian objects, r_info isn't really a
822 64-bit little-endian value: it has a 32-bit
823 little-endian symbol index followed by four
824 individual byte fields. Reorder INFO
826 bfd_vma info
= rels
[i
].r_info
;
827 info
= (((info
& 0xffffffff) << 32)
828 | ((info
>> 56) & 0xff)
829 | ((info
>> 40) & 0xff00)
830 | ((info
>> 24) & 0xff0000)
831 | ((info
>> 8) & 0xff000000));
832 rels
[i
].r_info
= info
;
844 /* Returns the reloc type extracted from the reloc info field. */
847 get_reloc_type (bfd_vma reloc_info
)
850 return ELF32_R_TYPE (reloc_info
);
852 switch (elf_header
.e_machine
)
855 /* Note: We assume that reloc_info has already been adjusted for us. */
856 return ELF64_MIPS_R_TYPE (reloc_info
);
859 return ELF64_R_TYPE_ID (reloc_info
);
862 return ELF64_R_TYPE (reloc_info
);
866 /* Return the symbol index extracted from the reloc info field. */
869 get_reloc_symindex (bfd_vma reloc_info
)
871 return is_32bit_elf
? ELF32_R_SYM (reloc_info
) : ELF64_R_SYM (reloc_info
);
874 /* Display the contents of the relocation data found at the specified
878 dump_relocations (FILE *file
,
879 unsigned long rel_offset
,
880 unsigned long rel_size
,
881 Elf_Internal_Sym
*symtab
,
884 unsigned long strtablen
,
888 Elf_Internal_Rela
*rels
;
891 if (is_rela
== UNKNOWN
)
892 is_rela
= guess_is_rela (elf_header
.e_machine
);
896 if (!slurp_rela_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
901 if (!slurp_rel_relocs (file
, rel_offset
, rel_size
, &rels
, &rel_size
))
910 printf (_(" Offset Info Type Sym. Value Symbol's Name + Addend\n"));
912 printf (_(" Offset Info Type Sym.Value Sym. Name + Addend\n"));
917 printf (_(" Offset Info Type Sym. Value Symbol's Name\n"));
919 printf (_(" Offset Info Type Sym.Value Sym. Name\n"));
927 printf (_(" Offset Info Type Symbol's Value Symbol's Name + Addend\n"));
929 printf (_(" Offset Info Type Sym. Value Sym. Name + Addend\n"));
934 printf (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
936 printf (_(" Offset Info Type Sym. Value Sym. Name\n"));
940 for (i
= 0; i
< rel_size
; i
++)
945 bfd_vma symtab_index
;
948 offset
= rels
[i
].r_offset
;
949 info
= rels
[i
].r_info
;
951 type
= get_reloc_type (info
);
952 symtab_index
= get_reloc_symindex (info
);
956 printf ("%8.8lx %8.8lx ",
957 (unsigned long) offset
& 0xffffffff,
958 (unsigned long) info
& 0xffffffff);
962 #if BFD_HOST_64BIT_LONG
964 ? "%16.16lx %16.16lx "
965 : "%12.12lx %12.12lx ",
967 #elif BFD_HOST_64BIT_LONG_LONG
970 ? "%16.16llx %16.16llx "
971 : "%12.12llx %12.12llx ",
975 ? "%16.16I64x %16.16I64x "
976 : "%12.12I64x %12.12I64x ",
981 ? "%8.8lx%8.8lx %8.8lx%8.8lx "
982 : "%4.4lx%8.8lx %4.4lx%8.8lx ",
983 _bfd_int64_high (offset
),
984 _bfd_int64_low (offset
),
985 _bfd_int64_high (info
),
986 _bfd_int64_low (info
));
990 switch (elf_header
.e_machine
)
998 rtype
= elf_m32r_reloc_type (type
);
1003 rtype
= elf_i386_reloc_type (type
);
1008 rtype
= elf_m68hc11_reloc_type (type
);
1012 rtype
= elf_m68k_reloc_type (type
);
1016 rtype
= elf_i960_reloc_type (type
);
1021 rtype
= elf_avr_reloc_type (type
);
1024 case EM_OLD_SPARCV9
:
1025 case EM_SPARC32PLUS
:
1028 rtype
= elf_sparc_reloc_type (type
);
1032 rtype
= elf_spu_reloc_type (type
);
1036 case EM_CYGNUS_V850
:
1037 rtype
= v850_reloc_type (type
);
1041 case EM_CYGNUS_D10V
:
1042 rtype
= elf_d10v_reloc_type (type
);
1046 case EM_CYGNUS_D30V
:
1047 rtype
= elf_d30v_reloc_type (type
);
1051 rtype
= elf_dlx_reloc_type (type
);
1055 rtype
= elf_sh_reloc_type (type
);
1059 case EM_CYGNUS_MN10300
:
1060 rtype
= elf_mn10300_reloc_type (type
);
1064 case EM_CYGNUS_MN10200
:
1065 rtype
= elf_mn10200_reloc_type (type
);
1069 case EM_CYGNUS_FR30
:
1070 rtype
= elf_fr30_reloc_type (type
);
1074 rtype
= elf_frv_reloc_type (type
);
1078 rtype
= elf_mcore_reloc_type (type
);
1082 rtype
= elf_mmix_reloc_type (type
);
1087 rtype
= elf_msp430_reloc_type (type
);
1091 rtype
= elf_ppc_reloc_type (type
);
1095 rtype
= elf_ppc64_reloc_type (type
);
1099 case EM_MIPS_RS3_LE
:
1100 rtype
= elf_mips_reloc_type (type
);
1104 rtype
= elf_alpha_reloc_type (type
);
1108 rtype
= elf_arm_reloc_type (type
);
1112 rtype
= elf_arc_reloc_type (type
);
1116 rtype
= elf_hppa_reloc_type (type
);
1122 rtype
= elf_h8_reloc_type (type
);
1127 rtype
= elf_or32_reloc_type (type
);
1132 rtype
= elf_pj_reloc_type (type
);
1135 rtype
= elf_ia64_reloc_type (type
);
1139 rtype
= elf_cris_reloc_type (type
);
1143 rtype
= elf_i860_reloc_type (type
);
1147 rtype
= elf_x86_64_reloc_type (type
);
1151 rtype
= i370_reloc_type (type
);
1156 rtype
= elf_s390_reloc_type (type
);
1160 rtype
= elf_score_reloc_type (type
);
1164 rtype
= elf_xstormy16_reloc_type (type
);
1168 rtype
= elf_crx_reloc_type (type
);
1172 rtype
= elf_vax_reloc_type (type
);
1177 rtype
= elf_ip2k_reloc_type (type
);
1181 rtype
= elf_iq2000_reloc_type (type
);
1186 rtype
= elf_xtensa_reloc_type (type
);
1191 rtype
= elf_m32c_reloc_type (type
);
1195 rtype
= elf_mt_reloc_type (type
);
1199 rtype
= elf_bfin_reloc_type (type
);
1203 rtype
= elf_mep_reloc_type (type
);
1208 rtype
= elf_cr16_reloc_type (type
);
1213 printf (_("unrecognized: %-7lx"), (unsigned long) type
& 0xffffffff);
1215 printf (do_wide
? "%-22.22s" : "%-17.17s", rtype
);
1217 if (elf_header
.e_machine
== EM_ALPHA
1219 && streq (rtype
, "R_ALPHA_LITUSE")
1222 switch (rels
[i
].r_addend
)
1224 case LITUSE_ALPHA_ADDR
: rtype
= "ADDR"; break;
1225 case LITUSE_ALPHA_BASE
: rtype
= "BASE"; break;
1226 case LITUSE_ALPHA_BYTOFF
: rtype
= "BYTOFF"; break;
1227 case LITUSE_ALPHA_JSR
: rtype
= "JSR"; break;
1228 case LITUSE_ALPHA_TLSGD
: rtype
= "TLSGD"; break;
1229 case LITUSE_ALPHA_TLSLDM
: rtype
= "TLSLDM"; break;
1230 case LITUSE_ALPHA_JSRDIRECT
: rtype
= "JSRDIRECT"; break;
1231 default: rtype
= NULL
;
1234 printf (" (%s)", rtype
);
1238 printf (_("<unknown addend: %lx>"),
1239 (unsigned long) rels
[i
].r_addend
);
1242 else if (symtab_index
)
1244 if (symtab
== NULL
|| symtab_index
>= nsyms
)
1245 printf (" bad symbol index: %08lx", (unsigned long) symtab_index
);
1248 Elf_Internal_Sym
*psym
;
1250 psym
= symtab
+ symtab_index
;
1254 if (ELF_ST_TYPE (psym
->st_info
) == STT_IFUNC
)
1258 unsigned int width
= is_32bit_elf
? 8 : 14;
1260 /* Relocations against IFUNC symbols do not use the value of
1261 the symbol as the address to relocate against. Instead
1262 they invoke the function named by the symbol and use its
1263 result as the address for relocation.
1265 To indicate this to the user, do not display the value of
1266 the symbol in the "Symbols's Value" field. Instead show
1267 its name followed by () as a hint that the symbol is
1271 || psym
->st_name
== 0
1272 || psym
->st_name
>= strtablen
)
1275 name
= strtab
+ psym
->st_name
;
1277 len
= print_symbol (width
, name
);
1278 printf ("()%-*s", len
<= width
? (width
+ 1) - len
: 1, " ");
1282 print_vma (psym
->st_value
, LONG_HEX
);
1284 printf (is_32bit_elf
? " " : " ");
1287 if (psym
->st_name
== 0)
1289 const char *sec_name
= "<null>";
1292 if (ELF_ST_TYPE (psym
->st_info
) == STT_SECTION
)
1294 if (psym
->st_shndx
< elf_header
.e_shnum
)
1296 = SECTION_NAME (section_headers
+ psym
->st_shndx
);
1297 else if (psym
->st_shndx
== SHN_ABS
)
1299 else if (psym
->st_shndx
== SHN_COMMON
)
1300 sec_name
= "COMMON";
1301 else if (elf_header
.e_machine
== EM_MIPS
1302 && psym
->st_shndx
== SHN_MIPS_SCOMMON
)
1303 sec_name
= "SCOMMON";
1304 else if (elf_header
.e_machine
== EM_MIPS
1305 && psym
->st_shndx
== SHN_MIPS_SUNDEFINED
)
1306 sec_name
= "SUNDEF";
1307 else if (elf_header
.e_machine
== EM_X86_64
1308 && psym
->st_shndx
== SHN_X86_64_LCOMMON
)
1309 sec_name
= "LARGE_COMMON";
1310 else if (elf_header
.e_machine
== EM_IA_64
1311 && elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
1312 && psym
->st_shndx
== SHN_IA_64_ANSI_COMMON
)
1313 sec_name
= "ANSI_COM";
1314 else if (elf_header
.e_machine
== EM_IA_64
1315 && (elf_header
.e_ident
[EI_OSABI
]
1316 == ELFOSABI_OPENVMS
)
1317 && psym
->st_shndx
== SHN_IA_64_VMS_SYMVEC
)
1318 sec_name
= "VMS_SYMVEC";
1321 sprintf (name_buf
, "<section 0x%x>",
1322 (unsigned int) psym
->st_shndx
);
1323 sec_name
= name_buf
;
1326 print_symbol (22, sec_name
);
1328 else if (strtab
== NULL
)
1329 printf (_("<string table index: %3ld>"), psym
->st_name
);
1330 else if (psym
->st_name
>= strtablen
)
1331 printf (_("<corrupt string table index: %3ld>"), psym
->st_name
);
1333 print_symbol (22, strtab
+ psym
->st_name
);
1337 long offset
= (long) (bfd_signed_vma
) rels
[i
].r_addend
;
1340 printf (" - %lx", - offset
);
1342 printf (" + %lx", offset
);
1348 printf ("%*c", is_32bit_elf
?
1349 (do_wide
? 34 : 28) : (do_wide
? 26 : 20), ' ');
1350 print_vma (rels
[i
].r_addend
, LONG_HEX
);
1353 if (elf_header
.e_machine
== EM_SPARCV9
1355 && streq (rtype
, "R_SPARC_OLO10"))
1356 printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (info
));
1361 if (! is_32bit_elf
&& elf_header
.e_machine
== EM_MIPS
)
1363 bfd_vma type2
= ELF64_MIPS_R_TYPE2 (info
);
1364 bfd_vma type3
= ELF64_MIPS_R_TYPE3 (info
);
1365 const char *rtype2
= elf_mips_reloc_type (type2
);
1366 const char *rtype3
= elf_mips_reloc_type (type3
);
1368 printf (" Type2: ");
1371 printf (_("unrecognized: %-7lx"),
1372 (unsigned long) type2
& 0xffffffff);
1374 printf ("%-17.17s", rtype2
);
1376 printf ("\n Type3: ");
1379 printf (_("unrecognized: %-7lx"),
1380 (unsigned long) type3
& 0xffffffff);
1382 printf ("%-17.17s", rtype3
);
1393 get_mips_dynamic_type (unsigned long type
)
1397 case DT_MIPS_RLD_VERSION
: return "MIPS_RLD_VERSION";
1398 case DT_MIPS_TIME_STAMP
: return "MIPS_TIME_STAMP";
1399 case DT_MIPS_ICHECKSUM
: return "MIPS_ICHECKSUM";
1400 case DT_MIPS_IVERSION
: return "MIPS_IVERSION";
1401 case DT_MIPS_FLAGS
: return "MIPS_FLAGS";
1402 case DT_MIPS_BASE_ADDRESS
: return "MIPS_BASE_ADDRESS";
1403 case DT_MIPS_MSYM
: return "MIPS_MSYM";
1404 case DT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
1405 case DT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
1406 case DT_MIPS_LOCAL_GOTNO
: return "MIPS_LOCAL_GOTNO";
1407 case DT_MIPS_CONFLICTNO
: return "MIPS_CONFLICTNO";
1408 case DT_MIPS_LIBLISTNO
: return "MIPS_LIBLISTNO";
1409 case DT_MIPS_SYMTABNO
: return "MIPS_SYMTABNO";
1410 case DT_MIPS_UNREFEXTNO
: return "MIPS_UNREFEXTNO";
1411 case DT_MIPS_GOTSYM
: return "MIPS_GOTSYM";
1412 case DT_MIPS_HIPAGENO
: return "MIPS_HIPAGENO";
1413 case DT_MIPS_RLD_MAP
: return "MIPS_RLD_MAP";
1414 case DT_MIPS_DELTA_CLASS
: return "MIPS_DELTA_CLASS";
1415 case DT_MIPS_DELTA_CLASS_NO
: return "MIPS_DELTA_CLASS_NO";
1416 case DT_MIPS_DELTA_INSTANCE
: return "MIPS_DELTA_INSTANCE";
1417 case DT_MIPS_DELTA_INSTANCE_NO
: return "MIPS_DELTA_INSTANCE_NO";
1418 case DT_MIPS_DELTA_RELOC
: return "MIPS_DELTA_RELOC";
1419 case DT_MIPS_DELTA_RELOC_NO
: return "MIPS_DELTA_RELOC_NO";
1420 case DT_MIPS_DELTA_SYM
: return "MIPS_DELTA_SYM";
1421 case DT_MIPS_DELTA_SYM_NO
: return "MIPS_DELTA_SYM_NO";
1422 case DT_MIPS_DELTA_CLASSSYM
: return "MIPS_DELTA_CLASSSYM";
1423 case DT_MIPS_DELTA_CLASSSYM_NO
: return "MIPS_DELTA_CLASSSYM_NO";
1424 case DT_MIPS_CXX_FLAGS
: return "MIPS_CXX_FLAGS";
1425 case DT_MIPS_PIXIE_INIT
: return "MIPS_PIXIE_INIT";
1426 case DT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
1427 case DT_MIPS_LOCALPAGE_GOTIDX
: return "MIPS_LOCALPAGE_GOTIDX";
1428 case DT_MIPS_LOCAL_GOTIDX
: return "MIPS_LOCAL_GOTIDX";
1429 case DT_MIPS_HIDDEN_GOTIDX
: return "MIPS_HIDDEN_GOTIDX";
1430 case DT_MIPS_PROTECTED_GOTIDX
: return "MIPS_PROTECTED_GOTIDX";
1431 case DT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
1432 case DT_MIPS_INTERFACE
: return "MIPS_INTERFACE";
1433 case DT_MIPS_DYNSTR_ALIGN
: return "MIPS_DYNSTR_ALIGN";
1434 case DT_MIPS_INTERFACE_SIZE
: return "MIPS_INTERFACE_SIZE";
1435 case DT_MIPS_RLD_TEXT_RESOLVE_ADDR
: return "MIPS_RLD_TEXT_RESOLVE_ADDR";
1436 case DT_MIPS_PERF_SUFFIX
: return "MIPS_PERF_SUFFIX";
1437 case DT_MIPS_COMPACT_SIZE
: return "MIPS_COMPACT_SIZE";
1438 case DT_MIPS_GP_VALUE
: return "MIPS_GP_VALUE";
1439 case DT_MIPS_AUX_DYNAMIC
: return "MIPS_AUX_DYNAMIC";
1440 case DT_MIPS_PLTGOT
: return "MIPS_PLTGOT";
1441 case DT_MIPS_RWPLT
: return "MIPS_RWPLT";
1448 get_sparc64_dynamic_type (unsigned long type
)
1452 case DT_SPARC_REGISTER
: return "SPARC_REGISTER";
1459 get_ppc_dynamic_type (unsigned long type
)
1463 case DT_PPC_GOT
: return "PPC_GOT";
1470 get_ppc64_dynamic_type (unsigned long type
)
1474 case DT_PPC64_GLINK
: return "PPC64_GLINK";
1475 case DT_PPC64_OPD
: return "PPC64_OPD";
1476 case DT_PPC64_OPDSZ
: return "PPC64_OPDSZ";
1483 get_parisc_dynamic_type (unsigned long type
)
1487 case DT_HP_LOAD_MAP
: return "HP_LOAD_MAP";
1488 case DT_HP_DLD_FLAGS
: return "HP_DLD_FLAGS";
1489 case DT_HP_DLD_HOOK
: return "HP_DLD_HOOK";
1490 case DT_HP_UX10_INIT
: return "HP_UX10_INIT";
1491 case DT_HP_UX10_INITSZ
: return "HP_UX10_INITSZ";
1492 case DT_HP_PREINIT
: return "HP_PREINIT";
1493 case DT_HP_PREINITSZ
: return "HP_PREINITSZ";
1494 case DT_HP_NEEDED
: return "HP_NEEDED";
1495 case DT_HP_TIME_STAMP
: return "HP_TIME_STAMP";
1496 case DT_HP_CHECKSUM
: return "HP_CHECKSUM";
1497 case DT_HP_GST_SIZE
: return "HP_GST_SIZE";
1498 case DT_HP_GST_VERSION
: return "HP_GST_VERSION";
1499 case DT_HP_GST_HASHVAL
: return "HP_GST_HASHVAL";
1500 case DT_HP_EPLTREL
: return "HP_GST_EPLTREL";
1501 case DT_HP_EPLTRELSZ
: return "HP_GST_EPLTRELSZ";
1502 case DT_HP_FILTERED
: return "HP_FILTERED";
1503 case DT_HP_FILTER_TLS
: return "HP_FILTER_TLS";
1504 case DT_HP_COMPAT_FILTERED
: return "HP_COMPAT_FILTERED";
1505 case DT_HP_LAZYLOAD
: return "HP_LAZYLOAD";
1506 case DT_HP_BIND_NOW_COUNT
: return "HP_BIND_NOW_COUNT";
1507 case DT_PLT
: return "PLT";
1508 case DT_PLT_SIZE
: return "PLT_SIZE";
1509 case DT_DLT
: return "DLT";
1510 case DT_DLT_SIZE
: return "DLT_SIZE";
1517 get_ia64_dynamic_type (unsigned long type
)
1521 case DT_IA_64_PLT_RESERVE
: return "IA_64_PLT_RESERVE";
1522 case DT_IA_64_VMS_SUBTYPE
: return "VMS_SUBTYPE";
1523 case DT_IA_64_VMS_IMGIOCNT
: return "VMS_IMGIOCNT";
1524 case DT_IA_64_VMS_LNKFLAGS
: return "VMS_LNKFLAGS";
1525 case DT_IA_64_VMS_VIR_MEM_BLK_SIZ
: return "VMS_VIR_MEM_BLK_SIZ";
1526 case DT_IA_64_VMS_IDENT
: return "VMS_IDENT";
1527 case DT_IA_64_VMS_NEEDED_IDENT
: return "VMS_NEEDED_IDENT";
1528 case DT_IA_64_VMS_IMG_RELA_CNT
: return "VMS_IMG_RELA_CNT";
1529 case DT_IA_64_VMS_SEG_RELA_CNT
: return "VMS_SEG_RELA_CNT";
1530 case DT_IA_64_VMS_FIXUP_RELA_CNT
: return "VMS_FIXUP_RELA_CNT";
1531 case DT_IA_64_VMS_FIXUP_NEEDED
: return "VMS_FIXUP_NEEDED";
1532 case DT_IA_64_VMS_SYMVEC_CNT
: return "VMS_SYMVEC_CNT";
1533 case DT_IA_64_VMS_XLATED
: return "VMS_XLATED";
1534 case DT_IA_64_VMS_STACKSIZE
: return "VMS_STACKSIZE";
1535 case DT_IA_64_VMS_UNWINDSZ
: return "VMS_UNWINDSZ";
1536 case DT_IA_64_VMS_UNWIND_CODSEG
: return "VMS_UNWIND_CODSEG";
1537 case DT_IA_64_VMS_UNWIND_INFOSEG
: return "VMS_UNWIND_INFOSEG";
1538 case DT_IA_64_VMS_LINKTIME
: return "VMS_LINKTIME";
1539 case DT_IA_64_VMS_SEG_NO
: return "VMS_SEG_NO";
1540 case DT_IA_64_VMS_SYMVEC_OFFSET
: return "VMS_SYMVEC_OFFSET";
1541 case DT_IA_64_VMS_SYMVEC_SEG
: return "VMS_SYMVEC_SEG";
1542 case DT_IA_64_VMS_UNWIND_OFFSET
: return "VMS_UNWIND_OFFSET";
1543 case DT_IA_64_VMS_UNWIND_SEG
: return "VMS_UNWIND_SEG";
1544 case DT_IA_64_VMS_STRTAB_OFFSET
: return "VMS_STRTAB_OFFSET";
1545 case DT_IA_64_VMS_SYSVER_OFFSET
: return "VMS_SYSVER_OFFSET";
1546 case DT_IA_64_VMS_IMG_RELA_OFF
: return "VMS_IMG_RELA_OFF";
1547 case DT_IA_64_VMS_SEG_RELA_OFF
: return "VMS_SEG_RELA_OFF";
1548 case DT_IA_64_VMS_FIXUP_RELA_OFF
: return "VMS_FIXUP_RELA_OFF";
1549 case DT_IA_64_VMS_PLTGOT_OFFSET
: return "VMS_PLTGOT_OFFSET";
1550 case DT_IA_64_VMS_PLTGOT_SEG
: return "VMS_PLTGOT_SEG";
1551 case DT_IA_64_VMS_FPMODE
: return "VMS_FPMODE";
1558 get_alpha_dynamic_type (unsigned long type
)
1562 case DT_ALPHA_PLTRO
: return "ALPHA_PLTRO";
1569 get_score_dynamic_type (unsigned long type
)
1573 case DT_SCORE_BASE_ADDRESS
: return "SCORE_BASE_ADDRESS";
1574 case DT_SCORE_LOCAL_GOTNO
: return "SCORE_LOCAL_GOTNO";
1575 case DT_SCORE_SYMTABNO
: return "SCORE_SYMTABNO";
1576 case DT_SCORE_GOTSYM
: return "SCORE_GOTSYM";
1577 case DT_SCORE_UNREFEXTNO
: return "SCORE_UNREFEXTNO";
1578 case DT_SCORE_HIPAGENO
: return "SCORE_HIPAGENO";
1586 get_dynamic_type (unsigned long type
)
1588 static char buff
[64];
1592 case DT_NULL
: return "NULL";
1593 case DT_NEEDED
: return "NEEDED";
1594 case DT_PLTRELSZ
: return "PLTRELSZ";
1595 case DT_PLTGOT
: return "PLTGOT";
1596 case DT_HASH
: return "HASH";
1597 case DT_STRTAB
: return "STRTAB";
1598 case DT_SYMTAB
: return "SYMTAB";
1599 case DT_RELA
: return "RELA";
1600 case DT_RELASZ
: return "RELASZ";
1601 case DT_RELAENT
: return "RELAENT";
1602 case DT_STRSZ
: return "STRSZ";
1603 case DT_SYMENT
: return "SYMENT";
1604 case DT_INIT
: return "INIT";
1605 case DT_FINI
: return "FINI";
1606 case DT_SONAME
: return "SONAME";
1607 case DT_RPATH
: return "RPATH";
1608 case DT_SYMBOLIC
: return "SYMBOLIC";
1609 case DT_REL
: return "REL";
1610 case DT_RELSZ
: return "RELSZ";
1611 case DT_RELENT
: return "RELENT";
1612 case DT_PLTREL
: return "PLTREL";
1613 case DT_DEBUG
: return "DEBUG";
1614 case DT_TEXTREL
: return "TEXTREL";
1615 case DT_JMPREL
: return "JMPREL";
1616 case DT_BIND_NOW
: return "BIND_NOW";
1617 case DT_INIT_ARRAY
: return "INIT_ARRAY";
1618 case DT_FINI_ARRAY
: return "FINI_ARRAY";
1619 case DT_INIT_ARRAYSZ
: return "INIT_ARRAYSZ";
1620 case DT_FINI_ARRAYSZ
: return "FINI_ARRAYSZ";
1621 case DT_RUNPATH
: return "RUNPATH";
1622 case DT_FLAGS
: return "FLAGS";
1624 case DT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
1625 case DT_PREINIT_ARRAYSZ
: return "PREINIT_ARRAYSZ";
1627 case DT_CHECKSUM
: return "CHECKSUM";
1628 case DT_PLTPADSZ
: return "PLTPADSZ";
1629 case DT_MOVEENT
: return "MOVEENT";
1630 case DT_MOVESZ
: return "MOVESZ";
1631 case DT_FEATURE
: return "FEATURE";
1632 case DT_POSFLAG_1
: return "POSFLAG_1";
1633 case DT_SYMINSZ
: return "SYMINSZ";
1634 case DT_SYMINENT
: return "SYMINENT"; /* aka VALRNGHI */
1636 case DT_ADDRRNGLO
: return "ADDRRNGLO";
1637 case DT_CONFIG
: return "CONFIG";
1638 case DT_DEPAUDIT
: return "DEPAUDIT";
1639 case DT_AUDIT
: return "AUDIT";
1640 case DT_PLTPAD
: return "PLTPAD";
1641 case DT_MOVETAB
: return "MOVETAB";
1642 case DT_SYMINFO
: return "SYMINFO"; /* aka ADDRRNGHI */
1644 case DT_VERSYM
: return "VERSYM";
1646 case DT_TLSDESC_GOT
: return "TLSDESC_GOT";
1647 case DT_TLSDESC_PLT
: return "TLSDESC_PLT";
1648 case DT_RELACOUNT
: return "RELACOUNT";
1649 case DT_RELCOUNT
: return "RELCOUNT";
1650 case DT_FLAGS_1
: return "FLAGS_1";
1651 case DT_VERDEF
: return "VERDEF";
1652 case DT_VERDEFNUM
: return "VERDEFNUM";
1653 case DT_VERNEED
: return "VERNEED";
1654 case DT_VERNEEDNUM
: return "VERNEEDNUM";
1656 case DT_AUXILIARY
: return "AUXILIARY";
1657 case DT_USED
: return "USED";
1658 case DT_FILTER
: return "FILTER";
1660 case DT_GNU_PRELINKED
: return "GNU_PRELINKED";
1661 case DT_GNU_CONFLICT
: return "GNU_CONFLICT";
1662 case DT_GNU_CONFLICTSZ
: return "GNU_CONFLICTSZ";
1663 case DT_GNU_LIBLIST
: return "GNU_LIBLIST";
1664 case DT_GNU_LIBLISTSZ
: return "GNU_LIBLISTSZ";
1665 case DT_GNU_HASH
: return "GNU_HASH";
1668 if ((type
>= DT_LOPROC
) && (type
<= DT_HIPROC
))
1672 switch (elf_header
.e_machine
)
1675 case EM_MIPS_RS3_LE
:
1676 result
= get_mips_dynamic_type (type
);
1679 result
= get_sparc64_dynamic_type (type
);
1682 result
= get_ppc_dynamic_type (type
);
1685 result
= get_ppc64_dynamic_type (type
);
1688 result
= get_ia64_dynamic_type (type
);
1691 result
= get_alpha_dynamic_type (type
);
1694 result
= get_score_dynamic_type (type
);
1704 snprintf (buff
, sizeof (buff
), _("Processor Specific: %lx"), type
);
1706 else if (((type
>= DT_LOOS
) && (type
<= DT_HIOS
))
1707 || (elf_header
.e_machine
== EM_PARISC
1708 && (type
>= OLD_DT_LOOS
) && (type
<= OLD_DT_HIOS
)))
1712 switch (elf_header
.e_machine
)
1715 result
= get_parisc_dynamic_type (type
);
1718 result
= get_ia64_dynamic_type (type
);
1728 snprintf (buff
, sizeof (buff
), _("Operating System specific: %lx"),
1732 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), type
);
1739 get_file_type (unsigned e_type
)
1741 static char buff
[32];
1745 case ET_NONE
: return _("NONE (None)");
1746 case ET_REL
: return _("REL (Relocatable file)");
1747 case ET_EXEC
: return _("EXEC (Executable file)");
1748 case ET_DYN
: return _("DYN (Shared object file)");
1749 case ET_CORE
: return _("CORE (Core file)");
1752 if ((e_type
>= ET_LOPROC
) && (e_type
<= ET_HIPROC
))
1753 snprintf (buff
, sizeof (buff
), _("Processor Specific: (%x)"), e_type
);
1754 else if ((e_type
>= ET_LOOS
) && (e_type
<= ET_HIOS
))
1755 snprintf (buff
, sizeof (buff
), _("OS Specific: (%x)"), e_type
);
1757 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), e_type
);
1763 get_machine_name (unsigned e_machine
)
1765 static char buff
[64]; /* XXX */
1769 case EM_NONE
: return _("None");
1770 case EM_M32
: return "WE32100";
1771 case EM_SPARC
: return "Sparc";
1772 case EM_SPU
: return "SPU";
1773 case EM_386
: return "Intel 80386";
1774 case EM_68K
: return "MC68000";
1775 case EM_88K
: return "MC88000";
1776 case EM_486
: return "Intel 80486";
1777 case EM_860
: return "Intel 80860";
1778 case EM_MIPS
: return "MIPS R3000";
1779 case EM_S370
: return "IBM System/370";
1780 case EM_MIPS_RS3_LE
: return "MIPS R4000 big-endian";
1781 case EM_OLD_SPARCV9
: return "Sparc v9 (old)";
1782 case EM_PARISC
: return "HPPA";
1783 case EM_PPC_OLD
: return "Power PC (old)";
1784 case EM_SPARC32PLUS
: return "Sparc v8+" ;
1785 case EM_960
: return "Intel 90860";
1786 case EM_PPC
: return "PowerPC";
1787 case EM_PPC64
: return "PowerPC64";
1788 case EM_V800
: return "NEC V800";
1789 case EM_FR20
: return "Fujitsu FR20";
1790 case EM_RH32
: return "TRW RH32";
1791 case EM_MCORE
: return "MCORE";
1792 case EM_ARM
: return "ARM";
1793 case EM_OLD_ALPHA
: return "Digital Alpha (old)";
1794 case EM_SH
: return "Renesas / SuperH SH";
1795 case EM_SPARCV9
: return "Sparc v9";
1796 case EM_TRICORE
: return "Siemens Tricore";
1797 case EM_ARC
: return "ARC";
1798 case EM_H8_300
: return "Renesas H8/300";
1799 case EM_H8_300H
: return "Renesas H8/300H";
1800 case EM_H8S
: return "Renesas H8S";
1801 case EM_H8_500
: return "Renesas H8/500";
1802 case EM_IA_64
: return "Intel IA-64";
1803 case EM_MIPS_X
: return "Stanford MIPS-X";
1804 case EM_COLDFIRE
: return "Motorola Coldfire";
1805 case EM_68HC12
: return "Motorola M68HC12";
1806 case EM_ALPHA
: return "Alpha";
1807 case EM_CYGNUS_D10V
:
1808 case EM_D10V
: return "d10v";
1809 case EM_CYGNUS_D30V
:
1810 case EM_D30V
: return "d30v";
1811 case EM_CYGNUS_M32R
:
1812 case EM_M32R
: return "Renesas M32R (formerly Mitsubishi M32r)";
1813 case EM_CYGNUS_V850
:
1814 case EM_V850
: return "NEC v850";
1815 case EM_CYGNUS_MN10300
:
1816 case EM_MN10300
: return "mn10300";
1817 case EM_CYGNUS_MN10200
:
1818 case EM_MN10200
: return "mn10200";
1819 case EM_CYGNUS_FR30
:
1820 case EM_FR30
: return "Fujitsu FR30";
1821 case EM_CYGNUS_FRV
: return "Fujitsu FR-V";
1823 case EM_PJ
: return "picoJava";
1824 case EM_MMA
: return "Fujitsu Multimedia Accelerator";
1825 case EM_PCP
: return "Siemens PCP";
1826 case EM_NCPU
: return "Sony nCPU embedded RISC processor";
1827 case EM_NDR1
: return "Denso NDR1 microprocesspr";
1828 case EM_STARCORE
: return "Motorola Star*Core processor";
1829 case EM_ME16
: return "Toyota ME16 processor";
1830 case EM_ST100
: return "STMicroelectronics ST100 processor";
1831 case EM_TINYJ
: return "Advanced Logic Corp. TinyJ embedded processor";
1832 case EM_FX66
: return "Siemens FX66 microcontroller";
1833 case EM_ST9PLUS
: return "STMicroelectronics ST9+ 8/16 bit microcontroller";
1834 case EM_ST7
: return "STMicroelectronics ST7 8-bit microcontroller";
1835 case EM_68HC16
: return "Motorola MC68HC16 Microcontroller";
1836 case EM_68HC11
: return "Motorola MC68HC11 Microcontroller";
1837 case EM_68HC08
: return "Motorola MC68HC08 Microcontroller";
1838 case EM_68HC05
: return "Motorola MC68HC05 Microcontroller";
1839 case EM_SVX
: return "Silicon Graphics SVx";
1840 case EM_ST19
: return "STMicroelectronics ST19 8-bit microcontroller";
1841 case EM_VAX
: return "Digital VAX";
1843 case EM_AVR
: return "Atmel AVR 8-bit microcontroller";
1844 case EM_CRIS
: return "Axis Communications 32-bit embedded processor";
1845 case EM_JAVELIN
: return "Infineon Technologies 32-bit embedded cpu";
1846 case EM_FIREPATH
: return "Element 14 64-bit DSP processor";
1847 case EM_ZSP
: return "LSI Logic's 16-bit DSP processor";
1848 case EM_MMIX
: return "Donald Knuth's educational 64-bit processor";
1849 case EM_HUANY
: return "Harvard Universitys's machine-independent object format";
1850 case EM_PRISM
: return "Vitesse Prism";
1851 case EM_X86_64
: return "Advanced Micro Devices X86-64";
1853 case EM_S390
: return "IBM S/390";
1854 case EM_SCORE
: return "SUNPLUS S+Core";
1855 case EM_XSTORMY16
: return "Sanyo Xstormy16 CPU core";
1857 case EM_OR32
: return "OpenRISC";
1858 case EM_CRX
: return "National Semiconductor CRX microprocessor";
1859 case EM_DLX
: return "OpenDLX";
1861 case EM_IP2K
: return "Ubicom IP2xxx 8-bit microcontrollers";
1862 case EM_IQ2000
: return "Vitesse IQ2000";
1864 case EM_XTENSA
: return "Tensilica Xtensa Processor";
1866 case EM_M32C
: return "Renesas M32c";
1867 case EM_MT
: return "Morpho Techologies MT processor";
1868 case EM_BLACKFIN
: return "Analog Devices Blackfin";
1869 case EM_NIOS32
: return "Altera Nios";
1870 case EM_ALTERA_NIOS2
: return "Altera Nios II";
1871 case EM_XC16X
: return "Infineon Technologies xc16x";
1872 case EM_CYGNUS_MEP
: return "Toshiba MeP Media Engine";
1874 case EM_CR16_OLD
: return "National Semiconductor's CR16";
1876 snprintf (buff
, sizeof (buff
), _("<unknown>: 0x%x"), e_machine
);
1882 decode_ARM_machine_flags (unsigned e_flags
, char buf
[])
1887 eabi
= EF_ARM_EABI_VERSION (e_flags
);
1888 e_flags
&= ~ EF_ARM_EABIMASK
;
1890 /* Handle "generic" ARM flags. */
1891 if (e_flags
& EF_ARM_RELEXEC
)
1893 strcat (buf
, ", relocatable executable");
1894 e_flags
&= ~ EF_ARM_RELEXEC
;
1897 if (e_flags
& EF_ARM_HASENTRY
)
1899 strcat (buf
, ", has entry point");
1900 e_flags
&= ~ EF_ARM_HASENTRY
;
1903 /* Now handle EABI specific flags. */
1907 strcat (buf
, ", <unrecognized EABI>");
1912 case EF_ARM_EABI_VER1
:
1913 strcat (buf
, ", Version1 EABI");
1918 /* Process flags one bit at a time. */
1919 flag
= e_flags
& - e_flags
;
1924 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1925 strcat (buf
, ", sorted symbol tables");
1935 case EF_ARM_EABI_VER2
:
1936 strcat (buf
, ", Version2 EABI");
1941 /* Process flags one bit at a time. */
1942 flag
= e_flags
& - e_flags
;
1947 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
1948 strcat (buf
, ", sorted symbol tables");
1951 case EF_ARM_DYNSYMSUSESEGIDX
:
1952 strcat (buf
, ", dynamic symbols use segment index");
1955 case EF_ARM_MAPSYMSFIRST
:
1956 strcat (buf
, ", mapping symbols precede others");
1966 case EF_ARM_EABI_VER3
:
1967 strcat (buf
, ", Version3 EABI");
1970 case EF_ARM_EABI_VER4
:
1971 strcat (buf
, ", Version4 EABI");
1974 case EF_ARM_EABI_VER5
:
1975 strcat (buf
, ", Version5 EABI");
1981 /* Process flags one bit at a time. */
1982 flag
= e_flags
& - e_flags
;
1988 strcat (buf
, ", BE8");
1992 strcat (buf
, ", LE8");
2002 case EF_ARM_EABI_UNKNOWN
:
2003 strcat (buf
, ", GNU EABI");
2008 /* Process flags one bit at a time. */
2009 flag
= e_flags
& - e_flags
;
2014 case EF_ARM_INTERWORK
:
2015 strcat (buf
, ", interworking enabled");
2018 case EF_ARM_APCS_26
:
2019 strcat (buf
, ", uses APCS/26");
2022 case EF_ARM_APCS_FLOAT
:
2023 strcat (buf
, ", uses APCS/float");
2027 strcat (buf
, ", position independent");
2031 strcat (buf
, ", 8 bit structure alignment");
2034 case EF_ARM_NEW_ABI
:
2035 strcat (buf
, ", uses new ABI");
2038 case EF_ARM_OLD_ABI
:
2039 strcat (buf
, ", uses old ABI");
2042 case EF_ARM_SOFT_FLOAT
:
2043 strcat (buf
, ", software FP");
2046 case EF_ARM_VFP_FLOAT
:
2047 strcat (buf
, ", VFP");
2050 case EF_ARM_MAVERICK_FLOAT
:
2051 strcat (buf
, ", Maverick FP");
2062 strcat (buf
,", <unknown>");
2066 get_machine_flags (unsigned e_flags
, unsigned e_machine
)
2068 static char buf
[1024];
2080 decode_ARM_machine_flags (e_flags
, buf
);
2084 switch (e_flags
& EF_FRV_CPU_MASK
)
2086 case EF_FRV_CPU_GENERIC
:
2090 strcat (buf
, ", fr???");
2093 case EF_FRV_CPU_FR300
:
2094 strcat (buf
, ", fr300");
2097 case EF_FRV_CPU_FR400
:
2098 strcat (buf
, ", fr400");
2100 case EF_FRV_CPU_FR405
:
2101 strcat (buf
, ", fr405");
2104 case EF_FRV_CPU_FR450
:
2105 strcat (buf
, ", fr450");
2108 case EF_FRV_CPU_FR500
:
2109 strcat (buf
, ", fr500");
2111 case EF_FRV_CPU_FR550
:
2112 strcat (buf
, ", fr550");
2115 case EF_FRV_CPU_SIMPLE
:
2116 strcat (buf
, ", simple");
2118 case EF_FRV_CPU_TOMCAT
:
2119 strcat (buf
, ", tomcat");
2125 if ((e_flags
& EF_M68K_ARCH_MASK
) == EF_M68K_M68000
)
2126 strcat (buf
, ", m68000");
2127 else if ((e_flags
& EF_M68K_ARCH_MASK
) == EF_M68K_CPU32
)
2128 strcat (buf
, ", cpu32");
2129 else if ((e_flags
& EF_M68K_ARCH_MASK
) == EF_M68K_FIDO
)
2130 strcat (buf
, ", fido_a");
2133 char const *isa
= _("unknown");
2134 char const *mac
= _("unknown mac");
2135 char const *additional
= NULL
;
2137 switch (e_flags
& EF_M68K_CF_ISA_MASK
)
2139 case EF_M68K_CF_ISA_A_NODIV
:
2141 additional
= ", nodiv";
2143 case EF_M68K_CF_ISA_A
:
2146 case EF_M68K_CF_ISA_A_PLUS
:
2149 case EF_M68K_CF_ISA_B_NOUSP
:
2151 additional
= ", nousp";
2153 case EF_M68K_CF_ISA_B
:
2157 strcat (buf
, ", cf, isa ");
2160 strcat (buf
, additional
);
2161 if (e_flags
& EF_M68K_CF_FLOAT
)
2162 strcat (buf
, ", float");
2163 switch (e_flags
& EF_M68K_CF_MAC_MASK
)
2168 case EF_M68K_CF_MAC
:
2171 case EF_M68K_CF_EMAC
:
2184 if (e_flags
& EF_PPC_EMB
)
2185 strcat (buf
, ", emb");
2187 if (e_flags
& EF_PPC_RELOCATABLE
)
2188 strcat (buf
, ", relocatable");
2190 if (e_flags
& EF_PPC_RELOCATABLE_LIB
)
2191 strcat (buf
, ", relocatable-lib");
2195 case EM_CYGNUS_V850
:
2196 switch (e_flags
& EF_V850_ARCH
)
2199 strcat (buf
, ", v850e1");
2202 strcat (buf
, ", v850e");
2205 strcat (buf
, ", v850");
2208 strcat (buf
, ", unknown v850 architecture variant");
2214 case EM_CYGNUS_M32R
:
2215 if ((e_flags
& EF_M32R_ARCH
) == E_M32R_ARCH
)
2216 strcat (buf
, ", m32r");
2220 case EM_MIPS_RS3_LE
:
2221 if (e_flags
& EF_MIPS_NOREORDER
)
2222 strcat (buf
, ", noreorder");
2224 if (e_flags
& EF_MIPS_PIC
)
2225 strcat (buf
, ", pic");
2227 if (e_flags
& EF_MIPS_CPIC
)
2228 strcat (buf
, ", cpic");
2230 if (e_flags
& EF_MIPS_UCODE
)
2231 strcat (buf
, ", ugen_reserved");
2233 if (e_flags
& EF_MIPS_ABI2
)
2234 strcat (buf
, ", abi2");
2236 if (e_flags
& EF_MIPS_OPTIONS_FIRST
)
2237 strcat (buf
, ", odk first");
2239 if (e_flags
& EF_MIPS_32BITMODE
)
2240 strcat (buf
, ", 32bitmode");
2242 switch ((e_flags
& EF_MIPS_MACH
))
2244 case E_MIPS_MACH_3900
: strcat (buf
, ", 3900"); break;
2245 case E_MIPS_MACH_4010
: strcat (buf
, ", 4010"); break;
2246 case E_MIPS_MACH_4100
: strcat (buf
, ", 4100"); break;
2247 case E_MIPS_MACH_4111
: strcat (buf
, ", 4111"); break;
2248 case E_MIPS_MACH_4120
: strcat (buf
, ", 4120"); break;
2249 case E_MIPS_MACH_4650
: strcat (buf
, ", 4650"); break;
2250 case E_MIPS_MACH_5400
: strcat (buf
, ", 5400"); break;
2251 case E_MIPS_MACH_5500
: strcat (buf
, ", 5500"); break;
2252 case E_MIPS_MACH_SB1
: strcat (buf
, ", sb1"); break;
2253 case E_MIPS_MACH_9000
: strcat (buf
, ", 9000"); break;
2254 case E_MIPS_MACH_LS2E
: strcat (buf
, ", loongson-2e"); break;
2255 case E_MIPS_MACH_LS2F
: strcat (buf
, ", loongson-2f"); break;
2256 case E_MIPS_MACH_OCTEON
: strcat (buf
, ", octeon"); break;
2258 /* We simply ignore the field in this case to avoid confusion:
2259 MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
2262 default: strcat (buf
, ", unknown CPU"); break;
2265 switch ((e_flags
& EF_MIPS_ABI
))
2267 case E_MIPS_ABI_O32
: strcat (buf
, ", o32"); break;
2268 case E_MIPS_ABI_O64
: strcat (buf
, ", o64"); break;
2269 case E_MIPS_ABI_EABI32
: strcat (buf
, ", eabi32"); break;
2270 case E_MIPS_ABI_EABI64
: strcat (buf
, ", eabi64"); break;
2272 /* We simply ignore the field in this case to avoid confusion:
2273 MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension.
2274 This means it is likely to be an o32 file, but not for
2277 default: strcat (buf
, ", unknown ABI"); break;
2280 if (e_flags
& EF_MIPS_ARCH_ASE_MDMX
)
2281 strcat (buf
, ", mdmx");
2283 if (e_flags
& EF_MIPS_ARCH_ASE_M16
)
2284 strcat (buf
, ", mips16");
2286 switch ((e_flags
& EF_MIPS_ARCH
))
2288 case E_MIPS_ARCH_1
: strcat (buf
, ", mips1"); break;
2289 case E_MIPS_ARCH_2
: strcat (buf
, ", mips2"); break;
2290 case E_MIPS_ARCH_3
: strcat (buf
, ", mips3"); break;
2291 case E_MIPS_ARCH_4
: strcat (buf
, ", mips4"); break;
2292 case E_MIPS_ARCH_5
: strcat (buf
, ", mips5"); break;
2293 case E_MIPS_ARCH_32
: strcat (buf
, ", mips32"); break;
2294 case E_MIPS_ARCH_32R2
: strcat (buf
, ", mips32r2"); break;
2295 case E_MIPS_ARCH_64
: strcat (buf
, ", mips64"); break;
2296 case E_MIPS_ARCH_64R2
: strcat (buf
, ", mips64r2"); break;
2297 default: strcat (buf
, ", unknown ISA"); break;
2303 switch ((e_flags
& EF_SH_MACH_MASK
))
2305 case EF_SH1
: strcat (buf
, ", sh1"); break;
2306 case EF_SH2
: strcat (buf
, ", sh2"); break;
2307 case EF_SH3
: strcat (buf
, ", sh3"); break;
2308 case EF_SH_DSP
: strcat (buf
, ", sh-dsp"); break;
2309 case EF_SH3_DSP
: strcat (buf
, ", sh3-dsp"); break;
2310 case EF_SH4AL_DSP
: strcat (buf
, ", sh4al-dsp"); break;
2311 case EF_SH3E
: strcat (buf
, ", sh3e"); break;
2312 case EF_SH4
: strcat (buf
, ", sh4"); break;
2313 case EF_SH5
: strcat (buf
, ", sh5"); break;
2314 case EF_SH2E
: strcat (buf
, ", sh2e"); break;
2315 case EF_SH4A
: strcat (buf
, ", sh4a"); break;
2316 case EF_SH2A
: strcat (buf
, ", sh2a"); break;
2317 case EF_SH4_NOFPU
: strcat (buf
, ", sh4-nofpu"); break;
2318 case EF_SH4A_NOFPU
: strcat (buf
, ", sh4a-nofpu"); break;
2319 case EF_SH2A_NOFPU
: strcat (buf
, ", sh2a-nofpu"); break;
2320 case EF_SH3_NOMMU
: strcat (buf
, ", sh3-nommu"); break;
2321 case EF_SH4_NOMMU_NOFPU
: strcat (buf
, ", sh4-nommu-nofpu"); break;
2322 case EF_SH2A_SH4_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh4-nommu-nofpu"); break;
2323 case EF_SH2A_SH3_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh3-nommu"); break;
2324 case EF_SH2A_SH4
: strcat (buf
, ", sh2a-or-sh4"); break;
2325 case EF_SH2A_SH3E
: strcat (buf
, ", sh2a-or-sh3e"); break;
2326 default: strcat (buf
, ", unknown ISA"); break;
2332 if (e_flags
& EF_SPARC_32PLUS
)
2333 strcat (buf
, ", v8+");
2335 if (e_flags
& EF_SPARC_SUN_US1
)
2336 strcat (buf
, ", ultrasparcI");
2338 if (e_flags
& EF_SPARC_SUN_US3
)
2339 strcat (buf
, ", ultrasparcIII");
2341 if (e_flags
& EF_SPARC_HAL_R1
)
2342 strcat (buf
, ", halr1");
2344 if (e_flags
& EF_SPARC_LEDATA
)
2345 strcat (buf
, ", ledata");
2347 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_TSO
)
2348 strcat (buf
, ", tso");
2350 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_PSO
)
2351 strcat (buf
, ", pso");
2353 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_RMO
)
2354 strcat (buf
, ", rmo");
2358 switch (e_flags
& EF_PARISC_ARCH
)
2360 case EFA_PARISC_1_0
:
2361 strcpy (buf
, ", PA-RISC 1.0");
2363 case EFA_PARISC_1_1
:
2364 strcpy (buf
, ", PA-RISC 1.1");
2366 case EFA_PARISC_2_0
:
2367 strcpy (buf
, ", PA-RISC 2.0");
2372 if (e_flags
& EF_PARISC_TRAPNIL
)
2373 strcat (buf
, ", trapnil");
2374 if (e_flags
& EF_PARISC_EXT
)
2375 strcat (buf
, ", ext");
2376 if (e_flags
& EF_PARISC_LSB
)
2377 strcat (buf
, ", lsb");
2378 if (e_flags
& EF_PARISC_WIDE
)
2379 strcat (buf
, ", wide");
2380 if (e_flags
& EF_PARISC_NO_KABP
)
2381 strcat (buf
, ", no kabp");
2382 if (e_flags
& EF_PARISC_LAZYSWAP
)
2383 strcat (buf
, ", lazyswap");
2388 if ((e_flags
& EF_PICOJAVA_NEWCALLS
) == EF_PICOJAVA_NEWCALLS
)
2389 strcat (buf
, ", new calling convention");
2391 if ((e_flags
& EF_PICOJAVA_GNUCALLS
) == EF_PICOJAVA_GNUCALLS
)
2392 strcat (buf
, ", gnu calling convention");
2396 if ((e_flags
& EF_IA_64_ABI64
))
2397 strcat (buf
, ", 64-bit");
2399 strcat (buf
, ", 32-bit");
2400 if ((e_flags
& EF_IA_64_REDUCEDFP
))
2401 strcat (buf
, ", reduced fp model");
2402 if ((e_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
))
2403 strcat (buf
, ", no function descriptors, constant gp");
2404 else if ((e_flags
& EF_IA_64_CONS_GP
))
2405 strcat (buf
, ", constant gp");
2406 if ((e_flags
& EF_IA_64_ABSOLUTE
))
2407 strcat (buf
, ", absolute");
2411 if ((e_flags
& EF_VAX_NONPIC
))
2412 strcat (buf
, ", non-PIC");
2413 if ((e_flags
& EF_VAX_DFLOAT
))
2414 strcat (buf
, ", D-Float");
2415 if ((e_flags
& EF_VAX_GFLOAT
))
2416 strcat (buf
, ", G-Float");
2425 get_osabi_name (unsigned int osabi
)
2427 static char buff
[32];
2431 case ELFOSABI_NONE
: return "UNIX - System V";
2432 case ELFOSABI_HPUX
: return "UNIX - HP-UX";
2433 case ELFOSABI_NETBSD
: return "UNIX - NetBSD";
2434 case ELFOSABI_LINUX
: return "UNIX - Linux";
2435 case ELFOSABI_HURD
: return "GNU/Hurd";
2436 case ELFOSABI_SOLARIS
: return "UNIX - Solaris";
2437 case ELFOSABI_AIX
: return "UNIX - AIX";
2438 case ELFOSABI_IRIX
: return "UNIX - IRIX";
2439 case ELFOSABI_FREEBSD
: return "UNIX - FreeBSD";
2440 case ELFOSABI_TRU64
: return "UNIX - TRU64";
2441 case ELFOSABI_MODESTO
: return "Novell - Modesto";
2442 case ELFOSABI_OPENBSD
: return "UNIX - OpenBSD";
2443 case ELFOSABI_OPENVMS
: return "VMS - OpenVMS";
2444 case ELFOSABI_NSK
: return "HP - Non-Stop Kernel";
2445 case ELFOSABI_AROS
: return "AROS";
2446 case ELFOSABI_STANDALONE
: return _("Standalone App");
2447 case ELFOSABI_ARM
: return "ARM";
2449 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), osabi
);
2455 get_arm_segment_type (unsigned long type
)
2469 get_mips_segment_type (unsigned long type
)
2473 case PT_MIPS_REGINFO
:
2475 case PT_MIPS_RTPROC
:
2477 case PT_MIPS_OPTIONS
:
2487 get_parisc_segment_type (unsigned long type
)
2491 case PT_HP_TLS
: return "HP_TLS";
2492 case PT_HP_CORE_NONE
: return "HP_CORE_NONE";
2493 case PT_HP_CORE_VERSION
: return "HP_CORE_VERSION";
2494 case PT_HP_CORE_KERNEL
: return "HP_CORE_KERNEL";
2495 case PT_HP_CORE_COMM
: return "HP_CORE_COMM";
2496 case PT_HP_CORE_PROC
: return "HP_CORE_PROC";
2497 case PT_HP_CORE_LOADABLE
: return "HP_CORE_LOADABLE";
2498 case PT_HP_CORE_STACK
: return "HP_CORE_STACK";
2499 case PT_HP_CORE_SHM
: return "HP_CORE_SHM";
2500 case PT_HP_CORE_MMF
: return "HP_CORE_MMF";
2501 case PT_HP_PARALLEL
: return "HP_PARALLEL";
2502 case PT_HP_FASTBIND
: return "HP_FASTBIND";
2503 case PT_HP_OPT_ANNOT
: return "HP_OPT_ANNOT";
2504 case PT_HP_HSL_ANNOT
: return "HP_HSL_ANNOT";
2505 case PT_HP_STACK
: return "HP_STACK";
2506 case PT_HP_CORE_UTSNAME
: return "HP_CORE_UTSNAME";
2507 case PT_PARISC_ARCHEXT
: return "PARISC_ARCHEXT";
2508 case PT_PARISC_UNWIND
: return "PARISC_UNWIND";
2509 case PT_PARISC_WEAKORDER
: return "PARISC_WEAKORDER";
2518 get_ia64_segment_type (unsigned long type
)
2522 case PT_IA_64_ARCHEXT
: return "IA_64_ARCHEXT";
2523 case PT_IA_64_UNWIND
: return "IA_64_UNWIND";
2524 case PT_HP_TLS
: return "HP_TLS";
2525 case PT_IA_64_HP_OPT_ANOT
: return "HP_OPT_ANNOT";
2526 case PT_IA_64_HP_HSL_ANOT
: return "HP_HSL_ANNOT";
2527 case PT_IA_64_HP_STACK
: return "HP_STACK";
2536 get_segment_type (unsigned long p_type
)
2538 static char buff
[32];
2542 case PT_NULL
: return "NULL";
2543 case PT_LOAD
: return "LOAD";
2544 case PT_DYNAMIC
: return "DYNAMIC";
2545 case PT_INTERP
: return "INTERP";
2546 case PT_NOTE
: return "NOTE";
2547 case PT_SHLIB
: return "SHLIB";
2548 case PT_PHDR
: return "PHDR";
2549 case PT_TLS
: return "TLS";
2551 case PT_GNU_EH_FRAME
:
2552 return "GNU_EH_FRAME";
2553 case PT_GNU_STACK
: return "GNU_STACK";
2554 case PT_GNU_RELRO
: return "GNU_RELRO";
2557 if ((p_type
>= PT_LOPROC
) && (p_type
<= PT_HIPROC
))
2561 switch (elf_header
.e_machine
)
2564 result
= get_arm_segment_type (p_type
);
2567 case EM_MIPS_RS3_LE
:
2568 result
= get_mips_segment_type (p_type
);
2571 result
= get_parisc_segment_type (p_type
);
2574 result
= get_ia64_segment_type (p_type
);
2584 sprintf (buff
, "LOPROC+%lx", p_type
- PT_LOPROC
);
2586 else if ((p_type
>= PT_LOOS
) && (p_type
<= PT_HIOS
))
2590 switch (elf_header
.e_machine
)
2593 result
= get_parisc_segment_type (p_type
);
2596 result
= get_ia64_segment_type (p_type
);
2606 sprintf (buff
, "LOOS+%lx", p_type
- PT_LOOS
);
2609 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), p_type
);
2616 get_mips_section_type_name (unsigned int sh_type
)
2620 case SHT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
2621 case SHT_MIPS_MSYM
: return "MIPS_MSYM";
2622 case SHT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
2623 case SHT_MIPS_GPTAB
: return "MIPS_GPTAB";
2624 case SHT_MIPS_UCODE
: return "MIPS_UCODE";
2625 case SHT_MIPS_DEBUG
: return "MIPS_DEBUG";
2626 case SHT_MIPS_REGINFO
: return "MIPS_REGINFO";
2627 case SHT_MIPS_PACKAGE
: return "MIPS_PACKAGE";
2628 case SHT_MIPS_PACKSYM
: return "MIPS_PACKSYM";
2629 case SHT_MIPS_RELD
: return "MIPS_RELD";
2630 case SHT_MIPS_IFACE
: return "MIPS_IFACE";
2631 case SHT_MIPS_CONTENT
: return "MIPS_CONTENT";
2632 case SHT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
2633 case SHT_MIPS_SHDR
: return "MIPS_SHDR";
2634 case SHT_MIPS_FDESC
: return "MIPS_FDESC";
2635 case SHT_MIPS_EXTSYM
: return "MIPS_EXTSYM";
2636 case SHT_MIPS_DENSE
: return "MIPS_DENSE";
2637 case SHT_MIPS_PDESC
: return "MIPS_PDESC";
2638 case SHT_MIPS_LOCSYM
: return "MIPS_LOCSYM";
2639 case SHT_MIPS_AUXSYM
: return "MIPS_AUXSYM";
2640 case SHT_MIPS_OPTSYM
: return "MIPS_OPTSYM";
2641 case SHT_MIPS_LOCSTR
: return "MIPS_LOCSTR";
2642 case SHT_MIPS_LINE
: return "MIPS_LINE";
2643 case SHT_MIPS_RFDESC
: return "MIPS_RFDESC";
2644 case SHT_MIPS_DELTASYM
: return "MIPS_DELTASYM";
2645 case SHT_MIPS_DELTAINST
: return "MIPS_DELTAINST";
2646 case SHT_MIPS_DELTACLASS
: return "MIPS_DELTACLASS";
2647 case SHT_MIPS_DWARF
: return "MIPS_DWARF";
2648 case SHT_MIPS_DELTADECL
: return "MIPS_DELTADECL";
2649 case SHT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
2650 case SHT_MIPS_EVENTS
: return "MIPS_EVENTS";
2651 case SHT_MIPS_TRANSLATE
: return "MIPS_TRANSLATE";
2652 case SHT_MIPS_PIXIE
: return "MIPS_PIXIE";
2653 case SHT_MIPS_XLATE
: return "MIPS_XLATE";
2654 case SHT_MIPS_XLATE_DEBUG
: return "MIPS_XLATE_DEBUG";
2655 case SHT_MIPS_WHIRL
: return "MIPS_WHIRL";
2656 case SHT_MIPS_EH_REGION
: return "MIPS_EH_REGION";
2657 case SHT_MIPS_XLATE_OLD
: return "MIPS_XLATE_OLD";
2658 case SHT_MIPS_PDR_EXCEPTION
: return "MIPS_PDR_EXCEPTION";
2666 get_parisc_section_type_name (unsigned int sh_type
)
2670 case SHT_PARISC_EXT
: return "PARISC_EXT";
2671 case SHT_PARISC_UNWIND
: return "PARISC_UNWIND";
2672 case SHT_PARISC_DOC
: return "PARISC_DOC";
2673 case SHT_PARISC_ANNOT
: return "PARISC_ANNOT";
2674 case SHT_PARISC_SYMEXTN
: return "PARISC_SYMEXTN";
2675 case SHT_PARISC_STUBS
: return "PARISC_STUBS";
2676 case SHT_PARISC_DLKM
: return "PARISC_DLKM";
2684 get_ia64_section_type_name (unsigned int sh_type
)
2686 /* If the top 8 bits are 0x78 the next 8 are the os/abi ID. */
2687 if ((sh_type
& 0xFF000000) == SHT_IA_64_LOPSREG
)
2688 return get_osabi_name ((sh_type
& 0x00FF0000) >> 16);
2692 case SHT_IA_64_EXT
: return "IA_64_EXT";
2693 case SHT_IA_64_UNWIND
: return "IA_64_UNWIND";
2694 case SHT_IA_64_PRIORITY_INIT
: return "IA_64_PRIORITY_INIT";
2695 case SHT_IA_64_VMS_TRACE
: return "VMS_TRACE";
2696 case SHT_IA_64_VMS_TIE_SIGNATURES
: return "VMS_TIE_SIGNATURES";
2697 case SHT_IA_64_VMS_DEBUG
: return "VMS_DEBUG";
2698 case SHT_IA_64_VMS_DEBUG_STR
: return "VMS_DEBUG_STR";
2699 case SHT_IA_64_VMS_LINKAGES
: return "VMS_LINKAGES";
2700 case SHT_IA_64_VMS_SYMBOL_VECTOR
: return "VMS_SYMBOL_VECTOR";
2701 case SHT_IA_64_VMS_FIXUP
: return "VMS_FIXUP";
2709 get_x86_64_section_type_name (unsigned int sh_type
)
2713 case SHT_X86_64_UNWIND
: return "X86_64_UNWIND";
2721 get_arm_section_type_name (unsigned int sh_type
)
2727 case SHT_ARM_PREEMPTMAP
:
2728 return "ARM_PREEMPTMAP";
2729 case SHT_ARM_ATTRIBUTES
:
2730 return "ARM_ATTRIBUTES";
2738 get_section_type_name (unsigned int sh_type
)
2740 static char buff
[32];
2744 case SHT_NULL
: return "NULL";
2745 case SHT_PROGBITS
: return "PROGBITS";
2746 case SHT_SYMTAB
: return "SYMTAB";
2747 case SHT_STRTAB
: return "STRTAB";
2748 case SHT_RELA
: return "RELA";
2749 case SHT_HASH
: return "HASH";
2750 case SHT_DYNAMIC
: return "DYNAMIC";
2751 case SHT_NOTE
: return "NOTE";
2752 case SHT_NOBITS
: return "NOBITS";
2753 case SHT_REL
: return "REL";
2754 case SHT_SHLIB
: return "SHLIB";
2755 case SHT_DYNSYM
: return "DYNSYM";
2756 case SHT_INIT_ARRAY
: return "INIT_ARRAY";
2757 case SHT_FINI_ARRAY
: return "FINI_ARRAY";
2758 case SHT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
2759 case SHT_GNU_HASH
: return "GNU_HASH";
2760 case SHT_GROUP
: return "GROUP";
2761 case SHT_SYMTAB_SHNDX
: return "SYMTAB SECTION INDICIES";
2762 case SHT_GNU_verdef
: return "VERDEF";
2763 case SHT_GNU_verneed
: return "VERNEED";
2764 case SHT_GNU_versym
: return "VERSYM";
2765 case 0x6ffffff0: return "VERSYM";
2766 case 0x6ffffffc: return "VERDEF";
2767 case 0x7ffffffd: return "AUXILIARY";
2768 case 0x7fffffff: return "FILTER";
2769 case SHT_GNU_LIBLIST
: return "GNU_LIBLIST";
2772 if ((sh_type
>= SHT_LOPROC
) && (sh_type
<= SHT_HIPROC
))
2776 switch (elf_header
.e_machine
)
2779 case EM_MIPS_RS3_LE
:
2780 result
= get_mips_section_type_name (sh_type
);
2783 result
= get_parisc_section_type_name (sh_type
);
2786 result
= get_ia64_section_type_name (sh_type
);
2789 result
= get_x86_64_section_type_name (sh_type
);
2792 result
= get_arm_section_type_name (sh_type
);
2802 sprintf (buff
, "LOPROC+%x", sh_type
- SHT_LOPROC
);
2804 else if ((sh_type
>= SHT_LOOS
) && (sh_type
<= SHT_HIOS
))
2808 switch (elf_header
.e_machine
)
2811 result
= get_ia64_section_type_name (sh_type
);
2821 sprintf (buff
, "LOOS+%x", sh_type
- SHT_LOOS
);
2823 else if ((sh_type
>= SHT_LOUSER
) && (sh_type
<= SHT_HIUSER
))
2824 sprintf (buff
, "LOUSER+%x", sh_type
- SHT_LOUSER
);
2826 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), sh_type
);
2832 #define OPTION_DEBUG_DUMP 512
2834 static struct option options
[] =
2836 {"all", no_argument
, 0, 'a'},
2837 {"file-header", no_argument
, 0, 'h'},
2838 {"program-headers", no_argument
, 0, 'l'},
2839 {"headers", no_argument
, 0, 'e'},
2840 {"histogram", no_argument
, 0, 'I'},
2841 {"segments", no_argument
, 0, 'l'},
2842 {"sections", no_argument
, 0, 'S'},
2843 {"section-headers", no_argument
, 0, 'S'},
2844 {"section-groups", no_argument
, 0, 'g'},
2845 {"section-details", no_argument
, 0, 't'},
2846 {"full-section-name",no_argument
, 0, 'N'},
2847 {"symbols", no_argument
, 0, 's'},
2848 {"syms", no_argument
, 0, 's'},
2849 {"relocs", no_argument
, 0, 'r'},
2850 {"notes", no_argument
, 0, 'n'},
2851 {"dynamic", no_argument
, 0, 'd'},
2852 {"arch-specific", no_argument
, 0, 'A'},
2853 {"version-info", no_argument
, 0, 'V'},
2854 {"use-dynamic", no_argument
, 0, 'D'},
2855 {"unwind", no_argument
, 0, 'u'},
2856 {"archive-index", no_argument
, 0, 'c'},
2857 {"hex-dump", required_argument
, 0, 'x'},
2858 {"debug-dump", optional_argument
, 0, OPTION_DEBUG_DUMP
},
2859 {"string-dump", required_argument
, 0, 'p'},
2860 #ifdef SUPPORT_DISASSEMBLY
2861 {"instruction-dump", required_argument
, 0, 'i'},
2864 {"version", no_argument
, 0, 'v'},
2865 {"wide", no_argument
, 0, 'W'},
2866 {"help", no_argument
, 0, 'H'},
2867 {0, no_argument
, 0, 0}
2871 usage (FILE *stream
)
2873 fprintf (stream
, _("Usage: readelf <option(s)> elf-file(s)\n"));
2874 fprintf (stream
, _(" Display information about the contents of ELF format files\n"));
2875 fprintf (stream
, _(" Options are:\n\
2876 -a --all Equivalent to: -h -l -S -s -r -d -V -A -I\n\
2877 -h --file-header Display the ELF file header\n\
2878 -l --program-headers Display the program headers\n\
2879 --segments An alias for --program-headers\n\
2880 -S --section-headers Display the sections' header\n\
2881 --sections An alias for --section-headers\n\
2882 -g --section-groups Display the section groups\n\
2883 -t --section-details Display the section details\n\
2884 -e --headers Equivalent to: -h -l -S\n\
2885 -s --syms Display the symbol table\n\
2886 --symbols An alias for --syms\n\
2887 -n --notes Display the core notes (if present)\n\
2888 -r --relocs Display the relocations (if present)\n\
2889 -u --unwind Display the unwind info (if present)\n\
2890 -d --dynamic Display the dynamic section (if present)\n\
2891 -V --version-info Display the version sections (if present)\n\
2892 -A --arch-specific Display architecture specific information (if any).\n\
2893 -c --archive-index Display the symbol/file index in an archive\n\
2894 -D --use-dynamic Use the dynamic section info when displaying symbols\n\
2895 -x --hex-dump=<number|name>\n\
2896 Dump the contents of section <number|name> as bytes\n\
2897 -p --string-dump=<number|name>\n\
2898 Dump the contents of section <number|name> as strings\n\
2899 -w[lLiaprmfFsoR] or\n\
2900 --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges]\n\
2901 Display the contents of DWARF2 debug sections\n"));
2902 #ifdef SUPPORT_DISASSEMBLY
2903 fprintf (stream
, _("\
2904 -i --instruction-dump=<number|name>\n\
2905 Disassemble the contents of section <number|name>\n"));
2907 fprintf (stream
, _("\
2908 -I --histogram Display histogram of bucket list lengths\n\
2909 -W --wide Allow output width to exceed 80 characters\n\
2910 @<file> Read options from <file>\n\
2911 -H --help Display this information\n\
2912 -v --version Display the version number of readelf\n"));
2914 if (REPORT_BUGS_TO
[0] && stream
== stdout
)
2915 fprintf (stdout
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
2917 exit (stream
== stdout
? 0 : 1);
2920 /* Record the fact that the user wants the contents of section number
2921 SECTION to be displayed using the method(s) encoded as flags bits
2922 in TYPE. Note, TYPE can be zero if we are creating the array for
2926 request_dump_bynumber (unsigned int section
, dump_type type
)
2928 if (section
>= num_dump_sects
)
2930 dump_type
*new_dump_sects
;
2932 new_dump_sects
= calloc (section
+ 1, sizeof (* dump_sects
));
2934 if (new_dump_sects
== NULL
)
2935 error (_("Out of memory allocating dump request table.\n"));
2938 /* Copy current flag settings. */
2939 memcpy (new_dump_sects
, dump_sects
, num_dump_sects
* sizeof (* dump_sects
));
2943 dump_sects
= new_dump_sects
;
2944 num_dump_sects
= section
+ 1;
2949 dump_sects
[section
] |= type
;
2954 /* Request a dump by section name. */
2957 request_dump_byname (const char *section
, dump_type type
)
2959 struct dump_list_entry
*new_request
;
2961 new_request
= malloc (sizeof (struct dump_list_entry
));
2963 error (_("Out of memory allocating dump request table.\n"));
2965 new_request
->name
= strdup (section
);
2966 if (!new_request
->name
)
2967 error (_("Out of memory allocating dump request table.\n"));
2969 new_request
->type
= type
;
2971 new_request
->next
= dump_sects_byname
;
2972 dump_sects_byname
= new_request
;
2976 parse_args (int argc
, char **argv
)
2983 while ((c
= getopt_long
2984 (argc
, argv
, "ADHINSVWacdeghi:lnp:rstuvw::x:", options
, NULL
)) != EOF
)
3005 do_section_groups
++;
3013 do_section_groups
++;
3018 do_section_details
++;
3063 section
= strtoul (optarg
, & cp
, 0);
3064 if (! *cp
&& section
>= 0)
3065 request_dump_bynumber (section
, HEX_DUMP
);
3067 request_dump_byname (optarg
, HEX_DUMP
);
3071 section
= strtoul (optarg
, & cp
, 0);
3072 if (! *cp
&& section
>= 0)
3073 request_dump_bynumber (section
, STRING_DUMP
);
3075 request_dump_byname (optarg
, STRING_DUMP
);
3083 unsigned int index
= 0;
3087 while (optarg
[index
])
3088 switch (optarg
[index
++])
3095 do_debug_abbrevs
= 1;
3103 do_debug_lines_decoded
= 1;
3107 do_debug_pubnames
= 1;
3111 do_debug_aranges
= 1;
3115 do_debug_ranges
= 1;
3119 do_debug_frames_interp
= 1;
3121 do_debug_frames
= 1;
3125 do_debug_macinfo
= 1;
3137 warn (_("Unrecognized debug option '%s'\n"), optarg
);
3142 case OPTION_DEBUG_DUMP
:
3150 const char * option
;
3153 debug_dump_long_opts
;
3155 debug_dump_long_opts opts_table
[] =
3157 /* Please keep this table alpha- sorted. */
3158 { "Ranges", & do_debug_ranges
},
3159 { "abbrev", & do_debug_abbrevs
},
3160 { "aranges", & do_debug_aranges
},
3161 { "frames", & do_debug_frames
},
3162 { "frames-interp", & do_debug_frames_interp
},
3163 { "info", & do_debug_info
},
3164 { "line", & do_debug_lines
}, /* For backwards compatibility. */
3165 { "rawline", & do_debug_lines
},
3166 { "decodedline", & do_debug_lines_decoded
},
3167 { "loc", & do_debug_loc
},
3168 { "macro", & do_debug_macinfo
},
3169 { "pubnames", & do_debug_pubnames
},
3170 /* This entry is for compatability
3171 with earlier versions of readelf. */
3172 { "ranges", & do_debug_aranges
},
3173 { "str", & do_debug_str
},
3184 debug_dump_long_opts
* entry
;
3186 for (entry
= opts_table
; entry
->option
; entry
++)
3188 size_t len
= strlen (entry
->option
);
3190 if (strneq (p
, entry
->option
, len
)
3191 && (p
[len
] == ',' || p
[len
] == '\0'))
3193 * entry
->variable
= 1;
3195 /* The --debug-dump=frames-interp option also
3196 enables the --debug-dump=frames option. */
3197 if (do_debug_frames_interp
)
3198 do_debug_frames
= 1;
3205 if (entry
->option
== NULL
)
3207 warn (_("Unrecognized debug option '%s'\n"), p
);
3208 p
= strchr (p
, ',');
3218 #ifdef SUPPORT_DISASSEMBLY
3221 section
= strtoul (optarg
, & cp
, 0);
3222 if (! *cp
&& section
>= 0)
3223 request_dump_bynumber (section
, DISASS_DUMP
);
3225 request_dump_byname (optarg
, DISASS_DUMP
);
3228 print_version (program_name
);
3237 /* xgettext:c-format */
3238 error (_("Invalid option '-%c'\n"), c
);
3245 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
3246 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
3247 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
3248 && !do_section_groups
&& !do_archive_index
)
3252 warn (_("Nothing to do.\n"));
3258 get_elf_class (unsigned int elf_class
)
3260 static char buff
[32];
3264 case ELFCLASSNONE
: return _("none");
3265 case ELFCLASS32
: return "ELF32";
3266 case ELFCLASS64
: return "ELF64";
3268 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), elf_class
);
3274 get_data_encoding (unsigned int encoding
)
3276 static char buff
[32];
3280 case ELFDATANONE
: return _("none");
3281 case ELFDATA2LSB
: return _("2's complement, little endian");
3282 case ELFDATA2MSB
: return _("2's complement, big endian");
3284 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), encoding
);
3289 /* Decode the data held in 'elf_header'. */
3292 process_file_header (void)
3294 if ( elf_header
.e_ident
[EI_MAG0
] != ELFMAG0
3295 || elf_header
.e_ident
[EI_MAG1
] != ELFMAG1
3296 || elf_header
.e_ident
[EI_MAG2
] != ELFMAG2
3297 || elf_header
.e_ident
[EI_MAG3
] != ELFMAG3
)
3300 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
3304 init_dwarf_regnames (elf_header
.e_machine
);
3310 printf (_("ELF Header:\n"));
3311 printf (_(" Magic: "));
3312 for (i
= 0; i
< EI_NIDENT
; i
++)
3313 printf ("%2.2x ", elf_header
.e_ident
[i
]);
3315 printf (_(" Class: %s\n"),
3316 get_elf_class (elf_header
.e_ident
[EI_CLASS
]));
3317 printf (_(" Data: %s\n"),
3318 get_data_encoding (elf_header
.e_ident
[EI_DATA
]));
3319 printf (_(" Version: %d %s\n"),
3320 elf_header
.e_ident
[EI_VERSION
],
3321 (elf_header
.e_ident
[EI_VERSION
] == EV_CURRENT
3323 : (elf_header
.e_ident
[EI_VERSION
] != EV_NONE
3326 printf (_(" OS/ABI: %s\n"),
3327 get_osabi_name (elf_header
.e_ident
[EI_OSABI
]));
3328 printf (_(" ABI Version: %d\n"),
3329 elf_header
.e_ident
[EI_ABIVERSION
]);
3330 printf (_(" Type: %s\n"),
3331 get_file_type (elf_header
.e_type
));
3332 printf (_(" Machine: %s\n"),
3333 get_machine_name (elf_header
.e_machine
));
3334 printf (_(" Version: 0x%lx\n"),
3335 (unsigned long) elf_header
.e_version
);
3337 printf (_(" Entry point address: "));
3338 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3339 printf (_("\n Start of program headers: "));
3340 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3341 printf (_(" (bytes into file)\n Start of section headers: "));
3342 print_vma ((bfd_vma
) elf_header
.e_shoff
, DEC
);
3343 printf (_(" (bytes into file)\n"));
3345 printf (_(" Flags: 0x%lx%s\n"),
3346 (unsigned long) elf_header
.e_flags
,
3347 get_machine_flags (elf_header
.e_flags
, elf_header
.e_machine
));
3348 printf (_(" Size of this header: %ld (bytes)\n"),
3349 (long) elf_header
.e_ehsize
);
3350 printf (_(" Size of program headers: %ld (bytes)\n"),
3351 (long) elf_header
.e_phentsize
);
3352 printf (_(" Number of program headers: %ld\n"),
3353 (long) elf_header
.e_phnum
);
3354 printf (_(" Size of section headers: %ld (bytes)\n"),
3355 (long) elf_header
.e_shentsize
);
3356 printf (_(" Number of section headers: %ld"),
3357 (long) elf_header
.e_shnum
);
3358 if (section_headers
!= NULL
&& elf_header
.e_shnum
== SHN_UNDEF
)
3359 printf (" (%ld)", (long) section_headers
[0].sh_size
);
3360 putc ('\n', stdout
);
3361 printf (_(" Section header string table index: %ld"),
3362 (long) elf_header
.e_shstrndx
);
3363 if (section_headers
!= NULL
3364 && elf_header
.e_shstrndx
== (SHN_XINDEX
& 0xffff))
3365 printf (" (%u)", section_headers
[0].sh_link
);
3366 else if (elf_header
.e_shstrndx
>= elf_header
.e_shnum
)
3367 printf (" <corrupt: out of range>");
3368 putc ('\n', stdout
);
3371 if (section_headers
!= NULL
)
3373 if (elf_header
.e_shnum
== SHN_UNDEF
)
3374 elf_header
.e_shnum
= section_headers
[0].sh_size
;
3375 if (elf_header
.e_shstrndx
== (SHN_XINDEX
& 0xffff))
3376 elf_header
.e_shstrndx
= section_headers
[0].sh_link
;
3377 else if (elf_header
.e_shstrndx
>= elf_header
.e_shnum
)
3378 elf_header
.e_shstrndx
= SHN_UNDEF
;
3379 free (section_headers
);
3380 section_headers
= NULL
;
3388 get_32bit_program_headers (FILE *file
, Elf_Internal_Phdr
*program_headers
)
3390 Elf32_External_Phdr
*phdrs
;
3391 Elf32_External_Phdr
*external
;
3392 Elf_Internal_Phdr
*internal
;
3395 phdrs
= get_data (NULL
, file
, elf_header
.e_phoff
,
3396 elf_header
.e_phentsize
, elf_header
.e_phnum
,
3397 _("program headers"));
3401 for (i
= 0, internal
= program_headers
, external
= phdrs
;
3402 i
< elf_header
.e_phnum
;
3403 i
++, internal
++, external
++)
3405 internal
->p_type
= BYTE_GET (external
->p_type
);
3406 internal
->p_offset
= BYTE_GET (external
->p_offset
);
3407 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
3408 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
3409 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
3410 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
3411 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3412 internal
->p_align
= BYTE_GET (external
->p_align
);
3421 get_64bit_program_headers (FILE *file
, Elf_Internal_Phdr
*program_headers
)
3423 Elf64_External_Phdr
*phdrs
;
3424 Elf64_External_Phdr
*external
;
3425 Elf_Internal_Phdr
*internal
;
3428 phdrs
= get_data (NULL
, file
, elf_header
.e_phoff
,
3429 elf_header
.e_phentsize
, elf_header
.e_phnum
,
3430 _("program headers"));
3434 for (i
= 0, internal
= program_headers
, external
= phdrs
;
3435 i
< elf_header
.e_phnum
;
3436 i
++, internal
++, external
++)
3438 internal
->p_type
= BYTE_GET (external
->p_type
);
3439 internal
->p_flags
= BYTE_GET (external
->p_flags
);
3440 internal
->p_offset
= BYTE_GET (external
->p_offset
);
3441 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
3442 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
3443 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
3444 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
3445 internal
->p_align
= BYTE_GET (external
->p_align
);
3453 /* Returns 1 if the program headers were read into `program_headers'. */
3456 get_program_headers (FILE *file
)
3458 Elf_Internal_Phdr
*phdrs
;
3460 /* Check cache of prior read. */
3461 if (program_headers
!= NULL
)
3464 phdrs
= cmalloc (elf_header
.e_phnum
, sizeof (Elf_Internal_Phdr
));
3468 error (_("Out of memory\n"));
3473 ? get_32bit_program_headers (file
, phdrs
)
3474 : get_64bit_program_headers (file
, phdrs
))
3476 program_headers
= phdrs
;
3484 /* Returns 1 if the program headers were loaded. */
3487 process_program_headers (FILE *file
)
3489 Elf_Internal_Phdr
*segment
;
3492 if (elf_header
.e_phnum
== 0)
3495 printf (_("\nThere are no program headers in this file.\n"));
3499 if (do_segments
&& !do_header
)
3501 printf (_("\nElf file type is %s\n"), get_file_type (elf_header
.e_type
));
3502 printf (_("Entry point "));
3503 print_vma ((bfd_vma
) elf_header
.e_entry
, PREFIX_HEX
);
3504 printf (_("\nThere are %d program headers, starting at offset "),
3505 elf_header
.e_phnum
);
3506 print_vma ((bfd_vma
) elf_header
.e_phoff
, DEC
);
3510 if (! get_program_headers (file
))
3515 if (elf_header
.e_phnum
> 1)
3516 printf (_("\nProgram Headers:\n"));
3518 printf (_("\nProgram Headers:\n"));
3522 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3525 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
3529 (_(" Type Offset VirtAddr PhysAddr\n"));
3531 (_(" FileSiz MemSiz Flags Align\n"));
3538 for (i
= 0, segment
= program_headers
;
3539 i
< elf_header
.e_phnum
;
3544 printf (" %-14.14s ", get_segment_type (segment
->p_type
));
3548 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3549 printf ("0x%8.8lx ", (unsigned long) segment
->p_vaddr
);
3550 printf ("0x%8.8lx ", (unsigned long) segment
->p_paddr
);
3551 printf ("0x%5.5lx ", (unsigned long) segment
->p_filesz
);
3552 printf ("0x%5.5lx ", (unsigned long) segment
->p_memsz
);
3554 (segment
->p_flags
& PF_R
? 'R' : ' '),
3555 (segment
->p_flags
& PF_W
? 'W' : ' '),
3556 (segment
->p_flags
& PF_X
? 'E' : ' '));
3557 printf ("%#lx", (unsigned long) segment
->p_align
);
3561 if ((unsigned long) segment
->p_offset
== segment
->p_offset
)
3562 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
3565 print_vma (segment
->p_offset
, FULL_HEX
);
3569 print_vma (segment
->p_vaddr
, FULL_HEX
);
3571 print_vma (segment
->p_paddr
, FULL_HEX
);
3574 if ((unsigned long) segment
->p_filesz
== segment
->p_filesz
)
3575 printf ("0x%6.6lx ", (unsigned long) segment
->p_filesz
);
3578 print_vma (segment
->p_filesz
, FULL_HEX
);
3582 if ((unsigned long) segment
->p_memsz
== segment
->p_memsz
)
3583 printf ("0x%6.6lx", (unsigned long) segment
->p_memsz
);
3586 print_vma (segment
->p_offset
, FULL_HEX
);
3590 (segment
->p_flags
& PF_R
? 'R' : ' '),
3591 (segment
->p_flags
& PF_W
? 'W' : ' '),
3592 (segment
->p_flags
& PF_X
? 'E' : ' '));
3594 if ((unsigned long) segment
->p_align
== segment
->p_align
)
3595 printf ("%#lx", (unsigned long) segment
->p_align
);
3598 print_vma (segment
->p_align
, PREFIX_HEX
);
3603 print_vma (segment
->p_offset
, FULL_HEX
);
3605 print_vma (segment
->p_vaddr
, FULL_HEX
);
3607 print_vma (segment
->p_paddr
, FULL_HEX
);
3609 print_vma (segment
->p_filesz
, FULL_HEX
);
3611 print_vma (segment
->p_memsz
, FULL_HEX
);
3613 (segment
->p_flags
& PF_R
? 'R' : ' '),
3614 (segment
->p_flags
& PF_W
? 'W' : ' '),
3615 (segment
->p_flags
& PF_X
? 'E' : ' '));
3616 print_vma (segment
->p_align
, HEX
);
3620 switch (segment
->p_type
)
3624 error (_("more than one dynamic segment\n"));
3626 /* By default, assume that the .dynamic section is the first
3627 section in the DYNAMIC segment. */
3628 dynamic_addr
= segment
->p_offset
;
3629 dynamic_size
= segment
->p_filesz
;
3631 /* Try to locate the .dynamic section. If there is
3632 a section header table, we can easily locate it. */
3633 if (section_headers
!= NULL
)
3635 Elf_Internal_Shdr
*sec
;
3637 sec
= find_section (".dynamic");
3638 if (sec
== NULL
|| sec
->sh_size
== 0)
3640 error (_("no .dynamic section in the dynamic segment\n"));
3644 if (sec
->sh_type
== SHT_NOBITS
)
3650 dynamic_addr
= sec
->sh_offset
;
3651 dynamic_size
= sec
->sh_size
;
3653 if (dynamic_addr
< segment
->p_offset
3654 || dynamic_addr
> segment
->p_offset
+ segment
->p_filesz
)
3655 warn (_("the .dynamic section is not contained"
3656 " within the dynamic segment\n"));
3657 else if (dynamic_addr
> segment
->p_offset
)
3658 warn (_("the .dynamic section is not the first section"
3659 " in the dynamic segment.\n"));
3664 if (fseek (file
, archive_file_offset
+ (long) segment
->p_offset
,
3666 error (_("Unable to find program interpreter name\n"));
3670 int ret
= snprintf (fmt
, sizeof (fmt
), "%%%ds", PATH_MAX
);
3672 if (ret
>= (int) sizeof (fmt
) || ret
< 0)
3673 error (_("Internal error: failed to create format string to display program interpreter\n"));
3675 program_interpreter
[0] = 0;
3676 if (fscanf (file
, fmt
, program_interpreter
) <= 0)
3677 error (_("Unable to read program interpreter name\n"));
3680 printf (_("\n [Requesting program interpreter: %s]"),
3681 program_interpreter
);
3687 putc ('\n', stdout
);
3690 if (do_segments
&& section_headers
!= NULL
&& string_table
!= NULL
)
3692 printf (_("\n Section to Segment mapping:\n"));
3693 printf (_(" Segment Sections...\n"));
3695 for (i
= 0; i
< elf_header
.e_phnum
; i
++)
3698 Elf_Internal_Shdr
*section
;
3700 segment
= program_headers
+ i
;
3701 section
= section_headers
+ 1;
3703 printf (" %2.2d ", i
);
3705 for (j
= 1; j
< elf_header
.e_shnum
; j
++, section
++)
3707 if (ELF_IS_SECTION_IN_SEGMENT_MEMORY(section
, segment
))
3708 printf ("%s ", SECTION_NAME (section
));
3719 /* Find the file offset corresponding to VMA by using the program headers. */
3722 offset_from_vma (FILE *file
, bfd_vma vma
, bfd_size_type size
)
3724 Elf_Internal_Phdr
*seg
;
3726 if (! get_program_headers (file
))
3728 warn (_("Cannot interpret virtual addresses without program headers.\n"));
3732 for (seg
= program_headers
;
3733 seg
< program_headers
+ elf_header
.e_phnum
;
3736 if (seg
->p_type
!= PT_LOAD
)
3739 if (vma
>= (seg
->p_vaddr
& -seg
->p_align
)
3740 && vma
+ size
<= seg
->p_vaddr
+ seg
->p_filesz
)
3741 return vma
- seg
->p_vaddr
+ seg
->p_offset
;
3744 warn (_("Virtual address 0x%lx not located in any PT_LOAD segment.\n"),
3745 (unsigned long) vma
);
3751 get_32bit_section_headers (FILE *file
, unsigned int num
)
3753 Elf32_External_Shdr
*shdrs
;
3754 Elf_Internal_Shdr
*internal
;
3757 shdrs
= get_data (NULL
, file
, elf_header
.e_shoff
,
3758 elf_header
.e_shentsize
, num
, _("section headers"));
3762 section_headers
= cmalloc (num
, sizeof (Elf_Internal_Shdr
));
3764 if (section_headers
== NULL
)
3766 error (_("Out of memory\n"));
3770 for (i
= 0, internal
= section_headers
;
3774 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3775 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3776 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
3777 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
3778 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3779 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
3780 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3781 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3782 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3783 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
3792 get_64bit_section_headers (FILE *file
, unsigned int num
)
3794 Elf64_External_Shdr
*shdrs
;
3795 Elf_Internal_Shdr
*internal
;
3798 shdrs
= get_data (NULL
, file
, elf_header
.e_shoff
,
3799 elf_header
.e_shentsize
, num
, _("section headers"));
3803 section_headers
= cmalloc (num
, sizeof (Elf_Internal_Shdr
));
3805 if (section_headers
== NULL
)
3807 error (_("Out of memory\n"));
3811 for (i
= 0, internal
= section_headers
;
3815 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
3816 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
3817 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
3818 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
3819 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
3820 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
3821 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
3822 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
3823 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
3824 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
3832 static Elf_Internal_Sym
*
3833 get_32bit_elf_symbols (FILE *file
, Elf_Internal_Shdr
*section
)
3835 unsigned long number
;
3836 Elf32_External_Sym
*esyms
;
3837 Elf_External_Sym_Shndx
*shndx
;
3838 Elf_Internal_Sym
*isyms
;
3839 Elf_Internal_Sym
*psym
;
3842 esyms
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
3848 if (symtab_shndx_hdr
!= NULL
3849 && (symtab_shndx_hdr
->sh_link
3850 == (unsigned long) (section
- section_headers
)))
3852 shndx
= get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3853 1, symtab_shndx_hdr
->sh_size
, _("symtab shndx"));
3861 number
= section
->sh_size
/ section
->sh_entsize
;
3862 isyms
= cmalloc (number
, sizeof (Elf_Internal_Sym
));
3866 error (_("Out of memory\n"));
3873 for (j
= 0, psym
= isyms
;
3877 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3878 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3879 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3880 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3881 if (psym
->st_shndx
== (SHN_XINDEX
& 0xffff) && shndx
!= NULL
)
3883 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3884 else if (psym
->st_shndx
>= (SHN_LORESERVE
& 0xffff))
3885 psym
->st_shndx
+= SHN_LORESERVE
- (SHN_LORESERVE
& 0xffff);
3886 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3887 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3897 static Elf_Internal_Sym
*
3898 get_64bit_elf_symbols (FILE *file
, Elf_Internal_Shdr
*section
)
3900 unsigned long number
;
3901 Elf64_External_Sym
*esyms
;
3902 Elf_External_Sym_Shndx
*shndx
;
3903 Elf_Internal_Sym
*isyms
;
3904 Elf_Internal_Sym
*psym
;
3907 esyms
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
3913 if (symtab_shndx_hdr
!= NULL
3914 && (symtab_shndx_hdr
->sh_link
3915 == (unsigned long) (section
- section_headers
)))
3917 shndx
= get_data (NULL
, file
, symtab_shndx_hdr
->sh_offset
,
3918 1, symtab_shndx_hdr
->sh_size
, _("symtab shndx"));
3926 number
= section
->sh_size
/ section
->sh_entsize
;
3927 isyms
= cmalloc (number
, sizeof (Elf_Internal_Sym
));
3931 error (_("Out of memory\n"));
3938 for (j
= 0, psym
= isyms
;
3942 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
3943 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
3944 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
3945 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
3946 if (psym
->st_shndx
== (SHN_XINDEX
& 0xffff) && shndx
!= NULL
)
3948 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
3949 else if (psym
->st_shndx
>= (SHN_LORESERVE
& 0xffff))
3950 psym
->st_shndx
+= SHN_LORESERVE
- (SHN_LORESERVE
& 0xffff);
3951 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
3952 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
3963 get_elf_section_flags (bfd_vma sh_flags
)
3965 static char buff
[1024];
3967 int field_size
= is_32bit_elf
? 8 : 16;
3968 int index
, size
= sizeof (buff
) - (field_size
+ 4 + 1);
3969 bfd_vma os_flags
= 0;
3970 bfd_vma proc_flags
= 0;
3971 bfd_vma unknown_flags
= 0;
3985 { "LINK ORDER", 10 },
3986 { "OS NONCONF", 10 },
3989 /* IA-64 specific. */
3992 /* IA-64 OpenVMS specific. */
3993 { "VMS_GLOBAL", 10 },
3994 { "VMS_OVERLAID", 12 },
3995 { "VMS_SHARED", 10 },
3996 { "VMS_VECTOR", 10 },
3997 { "VMS_ALLOC_64BIT", 15 },
3998 { "VMS_PROTECTED", 13}
4001 if (do_section_details
)
4003 sprintf (buff
, "[%*.*lx]: ",
4004 field_size
, field_size
, (unsigned long) sh_flags
);
4005 p
+= field_size
+ 4;
4012 flag
= sh_flags
& - sh_flags
;
4015 if (do_section_details
)
4019 case SHF_WRITE
: index
= 0; break;
4020 case SHF_ALLOC
: index
= 1; break;
4021 case SHF_EXECINSTR
: index
= 2; break;
4022 case SHF_MERGE
: index
= 3; break;
4023 case SHF_STRINGS
: index
= 4; break;
4024 case SHF_INFO_LINK
: index
= 5; break;
4025 case SHF_LINK_ORDER
: index
= 6; break;
4026 case SHF_OS_NONCONFORMING
: index
= 7; break;
4027 case SHF_GROUP
: index
= 8; break;
4028 case SHF_TLS
: index
= 9; break;
4032 if (elf_header
.e_machine
== EM_IA_64
)
4034 if (flag
== SHF_IA_64_SHORT
)
4036 else if (flag
== SHF_IA_64_NORECOV
)
4039 else if (elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_OPENVMS
)
4042 case SHF_IA_64_VMS_GLOBAL
: index
= 12; break;
4043 case SHF_IA_64_VMS_OVERLAID
: index
= 13; break;
4044 case SHF_IA_64_VMS_SHARED
: index
= 14; break;
4045 case SHF_IA_64_VMS_VECTOR
: index
= 15; break;
4046 case SHF_IA_64_VMS_ALLOC_64BIT
: index
= 16; break;
4047 case SHF_IA_64_VMS_PROTECTED
: index
= 17; break;
4057 if (p
!= buff
+ field_size
+ 4)
4059 if (size
< (10 + 2))
4066 size
-= flags
[index
].len
;
4067 p
= stpcpy (p
, flags
[index
].str
);
4069 else if (flag
& SHF_MASKOS
)
4071 else if (flag
& SHF_MASKPROC
)
4074 unknown_flags
|= flag
;
4080 case SHF_WRITE
: *p
= 'W'; break;
4081 case SHF_ALLOC
: *p
= 'A'; break;
4082 case SHF_EXECINSTR
: *p
= 'X'; break;
4083 case SHF_MERGE
: *p
= 'M'; break;
4084 case SHF_STRINGS
: *p
= 'S'; break;
4085 case SHF_INFO_LINK
: *p
= 'I'; break;
4086 case SHF_LINK_ORDER
: *p
= 'L'; break;
4087 case SHF_OS_NONCONFORMING
: *p
= 'O'; break;
4088 case SHF_GROUP
: *p
= 'G'; break;
4089 case SHF_TLS
: *p
= 'T'; break;
4092 if (elf_header
.e_machine
== EM_X86_64
4093 && flag
== SHF_X86_64_LARGE
)
4095 else if (flag
& SHF_MASKOS
)
4098 sh_flags
&= ~ SHF_MASKOS
;
4100 else if (flag
& SHF_MASKPROC
)
4103 sh_flags
&= ~ SHF_MASKPROC
;
4113 if (do_section_details
)
4117 size
-= 5 + field_size
;
4118 if (p
!= buff
+ field_size
+ 4)
4126 sprintf (p
, "OS (%*.*lx)", field_size
, field_size
,
4127 (unsigned long) os_flags
);
4128 p
+= 5 + field_size
;
4132 size
-= 7 + field_size
;
4133 if (p
!= buff
+ field_size
+ 4)
4141 sprintf (p
, "PROC (%*.*lx)", field_size
, field_size
,
4142 (unsigned long) proc_flags
);
4143 p
+= 7 + field_size
;
4147 size
-= 10 + field_size
;
4148 if (p
!= buff
+ field_size
+ 4)
4156 sprintf (p
, "UNKNOWN (%*.*lx)", field_size
, field_size
,
4157 (unsigned long) unknown_flags
);
4158 p
+= 10 + field_size
;
4167 process_section_headers (FILE *file
)
4169 Elf_Internal_Shdr
*section
;
4172 section_headers
= NULL
;
4174 if (elf_header
.e_shnum
== 0)
4177 printf (_("\nThere are no sections in this file.\n"));
4182 if (do_sections
&& !do_header
)
4183 printf (_("There are %d section headers, starting at offset 0x%lx:\n"),
4184 elf_header
.e_shnum
, (unsigned long) elf_header
.e_shoff
);
4188 if (! get_32bit_section_headers (file
, elf_header
.e_shnum
))
4191 else if (! get_64bit_section_headers (file
, elf_header
.e_shnum
))
4194 /* Read in the string table, so that we have names to display. */
4195 if (elf_header
.e_shstrndx
!= SHN_UNDEF
4196 && elf_header
.e_shstrndx
< elf_header
.e_shnum
)
4198 section
= section_headers
+ elf_header
.e_shstrndx
;
4200 if (section
->sh_size
!= 0)
4202 string_table
= get_data (NULL
, file
, section
->sh_offset
,
4203 1, section
->sh_size
, _("string table"));
4205 string_table_length
= string_table
!= NULL
? section
->sh_size
: 0;
4209 /* Scan the sections for the dynamic symbol table
4210 and dynamic string table and debug sections. */
4211 dynamic_symbols
= NULL
;
4212 dynamic_strings
= NULL
;
4213 dynamic_syminfo
= NULL
;
4214 symtab_shndx_hdr
= NULL
;
4216 eh_addr_size
= is_32bit_elf
? 4 : 8;
4217 switch (elf_header
.e_machine
)
4220 case EM_MIPS_RS3_LE
:
4221 /* The 64-bit MIPS EABI uses a combination of 32-bit ELF and 64-bit
4222 FDE addresses. However, the ABI also has a semi-official ILP32
4223 variant for which the normal FDE address size rules apply.
4225 GCC 4.0 marks EABI64 objects with a dummy .gcc_compiled_longXX
4226 section, where XX is the size of longs in bits. Unfortunately,
4227 earlier compilers provided no way of distinguishing ILP32 objects
4228 from LP64 objects, so if there's any doubt, we should assume that
4229 the official LP64 form is being used. */
4230 if ((elf_header
.e_flags
& EF_MIPS_ABI
) == E_MIPS_ABI_EABI64
4231 && find_section (".gcc_compiled_long32") == NULL
)
4237 switch (elf_header
.e_flags
& EF_H8_MACH
)
4239 case E_H8_MACH_H8300
:
4240 case E_H8_MACH_H8300HN
:
4241 case E_H8_MACH_H8300SN
:
4242 case E_H8_MACH_H8300SXN
:
4245 case E_H8_MACH_H8300H
:
4246 case E_H8_MACH_H8300S
:
4247 case E_H8_MACH_H8300SX
:
4255 switch (elf_header
.e_flags
& EF_M32C_CPU_MASK
)
4257 case EF_M32C_CPU_M16C
:
4264 #define CHECK_ENTSIZE_VALUES(section, i, size32, size64) \
4267 size_t expected_entsize \
4268 = is_32bit_elf ? size32 : size64; \
4269 if (section->sh_entsize != expected_entsize) \
4270 error (_("Section %d has invalid sh_entsize %lx (expected %lx)\n"), \
4271 i, (unsigned long int) section->sh_entsize, \
4272 (unsigned long int) expected_entsize); \
4273 section->sh_entsize = expected_entsize; \
4276 #define CHECK_ENTSIZE(section, i, type) \
4277 CHECK_ENTSIZE_VALUES (section, i, sizeof (Elf32_External_##type), \
4278 sizeof (Elf64_External_##type))
4280 for (i
= 0, section
= section_headers
;
4281 i
< elf_header
.e_shnum
;
4284 char *name
= SECTION_NAME (section
);
4286 if (section
->sh_type
== SHT_DYNSYM
)
4288 if (dynamic_symbols
!= NULL
)
4290 error (_("File contains multiple dynamic symbol tables\n"));
4294 CHECK_ENTSIZE (section
, i
, Sym
);
4295 num_dynamic_syms
= section
->sh_size
/ section
->sh_entsize
;
4296 dynamic_symbols
= GET_ELF_SYMBOLS (file
, section
);
4298 else if (section
->sh_type
== SHT_STRTAB
4299 && streq (name
, ".dynstr"))
4301 if (dynamic_strings
!= NULL
)
4303 error (_("File contains multiple dynamic string tables\n"));
4307 dynamic_strings
= get_data (NULL
, file
, section
->sh_offset
,
4308 1, section
->sh_size
, _("dynamic strings"));
4309 dynamic_strings_length
= section
->sh_size
;
4311 else if (section
->sh_type
== SHT_SYMTAB_SHNDX
)
4313 if (symtab_shndx_hdr
!= NULL
)
4315 error (_("File contains multiple symtab shndx tables\n"));
4318 symtab_shndx_hdr
= section
;
4320 else if (section
->sh_type
== SHT_SYMTAB
)
4321 CHECK_ENTSIZE (section
, i
, Sym
);
4322 else if (section
->sh_type
== SHT_GROUP
)
4323 CHECK_ENTSIZE_VALUES (section
, i
, GRP_ENTRY_SIZE
, GRP_ENTRY_SIZE
);
4324 else if (section
->sh_type
== SHT_REL
)
4325 CHECK_ENTSIZE (section
, i
, Rel
);
4326 else if (section
->sh_type
== SHT_RELA
)
4327 CHECK_ENTSIZE (section
, i
, Rela
);
4328 else if ((do_debugging
|| do_debug_info
|| do_debug_abbrevs
4329 || do_debug_lines
|| do_debug_lines_decoded
|| do_debug_pubnames
4330 || do_debug_aranges
|| do_debug_frames
|| do_debug_macinfo
4331 || do_debug_str
|| do_debug_loc
|| do_debug_ranges
)
4332 && (const_strneq (name
, ".debug_")
4333 || const_strneq (name
, ".zdebug_")))
4336 name
+= sizeof (".zdebug_") - 1;
4338 name
+= sizeof (".debug_") - 1;
4341 || (do_debug_info
&& streq (name
, "info"))
4342 || (do_debug_abbrevs
&& streq (name
, "abbrev"))
4343 || ((do_debug_lines
|| do_debug_lines_decoded
)
4344 && streq (name
, "line"))
4345 || (do_debug_pubnames
&& streq (name
, "pubnames"))
4346 || (do_debug_aranges
&& streq (name
, "aranges"))
4347 || (do_debug_ranges
&& streq (name
, "ranges"))
4348 || (do_debug_frames
&& streq (name
, "frame"))
4349 || (do_debug_macinfo
&& streq (name
, "macinfo"))
4350 || (do_debug_str
&& streq (name
, "str"))
4351 || (do_debug_loc
&& streq (name
, "loc"))
4353 request_dump_bynumber (i
, DEBUG_DUMP
);
4355 /* Linkonce section to be combined with .debug_info at link time. */
4356 else if ((do_debugging
|| do_debug_info
)
4357 && const_strneq (name
, ".gnu.linkonce.wi."))
4358 request_dump_bynumber (i
, DEBUG_DUMP
);
4359 else if (do_debug_frames
&& streq (name
, ".eh_frame"))
4360 request_dump_bynumber (i
, DEBUG_DUMP
);
4366 if (elf_header
.e_shnum
> 1)
4367 printf (_("\nSection Headers:\n"));
4369 printf (_("\nSection Header:\n"));
4373 if (do_section_details
)
4375 printf (_(" [Nr] Name\n"));
4376 printf (_(" Type Addr Off Size ES Lk Inf Al\n"));
4380 (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
4384 if (do_section_details
)
4386 printf (_(" [Nr] Name\n"));
4387 printf (_(" Type Address Off Size ES Lk Inf Al\n"));
4391 (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n"));
4395 if (do_section_details
)
4397 printf (_(" [Nr] Name\n"));
4398 printf (_(" Type Address Offset Link\n"));
4399 printf (_(" Size EntSize Info Align\n"));
4403 printf (_(" [Nr] Name Type Address Offset\n"));
4404 printf (_(" Size EntSize Flags Link Info Align\n"));
4408 if (do_section_details
)
4409 printf (_(" Flags\n"));
4411 for (i
= 0, section
= section_headers
;
4412 i
< elf_header
.e_shnum
;
4415 if (do_section_details
)
4417 printf (" [%2u] %s\n",
4419 SECTION_NAME (section
));
4420 if (is_32bit_elf
|| do_wide
)
4421 printf (" %-15.15s ",
4422 get_section_type_name (section
->sh_type
));
4425 printf ((do_wide
? " [%2u] %-17s %-15s "
4426 : " [%2u] %-17.17s %-15.15s "),
4428 SECTION_NAME (section
),
4429 get_section_type_name (section
->sh_type
));
4433 print_vma (section
->sh_addr
, LONG_HEX
);
4435 printf ( " %6.6lx %6.6lx %2.2lx",
4436 (unsigned long) section
->sh_offset
,
4437 (unsigned long) section
->sh_size
,
4438 (unsigned long) section
->sh_entsize
);
4440 if (do_section_details
)
4441 fputs (" ", stdout
);
4443 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4445 printf ("%2u %3u %2lu\n",
4448 (unsigned long) section
->sh_addralign
);
4452 print_vma (section
->sh_addr
, LONG_HEX
);
4454 if ((long) section
->sh_offset
== section
->sh_offset
)
4455 printf (" %6.6lx", (unsigned long) section
->sh_offset
);
4459 print_vma (section
->sh_offset
, LONG_HEX
);
4462 if ((unsigned long) section
->sh_size
== section
->sh_size
)
4463 printf (" %6.6lx", (unsigned long) section
->sh_size
);
4467 print_vma (section
->sh_size
, LONG_HEX
);
4470 if ((unsigned long) section
->sh_entsize
== section
->sh_entsize
)
4471 printf (" %2.2lx", (unsigned long) section
->sh_entsize
);
4475 print_vma (section
->sh_entsize
, LONG_HEX
);
4478 if (do_section_details
)
4479 fputs (" ", stdout
);
4481 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4483 printf ("%2u %3u ", section
->sh_link
, section
->sh_info
);
4485 if ((unsigned long) section
->sh_addralign
== section
->sh_addralign
)
4486 printf ("%2lu\n", (unsigned long) section
->sh_addralign
);
4489 print_vma (section
->sh_addralign
, DEC
);
4493 else if (do_section_details
)
4495 printf (" %-15.15s ",
4496 get_section_type_name (section
->sh_type
));
4497 print_vma (section
->sh_addr
, LONG_HEX
);
4498 if ((long) section
->sh_offset
== section
->sh_offset
)
4499 printf (" %16.16lx", (unsigned long) section
->sh_offset
);
4503 print_vma (section
->sh_offset
, LONG_HEX
);
4505 printf (" %u\n ", section
->sh_link
);
4506 print_vma (section
->sh_size
, LONG_HEX
);
4508 print_vma (section
->sh_entsize
, LONG_HEX
);
4510 printf (" %-16u %lu\n",
4512 (unsigned long) section
->sh_addralign
);
4517 print_vma (section
->sh_addr
, LONG_HEX
);
4518 if ((long) section
->sh_offset
== section
->sh_offset
)
4519 printf (" %8.8lx", (unsigned long) section
->sh_offset
);
4523 print_vma (section
->sh_offset
, LONG_HEX
);
4526 print_vma (section
->sh_size
, LONG_HEX
);
4528 print_vma (section
->sh_entsize
, LONG_HEX
);
4530 printf (" %3s ", get_elf_section_flags (section
->sh_flags
));
4532 printf (" %2u %3u %lu\n",
4535 (unsigned long) section
->sh_addralign
);
4538 if (do_section_details
)
4539 printf (" %s\n", get_elf_section_flags (section
->sh_flags
));
4542 if (!do_section_details
)
4543 printf (_("Key to Flags:\n\
4544 W (write), A (alloc), X (execute), M (merge), S (strings)\n\
4545 I (info), L (link order), G (group), x (unknown)\n\
4546 O (extra OS processing required) o (OS specific), p (processor specific)\n"));
4552 get_group_flags (unsigned int flags
)
4554 static char buff
[32];
4561 snprintf (buff
, sizeof (buff
), _("[<unknown>: 0x%x]"), flags
);
4568 process_section_groups (FILE *file
)
4570 Elf_Internal_Shdr
*section
;
4572 struct group
*group
;
4573 Elf_Internal_Shdr
*symtab_sec
, *strtab_sec
;
4574 Elf_Internal_Sym
*symtab
;
4578 /* Don't process section groups unless needed. */
4579 if (!do_unwind
&& !do_section_groups
)
4582 if (elf_header
.e_shnum
== 0)
4584 if (do_section_groups
)
4585 printf (_("\nThere are no sections in this file.\n"));
4590 if (section_headers
== NULL
)
4592 error (_("Section headers are not available!\n"));
4596 section_headers_groups
= calloc (elf_header
.e_shnum
,
4597 sizeof (struct group
*));
4599 if (section_headers_groups
== NULL
)
4601 error (_("Out of memory\n"));
4605 /* Scan the sections for the group section. */
4607 for (i
= 0, section
= section_headers
;
4608 i
< elf_header
.e_shnum
;
4610 if (section
->sh_type
== SHT_GROUP
)
4613 if (group_count
== 0)
4615 if (do_section_groups
)
4616 printf (_("\nThere are no section groups in this file.\n"));
4621 section_groups
= calloc (group_count
, sizeof (struct group
));
4623 if (section_groups
== NULL
)
4625 error (_("Out of memory\n"));
4634 for (i
= 0, section
= section_headers
, group
= section_groups
;
4635 i
< elf_header
.e_shnum
;
4638 if (section
->sh_type
== SHT_GROUP
)
4640 char *name
= SECTION_NAME (section
);
4642 unsigned char *start
, *indices
;
4643 unsigned int entry
, j
, size
;
4644 Elf_Internal_Shdr
*sec
;
4645 Elf_Internal_Sym
*sym
;
4647 /* Get the symbol table. */
4648 if (section
->sh_link
>= elf_header
.e_shnum
4649 || ((sec
= section_headers
+ section
->sh_link
)->sh_type
4652 error (_("Bad sh_link in group section `%s'\n"), name
);
4656 if (symtab_sec
!= sec
)
4661 symtab
= GET_ELF_SYMBOLS (file
, symtab_sec
);
4664 sym
= symtab
+ section
->sh_info
;
4666 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
4668 if (sym
->st_shndx
== 0
4669 || sym
->st_shndx
>= elf_header
.e_shnum
)
4671 error (_("Bad sh_info in group section `%s'\n"), name
);
4675 group_name
= SECTION_NAME (section_headers
+ sym
->st_shndx
);
4684 /* Get the string table. */
4685 if (symtab_sec
->sh_link
>= elf_header
.e_shnum
)
4694 != (sec
= section_headers
+ symtab_sec
->sh_link
))
4699 strtab
= get_data (NULL
, file
, strtab_sec
->sh_offset
,
4700 1, strtab_sec
->sh_size
,
4702 strtab_size
= strtab
!= NULL
? strtab_sec
->sh_size
: 0;
4704 group_name
= sym
->st_name
< strtab_size
4705 ? strtab
+ sym
->st_name
: "<corrupt>";
4708 start
= get_data (NULL
, file
, section
->sh_offset
,
4709 1, section
->sh_size
, _("section data"));
4712 size
= (section
->sh_size
/ section
->sh_entsize
) - 1;
4713 entry
= byte_get (indices
, 4);
4716 if (do_section_groups
)
4718 printf ("\n%s group section [%5u] `%s' [%s] contains %u sections:\n",
4719 get_group_flags (entry
), i
, name
, group_name
, size
);
4721 printf (_(" [Index] Name\n"));
4724 group
->group_index
= i
;
4726 for (j
= 0; j
< size
; j
++)
4728 struct group_list
*g
;
4730 entry
= byte_get (indices
, 4);
4733 if (entry
>= elf_header
.e_shnum
)
4735 error (_("section [%5u] in group section [%5u] > maximum section [%5u]\n"),
4736 entry
, i
, elf_header
.e_shnum
- 1);
4740 if (section_headers_groups
[entry
] != NULL
)
4744 error (_("section [%5u] in group section [%5u] already in group section [%5u]\n"),
4746 section_headers_groups
[entry
]->group_index
);
4751 /* Intel C/C++ compiler may put section 0 in a
4752 section group. We just warn it the first time
4753 and ignore it afterwards. */
4754 static int warned
= 0;
4757 error (_("section 0 in group section [%5u]\n"),
4758 section_headers_groups
[entry
]->group_index
);
4764 section_headers_groups
[entry
] = group
;
4766 if (do_section_groups
)
4768 sec
= section_headers
+ entry
;
4769 printf (" [%5u] %s\n", entry
, SECTION_NAME (sec
));
4772 g
= xmalloc (sizeof (struct group_list
));
4773 g
->section_index
= entry
;
4774 g
->next
= group
->root
;
4798 } dynamic_relocations
[] =
4800 { "REL", DT_REL
, DT_RELSZ
, FALSE
},
4801 { "RELA", DT_RELA
, DT_RELASZ
, TRUE
},
4802 { "PLT", DT_JMPREL
, DT_PLTRELSZ
, UNKNOWN
}
4805 /* Process the reloc section. */
4808 process_relocs (FILE *file
)
4810 unsigned long rel_size
;
4811 unsigned long rel_offset
;
4817 if (do_using_dynamic
)
4821 int has_dynamic_reloc
;
4824 has_dynamic_reloc
= 0;
4826 for (i
= 0; i
< ARRAY_SIZE (dynamic_relocations
); i
++)
4828 is_rela
= dynamic_relocations
[i
].rela
;
4829 name
= dynamic_relocations
[i
].name
;
4830 rel_size
= dynamic_info
[dynamic_relocations
[i
].size
];
4831 rel_offset
= dynamic_info
[dynamic_relocations
[i
].reloc
];
4833 has_dynamic_reloc
|= rel_size
;
4835 if (is_rela
== UNKNOWN
)
4837 if (dynamic_relocations
[i
].reloc
== DT_JMPREL
)
4838 switch (dynamic_info
[DT_PLTREL
])
4852 (_("\n'%s' relocation section at offset 0x%lx contains %ld bytes:\n"),
4853 name
, rel_offset
, rel_size
);
4855 dump_relocations (file
,
4856 offset_from_vma (file
, rel_offset
, rel_size
),
4858 dynamic_symbols
, num_dynamic_syms
,
4859 dynamic_strings
, dynamic_strings_length
, is_rela
);
4863 if (! has_dynamic_reloc
)
4864 printf (_("\nThere are no dynamic relocations in this file.\n"));
4868 Elf_Internal_Shdr
*section
;
4872 for (i
= 0, section
= section_headers
;
4873 i
< elf_header
.e_shnum
;
4876 if ( section
->sh_type
!= SHT_RELA
4877 && section
->sh_type
!= SHT_REL
)
4880 rel_offset
= section
->sh_offset
;
4881 rel_size
= section
->sh_size
;
4885 Elf_Internal_Shdr
*strsec
;
4888 printf (_("\nRelocation section "));
4890 if (string_table
== NULL
)
4891 printf ("%d", section
->sh_name
);
4893 printf (_("'%s'"), SECTION_NAME (section
));
4895 printf (_(" at offset 0x%lx contains %lu entries:\n"),
4896 rel_offset
, (unsigned long) (rel_size
/ section
->sh_entsize
));
4898 is_rela
= section
->sh_type
== SHT_RELA
;
4900 if (section
->sh_link
!= 0
4901 && section
->sh_link
< elf_header
.e_shnum
)
4903 Elf_Internal_Shdr
*symsec
;
4904 Elf_Internal_Sym
*symtab
;
4905 unsigned long nsyms
;
4906 unsigned long strtablen
= 0;
4907 char *strtab
= NULL
;
4909 symsec
= section_headers
+ section
->sh_link
;
4910 if (symsec
->sh_type
!= SHT_SYMTAB
4911 && symsec
->sh_type
!= SHT_DYNSYM
)
4914 nsyms
= symsec
->sh_size
/ symsec
->sh_entsize
;
4915 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
4920 if (symsec
->sh_link
!= 0
4921 && symsec
->sh_link
< elf_header
.e_shnum
)
4923 strsec
= section_headers
+ symsec
->sh_link
;
4925 strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
4928 strtablen
= strtab
== NULL
? 0 : strsec
->sh_size
;
4931 dump_relocations (file
, rel_offset
, rel_size
,
4932 symtab
, nsyms
, strtab
, strtablen
, is_rela
);
4938 dump_relocations (file
, rel_offset
, rel_size
,
4939 NULL
, 0, NULL
, 0, is_rela
);
4946 printf (_("\nThere are no relocations in this file.\n"));
4952 /* Process the unwind section. */
4954 #include "unwind-ia64.h"
4956 /* An absolute address consists of a section and an offset. If the
4957 section is NULL, the offset itself is the address, otherwise, the
4958 address equals to LOAD_ADDRESS(section) + offset. */
4962 unsigned short section
;
4966 #define ABSADDR(a) \
4968 ? section_headers [(a).section].sh_addr + (a).offset \
4971 struct ia64_unw_aux_info
4973 struct ia64_unw_table_entry
4975 struct absaddr start
;
4977 struct absaddr info
;
4979 *table
; /* Unwind table. */
4980 unsigned long table_len
; /* Length of unwind table. */
4981 unsigned char *info
; /* Unwind info. */
4982 unsigned long info_size
; /* Size of unwind info. */
4983 bfd_vma info_addr
; /* starting address of unwind info. */
4984 bfd_vma seg_base
; /* Starting address of segment. */
4985 Elf_Internal_Sym
*symtab
; /* The symbol table. */
4986 unsigned long nsyms
; /* Number of symbols. */
4987 char *strtab
; /* The string table. */
4988 unsigned long strtab_size
; /* Size of string table. */
4992 find_symbol_for_address (Elf_Internal_Sym
*symtab
,
4993 unsigned long nsyms
,
4995 unsigned long strtab_size
,
4996 struct absaddr addr
,
4997 const char **symname
,
5000 bfd_vma dist
= 0x100000;
5001 Elf_Internal_Sym
*sym
, *best
= NULL
;
5004 for (i
= 0, sym
= symtab
; i
< nsyms
; ++i
, ++sym
)
5006 if (ELF_ST_TYPE (sym
->st_info
) == STT_FUNC
5007 && sym
->st_name
!= 0
5008 && (addr
.section
== SHN_UNDEF
|| addr
.section
== sym
->st_shndx
)
5009 && addr
.offset
>= sym
->st_value
5010 && addr
.offset
- sym
->st_value
< dist
)
5013 dist
= addr
.offset
- sym
->st_value
;
5020 *symname
= (best
->st_name
>= strtab_size
5021 ? "<corrupt>" : strtab
+ best
->st_name
);
5026 *offset
= addr
.offset
;
5030 dump_ia64_unwind (struct ia64_unw_aux_info
*aux
)
5032 struct ia64_unw_table_entry
*tp
;
5035 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
5039 const unsigned char *dp
;
5040 const unsigned char *head
;
5041 const char *procname
;
5043 find_symbol_for_address (aux
->symtab
, aux
->nsyms
, aux
->strtab
,
5044 aux
->strtab_size
, tp
->start
, &procname
, &offset
);
5046 fputs ("\n<", stdout
);
5050 fputs (procname
, stdout
);
5053 printf ("+%lx", (unsigned long) offset
);
5056 fputs (">: [", stdout
);
5057 print_vma (tp
->start
.offset
, PREFIX_HEX
);
5058 fputc ('-', stdout
);
5059 print_vma (tp
->end
.offset
, PREFIX_HEX
);
5060 printf ("], info at +0x%lx\n",
5061 (unsigned long) (tp
->info
.offset
- aux
->seg_base
));
5063 head
= aux
->info
+ (ABSADDR (tp
->info
) - aux
->info_addr
);
5064 stamp
= byte_get ((unsigned char *) head
, sizeof (stamp
));
5066 printf (" v%u, flags=0x%lx (%s%s), len=%lu bytes\n",
5067 (unsigned) UNW_VER (stamp
),
5068 (unsigned long) ((stamp
& UNW_FLAG_MASK
) >> 32),
5069 UNW_FLAG_EHANDLER (stamp
) ? " ehandler" : "",
5070 UNW_FLAG_UHANDLER (stamp
) ? " uhandler" : "",
5071 (unsigned long) (eh_addr_size
* UNW_LENGTH (stamp
)));
5073 if (UNW_VER (stamp
) != 1)
5075 printf ("\tUnknown version.\n");
5080 for (dp
= head
+ 8; dp
< head
+ 8 + eh_addr_size
* UNW_LENGTH (stamp
);)
5081 dp
= unw_decode (dp
, in_body
, & in_body
);
5086 slurp_ia64_unwind_table (FILE *file
,
5087 struct ia64_unw_aux_info
*aux
,
5088 Elf_Internal_Shdr
*sec
)
5090 unsigned long size
, nrelas
, i
;
5091 Elf_Internal_Phdr
*seg
;
5092 struct ia64_unw_table_entry
*tep
;
5093 Elf_Internal_Shdr
*relsec
;
5094 Elf_Internal_Rela
*rela
, *rp
;
5095 unsigned char *table
, *tp
;
5096 Elf_Internal_Sym
*sym
;
5097 const char *relname
;
5099 /* First, find the starting address of the segment that includes
5102 if (elf_header
.e_phnum
)
5104 if (! get_program_headers (file
))
5107 for (seg
= program_headers
;
5108 seg
< program_headers
+ elf_header
.e_phnum
;
5111 if (seg
->p_type
!= PT_LOAD
)
5114 if (sec
->sh_addr
>= seg
->p_vaddr
5115 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
5117 aux
->seg_base
= seg
->p_vaddr
;
5123 /* Second, build the unwind table from the contents of the unwind section: */
5124 size
= sec
->sh_size
;
5125 table
= get_data (NULL
, file
, sec
->sh_offset
, 1, size
, _("unwind table"));
5129 aux
->table
= xcmalloc (size
/ (3 * eh_addr_size
), sizeof (aux
->table
[0]));
5131 for (tp
= table
; tp
< table
+ size
; tp
+= 3 * eh_addr_size
, ++tep
)
5133 tep
->start
.section
= SHN_UNDEF
;
5134 tep
->end
.section
= SHN_UNDEF
;
5135 tep
->info
.section
= SHN_UNDEF
;
5138 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
5139 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
5140 tep
->info
.offset
= byte_get ((unsigned char *) tp
+ 8, 4);
5144 tep
->start
.offset
= BYTE_GET ((unsigned char *) tp
+ 0);
5145 tep
->end
.offset
= BYTE_GET ((unsigned char *) tp
+ 8);
5146 tep
->info
.offset
= BYTE_GET ((unsigned char *) tp
+ 16);
5148 tep
->start
.offset
+= aux
->seg_base
;
5149 tep
->end
.offset
+= aux
->seg_base
;
5150 tep
->info
.offset
+= aux
->seg_base
;
5154 /* Third, apply any relocations to the unwind table: */
5155 for (relsec
= section_headers
;
5156 relsec
< section_headers
+ elf_header
.e_shnum
;
5159 if (relsec
->sh_type
!= SHT_RELA
5160 || relsec
->sh_info
>= elf_header
.e_shnum
5161 || section_headers
+ relsec
->sh_info
!= sec
)
5164 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
5168 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
5170 relname
= elf_ia64_reloc_type (get_reloc_type (rp
->r_info
));
5171 sym
= aux
->symtab
+ get_reloc_symindex (rp
->r_info
);
5173 if (! const_strneq (relname
, "R_IA64_SEGREL"))
5175 warn (_("Skipping unexpected relocation type %s\n"), relname
);
5179 i
= rp
->r_offset
/ (3 * eh_addr_size
);
5181 switch (rp
->r_offset
/eh_addr_size
% 3)
5184 aux
->table
[i
].start
.section
= sym
->st_shndx
;
5185 aux
->table
[i
].start
.offset
+= rp
->r_addend
+ sym
->st_value
;
5188 aux
->table
[i
].end
.section
= sym
->st_shndx
;
5189 aux
->table
[i
].end
.offset
+= rp
->r_addend
+ sym
->st_value
;
5192 aux
->table
[i
].info
.section
= sym
->st_shndx
;
5193 aux
->table
[i
].info
.offset
+= rp
->r_addend
+ sym
->st_value
;
5203 aux
->table_len
= size
/ (3 * eh_addr_size
);
5208 ia64_process_unwind (FILE *file
)
5210 Elf_Internal_Shdr
*sec
, *unwsec
= NULL
, *strsec
;
5211 unsigned long i
, unwcount
= 0, unwstart
= 0;
5212 struct ia64_unw_aux_info aux
;
5214 memset (& aux
, 0, sizeof (aux
));
5216 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5218 if (sec
->sh_type
== SHT_SYMTAB
5219 && sec
->sh_link
< elf_header
.e_shnum
)
5221 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
5222 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
5224 strsec
= section_headers
+ sec
->sh_link
;
5225 aux
.strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
5226 1, strsec
->sh_size
, _("string table"));
5227 aux
.strtab_size
= aux
.strtab
!= NULL
? strsec
->sh_size
: 0;
5229 else if (sec
->sh_type
== SHT_IA_64_UNWIND
)
5234 printf (_("\nThere are no unwind sections in this file.\n"));
5236 while (unwcount
-- > 0)
5241 for (i
= unwstart
, sec
= section_headers
+ unwstart
;
5242 i
< elf_header
.e_shnum
; ++i
, ++sec
)
5243 if (sec
->sh_type
== SHT_IA_64_UNWIND
)
5250 len
= sizeof (ELF_STRING_ia64_unwind_once
) - 1;
5252 if ((unwsec
->sh_flags
& SHF_GROUP
) != 0)
5254 /* We need to find which section group it is in. */
5255 struct group_list
*g
= section_headers_groups
[i
]->root
;
5257 for (; g
!= NULL
; g
= g
->next
)
5259 sec
= section_headers
+ g
->section_index
;
5261 if (streq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info
))
5266 i
= elf_header
.e_shnum
;
5268 else if (strneq (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind_once
, len
))
5270 /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO. */
5271 len2
= sizeof (ELF_STRING_ia64_unwind_info_once
) - 1;
5272 suffix
= SECTION_NAME (unwsec
) + len
;
5273 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
5275 if (strneq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info_once
, len2
)
5276 && streq (SECTION_NAME (sec
) + len2
, suffix
))
5281 /* .IA_64.unwindFOO -> .IA_64.unwind_infoFOO
5282 .IA_64.unwind or BAR -> .IA_64.unwind_info. */
5283 len
= sizeof (ELF_STRING_ia64_unwind
) - 1;
5284 len2
= sizeof (ELF_STRING_ia64_unwind_info
) - 1;
5286 if (strneq (SECTION_NAME (unwsec
), ELF_STRING_ia64_unwind
, len
))
5287 suffix
= SECTION_NAME (unwsec
) + len
;
5288 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
;
5290 if (strneq (SECTION_NAME (sec
), ELF_STRING_ia64_unwind_info
, len2
)
5291 && streq (SECTION_NAME (sec
) + len2
, suffix
))
5295 if (i
== elf_header
.e_shnum
)
5297 printf (_("\nCould not find unwind info section for "));
5299 if (string_table
== NULL
)
5300 printf ("%d", unwsec
->sh_name
);
5302 printf (_("'%s'"), SECTION_NAME (unwsec
));
5306 aux
.info_size
= sec
->sh_size
;
5307 aux
.info_addr
= sec
->sh_addr
;
5308 aux
.info
= get_data (NULL
, file
, sec
->sh_offset
, 1, aux
.info_size
,
5311 printf (_("\nUnwind section "));
5313 if (string_table
== NULL
)
5314 printf ("%d", unwsec
->sh_name
);
5316 printf (_("'%s'"), SECTION_NAME (unwsec
));
5318 printf (_(" at offset 0x%lx contains %lu entries:\n"),
5319 (unsigned long) unwsec
->sh_offset
,
5320 (unsigned long) (unwsec
->sh_size
/ (3 * eh_addr_size
)));
5322 (void) slurp_ia64_unwind_table (file
, & aux
, unwsec
);
5324 if (aux
.table_len
> 0)
5325 dump_ia64_unwind (& aux
);
5328 free ((char *) aux
.table
);
5330 free ((char *) aux
.info
);
5339 free ((char *) aux
.strtab
);
5344 struct hppa_unw_aux_info
5346 struct hppa_unw_table_entry
5348 struct absaddr start
;
5350 unsigned int Cannot_unwind
:1; /* 0 */
5351 unsigned int Millicode
:1; /* 1 */
5352 unsigned int Millicode_save_sr0
:1; /* 2 */
5353 unsigned int Region_description
:2; /* 3..4 */
5354 unsigned int reserved1
:1; /* 5 */
5355 unsigned int Entry_SR
:1; /* 6 */
5356 unsigned int Entry_FR
:4; /* number saved */ /* 7..10 */
5357 unsigned int Entry_GR
:5; /* number saved */ /* 11..15 */
5358 unsigned int Args_stored
:1; /* 16 */
5359 unsigned int Variable_Frame
:1; /* 17 */
5360 unsigned int Separate_Package_Body
:1; /* 18 */
5361 unsigned int Frame_Extension_Millicode
:1; /* 19 */
5362 unsigned int Stack_Overflow_Check
:1; /* 20 */
5363 unsigned int Two_Instruction_SP_Increment
:1; /* 21 */
5364 unsigned int Ada_Region
:1; /* 22 */
5365 unsigned int cxx_info
:1; /* 23 */
5366 unsigned int cxx_try_catch
:1; /* 24 */
5367 unsigned int sched_entry_seq
:1; /* 25 */
5368 unsigned int reserved2
:1; /* 26 */
5369 unsigned int Save_SP
:1; /* 27 */
5370 unsigned int Save_RP
:1; /* 28 */
5371 unsigned int Save_MRP_in_frame
:1; /* 29 */
5372 unsigned int extn_ptr_defined
:1; /* 30 */
5373 unsigned int Cleanup_defined
:1; /* 31 */
5375 unsigned int MPE_XL_interrupt_marker
:1; /* 0 */
5376 unsigned int HP_UX_interrupt_marker
:1; /* 1 */
5377 unsigned int Large_frame
:1; /* 2 */
5378 unsigned int Pseudo_SP_Set
:1; /* 3 */
5379 unsigned int reserved4
:1; /* 4 */
5380 unsigned int Total_frame_size
:27; /* 5..31 */
5382 *table
; /* Unwind table. */
5383 unsigned long table_len
; /* Length of unwind table. */
5384 bfd_vma seg_base
; /* Starting address of segment. */
5385 Elf_Internal_Sym
*symtab
; /* The symbol table. */
5386 unsigned long nsyms
; /* Number of symbols. */
5387 char *strtab
; /* The string table. */
5388 unsigned long strtab_size
; /* Size of string table. */
5392 dump_hppa_unwind (struct hppa_unw_aux_info
*aux
)
5394 struct hppa_unw_table_entry
*tp
;
5396 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
5399 const char *procname
;
5401 find_symbol_for_address (aux
->symtab
, aux
->nsyms
, aux
->strtab
,
5402 aux
->strtab_size
, tp
->start
, &procname
,
5405 fputs ("\n<", stdout
);
5409 fputs (procname
, stdout
);
5412 printf ("+%lx", (unsigned long) offset
);
5415 fputs (">: [", stdout
);
5416 print_vma (tp
->start
.offset
, PREFIX_HEX
);
5417 fputc ('-', stdout
);
5418 print_vma (tp
->end
.offset
, PREFIX_HEX
);
5421 #define PF(_m) if (tp->_m) printf (#_m " ");
5422 #define PV(_m) if (tp->_m) printf (#_m "=%d ", tp->_m);
5425 PF(Millicode_save_sr0
);
5426 /* PV(Region_description); */
5432 PF(Separate_Package_Body
);
5433 PF(Frame_Extension_Millicode
);
5434 PF(Stack_Overflow_Check
);
5435 PF(Two_Instruction_SP_Increment
);
5439 PF(sched_entry_seq
);
5442 PF(Save_MRP_in_frame
);
5443 PF(extn_ptr_defined
);
5444 PF(Cleanup_defined
);
5445 PF(MPE_XL_interrupt_marker
);
5446 PF(HP_UX_interrupt_marker
);
5449 PV(Total_frame_size
);
5458 slurp_hppa_unwind_table (FILE *file
,
5459 struct hppa_unw_aux_info
*aux
,
5460 Elf_Internal_Shdr
*sec
)
5462 unsigned long size
, unw_ent_size
, nentries
, nrelas
, i
;
5463 Elf_Internal_Phdr
*seg
;
5464 struct hppa_unw_table_entry
*tep
;
5465 Elf_Internal_Shdr
*relsec
;
5466 Elf_Internal_Rela
*rela
, *rp
;
5467 unsigned char *table
, *tp
;
5468 Elf_Internal_Sym
*sym
;
5469 const char *relname
;
5471 /* First, find the starting address of the segment that includes
5474 if (elf_header
.e_phnum
)
5476 if (! get_program_headers (file
))
5479 for (seg
= program_headers
;
5480 seg
< program_headers
+ elf_header
.e_phnum
;
5483 if (seg
->p_type
!= PT_LOAD
)
5486 if (sec
->sh_addr
>= seg
->p_vaddr
5487 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
5489 aux
->seg_base
= seg
->p_vaddr
;
5495 /* Second, build the unwind table from the contents of the unwind
5497 size
= sec
->sh_size
;
5498 table
= get_data (NULL
, file
, sec
->sh_offset
, 1, size
, _("unwind table"));
5503 nentries
= size
/ unw_ent_size
;
5504 size
= unw_ent_size
* nentries
;
5506 tep
= aux
->table
= xcmalloc (nentries
, sizeof (aux
->table
[0]));
5508 for (tp
= table
; tp
< table
+ size
; tp
+= unw_ent_size
, ++tep
)
5510 unsigned int tmp1
, tmp2
;
5512 tep
->start
.section
= SHN_UNDEF
;
5513 tep
->end
.section
= SHN_UNDEF
;
5515 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
5516 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
5517 tmp1
= byte_get ((unsigned char *) tp
+ 8, 4);
5518 tmp2
= byte_get ((unsigned char *) tp
+ 12, 4);
5520 tep
->start
.offset
+= aux
->seg_base
;
5521 tep
->end
.offset
+= aux
->seg_base
;
5523 tep
->Cannot_unwind
= (tmp1
>> 31) & 0x1;
5524 tep
->Millicode
= (tmp1
>> 30) & 0x1;
5525 tep
->Millicode_save_sr0
= (tmp1
>> 29) & 0x1;
5526 tep
->Region_description
= (tmp1
>> 27) & 0x3;
5527 tep
->reserved1
= (tmp1
>> 26) & 0x1;
5528 tep
->Entry_SR
= (tmp1
>> 25) & 0x1;
5529 tep
->Entry_FR
= (tmp1
>> 21) & 0xf;
5530 tep
->Entry_GR
= (tmp1
>> 16) & 0x1f;
5531 tep
->Args_stored
= (tmp1
>> 15) & 0x1;
5532 tep
->Variable_Frame
= (tmp1
>> 14) & 0x1;
5533 tep
->Separate_Package_Body
= (tmp1
>> 13) & 0x1;
5534 tep
->Frame_Extension_Millicode
= (tmp1
>> 12) & 0x1;
5535 tep
->Stack_Overflow_Check
= (tmp1
>> 11) & 0x1;
5536 tep
->Two_Instruction_SP_Increment
= (tmp1
>> 10) & 0x1;
5537 tep
->Ada_Region
= (tmp1
>> 9) & 0x1;
5538 tep
->cxx_info
= (tmp1
>> 8) & 0x1;
5539 tep
->cxx_try_catch
= (tmp1
>> 7) & 0x1;
5540 tep
->sched_entry_seq
= (tmp1
>> 6) & 0x1;
5541 tep
->reserved2
= (tmp1
>> 5) & 0x1;
5542 tep
->Save_SP
= (tmp1
>> 4) & 0x1;
5543 tep
->Save_RP
= (tmp1
>> 3) & 0x1;
5544 tep
->Save_MRP_in_frame
= (tmp1
>> 2) & 0x1;
5545 tep
->extn_ptr_defined
= (tmp1
>> 1) & 0x1;
5546 tep
->Cleanup_defined
= tmp1
& 0x1;
5548 tep
->MPE_XL_interrupt_marker
= (tmp2
>> 31) & 0x1;
5549 tep
->HP_UX_interrupt_marker
= (tmp2
>> 30) & 0x1;
5550 tep
->Large_frame
= (tmp2
>> 29) & 0x1;
5551 tep
->Pseudo_SP_Set
= (tmp2
>> 28) & 0x1;
5552 tep
->reserved4
= (tmp2
>> 27) & 0x1;
5553 tep
->Total_frame_size
= tmp2
& 0x7ffffff;
5557 /* Third, apply any relocations to the unwind table. */
5558 for (relsec
= section_headers
;
5559 relsec
< section_headers
+ elf_header
.e_shnum
;
5562 if (relsec
->sh_type
!= SHT_RELA
5563 || relsec
->sh_info
>= elf_header
.e_shnum
5564 || section_headers
+ relsec
->sh_info
!= sec
)
5567 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
5571 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
5573 relname
= elf_hppa_reloc_type (get_reloc_type (rp
->r_info
));
5574 sym
= aux
->symtab
+ get_reloc_symindex (rp
->r_info
);
5576 /* R_PARISC_SEGREL32 or R_PARISC_SEGREL64. */
5577 if (! const_strneq (relname
, "R_PARISC_SEGREL"))
5579 warn (_("Skipping unexpected relocation type %s\n"), relname
);
5583 i
= rp
->r_offset
/ unw_ent_size
;
5585 switch ((rp
->r_offset
% unw_ent_size
) / eh_addr_size
)
5588 aux
->table
[i
].start
.section
= sym
->st_shndx
;
5589 aux
->table
[i
].start
.offset
+= sym
->st_value
+ rp
->r_addend
;
5592 aux
->table
[i
].end
.section
= sym
->st_shndx
;
5593 aux
->table
[i
].end
.offset
+= sym
->st_value
+ rp
->r_addend
;
5603 aux
->table_len
= nentries
;
5609 hppa_process_unwind (FILE *file
)
5611 struct hppa_unw_aux_info aux
;
5612 Elf_Internal_Shdr
*unwsec
= NULL
;
5613 Elf_Internal_Shdr
*strsec
;
5614 Elf_Internal_Shdr
*sec
;
5617 memset (& aux
, 0, sizeof (aux
));
5619 if (string_table
== NULL
)
5622 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5624 if (sec
->sh_type
== SHT_SYMTAB
5625 && sec
->sh_link
< elf_header
.e_shnum
)
5627 aux
.nsyms
= sec
->sh_size
/ sec
->sh_entsize
;
5628 aux
.symtab
= GET_ELF_SYMBOLS (file
, sec
);
5630 strsec
= section_headers
+ sec
->sh_link
;
5631 aux
.strtab
= get_data (NULL
, file
, strsec
->sh_offset
,
5632 1, strsec
->sh_size
, _("string table"));
5633 aux
.strtab_size
= aux
.strtab
!= NULL
? strsec
->sh_size
: 0;
5635 else if (streq (SECTION_NAME (sec
), ".PARISC.unwind"))
5640 printf (_("\nThere are no unwind sections in this file.\n"));
5642 for (i
= 0, sec
= section_headers
; i
< elf_header
.e_shnum
; ++i
, ++sec
)
5644 if (streq (SECTION_NAME (sec
), ".PARISC.unwind"))
5646 printf (_("\nUnwind section "));
5647 printf (_("'%s'"), SECTION_NAME (sec
));
5649 printf (_(" at offset 0x%lx contains %lu entries:\n"),
5650 (unsigned long) sec
->sh_offset
,
5651 (unsigned long) (sec
->sh_size
/ (2 * eh_addr_size
+ 8)));
5653 slurp_hppa_unwind_table (file
, &aux
, sec
);
5654 if (aux
.table_len
> 0)
5655 dump_hppa_unwind (&aux
);
5658 free ((char *) aux
.table
);
5666 free ((char *) aux
.strtab
);
5672 process_unwind (FILE *file
)
5674 struct unwind_handler
{
5676 int (*handler
)(FILE *file
);
5678 { EM_IA_64
, ia64_process_unwind
},
5679 { EM_PARISC
, hppa_process_unwind
},
5687 for (i
= 0; handlers
[i
].handler
!= NULL
; i
++)
5688 if (elf_header
.e_machine
== handlers
[i
].machtype
)
5689 return handlers
[i
].handler (file
);
5691 printf (_("\nThere are no unwind sections in this file.\n"));
5696 dynamic_section_mips_val (Elf_Internal_Dyn
*entry
)
5698 switch (entry
->d_tag
)
5701 if (entry
->d_un
.d_val
== 0)
5705 static const char * opts
[] =
5707 "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT",
5708 "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS",
5709 "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD",
5710 "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF",
5715 for (cnt
= 0; cnt
< ARRAY_SIZE (opts
); ++cnt
)
5716 if (entry
->d_un
.d_val
& (1 << cnt
))
5718 printf ("%s%s", first
? "" : " ", opts
[cnt
]);
5725 case DT_MIPS_IVERSION
:
5726 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
5727 printf ("Interface Version: %s\n", GET_DYNAMIC_NAME (entry
->d_un
.d_val
));
5729 printf ("<corrupt: %ld>\n", (long) entry
->d_un
.d_ptr
);
5732 case DT_MIPS_TIME_STAMP
:
5737 time_t time
= entry
->d_un
.d_val
;
5738 tmp
= gmtime (&time
);
5739 snprintf (timebuf
, sizeof (timebuf
), "%04u-%02u-%02uT%02u:%02u:%02u",
5740 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
5741 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
5742 printf ("Time Stamp: %s\n", timebuf
);
5746 case DT_MIPS_RLD_VERSION
:
5747 case DT_MIPS_LOCAL_GOTNO
:
5748 case DT_MIPS_CONFLICTNO
:
5749 case DT_MIPS_LIBLISTNO
:
5750 case DT_MIPS_SYMTABNO
:
5751 case DT_MIPS_UNREFEXTNO
:
5752 case DT_MIPS_HIPAGENO
:
5753 case DT_MIPS_DELTA_CLASS_NO
:
5754 case DT_MIPS_DELTA_INSTANCE_NO
:
5755 case DT_MIPS_DELTA_RELOC_NO
:
5756 case DT_MIPS_DELTA_SYM_NO
:
5757 case DT_MIPS_DELTA_CLASSSYM_NO
:
5758 case DT_MIPS_COMPACT_SIZE
:
5759 printf ("%ld\n", (long) entry
->d_un
.d_ptr
);
5763 printf ("%#lx\n", (unsigned long) entry
->d_un
.d_ptr
);
5769 dynamic_section_parisc_val (Elf_Internal_Dyn
*entry
)
5771 switch (entry
->d_tag
)
5773 case DT_HP_DLD_FLAGS
:
5782 { DT_HP_DEBUG_PRIVATE
, "HP_DEBUG_PRIVATE" },
5783 { DT_HP_DEBUG_CALLBACK
, "HP_DEBUG_CALLBACK" },
5784 { DT_HP_DEBUG_CALLBACK_BOR
, "HP_DEBUG_CALLBACK_BOR" },
5785 { DT_HP_NO_ENVVAR
, "HP_NO_ENVVAR" },
5786 { DT_HP_BIND_NOW
, "HP_BIND_NOW" },
5787 { DT_HP_BIND_NONFATAL
, "HP_BIND_NONFATAL" },
5788 { DT_HP_BIND_VERBOSE
, "HP_BIND_VERBOSE" },
5789 { DT_HP_BIND_RESTRICTED
, "HP_BIND_RESTRICTED" },
5790 { DT_HP_BIND_SYMBOLIC
, "HP_BIND_SYMBOLIC" },
5791 { DT_HP_RPATH_FIRST
, "HP_RPATH_FIRST" },
5792 { DT_HP_BIND_DEPTH_FIRST
, "HP_BIND_DEPTH_FIRST" },
5793 { DT_HP_GST
, "HP_GST" },
5794 { DT_HP_SHLIB_FIXED
, "HP_SHLIB_FIXED" },
5795 { DT_HP_MERGE_SHLIB_SEG
, "HP_MERGE_SHLIB_SEG" },
5796 { DT_HP_NODELETE
, "HP_NODELETE" },
5797 { DT_HP_GROUP
, "HP_GROUP" },
5798 { DT_HP_PROTECT_LINKAGE_TABLE
, "HP_PROTECT_LINKAGE_TABLE" }
5802 bfd_vma val
= entry
->d_un
.d_val
;
5804 for (cnt
= 0; cnt
< ARRAY_SIZE (flags
); ++cnt
)
5805 if (val
& flags
[cnt
].bit
)
5809 fputs (flags
[cnt
].str
, stdout
);
5811 val
^= flags
[cnt
].bit
;
5814 if (val
!= 0 || first
)
5818 print_vma (val
, HEX
);
5824 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5831 dynamic_section_ia64_val (Elf_Internal_Dyn
*entry
)
5833 switch (entry
->d_tag
)
5835 case DT_IA_64_PLT_RESERVE
:
5836 /* First 3 slots reserved. */
5837 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5839 print_vma (entry
->d_un
.d_ptr
+ (3 * 8), PREFIX_HEX
);
5843 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
5850 get_32bit_dynamic_section (FILE *file
)
5852 Elf32_External_Dyn
*edyn
, *ext
;
5853 Elf_Internal_Dyn
*entry
;
5855 edyn
= get_data (NULL
, file
, dynamic_addr
, 1, dynamic_size
,
5856 _("dynamic section"));
5860 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
5861 might not have the luxury of section headers. Look for the DT_NULL
5862 terminator to determine the number of entries. */
5863 for (ext
= edyn
, dynamic_nent
= 0;
5864 (char *) ext
< (char *) edyn
+ dynamic_size
;
5868 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
5872 dynamic_section
= cmalloc (dynamic_nent
, sizeof (*entry
));
5873 if (dynamic_section
== NULL
)
5875 error (_("Out of memory\n"));
5880 for (ext
= edyn
, entry
= dynamic_section
;
5881 entry
< dynamic_section
+ dynamic_nent
;
5884 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
5885 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
5894 get_64bit_dynamic_section (FILE *file
)
5896 Elf64_External_Dyn
*edyn
, *ext
;
5897 Elf_Internal_Dyn
*entry
;
5899 edyn
= get_data (NULL
, file
, dynamic_addr
, 1, dynamic_size
,
5900 _("dynamic section"));
5904 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
5905 might not have the luxury of section headers. Look for the DT_NULL
5906 terminator to determine the number of entries. */
5907 for (ext
= edyn
, dynamic_nent
= 0;
5908 (char *) ext
< (char *) edyn
+ dynamic_size
;
5912 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
5916 dynamic_section
= cmalloc (dynamic_nent
, sizeof (*entry
));
5917 if (dynamic_section
== NULL
)
5919 error (_("Out of memory\n"));
5924 for (ext
= edyn
, entry
= dynamic_section
;
5925 entry
< dynamic_section
+ dynamic_nent
;
5928 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
5929 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
5938 print_dynamic_flags (bfd_vma flags
)
5946 flag
= flags
& - flags
;
5956 case DF_ORIGIN
: fputs ("ORIGIN", stdout
); break;
5957 case DF_SYMBOLIC
: fputs ("SYMBOLIC", stdout
); break;
5958 case DF_TEXTREL
: fputs ("TEXTREL", stdout
); break;
5959 case DF_BIND_NOW
: fputs ("BIND_NOW", stdout
); break;
5960 case DF_STATIC_TLS
: fputs ("STATIC_TLS", stdout
); break;
5961 default: fputs ("unknown", stdout
); break;
5967 /* Parse and display the contents of the dynamic section. */
5970 process_dynamic_section (FILE *file
)
5972 Elf_Internal_Dyn
*entry
;
5974 if (dynamic_size
== 0)
5977 printf (_("\nThere is no dynamic section in this file.\n"));
5984 if (! get_32bit_dynamic_section (file
))
5987 else if (! get_64bit_dynamic_section (file
))
5990 /* Find the appropriate symbol table. */
5991 if (dynamic_symbols
== NULL
)
5993 for (entry
= dynamic_section
;
5994 entry
< dynamic_section
+ dynamic_nent
;
5997 Elf_Internal_Shdr section
;
5999 if (entry
->d_tag
!= DT_SYMTAB
)
6002 dynamic_info
[DT_SYMTAB
] = entry
->d_un
.d_val
;
6004 /* Since we do not know how big the symbol table is,
6005 we default to reading in the entire file (!) and
6006 processing that. This is overkill, I know, but it
6008 section
.sh_offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
6010 if (archive_file_offset
!= 0)
6011 section
.sh_size
= archive_file_size
- section
.sh_offset
;
6014 if (fseek (file
, 0, SEEK_END
))
6015 error (_("Unable to seek to end of file!\n"));
6017 section
.sh_size
= ftell (file
) - section
.sh_offset
;
6021 section
.sh_entsize
= sizeof (Elf32_External_Sym
);
6023 section
.sh_entsize
= sizeof (Elf64_External_Sym
);
6025 num_dynamic_syms
= section
.sh_size
/ section
.sh_entsize
;
6026 if (num_dynamic_syms
< 1)
6028 error (_("Unable to determine the number of symbols to load\n"));
6032 dynamic_symbols
= GET_ELF_SYMBOLS (file
, §ion
);
6036 /* Similarly find a string table. */
6037 if (dynamic_strings
== NULL
)
6039 for (entry
= dynamic_section
;
6040 entry
< dynamic_section
+ dynamic_nent
;
6043 unsigned long offset
;
6046 if (entry
->d_tag
!= DT_STRTAB
)
6049 dynamic_info
[DT_STRTAB
] = entry
->d_un
.d_val
;
6051 /* Since we do not know how big the string table is,
6052 we default to reading in the entire file (!) and
6053 processing that. This is overkill, I know, but it
6056 offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
6058 if (archive_file_offset
!= 0)
6059 str_tab_len
= archive_file_size
- offset
;
6062 if (fseek (file
, 0, SEEK_END
))
6063 error (_("Unable to seek to end of file\n"));
6064 str_tab_len
= ftell (file
) - offset
;
6067 if (str_tab_len
< 1)
6070 (_("Unable to determine the length of the dynamic string table\n"));
6074 dynamic_strings
= get_data (NULL
, file
, offset
, 1, str_tab_len
,
6075 _("dynamic string table"));
6076 dynamic_strings_length
= str_tab_len
;
6081 /* And find the syminfo section if available. */
6082 if (dynamic_syminfo
== NULL
)
6084 unsigned long syminsz
= 0;
6086 for (entry
= dynamic_section
;
6087 entry
< dynamic_section
+ dynamic_nent
;
6090 if (entry
->d_tag
== DT_SYMINENT
)
6092 /* Note: these braces are necessary to avoid a syntax
6093 error from the SunOS4 C compiler. */
6094 assert (sizeof (Elf_External_Syminfo
) == entry
->d_un
.d_val
);
6096 else if (entry
->d_tag
== DT_SYMINSZ
)
6097 syminsz
= entry
->d_un
.d_val
;
6098 else if (entry
->d_tag
== DT_SYMINFO
)
6099 dynamic_syminfo_offset
= offset_from_vma (file
, entry
->d_un
.d_val
,
6103 if (dynamic_syminfo_offset
!= 0 && syminsz
!= 0)
6105 Elf_External_Syminfo
*extsyminfo
, *extsym
;
6106 Elf_Internal_Syminfo
*syminfo
;
6108 /* There is a syminfo section. Read the data. */
6109 extsyminfo
= get_data (NULL
, file
, dynamic_syminfo_offset
, 1,
6110 syminsz
, _("symbol information"));
6114 dynamic_syminfo
= malloc (syminsz
);
6115 if (dynamic_syminfo
== NULL
)
6117 error (_("Out of memory\n"));
6121 dynamic_syminfo_nent
= syminsz
/ sizeof (Elf_External_Syminfo
);
6122 for (syminfo
= dynamic_syminfo
, extsym
= extsyminfo
;
6123 syminfo
< dynamic_syminfo
+ dynamic_syminfo_nent
;
6124 ++syminfo
, ++extsym
)
6126 syminfo
->si_boundto
= BYTE_GET (extsym
->si_boundto
);
6127 syminfo
->si_flags
= BYTE_GET (extsym
->si_flags
);
6134 if (do_dynamic
&& dynamic_addr
)
6135 printf (_("\nDynamic section at offset 0x%lx contains %u entries:\n"),
6136 dynamic_addr
, dynamic_nent
);
6138 printf (_(" Tag Type Name/Value\n"));
6140 for (entry
= dynamic_section
;
6141 entry
< dynamic_section
+ dynamic_nent
;
6149 print_vma (entry
->d_tag
, FULL_HEX
);
6150 dtype
= get_dynamic_type (entry
->d_tag
);
6151 printf (" (%s)%*s", dtype
,
6152 ((is_32bit_elf
? 27 : 19)
6153 - (int) strlen (dtype
)),
6157 switch (entry
->d_tag
)
6161 print_dynamic_flags (entry
->d_un
.d_val
);
6171 switch (entry
->d_tag
)
6174 printf (_("Auxiliary library"));
6178 printf (_("Filter library"));
6182 printf (_("Configuration file"));
6186 printf (_("Dependency audit library"));
6190 printf (_("Audit library"));
6194 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
6195 printf (": [%s]\n", GET_DYNAMIC_NAME (entry
->d_un
.d_val
));
6199 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6208 printf (_("Flags:"));
6210 if (entry
->d_un
.d_val
== 0)
6211 printf (_(" None\n"));
6214 unsigned long int val
= entry
->d_un
.d_val
;
6216 if (val
& DTF_1_PARINIT
)
6218 printf (" PARINIT");
6219 val
^= DTF_1_PARINIT
;
6221 if (val
& DTF_1_CONFEXP
)
6223 printf (" CONFEXP");
6224 val
^= DTF_1_CONFEXP
;
6227 printf (" %lx", val
);
6236 printf (_("Flags:"));
6238 if (entry
->d_un
.d_val
== 0)
6239 printf (_(" None\n"));
6242 unsigned long int val
= entry
->d_un
.d_val
;
6244 if (val
& DF_P1_LAZYLOAD
)
6246 printf (" LAZYLOAD");
6247 val
^= DF_P1_LAZYLOAD
;
6249 if (val
& DF_P1_GROUPPERM
)
6251 printf (" GROUPPERM");
6252 val
^= DF_P1_GROUPPERM
;
6255 printf (" %lx", val
);
6264 printf (_("Flags:"));
6265 if (entry
->d_un
.d_val
== 0)
6266 printf (_(" None\n"));
6269 unsigned long int val
= entry
->d_un
.d_val
;
6276 if (val
& DF_1_GLOBAL
)
6281 if (val
& DF_1_GROUP
)
6286 if (val
& DF_1_NODELETE
)
6288 printf (" NODELETE");
6289 val
^= DF_1_NODELETE
;
6291 if (val
& DF_1_LOADFLTR
)
6293 printf (" LOADFLTR");
6294 val
^= DF_1_LOADFLTR
;
6296 if (val
& DF_1_INITFIRST
)
6298 printf (" INITFIRST");
6299 val
^= DF_1_INITFIRST
;
6301 if (val
& DF_1_NOOPEN
)
6306 if (val
& DF_1_ORIGIN
)
6311 if (val
& DF_1_DIRECT
)
6316 if (val
& DF_1_TRANS
)
6321 if (val
& DF_1_INTERPOSE
)
6323 printf (" INTERPOSE");
6324 val
^= DF_1_INTERPOSE
;
6326 if (val
& DF_1_NODEFLIB
)
6328 printf (" NODEFLIB");
6329 val
^= DF_1_NODEFLIB
;
6331 if (val
& DF_1_NODUMP
)
6336 if (val
& DF_1_CONLFAT
)
6338 printf (" CONLFAT");
6339 val
^= DF_1_CONLFAT
;
6342 printf (" %lx", val
);
6349 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6351 puts (get_dynamic_type (entry
->d_un
.d_val
));
6371 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6377 if (VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
6378 name
= GET_DYNAMIC_NAME (entry
->d_un
.d_val
);
6384 switch (entry
->d_tag
)
6387 printf (_("Shared library: [%s]"), name
);
6389 if (streq (name
, program_interpreter
))
6390 printf (_(" program interpreter"));
6394 printf (_("Library soname: [%s]"), name
);
6398 printf (_("Library rpath: [%s]"), name
);
6402 printf (_("Library runpath: [%s]"), name
);
6406 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6411 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6424 dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
6428 case DT_INIT_ARRAYSZ
:
6429 case DT_FINI_ARRAYSZ
:
6430 case DT_GNU_CONFLICTSZ
:
6431 case DT_GNU_LIBLISTSZ
:
6434 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
6435 printf (" (bytes)\n");
6445 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
6458 if (entry
->d_tag
== DT_USED
6459 && VALID_DYNAMIC_NAME (entry
->d_un
.d_val
))
6461 char *name
= GET_DYNAMIC_NAME (entry
->d_un
.d_val
);
6465 printf (_("Not needed object: [%s]\n"), name
);
6470 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6476 /* The value of this entry is ignored. */
6481 case DT_GNU_PRELINKED
:
6485 time_t time
= entry
->d_un
.d_val
;
6487 tmp
= gmtime (&time
);
6488 printf ("%04u-%02u-%02uT%02u:%02u:%02u\n",
6489 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
6490 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
6496 dynamic_info_DT_GNU_HASH
= entry
->d_un
.d_val
;
6499 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6505 if ((entry
->d_tag
>= DT_VERSYM
) && (entry
->d_tag
<= DT_VERNEEDNUM
))
6506 version_info
[DT_VERSIONTAGIDX (entry
->d_tag
)] =
6511 switch (elf_header
.e_machine
)
6514 case EM_MIPS_RS3_LE
:
6515 dynamic_section_mips_val (entry
);
6518 dynamic_section_parisc_val (entry
);
6521 dynamic_section_ia64_val (entry
);
6524 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
6536 get_ver_flags (unsigned int flags
)
6538 static char buff
[32];
6545 if (flags
& VER_FLG_BASE
)
6546 strcat (buff
, "BASE ");
6548 if (flags
& VER_FLG_WEAK
)
6550 if (flags
& VER_FLG_BASE
)
6551 strcat (buff
, "| ");
6553 strcat (buff
, "WEAK ");
6556 if (flags
& ~(VER_FLG_BASE
| VER_FLG_WEAK
))
6557 strcat (buff
, "| <unknown>");
6562 /* Display the contents of the version sections. */
6564 process_version_sections (FILE *file
)
6566 Elf_Internal_Shdr
*section
;
6573 for (i
= 0, section
= section_headers
;
6574 i
< elf_header
.e_shnum
;
6577 switch (section
->sh_type
)
6579 case SHT_GNU_verdef
:
6581 Elf_External_Verdef
*edefs
;
6589 (_("\nVersion definition section '%s' contains %u entries:\n"),
6590 SECTION_NAME (section
), section
->sh_info
);
6592 printf (_(" Addr: 0x"));
6593 printf_vma (section
->sh_addr
);
6594 printf (_(" Offset: %#08lx Link: %u (%s)\n"),
6595 (unsigned long) section
->sh_offset
, section
->sh_link
,
6596 section
->sh_link
< elf_header
.e_shnum
6597 ? SECTION_NAME (section_headers
+ section
->sh_link
)
6600 edefs
= get_data (NULL
, file
, section
->sh_offset
, 1,
6602 _("version definition section"));
6603 endbuf
= (char *) edefs
+ section
->sh_size
;
6607 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
6610 Elf_External_Verdef
*edef
;
6611 Elf_Internal_Verdef ent
;
6612 Elf_External_Verdaux
*eaux
;
6613 Elf_Internal_Verdaux aux
;
6617 vstart
= ((char *) edefs
) + idx
;
6618 if (vstart
+ sizeof (*edef
) > endbuf
)
6621 edef
= (Elf_External_Verdef
*) vstart
;
6623 ent
.vd_version
= BYTE_GET (edef
->vd_version
);
6624 ent
.vd_flags
= BYTE_GET (edef
->vd_flags
);
6625 ent
.vd_ndx
= BYTE_GET (edef
->vd_ndx
);
6626 ent
.vd_cnt
= BYTE_GET (edef
->vd_cnt
);
6627 ent
.vd_hash
= BYTE_GET (edef
->vd_hash
);
6628 ent
.vd_aux
= BYTE_GET (edef
->vd_aux
);
6629 ent
.vd_next
= BYTE_GET (edef
->vd_next
);
6631 printf (_(" %#06x: Rev: %d Flags: %s"),
6632 idx
, ent
.vd_version
, get_ver_flags (ent
.vd_flags
));
6634 printf (_(" Index: %d Cnt: %d "),
6635 ent
.vd_ndx
, ent
.vd_cnt
);
6637 vstart
+= ent
.vd_aux
;
6639 eaux
= (Elf_External_Verdaux
*) vstart
;
6641 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
6642 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
6644 if (VALID_DYNAMIC_NAME (aux
.vda_name
))
6645 printf (_("Name: %s\n"), GET_DYNAMIC_NAME (aux
.vda_name
));
6647 printf (_("Name index: %ld\n"), aux
.vda_name
);
6649 isum
= idx
+ ent
.vd_aux
;
6651 for (j
= 1; j
< ent
.vd_cnt
; j
++)
6653 isum
+= aux
.vda_next
;
6654 vstart
+= aux
.vda_next
;
6656 eaux
= (Elf_External_Verdaux
*) vstart
;
6657 if (vstart
+ sizeof (*eaux
) > endbuf
)
6660 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
6661 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
6663 if (VALID_DYNAMIC_NAME (aux
.vda_name
))
6664 printf (_(" %#06x: Parent %d: %s\n"),
6665 isum
, j
, GET_DYNAMIC_NAME (aux
.vda_name
));
6667 printf (_(" %#06x: Parent %d, name index: %ld\n"),
6668 isum
, j
, aux
.vda_name
);
6671 printf (_(" Version def aux past end of section\n"));
6675 if (cnt
< section
->sh_info
)
6676 printf (_(" Version definition past end of section\n"));
6682 case SHT_GNU_verneed
:
6684 Elf_External_Verneed
*eneed
;
6691 printf (_("\nVersion needs section '%s' contains %u entries:\n"),
6692 SECTION_NAME (section
), section
->sh_info
);
6694 printf (_(" Addr: 0x"));
6695 printf_vma (section
->sh_addr
);
6696 printf (_(" Offset: %#08lx Link: %u (%s)\n"),
6697 (unsigned long) section
->sh_offset
, section
->sh_link
,
6698 section
->sh_link
< elf_header
.e_shnum
6699 ? SECTION_NAME (section_headers
+ section
->sh_link
)
6702 eneed
= get_data (NULL
, file
, section
->sh_offset
, 1,
6704 _("version need section"));
6705 endbuf
= (char *) eneed
+ section
->sh_size
;
6709 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
6711 Elf_External_Verneed
*entry
;
6712 Elf_Internal_Verneed ent
;
6717 vstart
= ((char *) eneed
) + idx
;
6718 if (vstart
+ sizeof (*entry
) > endbuf
)
6721 entry
= (Elf_External_Verneed
*) vstart
;
6723 ent
.vn_version
= BYTE_GET (entry
->vn_version
);
6724 ent
.vn_cnt
= BYTE_GET (entry
->vn_cnt
);
6725 ent
.vn_file
= BYTE_GET (entry
->vn_file
);
6726 ent
.vn_aux
= BYTE_GET (entry
->vn_aux
);
6727 ent
.vn_next
= BYTE_GET (entry
->vn_next
);
6729 printf (_(" %#06x: Version: %d"), idx
, ent
.vn_version
);
6731 if (VALID_DYNAMIC_NAME (ent
.vn_file
))
6732 printf (_(" File: %s"), GET_DYNAMIC_NAME (ent
.vn_file
));
6734 printf (_(" File: %lx"), ent
.vn_file
);
6736 printf (_(" Cnt: %d\n"), ent
.vn_cnt
);
6738 vstart
+= ent
.vn_aux
;
6740 for (j
= 0, isum
= idx
+ ent
.vn_aux
; j
< ent
.vn_cnt
; ++j
)
6742 Elf_External_Vernaux
*eaux
;
6743 Elf_Internal_Vernaux aux
;
6745 if (vstart
+ sizeof (*eaux
) > endbuf
)
6747 eaux
= (Elf_External_Vernaux
*) vstart
;
6749 aux
.vna_hash
= BYTE_GET (eaux
->vna_hash
);
6750 aux
.vna_flags
= BYTE_GET (eaux
->vna_flags
);
6751 aux
.vna_other
= BYTE_GET (eaux
->vna_other
);
6752 aux
.vna_name
= BYTE_GET (eaux
->vna_name
);
6753 aux
.vna_next
= BYTE_GET (eaux
->vna_next
);
6755 if (VALID_DYNAMIC_NAME (aux
.vna_name
))
6756 printf (_(" %#06x: Name: %s"),
6757 isum
, GET_DYNAMIC_NAME (aux
.vna_name
));
6759 printf (_(" %#06x: Name index: %lx"),
6760 isum
, aux
.vna_name
);
6762 printf (_(" Flags: %s Version: %d\n"),
6763 get_ver_flags (aux
.vna_flags
), aux
.vna_other
);
6765 isum
+= aux
.vna_next
;
6766 vstart
+= aux
.vna_next
;
6769 printf (_(" Version need aux past end of section\n"));
6773 if (cnt
< section
->sh_info
)
6774 printf (_(" Version need past end of section\n"));
6780 case SHT_GNU_versym
:
6782 Elf_Internal_Shdr
*link_section
;
6785 unsigned char *edata
;
6786 unsigned short *data
;
6788 Elf_Internal_Sym
*symbols
;
6789 Elf_Internal_Shdr
*string_sec
;
6792 if (section
->sh_link
>= elf_header
.e_shnum
)
6795 link_section
= section_headers
+ section
->sh_link
;
6796 total
= section
->sh_size
/ sizeof (Elf_External_Versym
);
6798 if (link_section
->sh_link
>= elf_header
.e_shnum
)
6803 symbols
= GET_ELF_SYMBOLS (file
, link_section
);
6805 string_sec
= section_headers
+ link_section
->sh_link
;
6807 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
, 1,
6808 string_sec
->sh_size
, _("version string table"));
6812 printf (_("\nVersion symbols section '%s' contains %d entries:\n"),
6813 SECTION_NAME (section
), total
);
6815 printf (_(" Addr: "));
6816 printf_vma (section
->sh_addr
);
6817 printf (_(" Offset: %#08lx Link: %u (%s)\n"),
6818 (unsigned long) section
->sh_offset
, section
->sh_link
,
6819 SECTION_NAME (link_section
));
6821 off
= offset_from_vma (file
,
6822 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
6823 total
* sizeof (short));
6824 edata
= get_data (NULL
, file
, off
, total
, sizeof (short),
6825 _("version symbol data"));
6832 data
= cmalloc (total
, sizeof (short));
6834 for (cnt
= total
; cnt
--;)
6835 data
[cnt
] = byte_get (edata
+ cnt
* sizeof (short),
6840 for (cnt
= 0; cnt
< total
; cnt
+= 4)
6843 int check_def
, check_need
;
6846 printf (" %03x:", cnt
);
6848 for (j
= 0; (j
< 4) && (cnt
+ j
) < total
; ++j
)
6849 switch (data
[cnt
+ j
])
6852 fputs (_(" 0 (*local*) "), stdout
);
6856 fputs (_(" 1 (*global*) "), stdout
);
6860 nn
= printf ("%4x%c", data
[cnt
+ j
] & 0x7fff,
6861 data
[cnt
+ j
] & 0x8000 ? 'h' : ' ');
6865 if (symbols
[cnt
+ j
].st_shndx
>= elf_header
.e_shnum
6866 || section_headers
[symbols
[cnt
+ j
].st_shndx
].sh_type
6869 if (symbols
[cnt
+ j
].st_shndx
== SHN_UNDEF
)
6876 && version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)])
6878 Elf_Internal_Verneed ivn
;
6879 unsigned long offset
;
6881 offset
= offset_from_vma
6882 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
6883 sizeof (Elf_External_Verneed
));
6887 Elf_Internal_Vernaux ivna
;
6888 Elf_External_Verneed evn
;
6889 Elf_External_Vernaux evna
;
6890 unsigned long a_off
;
6892 get_data (&evn
, file
, offset
, sizeof (evn
), 1,
6895 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
6896 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
6898 a_off
= offset
+ ivn
.vn_aux
;
6902 get_data (&evna
, file
, a_off
, sizeof (evna
),
6903 1, _("version need aux (2)"));
6905 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
6906 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
6908 a_off
+= ivna
.vna_next
;
6910 while (ivna
.vna_other
!= data
[cnt
+ j
]
6911 && ivna
.vna_next
!= 0);
6913 if (ivna
.vna_other
== data
[cnt
+ j
])
6915 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
6917 if (ivna
.vna_name
>= string_sec
->sh_size
)
6918 name
= _("*invalid*");
6920 name
= strtab
+ ivna
.vna_name
;
6921 nn
+= printf ("(%s%-*s",
6923 12 - (int) strlen (name
),
6929 offset
+= ivn
.vn_next
;
6931 while (ivn
.vn_next
);
6934 if (check_def
&& data
[cnt
+ j
] != 0x8001
6935 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
6937 Elf_Internal_Verdef ivd
;
6938 Elf_External_Verdef evd
;
6939 unsigned long offset
;
6941 offset
= offset_from_vma
6942 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
6947 get_data (&evd
, file
, offset
, sizeof (evd
), 1,
6950 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
6951 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
6953 offset
+= ivd
.vd_next
;
6955 while (ivd
.vd_ndx
!= (data
[cnt
+ j
] & 0x7fff)
6956 && ivd
.vd_next
!= 0);
6958 if (ivd
.vd_ndx
== (data
[cnt
+ j
] & 0x7fff))
6960 Elf_External_Verdaux evda
;
6961 Elf_Internal_Verdaux ivda
;
6963 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
6965 get_data (&evda
, file
,
6966 offset
- ivd
.vd_next
+ ivd
.vd_aux
,
6968 _("version def aux"));
6970 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
6972 if (ivda
.vda_name
>= string_sec
->sh_size
)
6973 name
= _("*invalid*");
6975 name
= strtab
+ ivda
.vda_name
;
6976 nn
+= printf ("(%s%-*s",
6978 12 - (int) strlen (name
),
6984 printf ("%*c", 18 - nn
, ' ');
7002 printf (_("\nNo version information found in this file.\n"));
7008 get_symbol_binding (unsigned int binding
)
7010 static char buff
[32];
7014 case STB_LOCAL
: return "LOCAL";
7015 case STB_GLOBAL
: return "GLOBAL";
7016 case STB_WEAK
: return "WEAK";
7018 if (binding
>= STB_LOPROC
&& binding
<= STB_HIPROC
)
7019 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"),
7021 else if (binding
>= STB_LOOS
&& binding
<= STB_HIOS
)
7022 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), binding
);
7024 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), binding
);
7030 get_symbol_type (unsigned int type
)
7032 static char buff
[32];
7036 case STT_NOTYPE
: return "NOTYPE";
7037 case STT_OBJECT
: return "OBJECT";
7038 case STT_FUNC
: return "FUNC";
7039 case STT_SECTION
: return "SECTION";
7040 case STT_FILE
: return "FILE";
7041 case STT_COMMON
: return "COMMON";
7042 case STT_TLS
: return "TLS";
7043 case STT_RELC
: return "RELC";
7044 case STT_SRELC
: return "SRELC";
7046 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
7048 if (elf_header
.e_machine
== EM_ARM
&& type
== STT_ARM_TFUNC
)
7049 return "THUMB_FUNC";
7051 if (elf_header
.e_machine
== EM_SPARCV9
&& type
== STT_REGISTER
)
7054 if (elf_header
.e_machine
== EM_PARISC
&& type
== STT_PARISC_MILLI
)
7055 return "PARISC_MILLI";
7057 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"), type
);
7059 else if (type
>= STT_LOOS
&& type
<= STT_HIOS
)
7061 if (elf_header
.e_machine
== EM_PARISC
)
7063 if (type
== STT_HP_OPAQUE
)
7065 if (type
== STT_HP_STUB
)
7068 else if (elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_LINUX
7069 || elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_HURD
7070 /* GNU/Linux is still using the default value 0. */
7071 || elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_NONE
)
7073 if (type
== STT_IFUNC
)
7077 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), type
);
7080 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), type
);
7086 get_symbol_visibility (unsigned int visibility
)
7090 case STV_DEFAULT
: return "DEFAULT";
7091 case STV_INTERNAL
: return "INTERNAL";
7092 case STV_HIDDEN
: return "HIDDEN";
7093 case STV_PROTECTED
: return "PROTECTED";
7099 get_mips_symbol_other (unsigned int other
)
7103 case STO_OPTIONAL
: return "OPTIONAL";
7104 case STO_MIPS16
: return "MIPS16";
7105 case STO_MIPS_PLT
: return "MIPS PLT";
7106 case STO_MIPS_PIC
: return "MIPS PIC";
7107 default: return NULL
;
7112 get_symbol_other (unsigned int other
)
7114 const char * result
= NULL
;
7115 static char buff
[32];
7120 switch (elf_header
.e_machine
)
7123 result
= get_mips_symbol_other (other
);
7131 snprintf (buff
, sizeof buff
, _("<other>: %x"), other
);
7136 get_symbol_index_type (unsigned int type
)
7138 static char buff
[32];
7142 case SHN_UNDEF
: return "UND";
7143 case SHN_ABS
: return "ABS";
7144 case SHN_COMMON
: return "COM";
7146 if (type
== SHN_IA_64_ANSI_COMMON
7147 && elf_header
.e_machine
== EM_IA_64
7148 && elf_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
)
7150 else if (elf_header
.e_machine
== EM_X86_64
7151 && type
== SHN_X86_64_LCOMMON
)
7153 else if (type
== SHN_MIPS_SCOMMON
7154 && elf_header
.e_machine
== EM_MIPS
)
7156 else if (type
== SHN_MIPS_SUNDEFINED
7157 && elf_header
.e_machine
== EM_MIPS
)
7159 else if (type
>= SHN_LOPROC
&& type
<= SHN_HIPROC
)
7160 sprintf (buff
, "PRC[0x%04x]", type
& 0xffff);
7161 else if (type
>= SHN_LOOS
&& type
<= SHN_HIOS
)
7162 sprintf (buff
, "OS [0x%04x]", type
& 0xffff);
7163 else if (type
>= SHN_LORESERVE
)
7164 sprintf (buff
, "RSV[0x%04x]", type
& 0xffff);
7166 sprintf (buff
, "%3d", type
);
7174 get_dynamic_data (FILE *file
, unsigned int number
, unsigned int ent_size
)
7176 unsigned char *e_data
;
7179 e_data
= cmalloc (number
, ent_size
);
7183 error (_("Out of memory\n"));
7187 if (fread (e_data
, ent_size
, number
, file
) != number
)
7189 error (_("Unable to read in dynamic data\n"));
7193 i_data
= cmalloc (number
, sizeof (*i_data
));
7197 error (_("Out of memory\n"));
7203 i_data
[number
] = byte_get (e_data
+ number
* ent_size
, ent_size
);
7211 print_dynamic_symbol (bfd_vma si
, unsigned long hn
)
7213 Elf_Internal_Sym
*psym
;
7216 psym
= dynamic_symbols
+ si
;
7218 n
= print_vma (si
, DEC_5
);
7220 fputs (" " + n
, stdout
);
7221 printf (" %3lu: ", hn
);
7222 print_vma (psym
->st_value
, LONG_HEX
);
7224 print_vma (psym
->st_size
, DEC_5
);
7226 printf (" %6s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
7227 printf (" %6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
7228 printf (" %3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
7229 /* Check to see if any other bits in the st_other field are set.
7230 Note - displaying this information disrupts the layout of the
7231 table being generated, but for the moment this case is very
7233 if (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
))
7234 printf (" [%s] ", get_symbol_other (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
)));
7235 printf (" %3.3s ", get_symbol_index_type (psym
->st_shndx
));
7236 if (VALID_DYNAMIC_NAME (psym
->st_name
))
7237 print_symbol (25, GET_DYNAMIC_NAME (psym
->st_name
));
7239 printf (" <corrupt: %14ld>", psym
->st_name
);
7243 /* Dump the symbol table. */
7245 process_symbol_table (FILE *file
)
7247 Elf_Internal_Shdr
*section
;
7248 bfd_vma nbuckets
= 0;
7249 bfd_vma nchains
= 0;
7250 bfd_vma
*buckets
= NULL
;
7251 bfd_vma
*chains
= NULL
;
7252 bfd_vma ngnubuckets
= 0;
7253 bfd_vma
*gnubuckets
= NULL
;
7254 bfd_vma
*gnuchains
= NULL
;
7255 bfd_vma gnusymidx
= 0;
7257 if (! do_syms
&& !do_histogram
)
7260 if (dynamic_info
[DT_HASH
]
7262 || (do_using_dynamic
&& dynamic_strings
!= NULL
)))
7264 unsigned char nb
[8];
7265 unsigned char nc
[8];
7266 int hash_ent_size
= 4;
7268 if ((elf_header
.e_machine
== EM_ALPHA
7269 || elf_header
.e_machine
== EM_S390
7270 || elf_header
.e_machine
== EM_S390_OLD
)
7271 && elf_header
.e_ident
[EI_CLASS
] == ELFCLASS64
)
7275 (archive_file_offset
7276 + offset_from_vma (file
, dynamic_info
[DT_HASH
],
7277 sizeof nb
+ sizeof nc
)),
7280 error (_("Unable to seek to start of dynamic information\n"));
7284 if (fread (nb
, hash_ent_size
, 1, file
) != 1)
7286 error (_("Failed to read in number of buckets\n"));
7290 if (fread (nc
, hash_ent_size
, 1, file
) != 1)
7292 error (_("Failed to read in number of chains\n"));
7296 nbuckets
= byte_get (nb
, hash_ent_size
);
7297 nchains
= byte_get (nc
, hash_ent_size
);
7299 buckets
= get_dynamic_data (file
, nbuckets
, hash_ent_size
);
7300 chains
= get_dynamic_data (file
, nchains
, hash_ent_size
);
7302 if (buckets
== NULL
|| chains
== NULL
)
7306 if (dynamic_info_DT_GNU_HASH
7308 || (do_using_dynamic
&& dynamic_strings
!= NULL
)))
7310 unsigned char nb
[16];
7311 bfd_vma i
, maxchain
= 0xffffffff, bitmaskwords
;
7312 bfd_vma buckets_vma
;
7315 (archive_file_offset
7316 + offset_from_vma (file
, dynamic_info_DT_GNU_HASH
,
7320 error (_("Unable to seek to start of dynamic information\n"));
7324 if (fread (nb
, 16, 1, file
) != 1)
7326 error (_("Failed to read in number of buckets\n"));
7330 ngnubuckets
= byte_get (nb
, 4);
7331 gnusymidx
= byte_get (nb
+ 4, 4);
7332 bitmaskwords
= byte_get (nb
+ 8, 4);
7333 buckets_vma
= dynamic_info_DT_GNU_HASH
+ 16;
7335 buckets_vma
+= bitmaskwords
* 4;
7337 buckets_vma
+= bitmaskwords
* 8;
7340 (archive_file_offset
7341 + offset_from_vma (file
, buckets_vma
, 4)),
7344 error (_("Unable to seek to start of dynamic information\n"));
7348 gnubuckets
= get_dynamic_data (file
, ngnubuckets
, 4);
7350 if (gnubuckets
== NULL
)
7353 for (i
= 0; i
< ngnubuckets
; i
++)
7354 if (gnubuckets
[i
] != 0)
7356 if (gnubuckets
[i
] < gnusymidx
)
7359 if (maxchain
== 0xffffffff || gnubuckets
[i
] > maxchain
)
7360 maxchain
= gnubuckets
[i
];
7363 if (maxchain
== 0xffffffff)
7366 maxchain
-= gnusymidx
;
7369 (archive_file_offset
7370 + offset_from_vma (file
, buckets_vma
7371 + 4 * (ngnubuckets
+ maxchain
), 4)),
7374 error (_("Unable to seek to start of dynamic information\n"));
7380 if (fread (nb
, 4, 1, file
) != 1)
7382 error (_("Failed to determine last chain length\n"));
7386 if (maxchain
+ 1 == 0)
7391 while ((byte_get (nb
, 4) & 1) == 0);
7394 (archive_file_offset
7395 + offset_from_vma (file
, buckets_vma
+ 4 * ngnubuckets
, 4)),
7398 error (_("Unable to seek to start of dynamic information\n"));
7402 gnuchains
= get_dynamic_data (file
, maxchain
, 4);
7404 if (gnuchains
== NULL
)
7408 if ((dynamic_info
[DT_HASH
] || dynamic_info_DT_GNU_HASH
)
7411 && dynamic_strings
!= NULL
)
7415 if (dynamic_info
[DT_HASH
])
7419 printf (_("\nSymbol table for image:\n"));
7421 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7423 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7425 for (hn
= 0; hn
< nbuckets
; hn
++)
7430 for (si
= buckets
[hn
]; si
< nchains
&& si
> 0; si
= chains
[si
])
7431 print_dynamic_symbol (si
, hn
);
7435 if (dynamic_info_DT_GNU_HASH
)
7437 printf (_("\nSymbol table of `.gnu.hash' for image:\n"));
7439 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7441 printf (_(" Num Buc: Value Size Type Bind Vis Ndx Name\n"));
7443 for (hn
= 0; hn
< ngnubuckets
; ++hn
)
7444 if (gnubuckets
[hn
] != 0)
7446 bfd_vma si
= gnubuckets
[hn
];
7447 bfd_vma off
= si
- gnusymidx
;
7451 print_dynamic_symbol (si
, hn
);
7454 while ((gnuchains
[off
++] & 1) == 0);
7458 else if (do_syms
&& !do_using_dynamic
)
7462 for (i
= 0, section
= section_headers
;
7463 i
< elf_header
.e_shnum
;
7467 char *strtab
= NULL
;
7468 unsigned long int strtab_size
= 0;
7469 Elf_Internal_Sym
*symtab
;
7470 Elf_Internal_Sym
*psym
;
7473 if ( section
->sh_type
!= SHT_SYMTAB
7474 && section
->sh_type
!= SHT_DYNSYM
)
7477 printf (_("\nSymbol table '%s' contains %lu entries:\n"),
7478 SECTION_NAME (section
),
7479 (unsigned long) (section
->sh_size
/ section
->sh_entsize
));
7481 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
7483 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
7485 symtab
= GET_ELF_SYMBOLS (file
, section
);
7489 if (section
->sh_link
== elf_header
.e_shstrndx
)
7491 strtab
= string_table
;
7492 strtab_size
= string_table_length
;
7494 else if (section
->sh_link
< elf_header
.e_shnum
)
7496 Elf_Internal_Shdr
*string_sec
;
7498 string_sec
= section_headers
+ section
->sh_link
;
7500 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
,
7501 1, string_sec
->sh_size
, _("string table"));
7502 strtab_size
= strtab
!= NULL
? string_sec
->sh_size
: 0;
7505 for (si
= 0, psym
= symtab
;
7506 si
< section
->sh_size
/ section
->sh_entsize
;
7509 printf ("%6d: ", si
);
7510 print_vma (psym
->st_value
, LONG_HEX
);
7512 print_vma (psym
->st_size
, DEC_5
);
7513 printf (" %-7s", get_symbol_type (ELF_ST_TYPE (psym
->st_info
)));
7514 printf (" %-6s", get_symbol_binding (ELF_ST_BIND (psym
->st_info
)));
7515 printf (" %-3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym
->st_other
)));
7516 /* Check to see if any other bits in the st_other field are set.
7517 Note - displaying this information disrupts the layout of the
7518 table being generated, but for the moment this case is very rare. */
7519 if (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
))
7520 printf (" [%s] ", get_symbol_other (psym
->st_other
^ ELF_ST_VISIBILITY (psym
->st_other
)));
7521 printf (" %4s ", get_symbol_index_type (psym
->st_shndx
));
7522 print_symbol (25, psym
->st_name
< strtab_size
7523 ? strtab
+ psym
->st_name
: "<corrupt>");
7525 if (section
->sh_type
== SHT_DYNSYM
&&
7526 version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] != 0)
7528 unsigned char data
[2];
7529 unsigned short vers_data
;
7530 unsigned long offset
;
7534 offset
= offset_from_vma
7535 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
7536 sizeof data
+ si
* sizeof (vers_data
));
7538 get_data (&data
, file
, offset
+ si
* sizeof (vers_data
),
7539 sizeof (data
), 1, _("version data"));
7541 vers_data
= byte_get (data
, 2);
7543 is_nobits
= (psym
->st_shndx
< elf_header
.e_shnum
7544 && section_headers
[psym
->st_shndx
].sh_type
7547 check_def
= (psym
->st_shndx
!= SHN_UNDEF
);
7549 if ((vers_data
& 0x8000) || vers_data
> 1)
7551 if (version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)]
7552 && (is_nobits
|| ! check_def
))
7554 Elf_External_Verneed evn
;
7555 Elf_Internal_Verneed ivn
;
7556 Elf_Internal_Vernaux ivna
;
7558 /* We must test both. */
7559 offset
= offset_from_vma
7560 (file
, version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
7565 unsigned long vna_off
;
7567 get_data (&evn
, file
, offset
, sizeof (evn
), 1,
7570 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
7571 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
7573 vna_off
= offset
+ ivn
.vn_aux
;
7577 Elf_External_Vernaux evna
;
7579 get_data (&evna
, file
, vna_off
,
7581 _("version need aux (3)"));
7583 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
7584 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
7585 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
7587 vna_off
+= ivna
.vna_next
;
7589 while (ivna
.vna_other
!= vers_data
7590 && ivna
.vna_next
!= 0);
7592 if (ivna
.vna_other
== vers_data
)
7595 offset
+= ivn
.vn_next
;
7597 while (ivn
.vn_next
!= 0);
7599 if (ivna
.vna_other
== vers_data
)
7602 ivna
.vna_name
< strtab_size
7603 ? strtab
+ ivna
.vna_name
: "<corrupt>",
7607 else if (! is_nobits
)
7608 error (_("bad dynamic symbol\n"));
7615 if (vers_data
!= 0x8001
7616 && version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
7618 Elf_Internal_Verdef ivd
;
7619 Elf_Internal_Verdaux ivda
;
7620 Elf_External_Verdaux evda
;
7621 unsigned long offset
;
7623 offset
= offset_from_vma
7625 version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
7626 sizeof (Elf_External_Verdef
));
7630 Elf_External_Verdef evd
;
7632 get_data (&evd
, file
, offset
, sizeof (evd
),
7633 1, _("version def"));
7635 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
7636 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
7637 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
7639 offset
+= ivd
.vd_next
;
7641 while (ivd
.vd_ndx
!= (vers_data
& 0x7fff)
7642 && ivd
.vd_next
!= 0);
7644 offset
-= ivd
.vd_next
;
7645 offset
+= ivd
.vd_aux
;
7647 get_data (&evda
, file
, offset
, sizeof (evda
),
7648 1, _("version def aux"));
7650 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
7652 if (psym
->st_name
!= ivda
.vda_name
)
7653 printf ((vers_data
& 0x8000)
7655 ivda
.vda_name
< strtab_size
7656 ? strtab
+ ivda
.vda_name
: "<corrupt>");
7666 if (strtab
!= string_table
)
7672 (_("\nDynamic symbol information is not available for displaying symbols.\n"));
7674 if (do_histogram
&& buckets
!= NULL
)
7676 unsigned long *lengths
;
7677 unsigned long *counts
;
7680 unsigned long maxlength
= 0;
7681 unsigned long nzero_counts
= 0;
7682 unsigned long nsyms
= 0;
7684 printf (_("\nHistogram for bucket list length (total of %lu buckets):\n"),
7685 (unsigned long) nbuckets
);
7686 printf (_(" Length Number %% of total Coverage\n"));
7688 lengths
= calloc (nbuckets
, sizeof (*lengths
));
7689 if (lengths
== NULL
)
7691 error (_("Out of memory\n"));
7694 for (hn
= 0; hn
< nbuckets
; ++hn
)
7696 for (si
= buckets
[hn
]; si
> 0 && si
< nchains
; si
= chains
[si
])
7699 if (maxlength
< ++lengths
[hn
])
7704 counts
= calloc (maxlength
+ 1, sizeof (*counts
));
7707 error (_("Out of memory\n"));
7711 for (hn
= 0; hn
< nbuckets
; ++hn
)
7712 ++counts
[lengths
[hn
]];
7717 printf (" 0 %-10lu (%5.1f%%)\n",
7718 counts
[0], (counts
[0] * 100.0) / nbuckets
);
7719 for (i
= 1; i
<= maxlength
; ++i
)
7721 nzero_counts
+= counts
[i
] * i
;
7722 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
7723 i
, counts
[i
], (counts
[i
] * 100.0) / nbuckets
,
7724 (nzero_counts
* 100.0) / nsyms
);
7732 if (buckets
!= NULL
)
7738 if (do_histogram
&& dynamic_info_DT_GNU_HASH
)
7740 unsigned long *lengths
;
7741 unsigned long *counts
;
7743 unsigned long maxlength
= 0;
7744 unsigned long nzero_counts
= 0;
7745 unsigned long nsyms
= 0;
7747 lengths
= calloc (ngnubuckets
, sizeof (*lengths
));
7748 if (lengths
== NULL
)
7750 error (_("Out of memory\n"));
7754 printf (_("\nHistogram for `.gnu.hash' bucket list length (total of %lu buckets):\n"),
7755 (unsigned long) ngnubuckets
);
7756 printf (_(" Length Number %% of total Coverage\n"));
7758 for (hn
= 0; hn
< ngnubuckets
; ++hn
)
7759 if (gnubuckets
[hn
] != 0)
7761 bfd_vma off
, length
= 1;
7763 for (off
= gnubuckets
[hn
] - gnusymidx
;
7764 (gnuchains
[off
] & 1) == 0; ++off
)
7766 lengths
[hn
] = length
;
7767 if (length
> maxlength
)
7772 counts
= calloc (maxlength
+ 1, sizeof (*counts
));
7775 error (_("Out of memory\n"));
7779 for (hn
= 0; hn
< ngnubuckets
; ++hn
)
7780 ++counts
[lengths
[hn
]];
7782 if (ngnubuckets
> 0)
7785 printf (" 0 %-10lu (%5.1f%%)\n",
7786 counts
[0], (counts
[0] * 100.0) / ngnubuckets
);
7787 for (j
= 1; j
<= maxlength
; ++j
)
7789 nzero_counts
+= counts
[j
] * j
;
7790 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
7791 j
, counts
[j
], (counts
[j
] * 100.0) / ngnubuckets
,
7792 (nzero_counts
* 100.0) / nsyms
);
7806 process_syminfo (FILE *file ATTRIBUTE_UNUSED
)
7810 if (dynamic_syminfo
== NULL
7812 /* No syminfo, this is ok. */
7815 /* There better should be a dynamic symbol section. */
7816 if (dynamic_symbols
== NULL
|| dynamic_strings
== NULL
)
7820 printf (_("\nDynamic info segment at offset 0x%lx contains %d entries:\n"),
7821 dynamic_syminfo_offset
, dynamic_syminfo_nent
);
7823 printf (_(" Num: Name BoundTo Flags\n"));
7824 for (i
= 0; i
< dynamic_syminfo_nent
; ++i
)
7826 unsigned short int flags
= dynamic_syminfo
[i
].si_flags
;
7828 printf ("%4d: ", i
);
7829 if (VALID_DYNAMIC_NAME (dynamic_symbols
[i
].st_name
))
7830 print_symbol (30, GET_DYNAMIC_NAME (dynamic_symbols
[i
].st_name
));
7832 printf ("<corrupt: %19ld>", dynamic_symbols
[i
].st_name
);
7835 switch (dynamic_syminfo
[i
].si_boundto
)
7837 case SYMINFO_BT_SELF
:
7838 fputs ("SELF ", stdout
);
7840 case SYMINFO_BT_PARENT
:
7841 fputs ("PARENT ", stdout
);
7844 if (dynamic_syminfo
[i
].si_boundto
> 0
7845 && dynamic_syminfo
[i
].si_boundto
< dynamic_nent
7846 && VALID_DYNAMIC_NAME (dynamic_section
[dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
))
7848 print_symbol (10, GET_DYNAMIC_NAME (dynamic_section
[dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
));
7852 printf ("%-10d ", dynamic_syminfo
[i
].si_boundto
);
7856 if (flags
& SYMINFO_FLG_DIRECT
)
7858 if (flags
& SYMINFO_FLG_PASSTHRU
)
7859 printf (" PASSTHRU");
7860 if (flags
& SYMINFO_FLG_COPY
)
7862 if (flags
& SYMINFO_FLG_LAZYLOAD
)
7863 printf (" LAZYLOAD");
7871 #ifdef SUPPORT_DISASSEMBLY
7873 disassemble_section (Elf_Internal_Shdr
*section
, FILE *file
)
7875 printf (_("\nAssembly dump of section %s\n"),
7876 SECTION_NAME (section
));
7878 /* XXX -- to be done --- XXX */
7885 dump_section_as_strings (Elf_Internal_Shdr
*section
, FILE *file
)
7887 Elf_Internal_Shdr
*relsec
;
7888 bfd_size_type num_bytes
;
7893 char *name
= SECTION_NAME (section
);
7894 bfd_boolean some_strings_shown
;
7896 num_bytes
= section
->sh_size
;
7898 if (num_bytes
== 0 || section
->sh_type
== SHT_NOBITS
)
7900 printf (_("\nSection '%s' has no data to dump.\n"), name
);
7904 addr
= section
->sh_addr
;
7906 start
= get_data (NULL
, file
, section
->sh_offset
, 1, num_bytes
,
7911 printf (_("\nString dump of section '%s':\n"), name
);
7913 /* If the section being dumped has relocations against it the user might
7914 be expecting these relocations to have been applied. Check for this
7915 case and issue a warning message in order to avoid confusion.
7916 FIXME: Maybe we ought to have an option that dumps a section with
7918 for (relsec
= section_headers
;
7919 relsec
< section_headers
+ elf_header
.e_shnum
;
7922 if ((relsec
->sh_type
!= SHT_RELA
&& relsec
->sh_type
!= SHT_REL
)
7923 || relsec
->sh_info
>= elf_header
.e_shnum
7924 || section_headers
+ relsec
->sh_info
!= section
7925 || relsec
->sh_size
== 0
7926 || relsec
->sh_link
>= elf_header
.e_shnum
)
7929 printf (_(" Note: This section has relocations against it, but these have NOT been applied to this dump.\n"));
7934 end
= start
+ num_bytes
;
7935 some_strings_shown
= FALSE
;
7939 while (!ISPRINT (* data
))
7946 printf (" [%6tx] %s\n", data
- start
, data
);
7948 printf (" [%6Ix] %s\n", (size_t) (data
- start
), data
);
7950 data
+= strlen (data
);
7951 some_strings_shown
= TRUE
;
7955 if (! some_strings_shown
)
7956 printf (_(" No strings found in this section."));
7966 dump_section_as_bytes (Elf_Internal_Shdr
*section
, FILE *file
)
7968 Elf_Internal_Shdr
*relsec
;
7969 bfd_size_type bytes
;
7971 unsigned char *data
;
7972 unsigned char *start
;
7974 bytes
= section
->sh_size
;
7976 if (bytes
== 0 || section
->sh_type
== SHT_NOBITS
)
7978 printf (_("\nSection '%s' has no data to dump.\n"),
7979 SECTION_NAME (section
));
7983 printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section
));
7985 addr
= section
->sh_addr
;
7987 start
= get_data (NULL
, file
, section
->sh_offset
, 1, bytes
,
7992 /* If the section being dumped has relocations against it the user might
7993 be expecting these relocations to have been applied. Check for this
7994 case and issue a warning message in order to avoid confusion.
7995 FIXME: Maybe we ought to have an option that dumps a section with
7997 for (relsec
= section_headers
;
7998 relsec
< section_headers
+ elf_header
.e_shnum
;
8001 if ((relsec
->sh_type
!= SHT_RELA
&& relsec
->sh_type
!= SHT_REL
)
8002 || relsec
->sh_info
>= elf_header
.e_shnum
8003 || section_headers
+ relsec
->sh_info
!= section
8004 || relsec
->sh_size
== 0
8005 || relsec
->sh_link
>= elf_header
.e_shnum
)
8008 printf (_(" NOTE: This section has relocations against it, but these have NOT been applied to this dump.\n"));
8020 lbytes
= (bytes
> 16 ? 16 : bytes
);
8022 printf (" 0x%8.8lx ", (unsigned long) addr
);
8024 for (j
= 0; j
< 16; j
++)
8027 printf ("%2.2x", data
[j
]);
8035 for (j
= 0; j
< lbytes
; j
++)
8038 if (k
>= ' ' && k
< 0x7f)
8057 /* Returns TRUE iff RELOC_TYPE is a 32-bit absolute RELA relocation used in
8058 DWARF debug sections. This is a target specific test. Note - we do not
8059 go through the whole including-target-headers-multiple-times route, (as
8060 we have already done with <elf/h8.h>) because this would become very
8061 messy and even then this function would have to contain target specific
8062 information (the names of the relocs instead of their numeric values).
8063 FIXME: This is not the correct way to solve this problem. The proper way
8064 is to have target specific reloc sizing and typing functions created by
8065 the reloc-macros.h header, in the same way that it already creates the
8066 reloc naming functions. */
8069 is_32bit_abs_reloc (unsigned int reloc_type
)
8071 switch (elf_header
.e_machine
)
8075 return reloc_type
== 1; /* R_386_32. */
8077 return reloc_type
== 1; /* R_68K_32. */
8079 return reloc_type
== 1; /* R_860_32. */
8081 return reloc_type
== 1; /* XXX Is this right ? */
8083 return reloc_type
== 1; /* R_ARC_32. */
8085 return reloc_type
== 2; /* R_ARM_ABS32 */
8088 return reloc_type
== 1;
8090 return reloc_type
== 0x12; /* R_byte4_data. */
8092 return reloc_type
== 3; /* R_CRIS_32. */
8095 return reloc_type
== 3; /* R_CR16_NUM32. */
8097 return reloc_type
== 15; /* R_CRX_NUM32. */
8099 return reloc_type
== 1;
8100 case EM_CYGNUS_D10V
:
8102 return reloc_type
== 6; /* R_D10V_32. */
8103 case EM_CYGNUS_D30V
:
8105 return reloc_type
== 12; /* R_D30V_32_NORMAL. */
8107 return reloc_type
== 3; /* R_DLX_RELOC_32. */
8108 case EM_CYGNUS_FR30
:
8110 return reloc_type
== 3; /* R_FR30_32. */
8114 return reloc_type
== 1; /* R_H8_DIR32. */
8116 return reloc_type
== 0x65; /* R_IA64_SECREL32LSB. */
8119 return reloc_type
== 2; /* R_IP2K_32. */
8121 return reloc_type
== 2; /* R_IQ2000_32. */
8124 return reloc_type
== 3; /* R_M32C_32. */
8126 return reloc_type
== 34; /* R_M32R_32_RELA. */
8128 return reloc_type
== 1; /* R_MCORE_ADDR32. */
8130 return reloc_type
== 4; /* R_MEP_32. */
8132 return reloc_type
== 2; /* R_MIPS_32. */
8134 return reloc_type
== 4; /* R_MMIX_32. */
8135 case EM_CYGNUS_MN10200
:
8137 return reloc_type
== 1; /* R_MN10200_32. */
8138 case EM_CYGNUS_MN10300
:
8140 return reloc_type
== 1; /* R_MN10300_32. */
8143 return reloc_type
== 1; /* R_MSP43_32. */
8145 return reloc_type
== 2; /* R_MT_32. */
8146 case EM_ALTERA_NIOS2
:
8148 return reloc_type
== 1; /* R_NIOS_32. */
8151 return reloc_type
== 1; /* R_OR32_32. */
8153 return reloc_type
== 1; /* R_PARISC_DIR32. */
8156 return reloc_type
== 1; /* R_PJ_DATA_DIR32. */
8158 return reloc_type
== 1; /* R_PPC64_ADDR32. */
8160 return reloc_type
== 1; /* R_PPC_ADDR32. */
8162 return reloc_type
== 1; /* R_I370_ADDR31. */
8165 return reloc_type
== 4; /* R_S390_32. */
8167 return reloc_type
== 8; /* R_SCORE_ABS32. */
8169 return reloc_type
== 1; /* R_SH_DIR32. */
8170 case EM_SPARC32PLUS
:
8173 return reloc_type
== 3 /* R_SPARC_32. */
8174 || reloc_type
== 23; /* R_SPARC_UA32. */
8176 return reloc_type
== 6; /* R_SPU_ADDR32 */
8177 case EM_CYGNUS_V850
:
8179 return reloc_type
== 6; /* R_V850_ABS32. */
8181 return reloc_type
== 1; /* R_VAX_32. */
8183 return reloc_type
== 10; /* R_X86_64_32. */
8185 return reloc_type
== 1; /* R_XSTROMY16_32. */
8188 return reloc_type
== 1; /* R_XTENSA_32. */
8191 error (_("Missing knowledge of 32-bit reloc types used in DWARF sections of machine number %d\n"),
8192 elf_header
.e_machine
);
8197 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
8198 a 32-bit pc-relative RELA relocation used in DWARF debug sections. */
8201 is_32bit_pcrel_reloc (unsigned int reloc_type
)
8203 switch (elf_header
.e_machine
)
8207 return reloc_type
== 2; /* R_386_PC32. */
8209 return reloc_type
== 4; /* R_68K_PC32. */
8211 return reloc_type
== 10; /* R_ALPHA_SREL32. */
8213 return reloc_type
== 3; /* R_ARM_REL32 */
8215 return reloc_type
== 9; /* R_PARISC_PCREL32. */
8217 return reloc_type
== 26; /* R_PPC_REL32. */
8219 return reloc_type
== 26; /* R_PPC64_REL32. */
8222 return reloc_type
== 5; /* R_390_PC32. */
8224 return reloc_type
== 2; /* R_SH_REL32. */
8225 case EM_SPARC32PLUS
:
8228 return reloc_type
== 6; /* R_SPARC_DISP32. */
8230 return reloc_type
== 13; /* R_SPU_REL32. */
8232 return reloc_type
== 2; /* R_X86_64_PC32. */
8235 return reloc_type
== 14; /* R_XTENSA_32_PCREL. */
8237 /* Do not abort or issue an error message here. Not all targets use
8238 pc-relative 32-bit relocs in their DWARF debug information and we
8239 have already tested for target coverage in is_32bit_abs_reloc. A
8240 more helpful warning message will be generated by
8241 debug_apply_relocations anyway, so just return. */
8246 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
8247 a 64-bit absolute RELA relocation used in DWARF debug sections. */
8250 is_64bit_abs_reloc (unsigned int reloc_type
)
8252 switch (elf_header
.e_machine
)
8255 return reloc_type
== 2; /* R_ALPHA_REFQUAD. */
8257 return reloc_type
== 0x27; /* R_IA64_DIR64LSB. */
8259 return reloc_type
== 80; /* R_PARISC_DIR64. */
8261 return reloc_type
== 38; /* R_PPC64_ADDR64. */
8262 case EM_SPARC32PLUS
:
8265 return reloc_type
== 54; /* R_SPARC_UA64. */
8267 return reloc_type
== 1; /* R_X86_64_64. */
8270 return reloc_type
== 22; /* R_S390_64 */
8272 return reloc_type
== 18; /* R_MIPS_64 */
8278 /* Like is_32bit_pcrel_reloc except that it returns TRUE iff RELOC_TYPE is
8279 a 64-bit pc-relative RELA relocation used in DWARF debug sections. */
8282 is_64bit_pcrel_reloc (unsigned int reloc_type
)
8284 switch (elf_header
.e_machine
)
8287 return reloc_type
== 11; /* R_ALPHA_SREL64 */
8289 return reloc_type
== 0x4f; /* R_IA64_PCREL64LSB */
8291 return reloc_type
== 72; /* R_PARISC_PCREL64 */
8293 return reloc_type
== 44; /* R_PPC64_REL64 */
8294 case EM_SPARC32PLUS
:
8297 return reloc_type
== 46; /* R_SPARC_DISP64 */
8299 return reloc_type
== 24; /* R_X86_64_PC64 */
8302 return reloc_type
== 23; /* R_S390_PC64 */
8308 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
8309 a 16-bit absolute RELA relocation used in DWARF debug sections. */
8312 is_16bit_abs_reloc (unsigned int reloc_type
)
8314 switch (elf_header
.e_machine
)
8318 return reloc_type
== 4; /* R_AVR_16. */
8319 case EM_CYGNUS_D10V
:
8321 return reloc_type
== 3; /* R_D10V_16. */
8325 return reloc_type
== R_H8_DIR16
;
8328 return reloc_type
== 1; /* R_IP2K_16. */
8331 return reloc_type
== 1; /* R_M32C_16 */
8334 return reloc_type
== 5; /* R_MSP430_16_BYTE. */
8335 case EM_ALTERA_NIOS2
:
8337 return reloc_type
== 9; /* R_NIOS_16. */
8343 /* Returns TRUE iff RELOC_TYPE is a NONE relocation used for discarded
8344 relocation entries (possibly formerly used for SHT_GROUP sections). */
8347 is_none_reloc (unsigned int reloc_type
)
8349 switch (elf_header
.e_machine
)
8351 case EM_68K
: /* R_68K_NONE. */
8352 case EM_386
: /* R_386_NONE. */
8353 case EM_SPARC32PLUS
:
8355 case EM_SPARC
: /* R_SPARC_NONE. */
8356 case EM_MIPS
: /* R_MIPS_NONE. */
8357 case EM_PARISC
: /* R_PARISC_NONE. */
8358 case EM_ALPHA
: /* R_ALPHA_NONE. */
8359 case EM_PPC
: /* R_PPC_NONE. */
8360 case EM_PPC64
: /* R_PPC64_NONE. */
8361 case EM_ARM
: /* R_ARM_NONE. */
8362 case EM_IA_64
: /* R_IA64_NONE. */
8363 case EM_SH
: /* R_SH_NONE. */
8365 case EM_S390
: /* R_390_NONE. */
8366 case EM_CRIS
: /* R_CRIS_NONE. */
8367 case EM_X86_64
: /* R_X86_64_NONE. */
8368 case EM_MN10300
: /* R_MN10300_NONE. */
8369 case EM_M32R
: /* R_M32R_NONE. */
8370 return reloc_type
== 0;
8375 /* Uncompresses a section that was compressed using zlib, in place.
8376 This is a copy of bfd_uncompress_section_contents, in bfd/compress.c */
8379 uncompress_section_contents (unsigned char **buffer
, dwarf_size_type
*size
)
8382 /* These are just to quiet gcc. */
8387 dwarf_size_type compressed_size
= *size
;
8388 unsigned char * compressed_buffer
= *buffer
;
8389 dwarf_size_type uncompressed_size
;
8390 unsigned char * uncompressed_buffer
;
8393 dwarf_size_type header_size
= 12;
8395 /* Read the zlib header. In this case, it should be "ZLIB" followed
8396 by the uncompressed section size, 8 bytes in big-endian order. */
8397 if (compressed_size
< header_size
8398 || ! streq ((char *) compressed_buffer
, "ZLIB"))
8401 uncompressed_size
= compressed_buffer
[4]; uncompressed_size
<<= 8;
8402 uncompressed_size
+= compressed_buffer
[5]; uncompressed_size
<<= 8;
8403 uncompressed_size
+= compressed_buffer
[6]; uncompressed_size
<<= 8;
8404 uncompressed_size
+= compressed_buffer
[7]; uncompressed_size
<<= 8;
8405 uncompressed_size
+= compressed_buffer
[8]; uncompressed_size
<<= 8;
8406 uncompressed_size
+= compressed_buffer
[9]; uncompressed_size
<<= 8;
8407 uncompressed_size
+= compressed_buffer
[10]; uncompressed_size
<<= 8;
8408 uncompressed_size
+= compressed_buffer
[11];
8410 /* It is possible the section consists of several compressed
8411 buffers concatenated together, so we uncompress in a loop. */
8415 strm
.avail_in
= compressed_size
- header_size
;
8416 strm
.next_in
= (Bytef
*) compressed_buffer
+ header_size
;
8417 strm
.avail_out
= uncompressed_size
;
8418 uncompressed_buffer
= xmalloc (uncompressed_size
);
8420 rc
= inflateInit (& strm
);
8421 while (strm
.avail_in
> 0)
8425 strm
.next_out
= ((Bytef
*) uncompressed_buffer
8426 + (uncompressed_size
- strm
.avail_out
));
8427 rc
= inflate (&strm
, Z_FINISH
);
8428 if (rc
!= Z_STREAM_END
)
8430 rc
= inflateReset (& strm
);
8432 rc
= inflateEnd (& strm
);
8434 || strm
.avail_out
!= 0)
8437 free (compressed_buffer
);
8438 *buffer
= uncompressed_buffer
;
8439 *size
= uncompressed_size
;
8443 free (uncompressed_buffer
);
8445 #endif /* HAVE_ZLIB_H */
8448 /* Apply relocations to a debug section. */
8451 debug_apply_relocations (void *file
,
8452 Elf_Internal_Shdr
*section
,
8453 unsigned char *start
)
8455 Elf_Internal_Shdr
*relsec
;
8456 unsigned char *end
= start
+ section
->sh_size
;
8458 if (elf_header
.e_type
!= ET_REL
)
8461 /* Find the reloc section associated with the debug section. */
8462 for (relsec
= section_headers
;
8463 relsec
< section_headers
+ elf_header
.e_shnum
;
8466 bfd_boolean is_rela
;
8467 unsigned long num_relocs
;
8468 Elf_Internal_Rela
*relocs
, *rp
;
8469 Elf_Internal_Shdr
*symsec
;
8470 Elf_Internal_Sym
*symtab
;
8471 Elf_Internal_Sym
*sym
;
8473 if ((relsec
->sh_type
!= SHT_RELA
&& relsec
->sh_type
!= SHT_REL
)
8474 || relsec
->sh_info
>= elf_header
.e_shnum
8475 || section_headers
+ relsec
->sh_info
!= section
8476 || relsec
->sh_size
== 0
8477 || relsec
->sh_link
>= elf_header
.e_shnum
)
8480 is_rela
= relsec
->sh_type
== SHT_RELA
;
8484 if (!slurp_rela_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
8485 & relocs
, & num_relocs
))
8490 if (!slurp_rel_relocs (file
, relsec
->sh_offset
, relsec
->sh_size
,
8491 & relocs
, & num_relocs
))
8495 /* SH uses RELA but uses in place value instead of the addend field. */
8496 if (elf_header
.e_machine
== EM_SH
)
8499 symsec
= section_headers
+ relsec
->sh_link
;
8500 symtab
= GET_ELF_SYMBOLS (file
, symsec
);
8502 for (rp
= relocs
; rp
< relocs
+ num_relocs
; ++rp
)
8505 unsigned int reloc_type
;
8506 unsigned int reloc_size
;
8507 unsigned char * loc
;
8509 reloc_type
= get_reloc_type (rp
->r_info
);
8511 if (is_none_reloc (reloc_type
))
8514 if (is_32bit_abs_reloc (reloc_type
)
8515 || is_32bit_pcrel_reloc (reloc_type
))
8517 else if (is_64bit_abs_reloc (reloc_type
)
8518 || is_64bit_pcrel_reloc (reloc_type
))
8520 else if (is_16bit_abs_reloc (reloc_type
))
8524 warn (_("unable to apply unsupported reloc type %d to section %s\n"),
8525 reloc_type
, SECTION_NAME (section
));
8529 loc
= start
+ rp
->r_offset
;
8530 if ((loc
+ reloc_size
) > end
)
8532 warn (_("skipping invalid relocation offset 0x%lx in section %s\n"),
8533 (unsigned long) rp
->r_offset
,
8534 SECTION_NAME (section
));
8538 sym
= symtab
+ get_reloc_symindex (rp
->r_info
);
8540 /* If the reloc has a symbol associated with it,
8541 make sure that it is of an appropriate type. */
8543 && ELF_ST_TYPE (sym
->st_info
) != STT_SECTION
8544 /* Relocations against symbols without type can happen.
8545 Gcc -feliminate-dwarf2-dups may generate symbols
8546 without type for debug info. */
8547 && ELF_ST_TYPE (sym
->st_info
) != STT_NOTYPE
8548 /* Relocations against object symbols can happen,
8549 eg when referencing a global array. For an
8550 example of this see the _clz.o binary in libgcc.a. */
8551 && ELF_ST_TYPE (sym
->st_info
) != STT_OBJECT
)
8553 warn (_("skipping unexpected symbol type %s in %ld'th relocation in section %s\n"),
8554 get_symbol_type (ELF_ST_TYPE (sym
->st_info
)),
8555 (long int)(rp
- relocs
),
8556 SECTION_NAME (relsec
));
8560 addend
= is_rela
? rp
->r_addend
: byte_get (loc
, reloc_size
);
8562 if (is_32bit_pcrel_reloc (reloc_type
)
8563 || is_64bit_pcrel_reloc (reloc_type
))
8565 /* On HPPA, all pc-relative relocations are biased by 8. */
8566 if (elf_header
.e_machine
== EM_PARISC
)
8568 byte_put (loc
, (addend
+ sym
->st_value
) - rp
->r_offset
,
8572 byte_put (loc
, addend
+ sym
->st_value
, reloc_size
);
8582 load_specific_debug_section (enum dwarf_section_display_enum debug
,
8583 Elf_Internal_Shdr
*sec
, void *file
)
8585 struct dwarf_section
*section
= &debug_displays
[debug
].section
;
8587 int section_is_compressed
;
8589 /* If it is already loaded, do nothing. */
8590 if (section
->start
!= NULL
)
8593 section_is_compressed
= section
->name
== section
->compressed_name
;
8595 snprintf (buf
, sizeof (buf
), _("%s section data"), section
->name
);
8596 section
->address
= sec
->sh_addr
;
8597 section
->size
= sec
->sh_size
;
8598 section
->start
= get_data (NULL
, file
, sec
->sh_offset
, 1,
8600 if (section
->start
== NULL
)
8603 if (section_is_compressed
)
8604 if (! uncompress_section_contents (§ion
->start
, §ion
->size
))
8607 if (debug_displays
[debug
].relocate
)
8608 debug_apply_relocations (file
, sec
, section
->start
);
8614 load_debug_section (enum dwarf_section_display_enum debug
, void *file
)
8616 struct dwarf_section
*section
= &debug_displays
[debug
].section
;
8617 Elf_Internal_Shdr
*sec
;
8619 /* Locate the debug section. */
8620 sec
= find_section (section
->uncompressed_name
);
8622 section
->name
= section
->uncompressed_name
;
8625 sec
= find_section (section
->compressed_name
);
8627 section
->name
= section
->compressed_name
;
8632 return load_specific_debug_section (debug
, sec
, file
);
8636 free_debug_section (enum dwarf_section_display_enum debug
)
8638 struct dwarf_section
*section
= &debug_displays
[debug
].section
;
8640 if (section
->start
== NULL
)
8643 free ((char *) section
->start
);
8644 section
->start
= NULL
;
8645 section
->address
= 0;
8650 display_debug_section (Elf_Internal_Shdr
*section
, FILE *file
)
8652 char *name
= SECTION_NAME (section
);
8653 bfd_size_type length
;
8655 enum dwarf_section_display_enum i
;
8657 length
= section
->sh_size
;
8660 printf (_("\nSection '%s' has no debugging data.\n"), name
);
8664 if (const_strneq (name
, ".gnu.linkonce.wi."))
8665 name
= ".debug_info";
8667 /* See if we know how to display the contents of this section. */
8668 for (i
= 0; i
< max
; i
++)
8669 if (streq (debug_displays
[i
].section
.uncompressed_name
, name
)
8670 || streq (debug_displays
[i
].section
.compressed_name
, name
))
8672 struct dwarf_section
*sec
= &debug_displays
[i
].section
;
8673 int secondary
= (section
!= find_section (name
));
8676 free_debug_section (i
);
8678 if (streq (debug_displays
[i
].section
.uncompressed_name
, name
))
8679 sec
->name
= sec
->uncompressed_name
;
8681 sec
->name
= sec
->compressed_name
;
8682 if (load_specific_debug_section (i
, section
, file
))
8684 result
&= debug_displays
[i
].display (sec
, file
);
8686 if (secondary
|| (i
!= info
&& i
!= abbrev
))
8687 free_debug_section (i
);
8695 printf (_("Unrecognized debug section: %s\n"), name
);
8702 /* Set DUMP_SECTS for all sections where dumps were requested
8703 based on section name. */
8706 initialise_dumps_byname (void)
8708 struct dump_list_entry
*cur
;
8710 for (cur
= dump_sects_byname
; cur
; cur
= cur
->next
)
8715 for (i
= 0, any
= 0; i
< elf_header
.e_shnum
; i
++)
8716 if (streq (SECTION_NAME (section_headers
+ i
), cur
->name
))
8718 request_dump_bynumber (i
, cur
->type
);
8723 warn (_("Section '%s' was not dumped because it does not exist!\n"),
8729 process_section_contents (FILE *file
)
8731 Elf_Internal_Shdr
*section
;
8737 initialise_dumps_byname ();
8739 for (i
= 0, section
= section_headers
;
8740 i
< elf_header
.e_shnum
&& i
< num_dump_sects
;
8743 #ifdef SUPPORT_DISASSEMBLY
8744 if (dump_sects
[i
] & DISASS_DUMP
)
8745 disassemble_section (section
, file
);
8747 if (dump_sects
[i
] & HEX_DUMP
)
8748 dump_section_as_bytes (section
, file
);
8750 if (dump_sects
[i
] & DEBUG_DUMP
)
8751 display_debug_section (section
, file
);
8753 if (dump_sects
[i
] & STRING_DUMP
)
8754 dump_section_as_strings (section
, file
);
8757 /* Check to see if the user requested a
8758 dump of a section that does not exist. */
8759 while (i
++ < num_dump_sects
)
8761 warn (_("Section %d was not dumped because it does not exist!\n"), i
);
8765 process_mips_fpe_exception (int mask
)
8770 if (mask
& OEX_FPU_INEX
)
8771 fputs ("INEX", stdout
), first
= 0;
8772 if (mask
& OEX_FPU_UFLO
)
8773 printf ("%sUFLO", first
? "" : "|"), first
= 0;
8774 if (mask
& OEX_FPU_OFLO
)
8775 printf ("%sOFLO", first
? "" : "|"), first
= 0;
8776 if (mask
& OEX_FPU_DIV0
)
8777 printf ("%sDIV0", first
? "" : "|"), first
= 0;
8778 if (mask
& OEX_FPU_INVAL
)
8779 printf ("%sINVAL", first
? "" : "|");
8782 fputs ("0", stdout
);
8785 /* ARM EABI attributes section. */
8790 /* 0 = special, 1 = string, 2 = uleb123, > 0x80 == table lookup. */
8793 } arm_attr_public_tag
;
8795 static const char *arm_attr_tag_CPU_arch
[] =
8796 {"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2",
8798 static const char *arm_attr_tag_ARM_ISA_use
[] = {"No", "Yes"};
8799 static const char *arm_attr_tag_THUMB_ISA_use
[] =
8800 {"No", "Thumb-1", "Thumb-2"};
8801 static const char *arm_attr_tag_VFP_arch
[] =
8802 {"No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16"};
8803 static const char *arm_attr_tag_WMMX_arch
[] = {"No", "WMMXv1"};
8804 static const char *arm_attr_tag_NEON_arch
[] = {"No", "NEONv1"};
8805 static const char *arm_attr_tag_ABI_PCS_config
[] =
8806 {"None", "Bare platform", "Linux application", "Linux DSO", "PalmOS 2004",
8807 "PalmOS (reserved)", "SymbianOS 2004", "SymbianOS (reserved)"};
8808 static const char *arm_attr_tag_ABI_PCS_R9_use
[] =
8809 {"V6", "SB", "TLS", "Unused"};
8810 static const char *arm_attr_tag_ABI_PCS_RW_data
[] =
8811 {"Absolute", "PC-relative", "SB-relative", "None"};
8812 static const char *arm_attr_tag_ABI_PCS_RO_DATA
[] =
8813 {"Absolute", "PC-relative", "None"};
8814 static const char *arm_attr_tag_ABI_PCS_GOT_use
[] =
8815 {"None", "direct", "GOT-indirect"};
8816 static const char *arm_attr_tag_ABI_PCS_wchar_t
[] =
8817 {"None", "??? 1", "2", "??? 3", "4"};
8818 static const char *arm_attr_tag_ABI_FP_rounding
[] = {"Unused", "Needed"};
8819 static const char *arm_attr_tag_ABI_FP_denormal
[] = {"Unused", "Needed"};
8820 static const char *arm_attr_tag_ABI_FP_exceptions
[] = {"Unused", "Needed"};
8821 static const char *arm_attr_tag_ABI_FP_user_exceptions
[] = {"Unused", "Needed"};
8822 static const char *arm_attr_tag_ABI_FP_number_model
[] =
8823 {"Unused", "Finite", "RTABI", "IEEE 754"};
8824 static const char *arm_attr_tag_ABI_align8_needed
[] = {"No", "Yes", "4-byte"};
8825 static const char *arm_attr_tag_ABI_align8_preserved
[] =
8826 {"No", "Yes, except leaf SP", "Yes"};
8827 static const char *arm_attr_tag_ABI_enum_size
[] =
8828 {"Unused", "small", "int", "forced to int"};
8829 static const char *arm_attr_tag_ABI_HardFP_use
[] =
8830 {"As Tag_VFP_arch", "SP only", "DP only", "SP and DP"};
8831 static const char *arm_attr_tag_ABI_VFP_args
[] =
8832 {"AAPCS", "VFP registers", "custom"};
8833 static const char *arm_attr_tag_ABI_WMMX_args
[] =
8834 {"AAPCS", "WMMX registers", "custom"};
8835 static const char *arm_attr_tag_ABI_optimization_goals
[] =
8836 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
8837 "Aggressive Size", "Prefer Debug", "Aggressive Debug"};
8838 static const char *arm_attr_tag_ABI_FP_optimization_goals
[] =
8839 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
8840 "Aggressive Size", "Prefer Accuracy", "Aggressive Accuracy"};
8841 static const char *arm_attr_tag_VFP_HP_extension
[] =
8842 {"Not Allowed", "Allowed"};
8843 static const char *arm_attr_tag_ABI_FP_16bit_format
[] =
8844 {"None", "IEEE 754", "Alternative Format"};
8846 #define LOOKUP(id, name) \
8847 {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
8848 static arm_attr_public_tag arm_attr_public_tags
[] =
8850 {4, "CPU_raw_name", 1, NULL
},
8851 {5, "CPU_name", 1, NULL
},
8852 LOOKUP(6, CPU_arch
),
8853 {7, "CPU_arch_profile", 0, NULL
},
8854 LOOKUP(8, ARM_ISA_use
),
8855 LOOKUP(9, THUMB_ISA_use
),
8856 LOOKUP(10, VFP_arch
),
8857 LOOKUP(11, WMMX_arch
),
8858 LOOKUP(12, NEON_arch
),
8859 LOOKUP(13, ABI_PCS_config
),
8860 LOOKUP(14, ABI_PCS_R9_use
),
8861 LOOKUP(15, ABI_PCS_RW_data
),
8862 LOOKUP(16, ABI_PCS_RO_DATA
),
8863 LOOKUP(17, ABI_PCS_GOT_use
),
8864 LOOKUP(18, ABI_PCS_wchar_t
),
8865 LOOKUP(19, ABI_FP_rounding
),
8866 LOOKUP(20, ABI_FP_denormal
),
8867 LOOKUP(21, ABI_FP_exceptions
),
8868 LOOKUP(22, ABI_FP_user_exceptions
),
8869 LOOKUP(23, ABI_FP_number_model
),
8870 LOOKUP(24, ABI_align8_needed
),
8871 LOOKUP(25, ABI_align8_preserved
),
8872 LOOKUP(26, ABI_enum_size
),
8873 LOOKUP(27, ABI_HardFP_use
),
8874 LOOKUP(28, ABI_VFP_args
),
8875 LOOKUP(29, ABI_WMMX_args
),
8876 LOOKUP(30, ABI_optimization_goals
),
8877 LOOKUP(31, ABI_FP_optimization_goals
),
8878 {32, "compatibility", 0, NULL
},
8879 LOOKUP(36, VFP_HP_extension
),
8880 LOOKUP(38, ABI_FP_16bit_format
),
8884 /* Read an unsigned LEB128 encoded value from p. Set *PLEN to the number of
8887 read_uleb128 (unsigned char *p
, unsigned int *plen
)
8901 val
|= ((unsigned int)c
& 0x7f) << shift
;
8910 static unsigned char *
8911 display_arm_attribute (unsigned char *p
)
8916 arm_attr_public_tag
*attr
;
8920 tag
= read_uleb128 (p
, &len
);
8923 for (i
= 0; i
< ARRAY_SIZE(arm_attr_public_tags
); i
++)
8925 if (arm_attr_public_tags
[i
].tag
== tag
)
8927 attr
= &arm_attr_public_tags
[i
];
8934 printf (" Tag_%s: ", attr
->name
);
8940 case 7: /* Tag_CPU_arch_profile. */
8941 val
= read_uleb128 (p
, &len
);
8945 case 0: printf ("None\n"); break;
8946 case 'A': printf ("Application\n"); break;
8947 case 'R': printf ("Realtime\n"); break;
8948 case 'M': printf ("Microcontroller\n"); break;
8949 default: printf ("??? (%d)\n", val
); break;
8953 case 32: /* Tag_compatibility. */
8954 val
= read_uleb128 (p
, &len
);
8956 printf ("flag = %d, vendor = %s\n", val
, p
);
8957 p
+= strlen((char *)p
) + 1;
8971 assert (attr
->type
& 0x80);
8972 val
= read_uleb128 (p
, &len
);
8974 type
= attr
->type
& 0x7f;
8976 printf ("??? (%d)\n", val
);
8978 printf ("%s\n", attr
->table
[val
]);
8985 type
= 1; /* String. */
8987 type
= 2; /* uleb128. */
8988 printf (" Tag_unknown_%d: ", tag
);
8993 printf ("\"%s\"\n", p
);
8994 p
+= strlen((char *)p
) + 1;
8998 val
= read_uleb128 (p
, &len
);
9000 printf ("%d (0x%x)\n", val
, val
);
9006 static unsigned char *
9007 display_gnu_attribute (unsigned char * p
,
9008 unsigned char * (* display_proc_gnu_attribute
) (unsigned char *, int))
9015 tag
= read_uleb128 (p
, &len
);
9018 /* Tag_compatibility is the only generic GNU attribute defined at
9022 val
= read_uleb128 (p
, &len
);
9024 printf ("flag = %d, vendor = %s\n", val
, p
);
9025 p
+= strlen ((char *) p
) + 1;
9029 if ((tag
& 2) == 0 && display_proc_gnu_attribute
)
9030 return display_proc_gnu_attribute (p
, tag
);
9033 type
= 1; /* String. */
9035 type
= 2; /* uleb128. */
9036 printf (" Tag_unknown_%d: ", tag
);
9040 printf ("\"%s\"\n", p
);
9041 p
+= strlen ((char *) p
) + 1;
9045 val
= read_uleb128 (p
, &len
);
9047 printf ("%d (0x%x)\n", val
, val
);
9053 static unsigned char *
9054 display_power_gnu_attribute (unsigned char *p
, int tag
)
9060 if (tag
== Tag_GNU_Power_ABI_FP
)
9062 val
= read_uleb128 (p
, &len
);
9064 printf (" Tag_GNU_Power_ABI_FP: ");
9069 printf ("Hard or soft float\n");
9072 printf ("Hard float\n");
9075 printf ("Soft float\n");
9078 printf ("Single-precision hard float\n");
9081 printf ("??? (%d)\n", val
);
9087 if (tag
== Tag_GNU_Power_ABI_Vector
)
9089 val
= read_uleb128 (p
, &len
);
9091 printf (" Tag_GNU_Power_ABI_Vector: ");
9098 printf ("Generic\n");
9101 printf ("AltiVec\n");
9107 printf ("??? (%d)\n", val
);
9113 if (tag
== Tag_GNU_Power_ABI_Struct_Return
)
9115 val
= read_uleb128 (p
, &len
);
9117 printf (" Tag_GNU_Power_ABI_Struct_Return: ");
9127 printf ("Memory\n");
9130 printf ("??? (%d)\n", val
);
9137 type
= 1; /* String. */
9139 type
= 2; /* uleb128. */
9140 printf (" Tag_unknown_%d: ", tag
);
9144 printf ("\"%s\"\n", p
);
9145 p
+= strlen ((char *) p
) + 1;
9149 val
= read_uleb128 (p
, &len
);
9151 printf ("%d (0x%x)\n", val
, val
);
9157 static unsigned char *
9158 display_mips_gnu_attribute (unsigned char *p
, int tag
)
9164 if (tag
== Tag_GNU_MIPS_ABI_FP
)
9166 val
= read_uleb128 (p
, &len
);
9168 printf (" Tag_GNU_MIPS_ABI_FP: ");
9173 printf ("Hard or soft float\n");
9176 printf ("Hard float (-mdouble-float)\n");
9179 printf ("Hard float (-msingle-float)\n");
9182 printf ("Soft float\n");
9185 printf ("64-bit float (-mips32r2 -mfp64)\n");
9188 printf ("??? (%d)\n", val
);
9195 type
= 1; /* String. */
9197 type
= 2; /* uleb128. */
9198 printf (" Tag_unknown_%d: ", tag
);
9202 printf ("\"%s\"\n", p
);
9203 p
+= strlen ((char *) p
) + 1;
9207 val
= read_uleb128 (p
, &len
);
9209 printf ("%d (0x%x)\n", val
, val
);
9216 process_attributes (FILE * file
,
9217 const char * public_name
,
9218 unsigned int proc_type
,
9219 unsigned char * (* display_pub_attribute
) (unsigned char *),
9220 unsigned char * (* display_proc_gnu_attribute
) (unsigned char *, int))
9222 Elf_Internal_Shdr
*sect
;
9223 unsigned char *contents
;
9226 bfd_vma section_len
;
9230 /* Find the section header so that we get the size. */
9231 for (i
= 0, sect
= section_headers
;
9232 i
< elf_header
.e_shnum
;
9235 if (sect
->sh_type
!= proc_type
&& sect
->sh_type
!= SHT_GNU_ATTRIBUTES
)
9238 contents
= get_data (NULL
, file
, sect
->sh_offset
, 1, sect
->sh_size
,
9240 if (contents
== NULL
)
9246 len
= sect
->sh_size
- 1;
9252 bfd_boolean public_section
;
9253 bfd_boolean gnu_section
;
9255 section_len
= byte_get (p
, 4);
9258 if (section_len
> len
)
9260 printf (_("ERROR: Bad section length (%d > %d)\n"),
9261 (int) section_len
, (int) len
);
9266 printf ("Attribute Section: %s\n", p
);
9268 if (public_name
&& streq ((char *) p
, public_name
))
9269 public_section
= TRUE
;
9271 public_section
= FALSE
;
9273 if (streq ((char *) p
, "gnu"))
9276 gnu_section
= FALSE
;
9278 namelen
= strlen ((char *) p
) + 1;
9280 section_len
-= namelen
+ 4;
9282 while (section_len
> 0)
9288 size
= byte_get (p
, 4);
9289 if (size
> section_len
)
9291 printf (_("ERROR: Bad subsection length (%d > %d)\n"),
9292 (int) size
, (int) section_len
);
9296 section_len
-= size
;
9303 printf ("File Attributes\n");
9306 printf ("Section Attributes:");
9309 printf ("Symbol Attributes:");
9315 val
= read_uleb128 (p
, &i
);
9319 printf (" %d", val
);
9324 printf ("Unknown tag: %d\n", tag
);
9325 public_section
= FALSE
;
9332 p
= display_pub_attribute (p
);
9334 else if (gnu_section
)
9337 p
= display_gnu_attribute (p
,
9338 display_proc_gnu_attribute
);
9342 /* ??? Do something sensible, like dump hex. */
9343 printf (" Unknown section contexts\n");
9350 printf (_("Unknown format '%c'\n"), *p
);
9358 process_arm_specific (FILE *file
)
9360 return process_attributes (file
, "aeabi", SHT_ARM_ATTRIBUTES
,
9361 display_arm_attribute
, NULL
);
9365 process_power_specific (FILE *file
)
9367 return process_attributes (file
, NULL
, SHT_GNU_ATTRIBUTES
, NULL
,
9368 display_power_gnu_attribute
);
9371 /* DATA points to the contents of a MIPS GOT that starts at VMA PLTGOT.
9372 Print the Address, Access and Initial fields of an entry at VMA ADDR
9373 and return the VMA of the next entry. */
9376 print_mips_got_entry (unsigned char *data
, bfd_vma pltgot
, bfd_vma addr
)
9379 print_vma (addr
, LONG_HEX
);
9381 if (addr
< pltgot
+ 0xfff0)
9382 printf ("%6d(gp)", (int) (addr
- pltgot
- 0x7ff0));
9384 printf ("%10s", "");
9387 printf ("%*s", is_32bit_elf
? 8 : 16, "<unknown>");
9392 entry
= byte_get (data
+ addr
- pltgot
, is_32bit_elf
? 4 : 8);
9393 print_vma (entry
, LONG_HEX
);
9395 return addr
+ (is_32bit_elf
? 4 : 8);
9398 /* DATA points to the contents of a MIPS PLT GOT that starts at VMA
9399 PLTGOT. Print the Address and Initial fields of an entry at VMA
9400 ADDR and return the VMA of the next entry. */
9403 print_mips_pltgot_entry (unsigned char *data
, bfd_vma pltgot
, bfd_vma addr
)
9406 print_vma (addr
, LONG_HEX
);
9409 printf ("%*s", is_32bit_elf
? 8 : 16, "<unknown>");
9414 entry
= byte_get (data
+ addr
- pltgot
, is_32bit_elf
? 4 : 8);
9415 print_vma (entry
, LONG_HEX
);
9417 return addr
+ (is_32bit_elf
? 4 : 8);
9421 process_mips_specific (FILE *file
)
9423 Elf_Internal_Dyn
*entry
;
9424 size_t liblist_offset
= 0;
9425 size_t liblistno
= 0;
9426 size_t conflictsno
= 0;
9427 size_t options_offset
= 0;
9428 size_t conflicts_offset
= 0;
9429 size_t pltrelsz
= 0;
9432 bfd_vma mips_pltgot
= 0;
9434 bfd_vma local_gotno
= 0;
9436 bfd_vma symtabno
= 0;
9438 process_attributes (file
, NULL
, SHT_GNU_ATTRIBUTES
, NULL
,
9439 display_mips_gnu_attribute
);
9441 /* We have a lot of special sections. Thanks SGI! */
9442 if (dynamic_section
== NULL
)
9443 /* No information available. */
9446 for (entry
= dynamic_section
; entry
->d_tag
!= DT_NULL
; ++entry
)
9447 switch (entry
->d_tag
)
9449 case DT_MIPS_LIBLIST
:
9451 = offset_from_vma (file
, entry
->d_un
.d_val
,
9452 liblistno
* sizeof (Elf32_External_Lib
));
9454 case DT_MIPS_LIBLISTNO
:
9455 liblistno
= entry
->d_un
.d_val
;
9457 case DT_MIPS_OPTIONS
:
9458 options_offset
= offset_from_vma (file
, entry
->d_un
.d_val
, 0);
9460 case DT_MIPS_CONFLICT
:
9462 = offset_from_vma (file
, entry
->d_un
.d_val
,
9463 conflictsno
* sizeof (Elf32_External_Conflict
));
9465 case DT_MIPS_CONFLICTNO
:
9466 conflictsno
= entry
->d_un
.d_val
;
9469 pltgot
= entry
->d_un
.d_ptr
;
9471 case DT_MIPS_LOCAL_GOTNO
:
9472 local_gotno
= entry
->d_un
.d_val
;
9474 case DT_MIPS_GOTSYM
:
9475 gotsym
= entry
->d_un
.d_val
;
9477 case DT_MIPS_SYMTABNO
:
9478 symtabno
= entry
->d_un
.d_val
;
9480 case DT_MIPS_PLTGOT
:
9481 mips_pltgot
= entry
->d_un
.d_ptr
;
9484 pltrel
= entry
->d_un
.d_val
;
9487 pltrelsz
= entry
->d_un
.d_val
;
9490 jmprel
= entry
->d_un
.d_ptr
;
9496 if (liblist_offset
!= 0 && liblistno
!= 0 && do_dynamic
)
9498 Elf32_External_Lib
*elib
;
9501 elib
= get_data (NULL
, file
, liblist_offset
,
9502 liblistno
, sizeof (Elf32_External_Lib
),
9506 printf ("\nSection '.liblist' contains %lu entries:\n",
9507 (unsigned long) liblistno
);
9508 fputs (" Library Time Stamp Checksum Version Flags\n",
9511 for (cnt
= 0; cnt
< liblistno
; ++cnt
)
9518 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
9519 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
9520 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
9521 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
9522 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
9524 tmp
= gmtime (&time
);
9525 snprintf (timebuf
, sizeof (timebuf
),
9526 "%04u-%02u-%02uT%02u:%02u:%02u",
9527 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
9528 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
9530 printf ("%3lu: ", (unsigned long) cnt
);
9531 if (VALID_DYNAMIC_NAME (liblist
.l_name
))
9532 print_symbol (20, GET_DYNAMIC_NAME (liblist
.l_name
));
9534 printf ("<corrupt: %9ld>", liblist
.l_name
);
9535 printf (" %s %#10lx %-7ld", timebuf
, liblist
.l_checksum
,
9538 if (liblist
.l_flags
== 0)
9549 { " EXACT_MATCH", LL_EXACT_MATCH
},
9550 { " IGNORE_INT_VER", LL_IGNORE_INT_VER
},
9551 { " REQUIRE_MINOR", LL_REQUIRE_MINOR
},
9552 { " EXPORTS", LL_EXPORTS
},
9553 { " DELAY_LOAD", LL_DELAY_LOAD
},
9554 { " DELTA", LL_DELTA
}
9556 int flags
= liblist
.l_flags
;
9559 for (fcnt
= 0; fcnt
< ARRAY_SIZE (l_flags_vals
); ++fcnt
)
9560 if ((flags
& l_flags_vals
[fcnt
].bit
) != 0)
9562 fputs (l_flags_vals
[fcnt
].name
, stdout
);
9563 flags
^= l_flags_vals
[fcnt
].bit
;
9566 printf (" %#x", (unsigned int) flags
);
9576 if (options_offset
!= 0)
9578 Elf_External_Options
*eopt
;
9579 Elf_Internal_Shdr
*sect
= section_headers
;
9580 Elf_Internal_Options
*iopt
;
9581 Elf_Internal_Options
*option
;
9585 /* Find the section header so that we get the size. */
9586 while (sect
->sh_type
!= SHT_MIPS_OPTIONS
)
9589 eopt
= get_data (NULL
, file
, options_offset
, 1, sect
->sh_size
,
9593 iopt
= cmalloc ((sect
->sh_size
/ sizeof (eopt
)), sizeof (*iopt
));
9596 error (_("Out of memory\n"));
9603 while (offset
< sect
->sh_size
)
9605 Elf_External_Options
*eoption
;
9607 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
9609 option
->kind
= BYTE_GET (eoption
->kind
);
9610 option
->size
= BYTE_GET (eoption
->size
);
9611 option
->section
= BYTE_GET (eoption
->section
);
9612 option
->info
= BYTE_GET (eoption
->info
);
9614 offset
+= option
->size
;
9620 printf (_("\nSection '%s' contains %d entries:\n"),
9621 SECTION_NAME (sect
), cnt
);
9629 switch (option
->kind
)
9632 /* This shouldn't happen. */
9633 printf (" NULL %d %lx", option
->section
, option
->info
);
9636 printf (" REGINFO ");
9637 if (elf_header
.e_machine
== EM_MIPS
)
9640 Elf32_External_RegInfo
*ereg
;
9641 Elf32_RegInfo reginfo
;
9643 ereg
= (Elf32_External_RegInfo
*) (option
+ 1);
9644 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
9645 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
9646 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
9647 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
9648 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
9649 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
9651 printf ("GPR %08lx GP 0x%lx\n",
9653 (unsigned long) reginfo
.ri_gp_value
);
9654 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
9655 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
9656 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
9661 Elf64_External_RegInfo
*ereg
;
9662 Elf64_Internal_RegInfo reginfo
;
9664 ereg
= (Elf64_External_RegInfo
*) (option
+ 1);
9665 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
9666 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
9667 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
9668 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
9669 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
9670 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
9672 printf ("GPR %08lx GP 0x",
9673 reginfo
.ri_gprmask
);
9674 printf_vma (reginfo
.ri_gp_value
);
9677 printf (" CPR0 %08lx CPR1 %08lx CPR2 %08lx CPR3 %08lx\n",
9678 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
9679 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
9683 case ODK_EXCEPTIONS
:
9684 fputs (" EXCEPTIONS fpe_min(", stdout
);
9685 process_mips_fpe_exception (option
->info
& OEX_FPU_MIN
);
9686 fputs (") fpe_max(", stdout
);
9687 process_mips_fpe_exception ((option
->info
& OEX_FPU_MAX
) >> 8);
9688 fputs (")", stdout
);
9690 if (option
->info
& OEX_PAGE0
)
9691 fputs (" PAGE0", stdout
);
9692 if (option
->info
& OEX_SMM
)
9693 fputs (" SMM", stdout
);
9694 if (option
->info
& OEX_FPDBUG
)
9695 fputs (" FPDBUG", stdout
);
9696 if (option
->info
& OEX_DISMISS
)
9697 fputs (" DISMISS", stdout
);
9700 fputs (" PAD ", stdout
);
9701 if (option
->info
& OPAD_PREFIX
)
9702 fputs (" PREFIX", stdout
);
9703 if (option
->info
& OPAD_POSTFIX
)
9704 fputs (" POSTFIX", stdout
);
9705 if (option
->info
& OPAD_SYMBOL
)
9706 fputs (" SYMBOL", stdout
);
9709 fputs (" HWPATCH ", stdout
);
9710 if (option
->info
& OHW_R4KEOP
)
9711 fputs (" R4KEOP", stdout
);
9712 if (option
->info
& OHW_R8KPFETCH
)
9713 fputs (" R8KPFETCH", stdout
);
9714 if (option
->info
& OHW_R5KEOP
)
9715 fputs (" R5KEOP", stdout
);
9716 if (option
->info
& OHW_R5KCVTL
)
9717 fputs (" R5KCVTL", stdout
);
9720 fputs (" FILL ", stdout
);
9721 /* XXX Print content of info word? */
9724 fputs (" TAGS ", stdout
);
9725 /* XXX Print content of info word? */
9728 fputs (" HWAND ", stdout
);
9729 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
9730 fputs (" R4KEOP_CHECKED", stdout
);
9731 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
9732 fputs (" R4KEOP_CLEAN", stdout
);
9735 fputs (" HWOR ", stdout
);
9736 if (option
->info
& OHWA0_R4KEOP_CHECKED
)
9737 fputs (" R4KEOP_CHECKED", stdout
);
9738 if (option
->info
& OHWA0_R4KEOP_CLEAN
)
9739 fputs (" R4KEOP_CLEAN", stdout
);
9742 printf (" GP_GROUP %#06lx self-contained %#06lx",
9743 option
->info
& OGP_GROUP
,
9744 (option
->info
& OGP_SELF
) >> 16);
9747 printf (" IDENT %#06lx self-contained %#06lx",
9748 option
->info
& OGP_GROUP
,
9749 (option
->info
& OGP_SELF
) >> 16);
9752 /* This shouldn't happen. */
9753 printf (" %3d ??? %d %lx",
9754 option
->kind
, option
->section
, option
->info
);
9758 len
= sizeof (*eopt
);
9759 while (len
< option
->size
)
9760 if (((char *) option
)[len
] >= ' '
9761 && ((char *) option
)[len
] < 0x7f)
9762 printf ("%c", ((char *) option
)[len
++]);
9764 printf ("\\%03o", ((char *) option
)[len
++]);
9766 fputs ("\n", stdout
);
9774 if (conflicts_offset
!= 0 && conflictsno
!= 0)
9776 Elf32_Conflict
*iconf
;
9779 if (dynamic_symbols
== NULL
)
9781 error (_("conflict list found without a dynamic symbol table\n"));
9785 iconf
= cmalloc (conflictsno
, sizeof (*iconf
));
9788 error (_("Out of memory\n"));
9794 Elf32_External_Conflict
*econf32
;
9796 econf32
= get_data (NULL
, file
, conflicts_offset
,
9797 conflictsno
, sizeof (*econf32
), _("conflict"));
9801 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
9802 iconf
[cnt
] = BYTE_GET (econf32
[cnt
]);
9808 Elf64_External_Conflict
*econf64
;
9810 econf64
= get_data (NULL
, file
, conflicts_offset
,
9811 conflictsno
, sizeof (*econf64
), _("conflict"));
9815 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
9816 iconf
[cnt
] = BYTE_GET (econf64
[cnt
]);
9821 printf (_("\nSection '.conflict' contains %lu entries:\n"),
9822 (unsigned long) conflictsno
);
9823 puts (_(" Num: Index Value Name"));
9825 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
9827 Elf_Internal_Sym
*psym
= & dynamic_symbols
[iconf
[cnt
]];
9829 printf ("%5lu: %8lu ", (unsigned long) cnt
, iconf
[cnt
]);
9830 print_vma (psym
->st_value
, FULL_HEX
);
9832 if (VALID_DYNAMIC_NAME (psym
->st_name
))
9833 print_symbol (25, GET_DYNAMIC_NAME (psym
->st_name
));
9835 printf ("<corrupt: %14ld>", psym
->st_name
);
9842 if (pltgot
!= 0 && local_gotno
!= 0)
9844 bfd_vma entry
, local_end
, global_end
;
9846 unsigned char *data
;
9850 addr_size
= (is_32bit_elf
? 4 : 8);
9851 local_end
= pltgot
+ local_gotno
* addr_size
;
9852 global_end
= local_end
+ (symtabno
- gotsym
) * addr_size
;
9854 offset
= offset_from_vma (file
, pltgot
, global_end
- pltgot
);
9855 data
= get_data (NULL
, file
, offset
, global_end
- pltgot
, 1, _("GOT"));
9856 printf (_("\nPrimary GOT:\n"));
9857 printf (_(" Canonical gp value: "));
9858 print_vma (pltgot
+ 0x7ff0, LONG_HEX
);
9861 printf (_(" Reserved entries:\n"));
9862 printf (_(" %*s %10s %*s Purpose\n"),
9863 addr_size
* 2, "Address", "Access",
9864 addr_size
* 2, "Initial");
9865 entry
= print_mips_got_entry (data
, pltgot
, entry
);
9866 printf (" Lazy resolver\n");
9868 && (byte_get (data
+ entry
- pltgot
, addr_size
)
9869 >> (addr_size
* 8 - 1)) != 0)
9871 entry
= print_mips_got_entry (data
, pltgot
, entry
);
9872 printf (" Module pointer (GNU extension)\n");
9876 if (entry
< local_end
)
9878 printf (_(" Local entries:\n"));
9879 printf (_(" %*s %10s %*s\n"),
9880 addr_size
* 2, "Address", "Access",
9881 addr_size
* 2, "Initial");
9882 while (entry
< local_end
)
9884 entry
= print_mips_got_entry (data
, pltgot
, entry
);
9890 if (gotsym
< symtabno
)
9894 printf (_(" Global entries:\n"));
9895 printf (_(" %*s %10s %*s %*s %-7s %3s %s\n"),
9896 addr_size
* 2, "Address", "Access",
9897 addr_size
* 2, "Initial",
9898 addr_size
* 2, "Sym.Val.", "Type", "Ndx", "Name");
9899 sym_width
= (is_32bit_elf
? 80 : 160) - 28 - addr_size
* 6 - 1;
9900 for (i
= gotsym
; i
< symtabno
; i
++)
9902 Elf_Internal_Sym
*psym
;
9904 psym
= dynamic_symbols
+ i
;
9905 entry
= print_mips_got_entry (data
, pltgot
, entry
);
9907 print_vma (psym
->st_value
, LONG_HEX
);
9908 printf (" %-7s %3s ",
9909 get_symbol_type (ELF_ST_TYPE (psym
->st_info
)),
9910 get_symbol_index_type (psym
->st_shndx
));
9911 if (VALID_DYNAMIC_NAME (psym
->st_name
))
9912 print_symbol (sym_width
, GET_DYNAMIC_NAME (psym
->st_name
));
9914 printf ("<corrupt: %14ld>", psym
->st_name
);
9924 if (mips_pltgot
!= 0 && jmprel
!= 0 && pltrel
!= 0 && pltrelsz
!= 0)
9927 size_t offset
, rel_offset
;
9928 unsigned long count
, i
;
9929 unsigned char *data
;
9930 int addr_size
, sym_width
;
9931 Elf_Internal_Rela
*rels
;
9933 rel_offset
= offset_from_vma (file
, jmprel
, pltrelsz
);
9934 if (pltrel
== DT_RELA
)
9936 if (!slurp_rela_relocs (file
, rel_offset
, pltrelsz
, &rels
, &count
))
9941 if (!slurp_rel_relocs (file
, rel_offset
, pltrelsz
, &rels
, &count
))
9945 entry
= mips_pltgot
;
9946 addr_size
= (is_32bit_elf
? 4 : 8);
9947 end
= mips_pltgot
+ (2 + count
) * addr_size
;
9949 offset
= offset_from_vma (file
, mips_pltgot
, end
- mips_pltgot
);
9950 data
= get_data (NULL
, file
, offset
, end
- mips_pltgot
, 1, _("PLT GOT"));
9951 printf (_("\nPLT GOT:\n\n"));
9952 printf (_(" Reserved entries:\n"));
9953 printf (_(" %*s %*s Purpose\n"),
9954 addr_size
* 2, "Address", addr_size
* 2, "Initial");
9955 entry
= print_mips_pltgot_entry (data
, mips_pltgot
, entry
);
9956 printf (" PLT lazy resolver\n");
9957 entry
= print_mips_pltgot_entry (data
, mips_pltgot
, entry
);
9958 printf (" Module pointer\n");
9961 printf (_(" Entries:\n"));
9962 printf (_(" %*s %*s %*s %-7s %3s %s\n"),
9963 addr_size
* 2, "Address",
9964 addr_size
* 2, "Initial",
9965 addr_size
* 2, "Sym.Val.", "Type", "Ndx", "Name");
9966 sym_width
= (is_32bit_elf
? 80 : 160) - 17 - addr_size
* 6 - 1;
9967 for (i
= 0; i
< count
; i
++)
9969 Elf_Internal_Sym
*psym
;
9971 psym
= dynamic_symbols
+ get_reloc_symindex (rels
[i
].r_info
);
9972 entry
= print_mips_pltgot_entry (data
, mips_pltgot
, entry
);
9974 print_vma (psym
->st_value
, LONG_HEX
);
9975 printf (" %-7s %3s ",
9976 get_symbol_type (ELF_ST_TYPE (psym
->st_info
)),
9977 get_symbol_index_type (psym
->st_shndx
));
9978 if (VALID_DYNAMIC_NAME (psym
->st_name
))
9979 print_symbol (sym_width
, GET_DYNAMIC_NAME (psym
->st_name
));
9981 printf ("<corrupt: %14ld>", psym
->st_name
);
9995 process_gnu_liblist (FILE *file
)
9997 Elf_Internal_Shdr
*section
, *string_sec
;
9998 Elf32_External_Lib
*elib
;
10000 size_t strtab_size
;
10007 for (i
= 0, section
= section_headers
;
10008 i
< elf_header
.e_shnum
;
10011 switch (section
->sh_type
)
10013 case SHT_GNU_LIBLIST
:
10014 if (section
->sh_link
>= elf_header
.e_shnum
)
10017 elib
= get_data (NULL
, file
, section
->sh_offset
, 1, section
->sh_size
,
10022 string_sec
= section_headers
+ section
->sh_link
;
10024 strtab
= get_data (NULL
, file
, string_sec
->sh_offset
, 1,
10025 string_sec
->sh_size
, _("liblist string table"));
10026 strtab_size
= string_sec
->sh_size
;
10029 || section
->sh_entsize
!= sizeof (Elf32_External_Lib
))
10035 printf (_("\nLibrary list section '%s' contains %lu entries:\n"),
10036 SECTION_NAME (section
),
10037 (unsigned long) (section
->sh_size
/ sizeof (Elf32_External_Lib
)));
10039 puts (" Library Time Stamp Checksum Version Flags");
10041 for (cnt
= 0; cnt
< section
->sh_size
/ sizeof (Elf32_External_Lib
);
10049 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
10050 time
= BYTE_GET (elib
[cnt
].l_time_stamp
);
10051 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
10052 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
10053 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
10055 tmp
= gmtime (&time
);
10056 snprintf (timebuf
, sizeof (timebuf
),
10057 "%04u-%02u-%02uT%02u:%02u:%02u",
10058 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
10059 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
10061 printf ("%3lu: ", (unsigned long) cnt
);
10063 printf ("%-20s", liblist
.l_name
< strtab_size
10064 ? strtab
+ liblist
.l_name
: "<corrupt>");
10066 printf ("%-20.20s", liblist
.l_name
< strtab_size
10067 ? strtab
+ liblist
.l_name
: "<corrupt>");
10068 printf (" %s %#010lx %-7ld %-7ld\n", timebuf
, liblist
.l_checksum
,
10069 liblist
.l_version
, liblist
.l_flags
);
10079 static const char *
10080 get_note_type (unsigned e_type
)
10082 static char buff
[64];
10084 if (elf_header
.e_type
== ET_CORE
)
10088 return _("NT_AUXV (auxiliary vector)");
10090 return _("NT_PRSTATUS (prstatus structure)");
10092 return _("NT_FPREGSET (floating point registers)");
10094 return _("NT_PRPSINFO (prpsinfo structure)");
10095 case NT_TASKSTRUCT
:
10096 return _("NT_TASKSTRUCT (task structure)");
10098 return _("NT_PRXFPREG (user_xfpregs structure)");
10100 return _("NT_PPC_VMX (ppc Altivec registers)");
10102 return _("NT_PPC_VSX (ppc VSX registers)");
10104 return _("NT_PSTATUS (pstatus structure)");
10106 return _("NT_FPREGS (floating point registers)");
10108 return _("NT_PSINFO (psinfo structure)");
10110 return _("NT_LWPSTATUS (lwpstatus_t structure)");
10112 return _("NT_LWPSINFO (lwpsinfo_t structure)");
10113 case NT_WIN32PSTATUS
:
10114 return _("NT_WIN32PSTATUS (win32_pstatus structure)");
10122 return _("NT_VERSION (version)");
10124 return _("NT_ARCH (architecture)");
10129 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
10133 static const char *
10134 get_gnu_elf_note_type (unsigned e_type
)
10136 static char buff
[64];
10140 case NT_GNU_ABI_TAG
:
10141 return _("NT_GNU_ABI_TAG (ABI version tag)");
10143 return _("NT_GNU_HWCAP (DSO-supplied software HWCAP info)");
10144 case NT_GNU_BUILD_ID
:
10145 return _("NT_GNU_BUILD_ID (unique build ID bitstring)");
10146 case NT_GNU_GOLD_VERSION
:
10147 return _("NT_GNU_GOLD_VERSION (gold version)");
10152 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
10156 static const char *
10157 get_netbsd_elfcore_note_type (unsigned e_type
)
10159 static char buff
[64];
10161 if (e_type
== NT_NETBSDCORE_PROCINFO
)
10163 /* NetBSD core "procinfo" structure. */
10164 return _("NetBSD procinfo structure");
10167 /* As of Jan 2002 there are no other machine-independent notes
10168 defined for NetBSD core files. If the note type is less
10169 than the start of the machine-dependent note types, we don't
10172 if (e_type
< NT_NETBSDCORE_FIRSTMACH
)
10174 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
10178 switch (elf_header
.e_machine
)
10180 /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0
10181 and PT_GETFPREGS == mach+2. */
10186 case EM_SPARC32PLUS
:
10190 case NT_NETBSDCORE_FIRSTMACH
+0:
10191 return _("PT_GETREGS (reg structure)");
10192 case NT_NETBSDCORE_FIRSTMACH
+2:
10193 return _("PT_GETFPREGS (fpreg structure)");
10199 /* On all other arch's, PT_GETREGS == mach+1 and
10200 PT_GETFPREGS == mach+3. */
10204 case NT_NETBSDCORE_FIRSTMACH
+1:
10205 return _("PT_GETREGS (reg structure)");
10206 case NT_NETBSDCORE_FIRSTMACH
+3:
10207 return _("PT_GETFPREGS (fpreg structure)");
10213 snprintf (buff
, sizeof (buff
), _("PT_FIRSTMACH+%d"),
10214 e_type
- NT_NETBSDCORE_FIRSTMACH
);
10218 /* Note that by the ELF standard, the name field is already null byte
10219 terminated, and namesz includes the terminating null byte.
10220 I.E. the value of namesz for the name "FSF" is 4.
10222 If the value of namesz is zero, there is no name present. */
10224 process_note (Elf_Internal_Note
*pnote
)
10226 const char *name
= pnote
->namesz
? pnote
->namedata
: "(NONE)";
10229 if (pnote
->namesz
== 0)
10230 /* If there is no note name, then use the default set of
10231 note type strings. */
10232 nt
= get_note_type (pnote
->type
);
10234 else if (const_strneq (pnote
->namedata
, "GNU"))
10235 /* GNU-specific object file notes. */
10236 nt
= get_gnu_elf_note_type (pnote
->type
);
10238 else if (const_strneq (pnote
->namedata
, "NetBSD-CORE"))
10239 /* NetBSD-specific core file notes. */
10240 nt
= get_netbsd_elfcore_note_type (pnote
->type
);
10242 else if (strneq (pnote
->namedata
, "SPU/", 4))
10244 /* SPU-specific core file notes. */
10245 nt
= pnote
->namedata
+ 4;
10250 /* Don't recognize this note name; just use the default set of
10251 note type strings. */
10252 nt
= get_note_type (pnote
->type
);
10254 printf (" %s\t\t0x%08lx\t%s\n", name
, pnote
->descsz
, nt
);
10260 process_corefile_note_segment (FILE *file
, bfd_vma offset
, bfd_vma length
)
10262 Elf_External_Note
*pnotes
;
10263 Elf_External_Note
*external
;
10269 pnotes
= get_data (NULL
, file
, offset
, 1, length
, _("notes"));
10275 printf (_("\nNotes at offset 0x%08lx with length 0x%08lx:\n"),
10276 (unsigned long) offset
, (unsigned long) length
);
10277 printf (_(" Owner\t\tData size\tDescription\n"));
10279 while (external
< (Elf_External_Note
*)((char *) pnotes
+ length
))
10281 Elf_External_Note
*next
;
10282 Elf_Internal_Note inote
;
10285 inote
.type
= BYTE_GET (external
->type
);
10286 inote
.namesz
= BYTE_GET (external
->namesz
);
10287 inote
.namedata
= external
->name
;
10288 inote
.descsz
= BYTE_GET (external
->descsz
);
10289 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 2);
10290 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
10292 next
= (Elf_External_Note
*)(inote
.descdata
+ align_power (inote
.descsz
, 2));
10294 if (((char *) next
) > (((char *) pnotes
) + length
))
10296 warn (_("corrupt note found at offset %lx into core notes\n"),
10297 (unsigned long) ((char *) external
- (char *) pnotes
));
10298 warn (_(" type: %lx, namesize: %08lx, descsize: %08lx\n"),
10299 inote
.type
, inote
.namesz
, inote
.descsz
);
10305 /* Verify that name is null terminated. It appears that at least
10306 one version of Linux (RedHat 6.0) generates corefiles that don't
10307 comply with the ELF spec by failing to include the null byte in
10309 if (inote
.namedata
[inote
.namesz
] != '\0')
10311 temp
= malloc (inote
.namesz
+ 1);
10315 error (_("Out of memory\n"));
10320 strncpy (temp
, inote
.namedata
, inote
.namesz
);
10321 temp
[inote
.namesz
] = 0;
10323 /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */
10324 inote
.namedata
= temp
;
10327 res
&= process_note (& inote
);
10342 process_corefile_note_segments (FILE *file
)
10344 Elf_Internal_Phdr
*segment
;
10348 if (! get_program_headers (file
))
10351 for (i
= 0, segment
= program_headers
;
10352 i
< elf_header
.e_phnum
;
10355 if (segment
->p_type
== PT_NOTE
)
10356 res
&= process_corefile_note_segment (file
,
10357 (bfd_vma
) segment
->p_offset
,
10358 (bfd_vma
) segment
->p_filesz
);
10365 process_note_sections (FILE *file
)
10367 Elf_Internal_Shdr
*section
;
10371 for (i
= 0, section
= section_headers
;
10372 i
< elf_header
.e_shnum
;
10374 if (section
->sh_type
== SHT_NOTE
)
10375 res
&= process_corefile_note_segment (file
,
10376 (bfd_vma
) section
->sh_offset
,
10377 (bfd_vma
) section
->sh_size
);
10383 process_notes (FILE *file
)
10385 /* If we have not been asked to display the notes then do nothing. */
10389 if (elf_header
.e_type
!= ET_CORE
)
10390 return process_note_sections (file
);
10392 /* No program headers means no NOTE segment. */
10393 if (elf_header
.e_phnum
> 0)
10394 return process_corefile_note_segments (file
);
10396 printf (_("No note segments present in the core file.\n"));
10401 process_arch_specific (FILE *file
)
10406 switch (elf_header
.e_machine
)
10409 return process_arm_specific (file
);
10411 case EM_MIPS_RS3_LE
:
10412 return process_mips_specific (file
);
10415 return process_power_specific (file
);
10424 get_file_header (FILE *file
)
10426 /* Read in the identity array. */
10427 if (fread (elf_header
.e_ident
, EI_NIDENT
, 1, file
) != 1)
10430 /* Determine how to read the rest of the header. */
10431 switch (elf_header
.e_ident
[EI_DATA
])
10433 default: /* fall through */
10434 case ELFDATANONE
: /* fall through */
10436 byte_get
= byte_get_little_endian
;
10437 byte_put
= byte_put_little_endian
;
10440 byte_get
= byte_get_big_endian
;
10441 byte_put
= byte_put_big_endian
;
10445 /* For now we only support 32 bit and 64 bit ELF files. */
10446 is_32bit_elf
= (elf_header
.e_ident
[EI_CLASS
] != ELFCLASS64
);
10448 /* Read in the rest of the header. */
10451 Elf32_External_Ehdr ehdr32
;
10453 if (fread (ehdr32
.e_type
, sizeof (ehdr32
) - EI_NIDENT
, 1, file
) != 1)
10456 elf_header
.e_type
= BYTE_GET (ehdr32
.e_type
);
10457 elf_header
.e_machine
= BYTE_GET (ehdr32
.e_machine
);
10458 elf_header
.e_version
= BYTE_GET (ehdr32
.e_version
);
10459 elf_header
.e_entry
= BYTE_GET (ehdr32
.e_entry
);
10460 elf_header
.e_phoff
= BYTE_GET (ehdr32
.e_phoff
);
10461 elf_header
.e_shoff
= BYTE_GET (ehdr32
.e_shoff
);
10462 elf_header
.e_flags
= BYTE_GET (ehdr32
.e_flags
);
10463 elf_header
.e_ehsize
= BYTE_GET (ehdr32
.e_ehsize
);
10464 elf_header
.e_phentsize
= BYTE_GET (ehdr32
.e_phentsize
);
10465 elf_header
.e_phnum
= BYTE_GET (ehdr32
.e_phnum
);
10466 elf_header
.e_shentsize
= BYTE_GET (ehdr32
.e_shentsize
);
10467 elf_header
.e_shnum
= BYTE_GET (ehdr32
.e_shnum
);
10468 elf_header
.e_shstrndx
= BYTE_GET (ehdr32
.e_shstrndx
);
10472 Elf64_External_Ehdr ehdr64
;
10474 /* If we have been compiled with sizeof (bfd_vma) == 4, then
10475 we will not be able to cope with the 64bit data found in
10476 64 ELF files. Detect this now and abort before we start
10477 overwriting things. */
10478 if (sizeof (bfd_vma
) < 8)
10480 error (_("This instance of readelf has been built without support for a\n\
10481 64 bit data type and so it cannot read 64 bit ELF files.\n"));
10485 if (fread (ehdr64
.e_type
, sizeof (ehdr64
) - EI_NIDENT
, 1, file
) != 1)
10488 elf_header
.e_type
= BYTE_GET (ehdr64
.e_type
);
10489 elf_header
.e_machine
= BYTE_GET (ehdr64
.e_machine
);
10490 elf_header
.e_version
= BYTE_GET (ehdr64
.e_version
);
10491 elf_header
.e_entry
= BYTE_GET (ehdr64
.e_entry
);
10492 elf_header
.e_phoff
= BYTE_GET (ehdr64
.e_phoff
);
10493 elf_header
.e_shoff
= BYTE_GET (ehdr64
.e_shoff
);
10494 elf_header
.e_flags
= BYTE_GET (ehdr64
.e_flags
);
10495 elf_header
.e_ehsize
= BYTE_GET (ehdr64
.e_ehsize
);
10496 elf_header
.e_phentsize
= BYTE_GET (ehdr64
.e_phentsize
);
10497 elf_header
.e_phnum
= BYTE_GET (ehdr64
.e_phnum
);
10498 elf_header
.e_shentsize
= BYTE_GET (ehdr64
.e_shentsize
);
10499 elf_header
.e_shnum
= BYTE_GET (ehdr64
.e_shnum
);
10500 elf_header
.e_shstrndx
= BYTE_GET (ehdr64
.e_shstrndx
);
10503 if (elf_header
.e_shoff
)
10505 /* There may be some extensions in the first section header. Don't
10506 bomb if we can't read it. */
10508 get_32bit_section_headers (file
, 1);
10510 get_64bit_section_headers (file
, 1);
10516 /* Process one ELF object file according to the command line options.
10517 This file may actually be stored in an archive. The file is
10518 positioned at the start of the ELF object. */
10521 process_object (char *file_name
, FILE *file
)
10525 if (! get_file_header (file
))
10527 error (_("%s: Failed to read file header\n"), file_name
);
10531 /* Initialise per file variables. */
10532 for (i
= ARRAY_SIZE (version_info
); i
--;)
10533 version_info
[i
] = 0;
10535 for (i
= ARRAY_SIZE (dynamic_info
); i
--;)
10536 dynamic_info
[i
] = 0;
10538 /* Process the file. */
10540 printf (_("\nFile: %s\n"), file_name
);
10542 /* Initialise the dump_sects array from the cmdline_dump_sects array.
10543 Note we do this even if cmdline_dump_sects is empty because we
10544 must make sure that the dump_sets array is zeroed out before each
10545 object file is processed. */
10546 if (num_dump_sects
> num_cmdline_dump_sects
)
10547 memset (dump_sects
, 0, num_dump_sects
* sizeof (* dump_sects
));
10549 if (num_cmdline_dump_sects
> 0)
10551 if (num_dump_sects
== 0)
10552 /* A sneaky way of allocating the dump_sects array. */
10553 request_dump_bynumber (num_cmdline_dump_sects
, 0);
10555 assert (num_dump_sects
>= num_cmdline_dump_sects
);
10556 memcpy (dump_sects
, cmdline_dump_sects
,
10557 num_cmdline_dump_sects
* sizeof (* dump_sects
));
10560 if (! process_file_header ())
10563 if (! process_section_headers (file
))
10565 /* Without loaded section headers we cannot process lots of
10567 do_unwind
= do_version
= do_dump
= do_arch
= 0;
10569 if (! do_using_dynamic
)
10570 do_syms
= do_reloc
= 0;
10573 if (! process_section_groups (file
))
10575 /* Without loaded section groups we cannot process unwind. */
10579 if (process_program_headers (file
))
10580 process_dynamic_section (file
);
10582 process_relocs (file
);
10584 process_unwind (file
);
10586 process_symbol_table (file
);
10588 process_syminfo (file
);
10590 process_version_sections (file
);
10592 process_section_contents (file
);
10594 process_notes (file
);
10596 process_gnu_liblist (file
);
10598 process_arch_specific (file
);
10600 if (program_headers
)
10602 free (program_headers
);
10603 program_headers
= NULL
;
10606 if (section_headers
)
10608 free (section_headers
);
10609 section_headers
= NULL
;
10614 free (string_table
);
10615 string_table
= NULL
;
10616 string_table_length
= 0;
10619 if (dynamic_strings
)
10621 free (dynamic_strings
);
10622 dynamic_strings
= NULL
;
10623 dynamic_strings_length
= 0;
10626 if (dynamic_symbols
)
10628 free (dynamic_symbols
);
10629 dynamic_symbols
= NULL
;
10630 num_dynamic_syms
= 0;
10633 if (dynamic_syminfo
)
10635 free (dynamic_syminfo
);
10636 dynamic_syminfo
= NULL
;
10639 if (section_headers_groups
)
10641 free (section_headers_groups
);
10642 section_headers_groups
= NULL
;
10645 if (section_groups
)
10647 struct group_list
*g
, *next
;
10649 for (i
= 0; i
< group_count
; i
++)
10651 for (g
= section_groups
[i
].root
; g
!= NULL
; g
= next
)
10658 free (section_groups
);
10659 section_groups
= NULL
;
10662 free_debug_memory ();
10667 /* Process an ELF archive.
10668 On entry the file is positioned just after the ARMAG string. */
10671 process_archive (char *file_name
, FILE *file
)
10673 struct ar_hdr arhdr
;
10675 unsigned long size
;
10676 unsigned long index_num
= 0;
10677 unsigned long *index_array
= NULL
;
10678 char *sym_table
= NULL
;
10679 unsigned long sym_size
= 0;
10680 char *longnames
= NULL
;
10681 unsigned long longnames_size
= 0;
10682 size_t file_name_size
;
10687 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
10688 if (got
!= sizeof arhdr
)
10693 error (_("%s: failed to read archive header\n"), file_name
);
10697 /* See if this is the archive symbol table. */
10698 if (const_strneq (arhdr
.ar_name
, "/ ")
10699 || const_strneq (arhdr
.ar_name
, "/SYM64/ "))
10701 size
= strtoul (arhdr
.ar_size
, NULL
, 10);
10702 size
= size
+ (size
& 1);
10704 if (do_archive_index
)
10707 /* A buffer used to hold numbers read in from an archive index.
10708 These are always 4 bytes long and stored in big-endian format. */
10709 #define SIZEOF_AR_INDEX_NUMBERS 4
10710 unsigned char integer_buffer
[SIZEOF_AR_INDEX_NUMBERS
];
10711 unsigned char * index_buffer
;
10713 /* Check the size of the archive index. */
10714 if (size
< SIZEOF_AR_INDEX_NUMBERS
)
10716 error (_("%s: the archive index is empty\n"), file_name
);
10720 /* Read the numer of entries in the archive index. */
10721 got
= fread (integer_buffer
, 1, sizeof integer_buffer
, file
);
10722 if (got
!= sizeof (integer_buffer
))
10724 error (_("%s: failed to read archive index\n"), file_name
);
10727 index_num
= byte_get_big_endian (integer_buffer
, sizeof integer_buffer
);
10728 size
-= SIZEOF_AR_INDEX_NUMBERS
;
10730 /* Read in the archive index. */
10731 if (size
< index_num
* SIZEOF_AR_INDEX_NUMBERS
)
10733 error (_("%s: the archive index is supposed to have %ld entries, but the size in the header is too small\n"),
10734 file_name
, index_num
);
10737 index_buffer
= malloc (index_num
* SIZEOF_AR_INDEX_NUMBERS
);
10738 if (index_buffer
== NULL
)
10740 error (_("Out of memory whilst trying to read archive symbol index\n"));
10743 got
= fread (index_buffer
, SIZEOF_AR_INDEX_NUMBERS
, index_num
, file
);
10744 if (got
!= index_num
)
10746 free (index_buffer
);
10747 error (_("%s: failed to read archive index\n"), file_name
);
10751 size
-= index_num
* SIZEOF_AR_INDEX_NUMBERS
;
10753 /* Convert the index numbers into the host's numeric format. */
10754 index_array
= malloc (index_num
* sizeof (* index_array
));
10755 if (index_array
== NULL
)
10757 free (index_buffer
);
10758 error (_("Out of memory whilst trying to convert the archive symbol index\n"));
10762 for (i
= 0; i
< index_num
; i
++)
10763 index_array
[i
] = byte_get_big_endian ((unsigned char *)(index_buffer
+ (i
* SIZEOF_AR_INDEX_NUMBERS
)),
10764 SIZEOF_AR_INDEX_NUMBERS
);
10765 free (index_buffer
);
10767 /* The remaining space in the header is taken up by the symbol table. */
10770 error (_("%s: the archive has an index but no symbols\n"), file_name
);
10774 sym_table
= malloc (size
);
10776 if (sym_table
== NULL
)
10778 error (_("Out of memory whilst trying to read archive index symbol table\n"));
10782 got
= fread (sym_table
, 1, size
, file
);
10785 error (_("%s: failed to read archive index symbol table\n"), file_name
);
10792 if (fseek (file
, size
, SEEK_CUR
) != 0)
10794 error (_("%s: failed to skip archive symbol table\n"), file_name
);
10799 got
= fread (& arhdr
, 1, sizeof arhdr
, file
);
10800 if (got
!= sizeof arhdr
)
10808 error (_("%s: failed to read archive header following archive index\n"), file_name
);
10813 else if (do_archive_index
)
10814 printf (_("%s has no archive index\n"), file_name
);
10816 if (const_strneq (arhdr
.ar_name
, "// "))
10818 /* This is the archive string table holding long member
10821 longnames_size
= strtoul (arhdr
.ar_size
, NULL
, 10);
10822 longnames
= malloc (longnames_size
);
10823 if (longnames
== NULL
)
10825 error (_("Out of memory reading long symbol names in archive\n"));
10830 if (fread (longnames
, longnames_size
, 1, file
) != 1)
10833 error (_("%s: failed to read long symbol name string table\n"), file_name
);
10838 if ((longnames_size
& 1) != 0)
10841 got
= fread (& arhdr
, 1, sizeof arhdr
, file
);
10842 if (got
!= sizeof arhdr
)
10848 error (_("%s: failed to read archive header following long symbol names\n"), file_name
);
10855 if (do_archive_index
)
10857 if (sym_table
== NULL
)
10858 error (_("%s: unable to dump the index as none was found\n"), file_name
);
10861 unsigned int i
, j
, k
, l
;
10863 unsigned long current_pos
;
10865 printf (_("Index of archive %s: (%ld entries, 0x%lx bytes in the symbol table)\n"),
10866 file_name
, index_num
, sym_size
);
10867 current_pos
= ftell (file
);
10869 for (i
= l
= 0; i
< index_num
; i
++)
10871 if ((i
== 0) || ((i
> 0) && (index_array
[i
] != index_array
[i
- 1])))
10873 if (fseek (file
, index_array
[i
], SEEK_SET
) != 0)
10875 error (_("%s: failed to seek to next file name\n"), file_name
);
10879 got
= fread (elf_name
, 1, 16, file
);
10882 error (_("%s: failed to read file name\n"), file_name
);
10887 if (elf_name
[0] == '/')
10889 /* We have a long name. */
10890 k
= j
= strtoul (elf_name
+ 1, NULL
, 10);
10891 while ((j
< longnames_size
) && (longnames
[j
] != '/'))
10893 longnames
[j
] = '\0';
10894 printf (_("Binary %s contains:\n"), longnames
+ k
);
10895 longnames
[j
] = '/';
10900 while ((elf_name
[j
] != '/') && (j
< 16))
10902 elf_name
[j
] = '\0';
10903 printf(_("Binary %s contains:\n"), elf_name
);
10908 error (_("%s: end of the symbol table reached before the end of the index\n"),
10912 printf ("\t%s\n", sym_table
+ l
);
10913 l
+= strlen (sym_table
+ l
) + 1;
10917 error (_("%s: symbols remain in the index symbol table, but without corresponding entries in the index table\n"),
10920 free (index_array
);
10921 index_array
= NULL
;
10924 if (fseek (file
, current_pos
, SEEK_SET
) != 0)
10926 error (_("%s: failed to seek back to start of object files in the archive\n"), file_name
);
10931 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
10932 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
10933 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
10934 && !do_section_groups
)
10935 return 0; /* Archive index only. */
10938 file_name_size
= strlen (file_name
);
10947 if (arhdr
.ar_name
[0] == '/')
10951 off
= strtoul (arhdr
.ar_name
+ 1, NULL
, 10);
10952 if (off
>= longnames_size
)
10954 error (_("%s: invalid archive string table offset %lu\n"), file_name
, off
);
10959 name
= longnames
+ off
;
10960 nameend
= memchr (name
, '/', longnames_size
- off
);
10964 name
= arhdr
.ar_name
;
10965 nameend
= memchr (name
, '/', 16);
10968 if (nameend
== NULL
)
10970 error (_("%s: bad archive file name\n"), file_name
);
10975 namealc
= malloc (file_name_size
+ (nameend
- name
) + 3);
10976 if (namealc
== NULL
)
10978 error (_("Out of memory\n"));
10983 memcpy (namealc
, file_name
, file_name_size
);
10984 namealc
[file_name_size
] = '(';
10985 memcpy (namealc
+ file_name_size
+ 1, name
, nameend
- name
);
10986 namealc
[file_name_size
+ 1 + (nameend
- name
)] = ')';
10987 namealc
[file_name_size
+ 2 + (nameend
- name
)] = '\0';
10989 archive_file_offset
= ftell (file
);
10990 archive_file_size
= strtoul (arhdr
.ar_size
, NULL
, 10);
10992 ret
|= process_object (namealc
, file
);
10997 (archive_file_offset
10998 + archive_file_size
10999 + (archive_file_size
& 1)),
11002 error (_("%s: failed to seek to next archive header\n"), file_name
);
11007 got
= fread (&arhdr
, 1, sizeof arhdr
, file
);
11008 if (got
!= sizeof arhdr
)
11013 error (_("%s: failed to read archive header\n"), file_name
);
11020 if (index_array
!= NULL
)
11021 free (index_array
);
11022 if (sym_table
!= NULL
)
11024 if (longnames
!= NULL
)
11031 process_file (char *file_name
)
11034 struct stat statbuf
;
11035 char armag
[SARMAG
];
11038 if (stat (file_name
, &statbuf
) < 0)
11040 if (errno
== ENOENT
)
11041 error (_("'%s': No such file\n"), file_name
);
11043 error (_("Could not locate '%s'. System error message: %s\n"),
11044 file_name
, strerror (errno
));
11048 if (! S_ISREG (statbuf
.st_mode
))
11050 error (_("'%s' is not an ordinary file\n"), file_name
);
11054 file
= fopen (file_name
, "rb");
11057 error (_("Input file '%s' is not readable.\n"), file_name
);
11061 if (fread (armag
, SARMAG
, 1, file
) != 1)
11063 error (_("%s: Failed to read file's magic number\n"), file_name
);
11068 if (memcmp (armag
, ARMAG
, SARMAG
) == 0)
11069 ret
= process_archive (file_name
, file
);
11072 if (do_archive_index
)
11073 error (_("File %s is not an archive so its index cannot be displayed.\n"),
11077 archive_file_size
= archive_file_offset
= 0;
11078 ret
= process_object (file_name
, file
);
11086 #ifdef SUPPORT_DISASSEMBLY
11087 /* Needed by the i386 disassembler. For extra credit, someone could
11088 fix this so that we insert symbolic addresses here, esp for GOT/PLT
11092 print_address (unsigned int addr
, FILE *outfile
)
11094 fprintf (outfile
,"0x%8.8x", addr
);
11097 /* Needed by the i386 disassembler. */
11099 db_task_printsym (unsigned int addr
)
11101 print_address (addr
, stderr
);
11106 main (int argc
, char **argv
)
11110 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
11111 setlocale (LC_MESSAGES
, "");
11113 #if defined (HAVE_SETLOCALE)
11114 setlocale (LC_CTYPE
, "");
11116 bindtextdomain (PACKAGE
, LOCALEDIR
);
11117 textdomain (PACKAGE
);
11119 expandargv (&argc
, &argv
);
11121 parse_args (argc
, argv
);
11123 if (num_dump_sects
> 0)
11125 /* Make a copy of the dump_sects array. */
11126 cmdline_dump_sects
= malloc (num_dump_sects
* sizeof (* dump_sects
));
11127 if (cmdline_dump_sects
== NULL
)
11128 error (_("Out of memory allocating dump request table.\n"));
11131 memcpy (cmdline_dump_sects
, dump_sects
,
11132 num_dump_sects
* sizeof (* dump_sects
));
11133 num_cmdline_dump_sects
= num_dump_sects
;
11137 if (optind
< (argc
- 1))
11141 while (optind
< argc
)
11142 err
|= process_file (argv
[optind
++]);
11144 if (dump_sects
!= NULL
)
11146 if (cmdline_dump_sects
!= NULL
)
11147 free (cmdline_dump_sects
);