1 /* readelf.c -- display contents of an ELF format file
2 Copyright (C) 1998-2022 Free Software Foundation, Inc.
4 Originally developed by Eric Youngdale <eric@andante.jic.com>
5 Modifications by Nick Clifton <nickc@redhat.com>
7 This file is part of GNU Binutils.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
24 /* The difference between readelf and objdump:
26 Both programs are capable of displaying the contents of ELF format files,
27 so why does the binutils project have two file dumpers ?
29 The reason is that objdump sees an ELF file through a BFD filter of the
30 world; if BFD has a bug where, say, it disagrees about a machine constant
31 in e_flags, then the odds are good that it will remain internally
32 consistent. The linker sees it the BFD way, objdump sees it the BFD way,
33 GAS sees it the BFD way. There was need for a tool to go find out what
34 the file actually says.
36 This is why the readelf program does not link against the BFD library - it
37 exists as an independent program to help verify the correct working of BFD.
39 There is also the case that readelf can provide more information about an
40 ELF file than is provided by objdump. In particular it can display DWARF
41 debugging information which (at the moment) objdump cannot. */
50 /* Define BFD64 here, even if our default architecture is 32 bit ELF
51 as this will allow us to read in and parse 64bit and 32bit ELF files.
52 Only do this if we believe that the compiler can support a 64 bit
53 data type. For now we only rely on GCC being able to do this. */
60 #include "demanguse.h"
65 #include "elf/common.h"
66 #include "elf/external.h"
67 #include "elf/internal.h"
70 /* Included here, before RELOC_MACROS_GEN_FUNC is defined, so that
71 we can obtain the H8 reloc numbers. We need these for the
72 get_reloc_size() function. We include h8.h again after defining
73 RELOC_MACROS_GEN_FUNC so that we get the naming function as well. */
78 /* Undo the effects of #including reloc-macros.h. */
80 #undef START_RELOC_NUMBERS
84 #undef END_RELOC_NUMBERS
85 #undef _RELOC_MACROS_H
87 /* The following headers use the elf/reloc-macros.h file to
88 automatically generate relocation recognition functions
89 such as elf_mips_reloc_type() */
91 #define RELOC_MACROS_GEN_FUNC
93 #include "elf/aarch64.h"
94 #include "elf/alpha.h"
100 #include "elf/cris.h"
102 #include "elf/csky.h"
103 #include "elf/d10v.h"
104 #include "elf/d30v.h"
107 #include "elf/epiphany.h"
108 #include "elf/fr30.h"
110 #include "elf/ft32.h"
112 #include "elf/hppa.h"
113 #include "elf/i386.h"
114 #include "elf/i370.h"
115 #include "elf/i860.h"
116 #include "elf/i960.h"
117 #include "elf/ia64.h"
118 #include "elf/ip2k.h"
119 #include "elf/lm32.h"
120 #include "elf/iq2000.h"
121 #include "elf/m32c.h"
122 #include "elf/m32r.h"
123 #include "elf/m68k.h"
124 #include "elf/m68hc11.h"
125 #include "elf/s12z.h"
126 #include "elf/mcore.h"
128 #include "elf/metag.h"
129 #include "elf/microblaze.h"
130 #include "elf/mips.h"
131 #include "elf/mmix.h"
132 #include "elf/mn10200.h"
133 #include "elf/mn10300.h"
134 #include "elf/moxie.h"
136 #include "elf/msp430.h"
137 #include "elf/nds32.h"
139 #include "elf/nios2.h"
140 #include "elf/or1k.h"
143 #include "elf/ppc64.h"
145 #include "elf/riscv.h"
146 #include "elf/rl78.h"
148 #include "elf/s390.h"
149 #include "elf/score.h"
151 #include "elf/sparc.h"
153 #include "elf/tic6x.h"
154 #include "elf/tilegx.h"
155 #include "elf/tilepro.h"
156 #include "elf/v850.h"
158 #include "elf/visium.h"
159 #include "elf/wasm32.h"
160 #include "elf/x86-64.h"
161 #include "elf/xc16x.h"
162 #include "elf/xgate.h"
163 #include "elf/xstormy16.h"
164 #include "elf/xtensa.h"
166 #include "elf/loongarch.h"
169 #include "libiberty.h"
170 #include "safe-ctype.h"
171 #include "filenames.h"
174 #define offsetof(TYPE, MEMBER) ((size_t) &(((TYPE *) 0)->MEMBER))
177 typedef struct elf_section_list
179 Elf_Internal_Shdr
* hdr
;
180 struct elf_section_list
* next
;
183 /* Flag bits indicating particular types of dump. */
184 #define HEX_DUMP (1 << 0) /* The -x command line switch. */
185 #define DISASS_DUMP (1 << 1) /* The -i command line switch. */
186 #define DEBUG_DUMP (1 << 2) /* The -w command line switch. */
187 #define STRING_DUMP (1 << 3) /* The -p command line switch. */
188 #define RELOC_DUMP (1 << 4) /* The -R command line switch. */
189 #define CTF_DUMP (1 << 5) /* The --ctf command line switch. */
191 typedef unsigned char dump_type
;
193 /* A linked list of the section names for which dumps were requested. */
194 struct dump_list_entry
198 struct dump_list_entry
* next
;
201 /* A dynamic array of flags indicating for which sections a dump
202 has been requested via command line switches. */
205 dump_type
* dump_sects
;
206 unsigned int num_dump_sects
;
209 static struct dump_data cmdline
;
211 static struct dump_list_entry
* dump_sects_byname
;
213 char * program_name
= "readelf";
215 static bool show_name
= false;
216 static bool do_dynamic
= false;
217 static bool do_syms
= false;
218 static bool do_dyn_syms
= false;
219 static bool do_lto_syms
= false;
220 static bool do_reloc
= false;
221 static bool do_sections
= false;
222 static bool do_section_groups
= false;
223 static bool do_section_details
= false;
224 static bool do_segments
= false;
225 static bool do_unwind
= false;
226 static bool do_using_dynamic
= false;
227 static bool do_header
= false;
228 static bool do_dump
= false;
229 static bool do_version
= false;
230 static bool do_histogram
= false;
231 static bool do_debugging
= false;
232 static bool do_ctf
= false;
233 static bool do_arch
= false;
234 static bool do_notes
= false;
235 static bool do_archive_index
= false;
236 static bool check_all
= false;
237 static bool is_32bit_elf
= false;
238 static bool decompress_dumps
= false;
239 static bool do_not_show_symbol_truncation
= false;
240 static bool do_demangle
= false; /* Pretty print C++ symbol names. */
241 static bool process_links
= false;
242 static int demangle_flags
= DMGL_ANSI
| DMGL_PARAMS
;
243 static int sym_base
= 0;
245 static char *dump_ctf_parent_name
;
246 static char *dump_ctf_symtab_name
;
247 static char *dump_ctf_strtab_name
;
251 struct group_list
* next
;
252 unsigned int section_index
;
257 struct group_list
* root
;
258 unsigned int group_index
;
261 typedef struct filedata
263 const char * file_name
;
266 bfd_size_type file_size
;
267 Elf_Internal_Ehdr file_header
;
268 unsigned long archive_file_offset
;
269 unsigned long archive_file_size
;
270 /* Everything below this point is cleared out by free_filedata. */
271 Elf_Internal_Shdr
* section_headers
;
272 Elf_Internal_Phdr
* program_headers
;
274 unsigned long string_table_length
;
275 unsigned long dynamic_addr
;
276 bfd_size_type dynamic_size
;
278 Elf_Internal_Dyn
* dynamic_section
;
279 Elf_Internal_Shdr
* dynamic_strtab_section
;
280 char * dynamic_strings
;
281 unsigned long dynamic_strings_length
;
282 Elf_Internal_Shdr
* dynamic_symtab_section
;
283 unsigned long num_dynamic_syms
;
284 Elf_Internal_Sym
* dynamic_symbols
;
285 bfd_vma version_info
[16];
286 unsigned int dynamic_syminfo_nent
;
287 Elf_Internal_Syminfo
* dynamic_syminfo
;
288 unsigned long dynamic_syminfo_offset
;
289 bfd_size_type nbuckets
;
290 bfd_size_type nchains
;
293 bfd_size_type ngnubuckets
;
294 bfd_size_type ngnuchains
;
295 bfd_vma
* gnubuckets
;
299 char * program_interpreter
;
300 bfd_vma dynamic_info
[DT_ENCODING
];
301 bfd_vma dynamic_info_DT_GNU_HASH
;
302 bfd_vma dynamic_info_DT_MIPS_XHASH
;
303 elf_section_list
* symtab_shndx_list
;
305 struct group
* section_groups
;
306 struct group
** section_headers_groups
;
307 /* A dynamic array of flags indicating for which sections a dump of
308 some kind has been requested. It is reset on a per-object file
309 basis and then initialised from the cmdline_dump_sects array,
310 the results of interpreting the -w switch, and the
311 dump_sects_byname list. */
312 struct dump_data dump
;
315 /* How to print a vma value. */
316 typedef enum print_mode
333 typedef enum unicode_display_type
341 } unicode_display_type
;
343 static unicode_display_type unicode_display
= unicode_default
;
353 /* Versioned symbol info. */
354 enum versioned_symbol_info
361 static const char * get_symbol_version_string
362 (Filedata
*, bool, const char *, unsigned long, unsigned,
363 Elf_Internal_Sym
*, enum versioned_symbol_info
*, unsigned short *);
367 static inline const char *
368 section_name (const Filedata
*filedata
, const Elf_Internal_Shdr
*hdr
)
370 return filedata
->string_table
+ hdr
->sh_name
;
374 section_name_valid (const Filedata
*filedata
, const Elf_Internal_Shdr
*hdr
)
377 && filedata
->string_table
!= NULL
378 && hdr
->sh_name
< filedata
->string_table_length
);
381 static inline const char *
382 section_name_print (const Filedata
*filedata
, const Elf_Internal_Shdr
*hdr
)
386 if (filedata
->string_table
== NULL
)
387 return _("<no-strings>");
388 if (hdr
->sh_name
>= filedata
->string_table_length
)
389 return _("<corrupt>");
390 return section_name (filedata
, hdr
);
393 #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
396 valid_symbol_name (const char *strtab
, size_t strtab_size
, uint64_t offset
)
398 return strtab
!= NULL
&& offset
< strtab_size
;
402 valid_dynamic_name (const Filedata
*filedata
, uint64_t offset
)
404 return valid_symbol_name (filedata
->dynamic_strings
,
405 filedata
->dynamic_strings_length
, offset
);
408 /* GET_DYNAMIC_NAME asssumes that VALID_DYNAMIC_NAME has
409 already been called and verified that the string exists. */
410 static inline const char *
411 get_dynamic_name (const Filedata
*filedata
, size_t offset
)
413 return filedata
->dynamic_strings
+ offset
;
416 #define REMOVE_ARCH_BITS(ADDR) \
419 if (filedata->file_header.e_machine == EM_ARM) \
424 /* Get the correct GNU hash section name. */
425 #define GNU_HASH_SECTION_NAME(filedata) \
426 filedata->dynamic_info_DT_MIPS_XHASH ? ".MIPS.xhash" : ".gnu.hash"
428 /* Print a BFD_VMA to an internal buffer, for use in error messages.
429 BFD_FMA_FMT can't be used in translated strings. */
432 bfd_vmatoa (char *fmtch
, bfd_vma value
)
434 /* bfd_vmatoa is used more then once in a printf call for output.
435 Cycle through an array of buffers. */
436 static int buf_pos
= 0;
437 static struct bfd_vmatoa_buf
444 ret
= buf
[buf_pos
++].place
;
445 buf_pos
%= ARRAY_SIZE (buf
);
447 sprintf (fmt
, "%%%s%s", BFD_VMA_FMT
, fmtch
);
448 snprintf (ret
, sizeof (buf
[0].place
), fmt
, value
);
452 /* Retrieve NMEMB structures, each SIZE bytes long from FILEDATA starting at
453 OFFSET + the offset of the current archive member, if we are examining an
454 archive. Put the retrieved data into VAR, if it is not NULL. Otherwise
455 allocate a buffer using malloc and fill that. In either case return the
456 pointer to the start of the retrieved data or NULL if something went wrong.
457 If something does go wrong and REASON is not NULL then emit an error
458 message using REASON as part of the context. */
461 get_data (void * var
,
463 unsigned long offset
,
469 bfd_size_type amt
= size
* nmemb
;
471 if (size
== 0 || nmemb
== 0)
474 /* If the size_t type is smaller than the bfd_size_type, eg because
475 you are building a 32-bit tool on a 64-bit host, then make sure
476 that when the sizes are cast to (size_t) no information is lost. */
477 if ((size_t) size
!= size
478 || (size_t) nmemb
!= nmemb
479 || (size_t) amt
!= amt
)
482 error (_("Size truncation prevents reading %s"
483 " elements of size %s for %s\n"),
484 bfd_vmatoa ("u", nmemb
), bfd_vmatoa ("u", size
), reason
);
488 /* Check for size overflow. */
489 if (amt
/ size
!= nmemb
|| (size_t) amt
+ 1 == 0)
492 error (_("Size overflow prevents reading %s"
493 " elements of size %s for %s\n"),
494 bfd_vmatoa ("u", nmemb
), bfd_vmatoa ("u", size
), reason
);
498 /* Be kind to memory checkers (eg valgrind, address sanitizer) by not
499 attempting to allocate memory when the read is bound to fail. */
500 if (filedata
->archive_file_offset
> filedata
->file_size
501 || offset
> filedata
->file_size
- filedata
->archive_file_offset
502 || amt
> filedata
->file_size
- filedata
->archive_file_offset
- offset
)
505 error (_("Reading %s bytes extends past end of file for %s\n"),
506 bfd_vmatoa ("u", amt
), reason
);
510 if (fseek (filedata
->handle
, filedata
->archive_file_offset
+ offset
,
514 error (_("Unable to seek to 0x%lx for %s\n"),
515 filedata
->archive_file_offset
+ offset
, reason
);
522 /* + 1 so that we can '\0' terminate invalid string table sections. */
523 mvar
= malloc ((size_t) amt
+ 1);
528 error (_("Out of memory allocating %s bytes for %s\n"),
529 bfd_vmatoa ("u", amt
), reason
);
533 ((char *) mvar
)[amt
] = '\0';
536 if (fread (mvar
, (size_t) size
, (size_t) nmemb
, filedata
->handle
) != nmemb
)
539 error (_("Unable to read in %s bytes of %s\n"),
540 bfd_vmatoa ("u", amt
), reason
);
549 /* Print a VMA value in the MODE specified.
550 Returns the number of characters displayed. */
553 print_vma (bfd_vma vma
, print_mode mode
)
565 return nc
+ printf ("%8.8" BFD_VMA_FMT
"x", vma
);
572 return printf ("%5" BFD_VMA_FMT
"d", vma
);
578 return nc
+ printf ("%" BFD_VMA_FMT
"x", vma
);
584 return nc
+ printf ("%05" BFD_VMA_FMT
"x", vma
);
587 return printf ("%" BFD_VMA_FMT
"d", vma
);
590 return printf ("%" BFD_VMA_FMT
"u", vma
);
593 return printf ("%5" BFD_VMA_FMT
"u", vma
);
596 return printf ("%" BFD_VMA_FMT
"o", vma
);
599 return printf ("%5" BFD_VMA_FMT
"o", vma
);
602 /* FIXME: Report unrecognised mode ? */
608 /* Display a symbol on stdout. Handles the display of control characters and
609 multibye characters (assuming the host environment supports them).
611 Display at most abs(WIDTH) characters, truncating as necessary, unless do_wide is true.
613 If truncation will happen and do_not_show_symbol_truncation is FALSE then display
614 abs(WIDTH) - 5 characters followed by "[...]".
616 If WIDTH is negative then ensure that the output is at least (- WIDTH) characters,
617 padding as necessary.
619 Returns the number of emitted characters. */
622 print_symbol (signed int width
, const char * symbol
)
624 bool extra_padding
= false;
625 bool do_dots
= false;
626 signed int num_printed
= 0;
627 #ifdef HAVE_MBSTATE_T
630 unsigned int width_remaining
;
631 const void * alloced_symbol
= NULL
;
635 /* Keep the width positive. This helps the code below. */
637 extra_padding
= true;
643 /* Set the remaining width to a very large value.
644 This simplifies the code below. */
645 width_remaining
= INT_MAX
;
648 width_remaining
= width
;
649 if (! do_not_show_symbol_truncation
650 && (int) strlen (symbol
) > width
)
652 width_remaining
-= 5;
653 if ((int) width_remaining
< 0)
659 #ifdef HAVE_MBSTATE_T
660 /* Initialise the multibyte conversion state. */
661 memset (& state
, 0, sizeof (state
));
664 if (do_demangle
&& *symbol
)
666 const char * res
= cplus_demangle (symbol
, demangle_flags
);
669 alloced_symbol
= symbol
= res
;
672 while (width_remaining
)
675 const char c
= *symbol
++;
686 else if (ISCNTRL (c
))
688 /* Do not print control characters directly as they can affect terminal
689 settings. Such characters usually appear in the names generated
690 by the assembler for local labels. */
692 if (width_remaining
< 2)
695 printf ("^%c", c
+ 0x40);
696 width_remaining
-= 2;
701 if (width_remaining
< 5)
704 width_remaining
-= 5;
707 else if (unicode_display
!= unicode_locale
708 && unicode_display
!= unicode_default
)
710 /* Display unicode characters as something else. */
711 unsigned char bytes
[4];
724 bytes
[1] = *symbol
++;
726 if ((bytes
[1] & 0xc0) != 0x80)
729 /* Do not consume this character. It may only
730 be the first byte in the sequence that was
735 else if ((bytes
[0] & 0x20) == 0)
742 bytes
[2] = *symbol
++;
744 if ((bytes
[2] & 0xc0) != 0x80)
750 else if ((bytes
[0] & 0x10) == 0)
757 bytes
[3] = *symbol
++;
761 if ((bytes
[3] & 0xc0) != 0x80)
773 if (unicode_display
== unicode_invalid
)
776 if (unicode_display
== unicode_hex
|| ! is_utf8
)
780 if (width_remaining
< (nbytes
* 2) + 2)
783 putchar (is_utf8
? '<' : '{');
785 for (i
= 0; i
< nbytes
; i
++)
786 printf ("%02x", bytes
[i
]);
787 putchar (is_utf8
? '>' : '}');
791 if (unicode_display
== unicode_highlight
&& isatty (1))
792 printf ("\x1B[31;47m"); /* Red. */
797 if (width_remaining
< 6)
799 printf ("\\u%02x%02x",
800 (bytes
[0] & 0x1c) >> 2,
801 ((bytes
[0] & 0x03) << 6) | (bytes
[1] & 0x3f));
804 if (width_remaining
< 6)
806 printf ("\\u%02x%02x",
807 ((bytes
[0] & 0x0f) << 4) | ((bytes
[1] & 0x3c) >> 2),
808 ((bytes
[1] & 0x03) << 6) | (bytes
[2] & 0x3f));
811 if (width_remaining
< 8)
813 printf ("\\u%02x%02x%02x",
814 ((bytes
[0] & 0x07) << 6) | ((bytes
[1] & 0x3c) >> 2),
815 ((bytes
[1] & 0x03) << 6) | ((bytes
[2] & 0x3c) >> 2),
816 ((bytes
[2] & 0x03) << 6) | (bytes
[3] & 0x3f));
824 if (unicode_display
== unicode_highlight
&& isatty (1))
825 printf ("\033[0m"); /* Default colour. */
828 if (bytes
[nbytes
- 1] == 0)
833 #ifdef HAVE_MBSTATE_T
836 /* Let printf do the hard work of displaying multibyte characters. */
837 printf ("%.1s", symbol
- 1);
841 #ifdef HAVE_MBSTATE_T
842 /* Try to find out how many bytes made up the character that was
843 just printed. Advance the symbol pointer past the bytes that
845 n
= mbrtowc (& w
, symbol
- 1, MB_CUR_MAX
, & state
);
849 if (n
!= (size_t) -1 && n
!= (size_t) -2 && n
> 0)
855 num_printed
+= printf ("[...]");
857 if (extra_padding
&& num_printed
< width
)
859 /* Fill in the remaining spaces. */
860 printf ("%-*s", width
- num_printed
, " ");
864 free ((void *) alloced_symbol
);
868 /* Returns a pointer to a static buffer containing a printable version of
869 the given section's name. Like print_symbol, except that it does not try
870 to print multibyte characters, it just interprets them as hex values. */
873 printable_section_name (Filedata
* filedata
, const Elf_Internal_Shdr
* sec
)
875 #define MAX_PRINT_SEC_NAME_LEN 256
876 static char sec_name_buf
[MAX_PRINT_SEC_NAME_LEN
+ 1];
877 const char * name
= section_name_print (filedata
, sec
);
878 char * buf
= sec_name_buf
;
880 unsigned int remaining
= MAX_PRINT_SEC_NAME_LEN
;
882 while ((c
= * name
++) != 0)
893 else if (ISPRINT (c
))
900 static char hex
[17] = "0123456789ABCDEF";
905 * buf
++ = hex
[(c
& 0xf0) >> 4];
906 * buf
++ = hex
[c
& 0x0f];
920 printable_section_name_from_index (Filedata
* filedata
, unsigned long ndx
)
922 if (ndx
>= filedata
->file_header
.e_shnum
)
923 return _("<corrupt>");
925 return printable_section_name (filedata
, filedata
->section_headers
+ ndx
);
928 /* Return a pointer to section NAME, or NULL if no such section exists. */
930 static Elf_Internal_Shdr
*
931 find_section (Filedata
* filedata
, const char * name
)
935 if (filedata
->section_headers
== NULL
)
938 for (i
= 0; i
< filedata
->file_header
.e_shnum
; i
++)
939 if (section_name_valid (filedata
, filedata
->section_headers
+ i
)
940 && streq (section_name (filedata
, filedata
->section_headers
+ i
),
942 return filedata
->section_headers
+ i
;
947 /* Return a pointer to a section containing ADDR, or NULL if no such
950 static Elf_Internal_Shdr
*
951 find_section_by_address (Filedata
* filedata
, bfd_vma addr
)
955 if (filedata
->section_headers
== NULL
)
958 for (i
= 0; i
< filedata
->file_header
.e_shnum
; i
++)
960 Elf_Internal_Shdr
*sec
= filedata
->section_headers
+ i
;
962 if (addr
>= sec
->sh_addr
&& addr
< sec
->sh_addr
+ sec
->sh_size
)
969 static Elf_Internal_Shdr
*
970 find_section_by_type (Filedata
* filedata
, unsigned int type
)
974 if (filedata
->section_headers
== NULL
)
977 for (i
= 0; i
< filedata
->file_header
.e_shnum
; i
++)
979 Elf_Internal_Shdr
*sec
= filedata
->section_headers
+ i
;
981 if (sec
->sh_type
== type
)
988 /* Return a pointer to section NAME, or NULL if no such section exists,
989 restricted to the list of sections given in SET. */
991 static Elf_Internal_Shdr
*
992 find_section_in_set (Filedata
* filedata
, const char * name
, unsigned int * set
)
996 if (filedata
->section_headers
== NULL
)
1001 while ((i
= *set
++) > 0)
1003 /* See PR 21156 for a reproducer. */
1004 if (i
>= filedata
->file_header
.e_shnum
)
1005 continue; /* FIXME: Should we issue an error message ? */
1007 if (section_name_valid (filedata
, filedata
->section_headers
+ i
)
1008 && streq (section_name (filedata
, filedata
->section_headers
+ i
),
1010 return filedata
->section_headers
+ i
;
1014 return find_section (filedata
, name
);
1017 /* Return TRUE if the current file is for IA-64 machine and OpenVMS ABI.
1018 This OS has so many departures from the ELF standard that we test it at
1022 is_ia64_vms (Filedata
* filedata
)
1024 return filedata
->file_header
.e_machine
== EM_IA_64
1025 && filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_OPENVMS
;
1028 /* Guess the relocation size commonly used by the specific machines. */
1031 guess_is_rela (unsigned int e_machine
)
1035 /* Targets that use REL relocations. */
1041 case EM_CYGNUS_D10V
:
1044 case EM_MIPS_RS3_LE
:
1045 case EM_CYGNUS_M32R
:
1052 /* Targets that use RELA relocations. */
1056 case EM_ADAPTEVA_EPIPHANY
:
1058 case EM_ALTERA_NIOS2
:
1060 case EM_ARC_COMPACT
:
1061 case EM_ARC_COMPACT2
:
1070 case EM_CYGNUS_D30V
:
1073 case EM_CYGNUS_FR30
:
1082 case EM_LATTICEMICO32
:
1091 case EM_CYGNUS_MN10200
:
1093 case EM_CYGNUS_MN10300
:
1111 case EM_SPARC32PLUS
:
1119 case EM_CYGNUS_V850
:
1129 case EM_MICROBLAZE_OLD
:
1130 case EM_WEBASSEMBLY
:
1151 warn (_("Don't know about relocations on this machine architecture\n"));
1156 /* Load RELA type relocations from FILEDATA at REL_OFFSET extending for REL_SIZE bytes.
1157 Returns TRUE upon success, FALSE otherwise. If successful then a
1158 pointer to a malloc'ed buffer containing the relocs is placed in *RELASP,
1159 and the number of relocs loaded is placed in *NRELASP. It is the caller's
1160 responsibility to free the allocated buffer. */
1163 slurp_rela_relocs (Filedata
* filedata
,
1164 unsigned long rel_offset
,
1165 unsigned long rel_size
,
1166 Elf_Internal_Rela
** relasp
,
1167 unsigned long * nrelasp
)
1169 Elf_Internal_Rela
* relas
;
1175 Elf32_External_Rela
* erelas
;
1177 erelas
= (Elf32_External_Rela
*) get_data (NULL
, filedata
, rel_offset
, 1,
1178 rel_size
, _("32-bit relocation data"));
1182 nrelas
= rel_size
/ sizeof (Elf32_External_Rela
);
1184 relas
= (Elf_Internal_Rela
*) cmalloc (nrelas
,
1185 sizeof (Elf_Internal_Rela
));
1190 error (_("out of memory parsing relocs\n"));
1194 for (i
= 0; i
< nrelas
; i
++)
1196 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
1197 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
1198 relas
[i
].r_addend
= BYTE_GET_SIGNED (erelas
[i
].r_addend
);
1205 Elf64_External_Rela
* erelas
;
1207 erelas
= (Elf64_External_Rela
*) get_data (NULL
, filedata
, rel_offset
, 1,
1208 rel_size
, _("64-bit relocation data"));
1212 nrelas
= rel_size
/ sizeof (Elf64_External_Rela
);
1214 relas
= (Elf_Internal_Rela
*) cmalloc (nrelas
,
1215 sizeof (Elf_Internal_Rela
));
1220 error (_("out of memory parsing relocs\n"));
1224 for (i
= 0; i
< nrelas
; i
++)
1226 relas
[i
].r_offset
= BYTE_GET (erelas
[i
].r_offset
);
1227 relas
[i
].r_info
= BYTE_GET (erelas
[i
].r_info
);
1228 relas
[i
].r_addend
= BYTE_GET_SIGNED (erelas
[i
].r_addend
);
1230 /* The #ifdef BFD64 below is to prevent a compile time
1231 warning. We know that if we do not have a 64 bit data
1232 type that we will never execute this code anyway. */
1234 if (filedata
->file_header
.e_machine
== EM_MIPS
1235 && filedata
->file_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
1237 /* In little-endian objects, r_info isn't really a
1238 64-bit little-endian value: it has a 32-bit
1239 little-endian symbol index followed by four
1240 individual byte fields. Reorder INFO
1242 bfd_vma inf
= relas
[i
].r_info
;
1243 inf
= (((inf
& 0xffffffff) << 32)
1244 | ((inf
>> 56) & 0xff)
1245 | ((inf
>> 40) & 0xff00)
1246 | ((inf
>> 24) & 0xff0000)
1247 | ((inf
>> 8) & 0xff000000));
1248 relas
[i
].r_info
= inf
;
1261 /* Load REL type relocations from FILEDATA at REL_OFFSET extending for REL_SIZE bytes.
1262 Returns TRUE upon success, FALSE otherwise. If successful then a
1263 pointer to a malloc'ed buffer containing the relocs is placed in *RELSP,
1264 and the number of relocs loaded is placed in *NRELSP. It is the caller's
1265 responsibility to free the allocated buffer. */
1268 slurp_rel_relocs (Filedata
* filedata
,
1269 unsigned long rel_offset
,
1270 unsigned long rel_size
,
1271 Elf_Internal_Rela
** relsp
,
1272 unsigned long * nrelsp
)
1274 Elf_Internal_Rela
* rels
;
1280 Elf32_External_Rel
* erels
;
1282 erels
= (Elf32_External_Rel
*) get_data (NULL
, filedata
, rel_offset
, 1,
1283 rel_size
, _("32-bit relocation data"));
1287 nrels
= rel_size
/ sizeof (Elf32_External_Rel
);
1289 rels
= (Elf_Internal_Rela
*) cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
1294 error (_("out of memory parsing relocs\n"));
1298 for (i
= 0; i
< nrels
; i
++)
1300 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
1301 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
1302 rels
[i
].r_addend
= 0;
1309 Elf64_External_Rel
* erels
;
1311 erels
= (Elf64_External_Rel
*) get_data (NULL
, filedata
, rel_offset
, 1,
1312 rel_size
, _("64-bit relocation data"));
1316 nrels
= rel_size
/ sizeof (Elf64_External_Rel
);
1318 rels
= (Elf_Internal_Rela
*) cmalloc (nrels
, sizeof (Elf_Internal_Rela
));
1323 error (_("out of memory parsing relocs\n"));
1327 for (i
= 0; i
< nrels
; i
++)
1329 rels
[i
].r_offset
= BYTE_GET (erels
[i
].r_offset
);
1330 rels
[i
].r_info
= BYTE_GET (erels
[i
].r_info
);
1331 rels
[i
].r_addend
= 0;
1333 /* The #ifdef BFD64 below is to prevent a compile time
1334 warning. We know that if we do not have a 64 bit data
1335 type that we will never execute this code anyway. */
1337 if (filedata
->file_header
.e_machine
== EM_MIPS
1338 && filedata
->file_header
.e_ident
[EI_DATA
] != ELFDATA2MSB
)
1340 /* In little-endian objects, r_info isn't really a
1341 64-bit little-endian value: it has a 32-bit
1342 little-endian symbol index followed by four
1343 individual byte fields. Reorder INFO
1345 bfd_vma inf
= rels
[i
].r_info
;
1346 inf
= (((inf
& 0xffffffff) << 32)
1347 | ((inf
>> 56) & 0xff)
1348 | ((inf
>> 40) & 0xff00)
1349 | ((inf
>> 24) & 0xff0000)
1350 | ((inf
>> 8) & 0xff000000));
1351 rels
[i
].r_info
= inf
;
1365 slurp_relr_relocs (Filedata
* filedata
,
1366 unsigned long relr_offset
,
1367 unsigned long relr_size
,
1369 unsigned long * nrelrsp
)
1372 size_t size
= 0, nentries
, i
;
1373 bfd_vma base
= 0, addr
, entry
;
1375 relrs
= get_data (NULL
, filedata
, relr_offset
, 1, relr_size
,
1376 _("RELR relocation data"));
1381 nentries
= relr_size
/ sizeof (Elf32_External_Relr
);
1383 nentries
= relr_size
/ sizeof (Elf64_External_Relr
);
1384 for (i
= 0; i
< nentries
; i
++)
1387 entry
= BYTE_GET (((Elf32_External_Relr
*)relrs
)[i
].r_data
);
1389 entry
= BYTE_GET (((Elf64_External_Relr
*)relrs
)[i
].r_data
);
1390 if ((entry
& 1) == 0)
1393 while ((entry
>>= 1) != 0)
1394 if ((entry
& 1) == 1)
1398 *relrsp
= (bfd_vma
*) xmalloc (size
* sizeof (bfd_vma
));
1399 if (*relrsp
== NULL
)
1402 error (_("out of memory parsing relocs\n"));
1407 for (i
= 0; i
< nentries
; i
++)
1409 const bfd_vma entry_bytes
= is_32bit_elf
? 4 : 8;
1412 entry
= BYTE_GET (((Elf32_External_Relr
*)relrs
)[i
].r_data
);
1414 entry
= BYTE_GET (((Elf64_External_Relr
*)relrs
)[i
].r_data
);
1415 if ((entry
& 1) == 0)
1417 (*relrsp
)[size
++] = entry
;
1418 base
= entry
+ entry_bytes
;
1422 for (addr
= base
; (entry
>>= 1) != 0; addr
+= entry_bytes
)
1423 if ((entry
& 1) != 0)
1424 (*relrsp
)[size
++] = addr
;
1425 base
+= entry_bytes
* (entry_bytes
* CHAR_BIT
- 1);
1434 /* Returns the reloc type extracted from the reloc info field. */
1437 get_reloc_type (Filedata
* filedata
, bfd_vma reloc_info
)
1440 return ELF32_R_TYPE (reloc_info
);
1442 switch (filedata
->file_header
.e_machine
)
1445 /* Note: We assume that reloc_info has already been adjusted for us. */
1446 return ELF64_MIPS_R_TYPE (reloc_info
);
1449 return ELF64_R_TYPE_ID (reloc_info
);
1452 return ELF64_R_TYPE (reloc_info
);
1456 /* Return the symbol index extracted from the reloc info field. */
1459 get_reloc_symindex (bfd_vma reloc_info
)
1461 return is_32bit_elf
? ELF32_R_SYM (reloc_info
) : ELF64_R_SYM (reloc_info
);
1465 uses_msp430x_relocs (Filedata
* filedata
)
1468 filedata
->file_header
.e_machine
== EM_MSP430
/* Paranoia. */
1469 /* GCC uses osabi == ELFOSBI_STANDALONE. */
1470 && (((filedata
->file_header
.e_flags
& EF_MSP430_MACH
) == E_MSP430_MACH_MSP430X
)
1471 /* TI compiler uses ELFOSABI_NONE. */
1472 || (filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_NONE
));
1475 /* Display the contents of the relocation data found at the specified
1479 dump_relocations (Filedata
* filedata
,
1480 unsigned long rel_offset
,
1481 unsigned long rel_size
,
1482 Elf_Internal_Sym
* symtab
,
1483 unsigned long nsyms
,
1485 unsigned long strtablen
,
1486 relocation_type rel_type
,
1490 Elf_Internal_Rela
* rels
;
1493 if (rel_type
== reltype_unknown
)
1494 rel_type
= guess_is_rela (filedata
->file_header
.e_machine
) ? reltype_rela
: reltype_rel
;
1496 if (rel_type
== reltype_rela
)
1498 if (!slurp_rela_relocs (filedata
, rel_offset
, rel_size
, &rels
, &rel_size
))
1501 else if (rel_type
== reltype_rel
)
1503 if (!slurp_rel_relocs (filedata
, rel_offset
, rel_size
, &rels
, &rel_size
))
1506 else if (rel_type
== reltype_relr
)
1510 = is_32bit_elf
? "%08" BFD_VMA_FMT
"x\n" : "%016" BFD_VMA_FMT
"x\n";
1512 if (!slurp_relr_relocs (filedata
, rel_offset
, rel_size
, &relrs
,
1516 printf (ngettext (" %lu offset\n", " %lu offsets\n", rel_size
), rel_size
);
1517 for (i
= 0; i
< rel_size
; i
++)
1518 printf (format
, relrs
[i
]);
1525 if (rel_type
== reltype_rela
)
1528 printf (_(" Offset Info Type Sym. Value Symbol's Name + Addend\n"));
1530 printf (_(" Offset Info Type Sym.Value Sym. Name + Addend\n"));
1535 printf (_(" Offset Info Type Sym. Value Symbol's Name\n"));
1537 printf (_(" Offset Info Type Sym.Value Sym. Name\n"));
1542 if (rel_type
== reltype_rela
)
1545 printf (_(" Offset Info Type Symbol's Value Symbol's Name + Addend\n"));
1547 printf (_(" Offset Info Type Sym. Value Sym. Name + Addend\n"));
1552 printf (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
1554 printf (_(" Offset Info Type Sym. Value Sym. Name\n"));
1558 for (i
= 0; i
< rel_size
; i
++)
1563 bfd_vma symtab_index
;
1566 offset
= rels
[i
].r_offset
;
1567 inf
= rels
[i
].r_info
;
1569 type
= get_reloc_type (filedata
, inf
);
1570 symtab_index
= get_reloc_symindex (inf
);
1574 printf ("%8.8lx %8.8lx ",
1575 (unsigned long) offset
& 0xffffffff,
1576 (unsigned long) inf
& 0xffffffff);
1581 ? "%16.16" BFD_VMA_FMT
"x %16.16" BFD_VMA_FMT
"x "
1582 : "%12.12" BFD_VMA_FMT
"x %12.12" BFD_VMA_FMT
"x ",
1586 switch (filedata
->file_header
.e_machine
)
1593 rtype
= elf_aarch64_reloc_type (type
);
1597 case EM_CYGNUS_M32R
:
1598 rtype
= elf_m32r_reloc_type (type
);
1603 rtype
= elf_i386_reloc_type (type
);
1608 rtype
= elf_m68hc11_reloc_type (type
);
1612 rtype
= elf_s12z_reloc_type (type
);
1616 rtype
= elf_m68k_reloc_type (type
);
1620 rtype
= elf_i960_reloc_type (type
);
1625 rtype
= elf_avr_reloc_type (type
);
1628 case EM_OLD_SPARCV9
:
1629 case EM_SPARC32PLUS
:
1632 rtype
= elf_sparc_reloc_type (type
);
1636 rtype
= elf_spu_reloc_type (type
);
1640 rtype
= v800_reloc_type (type
);
1643 case EM_CYGNUS_V850
:
1644 rtype
= v850_reloc_type (type
);
1648 case EM_CYGNUS_D10V
:
1649 rtype
= elf_d10v_reloc_type (type
);
1653 case EM_CYGNUS_D30V
:
1654 rtype
= elf_d30v_reloc_type (type
);
1658 rtype
= elf_dlx_reloc_type (type
);
1662 rtype
= elf_sh_reloc_type (type
);
1666 case EM_CYGNUS_MN10300
:
1667 rtype
= elf_mn10300_reloc_type (type
);
1671 case EM_CYGNUS_MN10200
:
1672 rtype
= elf_mn10200_reloc_type (type
);
1676 case EM_CYGNUS_FR30
:
1677 rtype
= elf_fr30_reloc_type (type
);
1681 rtype
= elf_frv_reloc_type (type
);
1685 rtype
= elf_csky_reloc_type (type
);
1689 rtype
= elf_ft32_reloc_type (type
);
1693 rtype
= elf_mcore_reloc_type (type
);
1697 rtype
= elf_mmix_reloc_type (type
);
1701 rtype
= elf_moxie_reloc_type (type
);
1705 if (uses_msp430x_relocs (filedata
))
1707 rtype
= elf_msp430x_reloc_type (type
);
1712 rtype
= elf_msp430_reloc_type (type
);
1716 rtype
= elf_nds32_reloc_type (type
);
1720 rtype
= elf_ppc_reloc_type (type
);
1724 rtype
= elf_ppc64_reloc_type (type
);
1728 case EM_MIPS_RS3_LE
:
1729 rtype
= elf_mips_reloc_type (type
);
1733 rtype
= elf_riscv_reloc_type (type
);
1737 rtype
= elf_alpha_reloc_type (type
);
1741 rtype
= elf_arm_reloc_type (type
);
1745 case EM_ARC_COMPACT
:
1746 case EM_ARC_COMPACT2
:
1747 rtype
= elf_arc_reloc_type (type
);
1751 rtype
= elf_hppa_reloc_type (type
);
1757 rtype
= elf_h8_reloc_type (type
);
1761 rtype
= elf_or1k_reloc_type (type
);
1766 rtype
= elf_pj_reloc_type (type
);
1769 rtype
= elf_ia64_reloc_type (type
);
1773 rtype
= elf_cris_reloc_type (type
);
1777 rtype
= elf_i860_reloc_type (type
);
1783 rtype
= elf_x86_64_reloc_type (type
);
1787 rtype
= i370_reloc_type (type
);
1792 rtype
= elf_s390_reloc_type (type
);
1796 rtype
= elf_score_reloc_type (type
);
1800 rtype
= elf_xstormy16_reloc_type (type
);
1804 rtype
= elf_crx_reloc_type (type
);
1808 rtype
= elf_vax_reloc_type (type
);
1812 rtype
= elf_visium_reloc_type (type
);
1816 rtype
= elf_bpf_reloc_type (type
);
1819 case EM_ADAPTEVA_EPIPHANY
:
1820 rtype
= elf_epiphany_reloc_type (type
);
1825 rtype
= elf_ip2k_reloc_type (type
);
1829 rtype
= elf_iq2000_reloc_type (type
);
1834 rtype
= elf_xtensa_reloc_type (type
);
1837 case EM_LATTICEMICO32
:
1838 rtype
= elf_lm32_reloc_type (type
);
1843 rtype
= elf_m32c_reloc_type (type
);
1847 rtype
= elf_mt_reloc_type (type
);
1851 rtype
= elf_bfin_reloc_type (type
);
1855 rtype
= elf_mep_reloc_type (type
);
1859 rtype
= elf_cr16_reloc_type (type
);
1863 case EM_MICROBLAZE_OLD
:
1864 rtype
= elf_microblaze_reloc_type (type
);
1868 rtype
= elf_rl78_reloc_type (type
);
1872 rtype
= elf_rx_reloc_type (type
);
1876 rtype
= elf_metag_reloc_type (type
);
1881 rtype
= elf_xc16x_reloc_type (type
);
1885 rtype
= elf_tic6x_reloc_type (type
);
1889 rtype
= elf_tilegx_reloc_type (type
);
1893 rtype
= elf_tilepro_reloc_type (type
);
1896 case EM_WEBASSEMBLY
:
1897 rtype
= elf_wasm32_reloc_type (type
);
1901 rtype
= elf_xgate_reloc_type (type
);
1904 case EM_ALTERA_NIOS2
:
1905 rtype
= elf_nios2_reloc_type (type
);
1909 rtype
= elf_pru_reloc_type (type
);
1913 if (EF_NFP_MACH (filedata
->file_header
.e_flags
) == E_NFP_MACH_3200
)
1914 rtype
= elf_nfp3200_reloc_type (type
);
1916 rtype
= elf_nfp_reloc_type (type
);
1920 rtype
= elf_z80_reloc_type (type
);
1924 rtype
= elf_loongarch_reloc_type (type
);
1930 printf (_("unrecognized: %-7lx"), (unsigned long) type
& 0xffffffff);
1932 printf (do_wide
? "%-22s" : "%-17.17s", rtype
);
1934 if (filedata
->file_header
.e_machine
== EM_ALPHA
1936 && streq (rtype
, "R_ALPHA_LITUSE")
1937 && rel_type
== reltype_rela
)
1939 switch (rels
[i
].r_addend
)
1941 case LITUSE_ALPHA_ADDR
: rtype
= "ADDR"; break;
1942 case LITUSE_ALPHA_BASE
: rtype
= "BASE"; break;
1943 case LITUSE_ALPHA_BYTOFF
: rtype
= "BYTOFF"; break;
1944 case LITUSE_ALPHA_JSR
: rtype
= "JSR"; break;
1945 case LITUSE_ALPHA_TLSGD
: rtype
= "TLSGD"; break;
1946 case LITUSE_ALPHA_TLSLDM
: rtype
= "TLSLDM"; break;
1947 case LITUSE_ALPHA_JSRDIRECT
: rtype
= "JSRDIRECT"; break;
1948 default: rtype
= NULL
;
1952 printf (" (%s)", rtype
);
1956 printf (_("<unknown addend: %lx>"),
1957 (unsigned long) rels
[i
].r_addend
);
1961 else if (symtab_index
)
1963 if (symtab
== NULL
|| symtab_index
>= nsyms
)
1965 error (_(" bad symbol index: %08lx in reloc\n"),
1966 (unsigned long) symtab_index
);
1971 Elf_Internal_Sym
* psym
;
1972 const char * version_string
;
1973 enum versioned_symbol_info sym_info
;
1974 unsigned short vna_other
;
1976 psym
= symtab
+ symtab_index
;
1979 = get_symbol_version_string (filedata
, is_dynsym
,
1988 if (ELF_ST_TYPE (psym
->st_info
) == STT_GNU_IFUNC
)
1992 unsigned int width
= is_32bit_elf
? 8 : 14;
1994 /* Relocations against GNU_IFUNC symbols do not use the value
1995 of the symbol as the address to relocate against. Instead
1996 they invoke the function named by the symbol and use its
1997 result as the address for relocation.
1999 To indicate this to the user, do not display the value of
2000 the symbol in the "Symbols's Value" field. Instead show
2001 its name followed by () as a hint that the symbol is
2005 || psym
->st_name
== 0
2006 || psym
->st_name
>= strtablen
)
2009 name
= strtab
+ psym
->st_name
;
2011 len
= print_symbol (width
, name
);
2013 printf (sym_info
== symbol_public
? "@@%s" : "@%s",
2015 printf ("()%-*s", len
<= width
? (width
+ 1) - len
: 1, " ");
2019 print_vma (psym
->st_value
, LONG_HEX
);
2021 printf (is_32bit_elf
? " " : " ");
2024 if (psym
->st_name
== 0)
2026 const char * sec_name
= "<null>";
2029 if (ELF_ST_TYPE (psym
->st_info
) == STT_SECTION
)
2031 if (psym
->st_shndx
< filedata
->file_header
.e_shnum
2032 && filedata
->section_headers
!= NULL
)
2033 sec_name
= section_name_print (filedata
,
2034 filedata
->section_headers
2036 else if (psym
->st_shndx
== SHN_ABS
)
2038 else if (psym
->st_shndx
== SHN_COMMON
)
2039 sec_name
= "COMMON";
2040 else if ((filedata
->file_header
.e_machine
== EM_MIPS
2041 && psym
->st_shndx
== SHN_MIPS_SCOMMON
)
2042 || (filedata
->file_header
.e_machine
== EM_TI_C6000
2043 && psym
->st_shndx
== SHN_TIC6X_SCOMMON
))
2044 sec_name
= "SCOMMON";
2045 else if (filedata
->file_header
.e_machine
== EM_MIPS
2046 && psym
->st_shndx
== SHN_MIPS_SUNDEFINED
)
2047 sec_name
= "SUNDEF";
2048 else if ((filedata
->file_header
.e_machine
== EM_X86_64
2049 || filedata
->file_header
.e_machine
== EM_L1OM
2050 || filedata
->file_header
.e_machine
== EM_K1OM
)
2051 && psym
->st_shndx
== SHN_X86_64_LCOMMON
)
2052 sec_name
= "LARGE_COMMON";
2053 else if (filedata
->file_header
.e_machine
== EM_IA_64
2054 && filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
2055 && psym
->st_shndx
== SHN_IA_64_ANSI_COMMON
)
2056 sec_name
= "ANSI_COM";
2057 else if (is_ia64_vms (filedata
)
2058 && psym
->st_shndx
== SHN_IA_64_VMS_SYMVEC
)
2059 sec_name
= "VMS_SYMVEC";
2062 sprintf (name_buf
, "<section 0x%x>",
2063 (unsigned int) psym
->st_shndx
);
2064 sec_name
= name_buf
;
2067 print_symbol (22, sec_name
);
2069 else if (strtab
== NULL
)
2070 printf (_("<string table index: %3ld>"), psym
->st_name
);
2071 else if (psym
->st_name
>= strtablen
)
2073 error (_("<corrupt string table index: %3ld>\n"),
2079 print_symbol (22, strtab
+ psym
->st_name
);
2081 printf (sym_info
== symbol_public
? "@@%s" : "@%s",
2085 if (rel_type
== reltype_rela
)
2087 bfd_vma off
= rels
[i
].r_addend
;
2089 if ((bfd_signed_vma
) off
< 0)
2090 printf (" - %" BFD_VMA_FMT
"x", - off
);
2092 printf (" + %" BFD_VMA_FMT
"x", off
);
2096 else if (rel_type
== reltype_rela
)
2098 bfd_vma off
= rels
[i
].r_addend
;
2100 printf ("%*c", is_32bit_elf
? 12 : 20, ' ');
2101 if ((bfd_signed_vma
) off
< 0)
2102 printf ("-%" BFD_VMA_FMT
"x", - off
);
2104 printf ("%" BFD_VMA_FMT
"x", off
);
2107 if (filedata
->file_header
.e_machine
== EM_SPARCV9
2109 && streq (rtype
, "R_SPARC_OLO10"))
2110 printf (" + %lx", (unsigned long) ELF64_R_TYPE_DATA (inf
));
2115 if (! is_32bit_elf
&& filedata
->file_header
.e_machine
== EM_MIPS
)
2117 bfd_vma type2
= ELF64_MIPS_R_TYPE2 (inf
);
2118 bfd_vma type3
= ELF64_MIPS_R_TYPE3 (inf
);
2119 const char * rtype2
= elf_mips_reloc_type (type2
);
2120 const char * rtype3
= elf_mips_reloc_type (type3
);
2122 printf (" Type2: ");
2125 printf (_("unrecognized: %-7lx"),
2126 (unsigned long) type2
& 0xffffffff);
2128 printf ("%-17.17s", rtype2
);
2130 printf ("\n Type3: ");
2133 printf (_("unrecognized: %-7lx"),
2134 (unsigned long) type3
& 0xffffffff);
2136 printf ("%-17.17s", rtype3
);
2149 get_aarch64_dynamic_type (unsigned long type
)
2153 case DT_AARCH64_BTI_PLT
: return "AARCH64_BTI_PLT";
2154 case DT_AARCH64_PAC_PLT
: return "AARCH64_PAC_PLT";
2155 case DT_AARCH64_VARIANT_PCS
: return "AARCH64_VARIANT_PCS";
2162 get_mips_dynamic_type (unsigned long type
)
2166 case DT_MIPS_RLD_VERSION
: return "MIPS_RLD_VERSION";
2167 case DT_MIPS_TIME_STAMP
: return "MIPS_TIME_STAMP";
2168 case DT_MIPS_ICHECKSUM
: return "MIPS_ICHECKSUM";
2169 case DT_MIPS_IVERSION
: return "MIPS_IVERSION";
2170 case DT_MIPS_FLAGS
: return "MIPS_FLAGS";
2171 case DT_MIPS_BASE_ADDRESS
: return "MIPS_BASE_ADDRESS";
2172 case DT_MIPS_MSYM
: return "MIPS_MSYM";
2173 case DT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
2174 case DT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
2175 case DT_MIPS_LOCAL_GOTNO
: return "MIPS_LOCAL_GOTNO";
2176 case DT_MIPS_CONFLICTNO
: return "MIPS_CONFLICTNO";
2177 case DT_MIPS_LIBLISTNO
: return "MIPS_LIBLISTNO";
2178 case DT_MIPS_SYMTABNO
: return "MIPS_SYMTABNO";
2179 case DT_MIPS_UNREFEXTNO
: return "MIPS_UNREFEXTNO";
2180 case DT_MIPS_GOTSYM
: return "MIPS_GOTSYM";
2181 case DT_MIPS_HIPAGENO
: return "MIPS_HIPAGENO";
2182 case DT_MIPS_RLD_MAP
: return "MIPS_RLD_MAP";
2183 case DT_MIPS_RLD_MAP_REL
: return "MIPS_RLD_MAP_REL";
2184 case DT_MIPS_DELTA_CLASS
: return "MIPS_DELTA_CLASS";
2185 case DT_MIPS_DELTA_CLASS_NO
: return "MIPS_DELTA_CLASS_NO";
2186 case DT_MIPS_DELTA_INSTANCE
: return "MIPS_DELTA_INSTANCE";
2187 case DT_MIPS_DELTA_INSTANCE_NO
: return "MIPS_DELTA_INSTANCE_NO";
2188 case DT_MIPS_DELTA_RELOC
: return "MIPS_DELTA_RELOC";
2189 case DT_MIPS_DELTA_RELOC_NO
: return "MIPS_DELTA_RELOC_NO";
2190 case DT_MIPS_DELTA_SYM
: return "MIPS_DELTA_SYM";
2191 case DT_MIPS_DELTA_SYM_NO
: return "MIPS_DELTA_SYM_NO";
2192 case DT_MIPS_DELTA_CLASSSYM
: return "MIPS_DELTA_CLASSSYM";
2193 case DT_MIPS_DELTA_CLASSSYM_NO
: return "MIPS_DELTA_CLASSSYM_NO";
2194 case DT_MIPS_CXX_FLAGS
: return "MIPS_CXX_FLAGS";
2195 case DT_MIPS_PIXIE_INIT
: return "MIPS_PIXIE_INIT";
2196 case DT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
2197 case DT_MIPS_LOCALPAGE_GOTIDX
: return "MIPS_LOCALPAGE_GOTIDX";
2198 case DT_MIPS_LOCAL_GOTIDX
: return "MIPS_LOCAL_GOTIDX";
2199 case DT_MIPS_HIDDEN_GOTIDX
: return "MIPS_HIDDEN_GOTIDX";
2200 case DT_MIPS_PROTECTED_GOTIDX
: return "MIPS_PROTECTED_GOTIDX";
2201 case DT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
2202 case DT_MIPS_INTERFACE
: return "MIPS_INTERFACE";
2203 case DT_MIPS_DYNSTR_ALIGN
: return "MIPS_DYNSTR_ALIGN";
2204 case DT_MIPS_INTERFACE_SIZE
: return "MIPS_INTERFACE_SIZE";
2205 case DT_MIPS_RLD_TEXT_RESOLVE_ADDR
: return "MIPS_RLD_TEXT_RESOLVE_ADDR";
2206 case DT_MIPS_PERF_SUFFIX
: return "MIPS_PERF_SUFFIX";
2207 case DT_MIPS_COMPACT_SIZE
: return "MIPS_COMPACT_SIZE";
2208 case DT_MIPS_GP_VALUE
: return "MIPS_GP_VALUE";
2209 case DT_MIPS_AUX_DYNAMIC
: return "MIPS_AUX_DYNAMIC";
2210 case DT_MIPS_PLTGOT
: return "MIPS_PLTGOT";
2211 case DT_MIPS_RWPLT
: return "MIPS_RWPLT";
2212 case DT_MIPS_XHASH
: return "MIPS_XHASH";
2219 get_sparc64_dynamic_type (unsigned long type
)
2223 case DT_SPARC_REGISTER
: return "SPARC_REGISTER";
2230 get_ppc_dynamic_type (unsigned long type
)
2234 case DT_PPC_GOT
: return "PPC_GOT";
2235 case DT_PPC_OPT
: return "PPC_OPT";
2242 get_ppc64_dynamic_type (unsigned long type
)
2246 case DT_PPC64_GLINK
: return "PPC64_GLINK";
2247 case DT_PPC64_OPD
: return "PPC64_OPD";
2248 case DT_PPC64_OPDSZ
: return "PPC64_OPDSZ";
2249 case DT_PPC64_OPT
: return "PPC64_OPT";
2256 get_parisc_dynamic_type (unsigned long type
)
2260 case DT_HP_LOAD_MAP
: return "HP_LOAD_MAP";
2261 case DT_HP_DLD_FLAGS
: return "HP_DLD_FLAGS";
2262 case DT_HP_DLD_HOOK
: return "HP_DLD_HOOK";
2263 case DT_HP_UX10_INIT
: return "HP_UX10_INIT";
2264 case DT_HP_UX10_INITSZ
: return "HP_UX10_INITSZ";
2265 case DT_HP_PREINIT
: return "HP_PREINIT";
2266 case DT_HP_PREINITSZ
: return "HP_PREINITSZ";
2267 case DT_HP_NEEDED
: return "HP_NEEDED";
2268 case DT_HP_TIME_STAMP
: return "HP_TIME_STAMP";
2269 case DT_HP_CHECKSUM
: return "HP_CHECKSUM";
2270 case DT_HP_GST_SIZE
: return "HP_GST_SIZE";
2271 case DT_HP_GST_VERSION
: return "HP_GST_VERSION";
2272 case DT_HP_GST_HASHVAL
: return "HP_GST_HASHVAL";
2273 case DT_HP_EPLTREL
: return "HP_GST_EPLTREL";
2274 case DT_HP_EPLTRELSZ
: return "HP_GST_EPLTRELSZ";
2275 case DT_HP_FILTERED
: return "HP_FILTERED";
2276 case DT_HP_FILTER_TLS
: return "HP_FILTER_TLS";
2277 case DT_HP_COMPAT_FILTERED
: return "HP_COMPAT_FILTERED";
2278 case DT_HP_LAZYLOAD
: return "HP_LAZYLOAD";
2279 case DT_HP_BIND_NOW_COUNT
: return "HP_BIND_NOW_COUNT";
2280 case DT_PLT
: return "PLT";
2281 case DT_PLT_SIZE
: return "PLT_SIZE";
2282 case DT_DLT
: return "DLT";
2283 case DT_DLT_SIZE
: return "DLT_SIZE";
2290 get_ia64_dynamic_type (unsigned long type
)
2294 case DT_IA_64_PLT_RESERVE
: return "IA_64_PLT_RESERVE";
2295 case DT_IA_64_VMS_SUBTYPE
: return "VMS_SUBTYPE";
2296 case DT_IA_64_VMS_IMGIOCNT
: return "VMS_IMGIOCNT";
2297 case DT_IA_64_VMS_LNKFLAGS
: return "VMS_LNKFLAGS";
2298 case DT_IA_64_VMS_VIR_MEM_BLK_SIZ
: return "VMS_VIR_MEM_BLK_SIZ";
2299 case DT_IA_64_VMS_IDENT
: return "VMS_IDENT";
2300 case DT_IA_64_VMS_NEEDED_IDENT
: return "VMS_NEEDED_IDENT";
2301 case DT_IA_64_VMS_IMG_RELA_CNT
: return "VMS_IMG_RELA_CNT";
2302 case DT_IA_64_VMS_SEG_RELA_CNT
: return "VMS_SEG_RELA_CNT";
2303 case DT_IA_64_VMS_FIXUP_RELA_CNT
: return "VMS_FIXUP_RELA_CNT";
2304 case DT_IA_64_VMS_FIXUP_NEEDED
: return "VMS_FIXUP_NEEDED";
2305 case DT_IA_64_VMS_SYMVEC_CNT
: return "VMS_SYMVEC_CNT";
2306 case DT_IA_64_VMS_XLATED
: return "VMS_XLATED";
2307 case DT_IA_64_VMS_STACKSIZE
: return "VMS_STACKSIZE";
2308 case DT_IA_64_VMS_UNWINDSZ
: return "VMS_UNWINDSZ";
2309 case DT_IA_64_VMS_UNWIND_CODSEG
: return "VMS_UNWIND_CODSEG";
2310 case DT_IA_64_VMS_UNWIND_INFOSEG
: return "VMS_UNWIND_INFOSEG";
2311 case DT_IA_64_VMS_LINKTIME
: return "VMS_LINKTIME";
2312 case DT_IA_64_VMS_SEG_NO
: return "VMS_SEG_NO";
2313 case DT_IA_64_VMS_SYMVEC_OFFSET
: return "VMS_SYMVEC_OFFSET";
2314 case DT_IA_64_VMS_SYMVEC_SEG
: return "VMS_SYMVEC_SEG";
2315 case DT_IA_64_VMS_UNWIND_OFFSET
: return "VMS_UNWIND_OFFSET";
2316 case DT_IA_64_VMS_UNWIND_SEG
: return "VMS_UNWIND_SEG";
2317 case DT_IA_64_VMS_STRTAB_OFFSET
: return "VMS_STRTAB_OFFSET";
2318 case DT_IA_64_VMS_SYSVER_OFFSET
: return "VMS_SYSVER_OFFSET";
2319 case DT_IA_64_VMS_IMG_RELA_OFF
: return "VMS_IMG_RELA_OFF";
2320 case DT_IA_64_VMS_SEG_RELA_OFF
: return "VMS_SEG_RELA_OFF";
2321 case DT_IA_64_VMS_FIXUP_RELA_OFF
: return "VMS_FIXUP_RELA_OFF";
2322 case DT_IA_64_VMS_PLTGOT_OFFSET
: return "VMS_PLTGOT_OFFSET";
2323 case DT_IA_64_VMS_PLTGOT_SEG
: return "VMS_PLTGOT_SEG";
2324 case DT_IA_64_VMS_FPMODE
: return "VMS_FPMODE";
2331 get_solaris_section_type (unsigned long type
)
2335 case 0x6fffffee: return "SUNW_ancillary";
2336 case 0x6fffffef: return "SUNW_capchain";
2337 case 0x6ffffff0: return "SUNW_capinfo";
2338 case 0x6ffffff1: return "SUNW_symsort";
2339 case 0x6ffffff2: return "SUNW_tlssort";
2340 case 0x6ffffff3: return "SUNW_LDYNSYM";
2341 case 0x6ffffff4: return "SUNW_dof";
2342 case 0x6ffffff5: return "SUNW_cap";
2343 case 0x6ffffff6: return "SUNW_SIGNATURE";
2344 case 0x6ffffff7: return "SUNW_ANNOTATE";
2345 case 0x6ffffff8: return "SUNW_DEBUGSTR";
2346 case 0x6ffffff9: return "SUNW_DEBUG";
2347 case 0x6ffffffa: return "SUNW_move";
2348 case 0x6ffffffb: return "SUNW_COMDAT";
2349 case 0x6ffffffc: return "SUNW_syminfo";
2350 case 0x6ffffffd: return "SUNW_verdef";
2351 case 0x6ffffffe: return "SUNW_verneed";
2352 case 0x6fffffff: return "SUNW_versym";
2353 case 0x70000000: return "SPARC_GOTDATA";
2354 default: return NULL
;
2359 get_alpha_dynamic_type (unsigned long type
)
2363 case DT_ALPHA_PLTRO
: return "ALPHA_PLTRO";
2364 default: return NULL
;
2369 get_score_dynamic_type (unsigned long type
)
2373 case DT_SCORE_BASE_ADDRESS
: return "SCORE_BASE_ADDRESS";
2374 case DT_SCORE_LOCAL_GOTNO
: return "SCORE_LOCAL_GOTNO";
2375 case DT_SCORE_SYMTABNO
: return "SCORE_SYMTABNO";
2376 case DT_SCORE_GOTSYM
: return "SCORE_GOTSYM";
2377 case DT_SCORE_UNREFEXTNO
: return "SCORE_UNREFEXTNO";
2378 case DT_SCORE_HIPAGENO
: return "SCORE_HIPAGENO";
2379 default: return NULL
;
2384 get_tic6x_dynamic_type (unsigned long type
)
2388 case DT_C6000_GSYM_OFFSET
: return "C6000_GSYM_OFFSET";
2389 case DT_C6000_GSTR_OFFSET
: return "C6000_GSTR_OFFSET";
2390 case DT_C6000_DSBT_BASE
: return "C6000_DSBT_BASE";
2391 case DT_C6000_DSBT_SIZE
: return "C6000_DSBT_SIZE";
2392 case DT_C6000_PREEMPTMAP
: return "C6000_PREEMPTMAP";
2393 case DT_C6000_DSBT_INDEX
: return "C6000_DSBT_INDEX";
2394 default: return NULL
;
2399 get_nios2_dynamic_type (unsigned long type
)
2403 case DT_NIOS2_GP
: return "NIOS2_GP";
2404 default: return NULL
;
2409 get_solaris_dynamic_type (unsigned long type
)
2413 case 0x6000000d: return "SUNW_AUXILIARY";
2414 case 0x6000000e: return "SUNW_RTLDINF";
2415 case 0x6000000f: return "SUNW_FILTER";
2416 case 0x60000010: return "SUNW_CAP";
2417 case 0x60000011: return "SUNW_SYMTAB";
2418 case 0x60000012: return "SUNW_SYMSZ";
2419 case 0x60000013: return "SUNW_SORTENT";
2420 case 0x60000014: return "SUNW_SYMSORT";
2421 case 0x60000015: return "SUNW_SYMSORTSZ";
2422 case 0x60000016: return "SUNW_TLSSORT";
2423 case 0x60000017: return "SUNW_TLSSORTSZ";
2424 case 0x60000018: return "SUNW_CAPINFO";
2425 case 0x60000019: return "SUNW_STRPAD";
2426 case 0x6000001a: return "SUNW_CAPCHAIN";
2427 case 0x6000001b: return "SUNW_LDMACH";
2428 case 0x6000001d: return "SUNW_CAPCHAINENT";
2429 case 0x6000001f: return "SUNW_CAPCHAINSZ";
2430 case 0x60000021: return "SUNW_PARENT";
2431 case 0x60000023: return "SUNW_ASLR";
2432 case 0x60000025: return "SUNW_RELAX";
2433 case 0x60000029: return "SUNW_NXHEAP";
2434 case 0x6000002b: return "SUNW_NXSTACK";
2436 case 0x70000001: return "SPARC_REGISTER";
2437 case 0x7ffffffd: return "AUXILIARY";
2438 case 0x7ffffffe: return "USED";
2439 case 0x7fffffff: return "FILTER";
2441 default: return NULL
;
2446 get_riscv_dynamic_type (unsigned long type
)
2450 case DT_RISCV_VARIANT_CC
: return "RISCV_VARIANT_CC";
2457 get_dynamic_type (Filedata
* filedata
, unsigned long type
)
2459 static char buff
[64];
2463 case DT_NULL
: return "NULL";
2464 case DT_NEEDED
: return "NEEDED";
2465 case DT_PLTRELSZ
: return "PLTRELSZ";
2466 case DT_PLTGOT
: return "PLTGOT";
2467 case DT_HASH
: return "HASH";
2468 case DT_STRTAB
: return "STRTAB";
2469 case DT_SYMTAB
: return "SYMTAB";
2470 case DT_RELA
: return "RELA";
2471 case DT_RELASZ
: return "RELASZ";
2472 case DT_RELAENT
: return "RELAENT";
2473 case DT_STRSZ
: return "STRSZ";
2474 case DT_SYMENT
: return "SYMENT";
2475 case DT_INIT
: return "INIT";
2476 case DT_FINI
: return "FINI";
2477 case DT_SONAME
: return "SONAME";
2478 case DT_RPATH
: return "RPATH";
2479 case DT_SYMBOLIC
: return "SYMBOLIC";
2480 case DT_REL
: return "REL";
2481 case DT_RELSZ
: return "RELSZ";
2482 case DT_RELENT
: return "RELENT";
2483 case DT_RELR
: return "RELR";
2484 case DT_RELRSZ
: return "RELRSZ";
2485 case DT_RELRENT
: return "RELRENT";
2486 case DT_PLTREL
: return "PLTREL";
2487 case DT_DEBUG
: return "DEBUG";
2488 case DT_TEXTREL
: return "TEXTREL";
2489 case DT_JMPREL
: return "JMPREL";
2490 case DT_BIND_NOW
: return "BIND_NOW";
2491 case DT_INIT_ARRAY
: return "INIT_ARRAY";
2492 case DT_FINI_ARRAY
: return "FINI_ARRAY";
2493 case DT_INIT_ARRAYSZ
: return "INIT_ARRAYSZ";
2494 case DT_FINI_ARRAYSZ
: return "FINI_ARRAYSZ";
2495 case DT_RUNPATH
: return "RUNPATH";
2496 case DT_FLAGS
: return "FLAGS";
2498 case DT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
2499 case DT_PREINIT_ARRAYSZ
: return "PREINIT_ARRAYSZ";
2500 case DT_SYMTAB_SHNDX
: return "SYMTAB_SHNDX";
2502 case DT_CHECKSUM
: return "CHECKSUM";
2503 case DT_PLTPADSZ
: return "PLTPADSZ";
2504 case DT_MOVEENT
: return "MOVEENT";
2505 case DT_MOVESZ
: return "MOVESZ";
2506 case DT_FEATURE
: return "FEATURE";
2507 case DT_POSFLAG_1
: return "POSFLAG_1";
2508 case DT_SYMINSZ
: return "SYMINSZ";
2509 case DT_SYMINENT
: return "SYMINENT"; /* aka VALRNGHI */
2511 case DT_ADDRRNGLO
: return "ADDRRNGLO";
2512 case DT_CONFIG
: return "CONFIG";
2513 case DT_DEPAUDIT
: return "DEPAUDIT";
2514 case DT_AUDIT
: return "AUDIT";
2515 case DT_PLTPAD
: return "PLTPAD";
2516 case DT_MOVETAB
: return "MOVETAB";
2517 case DT_SYMINFO
: return "SYMINFO"; /* aka ADDRRNGHI */
2519 case DT_VERSYM
: return "VERSYM";
2521 case DT_TLSDESC_GOT
: return "TLSDESC_GOT";
2522 case DT_TLSDESC_PLT
: return "TLSDESC_PLT";
2523 case DT_RELACOUNT
: return "RELACOUNT";
2524 case DT_RELCOUNT
: return "RELCOUNT";
2525 case DT_FLAGS_1
: return "FLAGS_1";
2526 case DT_VERDEF
: return "VERDEF";
2527 case DT_VERDEFNUM
: return "VERDEFNUM";
2528 case DT_VERNEED
: return "VERNEED";
2529 case DT_VERNEEDNUM
: return "VERNEEDNUM";
2531 case DT_AUXILIARY
: return "AUXILIARY";
2532 case DT_USED
: return "USED";
2533 case DT_FILTER
: return "FILTER";
2535 case DT_GNU_PRELINKED
: return "GNU_PRELINKED";
2536 case DT_GNU_CONFLICT
: return "GNU_CONFLICT";
2537 case DT_GNU_CONFLICTSZ
: return "GNU_CONFLICTSZ";
2538 case DT_GNU_LIBLIST
: return "GNU_LIBLIST";
2539 case DT_GNU_LIBLISTSZ
: return "GNU_LIBLISTSZ";
2540 case DT_GNU_HASH
: return "GNU_HASH";
2541 case DT_GNU_FLAGS_1
: return "GNU_FLAGS_1";
2544 if ((type
>= DT_LOPROC
) && (type
<= DT_HIPROC
))
2546 const char * result
;
2548 switch (filedata
->file_header
.e_machine
)
2551 result
= get_aarch64_dynamic_type (type
);
2554 case EM_MIPS_RS3_LE
:
2555 result
= get_mips_dynamic_type (type
);
2558 result
= get_sparc64_dynamic_type (type
);
2561 result
= get_ppc_dynamic_type (type
);
2564 result
= get_ppc64_dynamic_type (type
);
2567 result
= get_ia64_dynamic_type (type
);
2570 result
= get_alpha_dynamic_type (type
);
2573 result
= get_score_dynamic_type (type
);
2576 result
= get_tic6x_dynamic_type (type
);
2578 case EM_ALTERA_NIOS2
:
2579 result
= get_nios2_dynamic_type (type
);
2582 result
= get_riscv_dynamic_type (type
);
2585 if (filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_SOLARIS
)
2586 result
= get_solaris_dynamic_type (type
);
2595 snprintf (buff
, sizeof (buff
), _("Processor Specific: %lx"), type
);
2597 else if (((type
>= DT_LOOS
) && (type
<= DT_HIOS
))
2598 || (filedata
->file_header
.e_machine
== EM_PARISC
2599 && (type
>= OLD_DT_LOOS
) && (type
<= OLD_DT_HIOS
)))
2601 const char * result
;
2603 switch (filedata
->file_header
.e_machine
)
2606 result
= get_parisc_dynamic_type (type
);
2609 result
= get_ia64_dynamic_type (type
);
2612 if (filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_SOLARIS
)
2613 result
= get_solaris_dynamic_type (type
);
2622 snprintf (buff
, sizeof (buff
), _("Operating System specific: %lx"),
2626 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), type
);
2632 static bool get_program_headers (Filedata
*);
2633 static bool get_dynamic_section (Filedata
*);
2636 locate_dynamic_section (Filedata
*filedata
)
2638 unsigned long dynamic_addr
= 0;
2639 bfd_size_type dynamic_size
= 0;
2641 if (filedata
->file_header
.e_phnum
!= 0
2642 && get_program_headers (filedata
))
2644 Elf_Internal_Phdr
*segment
;
2647 for (i
= 0, segment
= filedata
->program_headers
;
2648 i
< filedata
->file_header
.e_phnum
;
2651 if (segment
->p_type
== PT_DYNAMIC
)
2653 dynamic_addr
= segment
->p_offset
;
2654 dynamic_size
= segment
->p_filesz
;
2656 if (filedata
->section_headers
!= NULL
)
2658 Elf_Internal_Shdr
*sec
;
2660 sec
= find_section (filedata
, ".dynamic");
2663 if (sec
->sh_size
== 0
2664 || sec
->sh_type
== SHT_NOBITS
)
2671 dynamic_addr
= sec
->sh_offset
;
2672 dynamic_size
= sec
->sh_size
;
2677 if (dynamic_addr
> filedata
->file_size
2678 || (dynamic_size
> filedata
->file_size
- dynamic_addr
))
2687 filedata
->dynamic_addr
= dynamic_addr
;
2688 filedata
->dynamic_size
= dynamic_size
? dynamic_size
: 1;
2692 is_pie (Filedata
*filedata
)
2694 Elf_Internal_Dyn
*entry
;
2696 if (filedata
->dynamic_size
== 0)
2697 locate_dynamic_section (filedata
);
2698 if (filedata
->dynamic_size
<= 1)
2701 if (!get_dynamic_section (filedata
))
2704 for (entry
= filedata
->dynamic_section
;
2705 entry
< filedata
->dynamic_section
+ filedata
->dynamic_nent
;
2708 if (entry
->d_tag
== DT_FLAGS_1
)
2710 if ((entry
->d_un
.d_val
& DF_1_PIE
) != 0)
2719 get_file_type (Filedata
*filedata
)
2721 unsigned e_type
= filedata
->file_header
.e_type
;
2722 static char buff
[64];
2726 case ET_NONE
: return _("NONE (None)");
2727 case ET_REL
: return _("REL (Relocatable file)");
2728 case ET_EXEC
: return _("EXEC (Executable file)");
2730 if (is_pie (filedata
))
2731 return _("DYN (Position-Independent Executable file)");
2733 return _("DYN (Shared object file)");
2734 case ET_CORE
: return _("CORE (Core file)");
2737 if ((e_type
>= ET_LOPROC
) && (e_type
<= ET_HIPROC
))
2738 snprintf (buff
, sizeof (buff
), _("Processor Specific: (%x)"), e_type
);
2739 else if ((e_type
>= ET_LOOS
) && (e_type
<= ET_HIOS
))
2740 snprintf (buff
, sizeof (buff
), _("OS Specific: (%x)"), e_type
);
2742 snprintf (buff
, sizeof (buff
), _("<unknown>: %x"), e_type
);
2748 get_machine_name (unsigned e_machine
)
2750 static char buff
[64]; /* XXX */
2754 /* Please keep this switch table sorted by increasing EM_ value. */
2756 case EM_NONE
: return _("None");
2757 case EM_M32
: return "WE32100";
2758 case EM_SPARC
: return "Sparc";
2759 case EM_386
: return "Intel 80386";
2760 case EM_68K
: return "MC68000";
2761 case EM_88K
: return "MC88000";
2762 case EM_IAMCU
: return "Intel MCU";
2763 case EM_860
: return "Intel 80860";
2764 case EM_MIPS
: return "MIPS R3000";
2765 case EM_S370
: return "IBM System/370";
2767 case EM_MIPS_RS3_LE
: return "MIPS R4000 big-endian";
2768 case EM_OLD_SPARCV9
: return "Sparc v9 (old)";
2769 case EM_PARISC
: return "HPPA";
2770 case EM_VPP550
: return "Fujitsu VPP500";
2771 case EM_SPARC32PLUS
: return "Sparc v8+" ;
2772 case EM_960
: return "Intel 80960";
2773 case EM_PPC
: return "PowerPC";
2775 case EM_PPC64
: return "PowerPC64";
2777 case EM_S390
: return "IBM S/390";
2778 case EM_SPU
: return "SPU";
2780 case EM_V800
: return "Renesas V850 (using RH850 ABI)";
2781 case EM_FR20
: return "Fujitsu FR20";
2782 case EM_RH32
: return "TRW RH32";
2783 case EM_MCORE
: return "MCORE";
2785 case EM_ARM
: return "ARM";
2786 case EM_OLD_ALPHA
: return "Digital Alpha (old)";
2787 case EM_SH
: return "Renesas / SuperH SH";
2788 case EM_SPARCV9
: return "Sparc v9";
2789 case EM_TRICORE
: return "Siemens Tricore";
2790 case EM_ARC
: return "ARC";
2791 case EM_H8_300
: return "Renesas H8/300";
2792 case EM_H8_300H
: return "Renesas H8/300H";
2793 case EM_H8S
: return "Renesas H8S";
2794 case EM_H8_500
: return "Renesas H8/500";
2796 case EM_IA_64
: return "Intel IA-64";
2797 case EM_MIPS_X
: return "Stanford MIPS-X";
2798 case EM_COLDFIRE
: return "Motorola Coldfire";
2799 case EM_68HC12
: return "Motorola MC68HC12 Microcontroller";
2800 case EM_MMA
: return "Fujitsu Multimedia Accelerator";
2801 case EM_PCP
: return "Siemens PCP";
2802 case EM_NCPU
: return "Sony nCPU embedded RISC processor";
2803 case EM_NDR1
: return "Denso NDR1 microprocesspr";
2804 case EM_STARCORE
: return "Motorola Star*Core processor";
2805 case EM_ME16
: return "Toyota ME16 processor";
2807 case EM_ST100
: return "STMicroelectronics ST100 processor";
2808 case EM_TINYJ
: return "Advanced Logic Corp. TinyJ embedded processor";
2809 case EM_X86_64
: return "Advanced Micro Devices X86-64";
2810 case EM_PDSP
: return "Sony DSP processor";
2811 case EM_PDP10
: return "Digital Equipment Corp. PDP-10";
2812 case EM_PDP11
: return "Digital Equipment Corp. PDP-11";
2813 case EM_FX66
: return "Siemens FX66 microcontroller";
2814 case EM_ST9PLUS
: return "STMicroelectronics ST9+ 8/16 bit microcontroller";
2815 case EM_ST7
: return "STMicroelectronics ST7 8-bit microcontroller";
2816 case EM_68HC16
: return "Motorola MC68HC16 Microcontroller";
2818 case EM_68HC11
: return "Motorola MC68HC11 Microcontroller";
2819 case EM_68HC08
: return "Motorola MC68HC08 Microcontroller";
2820 case EM_68HC05
: return "Motorola MC68HC05 Microcontroller";
2821 case EM_SVX
: return "Silicon Graphics SVx";
2822 case EM_ST19
: return "STMicroelectronics ST19 8-bit microcontroller";
2823 case EM_VAX
: return "Digital VAX";
2824 case EM_CRIS
: return "Axis Communications 32-bit embedded processor";
2825 case EM_JAVELIN
: return "Infineon Technologies 32-bit embedded cpu";
2826 case EM_FIREPATH
: return "Element 14 64-bit DSP processor";
2827 case EM_ZSP
: return "LSI Logic's 16-bit DSP processor";
2829 case EM_MMIX
: return "Donald Knuth's educational 64-bit processor";
2830 case EM_HUANY
: return "Harvard Universitys's machine-independent object format";
2831 case EM_PRISM
: return "Vitesse Prism";
2833 case EM_AVR
: return "Atmel AVR 8-bit microcontroller";
2834 case EM_CYGNUS_FR30
:
2835 case EM_FR30
: return "Fujitsu FR30";
2836 case EM_CYGNUS_D10V
:
2837 case EM_D10V
: return "d10v";
2838 case EM_CYGNUS_D30V
:
2839 case EM_D30V
: return "d30v";
2840 case EM_CYGNUS_V850
:
2841 case EM_V850
: return "Renesas V850";
2842 case EM_CYGNUS_M32R
:
2843 case EM_M32R
: return "Renesas M32R (formerly Mitsubishi M32r)";
2844 case EM_CYGNUS_MN10300
:
2845 case EM_MN10300
: return "mn10300";
2847 case EM_CYGNUS_MN10200
:
2848 case EM_MN10200
: return "mn10200";
2849 case EM_PJ
: return "picoJava";
2850 case EM_OR1K
: return "OpenRISC 1000";
2851 case EM_ARC_COMPACT
: return "ARCompact";
2853 case EM_XTENSA
: return "Tensilica Xtensa Processor";
2854 case EM_VIDEOCORE
: return "Alphamosaic VideoCore processor";
2855 case EM_TMM_GPP
: return "Thompson Multimedia General Purpose Processor";
2856 case EM_NS32K
: return "National Semiconductor 32000 series";
2857 case EM_TPC
: return "Tenor Network TPC processor";
2858 case EM_SNP1K
: return "Trebia SNP 1000 processor";
2860 case EM_ST200
: return "STMicroelectronics ST200 microcontroller";
2862 case EM_IP2K
: return "Ubicom IP2xxx 8-bit microcontrollers";
2863 case EM_MAX
: return "MAX Processor";
2864 case EM_CR
: return "National Semiconductor CompactRISC";
2865 case EM_F2MC16
: return "Fujitsu F2MC16";
2866 case EM_MSP430
: return "Texas Instruments msp430 microcontroller";
2867 case EM_BLACKFIN
: return "Analog Devices Blackfin";
2868 case EM_SE_C33
: return "S1C33 Family of Seiko Epson processors";
2869 case EM_SEP
: return "Sharp embedded microprocessor";
2870 case EM_ARCA
: return "Arca RISC microprocessor";
2872 case EM_UNICORE
: return "Unicore";
2873 case EM_EXCESS
: return "eXcess 16/32/64-bit configurable embedded CPU";
2874 case EM_DXP
: return "Icera Semiconductor Inc. Deep Execution Processor";
2875 case EM_ALTERA_NIOS2
: return "Altera Nios II";
2876 case EM_CRX
: return "National Semiconductor CRX microprocessor";
2877 case EM_XGATE
: return "Motorola XGATE embedded processor";
2879 case EM_XC16X
: return "Infineon Technologies xc16x";
2880 case EM_M16C
: return "Renesas M16C series microprocessors";
2881 case EM_DSPIC30F
: return "Microchip Technology dsPIC30F Digital Signal Controller";
2882 case EM_CE
: return "Freescale Communication Engine RISC core";
2884 case EM_M32C
: return "Renesas M32c";
2886 case EM_TSK3000
: return "Altium TSK3000 core";
2887 case EM_RS08
: return "Freescale RS08 embedded processor";
2888 case EM_ECOG2
: return "Cyan Technology eCOG2 microprocessor";
2889 case EM_SCORE
: return "SUNPLUS S+Core";
2890 case EM_DSP24
: return "New Japan Radio (NJR) 24-bit DSP Processor";
2891 case EM_VIDEOCORE3
: return "Broadcom VideoCore III processor";
2892 case EM_LATTICEMICO32
: return "Lattice Mico32";
2893 case EM_SE_C17
: return "Seiko Epson C17 family";
2895 case EM_TI_C6000
: return "Texas Instruments TMS320C6000 DSP family";
2896 case EM_TI_C2000
: return "Texas Instruments TMS320C2000 DSP family";
2897 case EM_TI_C5500
: return "Texas Instruments TMS320C55x DSP family";
2898 case EM_TI_PRU
: return "TI PRU I/O processor";
2900 case EM_MMDSP_PLUS
: return "STMicroelectronics 64bit VLIW Data Signal Processor";
2901 case EM_CYPRESS_M8C
: return "Cypress M8C microprocessor";
2902 case EM_R32C
: return "Renesas R32C series microprocessors";
2903 case EM_TRIMEDIA
: return "NXP Semiconductors TriMedia architecture family";
2904 case EM_QDSP6
: return "QUALCOMM DSP6 Processor";
2905 case EM_8051
: return "Intel 8051 and variants";
2906 case EM_STXP7X
: return "STMicroelectronics STxP7x family";
2907 case EM_NDS32
: return "Andes Technology compact code size embedded RISC processor family";
2908 case EM_ECOG1X
: return "Cyan Technology eCOG1X family";
2909 case EM_MAXQ30
: return "Dallas Semiconductor MAXQ30 Core microcontrollers";
2911 case EM_XIMO16
: return "New Japan Radio (NJR) 16-bit DSP Processor";
2912 case EM_MANIK
: return "M2000 Reconfigurable RISC Microprocessor";
2913 case EM_CRAYNV2
: return "Cray Inc. NV2 vector architecture";
2914 case EM_RX
: return "Renesas RX";
2915 case EM_METAG
: return "Imagination Technologies Meta processor architecture";
2916 case EM_MCST_ELBRUS
: return "MCST Elbrus general purpose hardware architecture";
2917 case EM_ECOG16
: return "Cyan Technology eCOG16 family";
2920 case EM_MICROBLAZE_OLD
: return "Xilinx MicroBlaze";
2921 case EM_ETPU
: return "Freescale Extended Time Processing Unit";
2922 case EM_SLE9X
: return "Infineon Technologies SLE9X core";
2924 case EM_L1OM
: return "Intel L1OM";
2925 case EM_K1OM
: return "Intel K1OM";
2926 case EM_INTEL182
: return "Intel (reserved)";
2927 case EM_AARCH64
: return "AArch64";
2928 case EM_ARM184
: return "ARM (reserved)";
2929 case EM_AVR32
: return "Atmel Corporation 32-bit microprocessor";
2930 case EM_STM8
: return "STMicroeletronics STM8 8-bit microcontroller";
2931 case EM_TILE64
: return "Tilera TILE64 multicore architecture family";
2932 case EM_TILEPRO
: return "Tilera TILEPro multicore architecture family";
2934 case EM_CUDA
: return "NVIDIA CUDA architecture";
2935 case EM_TILEGX
: return "Tilera TILE-Gx multicore architecture family";
2936 case EM_CLOUDSHIELD
: return "CloudShield architecture family";
2937 case EM_COREA_1ST
: return "KIPO-KAIST Core-A 1st generation processor family";
2938 case EM_COREA_2ND
: return "KIPO-KAIST Core-A 2nd generation processor family";
2939 case EM_ARC_COMPACT2
: return "ARCv2";
2940 case EM_OPEN8
: return "Open8 8-bit RISC soft processor core";
2941 case EM_RL78
: return "Renesas RL78";
2942 case EM_VIDEOCORE5
: return "Broadcom VideoCore V processor";
2943 case EM_78K0R
: return "Renesas 78K0R";
2945 case EM_56800EX
: return "Freescale 56800EX Digital Signal Controller (DSC)";
2946 case EM_BA1
: return "Beyond BA1 CPU architecture";
2947 case EM_BA2
: return "Beyond BA2 CPU architecture";
2948 case EM_XCORE
: return "XMOS xCORE processor family";
2949 case EM_MCHP_PIC
: return "Microchip 8-bit PIC(r) family";
2950 case EM_INTELGT
: return "Intel Graphics Technology";
2952 case EM_KM32
: return "KM211 KM32 32-bit processor";
2953 case EM_KMX32
: return "KM211 KMX32 32-bit processor";
2954 case EM_KMX16
: return "KM211 KMX16 16-bit processor";
2955 case EM_KMX8
: return "KM211 KMX8 8-bit processor";
2956 case EM_KVARC
: return "KM211 KVARC processor";
2957 case EM_CDP
: return "Paneve CDP architecture family";
2958 case EM_COGE
: return "Cognitive Smart Memory Processor";
2959 case EM_COOL
: return "Bluechip Systems CoolEngine";
2960 case EM_NORC
: return "Nanoradio Optimized RISC";
2961 case EM_CSR_KALIMBA
: return "CSR Kalimba architecture family";
2963 case EM_Z80
: return "Zilog Z80";
2964 case EM_VISIUM
: return "CDS VISIUMcore processor";
2965 case EM_FT32
: return "FTDI Chip FT32";
2966 case EM_MOXIE
: return "Moxie";
2967 case EM_AMDGPU
: return "AMD GPU";
2968 /* 230 (all reserved) */
2970 case EM_RISCV
: return "RISC-V";
2971 case EM_LANAI
: return "Lanai 32-bit processor";
2972 case EM_CEVA
: return "CEVA Processor Architecture Family";
2973 case EM_CEVA_X2
: return "CEVA X2 Processor Family";
2974 case EM_BPF
: return "Linux BPF";
2975 case EM_GRAPHCORE_IPU
: return "Graphcore Intelligent Processing Unit";
2976 case EM_IMG1
: return "Imagination Technologies";
2978 case EM_NFP
: return "Netronome Flow Processor";
2979 case EM_VE
: return "NEC Vector Engine";
2980 case EM_CSKY
: return "C-SKY";
2981 case EM_ARC_COMPACT3_64
: return "Synopsys ARCv2.3 64-bit";
2982 case EM_MCS6502
: return "MOS Technology MCS 6502 processor";
2983 case EM_ARC_COMPACT3
: return "Synopsys ARCv2.3 32-bit";
2984 case EM_KVX
: return "Kalray VLIW core of the MPPA processor family";
2985 case EM_65816
: return "WDC 65816/65C816";
2986 case EM_LOONGARCH
: return "LoongArch";
2987 case EM_KF32
: return "ChipON KungFu32";
2989 /* Large numbers... */
2990 case EM_MT
: return "Morpho Techologies MT processor";
2991 case EM_ALPHA
: return "Alpha";
2992 case EM_WEBASSEMBLY
: return "Web Assembly";
2993 case EM_DLX
: return "OpenDLX";
2994 case EM_XSTORMY16
: return "Sanyo XStormy16 CPU core";
2995 case EM_IQ2000
: return "Vitesse IQ2000";
2997 case EM_NIOS32
: return "Altera Nios";
2998 case EM_CYGNUS_MEP
: return "Toshiba MeP Media Engine";
2999 case EM_ADAPTEVA_EPIPHANY
: return "Adapteva EPIPHANY";
3000 case EM_CYGNUS_FRV
: return "Fujitsu FR-V";
3001 case EM_S12Z
: return "Freescale S12Z";
3004 snprintf (buff
, sizeof (buff
), _("<unknown>: 0x%x"), e_machine
);
3010 decode_ARC_machine_flags (unsigned e_flags
, unsigned e_machine
, char buf
[])
3012 /* ARC has two machine types EM_ARC_COMPACT and EM_ARC_COMPACT2. Some
3013 other compilers don't specify an architecture type in the e_flags, and
3014 instead use EM_ARC_COMPACT for old ARC600, ARC601, and ARC700
3015 architectures, and switch to EM_ARC_COMPACT2 for newer ARCEM and ARCHS
3018 Th GNU tools follows this use of EM_ARC_COMPACT and EM_ARC_COMPACT2,
3019 but also sets a specific architecture type in the e_flags field.
3021 However, when decoding the flags we don't worry if we see an
3022 unexpected pairing, for example EM_ARC_COMPACT machine type, with
3023 ARCEM architecture type. */
3025 switch (e_flags
& EF_ARC_MACH_MSK
)
3027 /* We only expect these to occur for EM_ARC_COMPACT2. */
3028 case EF_ARC_CPU_ARCV2EM
:
3029 strcat (buf
, ", ARC EM");
3031 case EF_ARC_CPU_ARCV2HS
:
3032 strcat (buf
, ", ARC HS");
3035 /* We only expect these to occur for EM_ARC_COMPACT. */
3036 case E_ARC_MACH_ARC600
:
3037 strcat (buf
, ", ARC600");
3039 case E_ARC_MACH_ARC601
:
3040 strcat (buf
, ", ARC601");
3042 case E_ARC_MACH_ARC700
:
3043 strcat (buf
, ", ARC700");
3046 /* The only times we should end up here are (a) A corrupt ELF, (b) A
3047 new ELF with new architecture being read by an old version of
3048 readelf, or (c) An ELF built with non-GNU compiler that does not
3049 set the architecture in the e_flags. */
3051 if (e_machine
== EM_ARC_COMPACT
)
3052 strcat (buf
, ", Unknown ARCompact");
3054 strcat (buf
, ", Unknown ARC");
3058 switch (e_flags
& EF_ARC_OSABI_MSK
)
3060 case E_ARC_OSABI_ORIG
:
3061 strcat (buf
, ", (ABI:legacy)");
3063 case E_ARC_OSABI_V2
:
3064 strcat (buf
, ", (ABI:v2)");
3066 /* Only upstream 3.9+ kernels will support ARCv2 ISA. */
3067 case E_ARC_OSABI_V3
:
3068 strcat (buf
, ", v3 no-legacy-syscalls ABI");
3070 case E_ARC_OSABI_V4
:
3071 strcat (buf
, ", v4 ABI");
3074 strcat (buf
, ", unrecognised ARC OSABI flag");
3080 decode_ARM_machine_flags (unsigned e_flags
, char buf
[])
3083 bool unknown
= false;
3085 eabi
= EF_ARM_EABI_VERSION (e_flags
);
3086 e_flags
&= ~ EF_ARM_EABIMASK
;
3088 /* Handle "generic" ARM flags. */
3089 if (e_flags
& EF_ARM_RELEXEC
)
3091 strcat (buf
, ", relocatable executable");
3092 e_flags
&= ~ EF_ARM_RELEXEC
;
3095 if (e_flags
& EF_ARM_PIC
)
3097 strcat (buf
, ", position independent");
3098 e_flags
&= ~ EF_ARM_PIC
;
3101 /* Now handle EABI specific flags. */
3105 strcat (buf
, ", <unrecognized EABI>");
3110 case EF_ARM_EABI_VER1
:
3111 strcat (buf
, ", Version1 EABI");
3116 /* Process flags one bit at a time. */
3117 flag
= e_flags
& - e_flags
;
3122 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
3123 strcat (buf
, ", sorted symbol tables");
3133 case EF_ARM_EABI_VER2
:
3134 strcat (buf
, ", Version2 EABI");
3139 /* Process flags one bit at a time. */
3140 flag
= e_flags
& - e_flags
;
3145 case EF_ARM_SYMSARESORTED
: /* Conflicts with EF_ARM_INTERWORK. */
3146 strcat (buf
, ", sorted symbol tables");
3149 case EF_ARM_DYNSYMSUSESEGIDX
:
3150 strcat (buf
, ", dynamic symbols use segment index");
3153 case EF_ARM_MAPSYMSFIRST
:
3154 strcat (buf
, ", mapping symbols precede others");
3164 case EF_ARM_EABI_VER3
:
3165 strcat (buf
, ", Version3 EABI");
3168 case EF_ARM_EABI_VER4
:
3169 strcat (buf
, ", Version4 EABI");
3174 /* Process flags one bit at a time. */
3175 flag
= e_flags
& - e_flags
;
3181 strcat (buf
, ", BE8");
3185 strcat (buf
, ", LE8");
3195 case EF_ARM_EABI_VER5
:
3196 strcat (buf
, ", Version5 EABI");
3201 /* Process flags one bit at a time. */
3202 flag
= e_flags
& - e_flags
;
3208 strcat (buf
, ", BE8");
3212 strcat (buf
, ", LE8");
3215 case EF_ARM_ABI_FLOAT_SOFT
: /* Conflicts with EF_ARM_SOFT_FLOAT. */
3216 strcat (buf
, ", soft-float ABI");
3219 case EF_ARM_ABI_FLOAT_HARD
: /* Conflicts with EF_ARM_VFP_FLOAT. */
3220 strcat (buf
, ", hard-float ABI");
3230 case EF_ARM_EABI_UNKNOWN
:
3231 strcat (buf
, ", GNU EABI");
3236 /* Process flags one bit at a time. */
3237 flag
= e_flags
& - e_flags
;
3242 case EF_ARM_INTERWORK
:
3243 strcat (buf
, ", interworking enabled");
3246 case EF_ARM_APCS_26
:
3247 strcat (buf
, ", uses APCS/26");
3250 case EF_ARM_APCS_FLOAT
:
3251 strcat (buf
, ", uses APCS/float");
3255 strcat (buf
, ", position independent");
3259 strcat (buf
, ", 8 bit structure alignment");
3262 case EF_ARM_NEW_ABI
:
3263 strcat (buf
, ", uses new ABI");
3266 case EF_ARM_OLD_ABI
:
3267 strcat (buf
, ", uses old ABI");
3270 case EF_ARM_SOFT_FLOAT
:
3271 strcat (buf
, ", software FP");
3274 case EF_ARM_VFP_FLOAT
:
3275 strcat (buf
, ", VFP");
3278 case EF_ARM_MAVERICK_FLOAT
:
3279 strcat (buf
, ", Maverick FP");
3290 strcat (buf
,_(", <unknown>"));
3294 decode_AVR_machine_flags (unsigned e_flags
, char buf
[], size_t size
)
3296 --size
; /* Leave space for null terminator. */
3298 switch (e_flags
& EF_AVR_MACH
)
3300 case E_AVR_MACH_AVR1
:
3301 strncat (buf
, ", avr:1", size
);
3303 case E_AVR_MACH_AVR2
:
3304 strncat (buf
, ", avr:2", size
);
3306 case E_AVR_MACH_AVR25
:
3307 strncat (buf
, ", avr:25", size
);
3309 case E_AVR_MACH_AVR3
:
3310 strncat (buf
, ", avr:3", size
);
3312 case E_AVR_MACH_AVR31
:
3313 strncat (buf
, ", avr:31", size
);
3315 case E_AVR_MACH_AVR35
:
3316 strncat (buf
, ", avr:35", size
);
3318 case E_AVR_MACH_AVR4
:
3319 strncat (buf
, ", avr:4", size
);
3321 case E_AVR_MACH_AVR5
:
3322 strncat (buf
, ", avr:5", size
);
3324 case E_AVR_MACH_AVR51
:
3325 strncat (buf
, ", avr:51", size
);
3327 case E_AVR_MACH_AVR6
:
3328 strncat (buf
, ", avr:6", size
);
3330 case E_AVR_MACH_AVRTINY
:
3331 strncat (buf
, ", avr:100", size
);
3333 case E_AVR_MACH_XMEGA1
:
3334 strncat (buf
, ", avr:101", size
);
3336 case E_AVR_MACH_XMEGA2
:
3337 strncat (buf
, ", avr:102", size
);
3339 case E_AVR_MACH_XMEGA3
:
3340 strncat (buf
, ", avr:103", size
);
3342 case E_AVR_MACH_XMEGA4
:
3343 strncat (buf
, ", avr:104", size
);
3345 case E_AVR_MACH_XMEGA5
:
3346 strncat (buf
, ", avr:105", size
);
3348 case E_AVR_MACH_XMEGA6
:
3349 strncat (buf
, ", avr:106", size
);
3351 case E_AVR_MACH_XMEGA7
:
3352 strncat (buf
, ", avr:107", size
);
3355 strncat (buf
, ", avr:<unknown>", size
);
3359 size
-= strlen (buf
);
3360 if (e_flags
& EF_AVR_LINKRELAX_PREPARED
)
3361 strncat (buf
, ", link-relax", size
);
3365 decode_NDS32_machine_flags (unsigned e_flags
, char buf
[], size_t size
)
3371 bool has_fpu
= false;
3374 static const char *ABI_STRINGS
[] =
3376 "ABI v0", /* use r5 as return register; only used in N1213HC */
3377 "ABI v1", /* use r0 as return register */
3378 "ABI v2", /* use r0 as return register and don't reserve 24 bytes for arguments */
3379 "ABI v2fp", /* for FPU */
3383 static const char *VER_STRINGS
[] =
3385 "Andes ELF V1.3 or older",
3389 static const char *ARCH_STRINGS
[] =
3398 abi
= EF_NDS_ABI
& e_flags
;
3399 arch
= EF_NDS_ARCH
& e_flags
;
3400 config
= EF_NDS_INST
& e_flags
;
3401 version
= EF_NDS32_ELF_VERSION
& e_flags
;
3403 memset (buf
, 0, size
);
3410 case E_NDS_ABI_V2FP
:
3411 case E_NDS_ABI_AABI
:
3412 case E_NDS_ABI_V2FP_PLUS
:
3413 /* In case there are holes in the array. */
3414 r
+= snprintf (buf
+ r
, size
- r
, ", %s", ABI_STRINGS
[abi
>> EF_NDS_ABI_SHIFT
]);
3418 r
+= snprintf (buf
+ r
, size
- r
, ", <unrecognized ABI>");
3424 case E_NDS32_ELF_VER_1_2
:
3425 case E_NDS32_ELF_VER_1_3
:
3426 case E_NDS32_ELF_VER_1_4
:
3427 r
+= snprintf (buf
+ r
, size
- r
, ", %s", VER_STRINGS
[version
>> EF_NDS32_ELF_VERSION_SHIFT
]);
3431 r
+= snprintf (buf
+ r
, size
- r
, ", <unrecognized ELF version number>");
3435 if (E_NDS_ABI_V0
== abi
)
3437 /* OLD ABI; only used in N1213HC, has performance extension 1. */
3438 r
+= snprintf (buf
+ r
, size
- r
, ", Andes Star v1.0, N1213HC, MAC, PERF1");
3439 if (arch
== E_NDS_ARCH_STAR_V1_0
)
3440 r
+= snprintf (buf
+ r
, size
-r
, ", 16b"); /* has 16-bit instructions */
3446 case E_NDS_ARCH_STAR_V1_0
:
3447 case E_NDS_ARCH_STAR_V2_0
:
3448 case E_NDS_ARCH_STAR_V3_0
:
3449 case E_NDS_ARCH_STAR_V3_M
:
3450 r
+= snprintf (buf
+ r
, size
- r
, ", %s", ARCH_STRINGS
[arch
>> EF_NDS_ARCH_SHIFT
]);
3454 r
+= snprintf (buf
+ r
, size
- r
, ", <unrecognized architecture>");
3455 /* ARCH version determines how the e_flags are interpreted.
3456 If it is unknown, we cannot proceed. */
3460 /* Newer ABI; Now handle architecture specific flags. */
3461 if (arch
== E_NDS_ARCH_STAR_V1_0
)
3463 if (config
& E_NDS32_HAS_MFUSR_PC_INST
)
3464 r
+= snprintf (buf
+ r
, size
-r
, ", MFUSR_PC");
3466 if (!(config
& E_NDS32_HAS_NO_MAC_INST
))
3467 r
+= snprintf (buf
+ r
, size
-r
, ", MAC");
3469 if (config
& E_NDS32_HAS_DIV_INST
)
3470 r
+= snprintf (buf
+ r
, size
-r
, ", DIV");
3472 if (config
& E_NDS32_HAS_16BIT_INST
)
3473 r
+= snprintf (buf
+ r
, size
-r
, ", 16b");
3477 if (config
& E_NDS32_HAS_MFUSR_PC_INST
)
3479 if (version
<= E_NDS32_ELF_VER_1_3
)
3480 r
+= snprintf (buf
+ r
, size
-r
, ", [B8]");
3482 r
+= snprintf (buf
+ r
, size
-r
, ", EX9");
3485 if (config
& E_NDS32_HAS_MAC_DX_INST
)
3486 r
+= snprintf (buf
+ r
, size
-r
, ", MAC_DX");
3488 if (config
& E_NDS32_HAS_DIV_DX_INST
)
3489 r
+= snprintf (buf
+ r
, size
-r
, ", DIV_DX");
3491 if (config
& E_NDS32_HAS_16BIT_INST
)
3493 if (version
<= E_NDS32_ELF_VER_1_3
)
3494 r
+= snprintf (buf
+ r
, size
-r
, ", 16b");
3496 r
+= snprintf (buf
+ r
, size
-r
, ", IFC");
3500 if (config
& E_NDS32_HAS_EXT_INST
)
3501 r
+= snprintf (buf
+ r
, size
-r
, ", PERF1");
3503 if (config
& E_NDS32_HAS_EXT2_INST
)
3504 r
+= snprintf (buf
+ r
, size
-r
, ", PERF2");
3506 if (config
& E_NDS32_HAS_FPU_INST
)
3509 r
+= snprintf (buf
+ r
, size
-r
, ", FPU_SP");
3512 if (config
& E_NDS32_HAS_FPU_DP_INST
)
3515 r
+= snprintf (buf
+ r
, size
-r
, ", FPU_DP");
3518 if (config
& E_NDS32_HAS_FPU_MAC_INST
)
3521 r
+= snprintf (buf
+ r
, size
-r
, ", FPU_MAC");
3526 switch ((config
& E_NDS32_FPU_REG_CONF
) >> E_NDS32_FPU_REG_CONF_SHIFT
)
3528 case E_NDS32_FPU_REG_8SP_4DP
:
3529 r
+= snprintf (buf
+ r
, size
-r
, ", FPU_REG:8/4");
3531 case E_NDS32_FPU_REG_16SP_8DP
:
3532 r
+= snprintf (buf
+ r
, size
-r
, ", FPU_REG:16/8");
3534 case E_NDS32_FPU_REG_32SP_16DP
:
3535 r
+= snprintf (buf
+ r
, size
-r
, ", FPU_REG:32/16");
3537 case E_NDS32_FPU_REG_32SP_32DP
:
3538 r
+= snprintf (buf
+ r
, size
-r
, ", FPU_REG:32/32");
3543 if (config
& E_NDS32_HAS_AUDIO_INST
)
3544 r
+= snprintf (buf
+ r
, size
-r
, ", AUDIO");
3546 if (config
& E_NDS32_HAS_STRING_INST
)
3547 r
+= snprintf (buf
+ r
, size
-r
, ", STR");
3549 if (config
& E_NDS32_HAS_REDUCED_REGS
)
3550 r
+= snprintf (buf
+ r
, size
-r
, ", 16REG");
3552 if (config
& E_NDS32_HAS_VIDEO_INST
)
3554 if (version
<= E_NDS32_ELF_VER_1_3
)
3555 r
+= snprintf (buf
+ r
, size
-r
, ", VIDEO");
3557 r
+= snprintf (buf
+ r
, size
-r
, ", SATURATION");
3560 if (config
& E_NDS32_HAS_ENCRIPT_INST
)
3561 r
+= snprintf (buf
+ r
, size
-r
, ", ENCRP");
3563 if (config
& E_NDS32_HAS_L2C_INST
)
3564 r
+= snprintf (buf
+ r
, size
-r
, ", L2C");
3568 get_machine_flags (Filedata
* filedata
, unsigned e_flags
, unsigned e_machine
)
3570 static char buf
[1024];
3581 case EM_ARC_COMPACT2
:
3582 case EM_ARC_COMPACT
:
3583 decode_ARC_machine_flags (e_flags
, e_machine
, buf
);
3587 decode_ARM_machine_flags (e_flags
, buf
);
3591 decode_AVR_machine_flags (e_flags
, buf
, sizeof buf
);
3595 if (e_flags
& EF_BFIN_PIC
)
3596 strcat (buf
, ", PIC");
3598 if (e_flags
& EF_BFIN_FDPIC
)
3599 strcat (buf
, ", FDPIC");
3601 if (e_flags
& EF_BFIN_CODE_IN_L1
)
3602 strcat (buf
, ", code in L1");
3604 if (e_flags
& EF_BFIN_DATA_IN_L1
)
3605 strcat (buf
, ", data in L1");
3610 switch (e_flags
& EF_FRV_CPU_MASK
)
3612 case EF_FRV_CPU_GENERIC
:
3616 strcat (buf
, ", fr???");
3619 case EF_FRV_CPU_FR300
:
3620 strcat (buf
, ", fr300");
3623 case EF_FRV_CPU_FR400
:
3624 strcat (buf
, ", fr400");
3626 case EF_FRV_CPU_FR405
:
3627 strcat (buf
, ", fr405");
3630 case EF_FRV_CPU_FR450
:
3631 strcat (buf
, ", fr450");
3634 case EF_FRV_CPU_FR500
:
3635 strcat (buf
, ", fr500");
3637 case EF_FRV_CPU_FR550
:
3638 strcat (buf
, ", fr550");
3641 case EF_FRV_CPU_SIMPLE
:
3642 strcat (buf
, ", simple");
3644 case EF_FRV_CPU_TOMCAT
:
3645 strcat (buf
, ", tomcat");
3651 if ((e_flags
& EF_M68K_ARCH_MASK
) == EF_M68K_M68000
)
3652 strcat (buf
, ", m68000");
3653 else if ((e_flags
& EF_M68K_ARCH_MASK
) == EF_M68K_CPU32
)
3654 strcat (buf
, ", cpu32");
3655 else if ((e_flags
& EF_M68K_ARCH_MASK
) == EF_M68K_FIDO
)
3656 strcat (buf
, ", fido_a");
3659 char const * isa
= _("unknown");
3660 char const * mac
= _("unknown mac");
3661 char const * additional
= NULL
;
3663 switch (e_flags
& EF_M68K_CF_ISA_MASK
)
3665 case EF_M68K_CF_ISA_A_NODIV
:
3667 additional
= ", nodiv";
3669 case EF_M68K_CF_ISA_A
:
3672 case EF_M68K_CF_ISA_A_PLUS
:
3675 case EF_M68K_CF_ISA_B_NOUSP
:
3677 additional
= ", nousp";
3679 case EF_M68K_CF_ISA_B
:
3682 case EF_M68K_CF_ISA_C
:
3685 case EF_M68K_CF_ISA_C_NODIV
:
3687 additional
= ", nodiv";
3690 strcat (buf
, ", cf, isa ");
3693 strcat (buf
, additional
);
3694 if (e_flags
& EF_M68K_CF_FLOAT
)
3695 strcat (buf
, ", float");
3696 switch (e_flags
& EF_M68K_CF_MAC_MASK
)
3701 case EF_M68K_CF_MAC
:
3704 case EF_M68K_CF_EMAC
:
3707 case EF_M68K_CF_EMAC_B
:
3720 switch (e_flags
& EF_MEP_CPU_MASK
)
3722 case EF_MEP_CPU_MEP
: strcat (buf
, ", generic MeP"); break;
3723 case EF_MEP_CPU_C2
: strcat (buf
, ", MeP C2"); break;
3724 case EF_MEP_CPU_C3
: strcat (buf
, ", MeP C3"); break;
3725 case EF_MEP_CPU_C4
: strcat (buf
, ", MeP C4"); break;
3726 case EF_MEP_CPU_C5
: strcat (buf
, ", MeP C5"); break;
3727 case EF_MEP_CPU_H1
: strcat (buf
, ", MeP H1"); break;
3728 default: strcat (buf
, _(", <unknown MeP cpu type>")); break;
3731 switch (e_flags
& EF_MEP_COP_MASK
)
3733 case EF_MEP_COP_NONE
: break;
3734 case EF_MEP_COP_AVC
: strcat (buf
, ", AVC coprocessor"); break;
3735 case EF_MEP_COP_AVC2
: strcat (buf
, ", AVC2 coprocessor"); break;
3736 case EF_MEP_COP_FMAX
: strcat (buf
, ", FMAX coprocessor"); break;
3737 case EF_MEP_COP_IVC2
: strcat (buf
, ", IVC2 coprocessor"); break;
3738 default: strcat (buf
, _("<unknown MeP copro type>")); break;
3741 if (e_flags
& EF_MEP_LIBRARY
)
3742 strcat (buf
, ", Built for Library");
3744 if (e_flags
& EF_MEP_INDEX_MASK
)
3745 sprintf (buf
+ strlen (buf
), ", Configuration Index: %#x",
3746 e_flags
& EF_MEP_INDEX_MASK
);
3748 if (e_flags
& ~ EF_MEP_ALL_FLAGS
)
3749 sprintf (buf
+ strlen (buf
), _(", unknown flags bits: %#x"),
3750 e_flags
& ~ EF_MEP_ALL_FLAGS
);
3754 if (e_flags
& EF_PPC_EMB
)
3755 strcat (buf
, ", emb");
3757 if (e_flags
& EF_PPC_RELOCATABLE
)
3758 strcat (buf
, _(", relocatable"));
3760 if (e_flags
& EF_PPC_RELOCATABLE_LIB
)
3761 strcat (buf
, _(", relocatable-lib"));
3765 if (e_flags
& EF_PPC64_ABI
)
3767 char abi
[] = ", abiv0";
3769 abi
[6] += e_flags
& EF_PPC64_ABI
;
3775 if ((e_flags
& EF_RH850_ABI
) == EF_RH850_ABI
)
3776 strcat (buf
, ", RH850 ABI");
3778 if (e_flags
& EF_V800_850E3
)
3779 strcat (buf
, ", V3 architecture");
3781 if ((e_flags
& (EF_RH850_FPU_DOUBLE
| EF_RH850_FPU_SINGLE
)) == 0)
3782 strcat (buf
, ", FPU not used");
3784 if ((e_flags
& (EF_RH850_REGMODE22
| EF_RH850_REGMODE32
)) == 0)
3785 strcat (buf
, ", regmode: COMMON");
3787 if ((e_flags
& (EF_RH850_GP_FIX
| EF_RH850_GP_NOFIX
)) == 0)
3788 strcat (buf
, ", r4 not used");
3790 if ((e_flags
& (EF_RH850_EP_FIX
| EF_RH850_EP_NOFIX
)) == 0)
3791 strcat (buf
, ", r30 not used");
3793 if ((e_flags
& (EF_RH850_TP_FIX
| EF_RH850_TP_NOFIX
)) == 0)
3794 strcat (buf
, ", r5 not used");
3796 if ((e_flags
& (EF_RH850_REG2_RESERVE
| EF_RH850_REG2_NORESERVE
)) == 0)
3797 strcat (buf
, ", r2 not used");
3799 for (e_flags
&= 0xFFFF; e_flags
; e_flags
&= ~ (e_flags
& - e_flags
))
3801 switch (e_flags
& - e_flags
)
3803 case EF_RH850_FPU_DOUBLE
: strcat (buf
, ", double precision FPU"); break;
3804 case EF_RH850_FPU_SINGLE
: strcat (buf
, ", single precision FPU"); break;
3805 case EF_RH850_REGMODE22
: strcat (buf
, ", regmode:22"); break;
3806 case EF_RH850_REGMODE32
: strcat (buf
, ", regmode:23"); break;
3807 case EF_RH850_GP_FIX
: strcat (buf
, ", r4 fixed"); break;
3808 case EF_RH850_GP_NOFIX
: strcat (buf
, ", r4 free"); break;
3809 case EF_RH850_EP_FIX
: strcat (buf
, ", r30 fixed"); break;
3810 case EF_RH850_EP_NOFIX
: strcat (buf
, ", r30 free"); break;
3811 case EF_RH850_TP_FIX
: strcat (buf
, ", r5 fixed"); break;
3812 case EF_RH850_TP_NOFIX
: strcat (buf
, ", r5 free"); break;
3813 case EF_RH850_REG2_RESERVE
: strcat (buf
, ", r2 fixed"); break;
3814 case EF_RH850_REG2_NORESERVE
: strcat (buf
, ", r2 free"); break;
3821 case EM_CYGNUS_V850
:
3822 switch (e_flags
& EF_V850_ARCH
)
3824 case E_V850E3V5_ARCH
:
3825 strcat (buf
, ", v850e3v5");
3827 case E_V850E2V3_ARCH
:
3828 strcat (buf
, ", v850e2v3");
3831 strcat (buf
, ", v850e2");
3834 strcat (buf
, ", v850e1");
3837 strcat (buf
, ", v850e");
3840 strcat (buf
, ", v850");
3843 strcat (buf
, _(", unknown v850 architecture variant"));
3849 case EM_CYGNUS_M32R
:
3850 if ((e_flags
& EF_M32R_ARCH
) == E_M32R_ARCH
)
3851 strcat (buf
, ", m32r");
3855 case EM_MIPS_RS3_LE
:
3856 if (e_flags
& EF_MIPS_NOREORDER
)
3857 strcat (buf
, ", noreorder");
3859 if (e_flags
& EF_MIPS_PIC
)
3860 strcat (buf
, ", pic");
3862 if (e_flags
& EF_MIPS_CPIC
)
3863 strcat (buf
, ", cpic");
3865 if (e_flags
& EF_MIPS_UCODE
)
3866 strcat (buf
, ", ugen_reserved");
3868 if (e_flags
& EF_MIPS_ABI2
)
3869 strcat (buf
, ", abi2");
3871 if (e_flags
& EF_MIPS_OPTIONS_FIRST
)
3872 strcat (buf
, ", odk first");
3874 if (e_flags
& EF_MIPS_32BITMODE
)
3875 strcat (buf
, ", 32bitmode");
3877 if (e_flags
& EF_MIPS_NAN2008
)
3878 strcat (buf
, ", nan2008");
3880 if (e_flags
& EF_MIPS_FP64
)
3881 strcat (buf
, ", fp64");
3883 switch ((e_flags
& EF_MIPS_MACH
))
3885 case E_MIPS_MACH_3900
: strcat (buf
, ", 3900"); break;
3886 case E_MIPS_MACH_4010
: strcat (buf
, ", 4010"); break;
3887 case E_MIPS_MACH_4100
: strcat (buf
, ", 4100"); break;
3888 case E_MIPS_MACH_4111
: strcat (buf
, ", 4111"); break;
3889 case E_MIPS_MACH_4120
: strcat (buf
, ", 4120"); break;
3890 case E_MIPS_MACH_4650
: strcat (buf
, ", 4650"); break;
3891 case E_MIPS_MACH_5400
: strcat (buf
, ", 5400"); break;
3892 case E_MIPS_MACH_5500
: strcat (buf
, ", 5500"); break;
3893 case E_MIPS_MACH_5900
: strcat (buf
, ", 5900"); break;
3894 case E_MIPS_MACH_SB1
: strcat (buf
, ", sb1"); break;
3895 case E_MIPS_MACH_9000
: strcat (buf
, ", 9000"); break;
3896 case E_MIPS_MACH_LS2E
: strcat (buf
, ", loongson-2e"); break;
3897 case E_MIPS_MACH_LS2F
: strcat (buf
, ", loongson-2f"); break;
3898 case E_MIPS_MACH_GS464
: strcat (buf
, ", gs464"); break;
3899 case E_MIPS_MACH_GS464E
: strcat (buf
, ", gs464e"); break;
3900 case E_MIPS_MACH_GS264E
: strcat (buf
, ", gs264e"); break;
3901 case E_MIPS_MACH_OCTEON
: strcat (buf
, ", octeon"); break;
3902 case E_MIPS_MACH_OCTEON2
: strcat (buf
, ", octeon2"); break;
3903 case E_MIPS_MACH_OCTEON3
: strcat (buf
, ", octeon3"); break;
3904 case E_MIPS_MACH_XLR
: strcat (buf
, ", xlr"); break;
3905 case E_MIPS_MACH_IAMR2
: strcat (buf
, ", interaptiv-mr2"); break;
3907 /* We simply ignore the field in this case to avoid confusion:
3908 MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
3911 default: strcat (buf
, _(", unknown CPU")); break;
3914 switch ((e_flags
& EF_MIPS_ABI
))
3916 case E_MIPS_ABI_O32
: strcat (buf
, ", o32"); break;
3917 case E_MIPS_ABI_O64
: strcat (buf
, ", o64"); break;
3918 case E_MIPS_ABI_EABI32
: strcat (buf
, ", eabi32"); break;
3919 case E_MIPS_ABI_EABI64
: strcat (buf
, ", eabi64"); break;
3921 /* We simply ignore the field in this case to avoid confusion:
3922 MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension.
3923 This means it is likely to be an o32 file, but not for
3926 default: strcat (buf
, _(", unknown ABI")); break;
3929 if (e_flags
& EF_MIPS_ARCH_ASE_MDMX
)
3930 strcat (buf
, ", mdmx");
3932 if (e_flags
& EF_MIPS_ARCH_ASE_M16
)
3933 strcat (buf
, ", mips16");
3935 if (e_flags
& EF_MIPS_ARCH_ASE_MICROMIPS
)
3936 strcat (buf
, ", micromips");
3938 switch ((e_flags
& EF_MIPS_ARCH
))
3940 case E_MIPS_ARCH_1
: strcat (buf
, ", mips1"); break;
3941 case E_MIPS_ARCH_2
: strcat (buf
, ", mips2"); break;
3942 case E_MIPS_ARCH_3
: strcat (buf
, ", mips3"); break;
3943 case E_MIPS_ARCH_4
: strcat (buf
, ", mips4"); break;
3944 case E_MIPS_ARCH_5
: strcat (buf
, ", mips5"); break;
3945 case E_MIPS_ARCH_32
: strcat (buf
, ", mips32"); break;
3946 case E_MIPS_ARCH_32R2
: strcat (buf
, ", mips32r2"); break;
3947 case E_MIPS_ARCH_32R6
: strcat (buf
, ", mips32r6"); break;
3948 case E_MIPS_ARCH_64
: strcat (buf
, ", mips64"); break;
3949 case E_MIPS_ARCH_64R2
: strcat (buf
, ", mips64r2"); break;
3950 case E_MIPS_ARCH_64R6
: strcat (buf
, ", mips64r6"); break;
3951 default: strcat (buf
, _(", unknown ISA")); break;
3956 decode_NDS32_machine_flags (e_flags
, buf
, sizeof buf
);
3960 switch (EF_NFP_MACH (e_flags
))
3962 case E_NFP_MACH_3200
:
3963 strcat (buf
, ", NFP-32xx");
3965 case E_NFP_MACH_6000
:
3966 strcat (buf
, ", NFP-6xxx");
3972 if (e_flags
& EF_RISCV_RVC
)
3973 strcat (buf
, ", RVC");
3975 if (e_flags
& EF_RISCV_RVE
)
3976 strcat (buf
, ", RVE");
3978 switch (e_flags
& EF_RISCV_FLOAT_ABI
)
3980 case EF_RISCV_FLOAT_ABI_SOFT
:
3981 strcat (buf
, ", soft-float ABI");
3984 case EF_RISCV_FLOAT_ABI_SINGLE
:
3985 strcat (buf
, ", single-float ABI");
3988 case EF_RISCV_FLOAT_ABI_DOUBLE
:
3989 strcat (buf
, ", double-float ABI");
3992 case EF_RISCV_FLOAT_ABI_QUAD
:
3993 strcat (buf
, ", quad-float ABI");
3999 switch ((e_flags
& EF_SH_MACH_MASK
))
4001 case EF_SH1
: strcat (buf
, ", sh1"); break;
4002 case EF_SH2
: strcat (buf
, ", sh2"); break;
4003 case EF_SH3
: strcat (buf
, ", sh3"); break;
4004 case EF_SH_DSP
: strcat (buf
, ", sh-dsp"); break;
4005 case EF_SH3_DSP
: strcat (buf
, ", sh3-dsp"); break;
4006 case EF_SH4AL_DSP
: strcat (buf
, ", sh4al-dsp"); break;
4007 case EF_SH3E
: strcat (buf
, ", sh3e"); break;
4008 case EF_SH4
: strcat (buf
, ", sh4"); break;
4009 case EF_SH5
: strcat (buf
, ", sh5"); break;
4010 case EF_SH2E
: strcat (buf
, ", sh2e"); break;
4011 case EF_SH4A
: strcat (buf
, ", sh4a"); break;
4012 case EF_SH2A
: strcat (buf
, ", sh2a"); break;
4013 case EF_SH4_NOFPU
: strcat (buf
, ", sh4-nofpu"); break;
4014 case EF_SH4A_NOFPU
: strcat (buf
, ", sh4a-nofpu"); break;
4015 case EF_SH2A_NOFPU
: strcat (buf
, ", sh2a-nofpu"); break;
4016 case EF_SH3_NOMMU
: strcat (buf
, ", sh3-nommu"); break;
4017 case EF_SH4_NOMMU_NOFPU
: strcat (buf
, ", sh4-nommu-nofpu"); break;
4018 case EF_SH2A_SH4_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh4-nommu-nofpu"); break;
4019 case EF_SH2A_SH3_NOFPU
: strcat (buf
, ", sh2a-nofpu-or-sh3-nommu"); break;
4020 case EF_SH2A_SH4
: strcat (buf
, ", sh2a-or-sh4"); break;
4021 case EF_SH2A_SH3E
: strcat (buf
, ", sh2a-or-sh3e"); break;
4022 default: strcat (buf
, _(", unknown ISA")); break;
4025 if (e_flags
& EF_SH_PIC
)
4026 strcat (buf
, ", pic");
4028 if (e_flags
& EF_SH_FDPIC
)
4029 strcat (buf
, ", fdpic");
4033 if (e_flags
& EF_OR1K_NODELAY
)
4034 strcat (buf
, ", no delay");
4038 if (e_flags
& EF_SPARC_32PLUS
)
4039 strcat (buf
, ", v8+");
4041 if (e_flags
& EF_SPARC_SUN_US1
)
4042 strcat (buf
, ", ultrasparcI");
4044 if (e_flags
& EF_SPARC_SUN_US3
)
4045 strcat (buf
, ", ultrasparcIII");
4047 if (e_flags
& EF_SPARC_HAL_R1
)
4048 strcat (buf
, ", halr1");
4050 if (e_flags
& EF_SPARC_LEDATA
)
4051 strcat (buf
, ", ledata");
4053 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_TSO
)
4054 strcat (buf
, ", tso");
4056 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_PSO
)
4057 strcat (buf
, ", pso");
4059 if ((e_flags
& EF_SPARCV9_MM
) == EF_SPARCV9_RMO
)
4060 strcat (buf
, ", rmo");
4064 switch (e_flags
& EF_PARISC_ARCH
)
4066 case EFA_PARISC_1_0
:
4067 strcpy (buf
, ", PA-RISC 1.0");
4069 case EFA_PARISC_1_1
:
4070 strcpy (buf
, ", PA-RISC 1.1");
4072 case EFA_PARISC_2_0
:
4073 strcpy (buf
, ", PA-RISC 2.0");
4078 if (e_flags
& EF_PARISC_TRAPNIL
)
4079 strcat (buf
, ", trapnil");
4080 if (e_flags
& EF_PARISC_EXT
)
4081 strcat (buf
, ", ext");
4082 if (e_flags
& EF_PARISC_LSB
)
4083 strcat (buf
, ", lsb");
4084 if (e_flags
& EF_PARISC_WIDE
)
4085 strcat (buf
, ", wide");
4086 if (e_flags
& EF_PARISC_NO_KABP
)
4087 strcat (buf
, ", no kabp");
4088 if (e_flags
& EF_PARISC_LAZYSWAP
)
4089 strcat (buf
, ", lazyswap");
4094 if ((e_flags
& EF_PICOJAVA_NEWCALLS
) == EF_PICOJAVA_NEWCALLS
)
4095 strcat (buf
, ", new calling convention");
4097 if ((e_flags
& EF_PICOJAVA_GNUCALLS
) == EF_PICOJAVA_GNUCALLS
)
4098 strcat (buf
, ", gnu calling convention");
4102 if ((e_flags
& EF_IA_64_ABI64
))
4103 strcat (buf
, ", 64-bit");
4105 strcat (buf
, ", 32-bit");
4106 if ((e_flags
& EF_IA_64_REDUCEDFP
))
4107 strcat (buf
, ", reduced fp model");
4108 if ((e_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
))
4109 strcat (buf
, ", no function descriptors, constant gp");
4110 else if ((e_flags
& EF_IA_64_CONS_GP
))
4111 strcat (buf
, ", constant gp");
4112 if ((e_flags
& EF_IA_64_ABSOLUTE
))
4113 strcat (buf
, ", absolute");
4114 if (filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_OPENVMS
)
4116 if ((e_flags
& EF_IA_64_VMS_LINKAGES
))
4117 strcat (buf
, ", vms_linkages");
4118 switch ((e_flags
& EF_IA_64_VMS_COMCOD
))
4120 case EF_IA_64_VMS_COMCOD_SUCCESS
:
4122 case EF_IA_64_VMS_COMCOD_WARNING
:
4123 strcat (buf
, ", warning");
4125 case EF_IA_64_VMS_COMCOD_ERROR
:
4126 strcat (buf
, ", error");
4128 case EF_IA_64_VMS_COMCOD_ABORT
:
4129 strcat (buf
, ", abort");
4132 warn (_("Unrecognised IA64 VMS Command Code: %x\n"),
4133 e_flags
& EF_IA_64_VMS_COMCOD
);
4134 strcat (buf
, ", <unknown>");
4140 if ((e_flags
& EF_VAX_NONPIC
))
4141 strcat (buf
, ", non-PIC");
4142 if ((e_flags
& EF_VAX_DFLOAT
))
4143 strcat (buf
, ", D-Float");
4144 if ((e_flags
& EF_VAX_GFLOAT
))
4145 strcat (buf
, ", G-Float");
4149 if (e_flags
& EF_VISIUM_ARCH_MCM
)
4150 strcat (buf
, ", mcm");
4151 else if (e_flags
& EF_VISIUM_ARCH_MCM24
)
4152 strcat (buf
, ", mcm24");
4153 if (e_flags
& EF_VISIUM_ARCH_GR6
)
4154 strcat (buf
, ", gr6");
4158 switch (e_flags
& E_FLAG_RL78_CPU_MASK
)
4160 case E_FLAG_RL78_ANY_CPU
: break;
4161 case E_FLAG_RL78_G10
: strcat (buf
, ", G10"); break;
4162 case E_FLAG_RL78_G13
: strcat (buf
, ", G13"); break;
4163 case E_FLAG_RL78_G14
: strcat (buf
, ", G14"); break;
4165 if (e_flags
& E_FLAG_RL78_64BIT_DOUBLES
)
4166 strcat (buf
, ", 64-bit doubles");
4170 if (e_flags
& E_FLAG_RX_64BIT_DOUBLES
)
4171 strcat (buf
, ", 64-bit doubles");
4172 if (e_flags
& E_FLAG_RX_DSP
)
4173 strcat (buf
, ", dsp");
4174 if (e_flags
& E_FLAG_RX_PID
)
4175 strcat (buf
, ", pid");
4176 if (e_flags
& E_FLAG_RX_ABI
)
4177 strcat (buf
, ", RX ABI");
4178 if (e_flags
& E_FLAG_RX_SINSNS_SET
)
4179 strcat (buf
, e_flags
& E_FLAG_RX_SINSNS_YES
4180 ? ", uses String instructions" : ", bans String instructions");
4181 if (e_flags
& E_FLAG_RX_V2
)
4182 strcat (buf
, ", V2");
4183 if (e_flags
& E_FLAG_RX_V3
)
4184 strcat (buf
, ", V3");
4188 if (e_flags
& EF_S390_HIGH_GPRS
)
4189 strcat (buf
, ", highgprs");
4193 if ((e_flags
& EF_C6000_REL
))
4194 strcat (buf
, ", relocatable module");
4198 strcat (buf
, _(": architecture variant: "));
4199 switch (e_flags
& EF_MSP430_MACH
)
4201 case E_MSP430_MACH_MSP430x11
: strcat (buf
, "MSP430x11"); break;
4202 case E_MSP430_MACH_MSP430x11x1
: strcat (buf
, "MSP430x11x1 "); break;
4203 case E_MSP430_MACH_MSP430x12
: strcat (buf
, "MSP430x12"); break;
4204 case E_MSP430_MACH_MSP430x13
: strcat (buf
, "MSP430x13"); break;
4205 case E_MSP430_MACH_MSP430x14
: strcat (buf
, "MSP430x14"); break;
4206 case E_MSP430_MACH_MSP430x15
: strcat (buf
, "MSP430x15"); break;
4207 case E_MSP430_MACH_MSP430x16
: strcat (buf
, "MSP430x16"); break;
4208 case E_MSP430_MACH_MSP430x31
: strcat (buf
, "MSP430x31"); break;
4209 case E_MSP430_MACH_MSP430x32
: strcat (buf
, "MSP430x32"); break;
4210 case E_MSP430_MACH_MSP430x33
: strcat (buf
, "MSP430x33"); break;
4211 case E_MSP430_MACH_MSP430x41
: strcat (buf
, "MSP430x41"); break;
4212 case E_MSP430_MACH_MSP430x42
: strcat (buf
, "MSP430x42"); break;
4213 case E_MSP430_MACH_MSP430x43
: strcat (buf
, "MSP430x43"); break;
4214 case E_MSP430_MACH_MSP430x44
: strcat (buf
, "MSP430x44"); break;
4215 case E_MSP430_MACH_MSP430X
: strcat (buf
, "MSP430X"); break;
4217 strcat (buf
, _(": unknown")); break;
4220 if (e_flags
& ~ EF_MSP430_MACH
)
4221 strcat (buf
, _(": unknown extra flag bits also present"));
4225 switch (e_flags
& EF_Z80_MACH_MSK
)
4227 case EF_Z80_MACH_Z80
: strcat (buf
, ", Z80"); break;
4228 case EF_Z80_MACH_Z180
: strcat (buf
, ", Z180"); break;
4229 case EF_Z80_MACH_R800
: strcat (buf
, ", R800"); break;
4230 case EF_Z80_MACH_EZ80_Z80
: strcat (buf
, ", EZ80"); break;
4231 case EF_Z80_MACH_EZ80_ADL
: strcat (buf
, ", EZ80, ADL"); break;
4232 case EF_Z80_MACH_GBZ80
: strcat (buf
, ", GBZ80"); break;
4233 case EF_Z80_MACH_Z80N
: strcat (buf
, ", Z80N"); break;
4235 strcat (buf
, _(", unknown")); break;
4239 if (EF_LOONGARCH_IS_LP64 (e_flags
))
4240 strcat (buf
, ", LP64");
4241 else if (EF_LOONGARCH_IS_ILP32 (e_flags
))
4242 strcat (buf
, ", ILP32");
4244 if (EF_LOONGARCH_IS_SOFT_FLOAT (e_flags
))
4245 strcat (buf
, ", SOFT-FLOAT");
4246 else if (EF_LOONGARCH_IS_SINGLE_FLOAT (e_flags
))
4247 strcat (buf
, ", SINGLE-FLOAT");
4248 else if (EF_LOONGARCH_IS_DOUBLE_FLOAT (e_flags
))
4249 strcat (buf
, ", DOUBLE-FLOAT");
4259 get_osabi_name (Filedata
* filedata
, unsigned int osabi
)
4261 static char buff
[32];
4265 case ELFOSABI_NONE
: return "UNIX - System V";
4266 case ELFOSABI_HPUX
: return "UNIX - HP-UX";
4267 case ELFOSABI_NETBSD
: return "UNIX - NetBSD";
4268 case ELFOSABI_GNU
: return "UNIX - GNU";
4269 case ELFOSABI_SOLARIS
: return "UNIX - Solaris";
4270 case ELFOSABI_AIX
: return "UNIX - AIX";
4271 case ELFOSABI_IRIX
: return "UNIX - IRIX";
4272 case ELFOSABI_FREEBSD
: return "UNIX - FreeBSD";
4273 case ELFOSABI_TRU64
: return "UNIX - TRU64";
4274 case ELFOSABI_MODESTO
: return "Novell - Modesto";
4275 case ELFOSABI_OPENBSD
: return "UNIX - OpenBSD";
4276 case ELFOSABI_OPENVMS
: return "VMS - OpenVMS";
4277 case ELFOSABI_NSK
: return "HP - Non-Stop Kernel";
4278 case ELFOSABI_AROS
: return "AROS";
4279 case ELFOSABI_FENIXOS
: return "FenixOS";
4280 case ELFOSABI_CLOUDABI
: return "Nuxi CloudABI";
4281 case ELFOSABI_OPENVOS
: return "Stratus Technologies OpenVOS";
4284 switch (filedata
->file_header
.e_machine
)
4289 case ELFOSABI_ARM
: return "ARM";
4290 case ELFOSABI_ARM_FDPIC
: return "ARM FDPIC";
4301 case ELFOSABI_STANDALONE
: return _("Standalone App");
4310 case ELFOSABI_C6000_ELFABI
: return _("Bare-metal C6000");
4311 case ELFOSABI_C6000_LINUX
: return "Linux C6000";
4320 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), osabi
);
4326 get_aarch64_segment_type (unsigned long type
)
4330 case PT_AARCH64_ARCHEXT
: return "AARCH64_ARCHEXT";
4331 default: return NULL
;
4336 get_arm_segment_type (unsigned long type
)
4340 case PT_ARM_EXIDX
: return "EXIDX";
4341 default: return NULL
;
4346 get_s390_segment_type (unsigned long type
)
4350 case PT_S390_PGSTE
: return "S390_PGSTE";
4351 default: return NULL
;
4356 get_mips_segment_type (unsigned long type
)
4360 case PT_MIPS_REGINFO
: return "REGINFO";
4361 case PT_MIPS_RTPROC
: return "RTPROC";
4362 case PT_MIPS_OPTIONS
: return "OPTIONS";
4363 case PT_MIPS_ABIFLAGS
: return "ABIFLAGS";
4364 default: return NULL
;
4369 get_parisc_segment_type (unsigned long type
)
4373 case PT_PARISC_ARCHEXT
: return "PARISC_ARCHEXT";
4374 case PT_PARISC_UNWIND
: return "PARISC_UNWIND";
4375 case PT_PARISC_WEAKORDER
: return "PARISC_WEAKORDER";
4376 default: return NULL
;
4381 get_ia64_segment_type (unsigned long type
)
4385 case PT_IA_64_ARCHEXT
: return "IA_64_ARCHEXT";
4386 case PT_IA_64_UNWIND
: return "IA_64_UNWIND";
4387 default: return NULL
;
4392 get_tic6x_segment_type (unsigned long type
)
4396 case PT_C6000_PHATTR
: return "C6000_PHATTR";
4397 default: return NULL
;
4402 get_riscv_segment_type (unsigned long type
)
4406 case PT_RISCV_ATTRIBUTES
: return "RISCV_ATTRIBUTES";
4407 default: return NULL
;
4412 get_hpux_segment_type (unsigned long type
, unsigned e_machine
)
4414 if (e_machine
== EM_PARISC
)
4417 case PT_HP_TLS
: return "HP_TLS";
4418 case PT_HP_CORE_NONE
: return "HP_CORE_NONE";
4419 case PT_HP_CORE_VERSION
: return "HP_CORE_VERSION";
4420 case PT_HP_CORE_KERNEL
: return "HP_CORE_KERNEL";
4421 case PT_HP_CORE_COMM
: return "HP_CORE_COMM";
4422 case PT_HP_CORE_PROC
: return "HP_CORE_PROC";
4423 case PT_HP_CORE_LOADABLE
: return "HP_CORE_LOADABLE";
4424 case PT_HP_CORE_STACK
: return "HP_CORE_STACK";
4425 case PT_HP_CORE_SHM
: return "HP_CORE_SHM";
4426 case PT_HP_CORE_MMF
: return "HP_CORE_MMF";
4427 case PT_HP_PARALLEL
: return "HP_PARALLEL";
4428 case PT_HP_FASTBIND
: return "HP_FASTBIND";
4429 case PT_HP_OPT_ANNOT
: return "HP_OPT_ANNOT";
4430 case PT_HP_HSL_ANNOT
: return "HP_HSL_ANNOT";
4431 case PT_HP_STACK
: return "HP_STACK";
4432 case PT_HP_CORE_UTSNAME
: return "HP_CORE_UTSNAME";
4433 default: return NULL
;
4436 if (e_machine
== EM_IA_64
)
4439 case PT_HP_TLS
: return "HP_TLS";
4440 case PT_IA_64_HP_OPT_ANOT
: return "HP_OPT_ANNOT";
4441 case PT_IA_64_HP_HSL_ANOT
: return "HP_HSL_ANNOT";
4442 case PT_IA_64_HP_STACK
: return "HP_STACK";
4443 default: return NULL
;
4450 get_solaris_segment_type (unsigned long type
)
4454 case 0x6464e550: return "PT_SUNW_UNWIND";
4455 case 0x6474e550: return "PT_SUNW_EH_FRAME";
4456 case 0x6ffffff7: return "PT_LOSUNW";
4457 case 0x6ffffffa: return "PT_SUNWBSS";
4458 case 0x6ffffffb: return "PT_SUNWSTACK";
4459 case 0x6ffffffc: return "PT_SUNWDTRACE";
4460 case 0x6ffffffd: return "PT_SUNWCAP";
4461 case 0x6fffffff: return "PT_HISUNW";
4462 default: return NULL
;
4467 get_segment_type (Filedata
* filedata
, unsigned long p_type
)
4469 static char buff
[32];
4473 case PT_NULL
: return "NULL";
4474 case PT_LOAD
: return "LOAD";
4475 case PT_DYNAMIC
: return "DYNAMIC";
4476 case PT_INTERP
: return "INTERP";
4477 case PT_NOTE
: return "NOTE";
4478 case PT_SHLIB
: return "SHLIB";
4479 case PT_PHDR
: return "PHDR";
4480 case PT_TLS
: return "TLS";
4481 case PT_GNU_EH_FRAME
: return "GNU_EH_FRAME";
4482 case PT_GNU_STACK
: return "GNU_STACK";
4483 case PT_GNU_RELRO
: return "GNU_RELRO";
4484 case PT_GNU_PROPERTY
: return "GNU_PROPERTY";
4486 case PT_OPENBSD_RANDOMIZE
: return "OPENBSD_RANDOMIZE";
4487 case PT_OPENBSD_WXNEEDED
: return "OPENBSD_WXNEEDED";
4488 case PT_OPENBSD_BOOTDATA
: return "OPENBSD_BOOTDATA";
4491 if ((p_type
>= PT_LOPROC
) && (p_type
<= PT_HIPROC
))
4493 const char * result
;
4495 switch (filedata
->file_header
.e_machine
)
4498 result
= get_aarch64_segment_type (p_type
);
4501 result
= get_arm_segment_type (p_type
);
4504 case EM_MIPS_RS3_LE
:
4505 result
= get_mips_segment_type (p_type
);
4508 result
= get_parisc_segment_type (p_type
);
4511 result
= get_ia64_segment_type (p_type
);
4514 result
= get_tic6x_segment_type (p_type
);
4518 result
= get_s390_segment_type (p_type
);
4521 result
= get_riscv_segment_type (p_type
);
4531 sprintf (buff
, "LOPROC+%#lx", p_type
- PT_LOPROC
);
4533 else if ((p_type
>= PT_LOOS
) && (p_type
<= PT_HIOS
))
4535 const char * result
= NULL
;
4537 switch (filedata
->file_header
.e_ident
[EI_OSABI
])
4540 case ELFOSABI_FREEBSD
:
4541 if (p_type
>= PT_GNU_MBIND_LO
&& p_type
<= PT_GNU_MBIND_HI
)
4543 sprintf (buff
, "GNU_MBIND+%#lx", p_type
- PT_GNU_MBIND_LO
);
4548 result
= get_hpux_segment_type (p_type
,
4549 filedata
->file_header
.e_machine
);
4551 case ELFOSABI_SOLARIS
:
4552 result
= get_solaris_segment_type (p_type
);
4560 sprintf (buff
, "LOOS+%#lx", p_type
- PT_LOOS
);
4563 snprintf (buff
, sizeof (buff
), _("<unknown>: %lx"), p_type
);
4570 get_arc_section_type_name (unsigned int sh_type
)
4574 case SHT_ARC_ATTRIBUTES
: return "ARC_ATTRIBUTES";
4582 get_mips_section_type_name (unsigned int sh_type
)
4586 case SHT_MIPS_LIBLIST
: return "MIPS_LIBLIST";
4587 case SHT_MIPS_MSYM
: return "MIPS_MSYM";
4588 case SHT_MIPS_CONFLICT
: return "MIPS_CONFLICT";
4589 case SHT_MIPS_GPTAB
: return "MIPS_GPTAB";
4590 case SHT_MIPS_UCODE
: return "MIPS_UCODE";
4591 case SHT_MIPS_DEBUG
: return "MIPS_DEBUG";
4592 case SHT_MIPS_REGINFO
: return "MIPS_REGINFO";
4593 case SHT_MIPS_PACKAGE
: return "MIPS_PACKAGE";
4594 case SHT_MIPS_PACKSYM
: return "MIPS_PACKSYM";
4595 case SHT_MIPS_RELD
: return "MIPS_RELD";
4596 case SHT_MIPS_IFACE
: return "MIPS_IFACE";
4597 case SHT_MIPS_CONTENT
: return "MIPS_CONTENT";
4598 case SHT_MIPS_OPTIONS
: return "MIPS_OPTIONS";
4599 case SHT_MIPS_SHDR
: return "MIPS_SHDR";
4600 case SHT_MIPS_FDESC
: return "MIPS_FDESC";
4601 case SHT_MIPS_EXTSYM
: return "MIPS_EXTSYM";
4602 case SHT_MIPS_DENSE
: return "MIPS_DENSE";
4603 case SHT_MIPS_PDESC
: return "MIPS_PDESC";
4604 case SHT_MIPS_LOCSYM
: return "MIPS_LOCSYM";
4605 case SHT_MIPS_AUXSYM
: return "MIPS_AUXSYM";
4606 case SHT_MIPS_OPTSYM
: return "MIPS_OPTSYM";
4607 case SHT_MIPS_LOCSTR
: return "MIPS_LOCSTR";
4608 case SHT_MIPS_LINE
: return "MIPS_LINE";
4609 case SHT_MIPS_RFDESC
: return "MIPS_RFDESC";
4610 case SHT_MIPS_DELTASYM
: return "MIPS_DELTASYM";
4611 case SHT_MIPS_DELTAINST
: return "MIPS_DELTAINST";
4612 case SHT_MIPS_DELTACLASS
: return "MIPS_DELTACLASS";
4613 case SHT_MIPS_DWARF
: return "MIPS_DWARF";
4614 case SHT_MIPS_DELTADECL
: return "MIPS_DELTADECL";
4615 case SHT_MIPS_SYMBOL_LIB
: return "MIPS_SYMBOL_LIB";
4616 case SHT_MIPS_EVENTS
: return "MIPS_EVENTS";
4617 case SHT_MIPS_TRANSLATE
: return "MIPS_TRANSLATE";
4618 case SHT_MIPS_PIXIE
: return "MIPS_PIXIE";
4619 case SHT_MIPS_XLATE
: return "MIPS_XLATE";
4620 case SHT_MIPS_XLATE_DEBUG
: return "MIPS_XLATE_DEBUG";
4621 case SHT_MIPS_WHIRL
: return "MIPS_WHIRL";
4622 case SHT_MIPS_EH_REGION
: return "MIPS_EH_REGION";
4623 case SHT_MIPS_XLATE_OLD
: return "MIPS_XLATE_OLD";
4624 case SHT_MIPS_PDR_EXCEPTION
: return "MIPS_PDR_EXCEPTION";
4625 case SHT_MIPS_ABIFLAGS
: return "MIPS_ABIFLAGS";
4626 case SHT_MIPS_XHASH
: return "MIPS_XHASH";
4634 get_parisc_section_type_name (unsigned int sh_type
)
4638 case SHT_PARISC_EXT
: return "PARISC_EXT";
4639 case SHT_PARISC_UNWIND
: return "PARISC_UNWIND";
4640 case SHT_PARISC_DOC
: return "PARISC_DOC";
4641 case SHT_PARISC_ANNOT
: return "PARISC_ANNOT";
4642 case SHT_PARISC_SYMEXTN
: return "PARISC_SYMEXTN";
4643 case SHT_PARISC_STUBS
: return "PARISC_STUBS";
4644 case SHT_PARISC_DLKM
: return "PARISC_DLKM";
4645 default: return NULL
;
4650 get_ia64_section_type_name (Filedata
* filedata
, unsigned int sh_type
)
4652 /* If the top 8 bits are 0x78 the next 8 are the os/abi ID. */
4653 if ((sh_type
& 0xFF000000) == SHT_IA_64_LOPSREG
)
4654 return get_osabi_name (filedata
, (sh_type
& 0x00FF0000) >> 16);
4658 case SHT_IA_64_EXT
: return "IA_64_EXT";
4659 case SHT_IA_64_UNWIND
: return "IA_64_UNWIND";
4660 case SHT_IA_64_PRIORITY_INIT
: return "IA_64_PRIORITY_INIT";
4661 case SHT_IA_64_VMS_TRACE
: return "VMS_TRACE";
4662 case SHT_IA_64_VMS_TIE_SIGNATURES
: return "VMS_TIE_SIGNATURES";
4663 case SHT_IA_64_VMS_DEBUG
: return "VMS_DEBUG";
4664 case SHT_IA_64_VMS_DEBUG_STR
: return "VMS_DEBUG_STR";
4665 case SHT_IA_64_VMS_LINKAGES
: return "VMS_LINKAGES";
4666 case SHT_IA_64_VMS_SYMBOL_VECTOR
: return "VMS_SYMBOL_VECTOR";
4667 case SHT_IA_64_VMS_FIXUP
: return "VMS_FIXUP";
4675 get_x86_64_section_type_name (unsigned int sh_type
)
4679 case SHT_X86_64_UNWIND
: return "X86_64_UNWIND";
4680 default: return NULL
;
4685 get_aarch64_section_type_name (unsigned int sh_type
)
4689 case SHT_AARCH64_ATTRIBUTES
: return "AARCH64_ATTRIBUTES";
4690 default: return NULL
;
4695 get_arm_section_type_name (unsigned int sh_type
)
4699 case SHT_ARM_EXIDX
: return "ARM_EXIDX";
4700 case SHT_ARM_PREEMPTMAP
: return "ARM_PREEMPTMAP";
4701 case SHT_ARM_ATTRIBUTES
: return "ARM_ATTRIBUTES";
4702 case SHT_ARM_DEBUGOVERLAY
: return "ARM_DEBUGOVERLAY";
4703 case SHT_ARM_OVERLAYSECTION
: return "ARM_OVERLAYSECTION";
4704 default: return NULL
;
4709 get_tic6x_section_type_name (unsigned int sh_type
)
4713 case SHT_C6000_UNWIND
: return "C6000_UNWIND";
4714 case SHT_C6000_PREEMPTMAP
: return "C6000_PREEMPTMAP";
4715 case SHT_C6000_ATTRIBUTES
: return "C6000_ATTRIBUTES";
4716 case SHT_TI_ICODE
: return "TI_ICODE";
4717 case SHT_TI_XREF
: return "TI_XREF";
4718 case SHT_TI_HANDLER
: return "TI_HANDLER";
4719 case SHT_TI_INITINFO
: return "TI_INITINFO";
4720 case SHT_TI_PHATTRS
: return "TI_PHATTRS";
4721 default: return NULL
;
4726 get_msp430_section_type_name (unsigned int sh_type
)
4730 case SHT_MSP430_SEC_FLAGS
: return "MSP430_SEC_FLAGS";
4731 case SHT_MSP430_SYM_ALIASES
: return "MSP430_SYM_ALIASES";
4732 case SHT_MSP430_ATTRIBUTES
: return "MSP430_ATTRIBUTES";
4733 default: return NULL
;
4738 get_nfp_section_type_name (unsigned int sh_type
)
4742 case SHT_NFP_MECONFIG
: return "NFP_MECONFIG";
4743 case SHT_NFP_INITREG
: return "NFP_INITREG";
4744 case SHT_NFP_UDEBUG
: return "NFP_UDEBUG";
4745 default: return NULL
;
4750 get_v850_section_type_name (unsigned int sh_type
)
4754 case SHT_V850_SCOMMON
: return "V850 Small Common";
4755 case SHT_V850_TCOMMON
: return "V850 Tiny Common";
4756 case SHT_V850_ZCOMMON
: return "V850 Zero Common";
4757 case SHT_RENESAS_IOP
: return "RENESAS IOP";
4758 case SHT_RENESAS_INFO
: return "RENESAS INFO";
4759 default: return NULL
;
4764 get_riscv_section_type_name (unsigned int sh_type
)
4768 case SHT_RISCV_ATTRIBUTES
: return "RISCV_ATTRIBUTES";
4769 default: return NULL
;
4774 get_csky_section_type_name (unsigned int sh_type
)
4778 case SHT_CSKY_ATTRIBUTES
: return "CSKY_ATTRIBUTES";
4779 default: return NULL
;
4784 get_section_type_name (Filedata
* filedata
, unsigned int sh_type
)
4786 static char buff
[32];
4787 const char * result
;
4791 case SHT_NULL
: return "NULL";
4792 case SHT_PROGBITS
: return "PROGBITS";
4793 case SHT_SYMTAB
: return "SYMTAB";
4794 case SHT_STRTAB
: return "STRTAB";
4795 case SHT_RELA
: return "RELA";
4796 case SHT_RELR
: return "RELR";
4797 case SHT_HASH
: return "HASH";
4798 case SHT_DYNAMIC
: return "DYNAMIC";
4799 case SHT_NOTE
: return "NOTE";
4800 case SHT_NOBITS
: return "NOBITS";
4801 case SHT_REL
: return "REL";
4802 case SHT_SHLIB
: return "SHLIB";
4803 case SHT_DYNSYM
: return "DYNSYM";
4804 case SHT_INIT_ARRAY
: return "INIT_ARRAY";
4805 case SHT_FINI_ARRAY
: return "FINI_ARRAY";
4806 case SHT_PREINIT_ARRAY
: return "PREINIT_ARRAY";
4807 case SHT_GNU_HASH
: return "GNU_HASH";
4808 case SHT_GROUP
: return "GROUP";
4809 case SHT_SYMTAB_SHNDX
: return "SYMTAB SECTION INDICES";
4810 case SHT_GNU_verdef
: return "VERDEF";
4811 case SHT_GNU_verneed
: return "VERNEED";
4812 case SHT_GNU_versym
: return "VERSYM";
4813 case 0x6ffffff0: return "VERSYM";
4814 case 0x6ffffffc: return "VERDEF";
4815 case 0x7ffffffd: return "AUXILIARY";
4816 case 0x7fffffff: return "FILTER";
4817 case SHT_GNU_LIBLIST
: return "GNU_LIBLIST";
4820 if ((sh_type
>= SHT_LOPROC
) && (sh_type
<= SHT_HIPROC
))
4822 switch (filedata
->file_header
.e_machine
)
4825 case EM_ARC_COMPACT
:
4826 case EM_ARC_COMPACT2
:
4827 result
= get_arc_section_type_name (sh_type
);
4830 case EM_MIPS_RS3_LE
:
4831 result
= get_mips_section_type_name (sh_type
);
4834 result
= get_parisc_section_type_name (sh_type
);
4837 result
= get_ia64_section_type_name (filedata
, sh_type
);
4842 result
= get_x86_64_section_type_name (sh_type
);
4845 result
= get_aarch64_section_type_name (sh_type
);
4848 result
= get_arm_section_type_name (sh_type
);
4851 result
= get_tic6x_section_type_name (sh_type
);
4854 result
= get_msp430_section_type_name (sh_type
);
4857 result
= get_nfp_section_type_name (sh_type
);
4861 case EM_CYGNUS_V850
:
4862 result
= get_v850_section_type_name (sh_type
);
4865 result
= get_riscv_section_type_name (sh_type
);
4868 result
= get_csky_section_type_name (sh_type
);
4878 sprintf (buff
, "LOPROC+%#x", sh_type
- SHT_LOPROC
);
4880 else if ((sh_type
>= SHT_LOOS
) && (sh_type
<= SHT_HIOS
))
4882 switch (filedata
->file_header
.e_machine
)
4885 result
= get_ia64_section_type_name (filedata
, sh_type
);
4888 if (filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_SOLARIS
)
4889 result
= get_solaris_section_type (sh_type
);
4894 case SHT_GNU_INCREMENTAL_INPUTS
: result
= "GNU_INCREMENTAL_INPUTS"; break;
4895 case SHT_GNU_ATTRIBUTES
: result
= "GNU_ATTRIBUTES"; break;
4896 case SHT_GNU_HASH
: result
= "GNU_HASH"; break;
4897 case SHT_GNU_LIBLIST
: result
= "GNU_LIBLIST"; break;
4909 sprintf (buff
, "LOOS+%#x", sh_type
- SHT_LOOS
);
4911 else if ((sh_type
>= SHT_LOUSER
) && (sh_type
<= SHT_HIUSER
))
4913 switch (filedata
->file_header
.e_machine
)
4917 case EM_CYGNUS_V850
:
4918 result
= get_v850_section_type_name (sh_type
);
4928 sprintf (buff
, "LOUSER+%#x", sh_type
- SHT_LOUSER
);
4931 /* This message is probably going to be displayed in a 15
4932 character wide field, so put the hex value first. */
4933 snprintf (buff
, sizeof (buff
), _("%08x: <unknown>"), sh_type
);
4939 enum long_option_values
4941 OPTION_DEBUG_DUMP
= 512,
4951 OPTION_WITH_SYMBOL_VERSIONS
,
4952 OPTION_RECURSE_LIMIT
,
4953 OPTION_NO_RECURSE_LIMIT
,
4954 OPTION_NO_DEMANGLING
,
4958 static struct option options
[] =
4960 /* Note - This table is alpha-sorted on the 'val'
4961 field in order to make adding new options easier. */
4962 {"arch-specific", no_argument
, 0, 'A'},
4963 {"all", no_argument
, 0, 'a'},
4964 {"demangle", optional_argument
, 0, 'C'},
4965 {"archive-index", no_argument
, 0, 'c'},
4966 {"use-dynamic", no_argument
, 0, 'D'},
4967 {"dynamic", no_argument
, 0, 'd'},
4968 {"headers", no_argument
, 0, 'e'},
4969 {"section-groups", no_argument
, 0, 'g'},
4970 {"help", no_argument
, 0, 'H'},
4971 {"file-header", no_argument
, 0, 'h'},
4972 {"histogram", no_argument
, 0, 'I'},
4973 {"lint", no_argument
, 0, 'L'},
4974 {"enable-checks", no_argument
, 0, 'L'},
4975 {"program-headers", no_argument
, 0, 'l'},
4976 {"segments", no_argument
, 0, 'l'},
4977 {"full-section-name",no_argument
, 0, 'N'},
4978 {"notes", no_argument
, 0, 'n'},
4979 {"process-links", no_argument
, 0, 'P'},
4980 {"string-dump", required_argument
, 0, 'p'},
4981 {"relocated-dump", required_argument
, 0, 'R'},
4982 {"relocs", no_argument
, 0, 'r'},
4983 {"section-headers", no_argument
, 0, 'S'},
4984 {"sections", no_argument
, 0, 'S'},
4985 {"symbols", no_argument
, 0, 's'},
4986 {"syms", no_argument
, 0, 's'},
4987 {"silent-truncation",no_argument
, 0, 'T'},
4988 {"section-details", no_argument
, 0, 't'},
4989 {"unicode", required_argument
, NULL
, 'U'},
4990 {"unwind", no_argument
, 0, 'u'},
4991 {"version-info", no_argument
, 0, 'V'},
4992 {"version", no_argument
, 0, 'v'},
4993 {"wide", no_argument
, 0, 'W'},
4994 {"hex-dump", required_argument
, 0, 'x'},
4995 {"decompress", no_argument
, 0, 'z'},
4997 {"no-demangle", no_argument
, 0, OPTION_NO_DEMANGLING
},
4998 {"recurse-limit", no_argument
, NULL
, OPTION_RECURSE_LIMIT
},
4999 {"no-recurse-limit", no_argument
, NULL
, OPTION_NO_RECURSE_LIMIT
},
5000 {"no-recursion-limit", no_argument
, NULL
, OPTION_NO_RECURSE_LIMIT
},
5001 {"dyn-syms", no_argument
, 0, OPTION_DYN_SYMS
},
5002 {"lto-syms", no_argument
, 0, OPTION_LTO_SYMS
},
5003 {"debug-dump", optional_argument
, 0, OPTION_DEBUG_DUMP
},
5004 {"dwarf-depth", required_argument
, 0, OPTION_DWARF_DEPTH
},
5005 {"dwarf-start", required_argument
, 0, OPTION_DWARF_START
},
5006 {"dwarf-check", no_argument
, 0, OPTION_DWARF_CHECK
},
5007 #ifdef ENABLE_LIBCTF
5008 {"ctf", required_argument
, 0, OPTION_CTF_DUMP
},
5009 {"ctf-symbols", required_argument
, 0, OPTION_CTF_SYMBOLS
},
5010 {"ctf-strings", required_argument
, 0, OPTION_CTF_STRINGS
},
5011 {"ctf-parent", required_argument
, 0, OPTION_CTF_PARENT
},
5013 {"sym-base", optional_argument
, 0, OPTION_SYM_BASE
},
5015 {0, no_argument
, 0, 0}
5019 usage (FILE * stream
)
5021 fprintf (stream
, _("Usage: readelf <option(s)> elf-file(s)\n"));
5022 fprintf (stream
, _(" Display information about the contents of ELF format files\n"));
5023 fprintf (stream
, _(" Options are:\n"));
5024 fprintf (stream
, _("\
5025 -a --all Equivalent to: -h -l -S -s -r -d -V -A -I\n"));
5026 fprintf (stream
, _("\
5027 -h --file-header Display the ELF file header\n"));
5028 fprintf (stream
, _("\
5029 -l --program-headers Display the program headers\n"));
5030 fprintf (stream
, _("\
5031 --segments An alias for --program-headers\n"));
5032 fprintf (stream
, _("\
5033 -S --section-headers Display the sections' header\n"));
5034 fprintf (stream
, _("\
5035 --sections An alias for --section-headers\n"));
5036 fprintf (stream
, _("\
5037 -g --section-groups Display the section groups\n"));
5038 fprintf (stream
, _("\
5039 -t --section-details Display the section details\n"));
5040 fprintf (stream
, _("\
5041 -e --headers Equivalent to: -h -l -S\n"));
5042 fprintf (stream
, _("\
5043 -s --syms Display the symbol table\n"));
5044 fprintf (stream
, _("\
5045 --symbols An alias for --syms\n"));
5046 fprintf (stream
, _("\
5047 --dyn-syms Display the dynamic symbol table\n"));
5048 fprintf (stream
, _("\
5049 --lto-syms Display LTO symbol tables\n"));
5050 fprintf (stream
, _("\
5051 --sym-base=[0|8|10|16] \n\
5052 Force base for symbol sizes. The options are \n\
5053 mixed (the default), octal, decimal, hexadecimal.\n"));
5054 fprintf (stream
, _("\
5055 -C --demangle[=STYLE] Decode mangled/processed symbol names\n"));
5056 display_demangler_styles (stream
, _("\
5058 fprintf (stream
, _("\
5059 --no-demangle Do not demangle low-level symbol names. (default)\n"));
5060 fprintf (stream
, _("\
5061 --recurse-limit Enable a demangling recursion limit. (default)\n"));
5062 fprintf (stream
, _("\
5063 --no-recurse-limit Disable a demangling recursion limit\n"));
5064 fprintf (stream
, _("\
5065 -U[dlexhi] --unicode=[default|locale|escape|hex|highlight|invalid]\n\
5066 Display unicode characters as determined by the current locale\n\
5067 (default), escape sequences, \"<hex sequences>\", highlighted\n\
5068 escape sequences, or treat them as invalid and display as\n\
5069 \"{hex sequences}\"\n"));
5070 fprintf (stream
, _("\
5071 -n --notes Display the core notes (if present)\n"));
5072 fprintf (stream
, _("\
5073 -r --relocs Display the relocations (if present)\n"));
5074 fprintf (stream
, _("\
5075 -u --unwind Display the unwind info (if present)\n"));
5076 fprintf (stream
, _("\
5077 -d --dynamic Display the dynamic section (if present)\n"));
5078 fprintf (stream
, _("\
5079 -V --version-info Display the version sections (if present)\n"));
5080 fprintf (stream
, _("\
5081 -A --arch-specific Display architecture specific information (if any)\n"));
5082 fprintf (stream
, _("\
5083 -c --archive-index Display the symbol/file index in an archive\n"));
5084 fprintf (stream
, _("\
5085 -D --use-dynamic Use the dynamic section info when displaying symbols\n"));
5086 fprintf (stream
, _("\
5087 -L --lint|--enable-checks\n\
5088 Display warning messages for possible problems\n"));
5089 fprintf (stream
, _("\
5090 -x --hex-dump=<number|name>\n\
5091 Dump the contents of section <number|name> as bytes\n"));
5092 fprintf (stream
, _("\
5093 -p --string-dump=<number|name>\n\
5094 Dump the contents of section <number|name> as strings\n"));
5095 fprintf (stream
, _("\
5096 -R --relocated-dump=<number|name>\n\
5097 Dump the relocated contents of section <number|name>\n"));
5098 fprintf (stream
, _("\
5099 -z --decompress Decompress section before dumping it\n"));
5100 fprintf (stream
, _("\
5101 -w --debug-dump[a/=abbrev, A/=addr, r/=aranges, c/=cu_index, L/=decodedline,\n\
5102 f/=frames, F/=frames-interp, g/=gdb_index, i/=info, o/=loc,\n\
5103 m/=macro, p/=pubnames, t/=pubtypes, R/=Ranges, l/=rawline,\n\
5104 s/=str, O/=str-offsets, u/=trace_abbrev, T/=trace_aranges,\n\
5106 Display the contents of DWARF debug sections\n"));
5107 fprintf (stream
, _("\
5108 -wk --debug-dump=links Display the contents of sections that link to separate\n\
5109 debuginfo files\n"));
5110 fprintf (stream
, _("\
5111 -P --process-links Display the contents of non-debug sections in separate\n\
5112 debuginfo files. (Implies -wK)\n"));
5113 #if DEFAULT_FOR_FOLLOW_LINKS
5114 fprintf (stream
, _("\
5115 -wK --debug-dump=follow-links\n\
5116 Follow links to separate debug info files (default)\n"));
5117 fprintf (stream
, _("\
5118 -wN --debug-dump=no-follow-links\n\
5119 Do not follow links to separate debug info files\n"));
5121 fprintf (stream
, _("\
5122 -wK --debug-dump=follow-links\n\
5123 Follow links to separate debug info files\n"));
5124 fprintf (stream
, _("\
5125 -wN --debug-dump=no-follow-links\n\
5126 Do not follow links to separate debug info files\n\
5129 fprintf (stream
, _("\
5130 --dwarf-depth=N Do not display DIEs at depth N or greater\n"));
5131 fprintf (stream
, _("\
5132 --dwarf-start=N Display DIEs starting at offset N\n"));
5133 #ifdef ENABLE_LIBCTF
5134 fprintf (stream
, _("\
5135 --ctf=<number|name> Display CTF info from section <number|name>\n"));
5136 fprintf (stream
, _("\
5137 --ctf-parent=<name> Use CTF archive member <name> as the CTF parent\n"));
5138 fprintf (stream
, _("\
5139 --ctf-symbols=<number|name>\n\
5140 Use section <number|name> as the CTF external symtab\n"));
5141 fprintf (stream
, _("\
5142 --ctf-strings=<number|name>\n\
5143 Use section <number|name> as the CTF external strtab\n"));
5146 #ifdef SUPPORT_DISASSEMBLY
5147 fprintf (stream
, _("\
5148 -i --instruction-dump=<number|name>\n\
5149 Disassemble the contents of section <number|name>\n"));
5151 fprintf (stream
, _("\
5152 -I --histogram Display histogram of bucket list lengths\n"));
5153 fprintf (stream
, _("\
5154 -W --wide Allow output width to exceed 80 characters\n"));
5155 fprintf (stream
, _("\
5156 -T --silent-truncation If a symbol name is truncated, do not add [...] suffix\n"));
5157 fprintf (stream
, _("\
5158 @<file> Read options from <file>\n"));
5159 fprintf (stream
, _("\
5160 -H --help Display this information\n"));
5161 fprintf (stream
, _("\
5162 -v --version Display the version number of readelf\n"));
5164 if (REPORT_BUGS_TO
[0] && stream
== stdout
)
5165 fprintf (stdout
, _("Report bugs to %s\n"), REPORT_BUGS_TO
);
5167 exit (stream
== stdout
? 0 : 1);
5170 /* Record the fact that the user wants the contents of section number
5171 SECTION to be displayed using the method(s) encoded as flags bits
5172 in TYPE. Note, TYPE can be zero if we are creating the array for
5176 request_dump_bynumber (struct dump_data
*dumpdata
,
5177 unsigned int section
, dump_type type
)
5179 if (section
>= dumpdata
->num_dump_sects
)
5181 dump_type
* new_dump_sects
;
5183 new_dump_sects
= (dump_type
*) calloc (section
+ 1,
5184 sizeof (* new_dump_sects
));
5186 if (new_dump_sects
== NULL
)
5187 error (_("Out of memory allocating dump request table.\n"));
5190 if (dumpdata
->dump_sects
)
5192 /* Copy current flag settings. */
5193 memcpy (new_dump_sects
, dumpdata
->dump_sects
,
5194 dumpdata
->num_dump_sects
* sizeof (* new_dump_sects
));
5196 free (dumpdata
->dump_sects
);
5199 dumpdata
->dump_sects
= new_dump_sects
;
5200 dumpdata
->num_dump_sects
= section
+ 1;
5204 if (dumpdata
->dump_sects
)
5205 dumpdata
->dump_sects
[section
] |= type
;
5208 /* Request a dump by section name. */
5211 request_dump_byname (const char * section
, dump_type type
)
5213 struct dump_list_entry
* new_request
;
5215 new_request
= (struct dump_list_entry
*)
5216 malloc (sizeof (struct dump_list_entry
));
5218 error (_("Out of memory allocating dump request table.\n"));
5220 new_request
->name
= strdup (section
);
5221 if (!new_request
->name
)
5222 error (_("Out of memory allocating dump request table.\n"));
5224 new_request
->type
= type
;
5226 new_request
->next
= dump_sects_byname
;
5227 dump_sects_byname
= new_request
;
5231 request_dump (struct dump_data
*dumpdata
, dump_type type
)
5237 section
= strtoul (optarg
, & cp
, 0);
5239 if (! *cp
&& section
>= 0)
5240 request_dump_bynumber (dumpdata
, section
, type
);
5242 request_dump_byname (optarg
, type
);
5246 parse_args (struct dump_data
*dumpdata
, int argc
, char ** argv
)
5253 while ((c
= getopt_long
5254 (argc
, argv
, "ACDHILNPR:STU:VWacdeghi:lnp:rstuvw::x:z", options
, NULL
)) != EOF
)
5272 do_section_groups
= true;
5275 do_histogram
= true;
5281 do_section_groups
= true;
5286 do_section_details
= true;
5297 do_using_dynamic
= true;
5321 do_histogram
= true;
5327 do_archive_index
= true;
5333 process_links
= true;
5334 do_follow_links
= true;
5337 request_dump (dumpdata
, HEX_DUMP
);
5340 request_dump (dumpdata
, STRING_DUMP
);
5343 request_dump (dumpdata
, RELOC_DUMP
);
5346 decompress_dumps
= true;
5352 do_debugging
= true;
5353 dwarf_select_sections_all ();
5357 do_debugging
= false;
5358 dwarf_select_sections_by_letters (optarg
);
5361 case OPTION_DEBUG_DUMP
:
5365 do_debugging
= true;
5366 dwarf_select_sections_all ();
5370 do_debugging
= false;
5371 dwarf_select_sections_by_names (optarg
);
5374 case OPTION_DWARF_DEPTH
:
5378 dwarf_cutoff_level
= strtoul (optarg
, & cp
, 0);
5381 case OPTION_DWARF_START
:
5385 dwarf_start_die
= strtoul (optarg
, & cp
, 0);
5388 case OPTION_DWARF_CHECK
:
5391 case OPTION_CTF_DUMP
:
5393 request_dump (dumpdata
, CTF_DUMP
);
5395 case OPTION_CTF_SYMBOLS
:
5396 free (dump_ctf_symtab_name
);
5397 dump_ctf_symtab_name
= strdup (optarg
);
5399 case OPTION_CTF_STRINGS
:
5400 free (dump_ctf_strtab_name
);
5401 dump_ctf_strtab_name
= strdup (optarg
);
5403 case OPTION_CTF_PARENT
:
5404 free (dump_ctf_parent_name
);
5405 dump_ctf_parent_name
= strdup (optarg
);
5407 case OPTION_DYN_SYMS
:
5410 case OPTION_LTO_SYMS
:
5413 #ifdef SUPPORT_DISASSEMBLY
5415 request_dump (dumpdata
, DISASS_DUMP
);
5419 print_version (program_name
);
5428 do_not_show_symbol_truncation
= true;
5434 enum demangling_styles style
;
5436 style
= cplus_demangle_name_to_style (optarg
);
5437 if (style
== unknown_demangling
)
5438 error (_("unknown demangling style `%s'"), optarg
);
5440 cplus_demangle_set_style (style
);
5443 case OPTION_NO_DEMANGLING
:
5444 do_demangle
= false;
5446 case OPTION_RECURSE_LIMIT
:
5447 demangle_flags
&= ~ DMGL_NO_RECURSE_LIMIT
;
5449 case OPTION_NO_RECURSE_LIMIT
:
5450 demangle_flags
|= DMGL_NO_RECURSE_LIMIT
;
5452 case OPTION_WITH_SYMBOL_VERSIONS
:
5453 /* Ignored for backward compatibility. */
5458 error (_("Missing arg to -U/--unicode")); /* Can this happen ? */
5459 else if (streq (optarg
, "default") || streq (optarg
, "d"))
5460 unicode_display
= unicode_default
;
5461 else if (streq (optarg
, "locale") || streq (optarg
, "l"))
5462 unicode_display
= unicode_locale
;
5463 else if (streq (optarg
, "escape") || streq (optarg
, "e"))
5464 unicode_display
= unicode_escape
;
5465 else if (streq (optarg
, "invalid") || streq (optarg
, "i"))
5466 unicode_display
= unicode_invalid
;
5467 else if (streq (optarg
, "hex") || streq (optarg
, "x"))
5468 unicode_display
= unicode_hex
;
5469 else if (streq (optarg
, "highlight") || streq (optarg
, "h"))
5470 unicode_display
= unicode_highlight
;
5472 error (_("invalid argument to -U/--unicode: %s"), optarg
);
5475 case OPTION_SYM_BASE
:
5479 sym_base
= strtoul (optarg
, NULL
, 0);
5496 /* xgettext:c-format */
5497 error (_("Invalid option '-%c'\n"), c
);
5504 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
5505 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
5506 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
5507 && !do_section_groups
&& !do_archive_index
5508 && !do_dyn_syms
&& !do_lto_syms
)
5513 do_dynamic
= do_syms
= do_reloc
= do_unwind
= do_sections
= true;
5514 do_segments
= do_header
= do_dump
= do_version
= true;
5515 do_histogram
= do_debugging
= do_arch
= do_notes
= true;
5516 do_section_groups
= do_archive_index
= do_dyn_syms
= true;
5525 get_elf_class (unsigned int elf_class
)
5527 static char buff
[32];
5531 case ELFCLASSNONE
: return _("none");
5532 case ELFCLASS32
: return "ELF32";
5533 case ELFCLASS64
: return "ELF64";
5535 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), elf_class
);
5541 get_data_encoding (unsigned int encoding
)
5543 static char buff
[32];
5547 case ELFDATANONE
: return _("none");
5548 case ELFDATA2LSB
: return _("2's complement, little endian");
5549 case ELFDATA2MSB
: return _("2's complement, big endian");
5551 snprintf (buff
, sizeof (buff
), _("<unknown: %x>"), encoding
);
5556 /* Decode the data held in 'filedata->file_header'. */
5559 process_file_header (Filedata
* filedata
)
5561 Elf_Internal_Ehdr
* header
= & filedata
->file_header
;
5563 if ( header
->e_ident
[EI_MAG0
] != ELFMAG0
5564 || header
->e_ident
[EI_MAG1
] != ELFMAG1
5565 || header
->e_ident
[EI_MAG2
] != ELFMAG2
5566 || header
->e_ident
[EI_MAG3
] != ELFMAG3
)
5569 (_("Not an ELF file - it has the wrong magic bytes at the start\n"));
5573 if (! filedata
->is_separate
)
5574 init_dwarf_regnames_by_elf_machine_code (header
->e_machine
);
5580 if (filedata
->is_separate
)
5581 printf (_("ELF Header in linked file '%s':\n"), filedata
->file_name
);
5583 printf (_("ELF Header:\n"));
5584 printf (_(" Magic: "));
5585 for (i
= 0; i
< EI_NIDENT
; i
++)
5586 printf ("%2.2x ", header
->e_ident
[i
]);
5588 printf (_(" Class: %s\n"),
5589 get_elf_class (header
->e_ident
[EI_CLASS
]));
5590 printf (_(" Data: %s\n"),
5591 get_data_encoding (header
->e_ident
[EI_DATA
]));
5592 printf (_(" Version: %d%s\n"),
5593 header
->e_ident
[EI_VERSION
],
5594 (header
->e_ident
[EI_VERSION
] == EV_CURRENT
5596 : (header
->e_ident
[EI_VERSION
] != EV_NONE
5599 printf (_(" OS/ABI: %s\n"),
5600 get_osabi_name (filedata
, header
->e_ident
[EI_OSABI
]));
5601 printf (_(" ABI Version: %d\n"),
5602 header
->e_ident
[EI_ABIVERSION
]);
5603 printf (_(" Type: %s\n"),
5604 get_file_type (filedata
));
5605 printf (_(" Machine: %s\n"),
5606 get_machine_name (header
->e_machine
));
5607 printf (_(" Version: 0x%lx\n"),
5610 printf (_(" Entry point address: "));
5611 print_vma (header
->e_entry
, PREFIX_HEX
);
5612 printf (_("\n Start of program headers: "));
5613 print_vma (header
->e_phoff
, DEC
);
5614 printf (_(" (bytes into file)\n Start of section headers: "));
5615 print_vma (header
->e_shoff
, DEC
);
5616 printf (_(" (bytes into file)\n"));
5618 printf (_(" Flags: 0x%lx%s\n"),
5620 get_machine_flags (filedata
, header
->e_flags
, header
->e_machine
));
5621 printf (_(" Size of this header: %u (bytes)\n"),
5623 printf (_(" Size of program headers: %u (bytes)\n"),
5624 header
->e_phentsize
);
5625 printf (_(" Number of program headers: %u"),
5627 if (filedata
->section_headers
!= NULL
5628 && header
->e_phnum
== PN_XNUM
5629 && filedata
->section_headers
[0].sh_info
!= 0)
5631 header
->e_phnum
= filedata
->section_headers
[0].sh_info
;
5632 printf (" (%u)", header
->e_phnum
);
5634 putc ('\n', stdout
);
5635 printf (_(" Size of section headers: %u (bytes)\n"),
5636 header
->e_shentsize
);
5637 printf (_(" Number of section headers: %u"),
5639 if (filedata
->section_headers
!= NULL
&& header
->e_shnum
== SHN_UNDEF
)
5641 header
->e_shnum
= filedata
->section_headers
[0].sh_size
;
5642 printf (" (%u)", header
->e_shnum
);
5644 putc ('\n', stdout
);
5645 printf (_(" Section header string table index: %u"),
5646 header
->e_shstrndx
);
5647 if (filedata
->section_headers
!= NULL
5648 && header
->e_shstrndx
== (SHN_XINDEX
& 0xffff))
5650 header
->e_shstrndx
= filedata
->section_headers
[0].sh_link
;
5651 printf (" (%u)", header
->e_shstrndx
);
5653 if (header
->e_shstrndx
!= SHN_UNDEF
5654 && header
->e_shstrndx
>= header
->e_shnum
)
5656 header
->e_shstrndx
= SHN_UNDEF
;
5657 printf (_(" <corrupt: out of range>"));
5659 putc ('\n', stdout
);
5662 if (filedata
->section_headers
!= NULL
)
5664 if (header
->e_phnum
== PN_XNUM
5665 && filedata
->section_headers
[0].sh_info
!= 0)
5666 header
->e_phnum
= filedata
->section_headers
[0].sh_info
;
5667 if (header
->e_shnum
== SHN_UNDEF
)
5668 header
->e_shnum
= filedata
->section_headers
[0].sh_size
;
5669 if (header
->e_shstrndx
== (SHN_XINDEX
& 0xffff))
5670 header
->e_shstrndx
= filedata
->section_headers
[0].sh_link
;
5671 if (header
->e_shstrndx
>= header
->e_shnum
)
5672 header
->e_shstrndx
= SHN_UNDEF
;
5678 /* Read in the program headers from FILEDATA and store them in PHEADERS.
5679 Returns TRUE upon success, FALSE otherwise. Loads 32-bit headers. */
5682 get_32bit_program_headers (Filedata
* filedata
, Elf_Internal_Phdr
* pheaders
)
5684 Elf32_External_Phdr
* phdrs
;
5685 Elf32_External_Phdr
* external
;
5686 Elf_Internal_Phdr
* internal
;
5688 unsigned int size
= filedata
->file_header
.e_phentsize
;
5689 unsigned int num
= filedata
->file_header
.e_phnum
;
5691 /* PR binutils/17531: Cope with unexpected section header sizes. */
5692 if (size
== 0 || num
== 0)
5694 if (size
< sizeof * phdrs
)
5696 error (_("The e_phentsize field in the ELF header is less than the size of an ELF program header\n"));
5699 if (size
> sizeof * phdrs
)
5700 warn (_("The e_phentsize field in the ELF header is larger than the size of an ELF program header\n"));
5702 phdrs
= (Elf32_External_Phdr
*) get_data (NULL
, filedata
, filedata
->file_header
.e_phoff
,
5703 size
, num
, _("program headers"));
5707 for (i
= 0, internal
= pheaders
, external
= phdrs
;
5708 i
< filedata
->file_header
.e_phnum
;
5709 i
++, internal
++, external
++)
5711 internal
->p_type
= BYTE_GET (external
->p_type
);
5712 internal
->p_offset
= BYTE_GET (external
->p_offset
);
5713 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
5714 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
5715 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
5716 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
5717 internal
->p_flags
= BYTE_GET (external
->p_flags
);
5718 internal
->p_align
= BYTE_GET (external
->p_align
);
5725 /* Read in the program headers from FILEDATA and store them in PHEADERS.
5726 Returns TRUE upon success, FALSE otherwise. Loads 64-bit headers. */
5729 get_64bit_program_headers (Filedata
* filedata
, Elf_Internal_Phdr
* pheaders
)
5731 Elf64_External_Phdr
* phdrs
;
5732 Elf64_External_Phdr
* external
;
5733 Elf_Internal_Phdr
* internal
;
5735 unsigned int size
= filedata
->file_header
.e_phentsize
;
5736 unsigned int num
= filedata
->file_header
.e_phnum
;
5738 /* PR binutils/17531: Cope with unexpected section header sizes. */
5739 if (size
== 0 || num
== 0)
5741 if (size
< sizeof * phdrs
)
5743 error (_("The e_phentsize field in the ELF header is less than the size of an ELF program header\n"));
5746 if (size
> sizeof * phdrs
)
5747 warn (_("The e_phentsize field in the ELF header is larger than the size of an ELF program header\n"));
5749 phdrs
= (Elf64_External_Phdr
*) get_data (NULL
, filedata
, filedata
->file_header
.e_phoff
,
5750 size
, num
, _("program headers"));
5754 for (i
= 0, internal
= pheaders
, external
= phdrs
;
5755 i
< filedata
->file_header
.e_phnum
;
5756 i
++, internal
++, external
++)
5758 internal
->p_type
= BYTE_GET (external
->p_type
);
5759 internal
->p_flags
= BYTE_GET (external
->p_flags
);
5760 internal
->p_offset
= BYTE_GET (external
->p_offset
);
5761 internal
->p_vaddr
= BYTE_GET (external
->p_vaddr
);
5762 internal
->p_paddr
= BYTE_GET (external
->p_paddr
);
5763 internal
->p_filesz
= BYTE_GET (external
->p_filesz
);
5764 internal
->p_memsz
= BYTE_GET (external
->p_memsz
);
5765 internal
->p_align
= BYTE_GET (external
->p_align
);
5772 /* Returns TRUE if the program headers were read into `program_headers'. */
5775 get_program_headers (Filedata
* filedata
)
5777 Elf_Internal_Phdr
* phdrs
;
5779 /* Check cache of prior read. */
5780 if (filedata
->program_headers
!= NULL
)
5783 /* Be kind to memory checkers by looking for
5784 e_phnum values which we know must be invalid. */
5785 if (filedata
->file_header
.e_phnum
5786 * (is_32bit_elf
? sizeof (Elf32_External_Phdr
) : sizeof (Elf64_External_Phdr
))
5787 >= filedata
->file_size
)
5789 error (_("Too many program headers - %#x - the file is not that big\n"),
5790 filedata
->file_header
.e_phnum
);
5794 phdrs
= (Elf_Internal_Phdr
*) cmalloc (filedata
->file_header
.e_phnum
,
5795 sizeof (Elf_Internal_Phdr
));
5798 error (_("Out of memory reading %u program headers\n"),
5799 filedata
->file_header
.e_phnum
);
5804 ? get_32bit_program_headers (filedata
, phdrs
)
5805 : get_64bit_program_headers (filedata
, phdrs
))
5807 filedata
->program_headers
= phdrs
;
5815 /* Print program header info and locate dynamic section. */
5818 process_program_headers (Filedata
* filedata
)
5820 Elf_Internal_Phdr
* segment
;
5822 Elf_Internal_Phdr
* previous_load
= NULL
;
5824 if (filedata
->file_header
.e_phnum
== 0)
5826 /* PR binutils/12467. */
5827 if (filedata
->file_header
.e_phoff
!= 0)
5828 warn (_("possibly corrupt ELF header - it has a non-zero program"
5829 " header offset, but no program headers\n"));
5830 else if (do_segments
)
5832 if (filedata
->is_separate
)
5833 printf (_("\nThere are no program headers in linked file '%s'.\n"),
5834 filedata
->file_name
);
5836 printf (_("\nThere are no program headers in this file.\n"));
5841 if (do_segments
&& !do_header
)
5843 if (filedata
->is_separate
)
5844 printf ("\nIn linked file '%s' the ELF file type is %s\n",
5845 filedata
->file_name
, get_file_type (filedata
));
5847 printf (_("\nElf file type is %s\n"), get_file_type (filedata
));
5848 printf (_("Entry point 0x%s\n"), bfd_vmatoa ("x", filedata
->file_header
.e_entry
));
5849 printf (ngettext ("There is %d program header, starting at offset %s\n",
5850 "There are %d program headers, starting at offset %s\n",
5851 filedata
->file_header
.e_phnum
),
5852 filedata
->file_header
.e_phnum
,
5853 bfd_vmatoa ("u", filedata
->file_header
.e_phoff
));
5856 if (! get_program_headers (filedata
))
5861 if (filedata
->file_header
.e_phnum
> 1)
5862 printf (_("\nProgram Headers:\n"));
5864 printf (_("\nProgram Headers:\n"));
5868 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
5871 (_(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"));
5875 (_(" Type Offset VirtAddr PhysAddr\n"));
5877 (_(" FileSiz MemSiz Flags Align\n"));
5881 unsigned long dynamic_addr
= 0;
5882 bfd_size_type dynamic_size
= 0;
5883 for (i
= 0, segment
= filedata
->program_headers
;
5884 i
< filedata
->file_header
.e_phnum
;
5889 printf (" %-14.14s ", get_segment_type (filedata
, segment
->p_type
));
5893 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
5894 printf ("0x%8.8lx ", (unsigned long) segment
->p_vaddr
);
5895 printf ("0x%8.8lx ", (unsigned long) segment
->p_paddr
);
5896 printf ("0x%5.5lx ", (unsigned long) segment
->p_filesz
);
5897 printf ("0x%5.5lx ", (unsigned long) segment
->p_memsz
);
5899 (segment
->p_flags
& PF_R
? 'R' : ' '),
5900 (segment
->p_flags
& PF_W
? 'W' : ' '),
5901 (segment
->p_flags
& PF_X
? 'E' : ' '));
5902 printf ("%#lx", (unsigned long) segment
->p_align
);
5906 if ((unsigned long) segment
->p_offset
== segment
->p_offset
)
5907 printf ("0x%6.6lx ", (unsigned long) segment
->p_offset
);
5910 print_vma (segment
->p_offset
, FULL_HEX
);
5914 print_vma (segment
->p_vaddr
, FULL_HEX
);
5916 print_vma (segment
->p_paddr
, FULL_HEX
);
5919 if ((unsigned long) segment
->p_filesz
== segment
->p_filesz
)
5920 printf ("0x%6.6lx ", (unsigned long) segment
->p_filesz
);
5923 print_vma (segment
->p_filesz
, FULL_HEX
);
5927 if ((unsigned long) segment
->p_memsz
== segment
->p_memsz
)
5928 printf ("0x%6.6lx", (unsigned long) segment
->p_memsz
);
5931 print_vma (segment
->p_memsz
, FULL_HEX
);
5935 (segment
->p_flags
& PF_R
? 'R' : ' '),
5936 (segment
->p_flags
& PF_W
? 'W' : ' '),
5937 (segment
->p_flags
& PF_X
? 'E' : ' '));
5939 if ((unsigned long) segment
->p_align
== segment
->p_align
)
5940 printf ("%#lx", (unsigned long) segment
->p_align
);
5943 print_vma (segment
->p_align
, PREFIX_HEX
);
5948 print_vma (segment
->p_offset
, FULL_HEX
);
5950 print_vma (segment
->p_vaddr
, FULL_HEX
);
5952 print_vma (segment
->p_paddr
, FULL_HEX
);
5954 print_vma (segment
->p_filesz
, FULL_HEX
);
5956 print_vma (segment
->p_memsz
, FULL_HEX
);
5958 (segment
->p_flags
& PF_R
? 'R' : ' '),
5959 (segment
->p_flags
& PF_W
? 'W' : ' '),
5960 (segment
->p_flags
& PF_X
? 'E' : ' '));
5961 print_vma (segment
->p_align
, PREFIX_HEX
);
5964 putc ('\n', stdout
);
5967 switch (segment
->p_type
)
5970 #if 0 /* Do not warn about out of order PT_LOAD segments. Although officially
5971 required by the ELF standard, several programs, including the Linux
5972 kernel, make use of non-ordered segments. */
5974 && previous_load
->p_vaddr
> segment
->p_vaddr
)
5975 error (_("LOAD segments must be sorted in order of increasing VirtAddr\n"));
5977 if (segment
->p_memsz
< segment
->p_filesz
)
5978 error (_("the segment's file size is larger than its memory size\n"));
5979 previous_load
= segment
;
5983 /* PR 20815 - Verify that the program header is loaded into memory. */
5984 if (i
> 0 && previous_load
!= NULL
)
5985 error (_("the PHDR segment must occur before any LOAD segment\n"));
5986 if (filedata
->file_header
.e_machine
!= EM_PARISC
)
5990 for (j
= 1; j
< filedata
->file_header
.e_phnum
; j
++)
5992 Elf_Internal_Phdr
*load
= filedata
->program_headers
+ j
;
5993 if (load
->p_type
== PT_LOAD
5994 && load
->p_offset
<= segment
->p_offset
5995 && (load
->p_offset
+ load
->p_filesz
5996 >= segment
->p_offset
+ segment
->p_filesz
)
5997 && load
->p_vaddr
<= segment
->p_vaddr
5998 && (load
->p_vaddr
+ load
->p_filesz
5999 >= segment
->p_vaddr
+ segment
->p_filesz
))
6002 if (j
== filedata
->file_header
.e_phnum
)
6003 error (_("the PHDR segment is not covered by a LOAD segment\n"));
6009 error (_("more than one dynamic segment\n"));
6011 /* By default, assume that the .dynamic section is the first
6012 section in the DYNAMIC segment. */
6013 dynamic_addr
= segment
->p_offset
;
6014 dynamic_size
= segment
->p_filesz
;
6016 /* Try to locate the .dynamic section. If there is
6017 a section header table, we can easily locate it. */
6018 if (filedata
->section_headers
!= NULL
)
6020 Elf_Internal_Shdr
* sec
;
6022 sec
= find_section (filedata
, ".dynamic");
6023 if (sec
== NULL
|| sec
->sh_size
== 0)
6025 /* A corresponding .dynamic section is expected, but on
6026 IA-64/OpenVMS it is OK for it to be missing. */
6027 if (!is_ia64_vms (filedata
))
6028 error (_("no .dynamic section in the dynamic segment\n"));
6032 if (sec
->sh_type
== SHT_NOBITS
)
6039 dynamic_addr
= sec
->sh_offset
;
6040 dynamic_size
= sec
->sh_size
;
6042 /* The PT_DYNAMIC segment, which is used by the run-time
6043 loader, should exactly match the .dynamic section. */
6045 && (dynamic_addr
!= segment
->p_offset
6046 || dynamic_size
!= segment
->p_filesz
))
6048 the .dynamic section is not the same as the dynamic segment\n"));
6051 /* PR binutils/17512: Avoid corrupt dynamic section info in the
6052 segment. Check this after matching against the section headers
6053 so we don't warn on debuginfo file (which have NOBITS .dynamic
6055 if (dynamic_addr
> filedata
->file_size
6056 || (dynamic_size
> filedata
->file_size
- dynamic_addr
))
6058 error (_("the dynamic segment offset + size exceeds the size of the file\n"));
6065 if (segment
->p_offset
>= filedata
->file_size
6066 || segment
->p_filesz
> filedata
->file_size
- segment
->p_offset
6067 || segment
->p_filesz
- 1 >= (size_t) -2
6068 || fseek (filedata
->handle
,
6069 filedata
->archive_file_offset
+ (long) segment
->p_offset
,
6071 error (_("Unable to find program interpreter name\n"));
6074 size_t len
= segment
->p_filesz
;
6075 free (filedata
->program_interpreter
);
6076 filedata
->program_interpreter
= xmalloc (len
+ 1);
6077 len
= fread (filedata
->program_interpreter
, 1, len
,
6079 filedata
->program_interpreter
[len
] = 0;
6082 printf (_(" [Requesting program interpreter: %s]\n"),
6083 filedata
->program_interpreter
);
6090 && filedata
->section_headers
!= NULL
6091 && filedata
->string_table
!= NULL
)
6093 printf (_("\n Section to Segment mapping:\n"));
6094 printf (_(" Segment Sections...\n"));
6096 for (i
= 0; i
< filedata
->file_header
.e_phnum
; i
++)
6099 Elf_Internal_Shdr
* section
;
6101 segment
= filedata
->program_headers
+ i
;
6102 section
= filedata
->section_headers
+ 1;
6104 printf (" %2.2d ", i
);
6106 for (j
= 1; j
< filedata
->file_header
.e_shnum
; j
++, section
++)
6108 if (!ELF_TBSS_SPECIAL (section
, segment
)
6109 && ELF_SECTION_IN_SEGMENT_STRICT (section
, segment
))
6110 printf ("%s ", printable_section_name (filedata
, section
));
6117 filedata
->dynamic_addr
= dynamic_addr
;
6118 filedata
->dynamic_size
= dynamic_size
? dynamic_size
: 1;
6122 filedata
->dynamic_addr
= 0;
6123 filedata
->dynamic_size
= 1;
6127 /* Find the file offset corresponding to VMA by using the program headers. */
6130 offset_from_vma (Filedata
* filedata
, bfd_vma vma
, bfd_size_type size
)
6132 Elf_Internal_Phdr
* seg
;
6134 if (! get_program_headers (filedata
))
6136 warn (_("Cannot interpret virtual addresses without program headers.\n"));
6140 for (seg
= filedata
->program_headers
;
6141 seg
< filedata
->program_headers
+ filedata
->file_header
.e_phnum
;
6144 if (seg
->p_type
!= PT_LOAD
)
6147 if (vma
>= (seg
->p_vaddr
& -seg
->p_align
)
6148 && vma
+ size
<= seg
->p_vaddr
+ seg
->p_filesz
)
6149 return vma
- seg
->p_vaddr
+ seg
->p_offset
;
6152 warn (_("Virtual address 0x%lx not located in any PT_LOAD segment.\n"),
6153 (unsigned long) vma
);
6158 /* Allocate memory and load the sections headers into FILEDATA->filedata->section_headers.
6159 If PROBE is true, this is just a probe and we do not generate any error
6160 messages if the load fails. */
6163 get_32bit_section_headers (Filedata
* filedata
, bool probe
)
6165 Elf32_External_Shdr
* shdrs
;
6166 Elf_Internal_Shdr
* internal
;
6168 unsigned int size
= filedata
->file_header
.e_shentsize
;
6169 unsigned int num
= probe
? 1 : filedata
->file_header
.e_shnum
;
6171 /* PR binutils/17531: Cope with unexpected section header sizes. */
6172 if (size
== 0 || num
== 0)
6174 if (size
< sizeof * shdrs
)
6177 error (_("The e_shentsize field in the ELF header is less than the size of an ELF section header\n"));
6180 if (!probe
&& size
> sizeof * shdrs
)
6181 warn (_("The e_shentsize field in the ELF header is larger than the size of an ELF section header\n"));
6183 shdrs
= (Elf32_External_Shdr
*) get_data (NULL
, filedata
, filedata
->file_header
.e_shoff
,
6185 probe
? NULL
: _("section headers"));
6189 filedata
->section_headers
= (Elf_Internal_Shdr
*)
6190 cmalloc (num
, sizeof (Elf_Internal_Shdr
));
6191 if (filedata
->section_headers
== NULL
)
6194 error (_("Out of memory reading %u section headers\n"), num
);
6199 for (i
= 0, internal
= filedata
->section_headers
;
6203 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
6204 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
6205 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
6206 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
6207 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
6208 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
6209 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
6210 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
6211 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
6212 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
6213 if (!probe
&& internal
->sh_link
> num
)
6214 warn (_("Section %u has an out of range sh_link value of %u\n"), i
, internal
->sh_link
);
6215 if (!probe
&& internal
->sh_flags
& SHF_INFO_LINK
&& internal
->sh_info
> num
)
6216 warn (_("Section %u has an out of range sh_info value of %u\n"), i
, internal
->sh_info
);
6223 /* Like get_32bit_section_headers, except that it fetches 64-bit headers. */
6226 get_64bit_section_headers (Filedata
* filedata
, bool probe
)
6228 Elf64_External_Shdr
* shdrs
;
6229 Elf_Internal_Shdr
* internal
;
6231 unsigned int size
= filedata
->file_header
.e_shentsize
;
6232 unsigned int num
= probe
? 1 : filedata
->file_header
.e_shnum
;
6234 /* PR binutils/17531: Cope with unexpected section header sizes. */
6235 if (size
== 0 || num
== 0)
6238 if (size
< sizeof * shdrs
)
6241 error (_("The e_shentsize field in the ELF header is less than the size of an ELF section header\n"));
6245 if (! probe
&& size
> sizeof * shdrs
)
6246 warn (_("The e_shentsize field in the ELF header is larger than the size of an ELF section header\n"));
6248 shdrs
= (Elf64_External_Shdr
*) get_data (NULL
, filedata
,
6249 filedata
->file_header
.e_shoff
,
6251 probe
? NULL
: _("section headers"));
6255 filedata
->section_headers
= (Elf_Internal_Shdr
*)
6256 cmalloc (num
, sizeof (Elf_Internal_Shdr
));
6257 if (filedata
->section_headers
== NULL
)
6260 error (_("Out of memory reading %u section headers\n"), num
);
6265 for (i
= 0, internal
= filedata
->section_headers
;
6269 internal
->sh_name
= BYTE_GET (shdrs
[i
].sh_name
);
6270 internal
->sh_type
= BYTE_GET (shdrs
[i
].sh_type
);
6271 internal
->sh_flags
= BYTE_GET (shdrs
[i
].sh_flags
);
6272 internal
->sh_addr
= BYTE_GET (shdrs
[i
].sh_addr
);
6273 internal
->sh_size
= BYTE_GET (shdrs
[i
].sh_size
);
6274 internal
->sh_entsize
= BYTE_GET (shdrs
[i
].sh_entsize
);
6275 internal
->sh_link
= BYTE_GET (shdrs
[i
].sh_link
);
6276 internal
->sh_info
= BYTE_GET (shdrs
[i
].sh_info
);
6277 internal
->sh_offset
= BYTE_GET (shdrs
[i
].sh_offset
);
6278 internal
->sh_addralign
= BYTE_GET (shdrs
[i
].sh_addralign
);
6279 if (!probe
&& internal
->sh_link
> num
)
6280 warn (_("Section %u has an out of range sh_link value of %u\n"), i
, internal
->sh_link
);
6281 if (!probe
&& internal
->sh_flags
& SHF_INFO_LINK
&& internal
->sh_info
> num
)
6282 warn (_("Section %u has an out of range sh_info value of %u\n"), i
, internal
->sh_info
);
6290 get_section_headers (Filedata
*filedata
, bool probe
)
6292 if (filedata
->section_headers
!= NULL
)
6296 return get_32bit_section_headers (filedata
, probe
);
6298 return get_64bit_section_headers (filedata
, probe
);
6301 static Elf_Internal_Sym
*
6302 get_32bit_elf_symbols (Filedata
* filedata
,
6303 Elf_Internal_Shdr
* section
,
6304 unsigned long * num_syms_return
)
6306 unsigned long number
= 0;
6307 Elf32_External_Sym
* esyms
= NULL
;
6308 Elf_External_Sym_Shndx
* shndx
= NULL
;
6309 Elf_Internal_Sym
* isyms
= NULL
;
6310 Elf_Internal_Sym
* psym
;
6312 elf_section_list
* entry
;
6314 if (section
->sh_size
== 0)
6316 if (num_syms_return
!= NULL
)
6317 * num_syms_return
= 0;
6321 /* Run some sanity checks first. */
6322 if (section
->sh_entsize
== 0 || section
->sh_entsize
> section
->sh_size
)
6324 error (_("Section %s has an invalid sh_entsize of 0x%lx\n"),
6325 printable_section_name (filedata
, section
),
6326 (unsigned long) section
->sh_entsize
);
6330 if (section
->sh_size
> filedata
->file_size
)
6332 error (_("Section %s has an invalid sh_size of 0x%lx\n"),
6333 printable_section_name (filedata
, section
),
6334 (unsigned long) section
->sh_size
);
6338 number
= section
->sh_size
/ section
->sh_entsize
;
6340 if (number
* sizeof (Elf32_External_Sym
) > section
->sh_size
+ 1)
6342 error (_("Size (0x%lx) of section %s is not a multiple of its sh_entsize (0x%lx)\n"),
6343 (unsigned long) section
->sh_size
,
6344 printable_section_name (filedata
, section
),
6345 (unsigned long) section
->sh_entsize
);
6349 esyms
= (Elf32_External_Sym
*) get_data (NULL
, filedata
, section
->sh_offset
, 1,
6350 section
->sh_size
, _("symbols"));
6355 for (entry
= filedata
->symtab_shndx_list
; entry
!= NULL
; entry
= entry
->next
)
6357 if (entry
->hdr
->sh_link
!= (unsigned long) (section
- filedata
->section_headers
))
6362 error (_("Multiple symbol table index sections associated with the same symbol section\n"));
6366 shndx
= (Elf_External_Sym_Shndx
*) get_data (NULL
, filedata
,
6367 entry
->hdr
->sh_offset
,
6368 1, entry
->hdr
->sh_size
,
6369 _("symbol table section indices"));
6373 /* PR17531: file: heap-buffer-overflow */
6374 if (entry
->hdr
->sh_size
/ sizeof (Elf_External_Sym_Shndx
) < number
)
6376 error (_("Index section %s has an sh_size of 0x%lx - expected 0x%lx\n"),
6377 printable_section_name (filedata
, entry
->hdr
),
6378 (unsigned long) entry
->hdr
->sh_size
,
6379 (unsigned long) section
->sh_size
);
6384 isyms
= (Elf_Internal_Sym
*) cmalloc (number
, sizeof (Elf_Internal_Sym
));
6388 error (_("Out of memory reading %lu symbols\n"),
6389 (unsigned long) number
);
6393 for (j
= 0, psym
= isyms
; j
< number
; j
++, psym
++)
6395 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
6396 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
6397 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
6398 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
6399 if (psym
->st_shndx
== (SHN_XINDEX
& 0xffff) && shndx
!= NULL
)
6401 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
6402 else if (psym
->st_shndx
>= (SHN_LORESERVE
& 0xffff))
6403 psym
->st_shndx
+= SHN_LORESERVE
- (SHN_LORESERVE
& 0xffff);
6404 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
6405 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
6412 if (num_syms_return
!= NULL
)
6413 * num_syms_return
= isyms
== NULL
? 0 : number
;
6418 static Elf_Internal_Sym
*
6419 get_64bit_elf_symbols (Filedata
* filedata
,
6420 Elf_Internal_Shdr
* section
,
6421 unsigned long * num_syms_return
)
6423 unsigned long number
= 0;
6424 Elf64_External_Sym
* esyms
= NULL
;
6425 Elf_External_Sym_Shndx
* shndx
= NULL
;
6426 Elf_Internal_Sym
* isyms
= NULL
;
6427 Elf_Internal_Sym
* psym
;
6429 elf_section_list
* entry
;
6431 if (section
->sh_size
== 0)
6433 if (num_syms_return
!= NULL
)
6434 * num_syms_return
= 0;
6438 /* Run some sanity checks first. */
6439 if (section
->sh_entsize
== 0 || section
->sh_entsize
> section
->sh_size
)
6441 error (_("Section %s has an invalid sh_entsize of 0x%lx\n"),
6442 printable_section_name (filedata
, section
),
6443 (unsigned long) section
->sh_entsize
);
6447 if (section
->sh_size
> filedata
->file_size
)
6449 error (_("Section %s has an invalid sh_size of 0x%lx\n"),
6450 printable_section_name (filedata
, section
),
6451 (unsigned long) section
->sh_size
);
6455 number
= section
->sh_size
/ section
->sh_entsize
;
6457 if (number
* sizeof (Elf64_External_Sym
) > section
->sh_size
+ 1)
6459 error (_("Size (0x%lx) of section %s is not a multiple of its sh_entsize (0x%lx)\n"),
6460 (unsigned long) section
->sh_size
,
6461 printable_section_name (filedata
, section
),
6462 (unsigned long) section
->sh_entsize
);
6466 esyms
= (Elf64_External_Sym
*) get_data (NULL
, filedata
, section
->sh_offset
, 1,
6467 section
->sh_size
, _("symbols"));
6472 for (entry
= filedata
->symtab_shndx_list
; entry
!= NULL
; entry
= entry
->next
)
6474 if (entry
->hdr
->sh_link
!= (unsigned long) (section
- filedata
->section_headers
))
6479 error (_("Multiple symbol table index sections associated with the same symbol section\n"));
6483 shndx
= (Elf_External_Sym_Shndx
*) get_data (NULL
, filedata
,
6484 entry
->hdr
->sh_offset
,
6485 1, entry
->hdr
->sh_size
,
6486 _("symbol table section indices"));
6490 /* PR17531: file: heap-buffer-overflow */
6491 if (entry
->hdr
->sh_size
/ sizeof (Elf_External_Sym_Shndx
) < number
)
6493 error (_("Index section %s has an sh_size of 0x%lx - expected 0x%lx\n"),
6494 printable_section_name (filedata
, entry
->hdr
),
6495 (unsigned long) entry
->hdr
->sh_size
,
6496 (unsigned long) section
->sh_size
);
6501 isyms
= (Elf_Internal_Sym
*) cmalloc (number
, sizeof (Elf_Internal_Sym
));
6505 error (_("Out of memory reading %lu symbols\n"),
6506 (unsigned long) number
);
6510 for (j
= 0, psym
= isyms
; j
< number
; j
++, psym
++)
6512 psym
->st_name
= BYTE_GET (esyms
[j
].st_name
);
6513 psym
->st_info
= BYTE_GET (esyms
[j
].st_info
);
6514 psym
->st_other
= BYTE_GET (esyms
[j
].st_other
);
6515 psym
->st_shndx
= BYTE_GET (esyms
[j
].st_shndx
);
6517 if (psym
->st_shndx
== (SHN_XINDEX
& 0xffff) && shndx
!= NULL
)
6519 = byte_get ((unsigned char *) &shndx
[j
], sizeof (shndx
[j
]));
6520 else if (psym
->st_shndx
>= (SHN_LORESERVE
& 0xffff))
6521 psym
->st_shndx
+= SHN_LORESERVE
- (SHN_LORESERVE
& 0xffff);
6523 psym
->st_value
= BYTE_GET (esyms
[j
].st_value
);
6524 psym
->st_size
= BYTE_GET (esyms
[j
].st_size
);
6531 if (num_syms_return
!= NULL
)
6532 * num_syms_return
= isyms
== NULL
? 0 : number
;
6537 static Elf_Internal_Sym
*
6538 get_elf_symbols (Filedata
*filedata
,
6539 Elf_Internal_Shdr
*section
,
6540 unsigned long *num_syms_return
)
6543 return get_32bit_elf_symbols (filedata
, section
, num_syms_return
);
6545 return get_64bit_elf_symbols (filedata
, section
, num_syms_return
);
6549 get_elf_section_flags (Filedata
* filedata
, bfd_vma sh_flags
)
6551 static char buff
[1024];
6553 unsigned int field_size
= is_32bit_elf
? 8 : 16;
6555 unsigned int size
= sizeof (buff
) - (field_size
+ 4 + 1);
6556 bfd_vma os_flags
= 0;
6557 bfd_vma proc_flags
= 0;
6558 bfd_vma unknown_flags
= 0;
6566 /* 0 */ { STRING_COMMA_LEN ("WRITE") },
6567 /* 1 */ { STRING_COMMA_LEN ("ALLOC") },
6568 /* 2 */ { STRING_COMMA_LEN ("EXEC") },
6569 /* 3 */ { STRING_COMMA_LEN ("MERGE") },
6570 /* 4 */ { STRING_COMMA_LEN ("STRINGS") },
6571 /* 5 */ { STRING_COMMA_LEN ("INFO LINK") },
6572 /* 6 */ { STRING_COMMA_LEN ("LINK ORDER") },
6573 /* 7 */ { STRING_COMMA_LEN ("OS NONCONF") },
6574 /* 8 */ { STRING_COMMA_LEN ("GROUP") },
6575 /* 9 */ { STRING_COMMA_LEN ("TLS") },
6576 /* IA-64 specific. */
6577 /* 10 */ { STRING_COMMA_LEN ("SHORT") },
6578 /* 11 */ { STRING_COMMA_LEN ("NORECOV") },
6579 /* IA-64 OpenVMS specific. */
6580 /* 12 */ { STRING_COMMA_LEN ("VMS_GLOBAL") },
6581 /* 13 */ { STRING_COMMA_LEN ("VMS_OVERLAID") },
6582 /* 14 */ { STRING_COMMA_LEN ("VMS_SHARED") },
6583 /* 15 */ { STRING_COMMA_LEN ("VMS_VECTOR") },
6584 /* 16 */ { STRING_COMMA_LEN ("VMS_ALLOC_64BIT") },
6585 /* 17 */ { STRING_COMMA_LEN ("VMS_PROTECTED") },
6587 /* 18 */ { STRING_COMMA_LEN ("EXCLUDE") },
6588 /* SPARC specific. */
6589 /* 19 */ { STRING_COMMA_LEN ("ORDERED") },
6590 /* 20 */ { STRING_COMMA_LEN ("COMPRESSED") },
6592 /* 21 */ { STRING_COMMA_LEN ("ENTRYSECT") },
6593 /* 22 */ { STRING_COMMA_LEN ("ARM_PURECODE") },
6594 /* 23 */ { STRING_COMMA_LEN ("COMDEF") },
6596 /* 24 */ { STRING_COMMA_LEN ("GNU_MBIND") },
6598 /* 25 */ { STRING_COMMA_LEN ("VLE") },
6600 /* 26 */ { STRING_COMMA_LEN ("GNU_RETAIN") },
6603 if (do_section_details
)
6605 sprintf (buff
, "[%*.*lx]: ",
6606 field_size
, field_size
, (unsigned long) sh_flags
);
6607 p
+= field_size
+ 4;
6614 flag
= sh_flags
& - sh_flags
;
6617 if (do_section_details
)
6621 case SHF_WRITE
: sindex
= 0; break;
6622 case SHF_ALLOC
: sindex
= 1; break;
6623 case SHF_EXECINSTR
: sindex
= 2; break;
6624 case SHF_MERGE
: sindex
= 3; break;
6625 case SHF_STRINGS
: sindex
= 4; break;
6626 case SHF_INFO_LINK
: sindex
= 5; break;
6627 case SHF_LINK_ORDER
: sindex
= 6; break;
6628 case SHF_OS_NONCONFORMING
: sindex
= 7; break;
6629 case SHF_GROUP
: sindex
= 8; break;
6630 case SHF_TLS
: sindex
= 9; break;
6631 case SHF_EXCLUDE
: sindex
= 18; break;
6632 case SHF_COMPRESSED
: sindex
= 20; break;
6636 switch (filedata
->file_header
.e_machine
)
6639 if (flag
== SHF_IA_64_SHORT
)
6641 else if (flag
== SHF_IA_64_NORECOV
)
6644 else if (filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_OPENVMS
)
6647 case SHF_IA_64_VMS_GLOBAL
: sindex
= 12; break;
6648 case SHF_IA_64_VMS_OVERLAID
: sindex
= 13; break;
6649 case SHF_IA_64_VMS_SHARED
: sindex
= 14; break;
6650 case SHF_IA_64_VMS_VECTOR
: sindex
= 15; break;
6651 case SHF_IA_64_VMS_ALLOC_64BIT
: sindex
= 16; break;
6652 case SHF_IA_64_VMS_PROTECTED
: sindex
= 17; break;
6663 case EM_OLD_SPARCV9
:
6664 case EM_SPARC32PLUS
:
6667 if (flag
== SHF_ORDERED
)
6674 case SHF_ENTRYSECT
: sindex
= 21; break;
6675 case SHF_ARM_PURECODE
: sindex
= 22; break;
6676 case SHF_COMDEF
: sindex
= 23; break;
6681 if (flag
== SHF_PPC_VLE
)
6688 switch (filedata
->file_header
.e_ident
[EI_OSABI
])
6691 case ELFOSABI_FREEBSD
:
6692 if (flag
== SHF_GNU_RETAIN
)
6696 if (flag
== SHF_GNU_MBIND
)
6697 /* We should not recognize SHF_GNU_MBIND for
6698 ELFOSABI_NONE, but binutils as of 2019-07-23 did
6699 not set the EI_OSABI header byte. */
6710 if (p
!= buff
+ field_size
+ 4)
6712 if (size
< (10 + 2))
6714 warn (_("Internal error: not enough buffer room for section flag info"));
6715 return _("<unknown>");
6722 size
-= flags
[sindex
].len
;
6723 p
= stpcpy (p
, flags
[sindex
].str
);
6725 else if (flag
& SHF_MASKOS
)
6727 else if (flag
& SHF_MASKPROC
)
6730 unknown_flags
|= flag
;
6736 case SHF_WRITE
: *p
= 'W'; break;
6737 case SHF_ALLOC
: *p
= 'A'; break;
6738 case SHF_EXECINSTR
: *p
= 'X'; break;
6739 case SHF_MERGE
: *p
= 'M'; break;
6740 case SHF_STRINGS
: *p
= 'S'; break;
6741 case SHF_INFO_LINK
: *p
= 'I'; break;
6742 case SHF_LINK_ORDER
: *p
= 'L'; break;
6743 case SHF_OS_NONCONFORMING
: *p
= 'O'; break;
6744 case SHF_GROUP
: *p
= 'G'; break;
6745 case SHF_TLS
: *p
= 'T'; break;
6746 case SHF_EXCLUDE
: *p
= 'E'; break;
6747 case SHF_COMPRESSED
: *p
= 'C'; break;
6750 if ((filedata
->file_header
.e_machine
== EM_X86_64
6751 || filedata
->file_header
.e_machine
== EM_L1OM
6752 || filedata
->file_header
.e_machine
== EM_K1OM
)
6753 && flag
== SHF_X86_64_LARGE
)
6755 else if (filedata
->file_header
.e_machine
== EM_ARM
6756 && flag
== SHF_ARM_PURECODE
)
6758 else if (filedata
->file_header
.e_machine
== EM_PPC
6759 && flag
== SHF_PPC_VLE
)
6761 else if (flag
& SHF_MASKOS
)
6763 switch (filedata
->file_header
.e_ident
[EI_OSABI
])
6766 case ELFOSABI_FREEBSD
:
6767 if (flag
== SHF_GNU_RETAIN
)
6774 if (flag
== SHF_GNU_MBIND
)
6776 /* We should not recognize SHF_GNU_MBIND for
6777 ELFOSABI_NONE, but binutils as of 2019-07-23 did
6778 not set the EI_OSABI header byte. */
6785 sh_flags
&= ~SHF_MASKOS
;
6789 else if (flag
& SHF_MASKPROC
)
6792 sh_flags
&= ~ SHF_MASKPROC
;
6802 if (do_section_details
)
6806 size
-= 5 + field_size
;
6807 if (p
!= buff
+ field_size
+ 4)
6811 warn (_("Internal error: not enough buffer room for section flag info"));
6812 return _("<unknown>");
6818 sprintf (p
, "OS (%*.*lx)", field_size
, field_size
,
6819 (unsigned long) os_flags
);
6820 p
+= 5 + field_size
;
6824 size
-= 7 + field_size
;
6825 if (p
!= buff
+ field_size
+ 4)
6829 warn (_("Internal error: not enough buffer room for section flag info"));
6830 return _("<unknown>");
6836 sprintf (p
, "PROC (%*.*lx)", field_size
, field_size
,
6837 (unsigned long) proc_flags
);
6838 p
+= 7 + field_size
;
6842 size
-= 10 + field_size
;
6843 if (p
!= buff
+ field_size
+ 4)
6847 warn (_("Internal error: not enough buffer room for section flag info"));
6848 return _("<unknown>");
6854 sprintf (p
, _("UNKNOWN (%*.*lx)"), field_size
, field_size
,
6855 (unsigned long) unknown_flags
);
6856 p
+= 10 + field_size
;
6864 static unsigned int ATTRIBUTE_WARN_UNUSED_RESULT
6865 get_compression_header (Elf_Internal_Chdr
*chdr
, unsigned char *buf
, bfd_size_type size
)
6869 Elf32_External_Chdr
*echdr
= (Elf32_External_Chdr
*) buf
;
6871 if (size
< sizeof (* echdr
))
6873 error (_("Compressed section is too small even for a compression header\n"));
6877 chdr
->ch_type
= BYTE_GET (echdr
->ch_type
);
6878 chdr
->ch_size
= BYTE_GET (echdr
->ch_size
);
6879 chdr
->ch_addralign
= BYTE_GET (echdr
->ch_addralign
);
6880 return sizeof (*echdr
);
6884 Elf64_External_Chdr
*echdr
= (Elf64_External_Chdr
*) buf
;
6886 if (size
< sizeof (* echdr
))
6888 error (_("Compressed section is too small even for a compression header\n"));
6892 chdr
->ch_type
= BYTE_GET (echdr
->ch_type
);
6893 chdr
->ch_size
= BYTE_GET (echdr
->ch_size
);
6894 chdr
->ch_addralign
= BYTE_GET (echdr
->ch_addralign
);
6895 return sizeof (*echdr
);
6900 process_section_headers (Filedata
* filedata
)
6902 Elf_Internal_Shdr
* section
;
6905 if (filedata
->file_header
.e_shnum
== 0)
6907 /* PR binutils/12467. */
6908 if (filedata
->file_header
.e_shoff
!= 0)
6910 warn (_("possibly corrupt ELF file header - it has a non-zero"
6911 " section header offset, but no section headers\n"));
6914 else if (do_sections
)
6915 printf (_("\nThere are no sections in this file.\n"));
6920 if (do_sections
&& !do_header
)
6922 if (filedata
->is_separate
&& process_links
)
6923 printf (_("In linked file '%s': "), filedata
->file_name
);
6924 if (! filedata
->is_separate
|| process_links
)
6925 printf (ngettext ("There is %d section header, "
6926 "starting at offset 0x%lx:\n",
6927 "There are %d section headers, "
6928 "starting at offset 0x%lx:\n",
6929 filedata
->file_header
.e_shnum
),
6930 filedata
->file_header
.e_shnum
,
6931 (unsigned long) filedata
->file_header
.e_shoff
);
6934 if (!get_section_headers (filedata
, false))
6937 /* Read in the string table, so that we have names to display. */
6938 if (filedata
->file_header
.e_shstrndx
!= SHN_UNDEF
6939 && filedata
->file_header
.e_shstrndx
< filedata
->file_header
.e_shnum
)
6941 section
= filedata
->section_headers
+ filedata
->file_header
.e_shstrndx
;
6943 if (section
->sh_size
!= 0)
6945 filedata
->string_table
= (char *) get_data (NULL
, filedata
, section
->sh_offset
,
6946 1, section
->sh_size
,
6949 filedata
->string_table_length
= filedata
->string_table
!= NULL
? section
->sh_size
: 0;
6953 /* Scan the sections for the dynamic symbol table
6954 and dynamic string table and debug sections. */
6955 eh_addr_size
= is_32bit_elf
? 4 : 8;
6956 switch (filedata
->file_header
.e_machine
)
6959 case EM_MIPS_RS3_LE
:
6960 /* The 64-bit MIPS EABI uses a combination of 32-bit ELF and 64-bit
6961 FDE addresses. However, the ABI also has a semi-official ILP32
6962 variant for which the normal FDE address size rules apply.
6964 GCC 4.0 marks EABI64 objects with a dummy .gcc_compiled_longXX
6965 section, where XX is the size of longs in bits. Unfortunately,
6966 earlier compilers provided no way of distinguishing ILP32 objects
6967 from LP64 objects, so if there's any doubt, we should assume that
6968 the official LP64 form is being used. */
6969 if ((filedata
->file_header
.e_flags
& EF_MIPS_ABI
) == E_MIPS_ABI_EABI64
6970 && find_section (filedata
, ".gcc_compiled_long32") == NULL
)
6976 switch (filedata
->file_header
.e_flags
& EF_H8_MACH
)
6978 case E_H8_MACH_H8300
:
6979 case E_H8_MACH_H8300HN
:
6980 case E_H8_MACH_H8300SN
:
6981 case E_H8_MACH_H8300SXN
:
6984 case E_H8_MACH_H8300H
:
6985 case E_H8_MACH_H8300S
:
6986 case E_H8_MACH_H8300SX
:
6994 switch (filedata
->file_header
.e_flags
& EF_M32C_CPU_MASK
)
6996 case EF_M32C_CPU_M16C
:
7003 #define CHECK_ENTSIZE_VALUES(section, i, size32, size64) \
7006 bfd_size_type expected_entsize = is_32bit_elf ? size32 : size64; \
7007 if (section->sh_entsize != expected_entsize) \
7010 sprintf_vma (buf, section->sh_entsize); \
7011 /* Note: coded this way so that there is a single string for \
7013 error (_("Section %d has invalid sh_entsize of %s\n"), i, buf); \
7014 error (_("(Using the expected size of %u for the rest of this dump)\n"), \
7015 (unsigned) expected_entsize); \
7016 section->sh_entsize = expected_entsize; \
7021 #define CHECK_ENTSIZE(section, i, type) \
7022 CHECK_ENTSIZE_VALUES (section, i, sizeof (Elf32_External_##type), \
7023 sizeof (Elf64_External_##type))
7025 for (i
= 0, section
= filedata
->section_headers
;
7026 i
< filedata
->file_header
.e_shnum
;
7029 const char *name
= section_name_print (filedata
, section
);
7031 /* Run some sanity checks on the headers and
7032 possibly fill in some file data as well. */
7033 switch (section
->sh_type
)
7036 if (filedata
->dynamic_symbols
!= NULL
)
7038 error (_("File contains multiple dynamic symbol tables\n"));
7042 CHECK_ENTSIZE (section
, i
, Sym
);
7043 filedata
->dynamic_symbols
7044 = get_elf_symbols (filedata
, section
, &filedata
->num_dynamic_syms
);
7045 filedata
->dynamic_symtab_section
= section
;
7049 if (streq (name
, ".dynstr"))
7051 if (filedata
->dynamic_strings
!= NULL
)
7053 error (_("File contains multiple dynamic string tables\n"));
7057 filedata
->dynamic_strings
7058 = (char *) get_data (NULL
, filedata
, section
->sh_offset
,
7059 1, section
->sh_size
, _("dynamic strings"));
7060 filedata
->dynamic_strings_length
7061 = filedata
->dynamic_strings
== NULL
? 0 : section
->sh_size
;
7062 filedata
->dynamic_strtab_section
= section
;
7066 case SHT_SYMTAB_SHNDX
:
7068 elf_section_list
* entry
= xmalloc (sizeof * entry
);
7070 entry
->hdr
= section
;
7071 entry
->next
= filedata
->symtab_shndx_list
;
7072 filedata
->symtab_shndx_list
= entry
;
7077 CHECK_ENTSIZE (section
, i
, Sym
);
7081 CHECK_ENTSIZE_VALUES (section
, i
, GRP_ENTRY_SIZE
, GRP_ENTRY_SIZE
);
7085 CHECK_ENTSIZE (section
, i
, Rel
);
7086 if (do_checks
&& section
->sh_size
== 0)
7087 warn (_("Section '%s': zero-sized relocation section\n"), name
);
7091 CHECK_ENTSIZE (section
, i
, Rela
);
7092 if (do_checks
&& section
->sh_size
== 0)
7093 warn (_("Section '%s': zero-sized relocation section\n"), name
);
7097 CHECK_ENTSIZE (section
, i
, Relr
);
7102 /* Having a zero sized section is not illegal according to the
7103 ELF standard, but it might be an indication that something
7104 is wrong. So issue a warning if we are running in lint mode. */
7105 if (do_checks
&& section
->sh_size
== 0)
7106 warn (_("Section '%s': has a size of zero - is this intended ?\n"), name
);
7113 if ((do_debugging
|| do_debug_info
|| do_debug_abbrevs
7114 || do_debug_lines
|| do_debug_pubnames
|| do_debug_pubtypes
7115 || do_debug_aranges
|| do_debug_frames
|| do_debug_macinfo
7116 || do_debug_str
|| do_debug_str_offsets
|| do_debug_loc
7118 || do_debug_addr
|| do_debug_cu_index
|| do_debug_links
)
7119 && (startswith (name
, ".debug_")
7120 || startswith (name
, ".zdebug_")))
7123 name
+= sizeof (".zdebug_") - 1;
7125 name
+= sizeof (".debug_") - 1;
7128 || (do_debug_info
&& startswith (name
, "info"))
7129 || (do_debug_info
&& startswith (name
, "types"))
7130 || (do_debug_abbrevs
&& startswith (name
, "abbrev"))
7131 || (do_debug_lines
&& strcmp (name
, "line") == 0)
7132 || (do_debug_lines
&& startswith (name
, "line."))
7133 || (do_debug_pubnames
&& startswith (name
, "pubnames"))
7134 || (do_debug_pubtypes
&& startswith (name
, "pubtypes"))
7135 || (do_debug_pubnames
&& startswith (name
, "gnu_pubnames"))
7136 || (do_debug_pubtypes
&& startswith (name
, "gnu_pubtypes"))
7137 || (do_debug_aranges
&& startswith (name
, "aranges"))
7138 || (do_debug_ranges
&& startswith (name
, "ranges"))
7139 || (do_debug_ranges
&& startswith (name
, "rnglists"))
7140 || (do_debug_frames
&& startswith (name
, "frame"))
7141 || (do_debug_macinfo
&& startswith (name
, "macinfo"))
7142 || (do_debug_macinfo
&& startswith (name
, "macro"))
7143 || (do_debug_str
&& startswith (name
, "str"))
7144 || (do_debug_links
&& startswith (name
, "sup"))
7145 || (do_debug_str_offsets
&& startswith (name
, "str_offsets"))
7146 || (do_debug_loc
&& startswith (name
, "loc"))
7147 || (do_debug_loc
&& startswith (name
, "loclists"))
7148 || (do_debug_addr
&& startswith (name
, "addr"))
7149 || (do_debug_cu_index
&& startswith (name
, "cu_index"))
7150 || (do_debug_cu_index
&& startswith (name
, "tu_index"))
7152 request_dump_bynumber (&filedata
->dump
, i
, DEBUG_DUMP
);
7154 /* Linkonce section to be combined with .debug_info at link time. */
7155 else if ((do_debugging
|| do_debug_info
)
7156 && startswith (name
, ".gnu.linkonce.wi."))
7157 request_dump_bynumber (&filedata
->dump
, i
, DEBUG_DUMP
);
7158 else if (do_debug_frames
&& streq (name
, ".eh_frame"))
7159 request_dump_bynumber (&filedata
->dump
, i
, DEBUG_DUMP
);
7160 else if (do_gdb_index
&& (streq (name
, ".gdb_index")
7161 || streq (name
, ".debug_names")))
7162 request_dump_bynumber (&filedata
->dump
, i
, DEBUG_DUMP
);
7163 /* Trace sections for Itanium VMS. */
7164 else if ((do_debugging
|| do_trace_info
|| do_trace_abbrevs
7165 || do_trace_aranges
)
7166 && startswith (name
, ".trace_"))
7168 name
+= sizeof (".trace_") - 1;
7171 || (do_trace_info
&& streq (name
, "info"))
7172 || (do_trace_abbrevs
&& streq (name
, "abbrev"))
7173 || (do_trace_aranges
&& streq (name
, "aranges"))
7175 request_dump_bynumber (&filedata
->dump
, i
, DEBUG_DUMP
);
7177 else if ((do_debugging
|| do_debug_links
)
7178 && (startswith (name
, ".gnu_debuglink")
7179 || startswith (name
, ".gnu_debugaltlink")))
7180 request_dump_bynumber (&filedata
->dump
, i
, DEBUG_DUMP
);
7186 if (filedata
->is_separate
&& ! process_links
)
7189 if (filedata
->is_separate
)
7190 printf (_("\nSection Headers in linked file '%s':\n"), filedata
->file_name
);
7191 else if (filedata
->file_header
.e_shnum
> 1)
7192 printf (_("\nSection Headers:\n"));
7194 printf (_("\nSection Header:\n"));
7198 if (do_section_details
)
7200 printf (_(" [Nr] Name\n"));
7201 printf (_(" Type Addr Off Size ES Lk Inf Al\n"));
7205 (_(" [Nr] Name Type Addr Off Size ES Flg Lk Inf Al\n"));
7209 if (do_section_details
)
7211 printf (_(" [Nr] Name\n"));
7212 printf (_(" Type Address Off Size ES Lk Inf Al\n"));
7216 (_(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al\n"));
7220 if (do_section_details
)
7222 printf (_(" [Nr] Name\n"));
7223 printf (_(" Type Address Offset Link\n"));
7224 printf (_(" Size EntSize Info Align\n"));
7228 printf (_(" [Nr] Name Type Address Offset\n"));
7229 printf (_(" Size EntSize Flags Link Info Align\n"));
7233 if (do_section_details
)
7234 printf (_(" Flags\n"));
7236 for (i
= 0, section
= filedata
->section_headers
;
7237 i
< filedata
->file_header
.e_shnum
;
7240 /* Run some sanity checks on the section header. */
7242 /* Check the sh_link field. */
7243 switch (section
->sh_type
)
7247 if (section
->sh_link
== 0
7248 && (filedata
->file_header
.e_type
== ET_EXEC
7249 || filedata
->file_header
.e_type
== ET_DYN
))
7250 /* A dynamic relocation section where all entries use a
7251 zero symbol index need not specify a symtab section. */
7254 case SHT_SYMTAB_SHNDX
:
7258 case SHT_GNU_versym
:
7259 if (section
->sh_link
== 0
7260 || section
->sh_link
>= filedata
->file_header
.e_shnum
7261 || (filedata
->section_headers
[section
->sh_link
].sh_type
!= SHT_SYMTAB
7262 && filedata
->section_headers
[section
->sh_link
].sh_type
!= SHT_DYNSYM
))
7263 warn (_("[%2u]: Link field (%u) should index a symtab section.\n"),
7264 i
, section
->sh_link
);
7270 case SHT_GNU_verneed
:
7271 case SHT_GNU_verdef
:
7272 case SHT_GNU_LIBLIST
:
7273 if (section
->sh_link
== 0
7274 || section
->sh_link
>= filedata
->file_header
.e_shnum
7275 || filedata
->section_headers
[section
->sh_link
].sh_type
!= SHT_STRTAB
)
7276 warn (_("[%2u]: Link field (%u) should index a string section.\n"),
7277 i
, section
->sh_link
);
7280 case SHT_INIT_ARRAY
:
7281 case SHT_FINI_ARRAY
:
7282 case SHT_PREINIT_ARRAY
:
7283 if (section
->sh_type
< SHT_LOOS
&& section
->sh_link
!= 0)
7284 warn (_("[%2u]: Unexpected value (%u) in link field.\n"),
7285 i
, section
->sh_link
);
7289 /* FIXME: Add support for target specific section types. */
7290 #if 0 /* Currently we do not check other section types as there are too
7291 many special cases. Stab sections for example have a type
7292 of SHT_PROGBITS but an sh_link field that links to the .stabstr
7294 if (section
->sh_type
< SHT_LOOS
&& section
->sh_link
!= 0)
7295 warn (_("[%2u]: Unexpected value (%u) in link field.\n"),
7296 i
, section
->sh_link
);
7301 /* Check the sh_info field. */
7302 switch (section
->sh_type
)
7306 if (section
->sh_info
== 0
7307 && (filedata
->file_header
.e_type
== ET_EXEC
7308 || filedata
->file_header
.e_type
== ET_DYN
))
7309 /* Dynamic relocations apply to segments, so they do not
7310 need to specify the section they relocate. */
7312 if (section
->sh_info
== 0
7313 || section
->sh_info
>= filedata
->file_header
.e_shnum
7314 || (filedata
->section_headers
[section
->sh_info
].sh_type
!= SHT_PROGBITS
7315 && filedata
->section_headers
[section
->sh_info
].sh_type
!= SHT_NOBITS
7316 && filedata
->section_headers
[section
->sh_info
].sh_type
!= SHT_NOTE
7317 && filedata
->section_headers
[section
->sh_info
].sh_type
!= SHT_INIT_ARRAY
7318 && filedata
->section_headers
[section
->sh_info
].sh_type
!= SHT_FINI_ARRAY
7319 && filedata
->section_headers
[section
->sh_info
].sh_type
!= SHT_PREINIT_ARRAY
7320 /* FIXME: Are other section types valid ? */
7321 && filedata
->section_headers
[section
->sh_info
].sh_type
< SHT_LOOS
))
7322 warn (_("[%2u]: Info field (%u) should index a relocatable section.\n"),
7323 i
, section
->sh_info
);
7328 case SHT_SYMTAB_SHNDX
:
7329 case SHT_INIT_ARRAY
:
7330 case SHT_FINI_ARRAY
:
7331 case SHT_PREINIT_ARRAY
:
7332 if (section
->sh_info
!= 0)
7333 warn (_("[%2u]: Unexpected value (%u) in info field.\n"),
7334 i
, section
->sh_info
);
7340 /* A symbol index - we assume that it is valid. */
7344 /* FIXME: Add support for target specific section types. */
7345 if (section
->sh_type
== SHT_NOBITS
)
7346 /* NOBITS section headers with non-zero sh_info fields can be
7347 created when a binary is stripped of everything but its debug
7348 information. The stripped sections have their headers
7349 preserved but their types set to SHT_NOBITS. So do not check
7350 this type of section. */
7352 else if (section
->sh_flags
& SHF_INFO_LINK
)
7354 if (section
->sh_info
< 1 || section
->sh_info
>= filedata
->file_header
.e_shnum
)
7355 warn (_("[%2u]: Expected link to another section in info field"), i
);
7357 else if (section
->sh_type
< SHT_LOOS
7358 && (section
->sh_flags
& SHF_GNU_MBIND
) == 0
7359 && section
->sh_info
!= 0)
7360 warn (_("[%2u]: Unexpected value (%u) in info field.\n"),
7361 i
, section
->sh_info
);
7365 /* Check the sh_size field. */
7366 if (section
->sh_size
> filedata
->file_size
7367 && section
->sh_type
!= SHT_NOBITS
7368 && section
->sh_type
!= SHT_NULL
7369 && section
->sh_type
< SHT_LOOS
)
7370 warn (_("Size of section %u is larger than the entire file!\n"), i
);
7372 printf (" [%2u] ", i
);
7373 if (do_section_details
)
7374 printf ("%s\n ", printable_section_name (filedata
, section
));
7376 print_symbol (-17, section_name_print (filedata
, section
));
7378 printf (do_wide
? " %-15s " : " %-15.15s ",
7379 get_section_type_name (filedata
, section
->sh_type
));
7383 const char * link_too_big
= NULL
;
7385 print_vma (section
->sh_addr
, LONG_HEX
);
7387 printf ( " %6.6lx %6.6lx %2.2lx",
7388 (unsigned long) section
->sh_offset
,
7389 (unsigned long) section
->sh_size
,
7390 (unsigned long) section
->sh_entsize
);
7392 if (do_section_details
)
7393 fputs (" ", stdout
);
7395 printf (" %3s ", get_elf_section_flags (filedata
, section
->sh_flags
));
7397 if (section
->sh_link
>= filedata
->file_header
.e_shnum
)
7400 /* The sh_link value is out of range. Normally this indicates
7401 an error but it can have special values in Solaris binaries. */
7402 switch (filedata
->file_header
.e_machine
)
7409 case EM_OLD_SPARCV9
:
7410 case EM_SPARC32PLUS
:
7413 if (section
->sh_link
== (SHN_BEFORE
& 0xffff))
7414 link_too_big
= "BEFORE";
7415 else if (section
->sh_link
== (SHN_AFTER
& 0xffff))
7416 link_too_big
= "AFTER";
7423 if (do_section_details
)
7425 if (link_too_big
!= NULL
&& * link_too_big
)
7426 printf ("<%s> ", link_too_big
);
7428 printf ("%2u ", section
->sh_link
);
7429 printf ("%3u %2lu\n", section
->sh_info
,
7430 (unsigned long) section
->sh_addralign
);
7433 printf ("%2u %3u %2lu\n",
7436 (unsigned long) section
->sh_addralign
);
7438 if (link_too_big
&& ! * link_too_big
)
7439 warn (_("section %u: sh_link value of %u is larger than the number of sections\n"),
7440 i
, section
->sh_link
);
7444 print_vma (section
->sh_addr
, LONG_HEX
);
7446 if ((long) section
->sh_offset
== section
->sh_offset
)
7447 printf (" %6.6lx", (unsigned long) section
->sh_offset
);
7451 print_vma (section
->sh_offset
, LONG_HEX
);
7454 if ((unsigned long) section
->sh_size
== section
->sh_size
)
7455 printf (" %6.6lx", (unsigned long) section
->sh_size
);
7459 print_vma (section
->sh_size
, LONG_HEX
);
7462 if ((unsigned long) section
->sh_entsize
== section
->sh_entsize
)
7463 printf (" %2.2lx", (unsigned long) section
->sh_entsize
);
7467 print_vma (section
->sh_entsize
, LONG_HEX
);
7470 if (do_section_details
)
7471 fputs (" ", stdout
);
7473 printf (" %3s ", get_elf_section_flags (filedata
, section
->sh_flags
));
7475 printf ("%2u %3u ", section
->sh_link
, section
->sh_info
);
7477 if ((unsigned long) section
->sh_addralign
== section
->sh_addralign
)
7478 printf ("%2lu\n", (unsigned long) section
->sh_addralign
);
7481 print_vma (section
->sh_addralign
, DEC
);
7485 else if (do_section_details
)
7488 print_vma (section
->sh_addr
, LONG_HEX
);
7489 if ((long) section
->sh_offset
== section
->sh_offset
)
7490 printf (" %16.16lx", (unsigned long) section
->sh_offset
);
7494 print_vma (section
->sh_offset
, LONG_HEX
);
7496 printf (" %u\n ", section
->sh_link
);
7497 print_vma (section
->sh_size
, LONG_HEX
);
7499 print_vma (section
->sh_entsize
, LONG_HEX
);
7501 printf (" %-16u %lu\n",
7503 (unsigned long) section
->sh_addralign
);
7508 print_vma (section
->sh_addr
, LONG_HEX
);
7509 if ((long) section
->sh_offset
== section
->sh_offset
)
7510 printf (" %8.8lx", (unsigned long) section
->sh_offset
);
7514 print_vma (section
->sh_offset
, LONG_HEX
);
7517 print_vma (section
->sh_size
, LONG_HEX
);
7519 print_vma (section
->sh_entsize
, LONG_HEX
);
7521 printf (" %3s ", get_elf_section_flags (filedata
, section
->sh_flags
));
7523 printf (" %2u %3u %lu\n",
7526 (unsigned long) section
->sh_addralign
);
7529 if (do_section_details
)
7531 printf (" %s\n", get_elf_section_flags (filedata
, section
->sh_flags
));
7532 if ((section
->sh_flags
& SHF_COMPRESSED
) != 0)
7534 /* Minimum section size is 12 bytes for 32-bit compression
7535 header + 12 bytes for compressed data header. */
7536 unsigned char buf
[24];
7538 assert (sizeof (buf
) >= sizeof (Elf64_External_Chdr
));
7539 if (get_data (&buf
, filedata
, section
->sh_offset
, 1,
7540 sizeof (buf
), _("compression header")))
7542 Elf_Internal_Chdr chdr
;
7544 if (get_compression_header (&chdr
, buf
, sizeof (buf
)) == 0)
7545 printf (_(" [<corrupt>]\n"));
7548 if (chdr
.ch_type
== ELFCOMPRESS_ZLIB
)
7551 printf (_(" [<unknown>: 0x%x], "),
7553 print_vma (chdr
.ch_size
, LONG_HEX
);
7554 printf (", %lu\n", (unsigned long) chdr
.ch_addralign
);
7561 if (!do_section_details
)
7563 /* The ordering of the letters shown here matches the ordering of the
7564 corresponding SHF_xxx values, and hence the order in which these
7565 letters will be displayed to the user. */
7566 printf (_("Key to Flags:\n\
7567 W (write), A (alloc), X (execute), M (merge), S (strings), I (info),\n\
7568 L (link order), O (extra OS processing required), G (group), T (TLS),\n\
7569 C (compressed), x (unknown), o (OS specific), E (exclude),\n "));
7570 switch (filedata
->file_header
.e_ident
[EI_OSABI
])
7573 case ELFOSABI_FREEBSD
:
7574 printf (_("R (retain), "));
7577 printf (_("D (mbind), "));
7582 if (filedata
->file_header
.e_machine
== EM_X86_64
7583 || filedata
->file_header
.e_machine
== EM_L1OM
7584 || filedata
->file_header
.e_machine
== EM_K1OM
)
7585 printf (_("l (large), "));
7586 else if (filedata
->file_header
.e_machine
== EM_ARM
)
7587 printf (_("y (purecode), "));
7588 else if (filedata
->file_header
.e_machine
== EM_PPC
)
7589 printf (_("v (VLE), "));
7590 printf ("p (processor specific)\n");
7597 get_symtab (Filedata
*filedata
, Elf_Internal_Shdr
*symsec
,
7598 Elf_Internal_Sym
**symtab
, unsigned long *nsyms
,
7599 char **strtab
, unsigned long *strtablen
)
7603 *symtab
= get_elf_symbols (filedata
, symsec
, nsyms
);
7605 if (*symtab
== NULL
)
7608 if (symsec
->sh_link
!= 0)
7610 Elf_Internal_Shdr
*strsec
;
7612 if (symsec
->sh_link
>= filedata
->file_header
.e_shnum
)
7614 error (_("Bad sh_link in symbol table section\n"));
7621 strsec
= filedata
->section_headers
+ symsec
->sh_link
;
7623 *strtab
= (char *) get_data (NULL
, filedata
, strsec
->sh_offset
,
7624 1, strsec
->sh_size
, _("string table"));
7625 if (*strtab
== NULL
)
7632 *strtablen
= strsec
->sh_size
;
7638 get_group_flags (unsigned int flags
)
7640 static char buff
[128];
7644 else if (flags
== GRP_COMDAT
)
7647 snprintf (buff
, sizeof buff
, "[0x%x: %s%s%s]",
7649 flags
& GRP_MASKOS
? _("<OS specific>") : "",
7650 flags
& GRP_MASKPROC
? _("<PROC specific>") : "",
7651 (flags
& ~(GRP_COMDAT
| GRP_MASKOS
| GRP_MASKPROC
)
7652 ? _("<unknown>") : ""));
7658 process_section_groups (Filedata
* filedata
)
7660 Elf_Internal_Shdr
* section
;
7662 struct group
* group
;
7663 Elf_Internal_Shdr
* symtab_sec
;
7664 Elf_Internal_Shdr
* strtab_sec
;
7665 Elf_Internal_Sym
* symtab
;
7666 unsigned long num_syms
;
7670 /* Don't process section groups unless needed. */
7671 if (!do_unwind
&& !do_section_groups
)
7674 if (filedata
->file_header
.e_shnum
== 0)
7676 if (do_section_groups
)
7678 if (filedata
->is_separate
)
7679 printf (_("\nThere are no sections group in linked file '%s'.\n"),
7680 filedata
->file_name
);
7682 printf (_("\nThere are no section groups in this file.\n"));
7687 if (filedata
->section_headers
== NULL
)
7689 error (_("Section headers are not available!\n"));
7690 /* PR 13622: This can happen with a corrupt ELF header. */
7694 filedata
->section_headers_groups
7695 = (struct group
**) calloc (filedata
->file_header
.e_shnum
,
7696 sizeof (struct group
*));
7698 if (filedata
->section_headers_groups
== NULL
)
7700 error (_("Out of memory reading %u section group headers\n"),
7701 filedata
->file_header
.e_shnum
);
7705 /* Scan the sections for the group section. */
7706 filedata
->group_count
= 0;
7707 for (i
= 0, section
= filedata
->section_headers
;
7708 i
< filedata
->file_header
.e_shnum
;
7710 if (section
->sh_type
== SHT_GROUP
)
7711 filedata
->group_count
++;
7713 if (filedata
->group_count
== 0)
7715 if (do_section_groups
)
7717 if (filedata
->is_separate
)
7718 printf (_("\nThere are no section groups in linked file '%s'.\n"),
7719 filedata
->file_name
);
7721 printf (_("\nThere are no section groups in this file.\n"));
7727 filedata
->section_groups
= (struct group
*) calloc (filedata
->group_count
,
7728 sizeof (struct group
));
7730 if (filedata
->section_groups
== NULL
)
7732 error (_("Out of memory reading %lu groups\n"),
7733 (unsigned long) filedata
->group_count
);
7744 if (filedata
->is_separate
)
7745 printf (_("Section groups in linked file '%s'\n"), filedata
->file_name
);
7747 for (i
= 0, section
= filedata
->section_headers
, group
= filedata
->section_groups
;
7748 i
< filedata
->file_header
.e_shnum
;
7751 if (section
->sh_type
== SHT_GROUP
)
7753 const char * name
= printable_section_name (filedata
, section
);
7754 const char * group_name
;
7755 unsigned char * start
;
7756 unsigned char * indices
;
7757 unsigned int entry
, j
, size
;
7758 Elf_Internal_Shdr
* sec
;
7759 Elf_Internal_Sym
* sym
;
7761 /* Get the symbol table. */
7762 if (section
->sh_link
>= filedata
->file_header
.e_shnum
7763 || ((sec
= filedata
->section_headers
+ section
->sh_link
)->sh_type
7766 error (_("Bad sh_link in group section `%s'\n"), name
);
7770 if (symtab_sec
!= sec
)
7774 symtab
= get_elf_symbols (filedata
, symtab_sec
, & num_syms
);
7779 error (_("Corrupt header in group section `%s'\n"), name
);
7783 if (section
->sh_info
>= num_syms
)
7785 error (_("Bad sh_info in group section `%s'\n"), name
);
7789 sym
= symtab
+ section
->sh_info
;
7791 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
7793 if (sym
->st_shndx
== 0
7794 || sym
->st_shndx
>= filedata
->file_header
.e_shnum
)
7796 error (_("Bad sh_info in group section `%s'\n"), name
);
7800 group_name
= section_name_print (filedata
,
7801 filedata
->section_headers
7810 /* Get the string table. */
7811 if (symtab_sec
->sh_link
>= filedata
->file_header
.e_shnum
)
7819 != (sec
= filedata
->section_headers
+ symtab_sec
->sh_link
))
7824 strtab
= (char *) get_data (NULL
, filedata
, strtab_sec
->sh_offset
,
7825 1, strtab_sec
->sh_size
,
7827 strtab_size
= strtab
!= NULL
? strtab_sec
->sh_size
: 0;
7829 group_name
= sym
->st_name
< strtab_size
7830 ? strtab
+ sym
->st_name
: _("<corrupt>");
7833 /* PR 17531: file: loop. */
7834 if (section
->sh_entsize
> section
->sh_size
)
7836 error (_("Section %s has sh_entsize (0x%lx) which is larger than its size (0x%lx)\n"),
7837 printable_section_name (filedata
, section
),
7838 (unsigned long) section
->sh_entsize
,
7839 (unsigned long) section
->sh_size
);
7843 start
= (unsigned char *) get_data (NULL
, filedata
, section
->sh_offset
,
7844 1, section
->sh_size
,
7850 size
= (section
->sh_size
/ section
->sh_entsize
) - 1;
7851 entry
= byte_get (indices
, 4);
7854 if (do_section_groups
)
7856 printf (_("\n%sgroup section [%5u] `%s' [%s] contains %u sections:\n"),
7857 get_group_flags (entry
), i
, name
, group_name
, size
);
7859 printf (_(" [Index] Name\n"));
7862 group
->group_index
= i
;
7864 for (j
= 0; j
< size
; j
++)
7866 struct group_list
* g
;
7868 entry
= byte_get (indices
, 4);
7871 if (entry
>= filedata
->file_header
.e_shnum
)
7873 static unsigned num_group_errors
= 0;
7875 if (num_group_errors
++ < 10)
7877 error (_("section [%5u] in group section [%5u] > maximum section [%5u]\n"),
7878 entry
, i
, filedata
->file_header
.e_shnum
- 1);
7879 if (num_group_errors
== 10)
7880 warn (_("Further error messages about overlarge group section indices suppressed\n"));
7885 if (filedata
->section_headers_groups
[entry
] != NULL
)
7889 static unsigned num_errs
= 0;
7891 if (num_errs
++ < 10)
7893 error (_("section [%5u] in group section [%5u] already in group section [%5u]\n"),
7895 filedata
->section_headers_groups
[entry
]->group_index
);
7897 warn (_("Further error messages about already contained group sections suppressed\n"));
7903 /* Intel C/C++ compiler may put section 0 in a
7904 section group. We just warn it the first time
7905 and ignore it afterwards. */
7906 static bool warned
= false;
7909 error (_("section 0 in group section [%5u]\n"),
7910 filedata
->section_headers_groups
[entry
]->group_index
);
7916 filedata
->section_headers_groups
[entry
] = group
;
7918 if (do_section_groups
)
7920 sec
= filedata
->section_headers
+ entry
;
7921 printf (" [%5u] %s\n", entry
, printable_section_name (filedata
, sec
));
7924 g
= (struct group_list
*) xmalloc (sizeof (struct group_list
));
7925 g
->section_index
= entry
;
7926 g
->next
= group
->root
;
7941 /* Data used to display dynamic fixups. */
7943 struct ia64_vms_dynfixup
7945 bfd_vma needed_ident
; /* Library ident number. */
7946 bfd_vma needed
; /* Index in the dstrtab of the library name. */
7947 bfd_vma fixup_needed
; /* Index of the library. */
7948 bfd_vma fixup_rela_cnt
; /* Number of fixups. */
7949 bfd_vma fixup_rela_off
; /* Fixups offset in the dynamic segment. */
7952 /* Data used to display dynamic relocations. */
7954 struct ia64_vms_dynimgrela
7956 bfd_vma img_rela_cnt
; /* Number of relocations. */
7957 bfd_vma img_rela_off
; /* Reloc offset in the dynamic segment. */
7960 /* Display IA-64 OpenVMS dynamic fixups (used to dynamically link a shared
7964 dump_ia64_vms_dynamic_fixups (Filedata
* filedata
,
7965 struct ia64_vms_dynfixup
* fixup
,
7966 const char * strtab
,
7967 unsigned int strtab_sz
)
7969 Elf64_External_VMS_IMAGE_FIXUP
* imfs
;
7971 const char * lib_name
;
7973 imfs
= get_data (NULL
, filedata
,
7974 filedata
->dynamic_addr
+ fixup
->fixup_rela_off
,
7975 sizeof (*imfs
), fixup
->fixup_rela_cnt
,
7976 _("dynamic section image fixups"));
7980 if (fixup
->needed
< strtab_sz
)
7981 lib_name
= strtab
+ fixup
->needed
;
7984 warn (_("corrupt library name index of 0x%lx found in dynamic entry"),
7985 (unsigned long) fixup
->needed
);
7989 printf (_("\nImage fixups for needed library #%d: %s - ident: %lx\n"),
7990 (int) fixup
->fixup_needed
, lib_name
, (long) fixup
->needed_ident
);
7992 (_("Seg Offset Type SymVec DataType\n"));
7994 for (i
= 0; i
< (long) fixup
->fixup_rela_cnt
; i
++)
7999 printf ("%3u ", (unsigned) BYTE_GET (imfs
[i
].fixup_seg
));
8000 printf_vma ((bfd_vma
) BYTE_GET (imfs
[i
].fixup_offset
));
8001 type
= BYTE_GET (imfs
[i
].type
);
8002 rtype
= elf_ia64_reloc_type (type
);
8004 printf (" 0x%08x ", type
);
8006 printf (" %-32s ", rtype
);
8007 printf ("%6u ", (unsigned) BYTE_GET (imfs
[i
].symvec_index
));
8008 printf ("0x%08x\n", (unsigned) BYTE_GET (imfs
[i
].data_type
));
8015 /* Display IA-64 OpenVMS dynamic relocations (used to relocate an image). */
8018 dump_ia64_vms_dynamic_relocs (Filedata
* filedata
, struct ia64_vms_dynimgrela
*imgrela
)
8020 Elf64_External_VMS_IMAGE_RELA
*imrs
;
8023 imrs
= get_data (NULL
, filedata
,
8024 filedata
->dynamic_addr
+ imgrela
->img_rela_off
,
8025 sizeof (*imrs
), imgrela
->img_rela_cnt
,
8026 _("dynamic section image relocations"));
8030 printf (_("\nImage relocs\n"));
8032 (_("Seg Offset Type Addend Seg Sym Off\n"));
8034 for (i
= 0; i
< (long) imgrela
->img_rela_cnt
; i
++)
8039 printf ("%3u ", (unsigned) BYTE_GET (imrs
[i
].rela_seg
));
8040 printf ("%08" BFD_VMA_FMT
"x ",
8041 (bfd_vma
) BYTE_GET (imrs
[i
].rela_offset
));
8042 type
= BYTE_GET (imrs
[i
].type
);
8043 rtype
= elf_ia64_reloc_type (type
);
8045 printf ("0x%08x ", type
);
8047 printf ("%-31s ", rtype
);
8048 print_vma (BYTE_GET (imrs
[i
].addend
), FULL_HEX
);
8049 printf ("%3u ", (unsigned) BYTE_GET (imrs
[i
].sym_seg
));
8050 printf ("%08" BFD_VMA_FMT
"x\n",
8051 (bfd_vma
) BYTE_GET (imrs
[i
].sym_offset
));
8058 /* Display IA-64 OpenVMS dynamic relocations and fixups. */
8061 process_ia64_vms_dynamic_relocs (Filedata
* filedata
)
8063 struct ia64_vms_dynfixup fixup
;
8064 struct ia64_vms_dynimgrela imgrela
;
8065 Elf_Internal_Dyn
*entry
;
8066 bfd_vma strtab_off
= 0;
8067 bfd_vma strtab_sz
= 0;
8068 char *strtab
= NULL
;
8071 memset (&fixup
, 0, sizeof (fixup
));
8072 memset (&imgrela
, 0, sizeof (imgrela
));
8074 /* Note: the order of the entries is specified by the OpenVMS specs. */
8075 for (entry
= filedata
->dynamic_section
;
8076 entry
< filedata
->dynamic_section
+ filedata
->dynamic_nent
;
8079 switch (entry
->d_tag
)
8081 case DT_IA_64_VMS_STRTAB_OFFSET
:
8082 strtab_off
= entry
->d_un
.d_val
;
8085 strtab_sz
= entry
->d_un
.d_val
;
8087 strtab
= get_data (NULL
, filedata
,
8088 filedata
->dynamic_addr
+ strtab_off
,
8089 1, strtab_sz
, _("dynamic string section"));
8094 case DT_IA_64_VMS_NEEDED_IDENT
:
8095 fixup
.needed_ident
= entry
->d_un
.d_val
;
8098 fixup
.needed
= entry
->d_un
.d_val
;
8100 case DT_IA_64_VMS_FIXUP_NEEDED
:
8101 fixup
.fixup_needed
= entry
->d_un
.d_val
;
8103 case DT_IA_64_VMS_FIXUP_RELA_CNT
:
8104 fixup
.fixup_rela_cnt
= entry
->d_un
.d_val
;
8106 case DT_IA_64_VMS_FIXUP_RELA_OFF
:
8107 fixup
.fixup_rela_off
= entry
->d_un
.d_val
;
8108 if (! dump_ia64_vms_dynamic_fixups (filedata
, &fixup
, strtab
, strtab_sz
))
8111 case DT_IA_64_VMS_IMG_RELA_CNT
:
8112 imgrela
.img_rela_cnt
= entry
->d_un
.d_val
;
8114 case DT_IA_64_VMS_IMG_RELA_OFF
:
8115 imgrela
.img_rela_off
= entry
->d_un
.d_val
;
8116 if (! dump_ia64_vms_dynamic_relocs (filedata
, &imgrela
))
8135 relocation_type rel_type
;
8137 dynamic_relocations
[] =
8139 { "REL", DT_REL
, DT_RELSZ
, reltype_rel
},
8140 { "RELA", DT_RELA
, DT_RELASZ
, reltype_rela
},
8141 { "RELR", DT_RELR
, DT_RELRSZ
, reltype_relr
},
8142 { "PLT", DT_JMPREL
, DT_PLTRELSZ
, reltype_unknown
}
8145 /* Process the reloc section. */
8148 process_relocs (Filedata
* filedata
)
8150 unsigned long rel_size
;
8151 unsigned long rel_offset
;
8156 if (do_using_dynamic
)
8158 relocation_type rel_type
;
8160 bool has_dynamic_reloc
;
8163 has_dynamic_reloc
= false;
8165 for (i
= 0; i
< ARRAY_SIZE (dynamic_relocations
); i
++)
8167 rel_type
= dynamic_relocations
[i
].rel_type
;
8168 name
= dynamic_relocations
[i
].name
;
8169 rel_size
= filedata
->dynamic_info
[dynamic_relocations
[i
].size
];
8170 rel_offset
= filedata
->dynamic_info
[dynamic_relocations
[i
].reloc
];
8173 has_dynamic_reloc
= true;
8175 if (rel_type
== reltype_unknown
)
8177 if (dynamic_relocations
[i
].reloc
== DT_JMPREL
)
8178 switch (filedata
->dynamic_info
[DT_PLTREL
])
8181 rel_type
= reltype_rel
;
8184 rel_type
= reltype_rela
;
8191 if (filedata
->is_separate
)
8193 (_("\nIn linked file '%s' section '%s' at offset 0x%lx contains %ld bytes:\n"),
8194 filedata
->file_name
, name
, rel_offset
, rel_size
);
8197 (_("\n'%s' relocation section at offset 0x%lx contains %ld bytes:\n"),
8198 name
, rel_offset
, rel_size
);
8200 dump_relocations (filedata
,
8201 offset_from_vma (filedata
, rel_offset
, rel_size
),
8203 filedata
->dynamic_symbols
,
8204 filedata
->num_dynamic_syms
,
8205 filedata
->dynamic_strings
,
8206 filedata
->dynamic_strings_length
,
8207 rel_type
, true /* is_dynamic */);
8211 if (is_ia64_vms (filedata
))
8212 if (process_ia64_vms_dynamic_relocs (filedata
))
8213 has_dynamic_reloc
= true;
8215 if (! has_dynamic_reloc
)
8217 if (filedata
->is_separate
)
8218 printf (_("\nThere are no dynamic relocations in linked file '%s'.\n"),
8219 filedata
->file_name
);
8221 printf (_("\nThere are no dynamic relocations in this file.\n"));
8226 Elf_Internal_Shdr
* section
;
8230 for (i
= 0, section
= filedata
->section_headers
;
8231 i
< filedata
->file_header
.e_shnum
;
8234 if ( section
->sh_type
!= SHT_RELA
8235 && section
->sh_type
!= SHT_REL
8236 && section
->sh_type
!= SHT_RELR
)
8239 rel_offset
= section
->sh_offset
;
8240 rel_size
= section
->sh_size
;
8244 relocation_type rel_type
;
8245 unsigned long num_rela
;
8247 if (filedata
->is_separate
)
8248 printf (_("\nIn linked file '%s' relocation section "),
8249 filedata
->file_name
);
8251 printf (_("\nRelocation section "));
8253 if (filedata
->string_table
== NULL
)
8254 printf ("%d", section
->sh_name
);
8256 printf ("'%s'", printable_section_name (filedata
, section
));
8258 num_rela
= rel_size
/ section
->sh_entsize
;
8259 printf (ngettext (" at offset 0x%lx contains %lu entry:\n",
8260 " at offset 0x%lx contains %lu entries:\n",
8262 rel_offset
, num_rela
);
8264 rel_type
= section
->sh_type
== SHT_RELA
? reltype_rela
:
8265 section
->sh_type
== SHT_REL
? reltype_rel
: reltype_relr
;
8267 if (section
->sh_link
!= 0
8268 && section
->sh_link
< filedata
->file_header
.e_shnum
)
8270 Elf_Internal_Shdr
* symsec
;
8271 Elf_Internal_Sym
* symtab
;
8272 unsigned long nsyms
;
8273 unsigned long strtablen
= 0;
8274 char * strtab
= NULL
;
8276 symsec
= filedata
->section_headers
+ section
->sh_link
;
8277 if (symsec
->sh_type
!= SHT_SYMTAB
8278 && symsec
->sh_type
!= SHT_DYNSYM
)
8281 if (!get_symtab (filedata
, symsec
,
8282 &symtab
, &nsyms
, &strtab
, &strtablen
))
8285 dump_relocations (filedata
, rel_offset
, rel_size
,
8286 symtab
, nsyms
, strtab
, strtablen
,
8288 symsec
->sh_type
== SHT_DYNSYM
);
8293 dump_relocations (filedata
, rel_offset
, rel_size
,
8294 NULL
, 0, NULL
, 0, rel_type
, false /* is_dynamic */);
8302 /* Users sometimes forget the -D option, so try to be helpful. */
8303 for (i
= 0; i
< ARRAY_SIZE (dynamic_relocations
); i
++)
8305 if (filedata
->dynamic_info
[dynamic_relocations
[i
].size
])
8307 if (filedata
->is_separate
)
8308 printf (_("\nThere are no static relocations in linked file '%s'."),
8309 filedata
->file_name
);
8311 printf (_("\nThere are no static relocations in this file."));
8312 printf (_("\nTo see the dynamic relocations add --use-dynamic to the command line.\n"));
8317 if (i
== ARRAY_SIZE (dynamic_relocations
))
8319 if (filedata
->is_separate
)
8320 printf (_("\nThere are no relocations in linked file '%s'.\n"),
8321 filedata
->file_name
);
8323 printf (_("\nThere are no relocations in this file.\n"));
8331 /* An absolute address consists of a section and an offset. If the
8332 section is NULL, the offset itself is the address, otherwise, the
8333 address equals to LOAD_ADDRESS(section) + offset. */
8337 unsigned short section
;
8341 /* Find the nearest symbol at or below ADDR. Returns the symbol
8342 name, if found, and the offset from the symbol to ADDR. */
8345 find_symbol_for_address (Filedata
* filedata
,
8346 Elf_Internal_Sym
* symtab
,
8347 unsigned long nsyms
,
8348 const char * strtab
,
8349 unsigned long strtab_size
,
8350 struct absaddr addr
,
8351 const char ** symname
,
8354 bfd_vma dist
= 0x100000;
8355 Elf_Internal_Sym
* sym
;
8356 Elf_Internal_Sym
* beg
;
8357 Elf_Internal_Sym
* end
;
8358 Elf_Internal_Sym
* best
= NULL
;
8360 REMOVE_ARCH_BITS (addr
.offset
);
8362 end
= symtab
+ nsyms
;
8368 sym
= beg
+ (end
- beg
) / 2;
8370 value
= sym
->st_value
;
8371 REMOVE_ARCH_BITS (value
);
8373 if (sym
->st_name
!= 0
8374 && (addr
.section
== SHN_UNDEF
|| addr
.section
== sym
->st_shndx
)
8375 && addr
.offset
>= value
8376 && addr
.offset
- value
< dist
)
8379 dist
= addr
.offset
- value
;
8384 if (addr
.offset
< value
)
8392 *symname
= (best
->st_name
>= strtab_size
8393 ? _("<corrupt>") : strtab
+ best
->st_name
);
8399 *offset
= addr
.offset
;
8402 static /* signed */ int
8403 symcmp (const void *p
, const void *q
)
8405 Elf_Internal_Sym
*sp
= (Elf_Internal_Sym
*) p
;
8406 Elf_Internal_Sym
*sq
= (Elf_Internal_Sym
*) q
;
8408 return sp
->st_value
> sq
->st_value
? 1 : (sp
->st_value
< sq
->st_value
? -1 : 0);
8411 /* Process the unwind section. */
8413 #include "unwind-ia64.h"
8415 struct ia64_unw_table_entry
8417 struct absaddr start
;
8419 struct absaddr info
;
8422 struct ia64_unw_aux_info
8424 struct ia64_unw_table_entry
* table
; /* Unwind table. */
8425 unsigned long table_len
; /* Length of unwind table. */
8426 unsigned char * info
; /* Unwind info. */
8427 unsigned long info_size
; /* Size of unwind info. */
8428 bfd_vma info_addr
; /* Starting address of unwind info. */
8429 bfd_vma seg_base
; /* Starting address of segment. */
8430 Elf_Internal_Sym
* symtab
; /* The symbol table. */
8431 unsigned long nsyms
; /* Number of symbols. */
8432 Elf_Internal_Sym
* funtab
; /* Sorted table of STT_FUNC symbols. */
8433 unsigned long nfuns
; /* Number of entries in funtab. */
8434 char * strtab
; /* The string table. */
8435 unsigned long strtab_size
; /* Size of string table. */
8439 dump_ia64_unwind (Filedata
* filedata
, struct ia64_unw_aux_info
* aux
)
8441 struct ia64_unw_table_entry
* tp
;
8442 unsigned long j
, nfuns
;
8446 aux
->funtab
= xmalloc (aux
->nsyms
* sizeof (Elf_Internal_Sym
));
8447 for (nfuns
= 0, j
= 0; j
< aux
->nsyms
; j
++)
8448 if (aux
->symtab
[j
].st_value
&& ELF_ST_TYPE (aux
->symtab
[j
].st_info
) == STT_FUNC
)
8449 aux
->funtab
[nfuns
++] = aux
->symtab
[j
];
8451 qsort (aux
->funtab
, aux
->nfuns
, sizeof (Elf_Internal_Sym
), symcmp
);
8453 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
8457 const unsigned char * dp
;
8458 const unsigned char * head
;
8459 const unsigned char * end
;
8460 const char * procname
;
8462 find_symbol_for_address (filedata
, aux
->funtab
, aux
->nfuns
, aux
->strtab
,
8463 aux
->strtab_size
, tp
->start
, &procname
, &offset
);
8465 fputs ("\n<", stdout
);
8469 fputs (procname
, stdout
);
8472 printf ("+%lx", (unsigned long) offset
);
8475 fputs (">: [", stdout
);
8476 print_vma (tp
->start
.offset
, PREFIX_HEX
);
8477 fputc ('-', stdout
);
8478 print_vma (tp
->end
.offset
, PREFIX_HEX
);
8479 printf ("], info at +0x%lx\n",
8480 (unsigned long) (tp
->info
.offset
- aux
->seg_base
));
8482 /* PR 17531: file: 86232b32. */
8483 if (aux
->info
== NULL
)
8486 offset
= tp
->info
.offset
;
8487 if (tp
->info
.section
)
8489 if (tp
->info
.section
>= filedata
->file_header
.e_shnum
)
8491 warn (_("Invalid section %u in table entry %ld\n"),
8492 tp
->info
.section
, (long) (tp
- aux
->table
));
8496 offset
+= filedata
->section_headers
[tp
->info
.section
].sh_addr
;
8498 offset
-= aux
->info_addr
;
8499 /* PR 17531: file: 0997b4d1. */
8500 if (offset
>= aux
->info_size
8501 || aux
->info_size
- offset
< 8)
8503 warn (_("Invalid offset %lx in table entry %ld\n"),
8504 (long) tp
->info
.offset
, (long) (tp
- aux
->table
));
8509 head
= aux
->info
+ offset
;
8510 stamp
= byte_get ((unsigned char *) head
, sizeof (stamp
));
8512 printf (" v%u, flags=0x%lx (%s%s), len=%lu bytes\n",
8513 (unsigned) UNW_VER (stamp
),
8514 (unsigned long) ((stamp
& UNW_FLAG_MASK
) >> 32),
8515 UNW_FLAG_EHANDLER (stamp
) ? " ehandler" : "",
8516 UNW_FLAG_UHANDLER (stamp
) ? " uhandler" : "",
8517 (unsigned long) (eh_addr_size
* UNW_LENGTH (stamp
)));
8519 if (UNW_VER (stamp
) != 1)
8521 printf (_("\tUnknown version.\n"));
8526 end
= head
+ 8 + eh_addr_size
* UNW_LENGTH (stamp
);
8527 /* PR 17531: file: 16ceda89. */
8528 if (end
> aux
->info
+ aux
->info_size
)
8529 end
= aux
->info
+ aux
->info_size
;
8530 for (dp
= head
+ 8; dp
< end
;)
8531 dp
= unw_decode (dp
, in_body
, & in_body
, end
);
8540 slurp_ia64_unwind_table (Filedata
* filedata
,
8541 struct ia64_unw_aux_info
* aux
,
8542 Elf_Internal_Shdr
* sec
)
8544 unsigned long size
, nrelas
, i
;
8545 Elf_Internal_Phdr
* seg
;
8546 struct ia64_unw_table_entry
* tep
;
8547 Elf_Internal_Shdr
* relsec
;
8548 Elf_Internal_Rela
* rela
;
8549 Elf_Internal_Rela
* rp
;
8550 unsigned char * table
;
8552 Elf_Internal_Sym
* sym
;
8553 const char * relname
;
8557 /* First, find the starting address of the segment that includes
8560 if (filedata
->file_header
.e_phnum
)
8562 if (! get_program_headers (filedata
))
8565 for (seg
= filedata
->program_headers
;
8566 seg
< filedata
->program_headers
+ filedata
->file_header
.e_phnum
;
8569 if (seg
->p_type
!= PT_LOAD
)
8572 if (sec
->sh_addr
>= seg
->p_vaddr
8573 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
8575 aux
->seg_base
= seg
->p_vaddr
;
8581 /* Second, build the unwind table from the contents of the unwind section: */
8582 size
= sec
->sh_size
;
8583 table
= (unsigned char *) get_data (NULL
, filedata
, sec
->sh_offset
, 1, size
,
8588 aux
->table_len
= size
/ (3 * eh_addr_size
);
8589 aux
->table
= (struct ia64_unw_table_entry
*)
8590 xcmalloc (aux
->table_len
, sizeof (aux
->table
[0]));
8593 for (tp
= table
; tp
<= table
+ size
- (3 * eh_addr_size
); ++tep
)
8595 tep
->start
.section
= SHN_UNDEF
;
8596 tep
->end
.section
= SHN_UNDEF
;
8597 tep
->info
.section
= SHN_UNDEF
;
8598 tep
->start
.offset
= byte_get (tp
, eh_addr_size
); tp
+= eh_addr_size
;
8599 tep
->end
.offset
= byte_get (tp
, eh_addr_size
); tp
+= eh_addr_size
;
8600 tep
->info
.offset
= byte_get (tp
, eh_addr_size
); tp
+= eh_addr_size
;
8601 tep
->start
.offset
+= aux
->seg_base
;
8602 tep
->end
.offset
+= aux
->seg_base
;
8603 tep
->info
.offset
+= aux
->seg_base
;
8607 /* Third, apply any relocations to the unwind table: */
8608 for (relsec
= filedata
->section_headers
;
8609 relsec
< filedata
->section_headers
+ filedata
->file_header
.e_shnum
;
8612 if (relsec
->sh_type
!= SHT_RELA
8613 || relsec
->sh_info
>= filedata
->file_header
.e_shnum
8614 || filedata
->section_headers
+ relsec
->sh_info
!= sec
)
8617 if (!slurp_rela_relocs (filedata
, relsec
->sh_offset
, relsec
->sh_size
,
8626 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
8628 unsigned int sym_ndx
;
8629 unsigned int r_type
= get_reloc_type (filedata
, rp
->r_info
);
8630 relname
= elf_ia64_reloc_type (r_type
);
8632 /* PR 17531: file: 9fa67536. */
8633 if (relname
== NULL
)
8635 warn (_("Skipping unknown relocation type: %u\n"), r_type
);
8639 if (! startswith (relname
, "R_IA64_SEGREL"))
8641 warn (_("Skipping unexpected relocation type: %s\n"), relname
);
8645 i
= rp
->r_offset
/ (3 * eh_addr_size
);
8647 /* PR 17531: file: 5bc8d9bf. */
8648 if (i
>= aux
->table_len
)
8650 warn (_("Skipping reloc with overlarge offset: %lx\n"), i
);
8654 sym_ndx
= get_reloc_symindex (rp
->r_info
);
8655 if (sym_ndx
>= aux
->nsyms
)
8657 warn (_("Skipping reloc with invalid symbol index: %u\n"),
8661 sym
= aux
->symtab
+ sym_ndx
;
8663 switch (rp
->r_offset
/ eh_addr_size
% 3)
8666 aux
->table
[i
].start
.section
= sym
->st_shndx
;
8667 aux
->table
[i
].start
.offset
= rp
->r_addend
+ sym
->st_value
;
8670 aux
->table
[i
].end
.section
= sym
->st_shndx
;
8671 aux
->table
[i
].end
.offset
= rp
->r_addend
+ sym
->st_value
;
8674 aux
->table
[i
].info
.section
= sym
->st_shndx
;
8675 aux
->table
[i
].info
.offset
= rp
->r_addend
+ sym
->st_value
;
8689 ia64_process_unwind (Filedata
* filedata
)
8691 Elf_Internal_Shdr
* sec
;
8692 Elf_Internal_Shdr
* unwsec
= NULL
;
8693 unsigned long i
, unwcount
= 0, unwstart
= 0;
8694 struct ia64_unw_aux_info aux
;
8697 memset (& aux
, 0, sizeof (aux
));
8699 for (i
= 0, sec
= filedata
->section_headers
; i
< filedata
->file_header
.e_shnum
; ++i
, ++sec
)
8701 if (sec
->sh_type
== SHT_SYMTAB
)
8705 error (_("Multiple symbol tables encountered\n"));
8711 if (!get_symtab (filedata
, sec
, &aux
.symtab
, &aux
.nsyms
,
8712 &aux
.strtab
, &aux
.strtab_size
))
8715 else if (sec
->sh_type
== SHT_IA_64_UNWIND
)
8720 printf (_("\nThere are no unwind sections in this file.\n"));
8722 while (unwcount
-- > 0)
8727 for (i
= unwstart
, sec
= filedata
->section_headers
+ unwstart
, unwsec
= NULL
;
8728 i
< filedata
->file_header
.e_shnum
; ++i
, ++sec
)
8729 if (sec
->sh_type
== SHT_IA_64_UNWIND
)
8734 /* We have already counted the number of SHT_IA64_UNWIND
8735 sections so the loop above should never fail. */
8736 assert (unwsec
!= NULL
);
8739 len
= sizeof (ELF_STRING_ia64_unwind_once
) - 1;
8741 if ((unwsec
->sh_flags
& SHF_GROUP
) != 0)
8743 /* We need to find which section group it is in. */
8744 struct group_list
* g
;
8746 if (filedata
->section_headers_groups
== NULL
8747 || filedata
->section_headers_groups
[i
] == NULL
)
8748 i
= filedata
->file_header
.e_shnum
;
8751 g
= filedata
->section_headers_groups
[i
]->root
;
8753 for (; g
!= NULL
; g
= g
->next
)
8755 sec
= filedata
->section_headers
+ g
->section_index
;
8757 if (section_name_valid (filedata
, sec
)
8758 && streq (section_name (filedata
, sec
),
8759 ELF_STRING_ia64_unwind_info
))
8764 i
= filedata
->file_header
.e_shnum
;
8767 else if (section_name_valid (filedata
, unwsec
)
8768 && startswith (section_name (filedata
, unwsec
),
8769 ELF_STRING_ia64_unwind_once
))
8771 /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO. */
8772 len2
= sizeof (ELF_STRING_ia64_unwind_info_once
) - 1;
8773 suffix
= section_name (filedata
, unwsec
) + len
;
8774 for (i
= 0, sec
= filedata
->section_headers
;
8775 i
< filedata
->file_header
.e_shnum
;
8777 if (section_name_valid (filedata
, sec
)
8778 && startswith (section_name (filedata
, sec
),
8779 ELF_STRING_ia64_unwind_info_once
)
8780 && streq (section_name (filedata
, sec
) + len2
, suffix
))
8785 /* .IA_64.unwindFOO -> .IA_64.unwind_infoFOO
8786 .IA_64.unwind or BAR -> .IA_64.unwind_info. */
8787 len
= sizeof (ELF_STRING_ia64_unwind
) - 1;
8788 len2
= sizeof (ELF_STRING_ia64_unwind_info
) - 1;
8790 if (section_name_valid (filedata
, unwsec
)
8791 && startswith (section_name (filedata
, unwsec
),
8792 ELF_STRING_ia64_unwind
))
8793 suffix
= section_name (filedata
, unwsec
) + len
;
8794 for (i
= 0, sec
= filedata
->section_headers
;
8795 i
< filedata
->file_header
.e_shnum
;
8797 if (section_name_valid (filedata
, sec
)
8798 && startswith (section_name (filedata
, sec
),
8799 ELF_STRING_ia64_unwind_info
)
8800 && streq (section_name (filedata
, sec
) + len2
, suffix
))
8804 if (i
== filedata
->file_header
.e_shnum
)
8806 printf (_("\nCould not find unwind info section for "));
8808 if (filedata
->string_table
== NULL
)
8809 printf ("%d", unwsec
->sh_name
);
8811 printf ("'%s'", printable_section_name (filedata
, unwsec
));
8815 aux
.info_addr
= sec
->sh_addr
;
8816 aux
.info
= (unsigned char *) get_data (NULL
, filedata
, sec
->sh_offset
, 1,
8819 aux
.info_size
= aux
.info
== NULL
? 0 : sec
->sh_size
;
8821 printf (_("\nUnwind section "));
8823 if (filedata
->string_table
== NULL
)
8824 printf ("%d", unwsec
->sh_name
);
8826 printf ("'%s'", printable_section_name (filedata
, unwsec
));
8828 printf (_(" at offset 0x%lx contains %lu entries:\n"),
8829 (unsigned long) unwsec
->sh_offset
,
8830 (unsigned long) (unwsec
->sh_size
/ (3 * eh_addr_size
)));
8832 if (slurp_ia64_unwind_table (filedata
, & aux
, unwsec
)
8833 && aux
.table_len
> 0)
8834 dump_ia64_unwind (filedata
, & aux
);
8836 free ((char *) aux
.table
);
8837 free ((char *) aux
.info
);
8844 free ((char *) aux
.strtab
);
8849 struct hppa_unw_table_entry
8851 struct absaddr start
;
8853 unsigned int Cannot_unwind
:1; /* 0 */
8854 unsigned int Millicode
:1; /* 1 */
8855 unsigned int Millicode_save_sr0
:1; /* 2 */
8856 unsigned int Region_description
:2; /* 3..4 */
8857 unsigned int reserved1
:1; /* 5 */
8858 unsigned int Entry_SR
:1; /* 6 */
8859 unsigned int Entry_FR
:4; /* Number saved 7..10 */
8860 unsigned int Entry_GR
:5; /* Number saved 11..15 */
8861 unsigned int Args_stored
:1; /* 16 */
8862 unsigned int Variable_Frame
:1; /* 17 */
8863 unsigned int Separate_Package_Body
:1; /* 18 */
8864 unsigned int Frame_Extension_Millicode
:1; /* 19 */
8865 unsigned int Stack_Overflow_Check
:1; /* 20 */
8866 unsigned int Two_Instruction_SP_Increment
:1; /* 21 */
8867 unsigned int Ada_Region
:1; /* 22 */
8868 unsigned int cxx_info
:1; /* 23 */
8869 unsigned int cxx_try_catch
:1; /* 24 */
8870 unsigned int sched_entry_seq
:1; /* 25 */
8871 unsigned int reserved2
:1; /* 26 */
8872 unsigned int Save_SP
:1; /* 27 */
8873 unsigned int Save_RP
:1; /* 28 */
8874 unsigned int Save_MRP_in_frame
:1; /* 29 */
8875 unsigned int extn_ptr_defined
:1; /* 30 */
8876 unsigned int Cleanup_defined
:1; /* 31 */
8878 unsigned int MPE_XL_interrupt_marker
:1; /* 0 */
8879 unsigned int HP_UX_interrupt_marker
:1; /* 1 */
8880 unsigned int Large_frame
:1; /* 2 */
8881 unsigned int Pseudo_SP_Set
:1; /* 3 */
8882 unsigned int reserved4
:1; /* 4 */
8883 unsigned int Total_frame_size
:27; /* 5..31 */
8886 struct hppa_unw_aux_info
8888 struct hppa_unw_table_entry
* table
; /* Unwind table. */
8889 unsigned long table_len
; /* Length of unwind table. */
8890 bfd_vma seg_base
; /* Starting address of segment. */
8891 Elf_Internal_Sym
* symtab
; /* The symbol table. */
8892 unsigned long nsyms
; /* Number of symbols. */
8893 Elf_Internal_Sym
* funtab
; /* Sorted table of STT_FUNC symbols. */
8894 unsigned long nfuns
; /* Number of entries in funtab. */
8895 char * strtab
; /* The string table. */
8896 unsigned long strtab_size
; /* Size of string table. */
8900 dump_hppa_unwind (Filedata
* filedata
, struct hppa_unw_aux_info
* aux
)
8902 struct hppa_unw_table_entry
* tp
;
8903 unsigned long j
, nfuns
;
8906 aux
->funtab
= xmalloc (aux
->nsyms
* sizeof (Elf_Internal_Sym
));
8907 for (nfuns
= 0, j
= 0; j
< aux
->nsyms
; j
++)
8908 if (aux
->symtab
[j
].st_value
&& ELF_ST_TYPE (aux
->symtab
[j
].st_info
) == STT_FUNC
)
8909 aux
->funtab
[nfuns
++] = aux
->symtab
[j
];
8911 qsort (aux
->funtab
, aux
->nfuns
, sizeof (Elf_Internal_Sym
), symcmp
);
8913 for (tp
= aux
->table
; tp
< aux
->table
+ aux
->table_len
; ++tp
)
8916 const char * procname
;
8918 find_symbol_for_address (filedata
, aux
->funtab
, aux
->nfuns
, aux
->strtab
,
8919 aux
->strtab_size
, tp
->start
, &procname
,
8922 fputs ("\n<", stdout
);
8926 fputs (procname
, stdout
);
8929 printf ("+%lx", (unsigned long) offset
);
8932 fputs (">: [", stdout
);
8933 print_vma (tp
->start
.offset
, PREFIX_HEX
);
8934 fputc ('-', stdout
);
8935 print_vma (tp
->end
.offset
, PREFIX_HEX
);
8938 #define PF(_m) if (tp->_m) printf (#_m " ");
8939 #define PV(_m) if (tp->_m) printf (#_m "=%d ", tp->_m);
8942 PF(Millicode_save_sr0
);
8943 /* PV(Region_description); */
8949 PF(Separate_Package_Body
);
8950 PF(Frame_Extension_Millicode
);
8951 PF(Stack_Overflow_Check
);
8952 PF(Two_Instruction_SP_Increment
);
8956 PF(sched_entry_seq
);
8959 PF(Save_MRP_in_frame
);
8960 PF(extn_ptr_defined
);
8961 PF(Cleanup_defined
);
8962 PF(MPE_XL_interrupt_marker
);
8963 PF(HP_UX_interrupt_marker
);
8966 PV(Total_frame_size
);
8979 slurp_hppa_unwind_table (Filedata
* filedata
,
8980 struct hppa_unw_aux_info
* aux
,
8981 Elf_Internal_Shdr
* sec
)
8983 unsigned long size
, unw_ent_size
, nentries
, nrelas
, i
;
8984 Elf_Internal_Phdr
* seg
;
8985 struct hppa_unw_table_entry
* tep
;
8986 Elf_Internal_Shdr
* relsec
;
8987 Elf_Internal_Rela
* rela
;
8988 Elf_Internal_Rela
* rp
;
8989 unsigned char * table
;
8991 Elf_Internal_Sym
* sym
;
8992 const char * relname
;
8994 /* First, find the starting address of the segment that includes
8996 if (filedata
->file_header
.e_phnum
)
8998 if (! get_program_headers (filedata
))
9001 for (seg
= filedata
->program_headers
;
9002 seg
< filedata
->program_headers
+ filedata
->file_header
.e_phnum
;
9005 if (seg
->p_type
!= PT_LOAD
)
9008 if (sec
->sh_addr
>= seg
->p_vaddr
9009 && (sec
->sh_addr
+ sec
->sh_size
<= seg
->p_vaddr
+ seg
->p_memsz
))
9011 aux
->seg_base
= seg
->p_vaddr
;
9017 /* Second, build the unwind table from the contents of the unwind
9019 size
= sec
->sh_size
;
9020 table
= (unsigned char *) get_data (NULL
, filedata
, sec
->sh_offset
, 1, size
,
9026 nentries
= size
/ unw_ent_size
;
9027 size
= unw_ent_size
* nentries
;
9029 aux
->table_len
= nentries
;
9030 tep
= aux
->table
= (struct hppa_unw_table_entry
*)
9031 xcmalloc (nentries
, sizeof (aux
->table
[0]));
9033 for (tp
= table
; tp
< table
+ size
; tp
+= unw_ent_size
, ++tep
)
9035 unsigned int tmp1
, tmp2
;
9037 tep
->start
.section
= SHN_UNDEF
;
9038 tep
->end
.section
= SHN_UNDEF
;
9040 tep
->start
.offset
= byte_get ((unsigned char *) tp
+ 0, 4);
9041 tep
->end
.offset
= byte_get ((unsigned char *) tp
+ 4, 4);
9042 tmp1
= byte_get ((unsigned char *) tp
+ 8, 4);
9043 tmp2
= byte_get ((unsigned char *) tp
+ 12, 4);
9045 tep
->start
.offset
+= aux
->seg_base
;
9046 tep
->end
.offset
+= aux
->seg_base
;
9048 tep
->Cannot_unwind
= (tmp1
>> 31) & 0x1;
9049 tep
->Millicode
= (tmp1
>> 30) & 0x1;
9050 tep
->Millicode_save_sr0
= (tmp1
>> 29) & 0x1;
9051 tep
->Region_description
= (tmp1
>> 27) & 0x3;
9052 tep
->reserved1
= (tmp1
>> 26) & 0x1;
9053 tep
->Entry_SR
= (tmp1
>> 25) & 0x1;
9054 tep
->Entry_FR
= (tmp1
>> 21) & 0xf;
9055 tep
->Entry_GR
= (tmp1
>> 16) & 0x1f;
9056 tep
->Args_stored
= (tmp1
>> 15) & 0x1;
9057 tep
->Variable_Frame
= (tmp1
>> 14) & 0x1;
9058 tep
->Separate_Package_Body
= (tmp1
>> 13) & 0x1;
9059 tep
->Frame_Extension_Millicode
= (tmp1
>> 12) & 0x1;
9060 tep
->Stack_Overflow_Check
= (tmp1
>> 11) & 0x1;
9061 tep
->Two_Instruction_SP_Increment
= (tmp1
>> 10) & 0x1;
9062 tep
->Ada_Region
= (tmp1
>> 9) & 0x1;
9063 tep
->cxx_info
= (tmp1
>> 8) & 0x1;
9064 tep
->cxx_try_catch
= (tmp1
>> 7) & 0x1;
9065 tep
->sched_entry_seq
= (tmp1
>> 6) & 0x1;
9066 tep
->reserved2
= (tmp1
>> 5) & 0x1;
9067 tep
->Save_SP
= (tmp1
>> 4) & 0x1;
9068 tep
->Save_RP
= (tmp1
>> 3) & 0x1;
9069 tep
->Save_MRP_in_frame
= (tmp1
>> 2) & 0x1;
9070 tep
->extn_ptr_defined
= (tmp1
>> 1) & 0x1;
9071 tep
->Cleanup_defined
= tmp1
& 0x1;
9073 tep
->MPE_XL_interrupt_marker
= (tmp2
>> 31) & 0x1;
9074 tep
->HP_UX_interrupt_marker
= (tmp2
>> 30) & 0x1;
9075 tep
->Large_frame
= (tmp2
>> 29) & 0x1;
9076 tep
->Pseudo_SP_Set
= (tmp2
>> 28) & 0x1;
9077 tep
->reserved4
= (tmp2
>> 27) & 0x1;
9078 tep
->Total_frame_size
= tmp2
& 0x7ffffff;
9082 /* Third, apply any relocations to the unwind table. */
9083 for (relsec
= filedata
->section_headers
;
9084 relsec
< filedata
->section_headers
+ filedata
->file_header
.e_shnum
;
9087 if (relsec
->sh_type
!= SHT_RELA
9088 || relsec
->sh_info
>= filedata
->file_header
.e_shnum
9089 || filedata
->section_headers
+ relsec
->sh_info
!= sec
)
9092 if (!slurp_rela_relocs (filedata
, relsec
->sh_offset
, relsec
->sh_size
,
9096 for (rp
= rela
; rp
< rela
+ nrelas
; ++rp
)
9098 unsigned int sym_ndx
;
9099 unsigned int r_type
= get_reloc_type (filedata
, rp
->r_info
);
9100 relname
= elf_hppa_reloc_type (r_type
);
9102 if (relname
== NULL
)
9104 warn (_("Skipping unknown relocation type: %u\n"), r_type
);
9108 /* R_PARISC_SEGREL32 or R_PARISC_SEGREL64. */
9109 if (! startswith (relname
, "R_PARISC_SEGREL"))
9111 warn (_("Skipping unexpected relocation type: %s\n"), relname
);
9115 i
= rp
->r_offset
/ unw_ent_size
;
9116 if (i
>= aux
->table_len
)
9118 warn (_("Skipping reloc with overlarge offset: %lx\n"), i
);
9122 sym_ndx
= get_reloc_symindex (rp
->r_info
);
9123 if (sym_ndx
>= aux
->nsyms
)
9125 warn (_("Skipping reloc with invalid symbol index: %u\n"),
9129 sym
= aux
->symtab
+ sym_ndx
;
9131 switch ((rp
->r_offset
% unw_ent_size
) / 4)
9134 aux
->table
[i
].start
.section
= sym
->st_shndx
;
9135 aux
->table
[i
].start
.offset
= sym
->st_value
+ rp
->r_addend
;
9138 aux
->table
[i
].end
.section
= sym
->st_shndx
;
9139 aux
->table
[i
].end
.offset
= sym
->st_value
+ rp
->r_addend
;
9153 hppa_process_unwind (Filedata
* filedata
)
9155 struct hppa_unw_aux_info aux
;
9156 Elf_Internal_Shdr
* unwsec
= NULL
;
9157 Elf_Internal_Shdr
* sec
;
9161 if (filedata
->string_table
== NULL
)
9164 memset (& aux
, 0, sizeof (aux
));
9166 for (i
= 0, sec
= filedata
->section_headers
; i
< filedata
->file_header
.e_shnum
; ++i
, ++sec
)
9168 if (sec
->sh_type
== SHT_SYMTAB
)
9172 error (_("Multiple symbol tables encountered\n"));
9178 if (!get_symtab (filedata
, sec
, &aux
.symtab
, &aux
.nsyms
,
9179 &aux
.strtab
, &aux
.strtab_size
))
9182 else if (section_name_valid (filedata
, sec
)
9183 && streq (section_name (filedata
, sec
), ".PARISC.unwind"))
9188 printf (_("\nThere are no unwind sections in this file.\n"));
9190 for (i
= 0, sec
= filedata
->section_headers
; i
< filedata
->file_header
.e_shnum
; ++i
, ++sec
)
9192 if (section_name_valid (filedata
, sec
)
9193 && streq (section_name (filedata
, sec
), ".PARISC.unwind"))
9195 unsigned long num_unwind
= sec
->sh_size
/ 16;
9197 printf (ngettext ("\nUnwind section '%s' at offset 0x%lx "
9198 "contains %lu entry:\n",
9199 "\nUnwind section '%s' at offset 0x%lx "
9200 "contains %lu entries:\n",
9202 printable_section_name (filedata
, sec
),
9203 (unsigned long) sec
->sh_offset
,
9206 if (! slurp_hppa_unwind_table (filedata
, &aux
, sec
))
9209 if (res
&& aux
.table_len
> 0)
9211 if (! dump_hppa_unwind (filedata
, &aux
))
9215 free ((char *) aux
.table
);
9221 free ((char *) aux
.strtab
);
9228 unsigned char * data
; /* The unwind data. */
9229 Elf_Internal_Shdr
* sec
; /* The cached unwind section header. */
9230 Elf_Internal_Rela
* rela
; /* The cached relocations for this section. */
9231 unsigned long nrelas
; /* The number of relocations. */
9232 unsigned int rel_type
; /* REL or RELA ? */
9233 Elf_Internal_Rela
* next_rela
; /* Cyclic pointer to the next reloc to process. */
9236 struct arm_unw_aux_info
9238 Filedata
* filedata
; /* The file containing the unwind sections. */
9239 Elf_Internal_Sym
* symtab
; /* The file's symbol table. */
9240 unsigned long nsyms
; /* Number of symbols. */
9241 Elf_Internal_Sym
* funtab
; /* Sorted table of STT_FUNC symbols. */
9242 unsigned long nfuns
; /* Number of these symbols. */
9243 char * strtab
; /* The file's string table. */
9244 unsigned long strtab_size
; /* Size of string table. */
9248 arm_print_vma_and_name (Filedata
* filedata
,
9249 struct arm_unw_aux_info
* aux
,
9251 struct absaddr addr
)
9253 const char *procname
;
9256 if (addr
.section
== SHN_UNDEF
)
9259 find_symbol_for_address (filedata
, aux
->funtab
, aux
->nfuns
, aux
->strtab
,
9260 aux
->strtab_size
, addr
, &procname
,
9263 print_vma (fn
, PREFIX_HEX
);
9267 fputs (" <", stdout
);
9268 fputs (procname
, stdout
);
9271 printf ("+0x%lx", (unsigned long) sym_offset
);
9272 fputc ('>', stdout
);
9279 arm_free_section (struct arm_section
*arm_sec
)
9281 free (arm_sec
->data
);
9282 free (arm_sec
->rela
);
9285 /* 1) If SEC does not match the one cached in ARM_SEC, then free the current
9286 cached section and install SEC instead.
9287 2) Locate the 32-bit word at WORD_OFFSET in unwind section SEC
9288 and return its valued in * WORDP, relocating if necessary.
9289 3) Update the NEXT_RELA field in ARM_SEC and store the section index and
9290 relocation's offset in ADDR.
9291 4) If SYM_NAME is non-NULL and a relocation was applied, record the offset
9292 into the string table of the symbol associated with the reloc. If no
9293 reloc was applied store -1 there.
9294 5) Return TRUE upon success, FALSE otherwise. */
9297 get_unwind_section_word (Filedata
* filedata
,
9298 struct arm_unw_aux_info
* aux
,
9299 struct arm_section
* arm_sec
,
9300 Elf_Internal_Shdr
* sec
,
9301 bfd_vma word_offset
,
9302 unsigned int * wordp
,
9303 struct absaddr
* addr
,
9306 Elf_Internal_Rela
*rp
;
9307 Elf_Internal_Sym
*sym
;
9308 const char * relname
;
9312 if (sec
== NULL
|| arm_sec
== NULL
)
9315 addr
->section
= SHN_UNDEF
;
9318 if (sym_name
!= NULL
)
9319 *sym_name
= (bfd_vma
) -1;
9321 /* If necessary, update the section cache. */
9322 if (sec
!= arm_sec
->sec
)
9324 Elf_Internal_Shdr
*relsec
;
9326 arm_free_section (arm_sec
);
9329 arm_sec
->data
= get_data (NULL
, aux
->filedata
, sec
->sh_offset
, 1,
9330 sec
->sh_size
, _("unwind data"));
9331 arm_sec
->rela
= NULL
;
9332 arm_sec
->nrelas
= 0;
9334 for (relsec
= filedata
->section_headers
;
9335 relsec
< filedata
->section_headers
+ filedata
->file_header
.e_shnum
;
9338 if (relsec
->sh_info
>= filedata
->file_header
.e_shnum
9339 || filedata
->section_headers
+ relsec
->sh_info
!= sec
9340 /* PR 15745: Check the section type as well. */
9341 || (relsec
->sh_type
!= SHT_REL
9342 && relsec
->sh_type
!= SHT_RELA
))
9345 arm_sec
->rel_type
= relsec
->sh_type
;
9346 if (relsec
->sh_type
== SHT_REL
)
9348 if (!slurp_rel_relocs (aux
->filedata
, relsec
->sh_offset
,
9350 & arm_sec
->rela
, & arm_sec
->nrelas
))
9353 else /* relsec->sh_type == SHT_RELA */
9355 if (!slurp_rela_relocs (aux
->filedata
, relsec
->sh_offset
,
9357 & arm_sec
->rela
, & arm_sec
->nrelas
))
9363 arm_sec
->next_rela
= arm_sec
->rela
;
9366 /* If there is no unwind data we can do nothing. */
9367 if (arm_sec
->data
== NULL
)
9370 /* If the offset is invalid then fail. */
9371 if (/* PR 21343 *//* PR 18879 */
9373 || word_offset
> (sec
->sh_size
- 4)
9374 || ((bfd_signed_vma
) word_offset
) < 0)
9377 /* Get the word at the required offset. */
9378 word
= byte_get (arm_sec
->data
+ word_offset
, 4);
9380 /* PR 17531: file: id:000001,src:001266+003044,op:splice,rep:128. */
9381 if (arm_sec
->rela
== NULL
)
9387 /* Look through the relocs to find the one that applies to the provided offset. */
9389 for (rp
= arm_sec
->next_rela
; rp
!= arm_sec
->rela
+ arm_sec
->nrelas
; rp
++)
9391 bfd_vma prelval
, offset
;
9393 if (rp
->r_offset
> word_offset
&& !wrapped
)
9398 if (rp
->r_offset
> word_offset
)
9401 if (rp
->r_offset
& 3)
9403 warn (_("Skipping unexpected relocation at offset 0x%lx\n"),
9404 (unsigned long) rp
->r_offset
);
9408 if (rp
->r_offset
< word_offset
)
9411 /* PR 17531: file: 027-161405-0.004 */
9412 if (aux
->symtab
== NULL
)
9415 if (arm_sec
->rel_type
== SHT_REL
)
9417 offset
= word
& 0x7fffffff;
9418 if (offset
& 0x40000000)
9419 offset
|= ~ (bfd_vma
) 0x7fffffff;
9421 else if (arm_sec
->rel_type
== SHT_RELA
)
9422 offset
= rp
->r_addend
;
9425 error (_("Unknown section relocation type %d encountered\n"),
9430 /* PR 17531 file: 027-1241568-0.004. */
9431 if (ELF32_R_SYM (rp
->r_info
) >= aux
->nsyms
)
9433 error (_("Bad symbol index in unwind relocation (%lu > %lu)\n"),
9434 (unsigned long) ELF32_R_SYM (rp
->r_info
), aux
->nsyms
);
9438 sym
= aux
->symtab
+ ELF32_R_SYM (rp
->r_info
);
9439 offset
+= sym
->st_value
;
9440 prelval
= offset
- (arm_sec
->sec
->sh_addr
+ rp
->r_offset
);
9442 /* Check that we are processing the expected reloc type. */
9443 if (filedata
->file_header
.e_machine
== EM_ARM
)
9445 relname
= elf_arm_reloc_type (ELF32_R_TYPE (rp
->r_info
));
9446 if (relname
== NULL
)
9448 warn (_("Skipping unknown ARM relocation type: %d\n"),
9449 (int) ELF32_R_TYPE (rp
->r_info
));
9453 if (streq (relname
, "R_ARM_NONE"))
9456 if (! streq (relname
, "R_ARM_PREL31"))
9458 warn (_("Skipping unexpected ARM relocation type %s\n"), relname
);
9462 else if (filedata
->file_header
.e_machine
== EM_TI_C6000
)
9464 relname
= elf_tic6x_reloc_type (ELF32_R_TYPE (rp
->r_info
));
9465 if (relname
== NULL
)
9467 warn (_("Skipping unknown C6000 relocation type: %d\n"),
9468 (int) ELF32_R_TYPE (rp
->r_info
));
9472 if (streq (relname
, "R_C6000_NONE"))
9475 if (! streq (relname
, "R_C6000_PREL31"))
9477 warn (_("Skipping unexpected C6000 relocation type %s\n"), relname
);
9485 /* This function currently only supports ARM and TI unwinders. */
9486 warn (_("Only TI and ARM unwinders are currently supported\n"));
9490 word
= (word
& ~ (bfd_vma
) 0x7fffffff) | (prelval
& 0x7fffffff);
9491 addr
->section
= sym
->st_shndx
;
9492 addr
->offset
= offset
;
9495 * sym_name
= sym
->st_name
;
9500 arm_sec
->next_rela
= rp
;
9505 static const char *tic6x_unwind_regnames
[16] =
9507 "A15", "B15", "B14", "B13", "B12", "B11", "B10", "B3",
9508 "A14", "A13", "A12", "A11", "A10",
9509 "[invalid reg 13]", "[invalid reg 14]", "[invalid reg 15]"
9513 decode_tic6x_unwind_regmask (unsigned int mask
)
9517 for (i
= 12; mask
; mask
>>= 1, i
--)
9521 fputs (tic6x_unwind_regnames
[i
], stdout
);
9523 fputs (", ", stdout
);
9529 if (remaining == 0 && more_words) \
9532 if (! get_unwind_section_word (filedata, aux, data_arm_sec, data_sec, \
9533 data_offset, & word, & addr, NULL)) \
9539 #define GET_OP(OP) \
9544 (OP) = word >> 24; \
9549 printf (_("[Truncated opcode]\n")); \
9552 printf ("0x%02x ", OP)
9555 decode_arm_unwind_bytecode (Filedata
* filedata
,
9556 struct arm_unw_aux_info
* aux
,
9558 unsigned int remaining
,
9559 unsigned int more_words
,
9560 bfd_vma data_offset
,
9561 Elf_Internal_Shdr
* data_sec
,
9562 struct arm_section
* data_arm_sec
)
9564 struct absaddr addr
;
9567 /* Decode the unwinding instructions. */
9570 unsigned int op
, op2
;
9579 printf (" 0x%02x ", op
);
9581 if ((op
& 0xc0) == 0x00)
9583 int offset
= ((op
& 0x3f) << 2) + 4;
9585 printf (" vsp = vsp + %d", offset
);
9587 else if ((op
& 0xc0) == 0x40)
9589 int offset
= ((op
& 0x3f) << 2) + 4;
9591 printf (" vsp = vsp - %d", offset
);
9593 else if ((op
& 0xf0) == 0x80)
9596 if (op
== 0x80 && op2
== 0)
9597 printf (_("Refuse to unwind"));
9600 unsigned int mask
= ((op
& 0x0f) << 8) | op2
;
9605 for (i
= 0; i
< 12; i
++)
9606 if (mask
& (1 << i
))
9612 printf ("r%d", 4 + i
);
9617 else if ((op
& 0xf0) == 0x90)
9619 if (op
== 0x9d || op
== 0x9f)
9620 printf (_(" [Reserved]"));
9622 printf (" vsp = r%d", op
& 0x0f);
9624 else if ((op
& 0xf0) == 0xa0)
9626 int end
= 4 + (op
& 0x07);
9631 for (i
= 4; i
<= end
; i
++)
9647 else if (op
== 0xb0)
9648 printf (_(" finish"));
9649 else if (op
== 0xb1)
9652 if (op2
== 0 || (op2
& 0xf0) != 0)
9653 printf (_("[Spare]"));
9656 unsigned int mask
= op2
& 0x0f;
9661 for (i
= 0; i
< 12; i
++)
9662 if (mask
& (1 << i
))
9673 else if (op
== 0xb2)
9675 unsigned char buf
[9];
9676 unsigned int i
, len
;
9677 unsigned long offset
;
9679 for (i
= 0; i
< sizeof (buf
); i
++)
9682 if ((buf
[i
] & 0x80) == 0)
9685 if (i
== sizeof (buf
))
9687 error (_("corrupt change to vsp\n"));
9692 offset
= read_leb128 (buf
, buf
+ i
+ 1, false, &len
, NULL
);
9693 assert (len
== i
+ 1);
9694 offset
= offset
* 4 + 0x204;
9695 printf ("vsp = vsp + %ld", offset
);
9698 else if (op
== 0xb3 || op
== 0xc8 || op
== 0xc9)
9700 unsigned int first
, last
;
9707 printf ("pop {D%d", first
);
9709 printf ("-D%d", first
+ last
);
9712 else if (op
== 0xb4)
9713 printf (_(" pop {ra_auth_code}"));
9714 else if ((op
& 0xf8) == 0xb8 || (op
& 0xf8) == 0xd0)
9716 unsigned int count
= op
& 0x07;
9720 printf ("-D%d", 8 + count
);
9723 else if (op
>= 0xc0 && op
<= 0xc5)
9725 unsigned int count
= op
& 0x07;
9727 printf (" pop {wR10");
9729 printf ("-wR%d", 10 + count
);
9732 else if (op
== 0xc6)
9734 unsigned int first
, last
;
9739 printf ("pop {wR%d", first
);
9741 printf ("-wR%d", first
+ last
);
9744 else if (op
== 0xc7)
9747 if (op2
== 0 || (op2
& 0xf0) != 0)
9748 printf (_("[Spare]"));
9751 unsigned int mask
= op2
& 0x0f;
9756 for (i
= 0; i
< 4; i
++)
9757 if (mask
& (1 << i
))
9763 printf ("wCGR%d", i
);
9770 printf (_(" [unsupported opcode]"));
9781 decode_tic6x_unwind_bytecode (Filedata
* filedata
,
9782 struct arm_unw_aux_info
* aux
,
9784 unsigned int remaining
,
9785 unsigned int more_words
,
9786 bfd_vma data_offset
,
9787 Elf_Internal_Shdr
* data_sec
,
9788 struct arm_section
* data_arm_sec
)
9790 struct absaddr addr
;
9792 /* Decode the unwinding instructions. */
9795 unsigned int op
, op2
;
9804 printf (" 0x%02x ", op
);
9806 if ((op
& 0xc0) == 0x00)
9808 int offset
= ((op
& 0x3f) << 3) + 8;
9809 printf (" sp = sp + %d", offset
);
9811 else if ((op
& 0xc0) == 0x80)
9814 if (op
== 0x80 && op2
== 0)
9815 printf (_("Refuse to unwind"));
9818 unsigned int mask
= ((op
& 0x1f) << 8) | op2
;
9820 printf ("pop compact {");
9824 decode_tic6x_unwind_regmask (mask
);
9828 else if ((op
& 0xf0) == 0xc0)
9836 unsigned int offset
;
9840 /* Scan entire instruction first so that GET_OP output is not
9841 interleaved with disassembly. */
9843 for (i
= 0; nregs
< (op
& 0xf); i
++)
9849 regpos
[nregs
].offset
= i
* 2;
9850 regpos
[nregs
].reg
= reg
;
9857 regpos
[nregs
].offset
= i
* 2 + 1;
9858 regpos
[nregs
].reg
= reg
;
9863 printf (_("pop frame {"));
9866 printf (_("*corrupt* - no registers specified"));
9871 for (i
= i
* 2; i
> 0; i
--)
9873 if (regpos
[reg
].offset
== i
- 1)
9875 name
= tic6x_unwind_regnames
[regpos
[reg
].reg
];
9882 fputs (name
, stdout
);
9890 else if (op
== 0xd0)
9891 printf (" MOV FP, SP");
9892 else if (op
== 0xd1)
9893 printf (" __c6xabi_pop_rts");
9894 else if (op
== 0xd2)
9896 unsigned char buf
[9];
9897 unsigned int i
, len
;
9898 unsigned long offset
;
9900 for (i
= 0; i
< sizeof (buf
); i
++)
9903 if ((buf
[i
] & 0x80) == 0)
9906 /* PR 17531: file: id:000001,src:001906+004739,op:splice,rep:2. */
9907 if (i
== sizeof (buf
))
9909 warn (_("Corrupt stack pointer adjustment detected\n"));
9913 offset
= read_leb128 (buf
, buf
+ i
+ 1, false, &len
, NULL
);
9914 assert (len
== i
+ 1);
9915 offset
= offset
* 8 + 0x408;
9916 printf (_("sp = sp + %ld"), offset
);
9918 else if ((op
& 0xf0) == 0xe0)
9920 if ((op
& 0x0f) == 7)
9923 printf (" MV %s, B3", tic6x_unwind_regnames
[op
& 0x0f]);
9927 printf (_(" [unsupported opcode]"));
9936 arm_expand_prel31 (Filedata
* filedata
, bfd_vma word
, bfd_vma where
)
9940 offset
= word
& 0x7fffffff;
9941 if (offset
& 0x40000000)
9942 offset
|= ~ (bfd_vma
) 0x7fffffff;
9944 if (filedata
->file_header
.e_machine
== EM_TI_C6000
)
9947 return offset
+ where
;
9951 decode_arm_unwind (Filedata
* filedata
,
9952 struct arm_unw_aux_info
* aux
,
9954 unsigned int remaining
,
9955 bfd_vma data_offset
,
9956 Elf_Internal_Shdr
* data_sec
,
9957 struct arm_section
* data_arm_sec
)
9960 unsigned int more_words
= 0;
9961 struct absaddr addr
;
9962 bfd_vma sym_name
= (bfd_vma
) -1;
9967 /* Fetch the first word.
9968 Note - when decoding an object file the address extracted
9969 here will always be 0. So we also pass in the sym_name
9970 parameter so that we can find the symbol associated with
9971 the personality routine. */
9972 if (! get_unwind_section_word (filedata
, aux
, data_arm_sec
, data_sec
, data_offset
,
9973 & word
, & addr
, & sym_name
))
9980 addr
.section
= SHN_UNDEF
;
9984 if ((word
& 0x80000000) == 0)
9986 /* Expand prel31 for personality routine. */
9988 const char *procname
;
9990 fn
= arm_expand_prel31 (filedata
, word
, data_sec
->sh_addr
+ data_offset
);
9991 printf (_(" Personality routine: "));
9993 && addr
.section
== SHN_UNDEF
&& addr
.offset
== 0
9994 && sym_name
!= (bfd_vma
) -1 && sym_name
< aux
->strtab_size
)
9996 procname
= aux
->strtab
+ sym_name
;
9997 print_vma (fn
, PREFIX_HEX
);
10000 fputs (" <", stdout
);
10001 fputs (procname
, stdout
);
10002 fputc ('>', stdout
);
10006 procname
= arm_print_vma_and_name (filedata
, aux
, fn
, addr
);
10007 fputc ('\n', stdout
);
10009 /* The GCC personality routines use the standard compact
10010 encoding, starting with one byte giving the number of
10012 if (procname
!= NULL
10013 && (startswith (procname
, "__gcc_personality_v0")
10014 || startswith (procname
, "__gxx_personality_v0")
10015 || startswith (procname
, "__gcj_personality_v0")
10016 || startswith (procname
, "__gnu_objc_personality_v0")))
10023 printf (_(" [Truncated data]\n"));
10026 more_words
= word
>> 24;
10036 /* ARM EHABI Section 6.3:
10038 An exception-handling table entry for the compact model looks like:
10040 31 30-28 27-24 23-0
10041 -- ----- ----- ----
10042 1 0 index Data for personalityRoutine[index] */
10044 if (filedata
->file_header
.e_machine
== EM_ARM
10045 && (word
& 0x70000000))
10047 warn (_("Corrupt ARM compact model table entry: %x \n"), word
);
10051 per_index
= (word
>> 24) & 0x7f;
10052 printf (_(" Compact model index: %d\n"), per_index
);
10053 if (per_index
== 0)
10059 else if (per_index
< 3)
10061 more_words
= (word
>> 16) & 0xff;
10067 switch (filedata
->file_header
.e_machine
)
10072 if (! decode_arm_unwind_bytecode (filedata
, aux
, word
, remaining
, more_words
,
10073 data_offset
, data_sec
, data_arm_sec
))
10078 warn (_("Unknown ARM compact model index encountered\n"));
10079 printf (_(" [reserved]\n"));
10087 if (! decode_tic6x_unwind_bytecode (filedata
, aux
, word
, remaining
, more_words
,
10088 data_offset
, data_sec
, data_arm_sec
))
10091 else if (per_index
< 5)
10093 if (((word
>> 17) & 0x7f) == 0x7f)
10094 printf (_(" Restore stack from frame pointer\n"));
10096 printf (_(" Stack increment %d\n"), (word
>> 14) & 0x1fc);
10097 printf (_(" Registers restored: "));
10098 if (per_index
== 4)
10099 printf (" (compact) ");
10100 decode_tic6x_unwind_regmask ((word
>> 4) & 0x1fff);
10102 printf (_(" Return register: %s\n"),
10103 tic6x_unwind_regnames
[word
& 0xf]);
10106 printf (_(" [reserved (%d)]\n"), per_index
);
10110 error (_("Unsupported architecture type %d encountered when decoding unwind table\n"),
10111 filedata
->file_header
.e_machine
);
10115 /* Decode the descriptors. Not implemented. */
10121 dump_arm_unwind (Filedata
* filedata
,
10122 struct arm_unw_aux_info
* aux
,
10123 Elf_Internal_Shdr
* exidx_sec
)
10125 struct arm_section exidx_arm_sec
, extab_arm_sec
;
10126 unsigned int i
, exidx_len
;
10127 unsigned long j
, nfuns
;
10130 memset (&exidx_arm_sec
, 0, sizeof (exidx_arm_sec
));
10131 memset (&extab_arm_sec
, 0, sizeof (extab_arm_sec
));
10132 exidx_len
= exidx_sec
->sh_size
/ 8;
10134 aux
->funtab
= xmalloc (aux
->nsyms
* sizeof (Elf_Internal_Sym
));
10135 for (nfuns
= 0, j
= 0; j
< aux
->nsyms
; j
++)
10136 if (aux
->symtab
[j
].st_value
&& ELF_ST_TYPE (aux
->symtab
[j
].st_info
) == STT_FUNC
)
10137 aux
->funtab
[nfuns
++] = aux
->symtab
[j
];
10138 aux
->nfuns
= nfuns
;
10139 qsort (aux
->funtab
, aux
->nfuns
, sizeof (Elf_Internal_Sym
), symcmp
);
10141 for (i
= 0; i
< exidx_len
; i
++)
10143 unsigned int exidx_fn
, exidx_entry
;
10144 struct absaddr fn_addr
, entry_addr
;
10147 fputc ('\n', stdout
);
10149 if (! get_unwind_section_word (filedata
, aux
, & exidx_arm_sec
, exidx_sec
,
10150 8 * i
, & exidx_fn
, & fn_addr
, NULL
)
10151 || ! get_unwind_section_word (filedata
, aux
, & exidx_arm_sec
, exidx_sec
,
10152 8 * i
+ 4, & exidx_entry
, & entry_addr
, NULL
))
10154 free (aux
->funtab
);
10155 arm_free_section (& exidx_arm_sec
);
10156 arm_free_section (& extab_arm_sec
);
10160 /* ARM EHABI, Section 5:
10161 An index table entry consists of 2 words.
10162 The first word contains a prel31 offset to the start of a function, with bit 31 clear. */
10163 if (exidx_fn
& 0x80000000)
10165 warn (_("corrupt index table entry: %x\n"), exidx_fn
);
10169 fn
= arm_expand_prel31 (filedata
, exidx_fn
, exidx_sec
->sh_addr
+ 8 * i
);
10171 arm_print_vma_and_name (filedata
, aux
, fn
, fn_addr
);
10172 fputs (": ", stdout
);
10174 if (exidx_entry
== 1)
10176 print_vma (exidx_entry
, PREFIX_HEX
);
10177 fputs (" [cantunwind]\n", stdout
);
10179 else if (exidx_entry
& 0x80000000)
10181 print_vma (exidx_entry
, PREFIX_HEX
);
10182 fputc ('\n', stdout
);
10183 decode_arm_unwind (filedata
, aux
, exidx_entry
, 4, 0, NULL
, NULL
);
10187 bfd_vma table
, table_offset
= 0;
10188 Elf_Internal_Shdr
*table_sec
;
10190 fputs ("@", stdout
);
10191 table
= arm_expand_prel31 (filedata
, exidx_entry
, exidx_sec
->sh_addr
+ 8 * i
+ 4);
10192 print_vma (table
, PREFIX_HEX
);
10195 /* Locate the matching .ARM.extab. */
10196 if (entry_addr
.section
!= SHN_UNDEF
10197 && entry_addr
.section
< filedata
->file_header
.e_shnum
)
10199 table_sec
= filedata
->section_headers
+ entry_addr
.section
;
10200 table_offset
= entry_addr
.offset
;
10202 if (table_offset
> table_sec
->sh_size
10203 || ((bfd_signed_vma
) table_offset
) < 0)
10205 warn (_("Unwind entry contains corrupt offset (0x%lx) into section %s\n"),
10206 (unsigned long) table_offset
,
10207 printable_section_name (filedata
, table_sec
));
10214 table_sec
= find_section_by_address (filedata
, table
);
10215 if (table_sec
!= NULL
)
10216 table_offset
= table
- table_sec
->sh_addr
;
10219 if (table_sec
== NULL
)
10221 warn (_("Could not locate .ARM.extab section containing 0x%lx.\n"),
10222 (unsigned long) table
);
10227 if (! decode_arm_unwind (filedata
, aux
, 0, 0, table_offset
, table_sec
,
10235 free (aux
->funtab
);
10236 arm_free_section (&exidx_arm_sec
);
10237 arm_free_section (&extab_arm_sec
);
10242 /* Used for both ARM and C6X unwinding tables. */
10245 arm_process_unwind (Filedata
* filedata
)
10247 struct arm_unw_aux_info aux
;
10248 Elf_Internal_Shdr
*unwsec
= NULL
;
10249 Elf_Internal_Shdr
*sec
;
10251 unsigned int sec_type
;
10254 switch (filedata
->file_header
.e_machine
)
10257 sec_type
= SHT_ARM_EXIDX
;
10261 sec_type
= SHT_C6000_UNWIND
;
10265 error (_("Unsupported architecture type %d encountered when processing unwind table\n"),
10266 filedata
->file_header
.e_machine
);
10270 if (filedata
->string_table
== NULL
)
10273 memset (& aux
, 0, sizeof (aux
));
10274 aux
.filedata
= filedata
;
10276 for (i
= 0, sec
= filedata
->section_headers
; i
< filedata
->file_header
.e_shnum
; ++i
, ++sec
)
10278 if (sec
->sh_type
== SHT_SYMTAB
)
10282 error (_("Multiple symbol tables encountered\n"));
10288 if (!get_symtab (filedata
, sec
, &aux
.symtab
, &aux
.nsyms
,
10289 &aux
.strtab
, &aux
.strtab_size
))
10292 else if (sec
->sh_type
== sec_type
)
10296 if (unwsec
== NULL
)
10297 printf (_("\nThere are no unwind sections in this file.\n"));
10299 for (i
= 0, sec
= filedata
->section_headers
; i
< filedata
->file_header
.e_shnum
; ++i
, ++sec
)
10301 if (sec
->sh_type
== sec_type
)
10303 unsigned long num_unwind
= sec
->sh_size
/ (2 * eh_addr_size
);
10304 printf (ngettext ("\nUnwind section '%s' at offset 0x%lx "
10305 "contains %lu entry:\n",
10306 "\nUnwind section '%s' at offset 0x%lx "
10307 "contains %lu entries:\n",
10309 printable_section_name (filedata
, sec
),
10310 (unsigned long) sec
->sh_offset
,
10313 if (! dump_arm_unwind (filedata
, &aux
, sec
))
10319 free ((char *) aux
.strtab
);
10325 no_processor_specific_unwind (Filedata
* filedata ATTRIBUTE_UNUSED
)
10327 printf (_("No processor specific unwind information to decode\n"));
10332 process_unwind (Filedata
* filedata
)
10334 struct unwind_handler
10336 unsigned int machtype
;
10337 bool (* handler
)(Filedata
*);
10340 { EM_ARM
, arm_process_unwind
},
10341 { EM_IA_64
, ia64_process_unwind
},
10342 { EM_PARISC
, hppa_process_unwind
},
10343 { EM_TI_C6000
, arm_process_unwind
},
10344 { EM_386
, no_processor_specific_unwind
},
10345 { EM_X86_64
, no_processor_specific_unwind
},
10353 for (i
= 0; handlers
[i
].handler
!= NULL
; i
++)
10354 if (filedata
->file_header
.e_machine
== handlers
[i
].machtype
)
10355 return handlers
[i
].handler (filedata
);
10357 printf (_("\nThe decoding of unwind sections for machine type %s is not currently supported.\n"),
10358 get_machine_name (filedata
->file_header
.e_machine
));
10363 dynamic_section_aarch64_val (Elf_Internal_Dyn
* entry
)
10365 switch (entry
->d_tag
)
10367 case DT_AARCH64_BTI_PLT
:
10368 case DT_AARCH64_PAC_PLT
:
10371 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
10378 dynamic_section_mips_val (Filedata
* filedata
, Elf_Internal_Dyn
* entry
)
10380 switch (entry
->d_tag
)
10382 case DT_MIPS_FLAGS
:
10383 if (entry
->d_un
.d_val
== 0)
10384 printf (_("NONE"));
10387 static const char * opts
[] =
10389 "QUICKSTART", "NOTPOT", "NO_LIBRARY_REPLACEMENT",
10390 "NO_MOVE", "SGI_ONLY", "GUARANTEE_INIT", "DELTA_C_PLUS_PLUS",
10391 "GUARANTEE_START_INIT", "PIXIE", "DEFAULT_DELAY_LOAD",
10392 "REQUICKSTART", "REQUICKSTARTED", "CORD", "NO_UNRES_UNDEF",
10398 for (cnt
= 0; cnt
< ARRAY_SIZE (opts
); ++cnt
)
10399 if (entry
->d_un
.d_val
& (1 << cnt
))
10401 printf ("%s%s", first
? "" : " ", opts
[cnt
]);
10407 case DT_MIPS_IVERSION
:
10408 if (valid_dynamic_name (filedata
, entry
->d_un
.d_val
))
10409 printf (_("Interface Version: %s"),
10410 get_dynamic_name (filedata
, entry
->d_un
.d_val
));
10414 sprintf_vma (buf
, entry
->d_un
.d_ptr
);
10415 /* Note: coded this way so that there is a single string for translation. */
10416 printf (_("<corrupt: %s>"), buf
);
10420 case DT_MIPS_TIME_STAMP
:
10424 time_t atime
= entry
->d_un
.d_val
;
10426 tmp
= gmtime (&atime
);
10427 /* PR 17531: file: 6accc532. */
10429 snprintf (timebuf
, sizeof (timebuf
), _("<corrupt>"));
10431 snprintf (timebuf
, sizeof (timebuf
), "%04u-%02u-%02uT%02u:%02u:%02u",
10432 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
10433 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
10434 printf (_("Time Stamp: %s"), timebuf
);
10438 case DT_MIPS_RLD_VERSION
:
10439 case DT_MIPS_LOCAL_GOTNO
:
10440 case DT_MIPS_CONFLICTNO
:
10441 case DT_MIPS_LIBLISTNO
:
10442 case DT_MIPS_SYMTABNO
:
10443 case DT_MIPS_UNREFEXTNO
:
10444 case DT_MIPS_HIPAGENO
:
10445 case DT_MIPS_DELTA_CLASS_NO
:
10446 case DT_MIPS_DELTA_INSTANCE_NO
:
10447 case DT_MIPS_DELTA_RELOC_NO
:
10448 case DT_MIPS_DELTA_SYM_NO
:
10449 case DT_MIPS_DELTA_CLASSSYM_NO
:
10450 case DT_MIPS_COMPACT_SIZE
:
10451 print_vma (entry
->d_un
.d_val
, DEC
);
10454 case DT_MIPS_XHASH
:
10455 filedata
->dynamic_info_DT_MIPS_XHASH
= entry
->d_un
.d_val
;
10456 filedata
->dynamic_info_DT_GNU_HASH
= entry
->d_un
.d_val
;
10457 /* Falls through. */
10460 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
10466 dynamic_section_parisc_val (Elf_Internal_Dyn
* entry
)
10468 switch (entry
->d_tag
)
10470 case DT_HP_DLD_FLAGS
:
10479 { DT_HP_DEBUG_PRIVATE
, "HP_DEBUG_PRIVATE" },
10480 { DT_HP_DEBUG_CALLBACK
, "HP_DEBUG_CALLBACK" },
10481 { DT_HP_DEBUG_CALLBACK_BOR
, "HP_DEBUG_CALLBACK_BOR" },
10482 { DT_HP_NO_ENVVAR
, "HP_NO_ENVVAR" },
10483 { DT_HP_BIND_NOW
, "HP_BIND_NOW" },
10484 { DT_HP_BIND_NONFATAL
, "HP_BIND_NONFATAL" },
10485 { DT_HP_BIND_VERBOSE
, "HP_BIND_VERBOSE" },
10486 { DT_HP_BIND_RESTRICTED
, "HP_BIND_RESTRICTED" },
10487 { DT_HP_BIND_SYMBOLIC
, "HP_BIND_SYMBOLIC" },
10488 { DT_HP_RPATH_FIRST
, "HP_RPATH_FIRST" },
10489 { DT_HP_BIND_DEPTH_FIRST
, "HP_BIND_DEPTH_FIRST" },
10490 { DT_HP_GST
, "HP_GST" },
10491 { DT_HP_SHLIB_FIXED
, "HP_SHLIB_FIXED" },
10492 { DT_HP_MERGE_SHLIB_SEG
, "HP_MERGE_SHLIB_SEG" },
10493 { DT_HP_NODELETE
, "HP_NODELETE" },
10494 { DT_HP_GROUP
, "HP_GROUP" },
10495 { DT_HP_PROTECT_LINKAGE_TABLE
, "HP_PROTECT_LINKAGE_TABLE" }
10499 bfd_vma val
= entry
->d_un
.d_val
;
10501 for (cnt
= 0; cnt
< ARRAY_SIZE (flags
); ++cnt
)
10502 if (val
& flags
[cnt
].bit
)
10506 fputs (flags
[cnt
].str
, stdout
);
10508 val
^= flags
[cnt
].bit
;
10511 if (val
!= 0 || first
)
10515 print_vma (val
, HEX
);
10521 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
10529 /* VMS vs Unix time offset and factor. */
10531 #define VMS_EPOCH_OFFSET 35067168000000000LL
10532 #define VMS_GRANULARITY_FACTOR 10000000
10534 #define INT64_MIN (-9223372036854775807LL - 1)
10537 /* Display a VMS time in a human readable format. */
10540 print_vms_time (bfd_int64_t vmstime
)
10542 struct tm
*tm
= NULL
;
10545 if (vmstime
>= INT64_MIN
+ VMS_EPOCH_OFFSET
)
10547 vmstime
= (vmstime
- VMS_EPOCH_OFFSET
) / VMS_GRANULARITY_FACTOR
;
10549 if (unxtime
== vmstime
)
10550 tm
= gmtime (&unxtime
);
10553 printf ("%04u-%02u-%02uT%02u:%02u:%02u",
10554 tm
->tm_year
+ 1900, tm
->tm_mon
+ 1, tm
->tm_mday
,
10555 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
10560 dynamic_section_ia64_val (Elf_Internal_Dyn
* entry
)
10562 switch (entry
->d_tag
)
10564 case DT_IA_64_PLT_RESERVE
:
10565 /* First 3 slots reserved. */
10566 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
10568 print_vma (entry
->d_un
.d_ptr
+ (3 * 8), PREFIX_HEX
);
10571 case DT_IA_64_VMS_LINKTIME
:
10573 print_vms_time (entry
->d_un
.d_val
);
10577 case DT_IA_64_VMS_LNKFLAGS
:
10578 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
10579 if (entry
->d_un
.d_val
& VMS_LF_CALL_DEBUG
)
10580 printf (" CALL_DEBUG");
10581 if (entry
->d_un
.d_val
& VMS_LF_NOP0BUFS
)
10582 printf (" NOP0BUFS");
10583 if (entry
->d_un
.d_val
& VMS_LF_P0IMAGE
)
10584 printf (" P0IMAGE");
10585 if (entry
->d_un
.d_val
& VMS_LF_MKTHREADS
)
10586 printf (" MKTHREADS");
10587 if (entry
->d_un
.d_val
& VMS_LF_UPCALLS
)
10588 printf (" UPCALLS");
10589 if (entry
->d_un
.d_val
& VMS_LF_IMGSTA
)
10590 printf (" IMGSTA");
10591 if (entry
->d_un
.d_val
& VMS_LF_INITIALIZE
)
10592 printf (" INITIALIZE");
10593 if (entry
->d_un
.d_val
& VMS_LF_MAIN
)
10595 if (entry
->d_un
.d_val
& VMS_LF_EXE_INIT
)
10596 printf (" EXE_INIT");
10597 if (entry
->d_un
.d_val
& VMS_LF_TBK_IN_IMG
)
10598 printf (" TBK_IN_IMG");
10599 if (entry
->d_un
.d_val
& VMS_LF_DBG_IN_IMG
)
10600 printf (" DBG_IN_IMG");
10601 if (entry
->d_un
.d_val
& VMS_LF_TBK_IN_DSF
)
10602 printf (" TBK_IN_DSF");
10603 if (entry
->d_un
.d_val
& VMS_LF_DBG_IN_DSF
)
10604 printf (" DBG_IN_DSF");
10605 if (entry
->d_un
.d_val
& VMS_LF_SIGNATURES
)
10606 printf (" SIGNATURES");
10607 if (entry
->d_un
.d_val
& VMS_LF_REL_SEG_OFF
)
10608 printf (" REL_SEG_OFF");
10612 print_vma (entry
->d_un
.d_ptr
, PREFIX_HEX
);
10619 get_32bit_dynamic_section (Filedata
* filedata
)
10621 Elf32_External_Dyn
* edyn
;
10622 Elf32_External_Dyn
* ext
;
10623 Elf_Internal_Dyn
* entry
;
10625 edyn
= (Elf32_External_Dyn
*) get_data (NULL
, filedata
,
10626 filedata
->dynamic_addr
, 1,
10627 filedata
->dynamic_size
,
10628 _("dynamic section"));
10632 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
10633 might not have the luxury of section headers. Look for the DT_NULL
10634 terminator to determine the number of entries. */
10635 for (ext
= edyn
, filedata
->dynamic_nent
= 0;
10636 (char *) (ext
+ 1) <= (char *) edyn
+ filedata
->dynamic_size
;
10639 filedata
->dynamic_nent
++;
10640 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
10644 filedata
->dynamic_section
10645 = (Elf_Internal_Dyn
*) cmalloc (filedata
->dynamic_nent
, sizeof (* entry
));
10646 if (filedata
->dynamic_section
== NULL
)
10648 error (_("Out of memory allocating space for %lu dynamic entries\n"),
10649 (unsigned long) filedata
->dynamic_nent
);
10654 for (ext
= edyn
, entry
= filedata
->dynamic_section
;
10655 entry
< filedata
->dynamic_section
+ filedata
->dynamic_nent
;
10658 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
10659 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
10668 get_64bit_dynamic_section (Filedata
* filedata
)
10670 Elf64_External_Dyn
* edyn
;
10671 Elf64_External_Dyn
* ext
;
10672 Elf_Internal_Dyn
* entry
;
10674 /* Read in the data. */
10675 edyn
= (Elf64_External_Dyn
*) get_data (NULL
, filedata
,
10676 filedata
->dynamic_addr
, 1,
10677 filedata
->dynamic_size
,
10678 _("dynamic section"));
10682 /* SGI's ELF has more than one section in the DYNAMIC segment, and we
10683 might not have the luxury of section headers. Look for the DT_NULL
10684 terminator to determine the number of entries. */
10685 for (ext
= edyn
, filedata
->dynamic_nent
= 0;
10686 /* PR 17533 file: 033-67080-0.004 - do not read past end of buffer. */
10687 (char *) (ext
+ 1) <= (char *) edyn
+ filedata
->dynamic_size
;
10690 filedata
->dynamic_nent
++;
10691 if (BYTE_GET (ext
->d_tag
) == DT_NULL
)
10695 filedata
->dynamic_section
10696 = (Elf_Internal_Dyn
*) cmalloc (filedata
->dynamic_nent
, sizeof (* entry
));
10697 if (filedata
->dynamic_section
== NULL
)
10699 error (_("Out of memory allocating space for %lu dynamic entries\n"),
10700 (unsigned long) filedata
->dynamic_nent
);
10705 /* Convert from external to internal formats. */
10706 for (ext
= edyn
, entry
= filedata
->dynamic_section
;
10707 entry
< filedata
->dynamic_section
+ filedata
->dynamic_nent
;
10710 entry
->d_tag
= BYTE_GET (ext
->d_tag
);
10711 entry
->d_un
.d_val
= BYTE_GET (ext
->d_un
.d_val
);
10720 get_dynamic_section (Filedata
*filedata
)
10722 if (filedata
->dynamic_section
)
10726 return get_32bit_dynamic_section (filedata
);
10728 return get_64bit_dynamic_section (filedata
);
10732 print_dynamic_flags (bfd_vma flags
)
10740 flag
= flags
& - flags
;
10746 putc (' ', stdout
);
10750 case DF_ORIGIN
: fputs ("ORIGIN", stdout
); break;
10751 case DF_SYMBOLIC
: fputs ("SYMBOLIC", stdout
); break;
10752 case DF_TEXTREL
: fputs ("TEXTREL", stdout
); break;
10753 case DF_BIND_NOW
: fputs ("BIND_NOW", stdout
); break;
10754 case DF_STATIC_TLS
: fputs ("STATIC_TLS", stdout
); break;
10755 default: fputs (_("unknown"), stdout
); break;
10762 get_dynamic_data (Filedata
* filedata
, bfd_size_type number
, unsigned int ent_size
)
10764 unsigned char * e_data
;
10767 /* If the size_t type is smaller than the bfd_size_type, eg because
10768 you are building a 32-bit tool on a 64-bit host, then make sure
10769 that when (number) is cast to (size_t) no information is lost. */
10770 if (sizeof (size_t) < sizeof (bfd_size_type
)
10771 && (bfd_size_type
) ((size_t) number
) != number
)
10773 error (_("Size truncation prevents reading %s elements of size %u\n"),
10774 bfd_vmatoa ("u", number
), ent_size
);
10778 /* Be kind to memory checkers (eg valgrind, address sanitizer) by not
10779 attempting to allocate memory when the read is bound to fail. */
10780 if (ent_size
* number
> filedata
->file_size
)
10782 error (_("Invalid number of dynamic entries: %s\n"),
10783 bfd_vmatoa ("u", number
));
10787 e_data
= (unsigned char *) cmalloc ((size_t) number
, ent_size
);
10788 if (e_data
== NULL
)
10790 error (_("Out of memory reading %s dynamic entries\n"),
10791 bfd_vmatoa ("u", number
));
10795 if (fread (e_data
, ent_size
, (size_t) number
, filedata
->handle
) != number
)
10797 error (_("Unable to read in %s bytes of dynamic data\n"),
10798 bfd_vmatoa ("u", number
* ent_size
));
10803 i_data
= (bfd_vma
*) cmalloc ((size_t) number
, sizeof (*i_data
));
10804 if (i_data
== NULL
)
10806 error (_("Out of memory allocating space for %s dynamic entries\n"),
10807 bfd_vmatoa ("u", number
));
10813 i_data
[number
] = byte_get (e_data
+ number
* ent_size
, ent_size
);
10820 static unsigned long
10821 get_num_dynamic_syms (Filedata
* filedata
)
10823 unsigned long num_of_syms
= 0;
10825 if (!do_histogram
&& (!do_using_dynamic
|| do_dyn_syms
))
10826 return num_of_syms
;
10828 if (filedata
->dynamic_info
[DT_HASH
])
10830 unsigned char nb
[8];
10831 unsigned char nc
[8];
10832 unsigned int hash_ent_size
= 4;
10834 if ((filedata
->file_header
.e_machine
== EM_ALPHA
10835 || filedata
->file_header
.e_machine
== EM_S390
10836 || filedata
->file_header
.e_machine
== EM_S390_OLD
)
10837 && filedata
->file_header
.e_ident
[EI_CLASS
] == ELFCLASS64
)
10840 if (fseek (filedata
->handle
,
10841 (filedata
->archive_file_offset
10842 + offset_from_vma (filedata
, filedata
->dynamic_info
[DT_HASH
],
10843 sizeof nb
+ sizeof nc
)),
10846 error (_("Unable to seek to start of dynamic information\n"));
10850 if (fread (nb
, hash_ent_size
, 1, filedata
->handle
) != 1)
10852 error (_("Failed to read in number of buckets\n"));
10856 if (fread (nc
, hash_ent_size
, 1, filedata
->handle
) != 1)
10858 error (_("Failed to read in number of chains\n"));
10862 filedata
->nbuckets
= byte_get (nb
, hash_ent_size
);
10863 filedata
->nchains
= byte_get (nc
, hash_ent_size
);
10865 if (filedata
->nbuckets
!= 0 && filedata
->nchains
!= 0)
10867 filedata
->buckets
= get_dynamic_data (filedata
, filedata
->nbuckets
,
10869 filedata
->chains
= get_dynamic_data (filedata
, filedata
->nchains
,
10872 if (filedata
->buckets
!= NULL
&& filedata
->chains
!= NULL
)
10873 num_of_syms
= filedata
->nchains
;
10876 if (num_of_syms
== 0)
10878 free (filedata
->buckets
);
10879 filedata
->buckets
= NULL
;
10880 free (filedata
->chains
);
10881 filedata
->chains
= NULL
;
10882 filedata
->nbuckets
= 0;
10886 if (filedata
->dynamic_info_DT_GNU_HASH
)
10888 unsigned char nb
[16];
10889 bfd_vma i
, maxchain
= 0xffffffff, bitmaskwords
;
10890 bfd_vma buckets_vma
;
10893 if (fseek (filedata
->handle
,
10894 (filedata
->archive_file_offset
10895 + offset_from_vma (filedata
,
10896 filedata
->dynamic_info_DT_GNU_HASH
,
10900 error (_("Unable to seek to start of dynamic information\n"));
10904 if (fread (nb
, 16, 1, filedata
->handle
) != 1)
10906 error (_("Failed to read in number of buckets\n"));
10910 filedata
->ngnubuckets
= byte_get (nb
, 4);
10911 filedata
->gnusymidx
= byte_get (nb
+ 4, 4);
10912 bitmaskwords
= byte_get (nb
+ 8, 4);
10913 buckets_vma
= filedata
->dynamic_info_DT_GNU_HASH
+ 16;
10915 buckets_vma
+= bitmaskwords
* 4;
10917 buckets_vma
+= bitmaskwords
* 8;
10919 if (fseek (filedata
->handle
,
10920 (filedata
->archive_file_offset
10921 + offset_from_vma (filedata
, buckets_vma
, 4)),
10924 error (_("Unable to seek to start of dynamic information\n"));
10928 filedata
->gnubuckets
10929 = get_dynamic_data (filedata
, filedata
->ngnubuckets
, 4);
10931 if (filedata
->gnubuckets
== NULL
)
10934 for (i
= 0; i
< filedata
->ngnubuckets
; i
++)
10935 if (filedata
->gnubuckets
[i
] != 0)
10937 if (filedata
->gnubuckets
[i
] < filedata
->gnusymidx
)
10940 if (maxchain
== 0xffffffff || filedata
->gnubuckets
[i
] > maxchain
)
10941 maxchain
= filedata
->gnubuckets
[i
];
10944 if (maxchain
== 0xffffffff)
10947 maxchain
-= filedata
->gnusymidx
;
10949 if (fseek (filedata
->handle
,
10950 (filedata
->archive_file_offset
10951 + offset_from_vma (filedata
,
10952 buckets_vma
+ 4 * (filedata
->ngnubuckets
10957 error (_("Unable to seek to start of dynamic information\n"));
10963 if (fread (nb
, 4, 1, filedata
->handle
) != 1)
10965 error (_("Failed to determine last chain length\n"));
10969 if (maxchain
+ 1 == 0)
10974 while ((byte_get (nb
, 4) & 1) == 0);
10976 if (fseek (filedata
->handle
,
10977 (filedata
->archive_file_offset
10978 + offset_from_vma (filedata
, (buckets_vma
10979 + 4 * filedata
->ngnubuckets
),
10983 error (_("Unable to seek to start of dynamic information\n"));
10987 filedata
->gnuchains
= get_dynamic_data (filedata
, maxchain
, 4);
10988 filedata
->ngnuchains
= maxchain
;
10990 if (filedata
->gnuchains
== NULL
)
10993 if (filedata
->dynamic_info_DT_MIPS_XHASH
)
10995 if (fseek (filedata
->handle
,
10996 (filedata
->archive_file_offset
10997 + offset_from_vma (filedata
, (buckets_vma
10998 + 4 * (filedata
->ngnubuckets
11002 error (_("Unable to seek to start of dynamic information\n"));
11006 filedata
->mipsxlat
= get_dynamic_data (filedata
, maxchain
, 4);
11007 if (filedata
->mipsxlat
== NULL
)
11011 for (hn
= 0; hn
< filedata
->ngnubuckets
; ++hn
)
11012 if (filedata
->gnubuckets
[hn
] != 0)
11014 bfd_vma si
= filedata
->gnubuckets
[hn
];
11015 bfd_vma off
= si
- filedata
->gnusymidx
;
11019 if (filedata
->dynamic_info_DT_MIPS_XHASH
)
11021 if (off
< filedata
->ngnuchains
11022 && filedata
->mipsxlat
[off
] >= num_of_syms
)
11023 num_of_syms
= filedata
->mipsxlat
[off
] + 1;
11027 if (si
>= num_of_syms
)
11028 num_of_syms
= si
+ 1;
11032 while (off
< filedata
->ngnuchains
11033 && (filedata
->gnuchains
[off
++] & 1) == 0);
11036 if (num_of_syms
== 0)
11039 free (filedata
->mipsxlat
);
11040 filedata
->mipsxlat
= NULL
;
11041 free (filedata
->gnuchains
);
11042 filedata
->gnuchains
= NULL
;
11043 free (filedata
->gnubuckets
);
11044 filedata
->gnubuckets
= NULL
;
11045 filedata
->ngnubuckets
= 0;
11046 filedata
->ngnuchains
= 0;
11050 return num_of_syms
;
11053 /* Parse and display the contents of the dynamic section. */
11056 process_dynamic_section (Filedata
* filedata
)
11058 Elf_Internal_Dyn
* entry
;
11060 if (filedata
->dynamic_size
<= 1)
11064 if (filedata
->is_separate
)
11065 printf (_("\nThere is no dynamic section in linked file '%s'.\n"),
11066 filedata
->file_name
);
11068 printf (_("\nThere is no dynamic section in this file.\n"));
11074 if (!get_dynamic_section (filedata
))
11077 /* Find the appropriate symbol table. */
11078 if (filedata
->dynamic_symbols
== NULL
|| do_histogram
)
11080 unsigned long num_of_syms
;
11082 for (entry
= filedata
->dynamic_section
;
11083 entry
< filedata
->dynamic_section
+ filedata
->dynamic_nent
;
11085 if (entry
->d_tag
== DT_SYMTAB
)
11086 filedata
->dynamic_info
[DT_SYMTAB
] = entry
->d_un
.d_val
;
11087 else if (entry
->d_tag
== DT_SYMENT
)
11088 filedata
->dynamic_info
[DT_SYMENT
] = entry
->d_un
.d_val
;
11089 else if (entry
->d_tag
== DT_HASH
)
11090 filedata
->dynamic_info
[DT_HASH
] = entry
->d_un
.d_val
;
11091 else if (entry
->d_tag
== DT_GNU_HASH
)
11092 filedata
->dynamic_info_DT_GNU_HASH
= entry
->d_un
.d_val
;
11093 else if ((filedata
->file_header
.e_machine
== EM_MIPS
11094 || filedata
->file_header
.e_machine
== EM_MIPS_RS3_LE
)
11095 && entry
->d_tag
== DT_MIPS_XHASH
)
11097 filedata
->dynamic_info_DT_MIPS_XHASH
= entry
->d_un
.d_val
;
11098 filedata
->dynamic_info_DT_GNU_HASH
= entry
->d_un
.d_val
;
11101 num_of_syms
= get_num_dynamic_syms (filedata
);
11103 if (num_of_syms
!= 0
11104 && filedata
->dynamic_symbols
== NULL
11105 && filedata
->dynamic_info
[DT_SYMTAB
]
11106 && filedata
->dynamic_info
[DT_SYMENT
])
11108 Elf_Internal_Phdr
*seg
;
11109 bfd_vma vma
= filedata
->dynamic_info
[DT_SYMTAB
];
11111 if (! get_program_headers (filedata
))
11113 error (_("Cannot interpret virtual addresses "
11114 "without program headers.\n"));
11118 for (seg
= filedata
->program_headers
;
11119 seg
< filedata
->program_headers
+ filedata
->file_header
.e_phnum
;
11122 if (seg
->p_type
!= PT_LOAD
)
11125 if (seg
->p_offset
+ seg
->p_filesz
> filedata
->file_size
)
11127 /* See PR 21379 for a reproducer. */
11128 error (_("Invalid PT_LOAD entry\n"));
11132 if (vma
>= (seg
->p_vaddr
& -seg
->p_align
)
11133 && vma
< seg
->p_vaddr
+ seg
->p_filesz
)
11135 /* Since we do not know how big the symbol table is,
11136 we default to reading in up to the end of PT_LOAD
11137 segment and processing that. This is overkill, I
11138 know, but it should work. */
11139 Elf_Internal_Shdr section
;
11140 section
.sh_offset
= (vma
- seg
->p_vaddr
11142 section
.sh_size
= (num_of_syms
11143 * filedata
->dynamic_info
[DT_SYMENT
]);
11144 section
.sh_entsize
= filedata
->dynamic_info
[DT_SYMENT
];
11147 && filedata
->dynamic_symtab_section
!= NULL
11148 && ((filedata
->dynamic_symtab_section
->sh_offset
11149 != section
.sh_offset
)
11150 || (filedata
->dynamic_symtab_section
->sh_size
11151 != section
.sh_size
)
11152 || (filedata
->dynamic_symtab_section
->sh_entsize
11153 != section
.sh_entsize
)))
11155 the .dynsym section doesn't match the DT_SYMTAB and DT_SYMENT tags\n"));
11157 section
.sh_name
= filedata
->string_table_length
;
11158 filedata
->dynamic_symbols
11159 = get_elf_symbols (filedata
, §ion
,
11160 &filedata
->num_dynamic_syms
);
11161 if (filedata
->dynamic_symbols
== NULL
11162 || filedata
->num_dynamic_syms
!= num_of_syms
)
11164 error (_("Corrupt DT_SYMTAB dynamic entry\n"));
11173 /* Similarly find a string table. */
11174 if (filedata
->dynamic_strings
== NULL
)
11175 for (entry
= filedata
->dynamic_section
;
11176 entry
< filedata
->dynamic_section
+ filedata
->dynamic_nent
;
11179 if (entry
->d_tag
== DT_STRTAB
)
11180 filedata
->dynamic_info
[DT_STRTAB
] = entry
->d_un
.d_val
;
11182 if (entry
->d_tag
== DT_STRSZ
)
11183 filedata
->dynamic_info
[DT_STRSZ
] = entry
->d_un
.d_val
;
11185 if (filedata
->dynamic_info
[DT_STRTAB
]
11186 && filedata
->dynamic_info
[DT_STRSZ
])
11188 unsigned long offset
;
11189 bfd_size_type str_tab_len
= filedata
->dynamic_info
[DT_STRSZ
];
11191 offset
= offset_from_vma (filedata
,
11192 filedata
->dynamic_info
[DT_STRTAB
],
11195 && filedata
->dynamic_strtab_section
11196 && ((filedata
->dynamic_strtab_section
->sh_offset
11197 != (file_ptr
) offset
)
11198 || (filedata
->dynamic_strtab_section
->sh_size
11201 the .dynstr section doesn't match the DT_STRTAB and DT_STRSZ tags\n"));
11203 filedata
->dynamic_strings
11204 = (char *) get_data (NULL
, filedata
, offset
, 1, str_tab_len
,
11205 _("dynamic string table"));
11206 if (filedata
->dynamic_strings
== NULL
)
11208 error (_("Corrupt DT_STRTAB dynamic entry\n"));
11212 filedata
->dynamic_strings_length
= str_tab_len
;
11217 /* And find the syminfo section if available. */
11218 if (filedata
->dynamic_syminfo
== NULL
)
11220 unsigned long syminsz
= 0;
11222 for (entry
= filedata
->dynamic_section
;
11223 entry
< filedata
->dynamic_section
+ filedata
->dynamic_nent
;
11226 if (entry
->d_tag
== DT_SYMINENT
)
11228 /* Note: these braces are necessary to avoid a syntax
11229 error from the SunOS4 C compiler. */
11230 /* PR binutils/17531: A corrupt file can trigger this test.
11231 So do not use an assert, instead generate an error message. */
11232 if (sizeof (Elf_External_Syminfo
) != entry
->d_un
.d_val
)
11233 error (_("Bad value (%d) for SYMINENT entry\n"),
11234 (int) entry
->d_un
.d_val
);
11236 else if (entry
->d_tag
== DT_SYMINSZ
)
11237 syminsz
= entry
->d_un
.d_val
;
11238 else if (entry
->d_tag
== DT_SYMINFO
)
11239 filedata
->dynamic_syminfo_offset
11240 = offset_from_vma (filedata
, entry
->d_un
.d_val
, syminsz
);
11243 if (filedata
->dynamic_syminfo_offset
!= 0 && syminsz
!= 0)
11245 Elf_External_Syminfo
* extsyminfo
;
11246 Elf_External_Syminfo
* extsym
;
11247 Elf_Internal_Syminfo
* syminfo
;
11249 /* There is a syminfo section. Read the data. */
11250 extsyminfo
= (Elf_External_Syminfo
*)
11251 get_data (NULL
, filedata
, filedata
->dynamic_syminfo_offset
,
11252 1, syminsz
, _("symbol information"));
11256 if (filedata
->dynamic_syminfo
!= NULL
)
11258 error (_("Multiple dynamic symbol information sections found\n"));
11259 free (filedata
->dynamic_syminfo
);
11261 filedata
->dynamic_syminfo
= (Elf_Internal_Syminfo
*) malloc (syminsz
);
11262 if (filedata
->dynamic_syminfo
== NULL
)
11264 error (_("Out of memory allocating %lu bytes "
11265 "for dynamic symbol info\n"),
11266 (unsigned long) syminsz
);
11270 filedata
->dynamic_syminfo_nent
11271 = syminsz
/ sizeof (Elf_External_Syminfo
);
11272 for (syminfo
= filedata
->dynamic_syminfo
, extsym
= extsyminfo
;
11273 syminfo
< (filedata
->dynamic_syminfo
11274 + filedata
->dynamic_syminfo_nent
);
11275 ++syminfo
, ++extsym
)
11277 syminfo
->si_boundto
= BYTE_GET (extsym
->si_boundto
);
11278 syminfo
->si_flags
= BYTE_GET (extsym
->si_flags
);
11285 if (do_dynamic
&& filedata
->dynamic_addr
)
11287 if (filedata
->is_separate
)
11288 printf (ngettext ("\nIn linked file '%s' the dynamic section at offset 0x%lx contains %lu entry:\n",
11289 "\nIn linked file '%s' the dynamic section at offset 0x%lx contains %lu entries:\n",
11290 (unsigned long) filedata
->dynamic_nent
),
11291 filedata
->file_name
,
11292 filedata
->dynamic_addr
,
11293 (unsigned long) filedata
->dynamic_nent
);
11295 printf (ngettext ("\nDynamic section at offset 0x%lx contains %lu entry:\n",
11296 "\nDynamic section at offset 0x%lx contains %lu entries:\n",
11297 (unsigned long) filedata
->dynamic_nent
),
11298 filedata
->dynamic_addr
,
11299 (unsigned long) filedata
->dynamic_nent
);
11302 printf (_(" Tag Type Name/Value\n"));
11304 for (entry
= filedata
->dynamic_section
;
11305 entry
< filedata
->dynamic_section
+ filedata
->dynamic_nent
;
11310 const char * dtype
;
11313 print_vma (entry
->d_tag
, FULL_HEX
);
11314 dtype
= get_dynamic_type (filedata
, entry
->d_tag
);
11315 printf (" (%s)%*s", dtype
,
11316 ((is_32bit_elf
? 27 : 19) - (int) strlen (dtype
)), " ");
11319 switch (entry
->d_tag
)
11323 print_dynamic_flags (entry
->d_un
.d_val
);
11333 switch (entry
->d_tag
)
11336 printf (_("Auxiliary library"));
11340 printf (_("Filter library"));
11344 printf (_("Configuration file"));
11348 printf (_("Dependency audit library"));
11352 printf (_("Audit library"));
11356 if (valid_dynamic_name (filedata
, entry
->d_un
.d_val
))
11357 printf (": [%s]\n",
11358 get_dynamic_name (filedata
, entry
->d_un
.d_val
));
11362 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
11371 printf (_("Flags:"));
11373 if (entry
->d_un
.d_val
== 0)
11374 printf (_(" None\n"));
11377 unsigned long int val
= entry
->d_un
.d_val
;
11379 if (val
& DTF_1_PARINIT
)
11381 printf (" PARINIT");
11382 val
^= DTF_1_PARINIT
;
11384 if (val
& DTF_1_CONFEXP
)
11386 printf (" CONFEXP");
11387 val
^= DTF_1_CONFEXP
;
11390 printf (" %lx", val
);
11399 printf (_("Flags:"));
11401 if (entry
->d_un
.d_val
== 0)
11402 printf (_(" None\n"));
11405 unsigned long int val
= entry
->d_un
.d_val
;
11407 if (val
& DF_P1_LAZYLOAD
)
11409 printf (" LAZYLOAD");
11410 val
^= DF_P1_LAZYLOAD
;
11412 if (val
& DF_P1_GROUPPERM
)
11414 printf (" GROUPPERM");
11415 val
^= DF_P1_GROUPPERM
;
11418 printf (" %lx", val
);
11427 printf (_("Flags:"));
11428 if (entry
->d_un
.d_val
== 0)
11429 printf (_(" None\n"));
11432 unsigned long int val
= entry
->d_un
.d_val
;
11434 if (val
& DF_1_NOW
)
11439 if (val
& DF_1_GLOBAL
)
11441 printf (" GLOBAL");
11442 val
^= DF_1_GLOBAL
;
11444 if (val
& DF_1_GROUP
)
11449 if (val
& DF_1_NODELETE
)
11451 printf (" NODELETE");
11452 val
^= DF_1_NODELETE
;
11454 if (val
& DF_1_LOADFLTR
)
11456 printf (" LOADFLTR");
11457 val
^= DF_1_LOADFLTR
;
11459 if (val
& DF_1_INITFIRST
)
11461 printf (" INITFIRST");
11462 val
^= DF_1_INITFIRST
;
11464 if (val
& DF_1_NOOPEN
)
11466 printf (" NOOPEN");
11467 val
^= DF_1_NOOPEN
;
11469 if (val
& DF_1_ORIGIN
)
11471 printf (" ORIGIN");
11472 val
^= DF_1_ORIGIN
;
11474 if (val
& DF_1_DIRECT
)
11476 printf (" DIRECT");
11477 val
^= DF_1_DIRECT
;
11479 if (val
& DF_1_TRANS
)
11484 if (val
& DF_1_INTERPOSE
)
11486 printf (" INTERPOSE");
11487 val
^= DF_1_INTERPOSE
;
11489 if (val
& DF_1_NODEFLIB
)
11491 printf (" NODEFLIB");
11492 val
^= DF_1_NODEFLIB
;
11494 if (val
& DF_1_NODUMP
)
11496 printf (" NODUMP");
11497 val
^= DF_1_NODUMP
;
11499 if (val
& DF_1_CONFALT
)
11501 printf (" CONFALT");
11502 val
^= DF_1_CONFALT
;
11504 if (val
& DF_1_ENDFILTEE
)
11506 printf (" ENDFILTEE");
11507 val
^= DF_1_ENDFILTEE
;
11509 if (val
& DF_1_DISPRELDNE
)
11511 printf (" DISPRELDNE");
11512 val
^= DF_1_DISPRELDNE
;
11514 if (val
& DF_1_DISPRELPND
)
11516 printf (" DISPRELPND");
11517 val
^= DF_1_DISPRELPND
;
11519 if (val
& DF_1_NODIRECT
)
11521 printf (" NODIRECT");
11522 val
^= DF_1_NODIRECT
;
11524 if (val
& DF_1_IGNMULDEF
)
11526 printf (" IGNMULDEF");
11527 val
^= DF_1_IGNMULDEF
;
11529 if (val
& DF_1_NOKSYMS
)
11531 printf (" NOKSYMS");
11532 val
^= DF_1_NOKSYMS
;
11534 if (val
& DF_1_NOHDR
)
11539 if (val
& DF_1_EDITED
)
11541 printf (" EDITED");
11542 val
^= DF_1_EDITED
;
11544 if (val
& DF_1_NORELOC
)
11546 printf (" NORELOC");
11547 val
^= DF_1_NORELOC
;
11549 if (val
& DF_1_SYMINTPOSE
)
11551 printf (" SYMINTPOSE");
11552 val
^= DF_1_SYMINTPOSE
;
11554 if (val
& DF_1_GLOBAUDIT
)
11556 printf (" GLOBAUDIT");
11557 val
^= DF_1_GLOBAUDIT
;
11559 if (val
& DF_1_SINGLETON
)
11561 printf (" SINGLETON");
11562 val
^= DF_1_SINGLETON
;
11564 if (val
& DF_1_STUB
)
11569 if (val
& DF_1_PIE
)
11574 if (val
& DF_1_KMOD
)
11579 if (val
& DF_1_WEAKFILTER
)
11581 printf (" WEAKFILTER");
11582 val
^= DF_1_WEAKFILTER
;
11584 if (val
& DF_1_NOCOMMON
)
11586 printf (" NOCOMMON");
11587 val
^= DF_1_NOCOMMON
;
11590 printf (" %lx", val
);
11597 filedata
->dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
11599 puts (get_dynamic_type (filedata
, entry
->d_un
.d_val
));
11620 filedata
->dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
11626 if (valid_dynamic_name (filedata
, entry
->d_un
.d_val
))
11627 name
= get_dynamic_name (filedata
, entry
->d_un
.d_val
);
11633 switch (entry
->d_tag
)
11636 printf (_("Shared library: [%s]"), name
);
11638 if (filedata
->program_interpreter
11639 && streq (name
, filedata
->program_interpreter
))
11640 printf (_(" program interpreter"));
11644 printf (_("Library soname: [%s]"), name
);
11648 printf (_("Library rpath: [%s]"), name
);
11652 printf (_("Library runpath: [%s]"), name
);
11656 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
11661 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
11676 filedata
->dynamic_info
[entry
->d_tag
] = entry
->d_un
.d_val
;
11677 /* Fall through. */
11681 case DT_PREINIT_ARRAYSZ
:
11682 case DT_INIT_ARRAYSZ
:
11683 case DT_FINI_ARRAYSZ
:
11684 case DT_GNU_CONFLICTSZ
:
11685 case DT_GNU_LIBLISTSZ
:
11688 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
11689 printf (_(" (bytes)\n"));
11694 case DT_VERNEEDNUM
:
11699 print_vma (entry
->d_un
.d_val
, UNSIGNED
);
11708 case DT_INIT_ARRAY
:
11709 case DT_FINI_ARRAY
:
11712 if (entry
->d_tag
== DT_USED
11713 && valid_dynamic_name (filedata
, entry
->d_un
.d_val
))
11716 = get_dynamic_name (filedata
, entry
->d_un
.d_val
);
11720 printf (_("Not needed object: [%s]\n"), name
);
11725 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
11731 /* The value of this entry is ignored. */
11736 case DT_GNU_PRELINKED
:
11740 time_t atime
= entry
->d_un
.d_val
;
11742 tmp
= gmtime (&atime
);
11743 /* PR 17533 file: 041-1244816-0.004. */
11745 printf (_("<corrupt time val: %lx"),
11746 (unsigned long) atime
);
11748 printf ("%04u-%02u-%02uT%02u:%02u:%02u\n",
11749 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
11750 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
11756 filedata
->dynamic_info_DT_GNU_HASH
= entry
->d_un
.d_val
;
11759 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
11764 case DT_GNU_FLAGS_1
:
11767 printf (_("Flags:"));
11768 if (entry
->d_un
.d_val
== 0)
11769 printf (_(" None\n"));
11772 unsigned long int val
= entry
->d_un
.d_val
;
11774 if (val
& DF_GNU_1_UNIQUE
)
11776 printf (" UNIQUE");
11777 val
^= DF_GNU_1_UNIQUE
;
11780 printf (" %lx", val
);
11787 if ((entry
->d_tag
>= DT_VERSYM
) && (entry
->d_tag
<= DT_VERNEEDNUM
))
11788 filedata
->version_info
[DT_VERSIONTAGIDX (entry
->d_tag
)]
11789 = entry
->d_un
.d_val
;
11793 switch (filedata
->file_header
.e_machine
)
11796 dynamic_section_aarch64_val (entry
);
11799 case EM_MIPS_RS3_LE
:
11800 dynamic_section_mips_val (filedata
, entry
);
11803 dynamic_section_parisc_val (entry
);
11806 dynamic_section_ia64_val (entry
);
11809 print_vma (entry
->d_un
.d_val
, PREFIX_HEX
);
11821 get_ver_flags (unsigned int flags
)
11823 static char buff
[128];
11830 if (flags
& VER_FLG_BASE
)
11831 strcat (buff
, "BASE");
11833 if (flags
& VER_FLG_WEAK
)
11835 if (flags
& VER_FLG_BASE
)
11836 strcat (buff
, " | ");
11838 strcat (buff
, "WEAK");
11841 if (flags
& VER_FLG_INFO
)
11843 if (flags
& (VER_FLG_BASE
|VER_FLG_WEAK
))
11844 strcat (buff
, " | ");
11846 strcat (buff
, "INFO");
11849 if (flags
& ~(VER_FLG_BASE
| VER_FLG_WEAK
| VER_FLG_INFO
))
11851 if (flags
& (VER_FLG_BASE
| VER_FLG_WEAK
| VER_FLG_INFO
))
11852 strcat (buff
, " | ");
11854 strcat (buff
, _("<unknown>"));
11860 /* Display the contents of the version sections. */
11863 process_version_sections (Filedata
* filedata
)
11865 Elf_Internal_Shdr
* section
;
11867 bool found
= false;
11872 for (i
= 0, section
= filedata
->section_headers
;
11873 i
< filedata
->file_header
.e_shnum
;
11876 switch (section
->sh_type
)
11878 case SHT_GNU_verdef
:
11880 Elf_External_Verdef
* edefs
;
11887 if (filedata
->is_separate
)
11888 printf (ngettext ("\nIn linked file '%s' the version definition section '%s' contains %u entry:\n",
11889 "\nIn linked file '%s' the version definition section '%s' contains %u entries:\n",
11891 filedata
->file_name
,
11892 printable_section_name (filedata
, section
),
11895 printf (ngettext ("\nVersion definition section '%s' "
11896 "contains %u entry:\n",
11897 "\nVersion definition section '%s' "
11898 "contains %u entries:\n",
11900 printable_section_name (filedata
, section
),
11903 printf (_(" Addr: 0x"));
11904 printf_vma (section
->sh_addr
);
11905 printf (_(" Offset: %#08lx Link: %u (%s)\n"),
11906 (unsigned long) section
->sh_offset
, section
->sh_link
,
11907 printable_section_name_from_index (filedata
, section
->sh_link
));
11909 edefs
= (Elf_External_Verdef
*)
11910 get_data (NULL
, filedata
, section
->sh_offset
, 1,section
->sh_size
,
11911 _("version definition section"));
11914 endbuf
= (char *) edefs
+ section
->sh_size
;
11916 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
11919 Elf_External_Verdef
* edef
;
11920 Elf_Internal_Verdef ent
;
11921 Elf_External_Verdaux
* eaux
;
11922 Elf_Internal_Verdaux aux
;
11923 unsigned long isum
;
11926 vstart
= ((char *) edefs
) + idx
;
11927 if (vstart
+ sizeof (*edef
) > endbuf
)
11930 edef
= (Elf_External_Verdef
*) vstart
;
11932 ent
.vd_version
= BYTE_GET (edef
->vd_version
);
11933 ent
.vd_flags
= BYTE_GET (edef
->vd_flags
);
11934 ent
.vd_ndx
= BYTE_GET (edef
->vd_ndx
);
11935 ent
.vd_cnt
= BYTE_GET (edef
->vd_cnt
);
11936 ent
.vd_hash
= BYTE_GET (edef
->vd_hash
);
11937 ent
.vd_aux
= BYTE_GET (edef
->vd_aux
);
11938 ent
.vd_next
= BYTE_GET (edef
->vd_next
);
11940 printf (_(" %#06lx: Rev: %d Flags: %s"),
11941 idx
, ent
.vd_version
, get_ver_flags (ent
.vd_flags
));
11943 printf (_(" Index: %d Cnt: %d "),
11944 ent
.vd_ndx
, ent
.vd_cnt
);
11946 /* Check for overflow. */
11947 if (ent
.vd_aux
> (size_t) (endbuf
- vstart
))
11950 vstart
+= ent
.vd_aux
;
11952 if (vstart
+ sizeof (*eaux
) > endbuf
)
11954 eaux
= (Elf_External_Verdaux
*) vstart
;
11956 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
11957 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
11959 if (valid_dynamic_name (filedata
, aux
.vda_name
))
11960 printf (_("Name: %s\n"),
11961 get_dynamic_name (filedata
, aux
.vda_name
));
11963 printf (_("Name index: %ld\n"), aux
.vda_name
);
11965 isum
= idx
+ ent
.vd_aux
;
11967 for (j
= 1; j
< ent
.vd_cnt
; j
++)
11969 if (aux
.vda_next
< sizeof (*eaux
)
11970 && !(j
== ent
.vd_cnt
- 1 && aux
.vda_next
== 0))
11972 warn (_("Invalid vda_next field of %lx\n"),
11977 /* Check for overflow. */
11978 if (aux
.vda_next
> (size_t) (endbuf
- vstart
))
11981 isum
+= aux
.vda_next
;
11982 vstart
+= aux
.vda_next
;
11984 if (vstart
+ sizeof (*eaux
) > endbuf
)
11986 eaux
= (Elf_External_Verdaux
*) vstart
;
11988 aux
.vda_name
= BYTE_GET (eaux
->vda_name
);
11989 aux
.vda_next
= BYTE_GET (eaux
->vda_next
);
11991 if (valid_dynamic_name (filedata
, aux
.vda_name
))
11992 printf (_(" %#06lx: Parent %d: %s\n"),
11994 get_dynamic_name (filedata
, aux
.vda_name
));
11996 printf (_(" %#06lx: Parent %d, name index: %ld\n"),
11997 isum
, j
, aux
.vda_name
);
12000 if (j
< ent
.vd_cnt
)
12001 printf (_(" Version def aux past end of section\n"));
12004 file: id:000001,src:000172+005151,op:splice,rep:2. */
12005 if (ent
.vd_next
< sizeof (*edef
)
12006 && !(cnt
== section
->sh_info
- 1 && ent
.vd_next
== 0))
12008 warn (_("Invalid vd_next field of %lx\n"), ent
.vd_next
);
12009 cnt
= section
->sh_info
;
12012 if (ent
.vd_next
> (size_t) (endbuf
- ((char *) edefs
+ idx
)))
12015 idx
+= ent
.vd_next
;
12018 if (cnt
< section
->sh_info
)
12019 printf (_(" Version definition past end of section\n"));
12025 case SHT_GNU_verneed
:
12027 Elf_External_Verneed
* eneed
;
12034 if (filedata
->is_separate
)
12035 printf (ngettext ("\nIn linked file '%s' the version needs section '%s' contains %u entry:\n",
12036 "\nIn linked file '%s' the version needs section '%s' contains %u entries:\n",
12038 filedata
->file_name
,
12039 printable_section_name (filedata
, section
),
12042 printf (ngettext ("\nVersion needs section '%s' "
12043 "contains %u entry:\n",
12044 "\nVersion needs section '%s' "
12045 "contains %u entries:\n",
12047 printable_section_name (filedata
, section
),
12050 printf (_(" Addr: 0x"));
12051 printf_vma (section
->sh_addr
);
12052 printf (_(" Offset: %#08lx Link: %u (%s)\n"),
12053 (unsigned long) section
->sh_offset
, section
->sh_link
,
12054 printable_section_name_from_index (filedata
, section
->sh_link
));
12056 eneed
= (Elf_External_Verneed
*) get_data (NULL
, filedata
,
12057 section
->sh_offset
, 1,
12059 _("Version Needs section"));
12062 endbuf
= (char *) eneed
+ section
->sh_size
;
12064 for (idx
= cnt
= 0; cnt
< section
->sh_info
; ++cnt
)
12066 Elf_External_Verneed
* entry
;
12067 Elf_Internal_Verneed ent
;
12068 unsigned long isum
;
12072 vstart
= ((char *) eneed
) + idx
;
12073 if (vstart
+ sizeof (*entry
) > endbuf
)
12076 entry
= (Elf_External_Verneed
*) vstart
;
12078 ent
.vn_version
= BYTE_GET (entry
->vn_version
);
12079 ent
.vn_cnt
= BYTE_GET (entry
->vn_cnt
);
12080 ent
.vn_file
= BYTE_GET (entry
->vn_file
);
12081 ent
.vn_aux
= BYTE_GET (entry
->vn_aux
);
12082 ent
.vn_next
= BYTE_GET (entry
->vn_next
);
12084 printf (_(" %#06lx: Version: %d"), idx
, ent
.vn_version
);
12086 if (valid_dynamic_name (filedata
, ent
.vn_file
))
12087 printf (_(" File: %s"),
12088 get_dynamic_name (filedata
, ent
.vn_file
));
12090 printf (_(" File: %lx"), ent
.vn_file
);
12092 printf (_(" Cnt: %d\n"), ent
.vn_cnt
);
12094 /* Check for overflow. */
12095 if (ent
.vn_aux
> (size_t) (endbuf
- vstart
))
12097 vstart
+= ent
.vn_aux
;
12099 for (j
= 0, isum
= idx
+ ent
.vn_aux
; j
< ent
.vn_cnt
; ++j
)
12101 Elf_External_Vernaux
* eaux
;
12102 Elf_Internal_Vernaux aux
;
12104 if (vstart
+ sizeof (*eaux
) > endbuf
)
12106 eaux
= (Elf_External_Vernaux
*) vstart
;
12108 aux
.vna_hash
= BYTE_GET (eaux
->vna_hash
);
12109 aux
.vna_flags
= BYTE_GET (eaux
->vna_flags
);
12110 aux
.vna_other
= BYTE_GET (eaux
->vna_other
);
12111 aux
.vna_name
= BYTE_GET (eaux
->vna_name
);
12112 aux
.vna_next
= BYTE_GET (eaux
->vna_next
);
12114 if (valid_dynamic_name (filedata
, aux
.vna_name
))
12115 printf (_(" %#06lx: Name: %s"),
12116 isum
, get_dynamic_name (filedata
, aux
.vna_name
));
12118 printf (_(" %#06lx: Name index: %lx"),
12119 isum
, aux
.vna_name
);
12121 printf (_(" Flags: %s Version: %d\n"),
12122 get_ver_flags (aux
.vna_flags
), aux
.vna_other
);
12124 if (aux
.vna_next
< sizeof (*eaux
)
12125 && !(j
== ent
.vn_cnt
- 1 && aux
.vna_next
== 0))
12127 warn (_("Invalid vna_next field of %lx\n"),
12132 /* Check for overflow. */
12133 if (aux
.vna_next
> (size_t) (endbuf
- vstart
))
12135 isum
+= aux
.vna_next
;
12136 vstart
+= aux
.vna_next
;
12139 if (j
< ent
.vn_cnt
)
12140 warn (_("Missing Version Needs auxiliary information\n"));
12142 if (ent
.vn_next
< sizeof (*entry
)
12143 && !(cnt
== section
->sh_info
- 1 && ent
.vn_next
== 0))
12145 warn (_("Invalid vn_next field of %lx\n"), ent
.vn_next
);
12146 cnt
= section
->sh_info
;
12149 if (ent
.vn_next
> (size_t) (endbuf
- ((char *) eneed
+ idx
)))
12151 idx
+= ent
.vn_next
;
12154 if (cnt
< section
->sh_info
)
12155 warn (_("Missing Version Needs information\n"));
12161 case SHT_GNU_versym
:
12163 Elf_Internal_Shdr
* link_section
;
12166 unsigned char * edata
;
12167 unsigned short * data
;
12169 Elf_Internal_Sym
* symbols
;
12170 Elf_Internal_Shdr
* string_sec
;
12171 unsigned long num_syms
;
12174 if (section
->sh_link
>= filedata
->file_header
.e_shnum
)
12177 link_section
= filedata
->section_headers
+ section
->sh_link
;
12178 total
= section
->sh_size
/ sizeof (Elf_External_Versym
);
12180 if (link_section
->sh_link
>= filedata
->file_header
.e_shnum
)
12185 symbols
= get_elf_symbols (filedata
, link_section
, & num_syms
);
12186 if (symbols
== NULL
)
12189 string_sec
= filedata
->section_headers
+ link_section
->sh_link
;
12191 strtab
= (char *) get_data (NULL
, filedata
, string_sec
->sh_offset
, 1,
12192 string_sec
->sh_size
,
12193 _("version string table"));
12200 if (filedata
->is_separate
)
12201 printf (ngettext ("\nIn linked file '%s' the version symbols section '%s' contains %lu entry:\n",
12202 "\nIn linked file '%s' the version symbols section '%s' contains %lu entries:\n",
12204 filedata
->file_name
,
12205 printable_section_name (filedata
, section
),
12206 (unsigned long) total
);
12208 printf (ngettext ("\nVersion symbols section '%s' "
12209 "contains %lu entry:\n",
12210 "\nVersion symbols section '%s' "
12211 "contains %lu entries:\n",
12213 printable_section_name (filedata
, section
),
12214 (unsigned long) total
);
12216 printf (_(" Addr: 0x"));
12217 printf_vma (section
->sh_addr
);
12218 printf (_(" Offset: %#08lx Link: %u (%s)\n"),
12219 (unsigned long) section
->sh_offset
, section
->sh_link
,
12220 printable_section_name (filedata
, link_section
));
12222 off
= offset_from_vma (filedata
,
12223 filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
12224 total
* sizeof (short));
12225 edata
= (unsigned char *) get_data (NULL
, filedata
, off
,
12226 sizeof (short), total
,
12227 _("version symbol data"));
12235 data
= (short unsigned int *) cmalloc (total
, sizeof (short));
12237 for (cnt
= total
; cnt
--;)
12238 data
[cnt
] = byte_get (edata
+ cnt
* sizeof (short),
12243 for (cnt
= 0; cnt
< total
; cnt
+= 4)
12247 char *invalid
= _("*invalid*");
12249 printf (" %03x:", cnt
);
12251 for (j
= 0; (j
< 4) && (cnt
+ j
) < total
; ++j
)
12252 switch (data
[cnt
+ j
])
12255 fputs (_(" 0 (*local*) "), stdout
);
12259 fputs (_(" 1 (*global*) "), stdout
);
12263 nn
= printf ("%4x%c", data
[cnt
+ j
] & VERSYM_VERSION
,
12264 data
[cnt
+ j
] & VERSYM_HIDDEN
? 'h' : ' ');
12266 /* If this index value is greater than the size of the symbols
12267 array, break to avoid an out-of-bounds read. */
12268 if ((unsigned long)(cnt
+ j
) >= num_syms
)
12270 warn (_("invalid index into symbol array\n"));
12275 if (filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)])
12277 Elf_Internal_Verneed ivn
;
12278 unsigned long offset
;
12280 offset
= offset_from_vma
12282 filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
12283 sizeof (Elf_External_Verneed
));
12287 Elf_Internal_Vernaux ivna
;
12288 Elf_External_Verneed evn
;
12289 Elf_External_Vernaux evna
;
12290 unsigned long a_off
;
12292 if (get_data (&evn
, filedata
, offset
, sizeof (evn
), 1,
12293 _("version need")) == NULL
)
12296 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
12297 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
12299 a_off
= offset
+ ivn
.vn_aux
;
12303 if (get_data (&evna
, filedata
, a_off
, sizeof (evna
),
12304 1, _("version need aux (2)")) == NULL
)
12307 ivna
.vna_other
= 0;
12311 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
12312 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
12315 a_off
+= ivna
.vna_next
;
12317 while (ivna
.vna_other
!= data
[cnt
+ j
]
12318 && ivna
.vna_next
!= 0);
12320 if (ivna
.vna_other
== data
[cnt
+ j
])
12322 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
12324 if (ivna
.vna_name
>= string_sec
->sh_size
)
12327 name
= strtab
+ ivna
.vna_name
;
12331 offset
+= ivn
.vn_next
;
12333 while (ivn
.vn_next
);
12336 if (data
[cnt
+ j
] != 0x8001
12337 && filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
12339 Elf_Internal_Verdef ivd
;
12340 Elf_External_Verdef evd
;
12341 unsigned long offset
;
12343 offset
= offset_from_vma
12345 filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
12350 if (get_data (&evd
, filedata
, offset
, sizeof (evd
), 1,
12351 _("version def")) == NULL
)
12354 /* PR 17531: file: 046-1082287-0.004. */
12355 ivd
.vd_ndx
= (data
[cnt
+ j
] & VERSYM_VERSION
) + 1;
12360 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
12361 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
12364 offset
+= ivd
.vd_next
;
12366 while (ivd
.vd_ndx
!= (data
[cnt
+ j
] & VERSYM_VERSION
)
12367 && ivd
.vd_next
!= 0);
12369 if (ivd
.vd_ndx
== (data
[cnt
+ j
] & VERSYM_VERSION
))
12371 Elf_External_Verdaux evda
;
12372 Elf_Internal_Verdaux ivda
;
12374 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
12376 if (get_data (&evda
, filedata
,
12377 offset
- ivd
.vd_next
+ ivd
.vd_aux
,
12379 _("version def aux")) == NULL
)
12382 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
12384 if (ivda
.vda_name
>= string_sec
->sh_size
)
12386 else if (name
!= NULL
&& name
!= invalid
)
12387 name
= _("*both*");
12389 name
= strtab
+ ivda
.vda_name
;
12393 nn
+= printf ("(%s%-*s",
12395 12 - (int) strlen (name
),
12399 printf ("%*c", 18 - nn
, ' ');
12418 if (filedata
->is_separate
)
12419 printf (_("\nNo version information found in linked file '%s'.\n"),
12420 filedata
->file_name
);
12422 printf (_("\nNo version information found in this file.\n"));
12428 static const char *
12429 get_symbol_binding (Filedata
* filedata
, unsigned int binding
)
12431 static char buff
[64];
12435 case STB_LOCAL
: return "LOCAL";
12436 case STB_GLOBAL
: return "GLOBAL";
12437 case STB_WEAK
: return "WEAK";
12439 if (binding
>= STB_LOPROC
&& binding
<= STB_HIPROC
)
12440 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"),
12442 else if (binding
>= STB_LOOS
&& binding
<= STB_HIOS
)
12444 if (binding
== STB_GNU_UNIQUE
12445 && filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_GNU
)
12447 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), binding
);
12450 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), binding
);
12455 static const char *
12456 get_symbol_type (Filedata
* filedata
, unsigned int type
)
12458 static char buff
[64];
12462 case STT_NOTYPE
: return "NOTYPE";
12463 case STT_OBJECT
: return "OBJECT";
12464 case STT_FUNC
: return "FUNC";
12465 case STT_SECTION
: return "SECTION";
12466 case STT_FILE
: return "FILE";
12467 case STT_COMMON
: return "COMMON";
12468 case STT_TLS
: return "TLS";
12469 case STT_RELC
: return "RELC";
12470 case STT_SRELC
: return "SRELC";
12472 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
12474 if (filedata
->file_header
.e_machine
== EM_ARM
&& type
== STT_ARM_TFUNC
)
12475 return "THUMB_FUNC";
12477 if (filedata
->file_header
.e_machine
== EM_SPARCV9
&& type
== STT_REGISTER
)
12480 if (filedata
->file_header
.e_machine
== EM_PARISC
&& type
== STT_PARISC_MILLI
)
12481 return "PARISC_MILLI";
12483 snprintf (buff
, sizeof (buff
), _("<processor specific>: %d"), type
);
12485 else if (type
>= STT_LOOS
&& type
<= STT_HIOS
)
12487 if (filedata
->file_header
.e_machine
== EM_PARISC
)
12489 if (type
== STT_HP_OPAQUE
)
12490 return "HP_OPAQUE";
12491 if (type
== STT_HP_STUB
)
12495 if (type
== STT_GNU_IFUNC
12496 && (filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_GNU
12497 || filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_FREEBSD
))
12500 snprintf (buff
, sizeof (buff
), _("<OS specific>: %d"), type
);
12503 snprintf (buff
, sizeof (buff
), _("<unknown>: %d"), type
);
12508 static const char *
12509 get_symbol_visibility (unsigned int visibility
)
12511 switch (visibility
)
12513 case STV_DEFAULT
: return "DEFAULT";
12514 case STV_INTERNAL
: return "INTERNAL";
12515 case STV_HIDDEN
: return "HIDDEN";
12516 case STV_PROTECTED
: return "PROTECTED";
12518 error (_("Unrecognized visibility value: %u\n"), visibility
);
12519 return _("<unknown>");
12523 static const char *
12524 get_alpha_symbol_other (unsigned int other
)
12528 case STO_ALPHA_NOPV
: return "NOPV";
12529 case STO_ALPHA_STD_GPLOAD
: return "STD GPLOAD";
12531 error (_("Unrecognized alpha specific other value: %u\n"), other
);
12532 return _("<unknown>");
12536 static const char *
12537 get_solaris_symbol_visibility (unsigned int visibility
)
12539 switch (visibility
)
12541 case 4: return "EXPORTED";
12542 case 5: return "SINGLETON";
12543 case 6: return "ELIMINATE";
12544 default: return get_symbol_visibility (visibility
);
12548 static const char *
12549 get_aarch64_symbol_other (unsigned int other
)
12551 static char buf
[32];
12553 if (other
& STO_AARCH64_VARIANT_PCS
)
12555 other
&= ~STO_AARCH64_VARIANT_PCS
;
12557 return "VARIANT_PCS";
12558 snprintf (buf
, sizeof buf
, "VARIANT_PCS | %x", other
);
12564 static const char *
12565 get_mips_symbol_other (unsigned int other
)
12569 case STO_OPTIONAL
: return "OPTIONAL";
12570 case STO_MIPS_PLT
: return "MIPS PLT";
12571 case STO_MIPS_PIC
: return "MIPS PIC";
12572 case STO_MICROMIPS
: return "MICROMIPS";
12573 case STO_MICROMIPS
| STO_MIPS_PIC
: return "MICROMIPS, MIPS PIC";
12574 case STO_MIPS16
: return "MIPS16";
12575 default: return NULL
;
12579 static const char *
12580 get_ia64_symbol_other (Filedata
* filedata
, unsigned int other
)
12582 if (is_ia64_vms (filedata
))
12584 static char res
[32];
12588 /* Function types is for images and .STB files only. */
12589 switch (filedata
->file_header
.e_type
)
12593 switch (VMS_ST_FUNC_TYPE (other
))
12595 case VMS_SFT_CODE_ADDR
:
12596 strcat (res
, " CA");
12598 case VMS_SFT_SYMV_IDX
:
12599 strcat (res
, " VEC");
12602 strcat (res
, " FD");
12604 case VMS_SFT_RESERVE
:
12605 strcat (res
, " RSV");
12608 warn (_("Unrecognized IA64 VMS ST Function type: %d\n"),
12609 VMS_ST_FUNC_TYPE (other
));
12610 strcat (res
, " <unknown>");
12617 switch (VMS_ST_LINKAGE (other
))
12619 case VMS_STL_IGNORE
:
12620 strcat (res
, " IGN");
12622 case VMS_STL_RESERVE
:
12623 strcat (res
, " RSV");
12626 strcat (res
, " STD");
12629 strcat (res
, " LNK");
12632 warn (_("Unrecognized IA64 VMS ST Linkage: %d\n"),
12633 VMS_ST_LINKAGE (other
));
12634 strcat (res
, " <unknown>");
12646 static const char *
12647 get_ppc64_symbol_other (unsigned int other
)
12649 if ((other
& ~STO_PPC64_LOCAL_MASK
) != 0)
12652 other
>>= STO_PPC64_LOCAL_BIT
;
12655 static char buf
[64];
12657 other
= ppc64_decode_local_entry (other
);
12658 snprintf (buf
, sizeof buf
, _("<localentry>: %d"), other
);
12664 static const char *
12665 get_riscv_symbol_other (unsigned int other
)
12667 static char buf
[32];
12670 if (other
& STO_RISCV_VARIANT_CC
)
12672 strcat (buf
, _(" VARIANT_CC"));
12673 other
&= ~STO_RISCV_VARIANT_CC
;
12677 snprintf (buf
, sizeof buf
, " %x", other
);
12686 static const char *
12687 get_symbol_other (Filedata
* filedata
, unsigned int other
)
12689 const char * result
= NULL
;
12690 static char buff
[64];
12695 switch (filedata
->file_header
.e_machine
)
12698 result
= get_alpha_symbol_other (other
);
12701 result
= get_aarch64_symbol_other (other
);
12704 result
= get_mips_symbol_other (other
);
12707 result
= get_ia64_symbol_other (filedata
, other
);
12710 result
= get_ppc64_symbol_other (other
);
12713 result
= get_riscv_symbol_other (other
);
12723 snprintf (buff
, sizeof buff
, _("<other>: %x"), other
);
12727 static const char *
12728 get_symbol_index_type (Filedata
* filedata
, unsigned int type
)
12730 static char buff
[32];
12734 case SHN_UNDEF
: return "UND";
12735 case SHN_ABS
: return "ABS";
12736 case SHN_COMMON
: return "COM";
12738 if (type
== SHN_IA_64_ANSI_COMMON
12739 && filedata
->file_header
.e_machine
== EM_IA_64
12740 && filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_HPUX
)
12742 else if ((filedata
->file_header
.e_machine
== EM_X86_64
12743 || filedata
->file_header
.e_machine
== EM_L1OM
12744 || filedata
->file_header
.e_machine
== EM_K1OM
)
12745 && type
== SHN_X86_64_LCOMMON
)
12746 return "LARGE_COM";
12747 else if ((type
== SHN_MIPS_SCOMMON
12748 && filedata
->file_header
.e_machine
== EM_MIPS
)
12749 || (type
== SHN_TIC6X_SCOMMON
12750 && filedata
->file_header
.e_machine
== EM_TI_C6000
))
12752 else if (type
== SHN_MIPS_SUNDEFINED
12753 && filedata
->file_header
.e_machine
== EM_MIPS
)
12755 else if (type
>= SHN_LOPROC
&& type
<= SHN_HIPROC
)
12756 sprintf (buff
, "PRC[0x%04x]", type
& 0xffff);
12757 else if (type
>= SHN_LOOS
&& type
<= SHN_HIOS
)
12758 sprintf (buff
, "OS [0x%04x]", type
& 0xffff);
12759 else if (type
>= SHN_LORESERVE
)
12760 sprintf (buff
, "RSV[0x%04x]", type
& 0xffff);
12761 else if (filedata
->file_header
.e_shnum
!= 0
12762 && type
>= filedata
->file_header
.e_shnum
)
12763 sprintf (buff
, _("bad section index[%3d]"), type
);
12765 sprintf (buff
, "%3d", type
);
12772 static const char *
12773 get_symbol_version_string (Filedata
* filedata
,
12775 const char * strtab
,
12776 unsigned long int strtab_size
,
12778 Elf_Internal_Sym
* psym
,
12779 enum versioned_symbol_info
* sym_info
,
12780 unsigned short * vna_other
)
12782 unsigned char data
[2];
12783 unsigned short vers_data
;
12784 unsigned long offset
;
12785 unsigned short max_vd_ndx
;
12788 || filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)] == 0)
12791 offset
= offset_from_vma (filedata
,
12792 filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERSYM
)],
12793 sizeof data
+ si
* sizeof (vers_data
));
12795 if (get_data (&data
, filedata
, offset
+ si
* sizeof (vers_data
),
12796 sizeof (data
), 1, _("version data")) == NULL
)
12799 vers_data
= byte_get (data
, 2);
12801 if ((vers_data
& VERSYM_HIDDEN
) == 0 && vers_data
== 0)
12804 *sym_info
= (vers_data
& VERSYM_HIDDEN
) != 0 ? symbol_hidden
: symbol_public
;
12807 /* Usually we'd only see verdef for defined symbols, and verneed for
12808 undefined symbols. However, symbols defined by the linker in
12809 .dynbss for variables copied from a shared library in order to
12810 avoid text relocations are defined yet have verneed. We could
12811 use a heuristic to detect the special case, for example, check
12812 for verneed first on symbols defined in SHT_NOBITS sections, but
12813 it is simpler and more reliable to just look for both verdef and
12814 verneed. .dynbss might not be mapped to a SHT_NOBITS section. */
12816 if (psym
->st_shndx
!= SHN_UNDEF
12817 && vers_data
!= 0x8001
12818 && filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)])
12820 Elf_Internal_Verdef ivd
;
12821 Elf_Internal_Verdaux ivda
;
12822 Elf_External_Verdaux evda
;
12825 off
= offset_from_vma (filedata
,
12826 filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERDEF
)],
12827 sizeof (Elf_External_Verdef
));
12831 Elf_External_Verdef evd
;
12833 if (get_data (&evd
, filedata
, off
, sizeof (evd
), 1,
12834 _("version def")) == NULL
)
12843 ivd
.vd_ndx
= BYTE_GET (evd
.vd_ndx
);
12844 ivd
.vd_aux
= BYTE_GET (evd
.vd_aux
);
12845 ivd
.vd_next
= BYTE_GET (evd
.vd_next
);
12846 ivd
.vd_flags
= BYTE_GET (evd
.vd_flags
);
12849 if ((ivd
.vd_ndx
& VERSYM_VERSION
) > max_vd_ndx
)
12850 max_vd_ndx
= ivd
.vd_ndx
& VERSYM_VERSION
;
12852 off
+= ivd
.vd_next
;
12854 while (ivd
.vd_ndx
!= (vers_data
& VERSYM_VERSION
) && ivd
.vd_next
!= 0);
12856 if (ivd
.vd_ndx
== (vers_data
& VERSYM_VERSION
))
12858 if (ivd
.vd_ndx
== 1 && ivd
.vd_flags
== VER_FLG_BASE
)
12861 off
-= ivd
.vd_next
;
12864 if (get_data (&evda
, filedata
, off
, sizeof (evda
), 1,
12865 _("version def aux")) != NULL
)
12867 ivda
.vda_name
= BYTE_GET (evda
.vda_name
);
12869 if (psym
->st_name
!= ivda
.vda_name
)
12870 return (ivda
.vda_name
< strtab_size
12871 ? strtab
+ ivda
.vda_name
: _("<corrupt>"));
12876 if (filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)])
12878 Elf_External_Verneed evn
;
12879 Elf_Internal_Verneed ivn
;
12880 Elf_Internal_Vernaux ivna
;
12882 offset
= offset_from_vma (filedata
,
12883 filedata
->version_info
[DT_VERSIONTAGIDX (DT_VERNEED
)],
12887 unsigned long vna_off
;
12889 if (get_data (&evn
, filedata
, offset
, sizeof (evn
), 1,
12890 _("version need")) == NULL
)
12893 ivna
.vna_other
= 0;
12898 ivn
.vn_aux
= BYTE_GET (evn
.vn_aux
);
12899 ivn
.vn_next
= BYTE_GET (evn
.vn_next
);
12901 vna_off
= offset
+ ivn
.vn_aux
;
12905 Elf_External_Vernaux evna
;
12907 if (get_data (&evna
, filedata
, vna_off
, sizeof (evna
), 1,
12908 _("version need aux (3)")) == NULL
)
12911 ivna
.vna_other
= 0;
12916 ivna
.vna_other
= BYTE_GET (evna
.vna_other
);
12917 ivna
.vna_next
= BYTE_GET (evna
.vna_next
);
12918 ivna
.vna_name
= BYTE_GET (evna
.vna_name
);
12921 vna_off
+= ivna
.vna_next
;
12923 while (ivna
.vna_other
!= vers_data
&& ivna
.vna_next
!= 0);
12925 if (ivna
.vna_other
== vers_data
)
12928 offset
+= ivn
.vn_next
;
12930 while (ivn
.vn_next
!= 0);
12932 if (ivna
.vna_other
== vers_data
)
12934 *sym_info
= symbol_undefined
;
12935 *vna_other
= ivna
.vna_other
;
12936 return (ivna
.vna_name
< strtab_size
12937 ? strtab
+ ivna
.vna_name
: _("<corrupt>"));
12939 else if ((max_vd_ndx
|| (vers_data
& VERSYM_VERSION
) != 1)
12940 && (vers_data
& VERSYM_VERSION
) > max_vd_ndx
)
12941 return _("<corrupt>");
12946 /* Display a symbol size on stdout. Format is based on --sym-base setting. */
12948 static unsigned int
12949 print_dynamic_symbol_size (bfd_vma vma
, int base
)
12954 return print_vma (vma
, OCTAL_5
);
12957 return print_vma (vma
, UNSIGNED_5
);
12960 return print_vma (vma
, PREFIX_HEX_5
);
12964 return print_vma (vma
, DEC_5
);
12969 print_dynamic_symbol (Filedata
*filedata
, unsigned long si
,
12970 Elf_Internal_Sym
*symtab
,
12971 Elf_Internal_Shdr
*section
,
12972 char *strtab
, size_t strtab_size
)
12974 const char *version_string
;
12975 enum versioned_symbol_info sym_info
;
12976 unsigned short vna_other
;
12979 Elf_Internal_Sym
*psym
= symtab
+ si
;
12981 printf ("%6ld: ", si
);
12982 print_vma (psym
->st_value
, LONG_HEX
);
12984 print_dynamic_symbol_size (psym
->st_size
, sym_base
);
12985 printf (" %-7s", get_symbol_type (filedata
, ELF_ST_TYPE (psym
->st_info
)));
12986 printf (" %-6s", get_symbol_binding (filedata
, ELF_ST_BIND (psym
->st_info
)));
12987 if (filedata
->file_header
.e_ident
[EI_OSABI
] == ELFOSABI_SOLARIS
)
12988 printf (" %-7s", get_solaris_symbol_visibility (psym
->st_other
));
12991 unsigned int vis
= ELF_ST_VISIBILITY (psym
->st_other
);
12993 printf (" %-7s", get_symbol_visibility (vis
));
12994 /* Check to see if any other bits in the st_other field are set.
12995 Note - displaying this information disrupts the layout of the
12996 table being generated, but for the moment this case is very rare. */
12997 if (psym
->st_other
^ vis
)
12998 printf (" [%s] ", get_symbol_other (filedata
, psym
->st_other
^ vis
));
13000 printf (" %4s ", get_symbol_index_type (filedata
, psym
->st_shndx
));
13002 if (ELF_ST_TYPE (psym
->st_info
) == STT_SECTION
13003 && psym
->st_shndx
< filedata
->file_header
.e_shnum
13004 && filedata
->section_headers
!= NULL
13005 && psym
->st_name
== 0)
13008 = section_name_valid (filedata
,
13009 filedata
->section_headers
+ psym
->st_shndx
);
13011 section_name_print (filedata
,
13012 filedata
->section_headers
+ psym
->st_shndx
)
13017 is_valid
= valid_symbol_name (strtab
, strtab_size
, psym
->st_name
);
13018 sstr
= is_valid
? strtab
+ psym
->st_name
: _("<corrupt>");
13022 = get_symbol_version_string (filedata
,
13024 || section
->sh_type
== SHT_DYNSYM
),
13025 strtab
, strtab_size
, si
,
13026 psym
, &sym_info
, &vna_other
);
13028 int len_avail
= 21;
13029 if (! do_wide
&& version_string
!= NULL
)
13033 len_avail
-= 1 + strlen (version_string
);
13035 if (sym_info
== symbol_undefined
)
13036 len_avail
-= sprintf (buffer
," (%d)", vna_other
);
13037 else if (sym_info
!= symbol_hidden
)
13041 print_symbol (len_avail
, sstr
);
13043 if (version_string
)
13045 if (sym_info
== symbol_undefined
)
13046 printf ("@%s (%d)", version_string
, vna_other
);
13048 printf (sym_info
== symbol_hidden
? "@%s" : "@@%s",
13054 if (ELF_ST_BIND (psym
->st_info
) == STB_LOCAL
13056 && si
>= section
->sh_info
13057 /* Irix 5 and 6 MIPS binaries are known to ignore this requirement. */
13058 && filedata
->file_header
.e_machine
!= EM_MIPS
13059 /* Solaris binaries have been found to violate this requirement as
13060 well. Not sure if this is a bug or an ABI requirement. */
13061 && filedata
->file_header
.e_ident
[EI_OSABI
] != ELFOSABI_SOLARIS
)
13062 warn (_("local symbol %lu found at index >= %s's sh_info value of %u\n"),
13063 si
, printable_section_name (filedata
, section
), section
->sh_info
);
13066 static const char *
13067 get_lto_kind (unsigned int kind
)
13071 case 0: return "DEF";
13072 case 1: return "WEAKDEF";
13073 case 2: return "UNDEF";
13074 case 3: return "WEAKUNDEF";
13075 case 4: return "COMMON";
13080 static char buffer
[30];
13081 error (_("Unknown LTO symbol definition encountered: %u\n"), kind
);
13082 sprintf (buffer
, "<unknown: %u>", kind
);
13086 static const char *
13087 get_lto_visibility (unsigned int visibility
)
13089 switch (visibility
)
13091 case 0: return "DEFAULT";
13092 case 1: return "PROTECTED";
13093 case 2: return "INTERNAL";
13094 case 3: return "HIDDEN";
13099 static char buffer
[30];
13100 error (_("Unknown LTO symbol visibility encountered: %u\n"), visibility
);
13101 sprintf (buffer
, "<unknown: %u>", visibility
);
13105 static const char *
13106 get_lto_sym_type (unsigned int sym_type
)
13110 case 0: return "UNKNOWN";
13111 case 1: return "FUNCTION";
13112 case 2: return "VARIABLE";
13117 static char buffer
[30];
13118 error (_("Unknown LTO symbol type encountered: %u\n"), sym_type
);
13119 sprintf (buffer
, "<unknown: %u>", sym_type
);
13123 /* Display an LTO format symbol table.
13124 FIXME: The format of LTO symbol tables is not formalized.
13125 So this code could need changing in the future. */
13128 display_lto_symtab (Filedata
* filedata
,
13129 Elf_Internal_Shdr
* section
)
13131 if (section
->sh_size
== 0)
13133 if (filedata
->is_separate
)
13134 printf (_("\nThe LTO Symbol table section '%s' in linked file '%s' is empty!\n"),
13135 printable_section_name (filedata
, section
),
13136 filedata
->file_name
);
13138 printf (_("\nLTO Symbol table '%s' is empty!\n"),
13139 printable_section_name (filedata
, section
));
13144 if (section
->sh_size
> filedata
->file_size
)
13146 error (_("Section %s has an invalid sh_size of 0x%lx\n"),
13147 printable_section_name (filedata
, section
),
13148 (unsigned long) section
->sh_size
);
13152 void * alloced_data
= get_data (NULL
, filedata
, section
->sh_offset
,
13153 section
->sh_size
, 1, _("LTO symbols"));
13154 if (alloced_data
== NULL
)
13157 /* Look for extended data for the symbol table. */
13158 Elf_Internal_Shdr
* ext
;
13159 void * ext_data_orig
= NULL
;
13160 char * ext_data
= NULL
;
13161 char * ext_data_end
= NULL
;
13162 char * ext_name
= NULL
;
13164 if (asprintf (& ext_name
, ".gnu.lto_.ext_symtab.%s",
13165 (section_name (filedata
, section
)
13166 + sizeof (".gnu.lto_.symtab.") - 1)) > 0
13167 && ext_name
!= NULL
/* Paranoia. */
13168 && (ext
= find_section (filedata
, ext_name
)) != NULL
)
13170 if (ext
->sh_size
< 3)
13171 error (_("LTO Symbol extension table '%s' is empty!\n"),
13172 printable_section_name (filedata
, ext
));
13175 ext_data_orig
= ext_data
= get_data (NULL
, filedata
, ext
->sh_offset
,
13177 _("LTO ext symbol data"));
13178 if (ext_data
!= NULL
)
13180 ext_data_end
= ext_data
+ ext
->sh_size
;
13181 if (* ext_data
++ != 1)
13182 error (_("Unexpected version number in symbol extension table\n"));
13187 const unsigned char * data
= (const unsigned char *) alloced_data
;
13188 const unsigned char * end
= data
+ section
->sh_size
;
13190 if (filedata
->is_separate
)
13191 printf (_("\nIn linked file '%s': "), filedata
->file_name
);
13195 if (ext_data_orig
!= NULL
)
13198 printf (_("LTO Symbol table '%s' and extension table '%s' contain:\n"),
13199 printable_section_name (filedata
, section
),
13200 printable_section_name (filedata
, ext
));
13203 printf (_("LTO Symbol table '%s'\n"),
13204 printable_section_name (filedata
, section
));
13205 printf (_(" and extension table '%s' contain:\n"),
13206 printable_section_name (filedata
, ext
));
13210 printf (_("LTO Symbol table '%s' contains:\n"),
13211 printable_section_name (filedata
, section
));
13213 /* FIXME: Add a wide version. */
13214 if (ext_data_orig
!= NULL
)
13215 printf (_(" Comdat_Key Kind Visibility Size Slot Type Section Name\n"));
13217 printf (_(" Comdat_Key Kind Visibility Size Slot Name\n"));
13219 /* FIXME: We do not handle style prefixes. */
13223 const unsigned char * sym_name
= data
;
13224 data
+= strnlen ((const char *) sym_name
, end
- data
) + 1;
13228 const unsigned char * comdat_key
= data
;
13229 data
+= strnlen ((const char *) comdat_key
, end
- data
) + 1;
13233 if (data
+ 2 + 8 + 4 > end
)
13236 unsigned int kind
= *data
++;
13237 unsigned int visibility
= *data
++;
13239 elf_vma size
= byte_get (data
, 8);
13242 elf_vma slot
= byte_get (data
, 4);
13245 if (ext_data
!= NULL
)
13247 if (ext_data
< (ext_data_end
- 1))
13249 unsigned int sym_type
= * ext_data
++;
13250 unsigned int sec_kind
= * ext_data
++;
13252 printf (" %10s %10s %11s %08lx %08lx %9s %08lx _",
13253 * comdat_key
== 0 ? "-" : (char *) comdat_key
,
13254 get_lto_kind (kind
),
13255 get_lto_visibility (visibility
),
13258 get_lto_sym_type (sym_type
),
13260 print_symbol (6, (const char *) sym_name
);
13264 error (_("Ran out of LTO symbol extension data\n"));
13266 /* FIXME: return FAIL result ? */
13271 printf (" %10s %10s %11s %08lx %08lx _",
13272 * comdat_key
== 0 ? "-" : (char *) comdat_key
,
13273 get_lto_kind (kind
),
13274 get_lto_visibility (visibility
),
13277 print_symbol (21, (const char *) sym_name
);
13282 if (ext_data
!= NULL
&& ext_data
< ext_data_end
)
13284 error (_("Data remains in the LTO symbol extension table\n"));
13288 free (alloced_data
);
13289 free (ext_data_orig
);
13294 error (_("Buffer overrun encountered whilst decoding LTO symbol table\n"));
13295 free (alloced_data
);
13296 free (ext_data_orig
);
13301 /* Display LTO symbol tables. */
13304 process_lto_symbol_tables (Filedata
* filedata
)
13306 Elf_Internal_Shdr
* section
;
13313 if (filedata
->section_headers
== NULL
)
13316 for (i
= 0, section
= filedata
->section_headers
;
13317 i
< filedata
->file_header
.e_shnum
;
13319 if (section_name_valid (filedata
, section
)
13320 && startswith (section_name (filedata
, section
), ".gnu.lto_.symtab."))
13321 res
&= display_lto_symtab (filedata
, section
);
13326 /* Dump the symbol table. */
13329 process_symbol_table (Filedata
* filedata
)
13331 Elf_Internal_Shdr
* section
;
13333 if (!do_syms
&& !do_dyn_syms
&& !do_histogram
)
13336 if ((filedata
->dynamic_info
[DT_HASH
] || filedata
->dynamic_info_DT_GNU_HASH
)
13338 && do_using_dynamic
13339 && filedata
->dynamic_strings
!= NULL
13340 && filedata
->dynamic_symbols
!= NULL
)
13344 if (filedata
->is_separate
)
13346 printf (ngettext ("\nIn linked file '%s' the dynamic symbol table contains %lu entry:\n",
13347 "\nIn linked file '%s' the dynamic symbol table contains %lu entries:\n",
13348 filedata
->num_dynamic_syms
),
13349 filedata
->file_name
,
13350 filedata
->num_dynamic_syms
);
13354 printf (ngettext ("\nSymbol table for image contains %lu entry:\n",
13355 "\nSymbol table for image contains %lu entries:\n",
13356 filedata
->num_dynamic_syms
),
13357 filedata
->num_dynamic_syms
);
13360 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
13362 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
13364 for (si
= 0; si
< filedata
->num_dynamic_syms
; si
++)
13365 print_dynamic_symbol (filedata
, si
, filedata
->dynamic_symbols
, NULL
,
13366 filedata
->dynamic_strings
,
13367 filedata
->dynamic_strings_length
);
13369 else if ((do_dyn_syms
|| (do_syms
&& !do_using_dynamic
))
13370 && filedata
->section_headers
!= NULL
)
13374 for (i
= 0, section
= filedata
->section_headers
;
13375 i
< filedata
->file_header
.e_shnum
;
13378 char * strtab
= NULL
;
13379 unsigned long int strtab_size
= 0;
13380 Elf_Internal_Sym
* symtab
;
13381 unsigned long si
, num_syms
;
13383 if ((section
->sh_type
!= SHT_SYMTAB
13384 && section
->sh_type
!= SHT_DYNSYM
)
13386 && section
->sh_type
== SHT_SYMTAB
))
13389 if (section
->sh_entsize
== 0)
13391 printf (_("\nSymbol table '%s' has a sh_entsize of zero!\n"),
13392 printable_section_name (filedata
, section
));
13396 num_syms
= section
->sh_size
/ section
->sh_entsize
;
13398 if (filedata
->is_separate
)
13399 printf (ngettext ("\nIn linked file '%s' symbol section '%s' contains %lu entry:\n",
13400 "\nIn linked file '%s' symbol section '%s' contains %lu entries:\n",
13402 filedata
->file_name
,
13403 printable_section_name (filedata
, section
),
13406 printf (ngettext ("\nSymbol table '%s' contains %lu entry:\n",
13407 "\nSymbol table '%s' contains %lu entries:\n",
13409 printable_section_name (filedata
, section
),
13413 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
13415 printf (_(" Num: Value Size Type Bind Vis Ndx Name\n"));
13417 symtab
= get_elf_symbols (filedata
, section
, & num_syms
);
13418 if (symtab
== NULL
)
13421 if (section
->sh_link
== filedata
->file_header
.e_shstrndx
)
13423 strtab
= filedata
->string_table
;
13424 strtab_size
= filedata
->string_table_length
;
13426 else if (section
->sh_link
< filedata
->file_header
.e_shnum
)
13428 Elf_Internal_Shdr
* string_sec
;
13430 string_sec
= filedata
->section_headers
+ section
->sh_link
;
13432 strtab
= (char *) get_data (NULL
, filedata
, string_sec
->sh_offset
,
13433 1, string_sec
->sh_size
,
13434 _("string table"));
13435 strtab_size
= strtab
!= NULL
? string_sec
->sh_size
: 0;
13438 for (si
= 0; si
< num_syms
; si
++)
13439 print_dynamic_symbol (filedata
, si
, symtab
, section
,
13440 strtab
, strtab_size
);
13443 if (strtab
!= filedata
->string_table
)
13449 (_("\nDynamic symbol information is not available for displaying symbols.\n"));
13451 if (do_histogram
&& filedata
->buckets
!= NULL
)
13453 unsigned long * lengths
;
13454 unsigned long * counts
;
13457 unsigned long maxlength
= 0;
13458 unsigned long nzero_counts
= 0;
13459 unsigned long nsyms
= 0;
13462 printf (ngettext ("\nHistogram for bucket list length "
13463 "(total of %lu bucket):\n",
13464 "\nHistogram for bucket list length "
13465 "(total of %lu buckets):\n",
13466 (unsigned long) filedata
->nbuckets
),
13467 (unsigned long) filedata
->nbuckets
);
13469 lengths
= (unsigned long *) calloc (filedata
->nbuckets
,
13470 sizeof (*lengths
));
13471 if (lengths
== NULL
)
13473 error (_("Out of memory allocating space for histogram buckets\n"));
13476 visited
= xcmalloc (filedata
->nchains
, 1);
13477 memset (visited
, 0, filedata
->nchains
);
13479 printf (_(" Length Number %% of total Coverage\n"));
13480 for (hn
= 0; hn
< filedata
->nbuckets
; ++hn
)
13482 for (si
= filedata
->buckets
[hn
]; si
> 0; si
= filedata
->chains
[si
])
13485 if (maxlength
< ++lengths
[hn
])
13487 if (si
>= filedata
->nchains
|| visited
[si
])
13489 error (_("histogram chain is corrupt\n"));
13497 counts
= (unsigned long *) calloc (maxlength
+ 1, sizeof (*counts
));
13498 if (counts
== NULL
)
13501 error (_("Out of memory allocating space for histogram counts\n"));
13505 for (hn
= 0; hn
< filedata
->nbuckets
; ++hn
)
13506 ++counts
[lengths
[hn
]];
13508 if (filedata
->nbuckets
> 0)
13511 printf (" 0 %-10lu (%5.1f%%)\n",
13512 counts
[0], (counts
[0] * 100.0) / filedata
->nbuckets
);
13513 for (i
= 1; i
<= maxlength
; ++i
)
13515 nzero_counts
+= counts
[i
] * i
;
13516 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
13517 i
, counts
[i
], (counts
[i
] * 100.0) / filedata
->nbuckets
,
13518 (nzero_counts
* 100.0) / nsyms
);
13526 free (filedata
->buckets
);
13527 filedata
->buckets
= NULL
;
13528 filedata
->nbuckets
= 0;
13529 free (filedata
->chains
);
13530 filedata
->chains
= NULL
;
13532 if (do_histogram
&& filedata
->gnubuckets
!= NULL
)
13534 unsigned long * lengths
;
13535 unsigned long * counts
;
13537 unsigned long maxlength
= 0;
13538 unsigned long nzero_counts
= 0;
13539 unsigned long nsyms
= 0;
13541 printf (ngettext ("\nHistogram for `%s' bucket list length "
13542 "(total of %lu bucket):\n",
13543 "\nHistogram for `%s' bucket list length "
13544 "(total of %lu buckets):\n",
13545 (unsigned long) filedata
->ngnubuckets
),
13546 GNU_HASH_SECTION_NAME (filedata
),
13547 (unsigned long) filedata
->ngnubuckets
);
13549 lengths
= (unsigned long *) calloc (filedata
->ngnubuckets
,
13550 sizeof (*lengths
));
13551 if (lengths
== NULL
)
13553 error (_("Out of memory allocating space for gnu histogram buckets\n"));
13557 printf (_(" Length Number %% of total Coverage\n"));
13559 for (hn
= 0; hn
< filedata
->ngnubuckets
; ++hn
)
13560 if (filedata
->gnubuckets
[hn
] != 0)
13562 bfd_vma off
, length
= 1;
13564 for (off
= filedata
->gnubuckets
[hn
] - filedata
->gnusymidx
;
13565 /* PR 17531 file: 010-77222-0.004. */
13566 off
< filedata
->ngnuchains
13567 && (filedata
->gnuchains
[off
] & 1) == 0;
13570 lengths
[hn
] = length
;
13571 if (length
> maxlength
)
13572 maxlength
= length
;
13576 counts
= (unsigned long *) calloc (maxlength
+ 1, sizeof (*counts
));
13577 if (counts
== NULL
)
13580 error (_("Out of memory allocating space for gnu histogram counts\n"));
13584 for (hn
= 0; hn
< filedata
->ngnubuckets
; ++hn
)
13585 ++counts
[lengths
[hn
]];
13587 if (filedata
->ngnubuckets
> 0)
13590 printf (" 0 %-10lu (%5.1f%%)\n",
13591 counts
[0], (counts
[0] * 100.0) / filedata
->ngnubuckets
);
13592 for (j
= 1; j
<= maxlength
; ++j
)
13594 nzero_counts
+= counts
[j
] * j
;
13595 printf ("%7lu %-10lu (%5.1f%%) %5.1f%%\n",
13596 j
, counts
[j
], (counts
[j
] * 100.0) / filedata
->ngnubuckets
,
13597 (nzero_counts
* 100.0) / nsyms
);
13604 free (filedata
->gnubuckets
);
13605 filedata
->gnubuckets
= NULL
;
13606 filedata
->ngnubuckets
= 0;
13607 free (filedata
->gnuchains
);
13608 filedata
->gnuchains
= NULL
;
13609 filedata
->ngnuchains
= 0;
13610 free (filedata
->mipsxlat
);
13611 filedata
->mipsxlat
= NULL
;
13615 free (filedata
->gnubuckets
);
13616 filedata
->gnubuckets
= NULL
;
13617 filedata
->ngnubuckets
= 0;
13618 free (filedata
->gnuchains
);
13619 filedata
->gnuchains
= NULL
;
13620 filedata
->ngnuchains
= 0;
13621 free (filedata
->mipsxlat
);
13622 filedata
->mipsxlat
= NULL
;
13623 free (filedata
->buckets
);
13624 filedata
->buckets
= NULL
;
13625 filedata
->nbuckets
= 0;
13626 free (filedata
->chains
);
13627 filedata
->chains
= NULL
;
13632 process_syminfo (Filedata
* filedata
)
13636 if (filedata
->dynamic_syminfo
== NULL
13638 /* No syminfo, this is ok. */
13641 /* There better should be a dynamic symbol section. */
13642 if (filedata
->dynamic_symbols
== NULL
|| filedata
->dynamic_strings
== NULL
)
13645 if (filedata
->is_separate
)
13646 printf (ngettext ("\nIn linked file '%s: the dynamic info segment at offset 0x%lx contains %d entry:\n",
13647 "\nIn linked file '%s: the dynamic info segment at offset 0x%lx contains %d entries:\n",
13648 filedata
->dynamic_syminfo_nent
),
13649 filedata
->file_name
,
13650 filedata
->dynamic_syminfo_offset
,
13651 filedata
->dynamic_syminfo_nent
);
13653 printf (ngettext ("\nDynamic info segment at offset 0x%lx "
13654 "contains %d entry:\n",
13655 "\nDynamic info segment at offset 0x%lx "
13656 "contains %d entries:\n",
13657 filedata
->dynamic_syminfo_nent
),
13658 filedata
->dynamic_syminfo_offset
,
13659 filedata
->dynamic_syminfo_nent
);
13661 printf (_(" Num: Name BoundTo Flags\n"));
13662 for (i
= 0; i
< filedata
->dynamic_syminfo_nent
; ++i
)
13664 unsigned short int flags
= filedata
->dynamic_syminfo
[i
].si_flags
;
13666 printf ("%4d: ", i
);
13667 if (i
>= filedata
->num_dynamic_syms
)
13668 printf (_("<corrupt index>"));
13669 else if (valid_dynamic_name (filedata
, filedata
->dynamic_symbols
[i
].st_name
))
13670 print_symbol (30, get_dynamic_name (filedata
,
13671 filedata
->dynamic_symbols
[i
].st_name
));
13673 printf (_("<corrupt: %19ld>"), filedata
->dynamic_symbols
[i
].st_name
);
13676 switch (filedata
->dynamic_syminfo
[i
].si_boundto
)
13678 case SYMINFO_BT_SELF
:
13679 fputs ("SELF ", stdout
);
13681 case SYMINFO_BT_PARENT
:
13682 fputs ("PARENT ", stdout
);
13685 if (filedata
->dynamic_syminfo
[i
].si_boundto
> 0
13686 && filedata
->dynamic_syminfo
[i
].si_boundto
< filedata
->dynamic_nent
13687 && valid_dynamic_name (filedata
,
13688 filedata
->dynamic_section
[filedata
->dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
))
13690 print_symbol (10, get_dynamic_name (filedata
,
13691 filedata
->dynamic_section
[filedata
->dynamic_syminfo
[i
].si_boundto
].d_un
.d_val
));
13695 printf ("%-10d ", filedata
->dynamic_syminfo
[i
].si_boundto
);
13699 if (flags
& SYMINFO_FLG_DIRECT
)
13700 printf (" DIRECT");
13701 if (flags
& SYMINFO_FLG_PASSTHRU
)
13702 printf (" PASSTHRU");
13703 if (flags
& SYMINFO_FLG_COPY
)
13705 if (flags
& SYMINFO_FLG_LAZYLOAD
)
13706 printf (" LAZYLOAD");
13714 /* A macro which evaluates to TRUE if the region ADDR .. ADDR + NELEM
13715 is contained by the region START .. END. The types of ADDR, START
13716 and END should all be the same. Note both ADDR + NELEM and END
13717 point to just beyond the end of the regions that are being tested. */
13718 #define IN_RANGE(START,END,ADDR,NELEM) \
13719 (((ADDR) >= (START)) && ((ADDR) < (END)) && ((ADDR) + (NELEM) <= (END)))
13721 /* Check to see if the given reloc needs to be handled in a target specific
13722 manner. If so then process the reloc and return TRUE otherwise return
13725 If called with reloc == NULL, then this is a signal that reloc processing
13726 for the current section has finished, and any saved state should be
13730 target_specific_reloc_handling (Filedata
* filedata
,
13731 Elf_Internal_Rela
* reloc
,
13732 unsigned char * start
,
13733 unsigned char * end
,
13734 Elf_Internal_Sym
* symtab
,
13735 unsigned long num_syms
)
13737 unsigned int reloc_type
= 0;
13738 unsigned long sym_index
= 0;
13742 reloc_type
= get_reloc_type (filedata
, reloc
->r_info
);
13743 sym_index
= get_reloc_symindex (reloc
->r_info
);
13746 switch (filedata
->file_header
.e_machine
)
13749 case EM_MSP430_OLD
:
13751 static Elf_Internal_Sym
* saved_sym
= NULL
;
13759 switch (reloc_type
)
13761 case 10: /* R_MSP430_SYM_DIFF */
13762 case 12: /* R_MSP430_GNU_SUB_ULEB128 */
13763 if (uses_msp430x_relocs (filedata
))
13765 /* Fall through. */
13766 case 21: /* R_MSP430X_SYM_DIFF */
13767 case 23: /* R_MSP430X_GNU_SUB_ULEB128 */
13769 if (sym_index
>= num_syms
)
13770 error (_("MSP430 SYM_DIFF reloc contains invalid symbol index %lu\n"),
13773 saved_sym
= symtab
+ sym_index
;
13776 case 1: /* R_MSP430_32 or R_MSP430_ABS32 */
13777 case 3: /* R_MSP430_16 or R_MSP430_ABS8 */
13778 goto handle_sym_diff
;
13780 case 5: /* R_MSP430_16_BYTE */
13781 case 9: /* R_MSP430_8 */
13782 case 11: /* R_MSP430_GNU_SET_ULEB128 */
13783 if (uses_msp430x_relocs (filedata
))
13785 goto handle_sym_diff
;
13787 case 2: /* R_MSP430_ABS16 */
13788 case 15: /* R_MSP430X_ABS16 */
13789 case 22: /* R_MSP430X_GNU_SET_ULEB128 */
13790 if (! uses_msp430x_relocs (filedata
))
13792 goto handle_sym_diff
;
13795 if (saved_sym
!= NULL
)
13798 unsigned int reloc_size
= 0;
13800 switch (reloc_type
)
13802 case 1: /* R_MSP430_32 or R_MSP430_ABS32 */
13805 case 11: /* R_MSP430_GNU_SET_ULEB128 */
13806 case 22: /* R_MSP430X_GNU_SET_ULEB128 */
13807 if (reloc
->r_offset
< (size_t) (end
- start
))
13808 read_leb128 (start
+ reloc
->r_offset
, end
, false,
13809 &reloc_size
, &leb_ret
);
13816 if (leb_ret
!= 0 || reloc_size
== 0 || reloc_size
> 8)
13817 error (_("MSP430 ULEB128 field at 0x%lx contains invalid "
13818 "ULEB128 value\n"),
13819 (long) reloc
->r_offset
);
13820 else if (sym_index
>= num_syms
)
13821 error (_("MSP430 reloc contains invalid symbol index %lu\n"),
13825 value
= reloc
->r_addend
+ (symtab
[sym_index
].st_value
13826 - saved_sym
->st_value
);
13828 if (IN_RANGE (start
, end
, start
+ reloc
->r_offset
, reloc_size
))
13829 byte_put (start
+ reloc
->r_offset
, value
, reloc_size
);
13832 error (_("MSP430 sym diff reloc contains invalid offset: 0x%lx\n"),
13833 (long) reloc
->r_offset
);
13842 if (saved_sym
!= NULL
)
13843 error (_("Unhandled MSP430 reloc type found after SYM_DIFF reloc\n"));
13850 case EM_CYGNUS_MN10300
:
13852 static Elf_Internal_Sym
* saved_sym
= NULL
;
13860 switch (reloc_type
)
13862 case 34: /* R_MN10300_ALIGN */
13864 case 33: /* R_MN10300_SYM_DIFF */
13865 if (sym_index
>= num_syms
)
13866 error (_("MN10300_SYM_DIFF reloc contains invalid symbol index %lu\n"),
13869 saved_sym
= symtab
+ sym_index
;
13872 case 1: /* R_MN10300_32 */
13873 case 2: /* R_MN10300_16 */
13874 if (saved_sym
!= NULL
)
13876 int reloc_size
= reloc_type
== 1 ? 4 : 2;
13879 if (sym_index
>= num_syms
)
13880 error (_("MN10300 reloc contains invalid symbol index %lu\n"),
13884 value
= reloc
->r_addend
+ (symtab
[sym_index
].st_value
13885 - saved_sym
->st_value
);
13887 if (IN_RANGE (start
, end
, start
+ reloc
->r_offset
, reloc_size
))
13888 byte_put (start
+ reloc
->r_offset
, value
, reloc_size
);
13890 error (_("MN10300 sym diff reloc contains invalid offset: 0x%lx\n"),
13891 (long) reloc
->r_offset
);
13899 if (saved_sym
!= NULL
)
13900 error (_("Unhandled MN10300 reloc type found after SYM_DIFF reloc\n"));
13908 static bfd_vma saved_sym1
= 0;
13909 static bfd_vma saved_sym2
= 0;
13910 static bfd_vma value
;
13914 saved_sym1
= saved_sym2
= 0;
13918 switch (reloc_type
)
13920 case 0x80: /* R_RL78_SYM. */
13921 saved_sym1
= saved_sym2
;
13922 if (sym_index
>= num_syms
)
13923 error (_("RL78_SYM reloc contains invalid symbol index %lu\n"),
13927 saved_sym2
= symtab
[sym_index
].st_value
;
13928 saved_sym2
+= reloc
->r_addend
;
13932 case 0x83: /* R_RL78_OPsub. */
13933 value
= saved_sym1
- saved_sym2
;
13934 saved_sym2
= saved_sym1
= 0;
13938 case 0x41: /* R_RL78_ABS32. */
13939 if (IN_RANGE (start
, end
, start
+ reloc
->r_offset
, 4))
13940 byte_put (start
+ reloc
->r_offset
, value
, 4);
13942 error (_("RL78 sym diff reloc contains invalid offset: 0x%lx\n"),
13943 (long) reloc
->r_offset
);
13947 case 0x43: /* R_RL78_ABS16. */
13948 if (IN_RANGE (start
, end
, start
+ reloc
->r_offset
, 2))
13949 byte_put (start
+ reloc
->r_offset
, value
, 2);
13951 error (_("RL78 sym diff reloc contains invalid offset: 0x%lx\n"),
13952 (long) reloc
->r_offset
);
13966 /* Returns TRUE iff RELOC_TYPE is a 32-bit absolute RELA relocation used in
13967 DWARF debug sections. This is a target specific test. Note - we do not
13968 go through the whole including-target-headers-multiple-times route, (as
13969 we have already done with <elf/h8.h>) because this would become very
13970 messy and even then this function would have to contain target specific
13971 information (the names of the relocs instead of their numeric values).
13972 FIXME: This is not the correct way to solve this problem. The proper way
13973 is to have target specific reloc sizing and typing functions created by
13974 the reloc-macros.h header, in the same way that it already creates the
13975 reloc naming functions. */
13978 is_32bit_abs_reloc (Filedata
* filedata
, unsigned int reloc_type
)
13980 /* Please keep this table alpha-sorted for ease of visual lookup. */
13981 switch (filedata
->file_header
.e_machine
)
13985 return reloc_type
== 1; /* R_386_32. */
13987 return reloc_type
== 1; /* R_68K_32. */
13989 return reloc_type
== 1; /* R_860_32. */
13991 return reloc_type
== 2; /* R_960_32. */
13993 return (reloc_type
== 258
13994 || reloc_type
== 1); /* R_AARCH64_ABS32 || R_AARCH64_P32_ABS32 */
13996 return reloc_type
== 11; /* R_BPF_DATA_32 */
13997 case EM_ADAPTEVA_EPIPHANY
:
13998 return reloc_type
== 3;
14000 return reloc_type
== 1; /* R_ALPHA_REFLONG. */
14002 return reloc_type
== 1; /* R_ARC_32. */
14003 case EM_ARC_COMPACT
:
14004 case EM_ARC_COMPACT2
:
14005 return reloc_type
== 4; /* R_ARC_32. */
14007 return reloc_type
== 2; /* R_ARM_ABS32 */
14010 return reloc_type
== 1;
14012 return reloc_type
== 0x12; /* R_byte4_data. */
14014 return reloc_type
== 3; /* R_CRIS_32. */
14016 return reloc_type
== 3; /* R_CR16_NUM32. */
14018 return reloc_type
== 15; /* R_CRX_NUM32. */
14020 return reloc_type
== 1; /* R_CKCORE_ADDR32. */
14021 case EM_CYGNUS_FRV
:
14022 return reloc_type
== 1;
14023 case EM_CYGNUS_D10V
:
14025 return reloc_type
== 6; /* R_D10V_32. */
14026 case EM_CYGNUS_D30V
:
14028 return reloc_type
== 12; /* R_D30V_32_NORMAL. */
14030 return reloc_type
== 3; /* R_DLX_RELOC_32. */
14031 case EM_CYGNUS_FR30
:
14033 return reloc_type
== 3; /* R_FR30_32. */
14035 return reloc_type
== 1; /* R_FT32_32. */
14039 return reloc_type
== 1; /* R_H8_DIR32. */
14041 return (reloc_type
== 0x64 /* R_IA64_SECREL32MSB. */
14042 || reloc_type
== 0x65 /* R_IA64_SECREL32LSB. */
14043 || reloc_type
== 0x24 /* R_IA64_DIR32MSB. */
14044 || reloc_type
== 0x25 /* R_IA64_DIR32LSB. */);
14047 return reloc_type
== 2; /* R_IP2K_32. */
14049 return reloc_type
== 2; /* R_IQ2000_32. */
14050 case EM_LATTICEMICO32
:
14051 return reloc_type
== 3; /* R_LM32_32. */
14053 return reloc_type
== 1; /* R_LARCH_32. */
14056 return reloc_type
== 3; /* R_M32C_32. */
14058 return reloc_type
== 34; /* R_M32R_32_RELA. */
14061 return reloc_type
== 6; /* R_M68HC11_32. */
14063 return reloc_type
== 7 || /* R_S12Z_EXT32 */
14064 reloc_type
== 6; /* R_S12Z_CW32. */
14066 return reloc_type
== 1; /* R_MCORE_ADDR32. */
14067 case EM_CYGNUS_MEP
:
14068 return reloc_type
== 4; /* R_MEP_32. */
14070 return reloc_type
== 2; /* R_METAG_ADDR32. */
14071 case EM_MICROBLAZE
:
14072 return reloc_type
== 1; /* R_MICROBLAZE_32. */
14074 return reloc_type
== 2; /* R_MIPS_32. */
14076 return reloc_type
== 4; /* R_MMIX_32. */
14077 case EM_CYGNUS_MN10200
:
14079 return reloc_type
== 1; /* R_MN10200_32. */
14080 case EM_CYGNUS_MN10300
:
14082 return reloc_type
== 1; /* R_MN10300_32. */
14084 return reloc_type
== 1; /* R_MOXIE_32. */
14085 case EM_MSP430_OLD
:
14087 return reloc_type
== 1; /* R_MSP430_32 or R_MSP320_ABS32. */
14089 return reloc_type
== 2; /* R_MT_32. */
14091 return reloc_type
== 20; /* R_NDS32_RELA. */
14092 case EM_ALTERA_NIOS2
:
14093 return reloc_type
== 12; /* R_NIOS2_BFD_RELOC_32. */
14095 return reloc_type
== 1; /* R_NIOS_32. */
14097 return reloc_type
== 1; /* R_OR1K_32. */
14099 return (reloc_type
== 1 /* R_PARISC_DIR32. */
14100 || reloc_type
== 2 /* R_PARISC_DIR21L. */
14101 || reloc_type
== 41); /* R_PARISC_SECREL32. */
14104 return reloc_type
== 1; /* R_PJ_DATA_DIR32. */
14106 return reloc_type
== 1; /* R_PPC64_ADDR32. */
14108 return reloc_type
== 1; /* R_PPC_ADDR32. */
14110 return reloc_type
== 11; /* R_PRU_BFD_RELOC_32. */
14112 return reloc_type
== 1; /* R_RISCV_32. */
14114 return reloc_type
== 1; /* R_RL78_DIR32. */
14116 return reloc_type
== 1; /* R_RX_DIR32. */
14118 return reloc_type
== 1; /* R_I370_ADDR31. */
14121 return reloc_type
== 4; /* R_S390_32. */
14123 return reloc_type
== 8; /* R_SCORE_ABS32. */
14125 return reloc_type
== 1; /* R_SH_DIR32. */
14126 case EM_SPARC32PLUS
:
14129 return reloc_type
== 3 /* R_SPARC_32. */
14130 || reloc_type
== 23; /* R_SPARC_UA32. */
14132 return reloc_type
== 6; /* R_SPU_ADDR32 */
14134 return reloc_type
== 1; /* R_C6000_ABS32. */
14136 return reloc_type
== 2; /* R_TILEGX_32. */
14138 return reloc_type
== 1; /* R_TILEPRO_32. */
14139 case EM_CYGNUS_V850
:
14141 return reloc_type
== 6; /* R_V850_ABS32. */
14143 return reloc_type
== 0x33; /* R_V810_WORD. */
14145 return reloc_type
== 1; /* R_VAX_32. */
14147 return reloc_type
== 3; /* R_VISIUM_32. */
14148 case EM_WEBASSEMBLY
:
14149 return reloc_type
== 1; /* R_WASM32_32. */
14153 return reloc_type
== 10; /* R_X86_64_32. */
14156 return reloc_type
== 3; /* R_XC16C_ABS_32. */
14158 return reloc_type
== 4; /* R_XGATE_32. */
14160 return reloc_type
== 1; /* R_XSTROMY16_32. */
14161 case EM_XTENSA_OLD
:
14163 return reloc_type
== 1; /* R_XTENSA_32. */
14165 return reloc_type
== 6; /* R_Z80_32. */
14168 static unsigned int prev_warn
= 0;
14170 /* Avoid repeating the same warning multiple times. */
14171 if (prev_warn
!= filedata
->file_header
.e_machine
)
14172 error (_("Missing knowledge of 32-bit reloc types used in DWARF sections of machine number %d\n"),
14173 filedata
->file_header
.e_machine
);
14174 prev_warn
= filedata
->file_header
.e_machine
;
14180 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14181 a 32-bit pc-relative RELA relocation used in DWARF debug sections. */
14184 is_32bit_pcrel_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14186 switch (filedata
->file_header
.e_machine
)
14187 /* Please keep this table alpha-sorted for ease of visual lookup. */
14191 return reloc_type
== 2; /* R_386_PC32. */
14193 return reloc_type
== 4; /* R_68K_PC32. */
14195 return reloc_type
== 261; /* R_AARCH64_PREL32 */
14196 case EM_ADAPTEVA_EPIPHANY
:
14197 return reloc_type
== 6;
14199 return reloc_type
== 10; /* R_ALPHA_SREL32. */
14200 case EM_ARC_COMPACT
:
14201 case EM_ARC_COMPACT2
:
14202 return reloc_type
== 49; /* R_ARC_32_PCREL. */
14204 return reloc_type
== 3; /* R_ARM_REL32 */
14207 return reloc_type
== 36; /* R_AVR_32_PCREL. */
14208 case EM_MICROBLAZE
:
14209 return reloc_type
== 2; /* R_MICROBLAZE_32_PCREL. */
14211 return reloc_type
== 9; /* R_OR1K_32_PCREL. */
14213 return reloc_type
== 9; /* R_PARISC_PCREL32. */
14215 return reloc_type
== 26; /* R_PPC_REL32. */
14217 return reloc_type
== 26; /* R_PPC64_REL32. */
14219 return reloc_type
== 57; /* R_RISCV_32_PCREL. */
14222 return reloc_type
== 5; /* R_390_PC32. */
14224 return reloc_type
== 2; /* R_SH_REL32. */
14225 case EM_SPARC32PLUS
:
14228 return reloc_type
== 6; /* R_SPARC_DISP32. */
14230 return reloc_type
== 13; /* R_SPU_REL32. */
14232 return reloc_type
== 6; /* R_TILEGX_32_PCREL. */
14234 return reloc_type
== 4; /* R_TILEPRO_32_PCREL. */
14236 return reloc_type
== 6; /* R_VISIUM_32_PCREL */
14240 return reloc_type
== 2; /* R_X86_64_PC32. */
14242 return reloc_type
== 4; /* R_VAX_PCREL32. */
14243 case EM_XTENSA_OLD
:
14245 return reloc_type
== 14; /* R_XTENSA_32_PCREL. */
14247 /* Do not abort or issue an error message here. Not all targets use
14248 pc-relative 32-bit relocs in their DWARF debug information and we
14249 have already tested for target coverage in is_32bit_abs_reloc. A
14250 more helpful warning message will be generated by apply_relocations
14251 anyway, so just return. */
14256 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14257 a 64-bit absolute RELA relocation used in DWARF debug sections. */
14260 is_64bit_abs_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14262 switch (filedata
->file_header
.e_machine
)
14265 return reloc_type
== 257; /* R_AARCH64_ABS64. */
14267 return reloc_type
== 2; /* R_ALPHA_REFQUAD. */
14269 return (reloc_type
== 0x26 /* R_IA64_DIR64MSB. */
14270 || reloc_type
== 0x27 /* R_IA64_DIR64LSB. */);
14272 return reloc_type
== 2; /* R_LARCH_64 */
14274 return reloc_type
== 80; /* R_PARISC_DIR64. */
14276 return reloc_type
== 38; /* R_PPC64_ADDR64. */
14278 return reloc_type
== 2; /* R_RISCV_64. */
14279 case EM_SPARC32PLUS
:
14282 return reloc_type
== 32 /* R_SPARC_64. */
14283 || reloc_type
== 54; /* R_SPARC_UA64. */
14287 return reloc_type
== 1; /* R_X86_64_64. */
14290 return reloc_type
== 22; /* R_S390_64. */
14292 return reloc_type
== 1; /* R_TILEGX_64. */
14294 return reloc_type
== 18; /* R_MIPS_64. */
14300 /* Like is_32bit_pcrel_reloc except that it returns TRUE iff RELOC_TYPE is
14301 a 64-bit pc-relative RELA relocation used in DWARF debug sections. */
14304 is_64bit_pcrel_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14306 switch (filedata
->file_header
.e_machine
)
14309 return reloc_type
== 260; /* R_AARCH64_PREL64. */
14311 return reloc_type
== 11; /* R_ALPHA_SREL64. */
14313 return (reloc_type
== 0x4e /* R_IA64_PCREL64MSB. */
14314 || reloc_type
== 0x4f /* R_IA64_PCREL64LSB. */);
14316 return reloc_type
== 72; /* R_PARISC_PCREL64. */
14318 return reloc_type
== 44; /* R_PPC64_REL64. */
14319 case EM_SPARC32PLUS
:
14322 return reloc_type
== 46; /* R_SPARC_DISP64. */
14326 return reloc_type
== 24; /* R_X86_64_PC64. */
14329 return reloc_type
== 23; /* R_S390_PC64. */
14331 return reloc_type
== 5; /* R_TILEGX_64_PCREL. */
14337 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14338 a 24-bit absolute RELA relocation used in DWARF debug sections. */
14341 is_24bit_abs_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14343 switch (filedata
->file_header
.e_machine
)
14345 case EM_CYGNUS_MN10200
:
14347 return reloc_type
== 4; /* R_MN10200_24. */
14349 return reloc_type
== 5; /* R_FT32_20. */
14351 return reloc_type
== 5; /* R_Z80_24. */
14357 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14358 a 16-bit absolute RELA relocation used in DWARF debug sections. */
14361 is_16bit_abs_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14363 /* Please keep this table alpha-sorted for ease of visual lookup. */
14364 switch (filedata
->file_header
.e_machine
)
14367 case EM_ARC_COMPACT
:
14368 case EM_ARC_COMPACT2
:
14369 return reloc_type
== 2; /* R_ARC_16. */
14370 case EM_ADAPTEVA_EPIPHANY
:
14371 return reloc_type
== 5;
14374 return reloc_type
== 4; /* R_AVR_16. */
14375 case EM_CYGNUS_D10V
:
14377 return reloc_type
== 3; /* R_D10V_16. */
14379 return reloc_type
== 2; /* R_FT32_16. */
14383 return reloc_type
== R_H8_DIR16
;
14386 return reloc_type
== 1; /* R_IP2K_16. */
14389 return reloc_type
== 1; /* R_M32C_16 */
14390 case EM_CYGNUS_MN10200
:
14392 return reloc_type
== 2; /* R_MN10200_16. */
14393 case EM_CYGNUS_MN10300
:
14395 return reloc_type
== 2; /* R_MN10300_16. */
14397 if (uses_msp430x_relocs (filedata
))
14398 return reloc_type
== 2; /* R_MSP430_ABS16. */
14399 /* Fall through. */
14400 case EM_MSP430_OLD
:
14401 return reloc_type
== 5; /* R_MSP430_16_BYTE. */
14403 return reloc_type
== 19; /* R_NDS32_RELA. */
14404 case EM_ALTERA_NIOS2
:
14405 return reloc_type
== 13; /* R_NIOS2_BFD_RELOC_16. */
14407 return reloc_type
== 9; /* R_NIOS_16. */
14409 return reloc_type
== 2; /* R_OR1K_16. */
14411 return reloc_type
== 55; /* R_RISCV_SET16. */
14413 return reloc_type
== 8; /* R_PRU_BFD_RELOC_16. */
14415 return reloc_type
== 2; /* R_C6000_ABS16. */
14417 return reloc_type
== 2; /* R_VISIUM_16. */
14420 return reloc_type
== 2; /* R_XC16C_ABS_16. */
14422 return reloc_type
== 3; /* R_XGATE_16. */
14424 return reloc_type
== 4; /* R_Z80_16. */
14430 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14431 a 8-bit absolute RELA relocation used in DWARF debug sections. */
14434 is_8bit_abs_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14436 switch (filedata
->file_header
.e_machine
)
14439 return reloc_type
== 54; /* R_RISCV_SET8. */
14441 return reloc_type
== 1; /* R_Z80_8. */
14447 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14448 a 6-bit absolute RELA relocation used in DWARF debug sections. */
14451 is_6bit_abs_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14453 switch (filedata
->file_header
.e_machine
)
14456 return reloc_type
== 53; /* R_RISCV_SET6. */
14462 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14463 a 32-bit inplace add RELA relocation used in DWARF debug sections. */
14466 is_32bit_inplace_add_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14468 /* Please keep this table alpha-sorted for ease of visual lookup. */
14469 switch (filedata
->file_header
.e_machine
)
14472 return reloc_type
== 35; /* R_RISCV_ADD32. */
14478 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14479 a 32-bit inplace sub RELA relocation used in DWARF debug sections. */
14482 is_32bit_inplace_sub_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14484 /* Please keep this table alpha-sorted for ease of visual lookup. */
14485 switch (filedata
->file_header
.e_machine
)
14488 return reloc_type
== 39; /* R_RISCV_SUB32. */
14494 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14495 a 64-bit inplace add RELA relocation used in DWARF debug sections. */
14498 is_64bit_inplace_add_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14500 /* Please keep this table alpha-sorted for ease of visual lookup. */
14501 switch (filedata
->file_header
.e_machine
)
14504 return reloc_type
== 36; /* R_RISCV_ADD64. */
14510 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14511 a 64-bit inplace sub RELA relocation used in DWARF debug sections. */
14514 is_64bit_inplace_sub_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14516 /* Please keep this table alpha-sorted for ease of visual lookup. */
14517 switch (filedata
->file_header
.e_machine
)
14520 return reloc_type
== 40; /* R_RISCV_SUB64. */
14526 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14527 a 16-bit inplace add RELA relocation used in DWARF debug sections. */
14530 is_16bit_inplace_add_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14532 /* Please keep this table alpha-sorted for ease of visual lookup. */
14533 switch (filedata
->file_header
.e_machine
)
14536 return reloc_type
== 34; /* R_RISCV_ADD16. */
14542 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14543 a 16-bit inplace sub RELA relocation used in DWARF debug sections. */
14546 is_16bit_inplace_sub_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14548 /* Please keep this table alpha-sorted for ease of visual lookup. */
14549 switch (filedata
->file_header
.e_machine
)
14552 return reloc_type
== 38; /* R_RISCV_SUB16. */
14558 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14559 a 8-bit inplace add RELA relocation used in DWARF debug sections. */
14562 is_8bit_inplace_add_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14564 /* Please keep this table alpha-sorted for ease of visual lookup. */
14565 switch (filedata
->file_header
.e_machine
)
14568 return reloc_type
== 33; /* R_RISCV_ADD8. */
14574 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14575 a 8-bit inplace sub RELA relocation used in DWARF debug sections. */
14578 is_8bit_inplace_sub_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14580 /* Please keep this table alpha-sorted for ease of visual lookup. */
14581 switch (filedata
->file_header
.e_machine
)
14584 return reloc_type
== 37; /* R_RISCV_SUB8. */
14590 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
14591 a 6-bit inplace sub RELA relocation used in DWARF debug sections. */
14594 is_6bit_inplace_sub_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14596 switch (filedata
->file_header
.e_machine
)
14599 return reloc_type
== 52; /* R_RISCV_SUB6. */
14605 /* Returns TRUE iff RELOC_TYPE is a NONE relocation used for discarded
14606 relocation entries (possibly formerly used for SHT_GROUP sections). */
14609 is_none_reloc (Filedata
* filedata
, unsigned int reloc_type
)
14611 switch (filedata
->file_header
.e_machine
)
14613 case EM_386
: /* R_386_NONE. */
14614 case EM_68K
: /* R_68K_NONE. */
14615 case EM_ADAPTEVA_EPIPHANY
:
14616 case EM_ALPHA
: /* R_ALPHA_NONE. */
14617 case EM_ALTERA_NIOS2
: /* R_NIOS2_NONE. */
14618 case EM_ARC
: /* R_ARC_NONE. */
14619 case EM_ARC_COMPACT2
: /* R_ARC_NONE. */
14620 case EM_ARC_COMPACT
: /* R_ARC_NONE. */
14621 case EM_ARM
: /* R_ARM_NONE. */
14622 case EM_C166
: /* R_XC16X_NONE. */
14623 case EM_CRIS
: /* R_CRIS_NONE. */
14624 case EM_FT32
: /* R_FT32_NONE. */
14625 case EM_IA_64
: /* R_IA64_NONE. */
14626 case EM_K1OM
: /* R_X86_64_NONE. */
14627 case EM_L1OM
: /* R_X86_64_NONE. */
14628 case EM_M32R
: /* R_M32R_NONE. */
14629 case EM_MIPS
: /* R_MIPS_NONE. */
14630 case EM_MN10300
: /* R_MN10300_NONE. */
14631 case EM_MOXIE
: /* R_MOXIE_NONE. */
14632 case EM_NIOS32
: /* R_NIOS_NONE. */
14633 case EM_OR1K
: /* R_OR1K_NONE. */
14634 case EM_PARISC
: /* R_PARISC_NONE. */
14635 case EM_PPC64
: /* R_PPC64_NONE. */
14636 case EM_PPC
: /* R_PPC_NONE. */
14637 case EM_RISCV
: /* R_RISCV_NONE. */
14638 case EM_S390
: /* R_390_NONE. */
14640 case EM_SH
: /* R_SH_NONE. */
14641 case EM_SPARC32PLUS
:
14642 case EM_SPARC
: /* R_SPARC_NONE. */
14644 case EM_TILEGX
: /* R_TILEGX_NONE. */
14645 case EM_TILEPRO
: /* R_TILEPRO_NONE. */
14646 case EM_TI_C6000
:/* R_C6000_NONE. */
14647 case EM_X86_64
: /* R_X86_64_NONE. */
14649 case EM_Z80
: /* R_Z80_NONE. */
14650 case EM_WEBASSEMBLY
: /* R_WASM32_NONE. */
14651 return reloc_type
== 0;
14654 return reloc_type
== 0 || reloc_type
== 256;
14657 return (reloc_type
== 0 /* R_AVR_NONE. */
14658 || reloc_type
== 30 /* R_AVR_DIFF8. */
14659 || reloc_type
== 31 /* R_AVR_DIFF16. */
14660 || reloc_type
== 32 /* R_AVR_DIFF32. */);
14662 return reloc_type
== 3; /* R_METAG_NONE. */
14664 return (reloc_type
== 0 /* R_XTENSA_NONE. */
14665 || reloc_type
== 204 /* R_NDS32_DIFF8. */
14666 || reloc_type
== 205 /* R_NDS32_DIFF16. */
14667 || reloc_type
== 206 /* R_NDS32_DIFF32. */
14668 || reloc_type
== 207 /* R_NDS32_ULEB128. */);
14670 return (reloc_type
== 0 /* R_PRU_NONE. */
14671 || reloc_type
== 65 /* R_PRU_DIFF8. */
14672 || reloc_type
== 66 /* R_PRU_DIFF16. */
14673 || reloc_type
== 67 /* R_PRU_DIFF32. */);
14674 case EM_XTENSA_OLD
:
14676 return (reloc_type
== 0 /* R_XTENSA_NONE. */
14677 || reloc_type
== 17 /* R_XTENSA_DIFF8. */
14678 || reloc_type
== 18 /* R_XTENSA_DIFF16. */
14679 || reloc_type
== 19 /* R_XTENSA_DIFF32. */
14680 || reloc_type
== 57 /* R_XTENSA_PDIFF8. */
14681 || reloc_type
== 58 /* R_XTENSA_PDIFF16. */
14682 || reloc_type
== 59 /* R_XTENSA_PDIFF32. */
14683 || reloc_type
== 60 /* R_XTENSA_NDIFF8. */
14684 || reloc_type
== 61 /* R_XTENSA_NDIFF16. */
14685 || reloc_type
== 62 /* R_XTENSA_NDIFF32. */);
14690 /* Returns TRUE if there is a relocation against
14691 section NAME at OFFSET bytes. */
14694 reloc_at (struct dwarf_section
* dsec
, dwarf_vma offset
)
14696 Elf_Internal_Rela
* relocs
;
14697 Elf_Internal_Rela
* rp
;
14699 if (dsec
== NULL
|| dsec
->reloc_info
== NULL
)
14702 relocs
= (Elf_Internal_Rela
*) dsec
->reloc_info
;
14704 for (rp
= relocs
; rp
< relocs
+ dsec
->num_relocs
; ++rp
)
14705 if (rp
->r_offset
== offset
)
14711 /* Apply relocations to a section.
14712 Returns TRUE upon success, FALSE otherwise.
14713 If RELOCS_RETURN is non-NULL then it is set to point to the loaded relocs.
14714 It is then the caller's responsibility to free them. NUM_RELOCS_RETURN
14715 will be set to the number of relocs loaded.
14717 Note: So far support has been added only for those relocations
14718 which can be found in debug sections. FIXME: Add support for
14719 more relocations ? */
14722 apply_relocations (Filedata
* filedata
,
14723 const Elf_Internal_Shdr
* section
,
14724 unsigned char * start
,
14725 bfd_size_type size
,
14726 void ** relocs_return
,
14727 unsigned long * num_relocs_return
)
14729 Elf_Internal_Shdr
* relsec
;
14730 unsigned char * end
= start
+ size
;
14732 if (relocs_return
!= NULL
)
14734 * (Elf_Internal_Rela
**) relocs_return
= NULL
;
14735 * num_relocs_return
= 0;
14738 if (filedata
->file_header
.e_type
!= ET_REL
)
14739 /* No relocs to apply. */
14742 /* Find the reloc section associated with the section. */
14743 for (relsec
= filedata
->section_headers
;
14744 relsec
< filedata
->section_headers
+ filedata
->file_header
.e_shnum
;
14748 unsigned long num_relocs
;
14749 Elf_Internal_Rela
* relocs
;
14750 Elf_Internal_Rela
* rp
;
14751 Elf_Internal_Shdr
* symsec
;
14752 Elf_Internal_Sym
* symtab
;
14753 unsigned long num_syms
;
14754 Elf_Internal_Sym
* sym
;
14756 if ((relsec
->sh_type
!= SHT_RELA
&& relsec
->sh_type
!= SHT_REL
)
14757 || relsec
->sh_info
>= filedata
->file_header
.e_shnum
14758 || filedata
->section_headers
+ relsec
->sh_info
!= section
14759 || relsec
->sh_size
== 0
14760 || relsec
->sh_link
>= filedata
->file_header
.e_shnum
)
14763 symsec
= filedata
->section_headers
+ relsec
->sh_link
;
14764 if (symsec
->sh_type
!= SHT_SYMTAB
14765 && symsec
->sh_type
!= SHT_DYNSYM
)
14768 is_rela
= relsec
->sh_type
== SHT_RELA
;
14772 if (!slurp_rela_relocs (filedata
, relsec
->sh_offset
,
14773 relsec
->sh_size
, & relocs
, & num_relocs
))
14778 if (!slurp_rel_relocs (filedata
, relsec
->sh_offset
,
14779 relsec
->sh_size
, & relocs
, & num_relocs
))
14783 /* SH uses RELA but uses in place value instead of the addend field. */
14784 if (filedata
->file_header
.e_machine
== EM_SH
)
14787 symtab
= get_elf_symbols (filedata
, symsec
, & num_syms
);
14789 for (rp
= relocs
; rp
< relocs
+ num_relocs
; ++rp
)
14792 unsigned int reloc_type
;
14793 unsigned int reloc_size
;
14794 bool reloc_inplace
= false;
14795 bool reloc_subtract
= false;
14796 unsigned char *rloc
;
14797 unsigned long sym_index
;
14799 reloc_type
= get_reloc_type (filedata
, rp
->r_info
);
14801 if (target_specific_reloc_handling (filedata
, rp
, start
, end
, symtab
, num_syms
))
14803 else if (is_none_reloc (filedata
, reloc_type
))
14805 else if (is_32bit_abs_reloc (filedata
, reloc_type
)
14806 || is_32bit_pcrel_reloc (filedata
, reloc_type
))
14808 else if (is_64bit_abs_reloc (filedata
, reloc_type
)
14809 || is_64bit_pcrel_reloc (filedata
, reloc_type
))
14811 else if (is_24bit_abs_reloc (filedata
, reloc_type
))
14813 else if (is_16bit_abs_reloc (filedata
, reloc_type
))
14815 else if (is_8bit_abs_reloc (filedata
, reloc_type
)
14816 || is_6bit_abs_reloc (filedata
, reloc_type
))
14818 else if ((reloc_subtract
= is_32bit_inplace_sub_reloc (filedata
,
14820 || is_32bit_inplace_add_reloc (filedata
, reloc_type
))
14823 reloc_inplace
= true;
14825 else if ((reloc_subtract
= is_64bit_inplace_sub_reloc (filedata
,
14827 || is_64bit_inplace_add_reloc (filedata
, reloc_type
))
14830 reloc_inplace
= true;
14832 else if ((reloc_subtract
= is_16bit_inplace_sub_reloc (filedata
,
14834 || is_16bit_inplace_add_reloc (filedata
, reloc_type
))
14837 reloc_inplace
= true;
14839 else if ((reloc_subtract
= is_8bit_inplace_sub_reloc (filedata
,
14841 || is_8bit_inplace_add_reloc (filedata
, reloc_type
))
14844 reloc_inplace
= true;
14846 else if ((reloc_subtract
= is_6bit_inplace_sub_reloc (filedata
,
14850 reloc_inplace
= true;
14854 static unsigned int prev_reloc
= 0;
14856 if (reloc_type
!= prev_reloc
)
14857 warn (_("unable to apply unsupported reloc type %d to section %s\n"),
14858 reloc_type
, printable_section_name (filedata
, section
));
14859 prev_reloc
= reloc_type
;
14863 rloc
= start
+ rp
->r_offset
;
14864 if (!IN_RANGE (start
, end
, rloc
, reloc_size
))
14866 warn (_("skipping invalid relocation offset 0x%lx in section %s\n"),
14867 (unsigned long) rp
->r_offset
,
14868 printable_section_name (filedata
, section
));
14872 sym_index
= (unsigned long) get_reloc_symindex (rp
->r_info
);
14873 if (sym_index
>= num_syms
)
14875 warn (_("skipping invalid relocation symbol index 0x%lx in section %s\n"),
14876 sym_index
, printable_section_name (filedata
, section
));
14879 sym
= symtab
+ sym_index
;
14881 /* If the reloc has a symbol associated with it,
14882 make sure that it is of an appropriate type.
14884 Relocations against symbols without type can happen.
14885 Gcc -feliminate-dwarf2-dups may generate symbols
14886 without type for debug info.
14888 Icc generates relocations against function symbols
14889 instead of local labels.
14891 Relocations against object symbols can happen, eg when
14892 referencing a global array. For an example of this see
14893 the _clz.o binary in libgcc.a. */
14895 && ELF_ST_TYPE (sym
->st_info
) != STT_COMMON
14896 && ELF_ST_TYPE (sym
->st_info
) > STT_SECTION
)
14898 warn (_("skipping unexpected symbol type %s in section %s relocation %ld\n"),
14899 get_symbol_type (filedata
, ELF_ST_TYPE (sym
->st_info
)),
14900 printable_section_name (filedata
, relsec
),
14901 (long int)(rp
- relocs
));
14907 addend
+= rp
->r_addend
;
14908 /* R_XTENSA_32, R_PJ_DATA_DIR32 and R_D30V_32_NORMAL are
14909 partial_inplace. */
14911 || (filedata
->file_header
.e_machine
== EM_XTENSA
14912 && reloc_type
== 1)
14913 || ((filedata
->file_header
.e_machine
== EM_PJ
14914 || filedata
->file_header
.e_machine
== EM_PJ_OLD
)
14915 && reloc_type
== 1)
14916 || ((filedata
->file_header
.e_machine
== EM_D30V
14917 || filedata
->file_header
.e_machine
== EM_CYGNUS_D30V
)
14918 && reloc_type
== 12)
14921 if (is_6bit_inplace_sub_reloc (filedata
, reloc_type
))
14922 addend
+= byte_get (rloc
, reloc_size
) & 0x3f;
14924 addend
+= byte_get (rloc
, reloc_size
);
14927 if (is_32bit_pcrel_reloc (filedata
, reloc_type
)
14928 || is_64bit_pcrel_reloc (filedata
, reloc_type
))
14930 /* On HPPA, all pc-relative relocations are biased by 8. */
14931 if (filedata
->file_header
.e_machine
== EM_PARISC
)
14933 byte_put (rloc
, (addend
+ sym
->st_value
) - rp
->r_offset
,
14936 else if (is_6bit_abs_reloc (filedata
, reloc_type
)
14937 || is_6bit_inplace_sub_reloc (filedata
, reloc_type
))
14939 if (reloc_subtract
)
14940 addend
-= sym
->st_value
;
14942 addend
+= sym
->st_value
;
14943 addend
= (addend
& 0x3f) | (byte_get (rloc
, reloc_size
) & 0xc0);
14944 byte_put (rloc
, addend
, reloc_size
);
14946 else if (reloc_subtract
)
14947 byte_put (rloc
, addend
- sym
->st_value
, reloc_size
);
14949 byte_put (rloc
, addend
+ sym
->st_value
, reloc_size
);
14953 /* Let the target specific reloc processing code know that
14954 we have finished with these relocs. */
14955 target_specific_reloc_handling (filedata
, NULL
, NULL
, NULL
, NULL
, 0);
14959 * (Elf_Internal_Rela
**) relocs_return
= relocs
;
14960 * num_relocs_return
= num_relocs
;
14971 #ifdef SUPPORT_DISASSEMBLY
14973 disassemble_section (Elf_Internal_Shdr
* section
, Filedata
* filedata
)
14975 printf (_("\nAssembly dump of section %s\n"), printable_section_name (filedata
, section
));
14977 /* FIXME: XXX -- to be done --- XXX */
14983 /* Reads in the contents of SECTION from FILE, returning a pointer
14984 to a malloc'ed buffer or NULL if something went wrong. */
14987 get_section_contents (Elf_Internal_Shdr
* section
, Filedata
* filedata
)
14989 bfd_size_type num_bytes
= section
->sh_size
;
14991 if (num_bytes
== 0 || section
->sh_type
== SHT_NOBITS
)
14993 printf (_("Section '%s' has no data to dump.\n"),
14994 printable_section_name (filedata
, section
));
14998 return (char *) get_data (NULL
, filedata
, section
->sh_offset
, 1, num_bytes
,
14999 _("section contents"));
15002 /* Uncompresses a section that was compressed using zlib, in place. */
15005 uncompress_section_contents (unsigned char ** buffer
,
15006 dwarf_size_type uncompressed_size
,
15007 dwarf_size_type
* size
)
15009 dwarf_size_type compressed_size
= *size
;
15010 unsigned char * compressed_buffer
= *buffer
;
15011 unsigned char * uncompressed_buffer
;
15015 /* It is possible the section consists of several compressed
15016 buffers concatenated together, so we uncompress in a loop. */
15017 /* PR 18313: The state field in the z_stream structure is supposed
15018 to be invisible to the user (ie us), but some compilers will
15019 still complain about it being used without initialisation. So
15020 we first zero the entire z_stream structure and then set the fields
15022 memset (& strm
, 0, sizeof strm
);
15023 strm
.avail_in
= compressed_size
;
15024 strm
.next_in
= (Bytef
*) compressed_buffer
;
15025 strm
.avail_out
= uncompressed_size
;
15026 uncompressed_buffer
= (unsigned char *) xmalloc (uncompressed_size
);
15028 rc
= inflateInit (& strm
);
15029 while (strm
.avail_in
> 0)
15033 strm
.next_out
= ((Bytef
*) uncompressed_buffer
15034 + (uncompressed_size
- strm
.avail_out
));
15035 rc
= inflate (&strm
, Z_FINISH
);
15036 if (rc
!= Z_STREAM_END
)
15038 rc
= inflateReset (& strm
);
15040 if (inflateEnd (& strm
) != Z_OK
15042 || strm
.avail_out
!= 0)
15045 *buffer
= uncompressed_buffer
;
15046 *size
= uncompressed_size
;
15050 free (uncompressed_buffer
);
15051 /* Indicate decompression failure. */
15057 dump_section_as_strings (Elf_Internal_Shdr
* section
, Filedata
* filedata
)
15059 Elf_Internal_Shdr
*relsec
;
15060 bfd_size_type num_bytes
;
15061 unsigned char *data
;
15062 unsigned char *end
;
15063 unsigned char *real_start
;
15064 unsigned char *start
;
15065 bool some_strings_shown
;
15067 real_start
= start
= (unsigned char *) get_section_contents (section
, filedata
);
15069 /* PR 21820: Do not fail if the section was empty. */
15070 return section
->sh_size
== 0 || section
->sh_type
== SHT_NOBITS
;
15072 num_bytes
= section
->sh_size
;
15074 if (filedata
->is_separate
)
15075 printf (_("\nString dump of section '%s' in linked file %s:\n"),
15076 printable_section_name (filedata
, section
),
15077 filedata
->file_name
);
15079 printf (_("\nString dump of section '%s':\n"),
15080 printable_section_name (filedata
, section
));
15082 if (decompress_dumps
)
15084 dwarf_size_type new_size
= num_bytes
;
15085 dwarf_size_type uncompressed_size
= 0;
15087 if ((section
->sh_flags
& SHF_COMPRESSED
) != 0)
15089 Elf_Internal_Chdr chdr
;
15090 unsigned int compression_header_size
15091 = get_compression_header (& chdr
, (unsigned char *) start
,
15093 if (compression_header_size
== 0)
15094 /* An error message will have already been generated
15095 by get_compression_header. */
15098 if (chdr
.ch_type
!= ELFCOMPRESS_ZLIB
)
15100 warn (_("section '%s' has unsupported compress type: %d\n"),
15101 printable_section_name (filedata
, section
), chdr
.ch_type
);
15104 uncompressed_size
= chdr
.ch_size
;
15105 start
+= compression_header_size
;
15106 new_size
-= compression_header_size
;
15108 else if (new_size
> 12 && streq ((char *) start
, "ZLIB"))
15110 /* Read the zlib header. In this case, it should be "ZLIB"
15111 followed by the uncompressed section size, 8 bytes in
15112 big-endian order. */
15113 uncompressed_size
= start
[4]; uncompressed_size
<<= 8;
15114 uncompressed_size
+= start
[5]; uncompressed_size
<<= 8;
15115 uncompressed_size
+= start
[6]; uncompressed_size
<<= 8;
15116 uncompressed_size
+= start
[7]; uncompressed_size
<<= 8;
15117 uncompressed_size
+= start
[8]; uncompressed_size
<<= 8;
15118 uncompressed_size
+= start
[9]; uncompressed_size
<<= 8;
15119 uncompressed_size
+= start
[10]; uncompressed_size
<<= 8;
15120 uncompressed_size
+= start
[11];
15125 if (uncompressed_size
)
15127 if (uncompress_section_contents (& start
,
15128 uncompressed_size
, & new_size
))
15129 num_bytes
= new_size
;
15132 error (_("Unable to decompress section %s\n"),
15133 printable_section_name (filedata
, section
));
15138 start
= real_start
;
15141 /* If the section being dumped has relocations against it the user might
15142 be expecting these relocations to have been applied. Check for this
15143 case and issue a warning message in order to avoid confusion.
15144 FIXME: Maybe we ought to have an option that dumps a section with
15145 relocs applied ? */
15146 for (relsec
= filedata
->section_headers
;
15147 relsec
< filedata
->section_headers
+ filedata
->file_header
.e_shnum
;
15150 if ((relsec
->sh_type
!= SHT_RELA
&& relsec
->sh_type
!= SHT_REL
)
15151 || relsec
->sh_info
>= filedata
->file_header
.e_shnum
15152 || filedata
->section_headers
+ relsec
->sh_info
!= section
15153 || relsec
->sh_size
== 0
15154 || relsec
->sh_link
>= filedata
->file_header
.e_shnum
)
15157 printf (_(" Note: This section has relocations against it, but these have NOT been applied to this dump.\n"));
15162 end
= start
+ num_bytes
;
15163 some_strings_shown
= false;
15165 #ifdef HAVE_MBSTATE_T
15167 /* Initialise the multibyte conversion state. */
15168 memset (& state
, 0, sizeof (state
));
15171 bool continuing
= false;
15175 while (!ISPRINT (* data
))
15176 if (++ data
>= end
)
15181 size_t maxlen
= end
- data
;
15186 continuing
= false;
15190 printf (" [%6lx] ", (unsigned long) (data
- start
));
15204 /* PR 25543: Treat new-lines as string-ending characters. */
15213 /* Do not print control characters directly as they can affect terminal
15214 settings. Such characters usually appear in the names generated
15215 by the assembler for local labels. */
15218 printf ("^%c", c
+ 0x40);
15220 else if (ISPRINT (c
))
15227 #ifdef HAVE_MBSTATE_T
15230 /* Let printf do the hard work of displaying multibyte characters. */
15231 printf ("%.1s", data
- 1);
15232 #ifdef HAVE_MBSTATE_T
15233 /* Try to find out how many bytes made up the character that was
15234 just printed. Advance the symbol pointer past the bytes that
15236 n
= mbrtowc (& w
, (char *)(data
- 1), MB_CUR_MAX
, & state
);
15240 if (n
!= (size_t) -1 && n
!= (size_t) -2 && n
> 0)
15250 printf (_("<corrupt>\n"));
15253 some_strings_shown
= true;
15257 if (! some_strings_shown
)
15258 printf (_(" No strings found in this section."));
15271 dump_section_as_bytes (Elf_Internal_Shdr
*section
,
15272 Filedata
*filedata
,
15275 Elf_Internal_Shdr
* relsec
;
15276 bfd_size_type bytes
;
15277 bfd_size_type section_size
;
15279 unsigned char * data
;
15280 unsigned char * real_start
;
15281 unsigned char * start
;
15283 real_start
= start
= (unsigned char *) get_section_contents (section
, filedata
);
15285 /* PR 21820: Do not fail if the section was empty. */
15286 return section
->sh_size
== 0 || section
->sh_type
== SHT_NOBITS
;
15288 section_size
= section
->sh_size
;
15290 if (filedata
->is_separate
)
15291 printf (_("\nHex dump of section '%s' in linked file %s:\n"),
15292 printable_section_name (filedata
, section
),
15293 filedata
->file_name
);
15295 printf (_("\nHex dump of section '%s':\n"),
15296 printable_section_name (filedata
, section
));
15298 if (decompress_dumps
)
15300 dwarf_size_type new_size
= section_size
;
15301 dwarf_size_type uncompressed_size
= 0;
15303 if ((section
->sh_flags
& SHF_COMPRESSED
) != 0)
15305 Elf_Internal_Chdr chdr
;
15306 unsigned int compression_header_size
15307 = get_compression_header (& chdr
, start
, section_size
);
15309 if (compression_header_size
== 0)
15310 /* An error message will have already been generated
15311 by get_compression_header. */
15314 if (chdr
.ch_type
!= ELFCOMPRESS_ZLIB
)
15316 warn (_("section '%s' has unsupported compress type: %d\n"),
15317 printable_section_name (filedata
, section
), chdr
.ch_type
);
15320 uncompressed_size
= chdr
.ch_size
;
15321 start
+= compression_header_size
;
15322 new_size
-= compression_header_size
;
15324 else if (new_size
> 12 && streq ((char *) start
, "ZLIB"))
15326 /* Read the zlib header. In this case, it should be "ZLIB"
15327 followed by the uncompressed section size, 8 bytes in
15328 big-endian order. */
15329 uncompressed_size
= start
[4]; uncompressed_size
<<= 8;
15330 uncompressed_size
+= start
[5]; uncompressed_size
<<= 8;
15331 uncompressed_size
+= start
[6]; uncompressed_size
<<= 8;
15332 uncompressed_size
+= start
[7]; uncompressed_size
<<= 8;
15333 uncompressed_size
+= start
[8]; uncompressed_size
<<= 8;
15334 uncompressed_size
+= start
[9]; uncompressed_size
<<= 8;
15335 uncompressed_size
+= start
[10]; uncompressed_size
<<= 8;
15336 uncompressed_size
+= start
[11];
15341 if (uncompressed_size
)
15343 if (uncompress_section_contents (& start
, uncompressed_size
,
15346 section_size
= new_size
;
15350 error (_("Unable to decompress section %s\n"),
15351 printable_section_name (filedata
, section
));
15352 /* FIXME: Print the section anyway ? */
15357 start
= real_start
;
15362 if (! apply_relocations (filedata
, section
, start
, section_size
, NULL
, NULL
))
15367 /* If the section being dumped has relocations against it the user might
15368 be expecting these relocations to have been applied. Check for this
15369 case and issue a warning message in order to avoid confusion.
15370 FIXME: Maybe we ought to have an option that dumps a section with
15371 relocs applied ? */
15372 for (relsec
= filedata
->section_headers
;
15373 relsec
< filedata
->section_headers
+ filedata
->file_header
.e_shnum
;
15376 if ((relsec
->sh_type
!= SHT_RELA
&& relsec
->sh_type
!= SHT_REL
)
15377 || relsec
->sh_info
>= filedata
->file_header
.e_shnum
15378 || filedata
->section_headers
+ relsec
->sh_info
!= section
15379 || relsec
->sh_size
== 0
15380 || relsec
->sh_link
>= filedata
->file_header
.e_shnum
)
15383 printf (_(" NOTE: This section has relocations against it, but these have NOT been applied to this dump.\n"));
15388 addr
= section
->sh_addr
;
15389 bytes
= section_size
;
15398 lbytes
= (bytes
> 16 ? 16 : bytes
);
15400 printf (" 0x%8.8lx ", (unsigned long) addr
);
15402 for (j
= 0; j
< 16; j
++)
15405 printf ("%2.2x", data
[j
]);
15413 for (j
= 0; j
< lbytes
; j
++)
15416 if (k
>= ' ' && k
< 0x7f)
15439 #ifdef ENABLE_LIBCTF
15440 static ctf_sect_t
*
15441 shdr_to_ctf_sect (ctf_sect_t
*buf
, Elf_Internal_Shdr
*shdr
, Filedata
*filedata
)
15443 buf
->cts_name
= section_name_print (filedata
, shdr
);
15444 buf
->cts_size
= shdr
->sh_size
;
15445 buf
->cts_entsize
= shdr
->sh_entsize
;
15450 /* Formatting callback function passed to ctf_dump. Returns either the pointer
15451 it is passed, or a pointer to newly-allocated storage, in which case
15452 dump_ctf() will free it when it no longer needs it. */
15455 dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED
,
15456 char *s
, void *arg
)
15458 const char *blanks
= arg
;
15461 if (asprintf (&new_s
, "%s%s", blanks
, s
) < 0)
15466 /* Dump CTF errors/warnings. */
15468 dump_ctf_errs (ctf_dict_t
*fp
)
15470 ctf_next_t
*it
= NULL
;
15475 /* Dump accumulated errors and warnings. */
15476 while ((errtext
= ctf_errwarning_next (fp
, &it
, &is_warning
, &err
)) != NULL
)
15478 error (_("%s: %s"), is_warning
? _("warning"): _("error"),
15482 if (err
!= ECTF_NEXT_END
)
15483 error (_("CTF error: cannot get CTF errors: `%s'"), ctf_errmsg (err
));
15486 /* Dump one CTF archive member. */
15489 dump_ctf_archive_member (ctf_dict_t
*ctf
, const char *name
, ctf_dict_t
*parent
,
15492 const char *things
[] = {"Header", "Labels", "Data objects",
15493 "Function objects", "Variables", "Types", "Strings",
15495 const char **thing
;
15498 /* Don't print out the name of the default-named archive member if it appears
15499 first in the list. The name .ctf appears everywhere, even for things that
15500 aren't really archives, so printing it out is liable to be confusing; also,
15501 the common case by far is for only one archive member to exist, and hiding
15502 it in that case seems worthwhile. */
15504 if (strcmp (name
, ".ctf") != 0 || member
!= 0)
15505 printf (_("\nCTF archive member: %s:\n"), name
);
15507 if (ctf_parent_name (ctf
) != NULL
)
15508 ctf_import (ctf
, parent
);
15510 for (i
= 0, thing
= things
; *thing
[0]; thing
++, i
++)
15512 ctf_dump_state_t
*s
= NULL
;
15515 printf ("\n %s:\n", *thing
);
15516 while ((item
= ctf_dump (ctf
, &s
, i
, dump_ctf_indent_lines
,
15517 (void *) " ")) != NULL
)
15519 printf ("%s\n", item
);
15523 if (ctf_errno (ctf
))
15525 error (_("Iteration failed: %s, %s\n"), *thing
,
15526 ctf_errmsg (ctf_errno (ctf
)));
15531 dump_ctf_errs (ctf
);
15535 dump_section_as_ctf (Elf_Internal_Shdr
* section
, Filedata
* filedata
)
15537 Elf_Internal_Shdr
* symtab_sec
= NULL
;
15538 Elf_Internal_Shdr
* strtab_sec
= NULL
;
15539 void * data
= NULL
;
15540 void * symdata
= NULL
;
15541 void * strdata
= NULL
;
15542 ctf_sect_t ctfsect
, symsect
, strsect
;
15543 ctf_sect_t
* symsectp
= NULL
;
15544 ctf_sect_t
* strsectp
= NULL
;
15545 ctf_archive_t
* ctfa
= NULL
;
15546 ctf_dict_t
* parent
= NULL
;
15549 ctf_next_t
*i
= NULL
;
15555 shdr_to_ctf_sect (&ctfsect
, section
, filedata
);
15556 data
= get_section_contents (section
, filedata
);
15557 ctfsect
.cts_data
= data
;
15559 if (!dump_ctf_symtab_name
)
15560 dump_ctf_symtab_name
= strdup (".dynsym");
15562 if (!dump_ctf_strtab_name
)
15563 dump_ctf_strtab_name
= strdup (".dynstr");
15565 if (dump_ctf_symtab_name
&& dump_ctf_symtab_name
[0] != 0)
15567 if ((symtab_sec
= find_section (filedata
, dump_ctf_symtab_name
)) == NULL
)
15569 error (_("No symbol section named %s\n"), dump_ctf_symtab_name
);
15572 if ((symdata
= (void *) get_data (NULL
, filedata
,
15573 symtab_sec
->sh_offset
, 1,
15574 symtab_sec
->sh_size
,
15575 _("symbols"))) == NULL
)
15577 symsectp
= shdr_to_ctf_sect (&symsect
, symtab_sec
, filedata
);
15578 symsect
.cts_data
= symdata
;
15581 if (dump_ctf_strtab_name
&& dump_ctf_strtab_name
[0] != 0)
15583 if ((strtab_sec
= find_section (filedata
, dump_ctf_strtab_name
)) == NULL
)
15585 error (_("No string table section named %s\n"),
15586 dump_ctf_strtab_name
);
15589 if ((strdata
= (void *) get_data (NULL
, filedata
,
15590 strtab_sec
->sh_offset
, 1,
15591 strtab_sec
->sh_size
,
15592 _("strings"))) == NULL
)
15594 strsectp
= shdr_to_ctf_sect (&strsect
, strtab_sec
, filedata
);
15595 strsect
.cts_data
= strdata
;
15598 /* Load the CTF file and dump it. It may be a raw CTF section, or an archive:
15599 libctf papers over the difference, so we can pretend it is always an
15602 if ((ctfa
= ctf_arc_bufopen (&ctfsect
, symsectp
, strsectp
, &err
)) == NULL
)
15604 dump_ctf_errs (NULL
);
15605 error (_("CTF open failure: %s\n"), ctf_errmsg (err
));
15609 ctf_arc_symsect_endianness (ctfa
, filedata
->file_header
.e_ident
[EI_DATA
]
15612 /* Preload the parent dict, since it will need to be imported into every
15614 if ((parent
= ctf_dict_open (ctfa
, dump_ctf_parent_name
, &err
)) == NULL
)
15616 dump_ctf_errs (NULL
);
15617 error (_("CTF open failure: %s\n"), ctf_errmsg (err
));
15623 if (filedata
->is_separate
)
15624 printf (_("\nDump of CTF section '%s' in linked file %s:\n"),
15625 printable_section_name (filedata
, section
),
15626 filedata
->file_name
);
15628 printf (_("\nDump of CTF section '%s':\n"),
15629 printable_section_name (filedata
, section
));
15631 while ((fp
= ctf_archive_next (ctfa
, &i
, &name
, 0, &err
)) != NULL
)
15632 dump_ctf_archive_member (fp
, name
, parent
, member
++);
15633 if (err
!= ECTF_NEXT_END
)
15635 dump_ctf_errs (NULL
);
15636 error (_("CTF member open failure: %s\n"), ctf_errmsg (err
));
15641 ctf_dict_close (parent
);
15651 load_specific_debug_section (enum dwarf_section_display_enum debug
,
15652 const Elf_Internal_Shdr
* sec
,
15655 struct dwarf_section
* section
= &debug_displays
[debug
].section
;
15657 Filedata
* filedata
= (Filedata
*) data
;
15659 if (section
->start
!= NULL
)
15661 /* If it is already loaded, do nothing. */
15662 if (streq (section
->filename
, filedata
->file_name
))
15664 free (section
->start
);
15667 snprintf (buf
, sizeof (buf
), _("%s section data"), section
->name
);
15668 section
->address
= sec
->sh_addr
;
15669 section
->filename
= filedata
->file_name
;
15670 section
->start
= (unsigned char *) get_data (NULL
, filedata
,
15672 sec
->sh_size
, buf
);
15673 if (section
->start
== NULL
)
15677 unsigned char *start
= section
->start
;
15678 dwarf_size_type size
= sec
->sh_size
;
15679 dwarf_size_type uncompressed_size
= 0;
15681 if ((sec
->sh_flags
& SHF_COMPRESSED
) != 0)
15683 Elf_Internal_Chdr chdr
;
15684 unsigned int compression_header_size
;
15686 if (size
< (is_32bit_elf
15687 ? sizeof (Elf32_External_Chdr
)
15688 : sizeof (Elf64_External_Chdr
)))
15690 warn (_("compressed section %s is too small to contain a compression header\n"),
15695 compression_header_size
= get_compression_header (&chdr
, start
, size
);
15696 if (compression_header_size
== 0)
15697 /* An error message will have already been generated
15698 by get_compression_header. */
15701 if (chdr
.ch_type
!= ELFCOMPRESS_ZLIB
)
15703 warn (_("section '%s' has unsupported compress type: %d\n"),
15704 section
->name
, chdr
.ch_type
);
15707 uncompressed_size
= chdr
.ch_size
;
15708 start
+= compression_header_size
;
15709 size
-= compression_header_size
;
15711 else if (size
> 12 && streq ((char *) start
, "ZLIB"))
15713 /* Read the zlib header. In this case, it should be "ZLIB"
15714 followed by the uncompressed section size, 8 bytes in
15715 big-endian order. */
15716 uncompressed_size
= start
[4]; uncompressed_size
<<= 8;
15717 uncompressed_size
+= start
[5]; uncompressed_size
<<= 8;
15718 uncompressed_size
+= start
[6]; uncompressed_size
<<= 8;
15719 uncompressed_size
+= start
[7]; uncompressed_size
<<= 8;
15720 uncompressed_size
+= start
[8]; uncompressed_size
<<= 8;
15721 uncompressed_size
+= start
[9]; uncompressed_size
<<= 8;
15722 uncompressed_size
+= start
[10]; uncompressed_size
<<= 8;
15723 uncompressed_size
+= start
[11];
15728 if (uncompressed_size
)
15730 if (uncompress_section_contents (&start
, uncompressed_size
,
15733 /* Free the compressed buffer, update the section buffer
15734 and the section size if uncompress is successful. */
15735 free (section
->start
);
15736 section
->start
= start
;
15740 error (_("Unable to decompress section %s\n"),
15741 printable_section_name (filedata
, sec
));
15746 section
->size
= size
;
15749 if (section
->start
== NULL
)
15752 if (debug_displays
[debug
].relocate
)
15754 if (! apply_relocations (filedata
, sec
, section
->start
, section
->size
,
15755 & section
->reloc_info
, & section
->num_relocs
))
15760 section
->reloc_info
= NULL
;
15761 section
->num_relocs
= 0;
15767 #if HAVE_LIBDEBUGINFOD
15768 /* Return a hex string representation of the build-id. */
15770 get_build_id (void * data
)
15772 Filedata
* filedata
= (Filedata
*) data
;
15773 Elf_Internal_Shdr
* shdr
;
15776 /* Iterate through notes to find note.gnu.build-id.
15777 FIXME: Only the first note in any note section is examined. */
15778 for (i
= 0, shdr
= filedata
->section_headers
;
15779 i
< filedata
->file_header
.e_shnum
&& shdr
!= NULL
;
15782 if (shdr
->sh_type
!= SHT_NOTE
)
15787 size_t data_remaining
;
15789 Elf_External_Note
* enote
;
15790 Elf_Internal_Note inote
;
15792 bfd_vma offset
= shdr
->sh_offset
;
15793 bfd_vma align
= shdr
->sh_addralign
;
15794 bfd_vma length
= shdr
->sh_size
;
15796 enote
= (Elf_External_Note
*) get_section_contents (shdr
, filedata
);
15802 else if (align
!= 4 && align
!= 8)
15808 end
= (char *) enote
+ length
;
15809 data_remaining
= end
- (char *) enote
;
15811 if (!is_ia64_vms (filedata
))
15813 min_notesz
= offsetof (Elf_External_Note
, name
);
15814 if (data_remaining
< min_notesz
)
15817 malformed note encountered in section %s whilst scanning for build-id note\n"),
15818 printable_section_name (filedata
, shdr
));
15822 data_remaining
-= min_notesz
;
15824 inote
.type
= BYTE_GET (enote
->type
);
15825 inote
.namesz
= BYTE_GET (enote
->namesz
);
15826 inote
.namedata
= enote
->name
;
15827 inote
.descsz
= BYTE_GET (enote
->descsz
);
15828 inote
.descdata
= ((char *) enote
15829 + ELF_NOTE_DESC_OFFSET (inote
.namesz
, align
));
15830 inote
.descpos
= offset
+ (inote
.descdata
- (char *) enote
);
15831 next
= ((char *) enote
15832 + ELF_NOTE_NEXT_OFFSET (inote
.namesz
, inote
.descsz
, align
));
15836 Elf64_External_VMS_Note
*vms_enote
;
15838 /* PR binutils/15191
15839 Make sure that there is enough data to read. */
15840 min_notesz
= offsetof (Elf64_External_VMS_Note
, name
);
15841 if (data_remaining
< min_notesz
)
15844 malformed note encountered in section %s whilst scanning for build-id note\n"),
15845 printable_section_name (filedata
, shdr
));
15849 data_remaining
-= min_notesz
;
15851 vms_enote
= (Elf64_External_VMS_Note
*) enote
;
15852 inote
.type
= BYTE_GET (vms_enote
->type
);
15853 inote
.namesz
= BYTE_GET (vms_enote
->namesz
);
15854 inote
.namedata
= vms_enote
->name
;
15855 inote
.descsz
= BYTE_GET (vms_enote
->descsz
);
15856 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 3);
15857 inote
.descpos
= offset
+ (inote
.descdata
- (char *) enote
);
15858 next
= inote
.descdata
+ align_power (inote
.descsz
, 3);
15861 /* Skip malformed notes. */
15862 if ((size_t) (inote
.descdata
- inote
.namedata
) < inote
.namesz
15863 || (size_t) (inote
.descdata
- inote
.namedata
) > data_remaining
15864 || (size_t) (next
- inote
.descdata
) < inote
.descsz
15865 || ((size_t) (next
- inote
.descdata
)
15866 > data_remaining
- (size_t) (inote
.descdata
- inote
.namedata
)))
15869 malformed note encountered in section %s whilst scanning for build-id note\n"),
15870 printable_section_name (filedata
, shdr
));
15875 /* Check if this is the build-id note. If so then convert the build-id
15876 bytes to a hex string. */
15877 if (inote
.namesz
> 0
15878 && startswith (inote
.namedata
, "GNU")
15879 && inote
.type
== NT_GNU_BUILD_ID
)
15884 build_id
= malloc (inote
.descsz
* 2 + 1);
15885 if (build_id
== NULL
)
15891 for (j
= 0; j
< inote
.descsz
; ++j
)
15892 sprintf (build_id
+ (j
* 2), "%02x", inote
.descdata
[j
] & 0xff);
15893 build_id
[inote
.descsz
* 2] = '\0';
15896 return (unsigned char *) build_id
;
15903 #endif /* HAVE_LIBDEBUGINFOD */
15905 /* If this is not NULL, load_debug_section will only look for sections
15906 within the list of sections given here. */
15907 static unsigned int * section_subset
= NULL
;
15910 load_debug_section (enum dwarf_section_display_enum debug
, void * data
)
15912 struct dwarf_section
* section
= &debug_displays
[debug
].section
;
15913 Elf_Internal_Shdr
* sec
;
15914 Filedata
* filedata
= (Filedata
*) data
;
15916 /* Without section headers we cannot find any sections. */
15917 if (filedata
->section_headers
== NULL
)
15920 if (filedata
->string_table
== NULL
15921 && filedata
->file_header
.e_shstrndx
!= SHN_UNDEF
15922 && filedata
->file_header
.e_shstrndx
< filedata
->file_header
.e_shnum
)
15924 Elf_Internal_Shdr
* strs
;
15926 /* Read in the string table, so that we have section names to scan. */
15927 strs
= filedata
->section_headers
+ filedata
->file_header
.e_shstrndx
;
15929 if (strs
!= NULL
&& strs
->sh_size
!= 0)
15931 filedata
->string_table
15932 = (char *) get_data (NULL
, filedata
, strs
->sh_offset
,
15933 1, strs
->sh_size
, _("string table"));
15935 filedata
->string_table_length
15936 = filedata
->string_table
!= NULL
? strs
->sh_size
: 0;
15940 /* Locate the debug section. */
15941 sec
= find_section_in_set (filedata
, section
->uncompressed_name
, section_subset
);
15943 section
->name
= section
->uncompressed_name
;
15946 sec
= find_section_in_set (filedata
, section
->compressed_name
, section_subset
);
15948 section
->name
= section
->compressed_name
;
15953 /* If we're loading from a subset of sections, and we've loaded
15954 a section matching this name before, it's likely that it's a
15956 if (section_subset
!= NULL
)
15957 free_debug_section (debug
);
15959 return load_specific_debug_section (debug
, sec
, data
);
15963 free_debug_section (enum dwarf_section_display_enum debug
)
15965 struct dwarf_section
* section
= &debug_displays
[debug
].section
;
15967 if (section
->start
== NULL
)
15970 free ((char *) section
->start
);
15971 section
->start
= NULL
;
15972 section
->address
= 0;
15975 free (section
->reloc_info
);
15976 section
->reloc_info
= NULL
;
15977 section
->num_relocs
= 0;
15981 display_debug_section (int shndx
, Elf_Internal_Shdr
* section
, Filedata
* filedata
)
15983 const char *name
= (section_name_valid (filedata
, section
)
15984 ? section_name (filedata
, section
) : "");
15985 const char *print_name
= printable_section_name (filedata
, section
);
15986 bfd_size_type length
;
15987 bool result
= true;
15990 length
= section
->sh_size
;
15993 printf (_("\nSection '%s' has no debugging data.\n"), print_name
);
15996 if (section
->sh_type
== SHT_NOBITS
)
15998 /* There is no point in dumping the contents of a debugging section
15999 which has the NOBITS type - the bits in the file will be random.
16000 This can happen when a file containing a .eh_frame section is
16001 stripped with the --only-keep-debug command line option. */
16002 printf (_("section '%s' has the NOBITS type - its contents are unreliable.\n"),
16007 if (startswith (name
, ".gnu.linkonce.wi."))
16008 name
= ".debug_info";
16010 /* See if we know how to display the contents of this section. */
16011 for (i
= 0; i
< max
; i
++)
16013 enum dwarf_section_display_enum id
= (enum dwarf_section_display_enum
) i
;
16014 struct dwarf_section_display
* display
= debug_displays
+ i
;
16015 struct dwarf_section
* sec
= & display
->section
;
16017 if (streq (sec
->uncompressed_name
, name
)
16018 || (id
== line
&& startswith (name
, ".debug_line."))
16019 || streq (sec
->compressed_name
, name
))
16021 bool secondary
= (section
!= find_section (filedata
, name
));
16024 free_debug_section (id
);
16026 if (i
== line
&& startswith (name
, ".debug_line."))
16028 else if (streq (sec
->uncompressed_name
, name
))
16029 sec
->name
= sec
->uncompressed_name
;
16031 sec
->name
= sec
->compressed_name
;
16033 if (load_specific_debug_section (id
, section
, filedata
))
16035 /* If this debug section is part of a CU/TU set in a .dwp file,
16036 restrict load_debug_section to the sections in that set. */
16037 section_subset
= find_cu_tu_set (filedata
, shndx
);
16039 result
&= display
->display (sec
, filedata
);
16041 section_subset
= NULL
;
16043 if (secondary
|| (id
!= info
&& id
!= abbrev
&& id
!= debug_addr
))
16044 free_debug_section (id
);
16052 printf (_("Unrecognized debug section: %s\n"), print_name
);
16059 /* Set DUMP_SECTS for all sections where dumps were requested
16060 based on section name. */
16063 initialise_dumps_byname (Filedata
* filedata
)
16065 struct dump_list_entry
* cur
;
16067 for (cur
= dump_sects_byname
; cur
; cur
= cur
->next
)
16072 for (i
= 0; i
< filedata
->file_header
.e_shnum
; i
++)
16073 if (section_name_valid (filedata
, filedata
->section_headers
+ i
)
16074 && streq (section_name (filedata
, filedata
->section_headers
+ i
),
16077 request_dump_bynumber (&filedata
->dump
, i
, cur
->type
);
16081 if (!any
&& !filedata
->is_separate
)
16082 warn (_("Section '%s' was not dumped because it does not exist\n"),
16088 process_section_contents (Filedata
* filedata
)
16090 Elf_Internal_Shdr
* section
;
16097 initialise_dumps_byname (filedata
);
16099 for (i
= 0, section
= filedata
->section_headers
;
16100 i
< filedata
->file_header
.e_shnum
&& i
< filedata
->dump
.num_dump_sects
;
16103 dump_type dump
= filedata
->dump
.dump_sects
[i
];
16105 if (filedata
->is_separate
&& ! process_links
)
16106 dump
&= DEBUG_DUMP
;
16108 #ifdef SUPPORT_DISASSEMBLY
16109 if (dump
& DISASS_DUMP
)
16111 if (! disassemble_section (section
, filedata
))
16115 if (dump
& HEX_DUMP
)
16117 if (! dump_section_as_bytes (section
, filedata
, false))
16121 if (dump
& RELOC_DUMP
)
16123 if (! dump_section_as_bytes (section
, filedata
, true))
16127 if (dump
& STRING_DUMP
)
16129 if (! dump_section_as_strings (section
, filedata
))
16133 if (dump
& DEBUG_DUMP
)
16135 if (! display_debug_section (i
, section
, filedata
))
16139 #ifdef ENABLE_LIBCTF
16140 if (dump
& CTF_DUMP
)
16142 if (! dump_section_as_ctf (section
, filedata
))
16148 if (! filedata
->is_separate
)
16150 /* Check to see if the user requested a
16151 dump of a section that does not exist. */
16152 for (; i
< filedata
->dump
.num_dump_sects
; i
++)
16153 if (filedata
->dump
.dump_sects
[i
])
16155 warn (_("Section %d was not dumped because it does not exist!\n"), i
);
16164 process_mips_fpe_exception (int mask
)
16170 if (mask
& OEX_FPU_INEX
)
16171 fputs ("INEX", stdout
), first
= false;
16172 if (mask
& OEX_FPU_UFLO
)
16173 printf ("%sUFLO", first
? "" : "|"), first
= false;
16174 if (mask
& OEX_FPU_OFLO
)
16175 printf ("%sOFLO", first
? "" : "|"), first
= false;
16176 if (mask
& OEX_FPU_DIV0
)
16177 printf ("%sDIV0", first
? "" : "|"), first
= false;
16178 if (mask
& OEX_FPU_INVAL
)
16179 printf ("%sINVAL", first
? "" : "|");
16182 fputs ("0", stdout
);
16185 /* Display's the value of TAG at location P. If TAG is
16186 greater than 0 it is assumed to be an unknown tag, and
16187 a message is printed to this effect. Otherwise it is
16188 assumed that a message has already been printed.
16190 If the bottom bit of TAG is set it assumed to have a
16191 string value, otherwise it is assumed to have an integer
16194 Returns an updated P pointing to the first unread byte
16195 beyond the end of TAG's value.
16197 Reads at or beyond END will not be made. */
16199 static unsigned char *
16200 display_tag_value (signed int tag
,
16202 const unsigned char * const end
)
16207 printf (" Tag_unknown_%d: ", tag
);
16211 warn (_("<corrupt tag>\n"));
16215 /* PR 17531 file: 027-19978-0.004. */
16216 size_t maxlen
= (end
- p
) - 1;
16221 print_symbol ((int) maxlen
, (const char *) p
);
16222 p
+= strnlen ((char *) p
, maxlen
) + 1;
16226 printf (_("<corrupt string tag>"));
16227 p
= (unsigned char *) end
;
16233 READ_ULEB (val
, p
, end
);
16234 printf ("%ld (0x%lx)\n", val
, val
);
16241 /* ARC ABI attributes section. */
16243 static unsigned char *
16244 display_arc_attribute (unsigned char * p
,
16245 const unsigned char * const end
)
16250 READ_ULEB (tag
, p
, end
);
16254 case Tag_ARC_PCS_config
:
16255 READ_ULEB (val
, p
, end
);
16256 printf (" Tag_ARC_PCS_config: ");
16260 printf (_("Absent/Non standard\n"));
16263 printf (_("Bare metal/mwdt\n"));
16266 printf (_("Bare metal/newlib\n"));
16269 printf (_("Linux/uclibc\n"));
16272 printf (_("Linux/glibc\n"));
16275 printf (_("Unknown\n"));
16280 case Tag_ARC_CPU_base
:
16281 READ_ULEB (val
, p
, end
);
16282 printf (" Tag_ARC_CPU_base: ");
16287 printf (_("Absent\n"));
16289 case TAG_CPU_ARC6xx
:
16290 printf ("ARC6xx\n");
16292 case TAG_CPU_ARC7xx
:
16293 printf ("ARC7xx\n");
16295 case TAG_CPU_ARCEM
:
16296 printf ("ARCEM\n");
16298 case TAG_CPU_ARCHS
:
16299 printf ("ARCHS\n");
16304 case Tag_ARC_CPU_variation
:
16305 READ_ULEB (val
, p
, end
);
16306 printf (" Tag_ARC_CPU_variation: ");
16310 if (val
> 0 && val
< 16)
16311 printf ("Core%d\n", val
);
16313 printf ("Unknown\n");
16317 printf (_("Absent\n"));
16322 case Tag_ARC_CPU_name
:
16323 printf (" Tag_ARC_CPU_name: ");
16324 p
= display_tag_value (-1, p
, end
);
16327 case Tag_ARC_ABI_rf16
:
16328 READ_ULEB (val
, p
, end
);
16329 printf (" Tag_ARC_ABI_rf16: %s\n", val
? _("yes") : _("no"));
16332 case Tag_ARC_ABI_osver
:
16333 READ_ULEB (val
, p
, end
);
16334 printf (" Tag_ARC_ABI_osver: v%d\n", val
);
16337 case Tag_ARC_ABI_pic
:
16338 case Tag_ARC_ABI_sda
:
16339 READ_ULEB (val
, p
, end
);
16340 printf (tag
== Tag_ARC_ABI_sda
? " Tag_ARC_ABI_sda: "
16341 : " Tag_ARC_ABI_pic: ");
16345 printf (_("Absent\n"));
16354 printf (_("Unknown\n"));
16359 case Tag_ARC_ABI_tls
:
16360 READ_ULEB (val
, p
, end
);
16361 printf (" Tag_ARC_ABI_tls: %s\n", val
? "r25": "none");
16364 case Tag_ARC_ABI_enumsize
:
16365 READ_ULEB (val
, p
, end
);
16366 printf (" Tag_ARC_ABI_enumsize: %s\n", val
? _("default") :
16370 case Tag_ARC_ABI_exceptions
:
16371 READ_ULEB (val
, p
, end
);
16372 printf (" Tag_ARC_ABI_exceptions: %s\n", val
? _("OPTFP")
16376 case Tag_ARC_ABI_double_size
:
16377 READ_ULEB (val
, p
, end
);
16378 printf (" Tag_ARC_ABI_double_size: %d\n", val
);
16381 case Tag_ARC_ISA_config
:
16382 printf (" Tag_ARC_ISA_config: ");
16383 p
= display_tag_value (-1, p
, end
);
16386 case Tag_ARC_ISA_apex
:
16387 printf (" Tag_ARC_ISA_apex: ");
16388 p
= display_tag_value (-1, p
, end
);
16391 case Tag_ARC_ISA_mpy_option
:
16392 READ_ULEB (val
, p
, end
);
16393 printf (" Tag_ARC_ISA_mpy_option: %d\n", val
);
16396 case Tag_ARC_ATR_version
:
16397 READ_ULEB (val
, p
, end
);
16398 printf (" Tag_ARC_ATR_version: %d\n", val
);
16402 return display_tag_value (tag
& 1, p
, end
);
16408 /* ARM EABI attributes section. */
16413 /* 0 = special, 1 = string, 2 = uleb123, > 0x80 == table lookup. */
16415 const char *const *table
;
16416 } arm_attr_public_tag
;
16418 static const char *const arm_attr_tag_CPU_arch
[] =
16419 {"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2",
16420 "v6K", "v7", "v6-M", "v6S-M", "v7E-M", "v8", "v8-R", "v8-M.baseline",
16421 "v8-M.mainline", "v8.1-A", "v8.2-A", "v8.3-A",
16422 "v8.1-M.mainline", "v9"};
16423 static const char *const arm_attr_tag_ARM_ISA_use
[] = {"No", "Yes"};
16424 static const char *const arm_attr_tag_THUMB_ISA_use
[] =
16425 {"No", "Thumb-1", "Thumb-2", "Yes"};
16426 static const char *const arm_attr_tag_FP_arch
[] =
16427 {"No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16", "VFPv4", "VFPv4-D16",
16428 "FP for ARMv8", "FPv5/FP-D16 for ARMv8"};
16429 static const char *const arm_attr_tag_WMMX_arch
[] = {"No", "WMMXv1", "WMMXv2"};
16430 static const char *const arm_attr_tag_Advanced_SIMD_arch
[] =
16431 {"No", "NEONv1", "NEONv1 with Fused-MAC", "NEON for ARMv8",
16432 "NEON for ARMv8.1"};
16433 static const char *const arm_attr_tag_PCS_config
[] =
16434 {"None", "Bare platform", "Linux application", "Linux DSO", "PalmOS 2004",
16435 "PalmOS (reserved)", "SymbianOS 2004", "SymbianOS (reserved)"};
16436 static const char *const arm_attr_tag_ABI_PCS_R9_use
[] =
16437 {"V6", "SB", "TLS", "Unused"};
16438 static const char *const arm_attr_tag_ABI_PCS_RW_data
[] =
16439 {"Absolute", "PC-relative", "SB-relative", "None"};
16440 static const char *const arm_attr_tag_ABI_PCS_RO_data
[] =
16441 {"Absolute", "PC-relative", "None"};
16442 static const char *const arm_attr_tag_ABI_PCS_GOT_use
[] =
16443 {"None", "direct", "GOT-indirect"};
16444 static const char *const arm_attr_tag_ABI_PCS_wchar_t
[] =
16445 {"None", "??? 1", "2", "??? 3", "4"};
16446 static const char *const arm_attr_tag_ABI_FP_rounding
[] = {"Unused", "Needed"};
16447 static const char *const arm_attr_tag_ABI_FP_denormal
[] =
16448 {"Unused", "Needed", "Sign only"};
16449 static const char *const arm_attr_tag_ABI_FP_exceptions
[] = {"Unused", "Needed"};
16450 static const char *const arm_attr_tag_ABI_FP_user_exceptions
[] = {"Unused", "Needed"};
16451 static const char *const arm_attr_tag_ABI_FP_number_model
[] =
16452 {"Unused", "Finite", "RTABI", "IEEE 754"};
16453 static const char *const arm_attr_tag_ABI_enum_size
[] =
16454 {"Unused", "small", "int", "forced to int"};
16455 static const char *const arm_attr_tag_ABI_HardFP_use
[] =
16456 {"As Tag_FP_arch", "SP only", "Reserved", "Deprecated"};
16457 static const char *const arm_attr_tag_ABI_VFP_args
[] =
16458 {"AAPCS", "VFP registers", "custom", "compatible"};
16459 static const char *const arm_attr_tag_ABI_WMMX_args
[] =
16460 {"AAPCS", "WMMX registers", "custom"};
16461 static const char *const arm_attr_tag_ABI_optimization_goals
[] =
16462 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
16463 "Aggressive Size", "Prefer Debug", "Aggressive Debug"};
16464 static const char *const arm_attr_tag_ABI_FP_optimization_goals
[] =
16465 {"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
16466 "Aggressive Size", "Prefer Accuracy", "Aggressive Accuracy"};
16467 static const char *const arm_attr_tag_CPU_unaligned_access
[] = {"None", "v6"};
16468 static const char *const arm_attr_tag_FP_HP_extension
[] =
16469 {"Not Allowed", "Allowed"};
16470 static const char *const arm_attr_tag_ABI_FP_16bit_format
[] =
16471 {"None", "IEEE 754", "Alternative Format"};
16472 static const char *const arm_attr_tag_DSP_extension
[] =
16473 {"Follow architecture", "Allowed"};
16474 static const char *const arm_attr_tag_MPextension_use
[] =
16475 {"Not Allowed", "Allowed"};
16476 static const char *const arm_attr_tag_DIV_use
[] =
16477 {"Allowed in Thumb-ISA, v7-R or v7-M", "Not allowed",
16478 "Allowed in v7-A with integer division extension"};
16479 static const char *const arm_attr_tag_T2EE_use
[] = {"Not Allowed", "Allowed"};
16480 static const char *const arm_attr_tag_Virtualization_use
[] =
16481 {"Not Allowed", "TrustZone", "Virtualization Extensions",
16482 "TrustZone and Virtualization Extensions"};
16483 static const char *const arm_attr_tag_MPextension_use_legacy
[] =
16484 {"Not Allowed", "Allowed"};
16486 static const char *const arm_attr_tag_MVE_arch
[] =
16487 {"No MVE", "MVE Integer only", "MVE Integer and FP"};
16489 static const char * arm_attr_tag_PAC_extension
[] =
16490 {"No PAC/AUT instructions",
16491 "PAC/AUT instructions permitted in the NOP space",
16492 "PAC/AUT instructions permitted in the NOP and in the non-NOP space"};
16494 static const char * arm_attr_tag_BTI_extension
[] =
16495 {"BTI instructions not permitted",
16496 "BTI instructions permitted in the NOP space",
16497 "BTI instructions permitted in the NOP and in the non-NOP space"};
16499 static const char * arm_attr_tag_BTI_use
[] =
16500 {"Compiled without branch target enforcement",
16501 "Compiled with branch target enforcement"};
16503 static const char * arm_attr_tag_PACRET_use
[] =
16504 {"Compiled without return address signing and authentication",
16505 "Compiled with return address signing and authentication"};
16507 #define LOOKUP(id, name) \
16508 {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
16509 static arm_attr_public_tag arm_attr_public_tags
[] =
16511 {4, "CPU_raw_name", 1, NULL
},
16512 {5, "CPU_name", 1, NULL
},
16513 LOOKUP(6, CPU_arch
),
16514 {7, "CPU_arch_profile", 0, NULL
},
16515 LOOKUP(8, ARM_ISA_use
),
16516 LOOKUP(9, THUMB_ISA_use
),
16517 LOOKUP(10, FP_arch
),
16518 LOOKUP(11, WMMX_arch
),
16519 LOOKUP(12, Advanced_SIMD_arch
),
16520 LOOKUP(13, PCS_config
),
16521 LOOKUP(14, ABI_PCS_R9_use
),
16522 LOOKUP(15, ABI_PCS_RW_data
),
16523 LOOKUP(16, ABI_PCS_RO_data
),
16524 LOOKUP(17, ABI_PCS_GOT_use
),
16525 LOOKUP(18, ABI_PCS_wchar_t
),
16526 LOOKUP(19, ABI_FP_rounding
),
16527 LOOKUP(20, ABI_FP_denormal
),
16528 LOOKUP(21, ABI_FP_exceptions
),
16529 LOOKUP(22, ABI_FP_user_exceptions
),
16530 LOOKUP(23, ABI_FP_number_model
),
16531 {24, "ABI_align_needed", 0, NULL
},
16532 {25, "ABI_align_preserved", 0, NULL
},
16533 LOOKUP(26, ABI_enum_size
),
16534 LOOKUP(27, ABI_HardFP_use
),
16535 LOOKUP(28, ABI_VFP_args
),
16536 LOOKUP(29, ABI_WMMX_args
),
16537 LOOKUP(30, ABI_optimization_goals
),
16538 LOOKUP(31, ABI_FP_optimization_goals
),
16539 {32, "compatibility", 0, NULL
},
16540 LOOKUP(34, CPU_unaligned_access
),
16541 LOOKUP(36, FP_HP_extension
),
16542 LOOKUP(38, ABI_FP_16bit_format
),
16543 LOOKUP(42, MPextension_use
),
16544 LOOKUP(44, DIV_use
),
16545 LOOKUP(46, DSP_extension
),
16546 LOOKUP(48, MVE_arch
),
16547 LOOKUP(50, PAC_extension
),
16548 LOOKUP(52, BTI_extension
),
16549 LOOKUP(74, BTI_use
),
16550 LOOKUP(76, PACRET_use
),
16551 {64, "nodefaults", 0, NULL
},
16552 {65, "also_compatible_with", 0, NULL
},
16553 LOOKUP(66, T2EE_use
),
16554 {67, "conformance", 1, NULL
},
16555 LOOKUP(68, Virtualization_use
),
16556 LOOKUP(70, MPextension_use_legacy
)
16560 static unsigned char *
16561 display_arm_attribute (unsigned char * p
,
16562 const unsigned char * const end
)
16566 arm_attr_public_tag
* attr
;
16570 READ_ULEB (tag
, p
, end
);
16572 for (i
= 0; i
< ARRAY_SIZE (arm_attr_public_tags
); i
++)
16574 if (arm_attr_public_tags
[i
].tag
== tag
)
16576 attr
= &arm_attr_public_tags
[i
];
16583 printf (" Tag_%s: ", attr
->name
);
16584 switch (attr
->type
)
16589 case 7: /* Tag_CPU_arch_profile. */
16590 READ_ULEB (val
, p
, end
);
16593 case 0: printf (_("None\n")); break;
16594 case 'A': printf (_("Application\n")); break;
16595 case 'R': printf (_("Realtime\n")); break;
16596 case 'M': printf (_("Microcontroller\n")); break;
16597 case 'S': printf (_("Application or Realtime\n")); break;
16598 default: printf ("??? (%d)\n", val
); break;
16602 case 24: /* Tag_align_needed. */
16603 READ_ULEB (val
, p
, end
);
16606 case 0: printf (_("None\n")); break;
16607 case 1: printf (_("8-byte\n")); break;
16608 case 2: printf (_("4-byte\n")); break;
16609 case 3: printf ("??? 3\n"); break;
16612 printf (_("8-byte and up to %d-byte extended\n"),
16615 printf ("??? (%d)\n", val
);
16620 case 25: /* Tag_align_preserved. */
16621 READ_ULEB (val
, p
, end
);
16624 case 0: printf (_("None\n")); break;
16625 case 1: printf (_("8-byte, except leaf SP\n")); break;
16626 case 2: printf (_("8-byte\n")); break;
16627 case 3: printf ("??? 3\n"); break;
16630 printf (_("8-byte and up to %d-byte extended\n"),
16633 printf ("??? (%d)\n", val
);
16638 case 32: /* Tag_compatibility. */
16640 READ_ULEB (val
, p
, end
);
16641 printf (_("flag = %d, vendor = "), val
);
16644 size_t maxlen
= (end
- p
) - 1;
16646 print_symbol ((int) maxlen
, (const char *) p
);
16647 p
+= strnlen ((char *) p
, maxlen
) + 1;
16651 printf (_("<corrupt>"));
16652 p
= (unsigned char *) end
;
16658 case 64: /* Tag_nodefaults. */
16659 /* PR 17531: file: 001-505008-0.01. */
16662 printf (_("True\n"));
16665 case 65: /* Tag_also_compatible_with. */
16666 READ_ULEB (val
, p
, end
);
16667 if (val
== 6 /* Tag_CPU_arch. */)
16669 READ_ULEB (val
, p
, end
);
16670 if ((unsigned int) val
>= ARRAY_SIZE (arm_attr_tag_CPU_arch
))
16671 printf ("??? (%d)\n", val
);
16673 printf ("%s\n", arm_attr_tag_CPU_arch
[val
]);
16677 while (p
< end
&& *(p
++) != '\0' /* NUL terminator. */)
16682 printf (_("<unknown: %d>\n"), tag
);
16688 return display_tag_value (-1, p
, end
);
16690 return display_tag_value (0, p
, end
);
16693 assert (attr
->type
& 0x80);
16694 READ_ULEB (val
, p
, end
);
16695 type
= attr
->type
& 0x7f;
16697 printf ("??? (%d)\n", val
);
16699 printf ("%s\n", attr
->table
[val
]);
16704 return display_tag_value (tag
, p
, end
);
16707 static unsigned char *
16708 display_gnu_attribute (unsigned char * p
,
16709 unsigned char * (* display_proc_gnu_attribute
) (unsigned char *, unsigned int, const unsigned char * const),
16710 const unsigned char * const end
)
16715 READ_ULEB (tag
, p
, end
);
16717 /* Tag_compatibility is the only generic GNU attribute defined at
16721 READ_ULEB (val
, p
, end
);
16723 printf (_("flag = %d, vendor = "), val
);
16726 printf (_("<corrupt>\n"));
16727 warn (_("corrupt vendor attribute\n"));
16733 size_t maxlen
= (end
- p
) - 1;
16735 print_symbol ((int) maxlen
, (const char *) p
);
16736 p
+= strnlen ((char *) p
, maxlen
) + 1;
16740 printf (_("<corrupt>"));
16741 p
= (unsigned char *) end
;
16748 if ((tag
& 2) == 0 && display_proc_gnu_attribute
)
16749 return display_proc_gnu_attribute (p
, tag
, end
);
16751 return display_tag_value (tag
, p
, end
);
16754 static unsigned char *
16755 display_m68k_gnu_attribute (unsigned char * p
,
16757 const unsigned char * const end
)
16761 if (tag
== Tag_GNU_M68K_ABI_FP
)
16763 printf (" Tag_GNU_M68K_ABI_FP: ");
16766 printf (_("<corrupt>\n"));
16769 READ_ULEB (val
, p
, end
);
16772 printf ("(%#x), ", val
);
16777 printf (_("unspecified hard/soft float\n"));
16780 printf (_("hard float\n"));
16783 printf (_("soft float\n"));
16789 return display_tag_value (tag
& 1, p
, end
);
16792 static unsigned char *
16793 display_power_gnu_attribute (unsigned char * p
,
16795 const unsigned char * const end
)
16799 if (tag
== Tag_GNU_Power_ABI_FP
)
16801 printf (" Tag_GNU_Power_ABI_FP: ");
16804 printf (_("<corrupt>\n"));
16807 READ_ULEB (val
, p
, end
);
16810 printf ("(%#x), ", val
);
16815 printf (_("unspecified hard/soft float, "));
16818 printf (_("hard float, "));
16821 printf (_("soft float, "));
16824 printf (_("single-precision hard float, "));
16831 printf (_("unspecified long double\n"));
16834 printf (_("128-bit IBM long double\n"));
16837 printf (_("64-bit long double\n"));
16840 printf (_("128-bit IEEE long double\n"));
16846 if (tag
== Tag_GNU_Power_ABI_Vector
)
16848 printf (" Tag_GNU_Power_ABI_Vector: ");
16851 printf (_("<corrupt>\n"));
16854 READ_ULEB (val
, p
, end
);
16857 printf ("(%#x), ", val
);
16862 printf (_("unspecified\n"));
16865 printf (_("generic\n"));
16868 printf ("AltiVec\n");
16877 if (tag
== Tag_GNU_Power_ABI_Struct_Return
)
16879 printf (" Tag_GNU_Power_ABI_Struct_Return: ");
16882 printf (_("<corrupt>\n"));
16885 READ_ULEB (val
, p
, end
);
16888 printf ("(%#x), ", val
);
16893 printf (_("unspecified\n"));
16896 printf ("r3/r4\n");
16899 printf (_("memory\n"));
16908 return display_tag_value (tag
& 1, p
, end
);
16911 static unsigned char *
16912 display_s390_gnu_attribute (unsigned char * p
,
16914 const unsigned char * const end
)
16918 if (tag
== Tag_GNU_S390_ABI_Vector
)
16920 printf (" Tag_GNU_S390_ABI_Vector: ");
16921 READ_ULEB (val
, p
, end
);
16926 printf (_("any\n"));
16929 printf (_("software\n"));
16932 printf (_("hardware\n"));
16935 printf ("??? (%d)\n", val
);
16941 return display_tag_value (tag
& 1, p
, end
);
16945 display_sparc_hwcaps (unsigned int mask
)
16951 if (mask
& ELF_SPARC_HWCAP_MUL32
)
16952 fputs ("mul32", stdout
), first
= false;
16953 if (mask
& ELF_SPARC_HWCAP_DIV32
)
16954 printf ("%sdiv32", first
? "" : "|"), first
= false;
16955 if (mask
& ELF_SPARC_HWCAP_FSMULD
)
16956 printf ("%sfsmuld", first
? "" : "|"), first
= false;
16957 if (mask
& ELF_SPARC_HWCAP_V8PLUS
)
16958 printf ("%sv8plus", first
? "" : "|"), first
= false;
16959 if (mask
& ELF_SPARC_HWCAP_POPC
)
16960 printf ("%spopc", first
? "" : "|"), first
= false;
16961 if (mask
& ELF_SPARC_HWCAP_VIS
)
16962 printf ("%svis", first
? "" : "|"), first
= false;
16963 if (mask
& ELF_SPARC_HWCAP_VIS2
)
16964 printf ("%svis2", first
? "" : "|"), first
= false;
16965 if (mask
& ELF_SPARC_HWCAP_ASI_BLK_INIT
)
16966 printf ("%sASIBlkInit", first
? "" : "|"), first
= false;
16967 if (mask
& ELF_SPARC_HWCAP_FMAF
)
16968 printf ("%sfmaf", first
? "" : "|"), first
= false;
16969 if (mask
& ELF_SPARC_HWCAP_VIS3
)
16970 printf ("%svis3", first
? "" : "|"), first
= false;
16971 if (mask
& ELF_SPARC_HWCAP_HPC
)
16972 printf ("%shpc", first
? "" : "|"), first
= false;
16973 if (mask
& ELF_SPARC_HWCAP_RANDOM
)
16974 printf ("%srandom", first
? "" : "|"), first
= false;
16975 if (mask
& ELF_SPARC_HWCAP_TRANS
)
16976 printf ("%strans", first
? "" : "|"), first
= false;
16977 if (mask
& ELF_SPARC_HWCAP_FJFMAU
)
16978 printf ("%sfjfmau", first
? "" : "|"), first
= false;
16979 if (mask
& ELF_SPARC_HWCAP_IMA
)
16980 printf ("%sima", first
? "" : "|"), first
= false;
16981 if (mask
& ELF_SPARC_HWCAP_ASI_CACHE_SPARING
)
16982 printf ("%scspare", first
? "" : "|"), first
= false;
16985 fputc ('0', stdout
);
16986 fputc ('\n', stdout
);
16990 display_sparc_hwcaps2 (unsigned int mask
)
16996 if (mask
& ELF_SPARC_HWCAP2_FJATHPLUS
)
16997 fputs ("fjathplus", stdout
), first
= false;
16998 if (mask
& ELF_SPARC_HWCAP2_VIS3B
)
16999 printf ("%svis3b", first
? "" : "|"), first
= false;
17000 if (mask
& ELF_SPARC_HWCAP2_ADP
)
17001 printf ("%sadp", first
? "" : "|"), first
= false;
17002 if (mask
& ELF_SPARC_HWCAP2_SPARC5
)
17003 printf ("%ssparc5", first
? "" : "|"), first
= false;
17004 if (mask
& ELF_SPARC_HWCAP2_MWAIT
)
17005 printf ("%smwait", first
? "" : "|"), first
= false;
17006 if (mask
& ELF_SPARC_HWCAP2_XMPMUL
)
17007 printf ("%sxmpmul", first
? "" : "|"), first
= false;
17008 if (mask
& ELF_SPARC_HWCAP2_XMONT
)
17009 printf ("%sxmont2", first
? "" : "|"), first
= false;
17010 if (mask
& ELF_SPARC_HWCAP2_NSEC
)
17011 printf ("%snsec", first
? "" : "|"), first
= false;
17012 if (mask
& ELF_SPARC_HWCAP2_FJATHHPC
)
17013 printf ("%sfjathhpc", first
? "" : "|"), first
= false;
17014 if (mask
& ELF_SPARC_HWCAP2_FJDES
)
17015 printf ("%sfjdes", first
? "" : "|"), first
= false;
17016 if (mask
& ELF_SPARC_HWCAP2_FJAES
)
17017 printf ("%sfjaes", first
? "" : "|"), first
= false;
17020 fputc ('0', stdout
);
17021 fputc ('\n', stdout
);
17024 static unsigned char *
17025 display_sparc_gnu_attribute (unsigned char * p
,
17027 const unsigned char * const end
)
17031 if (tag
== Tag_GNU_Sparc_HWCAPS
)
17033 READ_ULEB (val
, p
, end
);
17034 printf (" Tag_GNU_Sparc_HWCAPS: ");
17035 display_sparc_hwcaps (val
);
17038 if (tag
== Tag_GNU_Sparc_HWCAPS2
)
17040 READ_ULEB (val
, p
, end
);
17041 printf (" Tag_GNU_Sparc_HWCAPS2: ");
17042 display_sparc_hwcaps2 (val
);
17046 return display_tag_value (tag
, p
, end
);
17050 print_mips_fp_abi_value (unsigned int val
)
17054 case Val_GNU_MIPS_ABI_FP_ANY
:
17055 printf (_("Hard or soft float\n"));
17057 case Val_GNU_MIPS_ABI_FP_DOUBLE
:
17058 printf (_("Hard float (double precision)\n"));
17060 case Val_GNU_MIPS_ABI_FP_SINGLE
:
17061 printf (_("Hard float (single precision)\n"));
17063 case Val_GNU_MIPS_ABI_FP_SOFT
:
17064 printf (_("Soft float\n"));
17066 case Val_GNU_MIPS_ABI_FP_OLD_64
:
17067 printf (_("Hard float (MIPS32r2 64-bit FPU 12 callee-saved)\n"));
17069 case Val_GNU_MIPS_ABI_FP_XX
:
17070 printf (_("Hard float (32-bit CPU, Any FPU)\n"));
17072 case Val_GNU_MIPS_ABI_FP_64
:
17073 printf (_("Hard float (32-bit CPU, 64-bit FPU)\n"));
17075 case Val_GNU_MIPS_ABI_FP_64A
:
17076 printf (_("Hard float compat (32-bit CPU, 64-bit FPU)\n"));
17078 case Val_GNU_MIPS_ABI_FP_NAN2008
:
17079 printf (_("NaN 2008 compatibility\n"));
17082 printf ("??? (%d)\n", val
);
17087 static unsigned char *
17088 display_mips_gnu_attribute (unsigned char * p
,
17090 const unsigned char * const end
)
17092 if (tag
== Tag_GNU_MIPS_ABI_FP
)
17096 printf (" Tag_GNU_MIPS_ABI_FP: ");
17097 READ_ULEB (val
, p
, end
);
17098 print_mips_fp_abi_value (val
);
17102 if (tag
== Tag_GNU_MIPS_ABI_MSA
)
17106 printf (" Tag_GNU_MIPS_ABI_MSA: ");
17107 READ_ULEB (val
, p
, end
);
17111 case Val_GNU_MIPS_ABI_MSA_ANY
:
17112 printf (_("Any MSA or not\n"));
17114 case Val_GNU_MIPS_ABI_MSA_128
:
17115 printf (_("128-bit MSA\n"));
17118 printf ("??? (%d)\n", val
);
17124 return display_tag_value (tag
& 1, p
, end
);
17127 static unsigned char *
17128 display_tic6x_attribute (unsigned char * p
,
17129 const unsigned char * const end
)
17134 READ_ULEB (tag
, p
, end
);
17139 printf (" Tag_ISA: ");
17140 READ_ULEB (val
, p
, end
);
17144 case C6XABI_Tag_ISA_none
:
17145 printf (_("None\n"));
17147 case C6XABI_Tag_ISA_C62X
:
17150 case C6XABI_Tag_ISA_C67X
:
17153 case C6XABI_Tag_ISA_C67XP
:
17154 printf ("C67x+\n");
17156 case C6XABI_Tag_ISA_C64X
:
17159 case C6XABI_Tag_ISA_C64XP
:
17160 printf ("C64x+\n");
17162 case C6XABI_Tag_ISA_C674X
:
17163 printf ("C674x\n");
17166 printf ("??? (%d)\n", val
);
17171 case Tag_ABI_wchar_t
:
17172 printf (" Tag_ABI_wchar_t: ");
17173 READ_ULEB (val
, p
, end
);
17177 printf (_("Not used\n"));
17180 printf (_("2 bytes\n"));
17183 printf (_("4 bytes\n"));
17186 printf ("??? (%d)\n", val
);
17191 case Tag_ABI_stack_align_needed
:
17192 printf (" Tag_ABI_stack_align_needed: ");
17193 READ_ULEB (val
, p
, end
);
17197 printf (_("8-byte\n"));
17200 printf (_("16-byte\n"));
17203 printf ("??? (%d)\n", val
);
17208 case Tag_ABI_stack_align_preserved
:
17209 READ_ULEB (val
, p
, end
);
17210 printf (" Tag_ABI_stack_align_preserved: ");
17214 printf (_("8-byte\n"));
17217 printf (_("16-byte\n"));
17220 printf ("??? (%d)\n", val
);
17226 READ_ULEB (val
, p
, end
);
17227 printf (" Tag_ABI_DSBT: ");
17231 printf (_("DSBT addressing not used\n"));
17234 printf (_("DSBT addressing used\n"));
17237 printf ("??? (%d)\n", val
);
17243 READ_ULEB (val
, p
, end
);
17244 printf (" Tag_ABI_PID: ");
17248 printf (_("Data addressing position-dependent\n"));
17251 printf (_("Data addressing position-independent, GOT near DP\n"));
17254 printf (_("Data addressing position-independent, GOT far from DP\n"));
17257 printf ("??? (%d)\n", val
);
17263 READ_ULEB (val
, p
, end
);
17264 printf (" Tag_ABI_PIC: ");
17268 printf (_("Code addressing position-dependent\n"));
17271 printf (_("Code addressing position-independent\n"));
17274 printf ("??? (%d)\n", val
);
17279 case Tag_ABI_array_object_alignment
:
17280 READ_ULEB (val
, p
, end
);
17281 printf (" Tag_ABI_array_object_alignment: ");
17285 printf (_("8-byte\n"));
17288 printf (_("4-byte\n"));
17291 printf (_("16-byte\n"));
17294 printf ("??? (%d)\n", val
);
17299 case Tag_ABI_array_object_align_expected
:
17300 READ_ULEB (val
, p
, end
);
17301 printf (" Tag_ABI_array_object_align_expected: ");
17305 printf (_("8-byte\n"));
17308 printf (_("4-byte\n"));
17311 printf (_("16-byte\n"));
17314 printf ("??? (%d)\n", val
);
17319 case Tag_ABI_compatibility
:
17321 READ_ULEB (val
, p
, end
);
17322 printf (" Tag_ABI_compatibility: ");
17323 printf (_("flag = %d, vendor = "), val
);
17326 size_t maxlen
= (end
- p
) - 1;
17328 print_symbol ((int) maxlen
, (const char *) p
);
17329 p
+= strnlen ((char *) p
, maxlen
) + 1;
17333 printf (_("<corrupt>"));
17334 p
= (unsigned char *) end
;
17340 case Tag_ABI_conformance
:
17342 printf (" Tag_ABI_conformance: \"");
17345 size_t maxlen
= (end
- p
) - 1;
17347 print_symbol ((int) maxlen
, (const char *) p
);
17348 p
+= strnlen ((char *) p
, maxlen
) + 1;
17352 printf (_("<corrupt>"));
17353 p
= (unsigned char *) end
;
17360 return display_tag_value (tag
, p
, end
);
17364 display_raw_attribute (unsigned char * p
, unsigned char const * const end
)
17366 unsigned long addr
= 0;
17367 size_t bytes
= end
- p
;
17374 int lbytes
= (bytes
> 16 ? 16 : bytes
);
17376 printf (" 0x%8.8lx ", addr
);
17378 for (j
= 0; j
< 16; j
++)
17381 printf ("%2.2x", p
[j
]);
17389 for (j
= 0; j
< lbytes
; j
++)
17392 if (k
>= ' ' && k
< 0x7f)
17408 static unsigned char *
17409 display_msp430_attribute (unsigned char * p
,
17410 const unsigned char * const end
)
17415 READ_ULEB (tag
, p
, end
);
17419 case OFBA_MSPABI_Tag_ISA
:
17420 printf (" Tag_ISA: ");
17421 READ_ULEB (val
, p
, end
);
17424 case 0: printf (_("None\n")); break;
17425 case 1: printf (_("MSP430\n")); break;
17426 case 2: printf (_("MSP430X\n")); break;
17427 default: printf ("??? (%d)\n", val
); break;
17431 case OFBA_MSPABI_Tag_Code_Model
:
17432 printf (" Tag_Code_Model: ");
17433 READ_ULEB (val
, p
, end
);
17436 case 0: printf (_("None\n")); break;
17437 case 1: printf (_("Small\n")); break;
17438 case 2: printf (_("Large\n")); break;
17439 default: printf ("??? (%d)\n", val
); break;
17443 case OFBA_MSPABI_Tag_Data_Model
:
17444 printf (" Tag_Data_Model: ");
17445 READ_ULEB (val
, p
, end
);
17448 case 0: printf (_("None\n")); break;
17449 case 1: printf (_("Small\n")); break;
17450 case 2: printf (_("Large\n")); break;
17451 case 3: printf (_("Restricted Large\n")); break;
17452 default: printf ("??? (%d)\n", val
); break;
17457 printf (_(" <unknown tag %d>: "), tag
);
17464 size_t maxlen
= (end
- p
) - 1;
17466 print_symbol ((int) maxlen
, (const char *) p
);
17467 p
+= strnlen ((char *) p
, maxlen
) + 1;
17471 printf (_("<corrupt>"));
17472 p
= (unsigned char *) end
;
17478 READ_ULEB (val
, p
, end
);
17479 printf ("%d (0x%x)\n", val
, val
);
17488 static unsigned char *
17489 display_msp430_gnu_attribute (unsigned char * p
,
17491 const unsigned char * const end
)
17493 if (tag
== Tag_GNU_MSP430_Data_Region
)
17497 printf (" Tag_GNU_MSP430_Data_Region: ");
17498 READ_ULEB (val
, p
, end
);
17502 case Val_GNU_MSP430_Data_Region_Any
:
17503 printf (_("Any Region\n"));
17505 case Val_GNU_MSP430_Data_Region_Lower
:
17506 printf (_("Lower Region Only\n"));
17509 printf ("??? (%u)\n", val
);
17513 return display_tag_value (tag
& 1, p
, end
);
17516 struct riscv_attr_tag_t
{
17521 static struct riscv_attr_tag_t riscv_attr_tag
[] =
17523 #define T(tag) {"Tag_RISCV_" #tag, Tag_RISCV_##tag}
17526 T(priv_spec_minor
),
17527 T(priv_spec_revision
),
17528 T(unaligned_access
),
17533 static unsigned char *
17534 display_riscv_attribute (unsigned char *p
,
17535 const unsigned char * const end
)
17539 struct riscv_attr_tag_t
*attr
= NULL
;
17542 READ_ULEB (tag
, p
, end
);
17544 /* Find the name of attribute. */
17545 for (i
= 0; i
< ARRAY_SIZE (riscv_attr_tag
); i
++)
17547 if (riscv_attr_tag
[i
].tag
== tag
)
17549 attr
= &riscv_attr_tag
[i
];
17555 printf (" %s: ", attr
->name
);
17557 return display_tag_value (tag
, p
, end
);
17561 case Tag_RISCV_priv_spec
:
17562 case Tag_RISCV_priv_spec_minor
:
17563 case Tag_RISCV_priv_spec_revision
:
17564 READ_ULEB (val
, p
, end
);
17565 printf (_("%u\n"), val
);
17567 case Tag_RISCV_unaligned_access
:
17568 READ_ULEB (val
, p
, end
);
17572 printf (_("No unaligned access\n"));
17575 printf (_("Unaligned access\n"));
17579 case Tag_RISCV_stack_align
:
17580 READ_ULEB (val
, p
, end
);
17581 printf (_("%u-bytes\n"), val
);
17583 case Tag_RISCV_arch
:
17584 p
= display_tag_value (-1, p
, end
);
17587 return display_tag_value (tag
, p
, end
);
17593 static unsigned char *
17594 display_csky_attribute (unsigned char * p
,
17595 const unsigned char * const end
)
17599 READ_ULEB (tag
, p
, end
);
17601 if (tag
>= Tag_CSKY_MAX
)
17603 return display_tag_value (-1, p
, end
);
17608 case Tag_CSKY_ARCH_NAME
:
17609 printf (" Tag_CSKY_ARCH_NAME:\t\t");
17610 return display_tag_value (-1, p
, end
);
17611 case Tag_CSKY_CPU_NAME
:
17612 printf (" Tag_CSKY_CPU_NAME:\t\t");
17613 return display_tag_value (-1, p
, end
);
17615 case Tag_CSKY_ISA_FLAGS
:
17616 printf (" Tag_CSKY_ISA_FLAGS:\t\t");
17617 return display_tag_value (0, p
, end
);
17618 case Tag_CSKY_ISA_EXT_FLAGS
:
17619 printf (" Tag_CSKY_ISA_EXT_FLAGS:\t");
17620 return display_tag_value (0, p
, end
);
17622 case Tag_CSKY_DSP_VERSION
:
17623 printf (" Tag_CSKY_DSP_VERSION:\t\t");
17624 READ_ULEB (val
, p
, end
);
17625 if (val
== VAL_CSKY_DSP_VERSION_EXTENSION
)
17626 printf ("DSP Extension\n");
17627 else if (val
== VAL_CSKY_DSP_VERSION_2
)
17628 printf ("DSP 2.0\n");
17631 case Tag_CSKY_VDSP_VERSION
:
17632 printf (" Tag_CSKY_VDSP_VERSION:\t");
17633 READ_ULEB (val
, p
, end
);
17634 printf ("VDSP Version %d\n", val
);
17637 case Tag_CSKY_FPU_VERSION
:
17638 printf (" Tag_CSKY_FPU_VERSION:\t\t");
17639 READ_ULEB (val
, p
, end
);
17640 if (val
== VAL_CSKY_FPU_VERSION_1
)
17641 printf ("ABIV1 FPU Version 1\n");
17642 else if (val
== VAL_CSKY_FPU_VERSION_2
)
17643 printf ("FPU Version 2\n");
17646 case Tag_CSKY_FPU_ABI
:
17647 printf (" Tag_CSKY_FPU_ABI:\t\t");
17648 READ_ULEB (val
, p
, end
);
17649 if (val
== VAL_CSKY_FPU_ABI_HARD
)
17651 else if (val
== VAL_CSKY_FPU_ABI_SOFTFP
)
17652 printf ("SoftFP\n");
17653 else if (val
== VAL_CSKY_FPU_ABI_SOFT
)
17656 case Tag_CSKY_FPU_ROUNDING
:
17657 READ_ULEB (val
, p
, end
);
17660 printf (" Tag_CSKY_FPU_ROUNDING:\t");
17661 printf ("Needed\n");
17664 case Tag_CSKY_FPU_DENORMAL
:
17665 READ_ULEB (val
, p
, end
);
17668 printf (" Tag_CSKY_FPU_DENORMAL:\t");
17669 printf ("Needed\n");
17672 case Tag_CSKY_FPU_Exception
:
17673 READ_ULEB (val
, p
, end
);
17676 printf (" Tag_CSKY_FPU_Exception:\t");
17677 printf ("Needed\n");
17680 case Tag_CSKY_FPU_NUMBER_MODULE
:
17681 printf (" Tag_CSKY_FPU_NUMBER_MODULE:\t");
17682 return display_tag_value (-1, p
, end
);
17683 case Tag_CSKY_FPU_HARDFP
:
17684 printf (" Tag_CSKY_FPU_HARDFP:\t\t");
17685 READ_ULEB (val
, p
, end
);
17686 if (val
& VAL_CSKY_FPU_HARDFP_HALF
)
17688 if (val
& VAL_CSKY_FPU_HARDFP_SINGLE
)
17689 printf (" Single");
17690 if (val
& VAL_CSKY_FPU_HARDFP_DOUBLE
)
17691 printf (" Double");
17695 return display_tag_value (tag
, p
, end
);
17701 process_attributes (Filedata
* filedata
,
17702 const char * public_name
,
17703 unsigned int proc_type
,
17704 unsigned char * (* display_pub_attribute
) (unsigned char *, const unsigned char * const),
17705 unsigned char * (* display_proc_gnu_attribute
) (unsigned char *, unsigned int, const unsigned char * const))
17707 Elf_Internal_Shdr
* sect
;
17711 /* Find the section header so that we get the size. */
17712 for (i
= 0, sect
= filedata
->section_headers
;
17713 i
< filedata
->file_header
.e_shnum
;
17716 unsigned char * contents
;
17719 if (sect
->sh_type
!= proc_type
&& sect
->sh_type
!= SHT_GNU_ATTRIBUTES
)
17722 contents
= (unsigned char *) get_data (NULL
, filedata
, sect
->sh_offset
, 1,
17723 sect
->sh_size
, _("attributes"));
17724 if (contents
== NULL
)
17731 /* The first character is the version of the attributes.
17732 Currently only version 1, (aka 'A') is recognised here. */
17735 printf (_("Unknown attributes version '%c'(%d) - expecting 'A'\n"), *p
, *p
);
17740 bfd_vma section_len
;
17742 section_len
= sect
->sh_size
- 1;
17745 while (section_len
> 0)
17748 unsigned int namelen
;
17749 bool public_section
;
17752 if (section_len
<= 4)
17754 error (_("Tag section ends prematurely\n"));
17758 attr_len
= byte_get (p
, 4);
17761 if (attr_len
> section_len
)
17763 error (_("Bad attribute length (%u > %u)\n"),
17764 (unsigned) attr_len
, (unsigned) section_len
);
17765 attr_len
= section_len
;
17768 /* PR 17531: file: 001-101425-0.004 */
17769 else if (attr_len
< 5)
17771 error (_("Attribute length of %u is too small\n"), (unsigned) attr_len
);
17776 section_len
-= attr_len
;
17779 namelen
= strnlen ((char *) p
, attr_len
) + 1;
17780 if (namelen
== 0 || namelen
>= attr_len
)
17782 error (_("Corrupt attribute section name\n"));
17787 printf (_("Attribute Section: "));
17788 print_symbol (INT_MAX
, (const char *) p
);
17791 if (public_name
&& streq ((char *) p
, public_name
))
17792 public_section
= true;
17794 public_section
= false;
17796 if (streq ((char *) p
, "gnu"))
17797 gnu_section
= true;
17799 gnu_section
= false;
17802 attr_len
-= namelen
;
17804 while (attr_len
> 0 && p
< contents
+ sect
->sh_size
)
17809 unsigned char * end
;
17811 /* PR binutils/17531: Safe handling of corrupt files. */
17814 error (_("Unused bytes at end of section\n"));
17821 size
= byte_get (p
, 4);
17822 if (size
> attr_len
)
17824 error (_("Bad subsection length (%u > %u)\n"),
17825 (unsigned) size
, (unsigned) attr_len
);
17829 /* PR binutils/17531: Safe handling of corrupt files. */
17832 error (_("Bad subsection length (%u < 6)\n"),
17840 end
= p
+ size
- 1;
17841 assert (end
<= contents
+ sect
->sh_size
);
17847 printf (_("File Attributes\n"));
17850 printf (_("Section Attributes:"));
17853 printf (_("Symbol Attributes:"));
17854 /* Fall through. */
17858 READ_ULEB (val
, p
, end
);
17861 printf (" %d", val
);
17866 printf (_("Unknown tag: %d\n"), tag
);
17867 public_section
= false;
17871 if (public_section
&& display_pub_attribute
!= NULL
)
17874 p
= display_pub_attribute (p
, end
);
17877 else if (gnu_section
&& display_proc_gnu_attribute
!= NULL
)
17880 p
= display_gnu_attribute (p
,
17881 display_proc_gnu_attribute
,
17887 printf (_(" Unknown attribute:\n"));
17888 display_raw_attribute (p
, end
);
17903 /* DATA points to the contents of a MIPS GOT that starts at VMA PLTGOT.
17904 Print the Address, Access and Initial fields of an entry at VMA ADDR
17905 and return the VMA of the next entry, or -1 if there was a problem.
17906 Does not read from DATA_END or beyond. */
17909 print_mips_got_entry (unsigned char * data
, bfd_vma pltgot
, bfd_vma addr
,
17910 unsigned char * data_end
)
17913 print_vma (addr
, LONG_HEX
);
17915 if (addr
< pltgot
+ 0xfff0)
17916 printf ("%6d(gp)", (int) (addr
- pltgot
- 0x7ff0));
17918 printf ("%10s", "");
17921 printf ("%*s", is_32bit_elf
? 8 : 16, _("<unknown>"));
17925 unsigned char * from
= data
+ addr
- pltgot
;
17927 if (from
+ (is_32bit_elf
? 4 : 8) > data_end
)
17929 warn (_("MIPS GOT entry extends beyond the end of available data\n"));
17930 printf ("%*s", is_32bit_elf
? 8 : 16, _("<corrupt>"));
17931 return (bfd_vma
) -1;
17935 entry
= byte_get (data
+ addr
- pltgot
, is_32bit_elf
? 4 : 8);
17936 print_vma (entry
, LONG_HEX
);
17939 return addr
+ (is_32bit_elf
? 4 : 8);
17942 /* DATA points to the contents of a MIPS PLT GOT that starts at VMA
17943 PLTGOT. Print the Address and Initial fields of an entry at VMA
17944 ADDR and return the VMA of the next entry. */
17947 print_mips_pltgot_entry (unsigned char * data
, bfd_vma pltgot
, bfd_vma addr
)
17950 print_vma (addr
, LONG_HEX
);
17953 printf ("%*s", is_32bit_elf
? 8 : 16, _("<unknown>"));
17958 entry
= byte_get (data
+ addr
- pltgot
, is_32bit_elf
? 4 : 8);
17959 print_vma (entry
, LONG_HEX
);
17961 return addr
+ (is_32bit_elf
? 4 : 8);
17965 print_mips_ases (unsigned int mask
)
17967 if (mask
& AFL_ASE_DSP
)
17968 fputs ("\n\tDSP ASE", stdout
);
17969 if (mask
& AFL_ASE_DSPR2
)
17970 fputs ("\n\tDSP R2 ASE", stdout
);
17971 if (mask
& AFL_ASE_DSPR3
)
17972 fputs ("\n\tDSP R3 ASE", stdout
);
17973 if (mask
& AFL_ASE_EVA
)
17974 fputs ("\n\tEnhanced VA Scheme", stdout
);
17975 if (mask
& AFL_ASE_MCU
)
17976 fputs ("\n\tMCU (MicroController) ASE", stdout
);
17977 if (mask
& AFL_ASE_MDMX
)
17978 fputs ("\n\tMDMX ASE", stdout
);
17979 if (mask
& AFL_ASE_MIPS3D
)
17980 fputs ("\n\tMIPS-3D ASE", stdout
);
17981 if (mask
& AFL_ASE_MT
)
17982 fputs ("\n\tMT ASE", stdout
);
17983 if (mask
& AFL_ASE_SMARTMIPS
)
17984 fputs ("\n\tSmartMIPS ASE", stdout
);
17985 if (mask
& AFL_ASE_VIRT
)
17986 fputs ("\n\tVZ ASE", stdout
);
17987 if (mask
& AFL_ASE_MSA
)
17988 fputs ("\n\tMSA ASE", stdout
);
17989 if (mask
& AFL_ASE_MIPS16
)
17990 fputs ("\n\tMIPS16 ASE", stdout
);
17991 if (mask
& AFL_ASE_MICROMIPS
)
17992 fputs ("\n\tMICROMIPS ASE", stdout
);
17993 if (mask
& AFL_ASE_XPA
)
17994 fputs ("\n\tXPA ASE", stdout
);
17995 if (mask
& AFL_ASE_MIPS16E2
)
17996 fputs ("\n\tMIPS16e2 ASE", stdout
);
17997 if (mask
& AFL_ASE_CRC
)
17998 fputs ("\n\tCRC ASE", stdout
);
17999 if (mask
& AFL_ASE_GINV
)
18000 fputs ("\n\tGINV ASE", stdout
);
18001 if (mask
& AFL_ASE_LOONGSON_MMI
)
18002 fputs ("\n\tLoongson MMI ASE", stdout
);
18003 if (mask
& AFL_ASE_LOONGSON_CAM
)
18004 fputs ("\n\tLoongson CAM ASE", stdout
);
18005 if (mask
& AFL_ASE_LOONGSON_EXT
)
18006 fputs ("\n\tLoongson EXT ASE", stdout
);
18007 if (mask
& AFL_ASE_LOONGSON_EXT2
)
18008 fputs ("\n\tLoongson EXT2 ASE", stdout
);
18010 fprintf (stdout
, "\n\t%s", _("None"));
18011 else if ((mask
& ~AFL_ASE_MASK
) != 0)
18012 fprintf (stdout
, "\n\t%s (%x)", _("Unknown"), mask
& ~AFL_ASE_MASK
);
18016 print_mips_isa_ext (unsigned int isa_ext
)
18021 fputs (_("None"), stdout
);
18024 fputs ("RMI XLR", stdout
);
18026 case AFL_EXT_OCTEON3
:
18027 fputs ("Cavium Networks Octeon3", stdout
);
18029 case AFL_EXT_OCTEON2
:
18030 fputs ("Cavium Networks Octeon2", stdout
);
18032 case AFL_EXT_OCTEONP
:
18033 fputs ("Cavium Networks OcteonP", stdout
);
18035 case AFL_EXT_OCTEON
:
18036 fputs ("Cavium Networks Octeon", stdout
);
18039 fputs ("Toshiba R5900", stdout
);
18042 fputs ("MIPS R4650", stdout
);
18045 fputs ("LSI R4010", stdout
);
18048 fputs ("NEC VR4100", stdout
);
18051 fputs ("Toshiba R3900", stdout
);
18053 case AFL_EXT_10000
:
18054 fputs ("MIPS R10000", stdout
);
18057 fputs ("Broadcom SB-1", stdout
);
18060 fputs ("NEC VR4111/VR4181", stdout
);
18063 fputs ("NEC VR4120", stdout
);
18066 fputs ("NEC VR5400", stdout
);
18069 fputs ("NEC VR5500", stdout
);
18071 case AFL_EXT_LOONGSON_2E
:
18072 fputs ("ST Microelectronics Loongson 2E", stdout
);
18074 case AFL_EXT_LOONGSON_2F
:
18075 fputs ("ST Microelectronics Loongson 2F", stdout
);
18077 case AFL_EXT_INTERAPTIV_MR2
:
18078 fputs ("Imagination interAptiv MR2", stdout
);
18081 fprintf (stdout
, "%s (%d)", _("Unknown"), isa_ext
);
18086 get_mips_reg_size (int reg_size
)
18088 return (reg_size
== AFL_REG_NONE
) ? 0
18089 : (reg_size
== AFL_REG_32
) ? 32
18090 : (reg_size
== AFL_REG_64
) ? 64
18091 : (reg_size
== AFL_REG_128
) ? 128
18096 process_mips_specific (Filedata
* filedata
)
18098 Elf_Internal_Dyn
* entry
;
18099 Elf_Internal_Shdr
*sect
= NULL
;
18100 size_t liblist_offset
= 0;
18101 size_t liblistno
= 0;
18102 size_t conflictsno
= 0;
18103 size_t options_offset
= 0;
18104 size_t conflicts_offset
= 0;
18105 size_t pltrelsz
= 0;
18107 bfd_vma pltgot
= 0;
18108 bfd_vma mips_pltgot
= 0;
18109 bfd_vma jmprel
= 0;
18110 bfd_vma local_gotno
= 0;
18111 bfd_vma gotsym
= 0;
18112 bfd_vma symtabno
= 0;
18115 if (! process_attributes (filedata
, NULL
, SHT_GNU_ATTRIBUTES
, NULL
,
18116 display_mips_gnu_attribute
))
18119 sect
= find_section (filedata
, ".MIPS.abiflags");
18123 Elf_External_ABIFlags_v0
*abiflags_ext
;
18124 Elf_Internal_ABIFlags_v0 abiflags_in
;
18126 if (sizeof (Elf_External_ABIFlags_v0
) != sect
->sh_size
)
18128 error (_("Corrupt MIPS ABI Flags section.\n"));
18133 abiflags_ext
= get_data (NULL
, filedata
, sect
->sh_offset
, 1,
18134 sect
->sh_size
, _("MIPS ABI Flags section"));
18137 abiflags_in
.version
= BYTE_GET (abiflags_ext
->version
);
18138 abiflags_in
.isa_level
= BYTE_GET (abiflags_ext
->isa_level
);
18139 abiflags_in
.isa_rev
= BYTE_GET (abiflags_ext
->isa_rev
);
18140 abiflags_in
.gpr_size
= BYTE_GET (abiflags_ext
->gpr_size
);
18141 abiflags_in
.cpr1_size
= BYTE_GET (abiflags_ext
->cpr1_size
);
18142 abiflags_in
.cpr2_size
= BYTE_GET (abiflags_ext
->cpr2_size
);
18143 abiflags_in
.fp_abi
= BYTE_GET (abiflags_ext
->fp_abi
);
18144 abiflags_in
.isa_ext
= BYTE_GET (abiflags_ext
->isa_ext
);
18145 abiflags_in
.ases
= BYTE_GET (abiflags_ext
->ases
);
18146 abiflags_in
.flags1
= BYTE_GET (abiflags_ext
->flags1
);
18147 abiflags_in
.flags2
= BYTE_GET (abiflags_ext
->flags2
);
18149 printf ("\nMIPS ABI Flags Version: %d\n", abiflags_in
.version
);
18150 printf ("\nISA: MIPS%d", abiflags_in
.isa_level
);
18151 if (abiflags_in
.isa_rev
> 1)
18152 printf ("r%d", abiflags_in
.isa_rev
);
18153 printf ("\nGPR size: %d",
18154 get_mips_reg_size (abiflags_in
.gpr_size
));
18155 printf ("\nCPR1 size: %d",
18156 get_mips_reg_size (abiflags_in
.cpr1_size
));
18157 printf ("\nCPR2 size: %d",
18158 get_mips_reg_size (abiflags_in
.cpr2_size
));
18159 fputs ("\nFP ABI: ", stdout
);
18160 print_mips_fp_abi_value (abiflags_in
.fp_abi
);
18161 fputs ("ISA Extension: ", stdout
);
18162 print_mips_isa_ext (abiflags_in
.isa_ext
);
18163 fputs ("\nASEs:", stdout
);
18164 print_mips_ases (abiflags_in
.ases
);
18165 printf ("\nFLAGS 1: %8.8lx", abiflags_in
.flags1
);
18166 printf ("\nFLAGS 2: %8.8lx", abiflags_in
.flags2
);
18167 fputc ('\n', stdout
);
18168 free (abiflags_ext
);
18173 /* We have a lot of special sections. Thanks SGI! */
18174 if (filedata
->dynamic_section
== NULL
)
18176 /* No dynamic information available. See if there is static GOT. */
18177 sect
= find_section (filedata
, ".got");
18180 unsigned char *data_end
;
18181 unsigned char *data
;
18185 pltgot
= sect
->sh_addr
;
18188 addr_size
= (is_32bit_elf
? 4 : 8);
18189 end
= pltgot
+ sect
->sh_size
;
18191 data
= (unsigned char *) get_data (NULL
, filedata
, sect
->sh_offset
,
18193 _("Global Offset Table data"));
18194 /* PR 12855: Null data is handled gracefully throughout. */
18195 data_end
= data
+ (end
- pltgot
);
18197 printf (_("\nStatic GOT:\n"));
18198 printf (_(" Canonical gp value: "));
18199 print_vma (ent
+ 0x7ff0, LONG_HEX
);
18202 /* In a dynamic binary GOT[0] is reserved for the dynamic
18203 loader to store the lazy resolver pointer, however in
18204 a static binary it may well have been omitted and GOT
18205 reduced to a table of addresses.
18206 PR 21344: Check for the entry being fully available
18207 before fetching it. */
18209 && data
+ ent
- pltgot
+ addr_size
<= data_end
18210 && byte_get (data
+ ent
- pltgot
, addr_size
) == 0)
18212 printf (_(" Reserved entries:\n"));
18213 printf (_(" %*s %10s %*s\n"),
18214 addr_size
* 2, _("Address"), _("Access"),
18215 addr_size
* 2, _("Value"));
18216 ent
= print_mips_got_entry (data
, pltgot
, ent
, data_end
);
18218 if (ent
== (bfd_vma
) -1)
18219 goto sgot_print_fail
;
18221 /* Check for the MSB of GOT[1] being set, identifying a
18222 GNU object. This entry will be used by some runtime
18223 loaders, to store the module pointer. Otherwise this
18224 is an ordinary local entry.
18225 PR 21344: Check for the entry being fully available
18226 before fetching it. */
18228 && data
+ ent
- pltgot
+ addr_size
<= data_end
18229 && (byte_get (data
+ ent
- pltgot
, addr_size
)
18230 >> (addr_size
* 8 - 1)) != 0)
18232 ent
= print_mips_got_entry (data
, pltgot
, ent
, data_end
);
18234 if (ent
== (bfd_vma
) -1)
18235 goto sgot_print_fail
;
18240 if (data
!= NULL
&& ent
< end
)
18242 printf (_(" Local entries:\n"));
18243 printf (" %*s %10s %*s\n",
18244 addr_size
* 2, _("Address"), _("Access"),
18245 addr_size
* 2, _("Value"));
18248 ent
= print_mips_got_entry (data
, pltgot
, ent
, data_end
);
18250 if (ent
== (bfd_vma
) -1)
18251 goto sgot_print_fail
;
18262 for (entry
= filedata
->dynamic_section
;
18263 /* PR 17531 file: 012-50589-0.004. */
18264 (entry
< filedata
->dynamic_section
+ filedata
->dynamic_nent
18265 && entry
->d_tag
!= DT_NULL
);
18267 switch (entry
->d_tag
)
18269 case DT_MIPS_LIBLIST
:
18271 = offset_from_vma (filedata
, entry
->d_un
.d_val
,
18272 liblistno
* sizeof (Elf32_External_Lib
));
18274 case DT_MIPS_LIBLISTNO
:
18275 liblistno
= entry
->d_un
.d_val
;
18277 case DT_MIPS_OPTIONS
:
18278 options_offset
= offset_from_vma (filedata
, entry
->d_un
.d_val
, 0);
18280 case DT_MIPS_CONFLICT
:
18282 = offset_from_vma (filedata
, entry
->d_un
.d_val
,
18283 conflictsno
* sizeof (Elf32_External_Conflict
));
18285 case DT_MIPS_CONFLICTNO
:
18286 conflictsno
= entry
->d_un
.d_val
;
18289 pltgot
= entry
->d_un
.d_ptr
;
18291 case DT_MIPS_LOCAL_GOTNO
:
18292 local_gotno
= entry
->d_un
.d_val
;
18294 case DT_MIPS_GOTSYM
:
18295 gotsym
= entry
->d_un
.d_val
;
18297 case DT_MIPS_SYMTABNO
:
18298 symtabno
= entry
->d_un
.d_val
;
18300 case DT_MIPS_PLTGOT
:
18301 mips_pltgot
= entry
->d_un
.d_ptr
;
18304 pltrel
= entry
->d_un
.d_val
;
18307 pltrelsz
= entry
->d_un
.d_val
;
18310 jmprel
= entry
->d_un
.d_ptr
;
18316 if (liblist_offset
!= 0 && liblistno
!= 0 && do_dynamic
)
18318 Elf32_External_Lib
* elib
;
18321 elib
= (Elf32_External_Lib
*) get_data (NULL
, filedata
, liblist_offset
,
18322 sizeof (Elf32_External_Lib
),
18324 _("liblist section data"));
18327 printf (ngettext ("\nSection '.liblist' contains %lu entry:\n",
18328 "\nSection '.liblist' contains %lu entries:\n",
18329 (unsigned long) liblistno
),
18330 (unsigned long) liblistno
);
18331 fputs (_(" Library Time Stamp Checksum Version Flags\n"),
18334 for (cnt
= 0; cnt
< liblistno
; ++cnt
)
18341 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
18342 atime
= BYTE_GET (elib
[cnt
].l_time_stamp
);
18343 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
18344 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
18345 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
18347 tmp
= gmtime (&atime
);
18348 snprintf (timebuf
, sizeof (timebuf
),
18349 "%04u-%02u-%02uT%02u:%02u:%02u",
18350 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
18351 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
18353 printf ("%3lu: ", (unsigned long) cnt
);
18354 if (valid_dynamic_name (filedata
, liblist
.l_name
))
18355 print_symbol (20, get_dynamic_name (filedata
, liblist
.l_name
));
18357 printf (_("<corrupt: %9ld>"), liblist
.l_name
);
18358 printf (" %s %#10lx %-7ld", timebuf
, liblist
.l_checksum
,
18359 liblist
.l_version
);
18361 if (liblist
.l_flags
== 0)
18365 static const struct
18372 { " EXACT_MATCH", LL_EXACT_MATCH
},
18373 { " IGNORE_INT_VER", LL_IGNORE_INT_VER
},
18374 { " REQUIRE_MINOR", LL_REQUIRE_MINOR
},
18375 { " EXPORTS", LL_EXPORTS
},
18376 { " DELAY_LOAD", LL_DELAY_LOAD
},
18377 { " DELTA", LL_DELTA
}
18379 int flags
= liblist
.l_flags
;
18382 for (fcnt
= 0; fcnt
< ARRAY_SIZE (l_flags_vals
); ++fcnt
)
18383 if ((flags
& l_flags_vals
[fcnt
].bit
) != 0)
18385 fputs (l_flags_vals
[fcnt
].name
, stdout
);
18386 flags
^= l_flags_vals
[fcnt
].bit
;
18389 printf (" %#x", (unsigned int) flags
);
18401 if (options_offset
!= 0)
18403 Elf_External_Options
* eopt
;
18407 /* Find the section header so that we get the size. */
18408 sect
= find_section_by_type (filedata
, SHT_MIPS_OPTIONS
);
18409 /* PR 17533 file: 012-277276-0.004. */
18412 error (_("No MIPS_OPTIONS header found\n"));
18416 if (sect
->sh_size
< sizeof (* eopt
))
18418 error (_("The MIPS options section is too small.\n"));
18422 eopt
= (Elf_External_Options
*) get_data (NULL
, filedata
, options_offset
, 1,
18423 sect
->sh_size
, _("options"));
18426 Elf_Internal_Options option
;
18429 while (offset
<= sect
->sh_size
- sizeof (* eopt
))
18431 Elf_External_Options
* eoption
;
18432 unsigned int optsize
;
18434 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
18436 optsize
= BYTE_GET (eoption
->size
);
18438 /* PR 17531: file: ffa0fa3b. */
18439 if (optsize
< sizeof (* eopt
)
18440 || optsize
> sect
->sh_size
- offset
)
18442 error (_("Invalid size (%u) for MIPS option\n"),
18451 printf (ngettext ("\nSection '%s' contains %d entry:\n",
18452 "\nSection '%s' contains %d entries:\n",
18454 printable_section_name (filedata
, sect
), cnt
);
18460 Elf_External_Options
* eoption
;
18462 eoption
= (Elf_External_Options
*) ((char *) eopt
+ offset
);
18464 option
.kind
= BYTE_GET (eoption
->kind
);
18465 option
.size
= BYTE_GET (eoption
->size
);
18466 option
.section
= BYTE_GET (eoption
->section
);
18467 option
.info
= BYTE_GET (eoption
->info
);
18469 switch (option
.kind
)
18472 /* This shouldn't happen. */
18473 printf (" NULL %" PRId16
" %" PRIx32
,
18474 option
.section
, option
.info
);
18478 printf (" REGINFO ");
18479 if (filedata
->file_header
.e_machine
== EM_MIPS
)
18481 Elf32_External_RegInfo
* ereg
;
18482 Elf32_RegInfo reginfo
;
18485 if (option
.size
< (sizeof (Elf_External_Options
)
18486 + sizeof (Elf32_External_RegInfo
)))
18488 printf (_("<corrupt>\n"));
18489 error (_("Truncated MIPS REGINFO option\n"));
18494 ereg
= (Elf32_External_RegInfo
*) (eoption
+ 1);
18496 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
18497 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
18498 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
18499 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
18500 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
18501 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
18503 printf ("GPR %08" PRIx32
" GP 0x%" PRIx32
"\n",
18504 reginfo
.ri_gprmask
, reginfo
.ri_gp_value
);
18506 " CPR0 %08" PRIx32
" CPR1 %08" PRIx32
18507 " CPR2 %08" PRIx32
" CPR3 %08" PRIx32
"\n",
18508 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
18509 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
18514 Elf64_External_RegInfo
* ereg
;
18515 Elf64_Internal_RegInfo reginfo
;
18517 if (option
.size
< (sizeof (Elf_External_Options
)
18518 + sizeof (Elf64_External_RegInfo
)))
18520 printf (_("<corrupt>\n"));
18521 error (_("Truncated MIPS REGINFO option\n"));
18526 ereg
= (Elf64_External_RegInfo
*) (eoption
+ 1);
18527 reginfo
.ri_gprmask
= BYTE_GET (ereg
->ri_gprmask
);
18528 reginfo
.ri_cprmask
[0] = BYTE_GET (ereg
->ri_cprmask
[0]);
18529 reginfo
.ri_cprmask
[1] = BYTE_GET (ereg
->ri_cprmask
[1]);
18530 reginfo
.ri_cprmask
[2] = BYTE_GET (ereg
->ri_cprmask
[2]);
18531 reginfo
.ri_cprmask
[3] = BYTE_GET (ereg
->ri_cprmask
[3]);
18532 reginfo
.ri_gp_value
= BYTE_GET (ereg
->ri_gp_value
);
18534 printf ("GPR %08" PRIx32
" GP 0x%" PRIx64
"\n",
18535 reginfo
.ri_gprmask
, reginfo
.ri_gp_value
);
18537 " CPR0 %08" PRIx32
" CPR1 %08" PRIx32
18538 " CPR2 %08" PRIx32
" CPR3 %08" PRIx32
"\n",
18539 reginfo
.ri_cprmask
[0], reginfo
.ri_cprmask
[1],
18540 reginfo
.ri_cprmask
[2], reginfo
.ri_cprmask
[3]);
18542 offset
+= option
.size
;
18545 case ODK_EXCEPTIONS
:
18546 fputs (" EXCEPTIONS fpe_min(", stdout
);
18547 process_mips_fpe_exception (option
.info
& OEX_FPU_MIN
);
18548 fputs (") fpe_max(", stdout
);
18549 process_mips_fpe_exception ((option
.info
& OEX_FPU_MAX
) >> 8);
18550 fputs (")", stdout
);
18552 if (option
.info
& OEX_PAGE0
)
18553 fputs (" PAGE0", stdout
);
18554 if (option
.info
& OEX_SMM
)
18555 fputs (" SMM", stdout
);
18556 if (option
.info
& OEX_FPDBUG
)
18557 fputs (" FPDBUG", stdout
);
18558 if (option
.info
& OEX_DISMISS
)
18559 fputs (" DISMISS", stdout
);
18563 fputs (" PAD ", stdout
);
18564 if (option
.info
& OPAD_PREFIX
)
18565 fputs (" PREFIX", stdout
);
18566 if (option
.info
& OPAD_POSTFIX
)
18567 fputs (" POSTFIX", stdout
);
18568 if (option
.info
& OPAD_SYMBOL
)
18569 fputs (" SYMBOL", stdout
);
18573 fputs (" HWPATCH ", stdout
);
18574 if (option
.info
& OHW_R4KEOP
)
18575 fputs (" R4KEOP", stdout
);
18576 if (option
.info
& OHW_R8KPFETCH
)
18577 fputs (" R8KPFETCH", stdout
);
18578 if (option
.info
& OHW_R5KEOP
)
18579 fputs (" R5KEOP", stdout
);
18580 if (option
.info
& OHW_R5KCVTL
)
18581 fputs (" R5KCVTL", stdout
);
18585 fputs (" FILL ", stdout
);
18586 /* XXX Print content of info word? */
18590 fputs (" TAGS ", stdout
);
18591 /* XXX Print content of info word? */
18595 fputs (" HWAND ", stdout
);
18596 if (option
.info
& OHWA0_R4KEOP_CHECKED
)
18597 fputs (" R4KEOP_CHECKED", stdout
);
18598 if (option
.info
& OHWA0_R4KEOP_CLEAN
)
18599 fputs (" R4KEOP_CLEAN", stdout
);
18603 fputs (" HWOR ", stdout
);
18604 if (option
.info
& OHWA0_R4KEOP_CHECKED
)
18605 fputs (" R4KEOP_CHECKED", stdout
);
18606 if (option
.info
& OHWA0_R4KEOP_CLEAN
)
18607 fputs (" R4KEOP_CLEAN", stdout
);
18611 printf (" GP_GROUP %#06x self-contained %#06x",
18612 option
.info
& OGP_GROUP
,
18613 (option
.info
& OGP_SELF
) >> 16);
18617 printf (" IDENT %#06x self-contained %#06x",
18618 option
.info
& OGP_GROUP
,
18619 (option
.info
& OGP_SELF
) >> 16);
18623 /* This shouldn't happen. */
18624 printf (" %3d ??? %" PRId16
" %" PRIx32
,
18625 option
.kind
, option
.section
, option
.info
);
18629 len
= sizeof (* eopt
);
18630 while (len
< option
.size
)
18632 unsigned char datum
= *((unsigned char *) eoption
+ len
);
18634 if (ISPRINT (datum
))
18635 printf ("%c", datum
);
18637 printf ("\\%03o", datum
);
18640 fputs ("\n", stdout
);
18642 offset
+= option
.size
;
18650 if (conflicts_offset
!= 0 && conflictsno
!= 0)
18652 Elf32_Conflict
* iconf
;
18655 if (filedata
->dynamic_symbols
== NULL
)
18657 error (_("conflict list found without a dynamic symbol table\n"));
18661 /* PR 21345 - print a slightly more helpful error message
18662 if we are sure that the cmalloc will fail. */
18663 if (conflictsno
> filedata
->file_size
/ sizeof (* iconf
))
18665 error (_("Overlarge number of conflicts detected: %lx\n"),
18666 (long) conflictsno
);
18670 iconf
= (Elf32_Conflict
*) cmalloc (conflictsno
, sizeof (* iconf
));
18673 error (_("Out of memory allocating space for dynamic conflicts\n"));
18679 Elf32_External_Conflict
* econf32
;
18681 econf32
= (Elf32_External_Conflict
*)
18682 get_data (NULL
, filedata
, conflicts_offset
,
18683 sizeof (*econf32
), conflictsno
, _("conflict"));
18690 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
18691 iconf
[cnt
] = BYTE_GET (econf32
[cnt
]);
18697 Elf64_External_Conflict
* econf64
;
18699 econf64
= (Elf64_External_Conflict
*)
18700 get_data (NULL
, filedata
, conflicts_offset
,
18701 sizeof (*econf64
), conflictsno
, _("conflict"));
18708 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
18709 iconf
[cnt
] = BYTE_GET (econf64
[cnt
]);
18714 printf (ngettext ("\nSection '.conflict' contains %lu entry:\n",
18715 "\nSection '.conflict' contains %lu entries:\n",
18716 (unsigned long) conflictsno
),
18717 (unsigned long) conflictsno
);
18718 puts (_(" Num: Index Value Name"));
18720 for (cnt
= 0; cnt
< conflictsno
; ++cnt
)
18722 printf ("%5lu: %8lu ", (unsigned long) cnt
, iconf
[cnt
]);
18724 if (iconf
[cnt
] >= filedata
->num_dynamic_syms
)
18725 printf (_("<corrupt symbol index>"));
18728 Elf_Internal_Sym
* psym
;
18730 psym
= & filedata
->dynamic_symbols
[iconf
[cnt
]];
18731 print_vma (psym
->st_value
, FULL_HEX
);
18733 if (valid_dynamic_name (filedata
, psym
->st_name
))
18734 print_symbol (25, get_dynamic_name (filedata
, psym
->st_name
));
18736 printf (_("<corrupt: %14ld>"), psym
->st_name
);
18744 if (pltgot
!= 0 && local_gotno
!= 0)
18746 bfd_vma ent
, local_end
, global_end
;
18748 unsigned char * data
;
18749 unsigned char * data_end
;
18753 addr_size
= (is_32bit_elf
? 4 : 8);
18754 local_end
= pltgot
+ local_gotno
* addr_size
;
18756 /* PR binutils/17533 file: 012-111227-0.004 */
18757 if (symtabno
< gotsym
)
18759 error (_("The GOT symbol offset (%lu) is greater than the symbol table size (%lu)\n"),
18760 (unsigned long) gotsym
, (unsigned long) symtabno
);
18764 global_end
= local_end
+ (symtabno
- gotsym
) * addr_size
;
18765 /* PR 17531: file: 54c91a34. */
18766 if (global_end
< local_end
)
18768 error (_("Too many GOT symbols: %lu\n"), (unsigned long) symtabno
);
18772 offset
= offset_from_vma (filedata
, pltgot
, global_end
- pltgot
);
18773 data
= (unsigned char *) get_data (NULL
, filedata
, offset
,
18774 global_end
- pltgot
, 1,
18775 _("Global Offset Table data"));
18776 /* PR 12855: Null data is handled gracefully throughout. */
18777 data_end
= data
+ (global_end
- pltgot
);
18779 printf (_("\nPrimary GOT:\n"));
18780 printf (_(" Canonical gp value: "));
18781 print_vma (pltgot
+ 0x7ff0, LONG_HEX
);
18784 printf (_(" Reserved entries:\n"));
18785 printf (_(" %*s %10s %*s Purpose\n"),
18786 addr_size
* 2, _("Address"), _("Access"),
18787 addr_size
* 2, _("Initial"));
18788 ent
= print_mips_got_entry (data
, pltgot
, ent
, data_end
);
18789 printf (_(" Lazy resolver\n"));
18790 if (ent
== (bfd_vma
) -1)
18791 goto got_print_fail
;
18793 /* Check for the MSB of GOT[1] being set, denoting a GNU object.
18794 This entry will be used by some runtime loaders, to store the
18795 module pointer. Otherwise this is an ordinary local entry.
18796 PR 21344: Check for the entry being fully available before
18799 && data
+ ent
- pltgot
+ addr_size
<= data_end
18800 && (byte_get (data
+ ent
- pltgot
, addr_size
)
18801 >> (addr_size
* 8 - 1)) != 0)
18803 ent
= print_mips_got_entry (data
, pltgot
, ent
, data_end
);
18804 printf (_(" Module pointer (GNU extension)\n"));
18805 if (ent
== (bfd_vma
) -1)
18806 goto got_print_fail
;
18810 if (data
!= NULL
&& ent
< local_end
)
18812 printf (_(" Local entries:\n"));
18813 printf (" %*s %10s %*s\n",
18814 addr_size
* 2, _("Address"), _("Access"),
18815 addr_size
* 2, _("Initial"));
18816 while (ent
< local_end
)
18818 ent
= print_mips_got_entry (data
, pltgot
, ent
, data_end
);
18820 if (ent
== (bfd_vma
) -1)
18821 goto got_print_fail
;
18826 if (data
!= NULL
&& gotsym
< symtabno
)
18830 printf (_(" Global entries:\n"));
18831 printf (" %*s %10s %*s %*s %-7s %3s %s\n",
18832 addr_size
* 2, _("Address"),
18834 addr_size
* 2, _("Initial"),
18835 addr_size
* 2, _("Sym.Val."),
18837 /* Note for translators: "Ndx" = abbreviated form of "Index". */
18838 _("Ndx"), _("Name"));
18840 sym_width
= (is_32bit_elf
? 80 : 160) - 28 - addr_size
* 6 - 1;
18842 for (i
= gotsym
; i
< symtabno
; i
++)
18844 ent
= print_mips_got_entry (data
, pltgot
, ent
, data_end
);
18847 if (filedata
->dynamic_symbols
== NULL
)
18848 printf (_("<no dynamic symbols>"));
18849 else if (i
< filedata
->num_dynamic_syms
)
18851 Elf_Internal_Sym
* psym
= filedata
->dynamic_symbols
+ i
;
18853 print_vma (psym
->st_value
, LONG_HEX
);
18854 printf (" %-7s %3s ",
18855 get_symbol_type (filedata
, ELF_ST_TYPE (psym
->st_info
)),
18856 get_symbol_index_type (filedata
, psym
->st_shndx
));
18858 if (valid_dynamic_name (filedata
, psym
->st_name
))
18859 print_symbol (sym_width
,
18860 get_dynamic_name (filedata
, psym
->st_name
));
18862 printf (_("<corrupt: %14ld>"), psym
->st_name
);
18865 printf (_("<symbol index %lu exceeds number of dynamic symbols>"),
18866 (unsigned long) i
);
18869 if (ent
== (bfd_vma
) -1)
18879 if (mips_pltgot
!= 0 && jmprel
!= 0 && pltrel
!= 0 && pltrelsz
!= 0)
18882 size_t offset
, rel_offset
;
18883 unsigned long count
, i
;
18884 unsigned char * data
;
18885 int addr_size
, sym_width
;
18886 Elf_Internal_Rela
* rels
;
18888 rel_offset
= offset_from_vma (filedata
, jmprel
, pltrelsz
);
18889 if (pltrel
== DT_RELA
)
18891 if (!slurp_rela_relocs (filedata
, rel_offset
, pltrelsz
, &rels
, &count
))
18896 if (!slurp_rel_relocs (filedata
, rel_offset
, pltrelsz
, &rels
, &count
))
18901 addr_size
= (is_32bit_elf
? 4 : 8);
18902 end
= mips_pltgot
+ (2 + count
) * addr_size
;
18904 offset
= offset_from_vma (filedata
, mips_pltgot
, end
- mips_pltgot
);
18905 data
= (unsigned char *) get_data (NULL
, filedata
, offset
, end
- mips_pltgot
,
18906 1, _("Procedure Linkage Table data"));
18913 printf ("\nPLT GOT:\n\n");
18914 printf (_(" Reserved entries:\n"));
18915 printf (_(" %*s %*s Purpose\n"),
18916 addr_size
* 2, _("Address"), addr_size
* 2, _("Initial"));
18917 ent
= print_mips_pltgot_entry (data
, mips_pltgot
, ent
);
18918 printf (_(" PLT lazy resolver\n"));
18919 ent
= print_mips_pltgot_entry (data
, mips_pltgot
, ent
);
18920 printf (_(" Module pointer\n"));
18923 printf (_(" Entries:\n"));
18924 printf (" %*s %*s %*s %-7s %3s %s\n",
18925 addr_size
* 2, _("Address"),
18926 addr_size
* 2, _("Initial"),
18927 addr_size
* 2, _("Sym.Val."), _("Type"), _("Ndx"), _("Name"));
18928 sym_width
= (is_32bit_elf
? 80 : 160) - 17 - addr_size
* 6 - 1;
18929 for (i
= 0; i
< count
; i
++)
18931 unsigned long idx
= get_reloc_symindex (rels
[i
].r_info
);
18933 ent
= print_mips_pltgot_entry (data
, mips_pltgot
, ent
);
18936 if (idx
>= filedata
->num_dynamic_syms
)
18937 printf (_("<corrupt symbol index: %lu>"), idx
);
18940 Elf_Internal_Sym
* psym
= filedata
->dynamic_symbols
+ idx
;
18942 print_vma (psym
->st_value
, LONG_HEX
);
18943 printf (" %-7s %3s ",
18944 get_symbol_type (filedata
, ELF_ST_TYPE (psym
->st_info
)),
18945 get_symbol_index_type (filedata
, psym
->st_shndx
));
18946 if (valid_dynamic_name (filedata
, psym
->st_name
))
18947 print_symbol (sym_width
,
18948 get_dynamic_name (filedata
, psym
->st_name
));
18950 printf (_("<corrupt: %14ld>"), psym
->st_name
);
18964 process_nds32_specific (Filedata
* filedata
)
18966 Elf_Internal_Shdr
*sect
= NULL
;
18968 sect
= find_section (filedata
, ".nds32_e_flags");
18969 if (sect
!= NULL
&& sect
->sh_size
>= 4)
18971 unsigned char *buf
;
18974 printf ("\nNDS32 elf flags section:\n");
18975 buf
= get_data (NULL
, filedata
, sect
->sh_offset
, 1, 4,
18976 _("NDS32 elf flags section"));
18981 flag
= byte_get (buf
, 4);
18983 switch (flag
& 0x3)
18986 printf ("(VEC_SIZE):\tNo entry.\n");
18989 printf ("(VEC_SIZE):\t4 bytes\n");
18992 printf ("(VEC_SIZE):\t16 bytes\n");
18995 printf ("(VEC_SIZE):\treserved\n");
19004 process_gnu_liblist (Filedata
* filedata
)
19006 Elf_Internal_Shdr
* section
;
19007 Elf_Internal_Shdr
* string_sec
;
19008 Elf32_External_Lib
* elib
;
19010 size_t strtab_size
;
19012 unsigned long num_liblist
;
19019 for (i
= 0, section
= filedata
->section_headers
;
19020 i
< filedata
->file_header
.e_shnum
;
19023 switch (section
->sh_type
)
19025 case SHT_GNU_LIBLIST
:
19026 if (section
->sh_link
>= filedata
->file_header
.e_shnum
)
19029 elib
= (Elf32_External_Lib
*)
19030 get_data (NULL
, filedata
, section
->sh_offset
, 1, section
->sh_size
,
19031 _("liblist section data"));
19039 string_sec
= filedata
->section_headers
+ section
->sh_link
;
19040 strtab
= (char *) get_data (NULL
, filedata
, string_sec
->sh_offset
, 1,
19041 string_sec
->sh_size
,
19042 _("liblist string table"));
19044 || section
->sh_entsize
!= sizeof (Elf32_External_Lib
))
19051 strtab_size
= string_sec
->sh_size
;
19053 num_liblist
= section
->sh_size
/ sizeof (Elf32_External_Lib
);
19054 printf (ngettext ("\nLibrary list section '%s' contains %lu entries:\n",
19055 "\nLibrary list section '%s' contains %lu entries:\n",
19057 printable_section_name (filedata
, section
),
19060 puts (_(" Library Time Stamp Checksum Version Flags"));
19062 for (cnt
= 0; cnt
< section
->sh_size
/ sizeof (Elf32_External_Lib
);
19070 liblist
.l_name
= BYTE_GET (elib
[cnt
].l_name
);
19071 atime
= BYTE_GET (elib
[cnt
].l_time_stamp
);
19072 liblist
.l_checksum
= BYTE_GET (elib
[cnt
].l_checksum
);
19073 liblist
.l_version
= BYTE_GET (elib
[cnt
].l_version
);
19074 liblist
.l_flags
= BYTE_GET (elib
[cnt
].l_flags
);
19076 tmp
= gmtime (&atime
);
19077 snprintf (timebuf
, sizeof (timebuf
),
19078 "%04u-%02u-%02uT%02u:%02u:%02u",
19079 tmp
->tm_year
+ 1900, tmp
->tm_mon
+ 1, tmp
->tm_mday
,
19080 tmp
->tm_hour
, tmp
->tm_min
, tmp
->tm_sec
);
19082 printf ("%3lu: ", (unsigned long) cnt
);
19084 printf ("%-20s", liblist
.l_name
< strtab_size
19085 ? strtab
+ liblist
.l_name
: _("<corrupt>"));
19087 printf ("%-20.20s", liblist
.l_name
< strtab_size
19088 ? strtab
+ liblist
.l_name
: _("<corrupt>"));
19089 printf (" %s %#010lx %-7ld %-7ld\n", timebuf
, liblist
.l_checksum
,
19090 liblist
.l_version
, liblist
.l_flags
);
19101 static const char *
19102 get_note_type (Filedata
* filedata
, unsigned e_type
)
19104 static char buff
[64];
19106 if (filedata
->file_header
.e_type
== ET_CORE
)
19110 return _("NT_AUXV (auxiliary vector)");
19112 return _("NT_PRSTATUS (prstatus structure)");
19114 return _("NT_FPREGSET (floating point registers)");
19116 return _("NT_PRPSINFO (prpsinfo structure)");
19117 case NT_TASKSTRUCT
:
19118 return _("NT_TASKSTRUCT (task structure)");
19120 return _("NT_GDB_TDESC (GDB XML target description)");
19122 return _("NT_PRXFPREG (user_xfpregs structure)");
19124 return _("NT_PPC_VMX (ppc Altivec registers)");
19126 return _("NT_PPC_VSX (ppc VSX registers)");
19128 return _("NT_PPC_TAR (ppc TAR register)");
19130 return _("NT_PPC_PPR (ppc PPR register)");
19132 return _("NT_PPC_DSCR (ppc DSCR register)");
19134 return _("NT_PPC_EBB (ppc EBB registers)");
19136 return _("NT_PPC_PMU (ppc PMU registers)");
19137 case NT_PPC_TM_CGPR
:
19138 return _("NT_PPC_TM_CGPR (ppc checkpointed GPR registers)");
19139 case NT_PPC_TM_CFPR
:
19140 return _("NT_PPC_TM_CFPR (ppc checkpointed floating point registers)");
19141 case NT_PPC_TM_CVMX
:
19142 return _("NT_PPC_TM_CVMX (ppc checkpointed Altivec registers)");
19143 case NT_PPC_TM_CVSX
:
19144 return _("NT_PPC_TM_CVSX (ppc checkpointed VSX registers)");
19145 case NT_PPC_TM_SPR
:
19146 return _("NT_PPC_TM_SPR (ppc TM special purpose registers)");
19147 case NT_PPC_TM_CTAR
:
19148 return _("NT_PPC_TM_CTAR (ppc checkpointed TAR register)");
19149 case NT_PPC_TM_CPPR
:
19150 return _("NT_PPC_TM_CPPR (ppc checkpointed PPR register)");
19151 case NT_PPC_TM_CDSCR
:
19152 return _("NT_PPC_TM_CDSCR (ppc checkpointed DSCR register)");
19154 return _("NT_386_TLS (x86 TLS information)");
19155 case NT_386_IOPERM
:
19156 return _("NT_386_IOPERM (x86 I/O permissions)");
19157 case NT_X86_XSTATE
:
19158 return _("NT_X86_XSTATE (x86 XSAVE extended state)");
19160 return _("NT_X86_CET (x86 CET state)");
19161 case NT_S390_HIGH_GPRS
:
19162 return _("NT_S390_HIGH_GPRS (s390 upper register halves)");
19163 case NT_S390_TIMER
:
19164 return _("NT_S390_TIMER (s390 timer register)");
19165 case NT_S390_TODCMP
:
19166 return _("NT_S390_TODCMP (s390 TOD comparator register)");
19167 case NT_S390_TODPREG
:
19168 return _("NT_S390_TODPREG (s390 TOD programmable register)");
19170 return _("NT_S390_CTRS (s390 control registers)");
19171 case NT_S390_PREFIX
:
19172 return _("NT_S390_PREFIX (s390 prefix register)");
19173 case NT_S390_LAST_BREAK
:
19174 return _("NT_S390_LAST_BREAK (s390 last breaking event address)");
19175 case NT_S390_SYSTEM_CALL
:
19176 return _("NT_S390_SYSTEM_CALL (s390 system call restart data)");
19178 return _("NT_S390_TDB (s390 transaction diagnostic block)");
19179 case NT_S390_VXRS_LOW
:
19180 return _("NT_S390_VXRS_LOW (s390 vector registers 0-15 upper half)");
19181 case NT_S390_VXRS_HIGH
:
19182 return _("NT_S390_VXRS_HIGH (s390 vector registers 16-31)");
19183 case NT_S390_GS_CB
:
19184 return _("NT_S390_GS_CB (s390 guarded-storage registers)");
19185 case NT_S390_GS_BC
:
19186 return _("NT_S390_GS_BC (s390 guarded-storage broadcast control)");
19188 return _("NT_ARM_VFP (arm VFP registers)");
19190 return _("NT_ARM_TLS (AArch TLS registers)");
19191 case NT_ARM_HW_BREAK
:
19192 return _("NT_ARM_HW_BREAK (AArch hardware breakpoint registers)");
19193 case NT_ARM_HW_WATCH
:
19194 return _("NT_ARM_HW_WATCH (AArch hardware watchpoint registers)");
19196 return _("NT_ARM_SVE (AArch SVE registers)");
19197 case NT_ARM_PAC_MASK
:
19198 return _("NT_ARM_PAC_MASK (AArch pointer authentication code masks)");
19199 case NT_ARM_PACA_KEYS
:
19200 return _("NT_ARM_PACA_KEYS (ARM pointer authentication address keys)");
19201 case NT_ARM_PACG_KEYS
:
19202 return _("NT_ARM_PACG_KEYS (ARM pointer authentication generic keys)");
19203 case NT_ARM_TAGGED_ADDR_CTRL
:
19204 return _("NT_ARM_TAGGED_ADDR_CTRL (AArch tagged address control)");
19205 case NT_ARM_PAC_ENABLED_KEYS
:
19206 return _("NT_ARM_PAC_ENABLED_KEYS (AArch64 pointer authentication enabled keys)");
19208 return _("NT_ARC_V2 (ARC HS accumulator/extra registers)");
19210 return _("NT_RISCV_CSR (RISC-V control and status registers)");
19212 return _("NT_PSTATUS (pstatus structure)");
19214 return _("NT_FPREGS (floating point registers)");
19216 return _("NT_PSINFO (psinfo structure)");
19218 return _("NT_LWPSTATUS (lwpstatus_t structure)");
19220 return _("NT_LWPSINFO (lwpsinfo_t structure)");
19221 case NT_WIN32PSTATUS
:
19222 return _("NT_WIN32PSTATUS (win32_pstatus structure)");
19224 return _("NT_SIGINFO (siginfo_t data)");
19226 return _("NT_FILE (mapped files)");
19234 return _("NT_VERSION (version)");
19236 return _("NT_ARCH (architecture)");
19237 case NT_GNU_BUILD_ATTRIBUTE_OPEN
:
19239 case NT_GNU_BUILD_ATTRIBUTE_FUNC
:
19241 case NT_GO_BUILDID
:
19242 return _("GO BUILDID");
19243 case FDO_PACKAGING_METADATA
:
19244 return _("FDO_PACKAGING_METADATA");
19249 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
19254 print_core_note (Elf_Internal_Note
*pnote
)
19256 unsigned int addr_size
= is_32bit_elf
? 4 : 8;
19257 bfd_vma count
, page_size
;
19258 unsigned char *descdata
, *filenames
, *descend
;
19260 if (pnote
->type
!= NT_FILE
)
19270 printf (_(" Cannot decode 64-bit note in 32-bit build\n"));
19271 /* Still "successful". */
19276 if (pnote
->descsz
< 2 * addr_size
)
19278 error (_(" Malformed note - too short for header\n"));
19282 descdata
= (unsigned char *) pnote
->descdata
;
19283 descend
= descdata
+ pnote
->descsz
;
19285 if (descdata
[pnote
->descsz
- 1] != '\0')
19287 error (_(" Malformed note - does not end with \\0\n"));
19291 count
= byte_get (descdata
, addr_size
);
19292 descdata
+= addr_size
;
19294 page_size
= byte_get (descdata
, addr_size
);
19295 descdata
+= addr_size
;
19297 if (count
> ((bfd_vma
) -1 - 2 * addr_size
) / (3 * addr_size
)
19298 || pnote
->descsz
< 2 * addr_size
+ count
* 3 * addr_size
)
19300 error (_(" Malformed note - too short for supplied file count\n"));
19304 printf (_(" Page size: "));
19305 print_vma (page_size
, DEC
);
19308 printf (_(" %*s%*s%*s\n"),
19309 (int) (2 + 2 * addr_size
), _("Start"),
19310 (int) (4 + 2 * addr_size
), _("End"),
19311 (int) (4 + 2 * addr_size
), _("Page Offset"));
19312 filenames
= descdata
+ count
* 3 * addr_size
;
19313 while (count
-- > 0)
19315 bfd_vma start
, end
, file_ofs
;
19317 if (filenames
== descend
)
19319 error (_(" Malformed note - filenames end too early\n"));
19323 start
= byte_get (descdata
, addr_size
);
19324 descdata
+= addr_size
;
19325 end
= byte_get (descdata
, addr_size
);
19326 descdata
+= addr_size
;
19327 file_ofs
= byte_get (descdata
, addr_size
);
19328 descdata
+= addr_size
;
19331 print_vma (start
, FULL_HEX
);
19333 print_vma (end
, FULL_HEX
);
19335 print_vma (file_ofs
, FULL_HEX
);
19336 printf ("\n %s\n", filenames
);
19338 filenames
+= 1 + strlen ((char *) filenames
);
19344 static const char *
19345 get_gnu_elf_note_type (unsigned e_type
)
19347 /* NB/ Keep this switch statement in sync with print_gnu_note (). */
19350 case NT_GNU_ABI_TAG
:
19351 return _("NT_GNU_ABI_TAG (ABI version tag)");
19353 return _("NT_GNU_HWCAP (DSO-supplied software HWCAP info)");
19354 case NT_GNU_BUILD_ID
:
19355 return _("NT_GNU_BUILD_ID (unique build ID bitstring)");
19356 case NT_GNU_GOLD_VERSION
:
19357 return _("NT_GNU_GOLD_VERSION (gold version)");
19358 case NT_GNU_PROPERTY_TYPE_0
:
19359 return _("NT_GNU_PROPERTY_TYPE_0");
19360 case NT_GNU_BUILD_ATTRIBUTE_OPEN
:
19361 return _("NT_GNU_BUILD_ATTRIBUTE_OPEN");
19362 case NT_GNU_BUILD_ATTRIBUTE_FUNC
:
19363 return _("NT_GNU_BUILD_ATTRIBUTE_FUNC");
19366 static char buff
[64];
19368 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
19375 decode_x86_compat_isa (unsigned int bitmask
)
19379 unsigned int bit
= bitmask
& (- bitmask
);
19384 case GNU_PROPERTY_X86_COMPAT_ISA_1_486
:
19387 case GNU_PROPERTY_X86_COMPAT_ISA_1_586
:
19390 case GNU_PROPERTY_X86_COMPAT_ISA_1_686
:
19393 case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE
:
19396 case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE2
:
19399 case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE3
:
19402 case GNU_PROPERTY_X86_COMPAT_ISA_1_SSSE3
:
19405 case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE4_1
:
19408 case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE4_2
:
19411 case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX
:
19414 case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX2
:
19417 case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512F
:
19418 printf ("AVX512F");
19420 case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512CD
:
19421 printf ("AVX512CD");
19423 case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512ER
:
19424 printf ("AVX512ER");
19426 case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512PF
:
19427 printf ("AVX512PF");
19429 case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512VL
:
19430 printf ("AVX512VL");
19432 case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512DQ
:
19433 printf ("AVX512DQ");
19435 case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512BW
:
19436 printf ("AVX512BW");
19439 printf (_("<unknown: %x>"), bit
);
19448 decode_x86_compat_2_isa (unsigned int bitmask
)
19452 printf (_("<None>"));
19458 unsigned int bit
= bitmask
& (- bitmask
);
19463 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_CMOV
:
19466 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE
:
19469 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE2
:
19472 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE3
:
19475 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSSE3
:
19478 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE4_1
:
19481 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE4_2
:
19484 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX
:
19487 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX2
:
19490 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_FMA
:
19493 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512F
:
19494 printf ("AVX512F");
19496 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512CD
:
19497 printf ("AVX512CD");
19499 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512ER
:
19500 printf ("AVX512ER");
19502 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512PF
:
19503 printf ("AVX512PF");
19505 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512VL
:
19506 printf ("AVX512VL");
19508 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512DQ
:
19509 printf ("AVX512DQ");
19511 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512BW
:
19512 printf ("AVX512BW");
19514 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_4FMAPS
:
19515 printf ("AVX512_4FMAPS");
19517 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_4VNNIW
:
19518 printf ("AVX512_4VNNIW");
19520 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_BITALG
:
19521 printf ("AVX512_BITALG");
19523 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_IFMA
:
19524 printf ("AVX512_IFMA");
19526 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_VBMI
:
19527 printf ("AVX512_VBMI");
19529 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_VBMI2
:
19530 printf ("AVX512_VBMI2");
19532 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_VNNI
:
19533 printf ("AVX512_VNNI");
19535 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_BF16
:
19536 printf ("AVX512_BF16");
19539 printf (_("<unknown: %x>"), bit
);
19548 decode_x86_isa (unsigned int bitmask
)
19552 unsigned int bit
= bitmask
& (- bitmask
);
19557 case GNU_PROPERTY_X86_ISA_1_BASELINE
:
19558 printf ("x86-64-baseline");
19560 case GNU_PROPERTY_X86_ISA_1_V2
:
19561 printf ("x86-64-v2");
19563 case GNU_PROPERTY_X86_ISA_1_V3
:
19564 printf ("x86-64-v3");
19566 case GNU_PROPERTY_X86_ISA_1_V4
:
19567 printf ("x86-64-v4");
19570 printf (_("<unknown: %x>"), bit
);
19579 decode_x86_feature_1 (unsigned int bitmask
)
19583 printf (_("<None>"));
19589 unsigned int bit
= bitmask
& (- bitmask
);
19594 case GNU_PROPERTY_X86_FEATURE_1_IBT
:
19597 case GNU_PROPERTY_X86_FEATURE_1_SHSTK
:
19600 case GNU_PROPERTY_X86_FEATURE_1_LAM_U48
:
19601 printf ("LAM_U48");
19603 case GNU_PROPERTY_X86_FEATURE_1_LAM_U57
:
19604 printf ("LAM_U57");
19607 printf (_("<unknown: %x>"), bit
);
19616 decode_x86_feature_2 (unsigned int bitmask
)
19620 printf (_("<None>"));
19626 unsigned int bit
= bitmask
& (- bitmask
);
19631 case GNU_PROPERTY_X86_FEATURE_2_X86
:
19634 case GNU_PROPERTY_X86_FEATURE_2_X87
:
19637 case GNU_PROPERTY_X86_FEATURE_2_MMX
:
19640 case GNU_PROPERTY_X86_FEATURE_2_XMM
:
19643 case GNU_PROPERTY_X86_FEATURE_2_YMM
:
19646 case GNU_PROPERTY_X86_FEATURE_2_ZMM
:
19649 case GNU_PROPERTY_X86_FEATURE_2_TMM
:
19652 case GNU_PROPERTY_X86_FEATURE_2_MASK
:
19655 case GNU_PROPERTY_X86_FEATURE_2_FXSR
:
19658 case GNU_PROPERTY_X86_FEATURE_2_XSAVE
:
19661 case GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT
:
19662 printf ("XSAVEOPT");
19664 case GNU_PROPERTY_X86_FEATURE_2_XSAVEC
:
19668 printf (_("<unknown: %x>"), bit
);
19677 decode_aarch64_feature_1_and (unsigned int bitmask
)
19681 unsigned int bit
= bitmask
& (- bitmask
);
19686 case GNU_PROPERTY_AARCH64_FEATURE_1_BTI
:
19690 case GNU_PROPERTY_AARCH64_FEATURE_1_PAC
:
19695 printf (_("<unknown: %x>"), bit
);
19704 decode_1_needed (unsigned int bitmask
)
19708 unsigned int bit
= bitmask
& (- bitmask
);
19713 case GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
:
19714 printf ("indirect external access");
19717 printf (_("<unknown: %x>"), bit
);
19726 print_gnu_property_note (Filedata
* filedata
, Elf_Internal_Note
* pnote
)
19728 unsigned char * ptr
= (unsigned char *) pnote
->descdata
;
19729 unsigned char * ptr_end
= ptr
+ pnote
->descsz
;
19730 unsigned int size
= is_32bit_elf
? 4 : 8;
19732 printf (_(" Properties: "));
19734 if (pnote
->descsz
< 8 || (pnote
->descsz
% size
) != 0)
19736 printf (_("<corrupt GNU_PROPERTY_TYPE, size = %#lx>\n"), pnote
->descsz
);
19740 while (ptr
< ptr_end
)
19744 unsigned int datasz
;
19746 if ((size_t) (ptr_end
- ptr
) < 8)
19748 printf (_("<corrupt descsz: %#lx>\n"), pnote
->descsz
);
19752 type
= byte_get (ptr
, 4);
19753 datasz
= byte_get (ptr
+ 4, 4);
19757 if (datasz
> (size_t) (ptr_end
- ptr
))
19759 printf (_("<corrupt type (%#x) datasz: %#x>\n"),
19764 if (type
>= GNU_PROPERTY_LOPROC
&& type
<= GNU_PROPERTY_HIPROC
)
19766 if (filedata
->file_header
.e_machine
== EM_X86_64
19767 || filedata
->file_header
.e_machine
== EM_IAMCU
19768 || filedata
->file_header
.e_machine
== EM_386
)
19770 unsigned int bitmask
;
19773 bitmask
= byte_get (ptr
, 4);
19779 case GNU_PROPERTY_X86_ISA_1_USED
:
19781 printf (_("x86 ISA used: <corrupt length: %#x> "),
19785 printf ("x86 ISA used: ");
19786 decode_x86_isa (bitmask
);
19790 case GNU_PROPERTY_X86_ISA_1_NEEDED
:
19792 printf (_("x86 ISA needed: <corrupt length: %#x> "),
19796 printf ("x86 ISA needed: ");
19797 decode_x86_isa (bitmask
);
19801 case GNU_PROPERTY_X86_FEATURE_1_AND
:
19803 printf (_("x86 feature: <corrupt length: %#x> "),
19807 printf ("x86 feature: ");
19808 decode_x86_feature_1 (bitmask
);
19812 case GNU_PROPERTY_X86_FEATURE_2_USED
:
19814 printf (_("x86 feature used: <corrupt length: %#x> "),
19818 printf ("x86 feature used: ");
19819 decode_x86_feature_2 (bitmask
);
19823 case GNU_PROPERTY_X86_FEATURE_2_NEEDED
:
19825 printf (_("x86 feature needed: <corrupt length: %#x> "), datasz
);
19828 printf ("x86 feature needed: ");
19829 decode_x86_feature_2 (bitmask
);
19833 case GNU_PROPERTY_X86_COMPAT_ISA_1_USED
:
19835 printf (_("x86 ISA used: <corrupt length: %#x> "),
19839 printf ("x86 ISA used: ");
19840 decode_x86_compat_isa (bitmask
);
19844 case GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED
:
19846 printf (_("x86 ISA needed: <corrupt length: %#x> "),
19850 printf ("x86 ISA needed: ");
19851 decode_x86_compat_isa (bitmask
);
19855 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED
:
19857 printf (_("x86 ISA used: <corrupt length: %#x> "),
19861 printf ("x86 ISA used: ");
19862 decode_x86_compat_2_isa (bitmask
);
19866 case GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED
:
19868 printf (_("x86 ISA needed: <corrupt length: %#x> "),
19872 printf ("x86 ISA needed: ");
19873 decode_x86_compat_2_isa (bitmask
);
19881 else if (filedata
->file_header
.e_machine
== EM_AARCH64
)
19883 if (type
== GNU_PROPERTY_AARCH64_FEATURE_1_AND
)
19885 printf ("AArch64 feature: ");
19887 printf (_("<corrupt length: %#x> "), datasz
);
19889 decode_aarch64_feature_1_and (byte_get (ptr
, 4));
19898 case GNU_PROPERTY_STACK_SIZE
:
19899 printf (_("stack size: "));
19900 if (datasz
!= size
)
19901 printf (_("<corrupt length: %#x> "), datasz
);
19903 printf ("%#lx", (unsigned long) byte_get (ptr
, size
));
19906 case GNU_PROPERTY_NO_COPY_ON_PROTECTED
:
19907 printf ("no copy on protected ");
19909 printf (_("<corrupt length: %#x> "), datasz
);
19913 if ((type
>= GNU_PROPERTY_UINT32_AND_LO
19914 && type
<= GNU_PROPERTY_UINT32_AND_HI
)
19915 || (type
>= GNU_PROPERTY_UINT32_OR_LO
19916 && type
<= GNU_PROPERTY_UINT32_OR_HI
))
19920 case GNU_PROPERTY_1_NEEDED
:
19922 printf (_("1_needed: <corrupt length: %#x> "),
19926 unsigned int bitmask
= byte_get (ptr
, 4);
19927 printf ("1_needed: ");
19928 decode_1_needed (bitmask
);
19935 if (type
<= GNU_PROPERTY_UINT32_AND_HI
)
19936 printf (_("UINT32_AND (%#x): "), type
);
19938 printf (_("UINT32_OR (%#x): "), type
);
19940 printf (_("<corrupt length: %#x> "), datasz
);
19942 printf ("%#x", (unsigned int) byte_get (ptr
, 4));
19949 if (type
< GNU_PROPERTY_LOPROC
)
19950 printf (_("<unknown type %#x data: "), type
);
19951 else if (type
< GNU_PROPERTY_LOUSER
)
19952 printf (_("<processor-specific type %#x data: "), type
);
19954 printf (_("<application-specific type %#x data: "), type
);
19955 for (j
= 0; j
< datasz
; ++j
)
19956 printf ("%02x ", ptr
[j
] & 0xff);
19960 ptr
+= ((datasz
+ (size
- 1)) & ~ (size
- 1));
19961 if (ptr
== ptr_end
)
19974 print_gnu_note (Filedata
* filedata
, Elf_Internal_Note
*pnote
)
19976 /* NB/ Keep this switch statement in sync with get_gnu_elf_note_type (). */
19977 switch (pnote
->type
)
19979 case NT_GNU_BUILD_ID
:
19983 printf (_(" Build ID: "));
19984 for (i
= 0; i
< pnote
->descsz
; ++i
)
19985 printf ("%02x", pnote
->descdata
[i
] & 0xff);
19990 case NT_GNU_ABI_TAG
:
19992 unsigned long os
, major
, minor
, subminor
;
19993 const char *osname
;
19995 /* PR 17531: file: 030-599401-0.004. */
19996 if (pnote
->descsz
< 16)
19998 printf (_(" <corrupt GNU_ABI_TAG>\n"));
20002 os
= byte_get ((unsigned char *) pnote
->descdata
, 4);
20003 major
= byte_get ((unsigned char *) pnote
->descdata
+ 4, 4);
20004 minor
= byte_get ((unsigned char *) pnote
->descdata
+ 8, 4);
20005 subminor
= byte_get ((unsigned char *) pnote
->descdata
+ 12, 4);
20009 case GNU_ABI_TAG_LINUX
:
20012 case GNU_ABI_TAG_HURD
:
20015 case GNU_ABI_TAG_SOLARIS
:
20016 osname
= "Solaris";
20018 case GNU_ABI_TAG_FREEBSD
:
20019 osname
= "FreeBSD";
20021 case GNU_ABI_TAG_NETBSD
:
20024 case GNU_ABI_TAG_SYLLABLE
:
20025 osname
= "Syllable";
20027 case GNU_ABI_TAG_NACL
:
20031 osname
= "Unknown";
20035 printf (_(" OS: %s, ABI: %ld.%ld.%ld\n"), osname
,
20036 major
, minor
, subminor
);
20040 case NT_GNU_GOLD_VERSION
:
20044 printf (_(" Version: "));
20045 for (i
= 0; i
< pnote
->descsz
&& pnote
->descdata
[i
] != '\0'; ++i
)
20046 printf ("%c", pnote
->descdata
[i
]);
20053 unsigned long num_entries
, mask
;
20055 /* Hardware capabilities information. Word 0 is the number of entries.
20056 Word 1 is a bitmask of enabled entries. The rest of the descriptor
20057 is a series of entries, where each entry is a single byte followed
20058 by a nul terminated string. The byte gives the bit number to test
20059 if enabled in the bitmask. */
20060 printf (_(" Hardware Capabilities: "));
20061 if (pnote
->descsz
< 8)
20063 error (_("<corrupt GNU_HWCAP>\n"));
20066 num_entries
= byte_get ((unsigned char *) pnote
->descdata
, 4);
20067 mask
= byte_get ((unsigned char *) pnote
->descdata
+ 4, 4);
20068 printf (_("num entries: %ld, enabled mask: %lx\n"), num_entries
, mask
);
20069 /* FIXME: Add code to display the entries... */
20073 case NT_GNU_PROPERTY_TYPE_0
:
20074 print_gnu_property_note (filedata
, pnote
);
20078 /* Handle unrecognised types. An error message should have already been
20079 created by get_gnu_elf_note_type(), so all that we need to do is to
20080 display the data. */
20084 printf (_(" Description data: "));
20085 for (i
= 0; i
< pnote
->descsz
; ++i
)
20086 printf ("%02x ", pnote
->descdata
[i
] & 0xff);
20095 static const char *
20096 get_v850_elf_note_type (enum v850_notes n_type
)
20098 static char buff
[64];
20102 case V850_NOTE_ALIGNMENT
: return _("Alignment of 8-byte objects");
20103 case V850_NOTE_DATA_SIZE
: return _("Sizeof double and long double");
20104 case V850_NOTE_FPU_INFO
: return _("Type of FPU support needed");
20105 case V850_NOTE_SIMD_INFO
: return _("Use of SIMD instructions");
20106 case V850_NOTE_CACHE_INFO
: return _("Use of cache");
20107 case V850_NOTE_MMU_INFO
: return _("Use of MMU");
20109 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), n_type
);
20115 print_v850_note (Elf_Internal_Note
* pnote
)
20119 if (pnote
->descsz
!= 4)
20122 val
= byte_get ((unsigned char *) pnote
->descdata
, pnote
->descsz
);
20126 printf (_("not set\n"));
20130 switch (pnote
->type
)
20132 case V850_NOTE_ALIGNMENT
:
20135 case EF_RH850_DATA_ALIGN4
: printf (_("4-byte\n")); return true;
20136 case EF_RH850_DATA_ALIGN8
: printf (_("8-byte\n")); return true;
20140 case V850_NOTE_DATA_SIZE
:
20143 case EF_RH850_DOUBLE32
: printf (_("4-bytes\n")); return true;
20144 case EF_RH850_DOUBLE64
: printf (_("8-bytes\n")); return true;
20148 case V850_NOTE_FPU_INFO
:
20151 case EF_RH850_FPU20
: printf (_("FPU-2.0\n")); return true;
20152 case EF_RH850_FPU30
: printf (_("FPU-3.0\n")); return true;
20156 case V850_NOTE_MMU_INFO
:
20157 case V850_NOTE_CACHE_INFO
:
20158 case V850_NOTE_SIMD_INFO
:
20159 if (val
== EF_RH850_SIMD
)
20161 printf (_("yes\n"));
20167 /* An 'unknown note type' message will already have been displayed. */
20171 printf (_("unknown value: %x\n"), val
);
20176 process_netbsd_elf_note (Elf_Internal_Note
* pnote
)
20178 unsigned int version
;
20180 switch (pnote
->type
)
20182 case NT_NETBSD_IDENT
:
20183 if (pnote
->descsz
< 1)
20185 version
= byte_get ((unsigned char *) pnote
->descdata
, sizeof (version
));
20186 if ((version
/ 10000) % 100)
20187 printf (" NetBSD\t\t0x%08lx\tIDENT %u (%u.%u%s%c)\n", pnote
->descsz
,
20188 version
, version
/ 100000000, (version
/ 1000000) % 100,
20189 (version
/ 10000) % 100 > 26 ? "Z" : "",
20190 'A' + (version
/ 10000) % 26);
20192 printf (" NetBSD\t\t0x%08lx\tIDENT %u (%u.%u.%u)\n", pnote
->descsz
,
20193 version
, version
/ 100000000, (version
/ 1000000) % 100,
20194 (version
/ 100) % 100);
20197 case NT_NETBSD_MARCH
:
20198 printf (" NetBSD\t\t0x%08lx\tMARCH <%s>\n", pnote
->descsz
,
20202 case NT_NETBSD_PAX
:
20203 if (pnote
->descsz
< 1)
20205 version
= byte_get ((unsigned char *) pnote
->descdata
, sizeof (version
));
20206 printf (" NetBSD\t\t0x%08lx\tPaX <%s%s%s%s%s%s>\n", pnote
->descsz
,
20207 ((version
& NT_NETBSD_PAX_MPROTECT
) ? "+mprotect" : ""),
20208 ((version
& NT_NETBSD_PAX_NOMPROTECT
) ? "-mprotect" : ""),
20209 ((version
& NT_NETBSD_PAX_GUARD
) ? "+guard" : ""),
20210 ((version
& NT_NETBSD_PAX_NOGUARD
) ? "-guard" : ""),
20211 ((version
& NT_NETBSD_PAX_ASLR
) ? "+ASLR" : ""),
20212 ((version
& NT_NETBSD_PAX_NOASLR
) ? "-ASLR" : ""));
20216 printf (" NetBSD\t0x%08lx\tUnknown note type: (0x%08lx)\n",
20217 pnote
->descsz
, pnote
->type
);
20221 static const char *
20222 get_freebsd_elfcore_note_type (Filedata
* filedata
, unsigned e_type
)
20226 case NT_FREEBSD_THRMISC
:
20227 return _("NT_THRMISC (thrmisc structure)");
20228 case NT_FREEBSD_PROCSTAT_PROC
:
20229 return _("NT_PROCSTAT_PROC (proc data)");
20230 case NT_FREEBSD_PROCSTAT_FILES
:
20231 return _("NT_PROCSTAT_FILES (files data)");
20232 case NT_FREEBSD_PROCSTAT_VMMAP
:
20233 return _("NT_PROCSTAT_VMMAP (vmmap data)");
20234 case NT_FREEBSD_PROCSTAT_GROUPS
:
20235 return _("NT_PROCSTAT_GROUPS (groups data)");
20236 case NT_FREEBSD_PROCSTAT_UMASK
:
20237 return _("NT_PROCSTAT_UMASK (umask data)");
20238 case NT_FREEBSD_PROCSTAT_RLIMIT
:
20239 return _("NT_PROCSTAT_RLIMIT (rlimit data)");
20240 case NT_FREEBSD_PROCSTAT_OSREL
:
20241 return _("NT_PROCSTAT_OSREL (osreldate data)");
20242 case NT_FREEBSD_PROCSTAT_PSSTRINGS
:
20243 return _("NT_PROCSTAT_PSSTRINGS (ps_strings data)");
20244 case NT_FREEBSD_PROCSTAT_AUXV
:
20245 return _("NT_PROCSTAT_AUXV (auxv data)");
20246 case NT_FREEBSD_PTLWPINFO
:
20247 return _("NT_PTLWPINFO (ptrace_lwpinfo structure)");
20249 return get_note_type (filedata
, e_type
);
20252 static const char *
20253 get_netbsd_elfcore_note_type (Filedata
* filedata
, unsigned e_type
)
20255 static char buff
[64];
20259 case NT_NETBSDCORE_PROCINFO
:
20260 /* NetBSD core "procinfo" structure. */
20261 return _("NetBSD procinfo structure");
20263 case NT_NETBSDCORE_AUXV
:
20264 return _("NetBSD ELF auxiliary vector data");
20266 case NT_NETBSDCORE_LWPSTATUS
:
20267 return _("PT_LWPSTATUS (ptrace_lwpstatus structure)");
20270 /* As of Jan 2020 there are no other machine-independent notes
20271 defined for NetBSD core files. If the note type is less
20272 than the start of the machine-dependent note types, we don't
20275 if (e_type
< NT_NETBSDCORE_FIRSTMACH
)
20277 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
20283 switch (filedata
->file_header
.e_machine
)
20285 /* On the Alpha, SPARC (32-bit and 64-bit), PT_GETREGS == mach+0
20286 and PT_GETFPREGS == mach+2. */
20291 case EM_SPARC32PLUS
:
20295 case NT_NETBSDCORE_FIRSTMACH
+ 0:
20296 return _("PT_GETREGS (reg structure)");
20297 case NT_NETBSDCORE_FIRSTMACH
+ 2:
20298 return _("PT_GETFPREGS (fpreg structure)");
20304 /* On SuperH, PT_GETREGS == mach+3 and PT_GETFPREGS == mach+5.
20305 There's also old PT___GETREGS40 == mach + 1 for old reg
20306 structure which lacks GBR. */
20310 case NT_NETBSDCORE_FIRSTMACH
+ 1:
20311 return _("PT___GETREGS40 (old reg structure)");
20312 case NT_NETBSDCORE_FIRSTMACH
+ 3:
20313 return _("PT_GETREGS (reg structure)");
20314 case NT_NETBSDCORE_FIRSTMACH
+ 5:
20315 return _("PT_GETFPREGS (fpreg structure)");
20321 /* On all other arch's, PT_GETREGS == mach+1 and
20322 PT_GETFPREGS == mach+3. */
20326 case NT_NETBSDCORE_FIRSTMACH
+ 1:
20327 return _("PT_GETREGS (reg structure)");
20328 case NT_NETBSDCORE_FIRSTMACH
+ 3:
20329 return _("PT_GETFPREGS (fpreg structure)");
20335 snprintf (buff
, sizeof (buff
), "PT_FIRSTMACH+%d",
20336 e_type
- NT_NETBSDCORE_FIRSTMACH
);
20340 static const char *
20341 get_openbsd_elfcore_note_type (Filedata
* filedata
, unsigned e_type
)
20345 case NT_OPENBSD_PROCINFO
:
20346 return _("OpenBSD procinfo structure");
20347 case NT_OPENBSD_AUXV
:
20348 return _("OpenBSD ELF auxiliary vector data");
20349 case NT_OPENBSD_REGS
:
20350 return _("OpenBSD regular registers");
20351 case NT_OPENBSD_FPREGS
:
20352 return _("OpenBSD floating point registers");
20353 case NT_OPENBSD_WCOOKIE
:
20354 return _("OpenBSD window cookie");
20357 return get_note_type (filedata
, e_type
);
20360 static const char *
20361 get_stapsdt_note_type (unsigned e_type
)
20363 static char buff
[64];
20368 return _("NT_STAPSDT (SystemTap probe descriptors)");
20374 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
20379 print_stapsdt_note (Elf_Internal_Note
*pnote
)
20381 size_t len
, maxlen
;
20382 unsigned long addr_size
= is_32bit_elf
? 4 : 8;
20383 char *data
= pnote
->descdata
;
20384 char *data_end
= pnote
->descdata
+ pnote
->descsz
;
20385 bfd_vma pc
, base_addr
, semaphore
;
20386 char *provider
, *probe
, *arg_fmt
;
20388 if (pnote
->descsz
< (addr_size
* 3))
20389 goto stapdt_note_too_small
;
20391 pc
= byte_get ((unsigned char *) data
, addr_size
);
20394 base_addr
= byte_get ((unsigned char *) data
, addr_size
);
20397 semaphore
= byte_get ((unsigned char *) data
, addr_size
);
20400 if (data
>= data_end
)
20401 goto stapdt_note_too_small
;
20402 maxlen
= data_end
- data
;
20403 len
= strnlen (data
, maxlen
);
20410 goto stapdt_note_too_small
;
20412 if (data
>= data_end
)
20413 goto stapdt_note_too_small
;
20414 maxlen
= data_end
- data
;
20415 len
= strnlen (data
, maxlen
);
20422 goto stapdt_note_too_small
;
20424 if (data
>= data_end
)
20425 goto stapdt_note_too_small
;
20426 maxlen
= data_end
- data
;
20427 len
= strnlen (data
, maxlen
);
20434 goto stapdt_note_too_small
;
20436 printf (_(" Provider: %s\n"), provider
);
20437 printf (_(" Name: %s\n"), probe
);
20438 printf (_(" Location: "));
20439 print_vma (pc
, FULL_HEX
);
20440 printf (_(", Base: "));
20441 print_vma (base_addr
, FULL_HEX
);
20442 printf (_(", Semaphore: "));
20443 print_vma (semaphore
, FULL_HEX
);
20445 printf (_(" Arguments: %s\n"), arg_fmt
);
20447 return data
== data_end
;
20449 stapdt_note_too_small
:
20450 printf (_(" <corrupt - note is too small>\n"));
20451 error (_("corrupt stapdt note - the data size is too small\n"));
20456 print_fdo_note (Elf_Internal_Note
* pnote
)
20458 if (pnote
->descsz
> 0 && pnote
->type
== FDO_PACKAGING_METADATA
)
20460 printf (_(" Packaging Metadata: %.*s\n"), (int) pnote
->descsz
, pnote
->descdata
);
20466 static const char *
20467 get_ia64_vms_note_type (unsigned e_type
)
20469 static char buff
[64];
20474 return _("NT_VMS_MHD (module header)");
20476 return _("NT_VMS_LNM (language name)");
20478 return _("NT_VMS_SRC (source files)");
20480 return "NT_VMS_TITLE";
20482 return _("NT_VMS_EIDC (consistency check)");
20483 case NT_VMS_FPMODE
:
20484 return _("NT_VMS_FPMODE (FP mode)");
20485 case NT_VMS_LINKTIME
:
20486 return "NT_VMS_LINKTIME";
20487 case NT_VMS_IMGNAM
:
20488 return _("NT_VMS_IMGNAM (image name)");
20490 return _("NT_VMS_IMGID (image id)");
20491 case NT_VMS_LINKID
:
20492 return _("NT_VMS_LINKID (link id)");
20493 case NT_VMS_IMGBID
:
20494 return _("NT_VMS_IMGBID (build id)");
20495 case NT_VMS_GSTNAM
:
20496 return _("NT_VMS_GSTNAM (sym table name)");
20497 case NT_VMS_ORIG_DYN
:
20498 return "NT_VMS_ORIG_DYN";
20499 case NT_VMS_PATCHTIME
:
20500 return "NT_VMS_PATCHTIME";
20502 snprintf (buff
, sizeof (buff
), _("Unknown note type: (0x%08x)"), e_type
);
20508 print_ia64_vms_note (Elf_Internal_Note
* pnote
)
20510 int maxlen
= pnote
->descsz
;
20512 if (maxlen
< 2 || (unsigned long) maxlen
!= pnote
->descsz
)
20513 goto desc_size_fail
;
20515 switch (pnote
->type
)
20519 goto desc_size_fail
;
20521 int l
= (int) strnlen (pnote
->descdata
+ 34, maxlen
- 34);
20523 printf (_(" Creation date : %.17s\n"), pnote
->descdata
);
20524 printf (_(" Last patch date: %.17s\n"), pnote
->descdata
+ 17);
20525 if (l
+ 34 < maxlen
)
20527 printf (_(" Module name : %s\n"), pnote
->descdata
+ 34);
20528 if (l
+ 35 < maxlen
)
20529 printf (_(" Module version : %s\n"), pnote
->descdata
+ 34 + l
+ 1);
20531 printf (_(" Module version : <missing>\n"));
20535 printf (_(" Module name : <missing>\n"));
20536 printf (_(" Module version : <missing>\n"));
20541 printf (_(" Language: %.*s\n"), maxlen
, pnote
->descdata
);
20545 case NT_VMS_FPMODE
:
20546 printf (_(" Floating Point mode: "));
20548 goto desc_size_fail
;
20549 /* FIXME: Generate an error if descsz > 8 ? */
20551 printf ("0x%016" BFD_VMA_FMT
"x\n",
20552 (bfd_vma
) byte_get ((unsigned char *)pnote
->descdata
, 8));
20555 case NT_VMS_LINKTIME
:
20556 printf (_(" Link time: "));
20558 goto desc_size_fail
;
20559 /* FIXME: Generate an error if descsz > 8 ? */
20562 ((bfd_int64_t
) byte_get ((unsigned char *)pnote
->descdata
, 8));
20566 case NT_VMS_PATCHTIME
:
20567 printf (_(" Patch time: "));
20569 goto desc_size_fail
;
20570 /* FIXME: Generate an error if descsz > 8 ? */
20573 ((bfd_int64_t
) byte_get ((unsigned char *)pnote
->descdata
, 8));
20577 case NT_VMS_ORIG_DYN
:
20579 goto desc_size_fail
;
20581 printf (_(" Major id: %u, minor id: %u\n"),
20582 (unsigned) byte_get ((unsigned char *)pnote
->descdata
, 4),
20583 (unsigned) byte_get ((unsigned char *)pnote
->descdata
+ 4, 4));
20584 printf (_(" Last modified : "));
20586 ((bfd_int64_t
) byte_get ((unsigned char *)pnote
->descdata
+ 8, 8));
20587 printf (_("\n Link flags : "));
20588 printf ("0x%016" BFD_VMA_FMT
"x\n",
20589 (bfd_vma
) byte_get ((unsigned char *)pnote
->descdata
+ 16, 8));
20590 printf (_(" Header flags: 0x%08x\n"),
20591 (unsigned) byte_get ((unsigned char *)pnote
->descdata
+ 24, 4));
20592 printf (_(" Image id : %.*s\n"), maxlen
- 32, pnote
->descdata
+ 32);
20596 case NT_VMS_IMGNAM
:
20597 printf (_(" Image name: %.*s\n"), maxlen
, pnote
->descdata
);
20600 case NT_VMS_GSTNAM
:
20601 printf (_(" Global symbol table name: %.*s\n"), maxlen
, pnote
->descdata
);
20605 printf (_(" Image id: %.*s\n"), maxlen
, pnote
->descdata
);
20608 case NT_VMS_LINKID
:
20609 printf (_(" Linker id: %.*s\n"), maxlen
, pnote
->descdata
);
20619 printf (_(" <corrupt - data size is too small>\n"));
20620 error (_("corrupt IA64 note: data size is too small\n"));
20624 struct build_attr_cache
{
20625 Filedata
*filedata
;
20627 unsigned long strtablen
;
20628 Elf_Internal_Sym
*symtab
;
20629 unsigned long nsyms
;
20632 /* Find the symbol associated with a build attribute that is attached
20633 to address OFFSET. If PNAME is non-NULL then store the name of
20634 the symbol (if found) in the provided pointer, Returns NULL if a
20635 symbol could not be found. */
20637 static Elf_Internal_Sym
*
20638 get_symbol_for_build_attribute (Filedata
*filedata
,
20639 unsigned long offset
,
20641 const char **pname
)
20643 Elf_Internal_Sym
*saved_sym
= NULL
;
20644 Elf_Internal_Sym
*sym
;
20646 if (filedata
->section_headers
!= NULL
20647 && (ba_cache
.filedata
== NULL
|| filedata
!= ba_cache
.filedata
))
20649 Elf_Internal_Shdr
* symsec
;
20651 free (ba_cache
.strtab
);
20652 ba_cache
.strtab
= NULL
;
20653 free (ba_cache
.symtab
);
20654 ba_cache
.symtab
= NULL
;
20656 /* Load the symbol and string sections. */
20657 for (symsec
= filedata
->section_headers
;
20658 symsec
< filedata
->section_headers
+ filedata
->file_header
.e_shnum
;
20661 if (symsec
->sh_type
== SHT_SYMTAB
20662 && get_symtab (filedata
, symsec
,
20663 &ba_cache
.symtab
, &ba_cache
.nsyms
,
20664 &ba_cache
.strtab
, &ba_cache
.strtablen
))
20667 ba_cache
.filedata
= filedata
;
20670 if (ba_cache
.symtab
== NULL
)
20673 /* Find a symbol whose value matches offset. */
20674 for (sym
= ba_cache
.symtab
; sym
< ba_cache
.symtab
+ ba_cache
.nsyms
; sym
++)
20675 if (sym
->st_value
== offset
)
20677 if (sym
->st_name
>= ba_cache
.strtablen
)
20678 /* Huh ? This should not happen. */
20681 if (ba_cache
.strtab
[sym
->st_name
] == 0)
20684 /* The AArch64, ARM and RISC-V architectures define mapping symbols
20685 (eg $d, $x, $t) which we want to ignore. */
20686 if (ba_cache
.strtab
[sym
->st_name
] == '$'
20687 && ba_cache
.strtab
[sym
->st_name
+ 1] != 0
20688 && ba_cache
.strtab
[sym
->st_name
+ 2] == 0)
20693 /* For OPEN attributes we prefer GLOBAL over LOCAL symbols
20694 and FILE or OBJECT symbols over NOTYPE symbols. We skip
20695 FUNC symbols entirely. */
20696 switch (ELF_ST_TYPE (sym
->st_info
))
20703 /* If the symbol has a size associated
20704 with it then we can stop searching. */
20705 sym
= ba_cache
.symtab
+ ba_cache
.nsyms
;
20710 /* Ignore function symbols. */
20717 switch (ELF_ST_BIND (sym
->st_info
))
20720 if (saved_sym
== NULL
20721 || ELF_ST_TYPE (saved_sym
->st_info
) != STT_OBJECT
)
20726 if (saved_sym
== NULL
)
20736 if (ELF_ST_TYPE (sym
->st_info
) != STT_FUNC
)
20744 if (saved_sym
&& pname
)
20745 * pname
= ba_cache
.strtab
+ saved_sym
->st_name
;
20750 /* Returns true iff addr1 and addr2 are in the same section. */
20753 same_section (Filedata
* filedata
, unsigned long addr1
, unsigned long addr2
)
20755 Elf_Internal_Shdr
* a1
;
20756 Elf_Internal_Shdr
* a2
;
20758 a1
= find_section_by_address (filedata
, addr1
);
20759 a2
= find_section_by_address (filedata
, addr2
);
20761 return a1
== a2
&& a1
!= NULL
;
20765 print_gnu_build_attribute_description (Elf_Internal_Note
* pnote
,
20766 Filedata
* filedata
)
20768 static unsigned long global_offset
= 0;
20769 static unsigned long global_end
= 0;
20770 static unsigned long func_offset
= 0;
20771 static unsigned long func_end
= 0;
20773 Elf_Internal_Sym
*sym
;
20775 unsigned long start
;
20777 bool is_open_attr
= pnote
->type
== NT_GNU_BUILD_ATTRIBUTE_OPEN
;
20779 switch (pnote
->descsz
)
20782 /* A zero-length description means that the range of
20783 the previous note of the same type should be used. */
20786 if (global_end
> global_offset
)
20787 printf (_(" Applies to region from %#lx to %#lx\n"),
20788 global_offset
, global_end
);
20790 printf (_(" Applies to region from %#lx\n"), global_offset
);
20794 if (func_end
> func_offset
)
20795 printf (_(" Applies to region from %#lx to %#lx\n"), func_offset
, func_end
);
20797 printf (_(" Applies to region from %#lx\n"), func_offset
);
20802 start
= byte_get ((unsigned char *) pnote
->descdata
, 4);
20807 start
= byte_get ((unsigned char *) pnote
->descdata
, 4);
20808 end
= byte_get ((unsigned char *) pnote
->descdata
+ 4, 4);
20812 start
= byte_get ((unsigned char *) pnote
->descdata
, 8);
20813 end
= byte_get ((unsigned char *) pnote
->descdata
+ 8, 8);
20817 error (_(" <invalid description size: %lx>\n"), pnote
->descsz
);
20818 printf (_(" <invalid descsz>"));
20823 sym
= get_symbol_for_build_attribute (filedata
, start
, is_open_attr
, & name
);
20824 /* As of version 5 of the annobin plugin, filename symbols are biased by 2
20825 in order to avoid them being confused with the start address of the
20826 first function in the file... */
20827 if (sym
== NULL
&& is_open_attr
)
20828 sym
= get_symbol_for_build_attribute (filedata
, start
+ 2, is_open_attr
,
20831 if (end
== 0 && sym
!= NULL
&& sym
->st_size
> 0)
20832 end
= start
+ sym
->st_size
;
20836 /* FIXME: Need to properly allow for section alignment.
20837 16 is just the alignment used on x86_64. */
20839 && start
> BFD_ALIGN (global_end
, 16)
20840 /* Build notes are not guaranteed to be organised in order of
20841 increasing address, but we should find the all of the notes
20842 for one section in the same place. */
20843 && same_section (filedata
, start
, global_end
))
20844 warn (_("Gap in build notes detected from %#lx to %#lx\n"),
20845 global_end
+ 1, start
- 1);
20847 printf (_(" Applies to region from %#lx"), start
);
20848 global_offset
= start
;
20852 printf (_(" to %#lx"), end
);
20858 printf (_(" Applies to region from %#lx"), start
);
20859 func_offset
= start
;
20863 printf (_(" to %#lx"), end
);
20869 printf (_(" (%s)"), name
);
20876 print_gnu_build_attribute_name (Elf_Internal_Note
* pnote
)
20878 static const char string_expected
[2] = { GNU_BUILD_ATTRIBUTE_TYPE_STRING
, 0 };
20879 static const char number_expected
[2] = { GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC
, 0 };
20880 static const char bool_expected
[3] = { GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE
, GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE
, 0 };
20882 char name_attribute
;
20883 const char * expected_types
;
20884 const char * name
= pnote
->namedata
;
20888 if (name
== NULL
|| pnote
->namesz
< 2)
20890 error (_("corrupt name field in GNU build attribute note: size = %ld\n"), pnote
->namesz
);
20891 print_symbol (-20, _(" <corrupt name>"));
20900 /* Version 2 of the spec adds a "GA" prefix to the name field. */
20901 if (name
[0] == 'G' && name
[1] == 'A')
20903 if (pnote
->namesz
< 4)
20905 error (_("corrupt name field in GNU build attribute note: size = %ld\n"), pnote
->namesz
);
20906 print_symbol (-20, _(" <corrupt name>"));
20915 switch ((name_type
= * name
))
20917 case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC
:
20918 case GNU_BUILD_ATTRIBUTE_TYPE_STRING
:
20919 case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE
:
20920 case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE
:
20921 printf ("%c", * name
);
20925 error (_("unrecognised attribute type in name field: %d\n"), name_type
);
20926 print_symbol (-20, _("<unknown name type>"));
20933 switch ((name_attribute
= * name
))
20935 case GNU_BUILD_ATTRIBUTE_VERSION
:
20936 text
= _("<version>");
20937 expected_types
= string_expected
;
20940 case GNU_BUILD_ATTRIBUTE_STACK_PROT
:
20941 text
= _("<stack prot>");
20942 expected_types
= "!+*";
20945 case GNU_BUILD_ATTRIBUTE_RELRO
:
20946 text
= _("<relro>");
20947 expected_types
= bool_expected
;
20950 case GNU_BUILD_ATTRIBUTE_STACK_SIZE
:
20951 text
= _("<stack size>");
20952 expected_types
= number_expected
;
20955 case GNU_BUILD_ATTRIBUTE_TOOL
:
20956 text
= _("<tool>");
20957 expected_types
= string_expected
;
20960 case GNU_BUILD_ATTRIBUTE_ABI
:
20962 expected_types
= "$*";
20965 case GNU_BUILD_ATTRIBUTE_PIC
:
20967 expected_types
= number_expected
;
20970 case GNU_BUILD_ATTRIBUTE_SHORT_ENUM
:
20971 text
= _("<short enum>");
20972 expected_types
= bool_expected
;
20976 if (ISPRINT (* name
))
20978 int len
= strnlen (name
, pnote
->namesz
- (name
- pnote
->namedata
)) + 1;
20980 if (len
> left
&& ! do_wide
)
20982 printf ("%.*s:", len
, name
);
20988 static char tmpbuf
[128];
20990 error (_("unrecognised byte in name field: %d\n"), * name
);
20991 sprintf (tmpbuf
, _("<unknown:_%d>"), * name
);
20995 expected_types
= "*$!+";
21000 left
-= printf ("%s", text
);
21002 if (strchr (expected_types
, name_type
) == NULL
)
21003 warn (_("attribute does not have an expected type (%c)\n"), name_type
);
21005 if ((unsigned long)(name
- pnote
->namedata
) > pnote
->namesz
)
21007 error (_("corrupt name field: namesz: %lu but parsing gets to %ld\n"),
21008 (unsigned long) pnote
->namesz
,
21009 (long) (name
- pnote
->namedata
));
21013 if (left
< 1 && ! do_wide
)
21018 case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC
:
21020 unsigned int bytes
;
21021 unsigned long long val
= 0;
21022 unsigned int shift
= 0;
21023 char * decoded
= NULL
;
21025 bytes
= pnote
->namesz
- (name
- pnote
->namedata
);
21027 /* The -1 is because the name field is always 0 terminated, and we
21028 want to be able to ensure that the shift in the while loop below
21029 will not overflow. */
21032 if (bytes
> sizeof (val
))
21034 error (_("corrupt numeric name field: too many bytes in the value: %x\n"),
21036 bytes
= sizeof (val
);
21038 /* We do not bother to warn if bytes == 0 as this can
21039 happen with some early versions of the gcc plugin. */
21043 unsigned long long byte
= *name
++ & 0xff;
21045 val
|= byte
<< shift
;
21049 switch (name_attribute
)
21051 case GNU_BUILD_ATTRIBUTE_PIC
:
21054 case 0: decoded
= "static"; break;
21055 case 1: decoded
= "pic"; break;
21056 case 2: decoded
= "PIC"; break;
21057 case 3: decoded
= "pie"; break;
21058 case 4: decoded
= "PIE"; break;
21062 case GNU_BUILD_ATTRIBUTE_STACK_PROT
:
21065 /* Based upon the SPCT_FLAG_xxx enum values in gcc/cfgexpand.c. */
21066 case 0: decoded
= "off"; break;
21067 case 1: decoded
= "on"; break;
21068 case 2: decoded
= "all"; break;
21069 case 3: decoded
= "strong"; break;
21070 case 4: decoded
= "explicit"; break;
21078 if (decoded
!= NULL
)
21080 print_symbol (-left
, decoded
);
21091 left
-= printf ("0x%llx", val
);
21093 left
-= printf ("0x%-.*llx", left
, val
);
21097 case GNU_BUILD_ATTRIBUTE_TYPE_STRING
:
21098 left
-= print_symbol (- left
, name
);
21100 case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE
:
21101 left
-= print_symbol (- left
, "true");
21103 case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE
:
21104 left
-= print_symbol (- left
, "false");
21108 if (do_wide
&& left
> 0)
21109 printf ("%-*s", left
, " ");
21114 /* Note that by the ELF standard, the name field is already null byte
21115 terminated, and namesz includes the terminating null byte.
21116 I.E. the value of namesz for the name "FSF" is 4.
21118 If the value of namesz is zero, there is no name present. */
21121 process_note (Elf_Internal_Note
* pnote
,
21122 Filedata
* filedata
)
21124 const char * name
= pnote
->namesz
? pnote
->namedata
: "(NONE)";
21127 if (pnote
->namesz
== 0)
21128 /* If there is no note name, then use the default set of
21129 note type strings. */
21130 nt
= get_note_type (filedata
, pnote
->type
);
21132 else if (startswith (pnote
->namedata
, "GNU"))
21133 /* GNU-specific object file notes. */
21134 nt
= get_gnu_elf_note_type (pnote
->type
);
21136 else if (startswith (pnote
->namedata
, "FreeBSD"))
21137 /* FreeBSD-specific core file notes. */
21138 nt
= get_freebsd_elfcore_note_type (filedata
, pnote
->type
);
21140 else if (startswith (pnote
->namedata
, "NetBSD-CORE"))
21141 /* NetBSD-specific core file notes. */
21142 nt
= get_netbsd_elfcore_note_type (filedata
, pnote
->type
);
21144 else if (startswith (pnote
->namedata
, "NetBSD"))
21145 /* NetBSD-specific core file notes. */
21146 return process_netbsd_elf_note (pnote
);
21148 else if (startswith (pnote
->namedata
, "PaX"))
21149 /* NetBSD-specific core file notes. */
21150 return process_netbsd_elf_note (pnote
);
21152 else if (startswith (pnote
->namedata
, "OpenBSD"))
21153 /* OpenBSD-specific core file notes. */
21154 nt
= get_openbsd_elfcore_note_type (filedata
, pnote
->type
);
21156 else if (startswith (pnote
->namedata
, "SPU/"))
21158 /* SPU-specific core file notes. */
21159 nt
= pnote
->namedata
+ 4;
21163 else if (startswith (pnote
->namedata
, "IPF/VMS"))
21164 /* VMS/ia64-specific file notes. */
21165 nt
= get_ia64_vms_note_type (pnote
->type
);
21167 else if (startswith (pnote
->namedata
, "stapsdt"))
21168 nt
= get_stapsdt_note_type (pnote
->type
);
21171 /* Don't recognize this note name; just use the default set of
21172 note type strings. */
21173 nt
= get_note_type (filedata
, pnote
->type
);
21177 if (((startswith (pnote
->namedata
, "GA")
21178 && strchr ("*$!+", pnote
->namedata
[2]) != NULL
)
21179 || strchr ("*$!+", pnote
->namedata
[0]) != NULL
)
21180 && (pnote
->type
== NT_GNU_BUILD_ATTRIBUTE_OPEN
21181 || pnote
->type
== NT_GNU_BUILD_ATTRIBUTE_FUNC
))
21182 print_gnu_build_attribute_name (pnote
);
21184 print_symbol (-20, name
);
21187 printf (" 0x%08lx\t%s\t", pnote
->descsz
, nt
);
21189 printf (" 0x%08lx\t%s\n", pnote
->descsz
, nt
);
21191 if (startswith (pnote
->namedata
, "IPF/VMS"))
21192 return print_ia64_vms_note (pnote
);
21193 else if (startswith (pnote
->namedata
, "GNU"))
21194 return print_gnu_note (filedata
, pnote
);
21195 else if (startswith (pnote
->namedata
, "stapsdt"))
21196 return print_stapsdt_note (pnote
);
21197 else if (startswith (pnote
->namedata
, "CORE"))
21198 return print_core_note (pnote
);
21199 else if (startswith (pnote
->namedata
, "FDO"))
21200 return print_fdo_note (pnote
);
21201 else if (((startswith (pnote
->namedata
, "GA")
21202 && strchr ("*$!+", pnote
->namedata
[2]) != NULL
)
21203 || strchr ("*$!+", pnote
->namedata
[0]) != NULL
)
21204 && (pnote
->type
== NT_GNU_BUILD_ATTRIBUTE_OPEN
21205 || pnote
->type
== NT_GNU_BUILD_ATTRIBUTE_FUNC
))
21206 return print_gnu_build_attribute_description (pnote
, filedata
);
21212 printf (_(" description data: "));
21213 for (i
= 0; i
< pnote
->descsz
; i
++)
21214 printf ("%02x ", pnote
->descdata
[i
] & 0xff);
21226 process_notes_at (Filedata
* filedata
,
21227 Elf_Internal_Shdr
* section
,
21232 Elf_External_Note
*pnotes
;
21233 Elf_External_Note
*external
;
21242 pnotes
= (Elf_External_Note
*) get_section_contents (section
, filedata
);
21245 if (! apply_relocations (filedata
, section
, (unsigned char *) pnotes
, length
, NULL
, NULL
))
21253 pnotes
= (Elf_External_Note
*) get_data (NULL
, filedata
, offset
, 1, length
,
21256 if (pnotes
== NULL
)
21261 if (filedata
->is_separate
)
21262 printf (_("In linked file '%s': "), filedata
->file_name
);
21266 printf (_("Displaying notes found in: %s\n"), printable_section_name (filedata
, section
));
21268 printf (_("Displaying notes found at file offset 0x%08lx with length 0x%08lx:\n"),
21269 (unsigned long) offset
, (unsigned long) length
);
21271 /* NB: Some note sections may have alignment value of 0 or 1. gABI
21272 specifies that notes should be aligned to 4 bytes in 32-bit
21273 objects and to 8 bytes in 64-bit objects. As a Linux extension,
21274 we also support 4 byte alignment in 64-bit objects. If section
21275 alignment is less than 4, we treate alignment as 4 bytes. */
21278 else if (align
!= 4 && align
!= 8)
21280 warn (_("Corrupt note: alignment %ld, expecting 4 or 8\n"),
21286 printf (_(" %-20s %-10s\tDescription\n"), _("Owner"), _("Data size"));
21288 end
= (char *) pnotes
+ length
;
21289 while ((char *) external
< end
)
21291 Elf_Internal_Note inote
;
21294 char * temp
= NULL
;
21295 size_t data_remaining
= end
- (char *) external
;
21297 if (!is_ia64_vms (filedata
))
21299 /* PR binutils/15191
21300 Make sure that there is enough data to read. */
21301 min_notesz
= offsetof (Elf_External_Note
, name
);
21302 if (data_remaining
< min_notesz
)
21304 warn (ngettext ("Corrupt note: only %ld byte remains, "
21305 "not enough for a full note\n",
21306 "Corrupt note: only %ld bytes remain, "
21307 "not enough for a full note\n",
21309 (long) data_remaining
);
21312 data_remaining
-= min_notesz
;
21314 inote
.type
= BYTE_GET (external
->type
);
21315 inote
.namesz
= BYTE_GET (external
->namesz
);
21316 inote
.namedata
= external
->name
;
21317 inote
.descsz
= BYTE_GET (external
->descsz
);
21318 inote
.descdata
= ((char *) external
21319 + ELF_NOTE_DESC_OFFSET (inote
.namesz
, align
));
21320 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
21321 next
= ((char *) external
21322 + ELF_NOTE_NEXT_OFFSET (inote
.namesz
, inote
.descsz
, align
));
21326 Elf64_External_VMS_Note
*vms_external
;
21328 /* PR binutils/15191
21329 Make sure that there is enough data to read. */
21330 min_notesz
= offsetof (Elf64_External_VMS_Note
, name
);
21331 if (data_remaining
< min_notesz
)
21333 warn (ngettext ("Corrupt note: only %ld byte remains, "
21334 "not enough for a full note\n",
21335 "Corrupt note: only %ld bytes remain, "
21336 "not enough for a full note\n",
21338 (long) data_remaining
);
21341 data_remaining
-= min_notesz
;
21343 vms_external
= (Elf64_External_VMS_Note
*) external
;
21344 inote
.type
= BYTE_GET (vms_external
->type
);
21345 inote
.namesz
= BYTE_GET (vms_external
->namesz
);
21346 inote
.namedata
= vms_external
->name
;
21347 inote
.descsz
= BYTE_GET (vms_external
->descsz
);
21348 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 3);
21349 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
21350 next
= inote
.descdata
+ align_power (inote
.descsz
, 3);
21353 /* PR 17531: file: 3443835e. */
21354 /* PR 17531: file: id:000000,sig:11,src:006986,op:havoc,rep:4. */
21355 if ((size_t) (inote
.descdata
- inote
.namedata
) < inote
.namesz
21356 || (size_t) (inote
.descdata
- inote
.namedata
) > data_remaining
21357 || (size_t) (next
- inote
.descdata
) < inote
.descsz
21358 || ((size_t) (next
- inote
.descdata
)
21359 > data_remaining
- (size_t) (inote
.descdata
- inote
.namedata
)))
21361 warn (_("note with invalid namesz and/or descsz found at offset 0x%lx\n"),
21362 (unsigned long) ((char *) external
- (char *) pnotes
));
21363 warn (_(" type: 0x%lx, namesize: 0x%08lx, descsize: 0x%08lx, alignment: %u\n"),
21364 inote
.type
, inote
.namesz
, inote
.descsz
, (int) align
);
21368 external
= (Elf_External_Note
*) next
;
21370 /* Verify that name is null terminated. It appears that at least
21371 one version of Linux (RedHat 6.0) generates corefiles that don't
21372 comply with the ELF spec by failing to include the null byte in
21374 if (inote
.namesz
> 0 && inote
.namedata
[inote
.namesz
- 1] != '\0')
21376 if ((size_t) (inote
.descdata
- inote
.namedata
) == inote
.namesz
)
21378 temp
= (char *) malloc (inote
.namesz
+ 1);
21381 error (_("Out of memory allocating space for inote name\n"));
21386 memcpy (temp
, inote
.namedata
, inote
.namesz
);
21387 inote
.namedata
= temp
;
21389 inote
.namedata
[inote
.namesz
] = 0;
21392 if (! process_note (& inote
, filedata
))
21405 process_corefile_note_segments (Filedata
* filedata
)
21407 Elf_Internal_Phdr
*segment
;
21411 if (! get_program_headers (filedata
))
21414 for (i
= 0, segment
= filedata
->program_headers
;
21415 i
< filedata
->file_header
.e_phnum
;
21418 if (segment
->p_type
== PT_NOTE
)
21419 if (! process_notes_at (filedata
, NULL
,
21420 (bfd_vma
) segment
->p_offset
,
21421 (bfd_vma
) segment
->p_filesz
,
21422 (bfd_vma
) segment
->p_align
))
21430 process_v850_notes (Filedata
* filedata
, bfd_vma offset
, bfd_vma length
)
21432 Elf_External_Note
* pnotes
;
21433 Elf_External_Note
* external
;
21440 pnotes
= (Elf_External_Note
*) get_data (NULL
, filedata
, offset
, 1, length
,
21442 if (pnotes
== NULL
)
21446 end
= (char*) pnotes
+ length
;
21448 printf (_("\nDisplaying contents of Renesas V850 notes section at offset 0x%lx with length 0x%lx:\n"),
21449 (unsigned long) offset
, (unsigned long) length
);
21451 while ((char *) external
+ sizeof (Elf_External_Note
) < end
)
21453 Elf_External_Note
* next
;
21454 Elf_Internal_Note inote
;
21456 inote
.type
= BYTE_GET (external
->type
);
21457 inote
.namesz
= BYTE_GET (external
->namesz
);
21458 inote
.namedata
= external
->name
;
21459 inote
.descsz
= BYTE_GET (external
->descsz
);
21460 inote
.descdata
= inote
.namedata
+ align_power (inote
.namesz
, 2);
21461 inote
.descpos
= offset
+ (inote
.descdata
- (char *) pnotes
);
21463 if (inote
.descdata
< (char *) pnotes
|| inote
.descdata
>= end
)
21465 warn (_("Corrupt note: name size is too big: %lx\n"), inote
.namesz
);
21466 inote
.descdata
= inote
.namedata
;
21470 next
= (Elf_External_Note
*) (inote
.descdata
+ align_power (inote
.descsz
, 2));
21472 if ( ((char *) next
> end
)
21473 || ((char *) next
< (char *) pnotes
))
21475 warn (_("corrupt descsz found in note at offset 0x%lx\n"),
21476 (unsigned long) ((char *) external
- (char *) pnotes
));
21477 warn (_(" type: 0x%lx, namesize: 0x%lx, descsize: 0x%lx\n"),
21478 inote
.type
, inote
.namesz
, inote
.descsz
);
21484 /* Prevent out-of-bounds indexing. */
21485 if ( inote
.namedata
+ inote
.namesz
> end
21486 || inote
.namedata
+ inote
.namesz
< inote
.namedata
)
21488 warn (_("corrupt namesz found in note at offset 0x%lx\n"),
21489 (unsigned long) ((char *) external
- (char *) pnotes
));
21490 warn (_(" type: 0x%lx, namesize: 0x%lx, descsize: 0x%lx\n"),
21491 inote
.type
, inote
.namesz
, inote
.descsz
);
21495 printf (" %s: ", get_v850_elf_note_type (inote
.type
));
21497 if (! print_v850_note (& inote
))
21500 printf ("<corrupt sizes: namesz: %lx, descsz: %lx>\n",
21501 inote
.namesz
, inote
.descsz
);
21511 process_note_sections (Filedata
* filedata
)
21513 Elf_Internal_Shdr
*section
;
21515 unsigned int n
= 0;
21518 for (i
= 0, section
= filedata
->section_headers
;
21519 i
< filedata
->file_header
.e_shnum
&& section
!= NULL
;
21522 if (section
->sh_type
== SHT_NOTE
)
21524 if (! process_notes_at (filedata
, section
,
21525 (bfd_vma
) section
->sh_offset
,
21526 (bfd_vma
) section
->sh_size
,
21527 (bfd_vma
) section
->sh_addralign
))
21532 if (( filedata
->file_header
.e_machine
== EM_V800
21533 || filedata
->file_header
.e_machine
== EM_V850
21534 || filedata
->file_header
.e_machine
== EM_CYGNUS_V850
)
21535 && section
->sh_type
== SHT_RENESAS_INFO
)
21537 if (! process_v850_notes (filedata
,
21538 (bfd_vma
) section
->sh_offset
,
21539 (bfd_vma
) section
->sh_size
))
21546 /* Try processing NOTE segments instead. */
21547 return process_corefile_note_segments (filedata
);
21553 process_notes (Filedata
* filedata
)
21555 /* If we have not been asked to display the notes then do nothing. */
21559 if (filedata
->file_header
.e_type
!= ET_CORE
)
21560 return process_note_sections (filedata
);
21562 /* No program headers means no NOTE segment. */
21563 if (filedata
->file_header
.e_phnum
> 0)
21564 return process_corefile_note_segments (filedata
);
21566 if (filedata
->is_separate
)
21567 printf (_("No notes found in linked file '%s'.\n"),
21568 filedata
->file_name
);
21570 printf (_("No notes found file.\n"));
21575 static unsigned char *
21576 display_public_gnu_attributes (unsigned char * start
,
21577 const unsigned char * const end
)
21579 printf (_(" Unknown GNU attribute: %s\n"), start
);
21581 start
+= strnlen ((char *) start
, end
- start
);
21582 display_raw_attribute (start
, end
);
21584 return (unsigned char *) end
;
21587 static unsigned char *
21588 display_generic_attribute (unsigned char * start
,
21590 const unsigned char * const end
)
21593 return (unsigned char *) end
;
21595 return display_tag_value (tag
, start
, end
);
21599 process_arch_specific (Filedata
* filedata
)
21604 switch (filedata
->file_header
.e_machine
)
21607 case EM_ARC_COMPACT
:
21608 case EM_ARC_COMPACT2
:
21609 return process_attributes (filedata
, "ARC", SHT_ARC_ATTRIBUTES
,
21610 display_arc_attribute
,
21611 display_generic_attribute
);
21613 return process_attributes (filedata
, "aeabi", SHT_ARM_ATTRIBUTES
,
21614 display_arm_attribute
,
21615 display_generic_attribute
);
21618 case EM_MIPS_RS3_LE
:
21619 return process_mips_specific (filedata
);
21622 return process_attributes (filedata
, "mspabi", SHT_MSP430_ATTRIBUTES
,
21623 display_msp430_attribute
,
21624 display_msp430_gnu_attribute
);
21627 return process_attributes (filedata
, "riscv", SHT_RISCV_ATTRIBUTES
,
21628 display_riscv_attribute
,
21629 display_generic_attribute
);
21632 return process_nds32_specific (filedata
);
21635 return process_attributes (filedata
, NULL
, SHT_GNU_ATTRIBUTES
, NULL
,
21636 display_m68k_gnu_attribute
);
21640 return process_attributes (filedata
, NULL
, SHT_GNU_ATTRIBUTES
, NULL
,
21641 display_power_gnu_attribute
);
21645 return process_attributes (filedata
, NULL
, SHT_GNU_ATTRIBUTES
, NULL
,
21646 display_s390_gnu_attribute
);
21649 case EM_SPARC32PLUS
:
21651 return process_attributes (filedata
, NULL
, SHT_GNU_ATTRIBUTES
, NULL
,
21652 display_sparc_gnu_attribute
);
21655 return process_attributes (filedata
, "c6xabi", SHT_C6000_ATTRIBUTES
,
21656 display_tic6x_attribute
,
21657 display_generic_attribute
);
21660 return process_attributes (filedata
, "csky", SHT_CSKY_ATTRIBUTES
,
21661 display_csky_attribute
, NULL
);
21664 return process_attributes (filedata
, "gnu", SHT_GNU_ATTRIBUTES
,
21665 display_public_gnu_attributes
,
21666 display_generic_attribute
);
21671 get_file_header (Filedata
* filedata
)
21673 /* Read in the identity array. */
21674 if (fread (filedata
->file_header
.e_ident
, EI_NIDENT
, 1, filedata
->handle
) != 1)
21677 /* Determine how to read the rest of the header. */
21678 switch (filedata
->file_header
.e_ident
[EI_DATA
])
21683 byte_get
= byte_get_little_endian
;
21684 byte_put
= byte_put_little_endian
;
21687 byte_get
= byte_get_big_endian
;
21688 byte_put
= byte_put_big_endian
;
21692 /* For now we only support 32 bit and 64 bit ELF files. */
21693 is_32bit_elf
= (filedata
->file_header
.e_ident
[EI_CLASS
] != ELFCLASS64
);
21695 /* Read in the rest of the header. */
21698 Elf32_External_Ehdr ehdr32
;
21700 if (fread (ehdr32
.e_type
, sizeof (ehdr32
) - EI_NIDENT
, 1, filedata
->handle
) != 1)
21703 filedata
->file_header
.e_type
= BYTE_GET (ehdr32
.e_type
);
21704 filedata
->file_header
.e_machine
= BYTE_GET (ehdr32
.e_machine
);
21705 filedata
->file_header
.e_version
= BYTE_GET (ehdr32
.e_version
);
21706 filedata
->file_header
.e_entry
= BYTE_GET (ehdr32
.e_entry
);
21707 filedata
->file_header
.e_phoff
= BYTE_GET (ehdr32
.e_phoff
);
21708 filedata
->file_header
.e_shoff
= BYTE_GET (ehdr32
.e_shoff
);
21709 filedata
->file_header
.e_flags
= BYTE_GET (ehdr32
.e_flags
);
21710 filedata
->file_header
.e_ehsize
= BYTE_GET (ehdr32
.e_ehsize
);
21711 filedata
->file_header
.e_phentsize
= BYTE_GET (ehdr32
.e_phentsize
);
21712 filedata
->file_header
.e_phnum
= BYTE_GET (ehdr32
.e_phnum
);
21713 filedata
->file_header
.e_shentsize
= BYTE_GET (ehdr32
.e_shentsize
);
21714 filedata
->file_header
.e_shnum
= BYTE_GET (ehdr32
.e_shnum
);
21715 filedata
->file_header
.e_shstrndx
= BYTE_GET (ehdr32
.e_shstrndx
);
21719 Elf64_External_Ehdr ehdr64
;
21721 /* If we have been compiled with sizeof (bfd_vma) == 4, then
21722 we will not be able to cope with the 64bit data found in
21723 64 ELF files. Detect this now and abort before we start
21724 overwriting things. */
21725 if (sizeof (bfd_vma
) < 8)
21727 error (_("This instance of readelf has been built without support for a\n\
21728 64 bit data type and so it cannot read 64 bit ELF files.\n"));
21732 if (fread (ehdr64
.e_type
, sizeof (ehdr64
) - EI_NIDENT
, 1, filedata
->handle
) != 1)
21735 filedata
->file_header
.e_type
= BYTE_GET (ehdr64
.e_type
);
21736 filedata
->file_header
.e_machine
= BYTE_GET (ehdr64
.e_machine
);
21737 filedata
->file_header
.e_version
= BYTE_GET (ehdr64
.e_version
);
21738 filedata
->file_header
.e_entry
= BYTE_GET (ehdr64
.e_entry
);
21739 filedata
->file_header
.e_phoff
= BYTE_GET (ehdr64
.e_phoff
);
21740 filedata
->file_header
.e_shoff
= BYTE_GET (ehdr64
.e_shoff
);
21741 filedata
->file_header
.e_flags
= BYTE_GET (ehdr64
.e_flags
);
21742 filedata
->file_header
.e_ehsize
= BYTE_GET (ehdr64
.e_ehsize
);
21743 filedata
->file_header
.e_phentsize
= BYTE_GET (ehdr64
.e_phentsize
);
21744 filedata
->file_header
.e_phnum
= BYTE_GET (ehdr64
.e_phnum
);
21745 filedata
->file_header
.e_shentsize
= BYTE_GET (ehdr64
.e_shentsize
);
21746 filedata
->file_header
.e_shnum
= BYTE_GET (ehdr64
.e_shnum
);
21747 filedata
->file_header
.e_shstrndx
= BYTE_GET (ehdr64
.e_shstrndx
);
21754 free_filedata (Filedata
*filedata
)
21756 free (filedata
->program_interpreter
);
21757 free (filedata
->program_headers
);
21758 free (filedata
->section_headers
);
21759 free (filedata
->string_table
);
21760 free (filedata
->dump
.dump_sects
);
21761 free (filedata
->dynamic_strings
);
21762 free (filedata
->dynamic_symbols
);
21763 free (filedata
->dynamic_syminfo
);
21764 free (filedata
->dynamic_section
);
21766 while (filedata
->symtab_shndx_list
!= NULL
)
21768 elf_section_list
*next
= filedata
->symtab_shndx_list
->next
;
21769 free (filedata
->symtab_shndx_list
);
21770 filedata
->symtab_shndx_list
= next
;
21773 free (filedata
->section_headers_groups
);
21775 if (filedata
->section_groups
)
21778 struct group_list
* g
;
21779 struct group_list
* next
;
21781 for (i
= 0; i
< filedata
->group_count
; i
++)
21783 for (g
= filedata
->section_groups
[i
].root
; g
!= NULL
; g
= next
)
21790 free (filedata
->section_groups
);
21792 memset (&filedata
->section_headers
, 0,
21793 sizeof (Filedata
) - offsetof (Filedata
, section_headers
));
21797 close_file (Filedata
* filedata
)
21801 if (filedata
->handle
)
21802 fclose (filedata
->handle
);
21808 close_debug_file (void * data
)
21810 free_filedata ((Filedata
*) data
);
21811 close_file ((Filedata
*) data
);
21815 open_file (const char * pathname
, bool is_separate
)
21817 struct stat statbuf
;
21818 Filedata
* filedata
= NULL
;
21820 if (stat (pathname
, & statbuf
) < 0
21821 || ! S_ISREG (statbuf
.st_mode
))
21824 filedata
= calloc (1, sizeof * filedata
);
21825 if (filedata
== NULL
)
21828 filedata
->handle
= fopen (pathname
, "rb");
21829 if (filedata
->handle
== NULL
)
21832 filedata
->file_size
= (bfd_size_type
) statbuf
.st_size
;
21833 filedata
->file_name
= pathname
;
21834 filedata
->is_separate
= is_separate
;
21836 if (! get_file_header (filedata
))
21839 if (!get_section_headers (filedata
, false))
21847 if (filedata
->handle
)
21848 fclose (filedata
->handle
);
21855 open_debug_file (const char * pathname
)
21857 return open_file (pathname
, true);
21861 initialise_dump_sects (Filedata
* filedata
)
21863 /* Initialise the dump_sects array from the cmdline_dump_sects array.
21864 Note we do this even if cmdline_dump_sects is empty because we
21865 must make sure that the dump_sets array is zeroed out before each
21866 object file is processed. */
21867 if (filedata
->dump
.num_dump_sects
> cmdline
.num_dump_sects
)
21868 memset (filedata
->dump
.dump_sects
, 0,
21869 filedata
->dump
.num_dump_sects
* sizeof (*filedata
->dump
.dump_sects
));
21871 if (cmdline
.num_dump_sects
> 0)
21873 if (filedata
->dump
.num_dump_sects
== 0)
21874 /* A sneaky way of allocating the dump_sects array. */
21875 request_dump_bynumber (&filedata
->dump
, cmdline
.num_dump_sects
, 0);
21877 assert (filedata
->dump
.num_dump_sects
>= cmdline
.num_dump_sects
);
21878 memcpy (filedata
->dump
.dump_sects
, cmdline
.dump_sects
,
21879 cmdline
.num_dump_sects
* sizeof (*filedata
->dump
.dump_sects
));
21883 /* Process one ELF object file according to the command line options.
21884 This file may actually be stored in an archive. The file is
21885 positioned at the start of the ELF object. Returns TRUE if no
21886 problems were encountered, FALSE otherwise. */
21889 process_object (Filedata
* filedata
)
21891 bool have_separate_files
;
21895 if (! get_file_header (filedata
))
21897 error (_("%s: Failed to read file header\n"), filedata
->file_name
);
21901 /* Initialise per file variables. */
21902 for (i
= ARRAY_SIZE (filedata
->version_info
); i
--;)
21903 filedata
->version_info
[i
] = 0;
21905 for (i
= ARRAY_SIZE (filedata
->dynamic_info
); i
--;)
21906 filedata
->dynamic_info
[i
] = 0;
21907 filedata
->dynamic_info_DT_GNU_HASH
= 0;
21908 filedata
->dynamic_info_DT_MIPS_XHASH
= 0;
21910 /* Process the file. */
21912 printf (_("\nFile: %s\n"), filedata
->file_name
);
21914 initialise_dump_sects (filedata
);
21916 /* There may be some extensions in the first section header. Don't
21917 bomb if we can't read it. */
21918 get_section_headers (filedata
, true);
21920 if (! process_file_header (filedata
))
21926 /* Throw away the single section header read above, so that we
21927 re-read the entire set. */
21928 free (filedata
->section_headers
);
21929 filedata
->section_headers
= NULL
;
21931 if (! process_section_headers (filedata
))
21933 /* Without loaded section headers we cannot process lots of things. */
21934 do_unwind
= do_version
= do_dump
= do_arch
= false;
21936 if (! do_using_dynamic
)
21937 do_syms
= do_dyn_syms
= do_reloc
= false;
21940 if (! process_section_groups (filedata
))
21941 /* Without loaded section groups we cannot process unwind. */
21944 process_program_headers (filedata
);
21946 res
= process_dynamic_section (filedata
);
21948 if (! process_relocs (filedata
))
21951 if (! process_unwind (filedata
))
21954 if (! process_symbol_table (filedata
))
21957 if (! process_lto_symbol_tables (filedata
))
21960 if (! process_syminfo (filedata
))
21963 if (! process_version_sections (filedata
))
21966 if (filedata
->file_header
.e_shstrndx
!= SHN_UNDEF
)
21967 have_separate_files
= load_separate_debug_files (filedata
, filedata
->file_name
);
21969 have_separate_files
= false;
21971 if (! process_section_contents (filedata
))
21974 if (have_separate_files
)
21978 for (d
= first_separate_info
; d
!= NULL
; d
= d
->next
)
21980 initialise_dump_sects (d
->handle
);
21982 if (process_links
&& ! process_file_header (d
->handle
))
21984 else if (! process_section_headers (d
->handle
))
21986 else if (! process_section_contents (d
->handle
))
21988 else if (process_links
)
21990 if (! process_section_groups (d
->handle
))
21992 process_program_headers (d
->handle
);
21993 if (! process_dynamic_section (d
->handle
))
21995 if (! process_relocs (d
->handle
))
21997 if (! process_unwind (d
->handle
))
21999 if (! process_symbol_table (d
->handle
))
22001 if (! process_lto_symbol_tables (d
->handle
))
22003 if (! process_syminfo (d
->handle
))
22005 if (! process_version_sections (d
->handle
))
22007 if (! process_notes (d
->handle
))
22012 /* The file handles are closed by the call to free_debug_memory() below. */
22015 if (! process_notes (filedata
))
22018 if (! process_gnu_liblist (filedata
))
22021 if (! process_arch_specific (filedata
))
22025 free_filedata (filedata
);
22027 free_debug_memory ();
22032 /* Process an ELF archive.
22033 On entry the file is positioned just after the ARMAG string.
22034 Returns TRUE upon success, FALSE otherwise. */
22037 process_archive (Filedata
* filedata
, bool is_thin_archive
)
22039 struct archive_info arch
;
22040 struct archive_info nested_arch
;
22046 /* The ARCH structure is used to hold information about this archive. */
22047 arch
.file_name
= NULL
;
22049 arch
.index_array
= NULL
;
22050 arch
.sym_table
= NULL
;
22051 arch
.longnames
= NULL
;
22053 /* The NESTED_ARCH structure is used as a single-item cache of information
22054 about a nested archive (when members of a thin archive reside within
22055 another regular archive file). */
22056 nested_arch
.file_name
= NULL
;
22057 nested_arch
.file
= NULL
;
22058 nested_arch
.index_array
= NULL
;
22059 nested_arch
.sym_table
= NULL
;
22060 nested_arch
.longnames
= NULL
;
22062 if (setup_archive (&arch
, filedata
->file_name
, filedata
->handle
,
22063 filedata
->file_size
, is_thin_archive
,
22064 do_archive_index
) != 0)
22070 if (do_archive_index
)
22072 if (arch
.sym_table
== NULL
)
22073 error (_("%s: unable to dump the index as none was found\n"),
22074 filedata
->file_name
);
22077 unsigned long i
, l
;
22078 unsigned long current_pos
;
22080 printf (_("Index of archive %s: (%lu entries, 0x%lx bytes "
22081 "in the symbol table)\n"),
22082 filedata
->file_name
, (unsigned long) arch
.index_num
,
22085 current_pos
= ftell (filedata
->handle
);
22087 for (i
= l
= 0; i
< arch
.index_num
; i
++)
22090 || (i
> 0 && arch
.index_array
[i
] != arch
.index_array
[i
- 1]))
22093 = get_archive_member_name_at (&arch
, arch
.index_array
[i
],
22096 if (member_name
!= NULL
)
22098 char * qualified_name
22099 = make_qualified_name (&arch
, &nested_arch
,
22102 if (qualified_name
!= NULL
)
22104 printf (_("Contents of binary %s at offset "),
22106 (void) print_vma (arch
.index_array
[i
], PREFIX_HEX
);
22108 free (qualified_name
);
22110 free (member_name
);
22114 if (l
>= arch
.sym_size
)
22116 error (_("%s: end of the symbol table reached "
22117 "before the end of the index\n"),
22118 filedata
->file_name
);
22122 /* PR 17531: file: 0b6630b2. */
22123 printf ("\t%.*s\n",
22124 (int) (arch
.sym_size
- l
), arch
.sym_table
+ l
);
22125 l
+= strnlen (arch
.sym_table
+ l
, arch
.sym_size
- l
) + 1;
22128 if (arch
.uses_64bit_indices
)
22133 if (l
< arch
.sym_size
)
22135 error (ngettext ("%s: %ld byte remains in the symbol table, "
22136 "but without corresponding entries in "
22137 "the index table\n",
22138 "%s: %ld bytes remain in the symbol table, "
22139 "but without corresponding entries in "
22140 "the index table\n",
22141 arch
.sym_size
- l
),
22142 filedata
->file_name
, arch
.sym_size
- l
);
22146 if (fseek (filedata
->handle
, current_pos
, SEEK_SET
) != 0)
22148 error (_("%s: failed to seek back to start of object files "
22149 "in the archive\n"),
22150 filedata
->file_name
);
22156 if (!do_dynamic
&& !do_syms
&& !do_reloc
&& !do_unwind
&& !do_sections
22157 && !do_segments
&& !do_header
&& !do_dump
&& !do_version
22158 && !do_histogram
&& !do_debugging
&& !do_arch
&& !do_notes
22159 && !do_section_groups
&& !do_dyn_syms
)
22161 ret
= true; /* Archive index only. */
22170 char * qualified_name
;
22172 /* Read the next archive header. */
22173 if (fseek (filedata
->handle
, arch
.next_arhdr_offset
, SEEK_SET
) != 0)
22175 error (_("%s: failed to seek to next archive header\n"),
22180 got
= fread (&arch
.arhdr
, 1, sizeof arch
.arhdr
, filedata
->handle
);
22181 if (got
!= sizeof arch
.arhdr
)
22185 /* PR 24049 - we cannot use filedata->file_name as this will
22186 have already been freed. */
22187 error (_("%s: failed to read archive header\n"), arch
.file_name
);
22192 if (memcmp (arch
.arhdr
.ar_fmag
, ARFMAG
, 2) != 0)
22194 error (_("%s: did not find a valid archive header\n"),
22200 arch
.next_arhdr_offset
+= sizeof arch
.arhdr
;
22202 filedata
->archive_file_size
= strtoul (arch
.arhdr
.ar_size
, NULL
, 10);
22204 name
= get_archive_member_name (&arch
, &nested_arch
);
22207 error (_("%s: bad archive file name\n"), arch
.file_name
);
22211 namelen
= strlen (name
);
22213 qualified_name
= make_qualified_name (&arch
, &nested_arch
, name
);
22214 if (qualified_name
== NULL
)
22216 error (_("%s: bad archive file name\n"), arch
.file_name
);
22222 if (is_thin_archive
&& arch
.nested_member_origin
== 0)
22224 /* This is a proxy for an external member of a thin archive. */
22225 Filedata
* member_filedata
;
22226 char * member_file_name
= adjust_relative_path
22227 (filedata
->file_name
, name
, namelen
);
22230 if (member_file_name
== NULL
)
22232 free (qualified_name
);
22237 member_filedata
= open_file (member_file_name
, false);
22238 if (member_filedata
== NULL
)
22240 error (_("Input file '%s' is not readable.\n"), member_file_name
);
22241 free (member_file_name
);
22242 free (qualified_name
);
22247 filedata
->archive_file_offset
= arch
.nested_member_origin
;
22248 member_filedata
->file_name
= qualified_name
;
22250 /* The call to process_object() expects the file to be at the beginning. */
22251 rewind (member_filedata
->handle
);
22253 if (! process_object (member_filedata
))
22256 close_file (member_filedata
);
22257 free (member_file_name
);
22259 else if (is_thin_archive
)
22261 Filedata thin_filedata
;
22263 memset (&thin_filedata
, 0, sizeof (thin_filedata
));
22265 /* PR 15140: Allow for corrupt thin archives. */
22266 if (nested_arch
.file
== NULL
)
22268 error (_("%s: contains corrupt thin archive: %s\n"),
22269 qualified_name
, name
);
22270 free (qualified_name
);
22277 /* This is a proxy for a member of a nested archive. */
22278 filedata
->archive_file_offset
22279 = arch
.nested_member_origin
+ sizeof arch
.arhdr
;
22281 /* The nested archive file will have been opened and setup by
22282 get_archive_member_name. */
22283 if (fseek (nested_arch
.file
, filedata
->archive_file_offset
,
22286 error (_("%s: failed to seek to archive member.\n"),
22287 nested_arch
.file_name
);
22288 free (qualified_name
);
22293 thin_filedata
.handle
= nested_arch
.file
;
22294 thin_filedata
.file_name
= qualified_name
;
22296 if (! process_object (& thin_filedata
))
22302 filedata
->archive_file_offset
= arch
.next_arhdr_offset
;
22303 filedata
->file_name
= qualified_name
;
22304 if (! process_object (filedata
))
22306 arch
.next_arhdr_offset
+= (filedata
->archive_file_size
+ 1) & -2;
22307 /* Stop looping with "negative" archive_file_size. */
22308 if (arch
.next_arhdr_offset
< filedata
->archive_file_size
)
22309 arch
.next_arhdr_offset
= -1ul;
22312 free (qualified_name
);
22316 if (nested_arch
.file
!= NULL
)
22317 fclose (nested_arch
.file
);
22318 release_archive (&nested_arch
);
22319 release_archive (&arch
);
22325 process_file (char * file_name
)
22327 Filedata
* filedata
= NULL
;
22328 struct stat statbuf
;
22329 char armag
[SARMAG
];
22332 if (stat (file_name
, &statbuf
) < 0)
22334 if (errno
== ENOENT
)
22335 error (_("'%s': No such file\n"), file_name
);
22337 error (_("Could not locate '%s'. System error message: %s\n"),
22338 file_name
, strerror (errno
));
22342 if (! S_ISREG (statbuf
.st_mode
))
22344 error (_("'%s' is not an ordinary file\n"), file_name
);
22348 filedata
= calloc (1, sizeof * filedata
);
22349 if (filedata
== NULL
)
22351 error (_("Out of memory allocating file data structure\n"));
22355 filedata
->file_name
= file_name
;
22356 filedata
->handle
= fopen (file_name
, "rb");
22357 if (filedata
->handle
== NULL
)
22359 error (_("Input file '%s' is not readable.\n"), file_name
);
22364 if (fread (armag
, SARMAG
, 1, filedata
->handle
) != 1)
22366 error (_("%s: Failed to read file's magic number\n"), file_name
);
22367 fclose (filedata
->handle
);
22372 filedata
->file_size
= (bfd_size_type
) statbuf
.st_size
;
22373 filedata
->is_separate
= false;
22375 if (memcmp (armag
, ARMAG
, SARMAG
) == 0)
22377 if (! process_archive (filedata
, false))
22380 else if (memcmp (armag
, ARMAGT
, SARMAG
) == 0)
22382 if ( ! process_archive (filedata
, true))
22387 if (do_archive_index
&& !check_all
)
22388 error (_("File %s is not an archive so its index cannot be displayed.\n"),
22391 rewind (filedata
->handle
);
22392 filedata
->archive_file_size
= filedata
->archive_file_offset
= 0;
22394 if (! process_object (filedata
))
22398 fclose (filedata
->handle
);
22399 free (filedata
->section_headers
);
22400 free (filedata
->program_headers
);
22401 free (filedata
->string_table
);
22402 free (filedata
->dump
.dump_sects
);
22405 free (ba_cache
.strtab
);
22406 ba_cache
.strtab
= NULL
;
22407 free (ba_cache
.symtab
);
22408 ba_cache
.symtab
= NULL
;
22409 ba_cache
.filedata
= NULL
;
22414 #ifdef SUPPORT_DISASSEMBLY
22415 /* Needed by the i386 disassembler. For extra credit, someone could
22416 fix this so that we insert symbolic addresses here, esp for GOT/PLT
22420 print_address (unsigned int addr
, FILE * outfile
)
22422 fprintf (outfile
,"0x%8.8x", addr
);
22425 /* Needed by the i386 disassembler. */
22428 db_task_printsym (unsigned int addr
)
22430 print_address (addr
, stderr
);
22435 main (int argc
, char ** argv
)
22439 #ifdef HAVE_LC_MESSAGES
22440 setlocale (LC_MESSAGES
, "");
22442 setlocale (LC_CTYPE
, "");
22443 bindtextdomain (PACKAGE
, LOCALEDIR
);
22444 textdomain (PACKAGE
);
22446 expandargv (&argc
, &argv
);
22448 parse_args (& cmdline
, argc
, argv
);
22450 if (optind
< (argc
- 1))
22451 /* When displaying information for more than one file,
22452 prefix the information with the file name. */
22454 else if (optind
>= argc
)
22456 /* Ensure that the warning is always displayed. */
22459 warn (_("Nothing to do.\n"));
22464 while (optind
< argc
)
22465 if (! process_file (argv
[optind
++]))
22468 free (cmdline
.dump_sects
);
22470 free (dump_ctf_symtab_name
);
22471 free (dump_ctf_strtab_name
);
22472 free (dump_ctf_parent_name
);
22474 return err
? EXIT_FAILURE
: EXIT_SUCCESS
;