/* readelf.c -- display contents of an ELF format file
- Copyright (C) 1998-2020 Free Software Foundation, Inc.
+ Copyright (C) 1998-2021 Free Software Foundation, Inc.
Originally developed by Eric Youngdale <eric@andante.jic.com>
Modifications by Nick Clifton <nickc@redhat.com>
#include "elfcomm.h"
#include "dwarf.h"
#include "ctf-api.h"
+#include "demangle.h"
#include "elf/common.h"
#include "elf/external.h"
static bfd_boolean do_dynamic = FALSE;
static bfd_boolean do_syms = FALSE;
static bfd_boolean do_dyn_syms = FALSE;
+static bfd_boolean do_lto_syms = FALSE;
static bfd_boolean do_reloc = FALSE;
static bfd_boolean do_sections = FALSE;
static bfd_boolean do_section_groups = FALSE;
static bfd_boolean check_all = FALSE;
static bfd_boolean is_32bit_elf = FALSE;
static bfd_boolean decompress_dumps = FALSE;
+static bfd_boolean do_not_show_symbol_truncation = FALSE;
+static bfd_boolean do_demangle = FALSE; /* Pretty print C++ symbol names. */
+static int demangle_flags = DMGL_ANSI | DMGL_PARAMS;
static char *dump_ctf_parent_name;
static char *dump_ctf_symtab_name;
#define UNKNOWN -1
-#define SECTION_NAME(X) \
- ((X) == NULL ? _("<none>") \
- : filedata->string_table == NULL ? _("<no-strings>") \
- : ((X)->sh_name >= filedata->string_table_length ? _("<corrupt>") \
- : filedata->string_table + (X)->sh_name))
+#define SECTION_NAME(X) \
+ (filedata->string_table + (X)->sh_name)
+
+#define SECTION_NAME_VALID(X) \
+ ((X) != NULL \
+ && filedata->string_table != NULL \
+ && (X)->sh_name < filedata->string_table_length)
+
+#define SECTION_NAME_PRINT(X) \
+ ((X) == NULL ? _("<none>") \
+ : filedata->string_table == NULL ? _("<no-strings>") \
+ : (X)->sh_name >= filedata->string_table_length ? _("<corrupt>") \
+ : filedata->string_table + (X)->sh_name)
#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
Display at most abs(WIDTH) characters, truncating as necessary, unless do_wide is true.
+ If truncation will happen and do_not_show_symbol_truncation is FALSE then display
+ abs(WIDTH) - 5 characters followed by "[...]".
+
If WIDTH is negative then ensure that the output is at least (- WIDTH) characters,
padding as necessary.
Returns the number of emitted characters. */
static unsigned int
-print_symbol (signed int width, const char *symbol)
+print_symbol (signed int width, const char * symbol)
{
bfd_boolean extra_padding = FALSE;
+ bfd_boolean do_dots = FALSE;
signed int num_printed = 0;
#ifdef HAVE_MBSTATE_T
mbstate_t state;
#endif
unsigned int width_remaining;
+ const void * alloced_symbol = NULL;
if (width < 0)
{
This simplifies the code below. */
width_remaining = INT_MAX;
else
- width_remaining = width;
+ {
+ width_remaining = width;
+ if (! do_not_show_symbol_truncation
+ && (int) strlen (symbol) > width)
+ {
+ width_remaining -= 5;
+ if ((int) width_remaining < 0)
+ width_remaining = 0;
+ do_dots = TRUE;
+ }
+ }
#ifdef HAVE_MBSTATE_T
/* Initialise the multibyte conversion state. */
memset (& state, 0, sizeof (state));
#endif
+ if (do_demangle && *symbol)
+ {
+ const char * res = cplus_demangle (symbol, demangle_flags);
+
+ if (res != NULL)
+ alloced_symbol = symbol = res;
+ }
+
while (width_remaining)
{
size_t n;
}
}
+ if (do_dots)
+ num_printed += printf ("[...]");
+
if (extra_padding && num_printed < width)
{
/* Fill in the remaining spaces. */
num_printed = width;
}
+ free ((void *) alloced_symbol);
return num_printed;
}
{
#define MAX_PRINT_SEC_NAME_LEN 128
static char sec_name_buf [MAX_PRINT_SEC_NAME_LEN + 1];
- const char * name = SECTION_NAME (sec);
+ const char * name = SECTION_NAME_PRINT (sec);
char * buf = sec_name_buf;
char c;
unsigned int remaining = MAX_PRINT_SEC_NAME_LEN;
return NULL;
for (i = 0; i < filedata->file_header.e_shnum; i++)
- if (streq (SECTION_NAME (filedata->section_headers + i), name))
+ if (SECTION_NAME_VALID (filedata->section_headers + i)
+ && streq (SECTION_NAME (filedata->section_headers + i), name))
return filedata->section_headers + i;
return NULL;
if (i >= filedata->file_header.e_shnum)
continue; /* FIXME: Should we issue an error message ? */
- if (streq (SECTION_NAME (filedata->section_headers + i), name))
+ if (SECTION_NAME_VALID (filedata->section_headers + i)
+ && streq (SECTION_NAME (filedata->section_headers + i), name))
return filedata->section_headers + i;
}
}
}
else
{
-#if BFD_HOST_64BIT_LONG
- printf (do_wide
- ? "%16.16lx %16.16lx "
- : "%12.12lx %12.12lx ",
- offset, inf);
-#elif BFD_HOST_64BIT_LONG_LONG
-#ifndef __MSVCRT__
printf (do_wide
- ? "%16.16llx %16.16llx "
- : "%12.12llx %12.12llx ",
+ ? "%16.16" BFD_VMA_FMT "x %16.16" BFD_VMA_FMT "x "
+ : "%12.12" BFD_VMA_FMT "x %12.12" BFD_VMA_FMT "x ",
offset, inf);
-#else
- printf (do_wide
- ? "%16.16I64x %16.16I64x "
- : "%12.12I64x %12.12I64x ",
- offset, inf);
-#endif
-#else
- printf (do_wide
- ? "%8.8lx%8.8lx %8.8lx%8.8lx "
- : "%4.4lx%8.8lx %4.4lx%8.8lx ",
- _bfd_int64_high (offset),
- _bfd_int64_low (offset),
- _bfd_int64_high (inf),
- _bfd_int64_low (inf));
-#endif
}
switch (filedata->file_header.e_machine)
if (ELF_ST_TYPE (psym->st_info) == STT_SECTION)
{
if (psym->st_shndx < filedata->file_header.e_shnum)
- sec_name = SECTION_NAME (filedata->section_headers + psym->st_shndx);
+ sec_name = SECTION_NAME_PRINT (filedata->section_headers
+ + psym->st_shndx);
else if (psym->st_shndx == SHN_ABS)
sec_name = "ABS";
else if (psym->st_shndx == SHN_COMMON)
case DT_GNU_LIBLIST: return "GNU_LIBLIST";
case DT_GNU_LIBLISTSZ: return "GNU_LIBLISTSZ";
case DT_GNU_HASH: return "GNU_HASH";
+ case DT_GNU_FLAGS_1: return "GNU_FLAGS_1";
default:
if ((type >= DT_LOPROC) && (type <= DT_HIPROC))
case EM_FT32: return "FTDI Chip FT32";
case EM_MOXIE: return "Moxie";
case EM_AMDGPU: return "AMD GPU";
+ /* 230 (all reserved) */
+ /* 240 */
case EM_RISCV: return "RISC-V";
case EM_LANAI: return "Lanai 32-bit processor";
+ case EM_CEVA: return "CEVA Processor Architecture Family";
+ case EM_CEVA_X2: return "CEVA X2 Processor Family";
case EM_BPF: return "Linux BPF";
+ case EM_GRAPHCORE_IPU: return "Graphcore Intelligent Processing Unit";
+ case EM_IMG1: return "Imagination Technologies";
+ /* 250 */
case EM_NFP: return "Netronome Flow Processor";
+ case EM_VE: return "NEC Vector Engine";
+ case EM_CSKY: return "C-SKY";
+ case EM_ARC_COMPACT3_64: return "Synopsys ARCv2.3 64-bit";
+ case EM_MCS6502: return "MOS Technology MCS 6502 processor";
+ case EM_ARC_COMPACT3: return "Synopsys ARCv2.3 32-bit";
+ case EM_KVX: return "Kalray VLIW core of the MPPA processor family";
+ case EM_65816: return "WDC 65816/65C816";
+ case EM_LOONGARCH: return "Loongson Loongarch";
+ case EM_KF32: return "ChipON KungFu32";
/* Large numbers... */
case EM_MT: return "Morpho Techologies MT processor";
case EM_ADAPTEVA_EPIPHANY: return "Adapteva EPIPHANY";
case EM_CYGNUS_FRV: return "Fujitsu FR-V";
case EM_S12Z: return "Freescale S12Z";
- case EM_CSKY: return "C-SKY";
default:
snprintf (buff, sizeof (buff), _("<unknown>: 0x%x"), e_machine);
case PT_GNU_RELRO: return "GNU_RELRO";
case PT_GNU_PROPERTY: return "GNU_PROPERTY";
+ case PT_OPENBSD_RANDOMIZE: return "OPENBSD_RANDOMIZE";
+ case PT_OPENBSD_WXNEEDED: return "OPENBSD_WXNEEDED";
+ case PT_OPENBSD_BOOTDATA: return "OPENBSD_BOOTDATA";
+
default:
if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
{
}
static const char *
-get_msp430x_section_type_name (unsigned int sh_type)
+get_msp430_section_type_name (unsigned int sh_type)
{
switch (sh_type)
{
}
}
+static const char *
+get_csky_section_type_name (unsigned int sh_type)
+{
+ switch (sh_type)
+ {
+ case SHT_CSKY_ATTRIBUTES: return "CSKY_ATTRIBUTES";
+ default: return NULL;
+ }
+}
+
static const char *
get_section_type_name (Filedata * filedata, unsigned int sh_type)
{
result = get_tic6x_section_type_name (sh_type);
break;
case EM_MSP430:
- result = get_msp430x_section_type_name (sh_type);
+ result = get_msp430_section_type_name (sh_type);
break;
case EM_NFP:
result = get_nfp_section_type_name (sh_type);
case EM_RISCV:
result = get_riscv_section_type_name (sh_type);
break;
+ case EM_CSKY:
+ result = get_csky_section_type_name (sh_type);
+ break;
default:
result = NULL;
break;
}
}
-#define OPTION_DEBUG_DUMP 512
-#define OPTION_DYN_SYMS 513
-#define OPTION_DWARF_DEPTH 514
-#define OPTION_DWARF_START 515
-#define OPTION_DWARF_CHECK 516
-#define OPTION_CTF_DUMP 517
-#define OPTION_CTF_PARENT 518
-#define OPTION_CTF_SYMBOLS 519
-#define OPTION_CTF_STRINGS 520
+enum long_option_values
+{
+ OPTION_DEBUG_DUMP = 512,
+ OPTION_DYN_SYMS,
+ OPTION_LTO_SYMS,
+ OPTION_DWARF_DEPTH,
+ OPTION_DWARF_START,
+ OPTION_DWARF_CHECK,
+ OPTION_CTF_DUMP,
+ OPTION_CTF_PARENT,
+ OPTION_CTF_SYMBOLS,
+ OPTION_CTF_STRINGS,
+ OPTION_WITH_SYMBOL_VERSIONS,
+ OPTION_RECURSE_LIMIT,
+ OPTION_NO_RECURSE_LIMIT,
+ OPTION_NO_DEMANGLING
+};
static struct option options[] =
{
+ /* Note - This table is alpha-sorted on the 'val'
+ field in order to make adding new options easier. */
+ {"arch-specific", no_argument, 0, 'A'},
{"all", no_argument, 0, 'a'},
- {"file-header", no_argument, 0, 'h'},
- {"program-headers", no_argument, 0, 'l'},
+ {"demangle", optional_argument, 0, 'C'},
+ {"archive-index", no_argument, 0, 'c'},
+ {"use-dynamic", no_argument, 0, 'D'},
+ {"dynamic", no_argument, 0, 'd'},
{"headers", no_argument, 0, 'e'},
+ {"section-groups", no_argument, 0, 'g'},
+ {"help", no_argument, 0, 'H'},
+ {"file-header", no_argument, 0, 'h'},
{"histogram", no_argument, 0, 'I'},
+ {"lint", no_argument, 0, 'L'},
+ {"enable-checks", no_argument, 0, 'L'},
+ {"program-headers", no_argument, 0, 'l'},
{"segments", no_argument, 0, 'l'},
- {"sections", no_argument, 0, 'S'},
- {"section-headers", no_argument, 0, 'S'},
- {"section-groups", no_argument, 0, 'g'},
- {"section-details", no_argument, 0, 't'},
{"full-section-name",no_argument, 0, 'N'},
+ {"notes", no_argument, 0, 'n'},
+ {"string-dump", required_argument, 0, 'p'},
+ {"relocated-dump", required_argument, 0, 'R'},
+ {"relocs", no_argument, 0, 'r'},
+ {"section-headers", no_argument, 0, 'S'},
+ {"sections", no_argument, 0, 'S'},
{"symbols", no_argument, 0, 's'},
{"syms", no_argument, 0, 's'},
- {"dyn-syms", no_argument, 0, OPTION_DYN_SYMS},
- {"relocs", no_argument, 0, 'r'},
- {"notes", no_argument, 0, 'n'},
- {"dynamic", no_argument, 0, 'd'},
- {"lint", no_argument, 0, 'L'},
- {"enable-checks", no_argument, 0, 'L'},
- {"arch-specific", no_argument, 0, 'A'},
- {"version-info", no_argument, 0, 'V'},
- {"use-dynamic", no_argument, 0, 'D'},
+ {"silent-truncation",no_argument, 0, 'T'},
+ {"section-details", no_argument, 0, 't'},
{"unwind", no_argument, 0, 'u'},
- {"archive-index", no_argument, 0, 'c'},
+ {"version-info", no_argument, 0, 'V'},
+ {"version", no_argument, 0, 'v'},
+ {"wide", no_argument, 0, 'W'},
{"hex-dump", required_argument, 0, 'x'},
- {"relocated-dump", required_argument, 0, 'R'},
- {"string-dump", required_argument, 0, 'p'},
{"decompress", no_argument, 0, 'z'},
-#ifdef SUPPORT_DISASSEMBLY
- {"instruction-dump", required_argument, 0, 'i'},
-#endif
- {"debug-dump", optional_argument, 0, OPTION_DEBUG_DUMP},
+ {"no-demangle", no_argument, 0, OPTION_NO_DEMANGLING},
+ {"recurse-limit", no_argument, NULL, OPTION_RECURSE_LIMIT},
+ {"no-recurse-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
+ {"no-recursion-limit", no_argument, NULL, OPTION_NO_RECURSE_LIMIT},
+ {"dyn-syms", no_argument, 0, OPTION_DYN_SYMS},
+ {"lto-syms", no_argument, 0, OPTION_LTO_SYMS},
+ {"debug-dump", optional_argument, 0, OPTION_DEBUG_DUMP},
{"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH},
{"dwarf-start", required_argument, 0, OPTION_DWARF_START},
{"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
-
#ifdef ENABLE_LIBCTF
{"ctf", required_argument, 0, OPTION_CTF_DUMP},
-
{"ctf-symbols", required_argument, 0, OPTION_CTF_SYMBOLS},
{"ctf-strings", required_argument, 0, OPTION_CTF_STRINGS},
{"ctf-parent", required_argument, 0, OPTION_CTF_PARENT},
#endif
- {"version", no_argument, 0, 'v'},
- {"wide", no_argument, 0, 'W'},
- {"help", no_argument, 0, 'H'},
{0, no_argument, 0, 0}
};
-s --syms Display the symbol table\n\
--symbols An alias for --syms\n\
--dyn-syms Display the dynamic symbol table\n\
+ --lto-syms Display LTO symbol tables\n\
+ -C --demangle[=STYLE] Decode low-level symbol names into user-level names\n\
+ The STYLE, if specified, can be `auto' (the default),\n\
+ `gnu', `lucid', `arm', `hp', `edg', `gnu-v3', `java'\n\
+ or `gnat'\n\
+ --no-demangle Do not demangle low-level symbol names. (This is the default)\n\
+ --recurse-limit Enable a demangling recursion limit. (This is the default)\n\
+ --no-recurse-limit Disable a demangling recursion limit\n\
-n --notes Display the core notes (if present)\n\
-r --relocs Display the relocations (if present)\n\
-u --unwind Display the unwind info (if present)\n\
fprintf (stream, _("\
-I --histogram Display histogram of bucket list lengths\n\
-W --wide Allow output width to exceed 80 characters\n\
+ -T --silent-truncation If a symbol name is truncated, do not add a suffix [...]\n\
@<file> Read options from <file>\n\
-H --help Display this information\n\
-v --version Display the version number of readelf\n"));
usage (stderr);
while ((c = getopt_long
- (argc, argv, "ADHILNR:SVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
+ (argc, argv, "ACDHILNR:STVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
{
switch (c)
{
do_arch = TRUE;
do_notes = TRUE;
break;
+
case 'g':
do_section_groups = TRUE;
break;
break;
case 'w':
do_dump = TRUE;
- if (optarg == 0)
+ if (optarg == NULL)
{
do_debugging = TRUE;
dwarf_select_sections_all ();
break;
case OPTION_DEBUG_DUMP:
do_dump = TRUE;
- if (optarg == 0)
+ if (optarg == NULL)
do_debugging = TRUE;
else
{
request_dump (dumpdata, CTF_DUMP);
break;
case OPTION_CTF_SYMBOLS:
+ free (dump_ctf_symtab_name);
dump_ctf_symtab_name = strdup (optarg);
break;
case OPTION_CTF_STRINGS:
+ free (dump_ctf_strtab_name);
dump_ctf_strtab_name = strdup (optarg);
break;
case OPTION_CTF_PARENT:
+ free (dump_ctf_parent_name);
dump_ctf_parent_name = strdup (optarg);
break;
case OPTION_DYN_SYMS:
do_dyn_syms = TRUE;
break;
+ case OPTION_LTO_SYMS:
+ do_lto_syms = TRUE;
+ break;
#ifdef SUPPORT_DISASSEMBLY
case 'i':
request_dump (dumpdata, DISASS_DUMP);
case 'W':
do_wide = TRUE;
break;
+ case 'T':
+ do_not_show_symbol_truncation = TRUE;
+ break;
+ case 'C':
+ do_demangle = TRUE;
+ if (optarg != NULL)
+ {
+ enum demangling_styles style;
+
+ style = cplus_demangle_name_to_style (optarg);
+ if (style == unknown_demangling)
+ error (_("unknown demangling style `%s'"), optarg);
+
+ cplus_demangle_set_style (style);
+ }
+ break;
+ case OPTION_NO_DEMANGLING:
+ do_demangle = FALSE;
+ break;
+ case OPTION_RECURSE_LIMIT:
+ demangle_flags &= ~ DMGL_NO_RECURSE_LIMIT;
+ break;
+ case OPTION_NO_RECURSE_LIMIT:
+ demangle_flags |= DMGL_NO_RECURSE_LIMIT;
+ break;
+ case OPTION_WITH_SYMBOL_VERSIONS:
+ /* Ignored for backward compatibility. */
+ break;
+
default:
/* xgettext:c-format */
error (_("Invalid option '-%c'\n"), c);
&& !do_segments && !do_header && !do_dump && !do_version
&& !do_histogram && !do_debugging && !do_arch && !do_notes
&& !do_section_groups && !do_archive_index
- && !do_dyn_syms)
+ && !do_dyn_syms && !do_lto_syms)
{
if (do_checks)
{
do_segments = do_header = do_dump = do_version = TRUE;
do_histogram = do_debugging = do_arch = do_notes = TRUE;
do_section_groups = do_archive_index = do_dyn_syms = TRUE;
+ do_lto_syms = TRUE;
}
else
usage (stderr);
/* 24 */ { STRING_COMMA_LEN ("GNU_MBIND") },
/* VLE specific. */
/* 25 */ { STRING_COMMA_LEN ("VLE") },
+ /* GNU specific. */
+ /* 26 */ { STRING_COMMA_LEN ("GNU_RETAIN") },
};
if (do_section_details)
case SHF_TLS: sindex = 9; break;
case SHF_EXCLUDE: sindex = 18; break;
case SHF_COMPRESSED: sindex = 20; break;
- case SHF_GNU_MBIND: sindex = 24; break;
default:
sindex = -1;
if (flag == SHF_PPC_VLE)
sindex = 25;
break;
+ default:
+ break;
+ }
+ switch (filedata->file_header.e_ident[EI_OSABI])
+ {
+ case ELFOSABI_GNU:
+ case ELFOSABI_FREEBSD:
+ if (flag == SHF_GNU_RETAIN)
+ sindex = 26;
+ /* Fall through */
+ case ELFOSABI_NONE:
+ if (flag == SHF_GNU_MBIND)
+ /* We should not recognize SHF_GNU_MBIND for
+ ELFOSABI_NONE, but binutils as of 2019-07-23 did
+ not set the EI_OSABI header byte. */
+ sindex = 24;
+ break;
default:
break;
}
+ break;
}
if (sindex != -1)
case SHF_TLS: *p = 'T'; break;
case SHF_EXCLUDE: *p = 'E'; break;
case SHF_COMPRESSED: *p = 'C'; break;
- case SHF_GNU_MBIND: *p = 'D'; break;
default:
if ((filedata->file_header.e_machine == EM_X86_64
*p = 'l';
else if (filedata->file_header.e_machine == EM_ARM
&& flag == SHF_ARM_PURECODE)
- *p = 'y';
+ *p = 'y';
else if (filedata->file_header.e_machine == EM_PPC
&& flag == SHF_PPC_VLE)
- *p = 'v';
+ *p = 'v';
else if (flag & SHF_MASKOS)
{
- *p = 'o';
- sh_flags &= ~ SHF_MASKOS;
+ switch (filedata->file_header.e_ident[EI_OSABI])
+ {
+ case ELFOSABI_GNU:
+ case ELFOSABI_FREEBSD:
+ if (flag == SHF_GNU_RETAIN)
+ {
+ *p = 'R';
+ break;
+ }
+ /* Fall through */
+ case ELFOSABI_NONE:
+ if (flag == SHF_GNU_MBIND)
+ {
+ /* We should not recognize SHF_GNU_MBIND for
+ ELFOSABI_NONE, but binutils as of 2019-07-23 did
+ not set the EI_OSABI header byte. */
+ *p = 'D';
+ break;
+ }
+ /* Fall through */
+ default:
+ *p = 'o';
+ sh_flags &= ~SHF_MASKOS;
+ break;
+ }
}
else if (flag & SHF_MASKPROC)
{
i < filedata->file_header.e_shnum;
i++, section++)
{
- char * name = SECTION_NAME (section);
+ char * name = SECTION_NAME_PRINT (section);
/* Run some sanity checks on the headers and
possibly fill in some file data as well. */
if (do_section_details)
printf ("%s\n ", printable_section_name (filedata, section));
else
- print_symbol (-17, SECTION_NAME (section));
+ print_symbol (-17, SECTION_NAME_PRINT (section));
printf (do_wide ? " %-15s " : " %-15.15s ",
get_section_type_name (filedata, section->sh_type));
continue;
}
- group_name = SECTION_NAME (filedata->section_headers + sym->st_shndx);
+ group_name = SECTION_NAME_PRINT (filedata->section_headers
+ + sym->st_shndx);
strtab_sec = NULL;
free (strtab);
strtab = NULL;
{
sec = filedata->section_headers + g->section_index;
- if (streq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info))
+ if (SECTION_NAME_VALID (sec)
+ && streq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info))
break;
}
i = filedata->file_header.e_shnum;
}
}
- else if (strneq (SECTION_NAME (unwsec), ELF_STRING_ia64_unwind_once, len))
+ else if (SECTION_NAME_VALID (unwsec)
+ && strneq (SECTION_NAME (unwsec),
+ ELF_STRING_ia64_unwind_once, len))
{
/* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO. */
len2 = sizeof (ELF_STRING_ia64_unwind_info_once) - 1;
suffix = SECTION_NAME (unwsec) + len;
- for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum;
+ for (i = 0, sec = filedata->section_headers;
+ i < filedata->file_header.e_shnum;
++i, ++sec)
- if (strneq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info_once, len2)
+ if (SECTION_NAME_VALID (sec)
+ && strneq (SECTION_NAME (sec),
+ ELF_STRING_ia64_unwind_info_once, len2)
&& streq (SECTION_NAME (sec) + len2, suffix))
break;
}
len = sizeof (ELF_STRING_ia64_unwind) - 1;
len2 = sizeof (ELF_STRING_ia64_unwind_info) - 1;
suffix = "";
- if (strneq (SECTION_NAME (unwsec), ELF_STRING_ia64_unwind, len))
+ if (SECTION_NAME_VALID (unwsec)
+ && strneq (SECTION_NAME (unwsec), ELF_STRING_ia64_unwind, len))
suffix = SECTION_NAME (unwsec) + len;
- for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum;
+ for (i = 0, sec = filedata->section_headers;
+ i < filedata->file_header.e_shnum;
++i, ++sec)
- if (strneq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info, len2)
+ if (SECTION_NAME_VALID (sec)
+ && strneq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info, len2)
&& streq (SECTION_NAME (sec) + len2, suffix))
break;
}
nentries = size / unw_ent_size;
size = unw_ent_size * nentries;
+ aux->table_len = nentries;
tep = aux->table = (struct hppa_unw_table_entry *)
xcmalloc (nentries, sizeof (aux->table[0]));
free (rela);
}
- aux->table_len = nentries;
-
return TRUE;
}
&aux.strtab, &aux.strtab_size))
return FALSE;
}
- else if (streq (SECTION_NAME (sec), ".PARISC.unwind"))
+ else if (SECTION_NAME_VALID (sec)
+ && streq (SECTION_NAME (sec), ".PARISC.unwind"))
unwsec = sec;
}
for (i = 0, sec = filedata->section_headers; i < filedata->file_header.e_shnum; ++i, ++sec)
{
- if (streq (SECTION_NAME (sec), ".PARISC.unwind"))
+ if (SECTION_NAME_VALID (sec)
+ && streq (SECTION_NAME (sec), ".PARISC.unwind"))
{
unsigned long num_unwind = sec->sh_size / 16;
#define VMS_EPOCH_OFFSET 35067168000000000LL
#define VMS_GRANULARITY_FACTOR 10000000
+#ifndef INT64_MIN
+#define INT64_MIN (-9223372036854775807LL - 1)
+#endif
/* Display a VMS time in a human readable format. */
static void
print_vms_time (bfd_int64_t vmstime)
{
- struct tm *tm;
+ struct tm *tm = NULL;
time_t unxtime;
- unxtime = (vmstime - VMS_EPOCH_OFFSET) / VMS_GRANULARITY_FACTOR;
- tm = gmtime (&unxtime);
- printf ("%04u-%02u-%02uT%02u:%02u:%02u",
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min, tm->tm_sec);
+ if (vmstime >= INT64_MIN + VMS_EPOCH_OFFSET)
+ {
+ vmstime = (vmstime - VMS_EPOCH_OFFSET) / VMS_GRANULARITY_FACTOR;
+ unxtime = vmstime;
+ if (unxtime == vmstime)
+ tm = gmtime (&unxtime);
+ }
+ if (tm != NULL)
+ printf ("%04u-%02u-%02uT%02u:%02u:%02u",
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
}
#endif /* BFD64 */
}
break;
+ case DT_GNU_FLAGS_1:
+ if (do_dynamic)
+ {
+ printf (_("Flags:"));
+ if (entry->d_un.d_val == 0)
+ printf (_(" None\n"));
+ else
+ {
+ unsigned long int val = entry->d_un.d_val;
+
+ if (val & DF_GNU_1_UNIQUE)
+ {
+ printf (" UNIQUE");
+ val ^= DF_GNU_1_UNIQUE;
+ }
+ if (val != 0)
+ printf (" %lx", val);
+ puts ("");
+ }
+ }
+ break;
+
default:
if ((entry->d_tag >= DT_VERSYM) && (entry->d_tag <= DT_VERNEEDNUM))
filedata->version_info[DT_VERSIONTAGIDX (entry->d_tag)]
}
if (j < ent.vn_cnt)
- warn (_("Missing Version Needs auxillary information\n"));
+ warn (_("Missing Version Needs auxiliary information\n"));
if (ent.vn_next < sizeof (*entry)
&& !(cnt == section->sh_info - 1 && ent.vn_next == 0))
printf (" [%s] ", get_symbol_other (filedata, psym->st_other ^ vis));
}
printf (" %4s ", get_symbol_index_type (filedata, psym->st_shndx));
- print_symbol (25, VALID_SYMBOL_NAME (strtab, strtab_size,
- psym->st_name)
- ? strtab + psym->st_name : _("<corrupt>"));
+
+ bfd_boolean is_valid = VALID_SYMBOL_NAME (strtab, strtab_size,
+ psym->st_name);
+ const char * sstr = is_valid ? strtab + psym->st_name : _("<corrupt>");
version_string
= get_symbol_version_string (filedata,
|| section->sh_type == SHT_DYNSYM),
strtab, strtab_size, si,
psym, &sym_info, &vna_other);
+
+ int len_avail = 21;
+ if (! do_wide && version_string != NULL)
+ {
+ char buffer[16];
+
+ len_avail -= 1 + strlen (version_string);
+
+ if (sym_info == symbol_undefined)
+ len_avail -= sprintf (buffer," (%d)", vna_other);
+ else if (sym_info != symbol_hidden)
+ len_avail -= 1;
+ }
+
+ print_symbol (len_avail, sstr);
+
if (version_string)
{
if (sym_info == symbol_undefined)
si, printable_section_name (filedata, section), section->sh_info);
}
+static const char *
+get_lto_kind (unsigned int kind)
+{
+ switch (kind)
+ {
+ case 0: return "DEF";
+ case 1: return "WEAKDEF";
+ case 2: return "UNDEF";
+ case 3: return "WEAKUNDEF";
+ case 4: return "COMMON";
+ default:
+ break;
+ }
+
+ static char buffer[30];
+ error (_("Unknown LTO symbol definition encountered: %u\n"), kind);
+ sprintf (buffer, "<unknown: %u>", kind);
+ return buffer;
+}
+
+static const char *
+get_lto_visibility (unsigned int visibility)
+{
+ switch (visibility)
+ {
+ case 0: return "DEFAULT";
+ case 1: return "PROTECTED";
+ case 2: return "INTERNAL";
+ case 3: return "HIDDEN";
+ default:
+ break;
+ }
+
+ static char buffer[30];
+ error (_("Unknown LTO symbol visibility encountered: %u\n"), visibility);
+ sprintf (buffer, "<unknown: %u>", visibility);
+ return buffer;
+}
+
+static const char *
+get_lto_sym_type (unsigned int sym_type)
+{
+ switch (sym_type)
+ {
+ case 0: return "UNKNOWN";
+ case 1: return "FUNCTION";
+ case 2: return "VARIABLE";
+ default:
+ break;
+ }
+
+ static char buffer[30];
+ error (_("Unknown LTO symbol type encountered: %u\n"), sym_type);
+ sprintf (buffer, "<unknown: %u>", sym_type);
+ return buffer;
+}
+
+/* Display an LTO format symbol table.
+ FIXME: The format of LTO symbol tables is not formalized.
+ So this code could need changing in the future. */
+
+static bfd_boolean
+display_lto_symtab (Filedata * filedata,
+ Elf_Internal_Shdr * section)
+{
+ if (section->sh_size == 0)
+ {
+ printf (_("\nLTO Symbol table '%s' is empty!\n"),
+ printable_section_name (filedata, section));
+ return TRUE;
+ }
+
+ if (section->sh_size > filedata->file_size)
+ {
+ error (_("Section %s has an invalid sh_size of 0x%lx\n"),
+ printable_section_name (filedata, section),
+ (unsigned long) section->sh_size);
+ return FALSE;
+ }
+
+ void * alloced_data = get_data (NULL, filedata, section->sh_offset,
+ section->sh_size, 1, _("LTO symbols"));
+ if (alloced_data == NULL)
+ return FALSE;
+
+ /* Look for extended data for the symbol table. */
+ Elf_Internal_Shdr * ext;
+ void * ext_data_orig = NULL;
+ char * ext_data = NULL;
+ char * ext_data_end = NULL;
+ char * ext_name = NULL;
+
+ if (asprintf (& ext_name, ".gnu.lto_.ext_symtab.%s",
+ SECTION_NAME (section) + sizeof (".gnu.lto_.symtab.") - 1) > 0
+ && ext_name != NULL /* Paranoia. */
+ && (ext = find_section (filedata, ext_name)) != NULL)
+ {
+ if (ext->sh_size < 3)
+ error (_("LTO Symbol extension table '%s' is empty!\n"),
+ printable_section_name (filedata, ext));
+ else
+ {
+ ext_data_orig = ext_data = get_data (NULL, filedata, ext->sh_offset,
+ ext->sh_size, 1,
+ _("LTO ext symbol data"));
+ if (ext_data != NULL)
+ {
+ ext_data_end = ext_data + ext->sh_size;
+ if (* ext_data++ != 1)
+ error (_("Unexpected version number in symbol extension table\n"));
+ }
+ }
+ }
+
+ const unsigned char * data = (const unsigned char *) alloced_data;
+ const unsigned char * end = data + section->sh_size;
+
+ if (ext_data_orig != NULL)
+ {
+ if (do_wide)
+ printf (_("\nLTO Symbol table '%s' and extension table '%s' contain:\n"),
+ printable_section_name (filedata, section),
+ printable_section_name (filedata, ext));
+ else
+ {
+ printf (_("\nLTO Symbol table '%s'\n"),
+ printable_section_name (filedata, section));
+ printf (_(" and extension table '%s' contain:\n"),
+ printable_section_name (filedata, ext));
+ }
+ }
+ else
+ printf (_("\nLTO Symbol table '%s' contains:\n"),
+ printable_section_name (filedata, section));
+
+
+ /* FIXME: Add a wide version. */
+ if (ext_data_orig != NULL)
+ printf (_(" Comdat_Key Kind Visibility Size Slot Type Section Name\n"));
+ else
+ printf (_(" Comdat_Key Kind Visibility Size Slot Name\n"));
+
+ /* FIXME: We do not handle style prefixes. */
+
+ while (data < end)
+ {
+ const unsigned char * sym_name = data;
+ data += strnlen ((const char *) sym_name, end - data) + 1;
+ if (data >= end)
+ goto fail;
+
+ const unsigned char * comdat_key = data;
+ data += strnlen ((const char *) comdat_key, end - data) + 1;
+ if (data >= end)
+ goto fail;
+
+ if (data + 2 + 8 + 4 > end)
+ goto fail;
+
+ unsigned int kind = *data++;
+ unsigned int visibility = *data++;
+
+ elf_vma size = byte_get (data, 8);
+ data += 8;
+
+ elf_vma slot = byte_get (data, 4);
+ data += 4;
+
+ if (ext_data != NULL)
+ {
+ if (ext_data < (ext_data_end - 1))
+ {
+ unsigned int sym_type = * ext_data ++;
+ unsigned int sec_kind = * ext_data ++;
+
+ printf (" %10s %10s %11s %08lx %08lx %9s %08lx _",
+ * comdat_key == 0 ? "-" : (char *) comdat_key,
+ get_lto_kind (kind),
+ get_lto_visibility (visibility),
+ (long) size,
+ (long) slot,
+ get_lto_sym_type (sym_type),
+ (long) sec_kind);
+ print_symbol (6, (const char *) sym_name);
+ }
+ else
+ {
+ error (_("Ran out of LTO symbol extension data\n"));
+ ext_data = NULL;
+ /* FIXME: return FAIL result ? */
+ }
+ }
+ else
+ {
+ printf (" %10s %10s %11s %08lx %08lx _",
+ * comdat_key == 0 ? "-" : (char *) comdat_key,
+ get_lto_kind (kind),
+ get_lto_visibility (visibility),
+ (long) size,
+ (long) slot);
+ print_symbol (21, (const char *) sym_name);
+ }
+ putchar ('\n');
+ }
+
+ if (ext_data != NULL && ext_data < ext_data_end)
+ {
+ error (_("Data remains in the LTO symbol extension table\n"));
+ goto fail;
+ }
+
+ free (alloced_data);
+ free (ext_data_orig);
+ free (ext_name);
+ return TRUE;
+
+ fail:
+ error (_("Buffer overrun encountered whilst decoding LTO symbol table\n"));
+ free (alloced_data);
+ free (ext_data_orig);
+ free (ext_name);
+ return FALSE;
+}
+
+/* Display LTO symbol tables. */
+
+static bfd_boolean
+process_lto_symbol_tables (Filedata * filedata)
+{
+ Elf_Internal_Shdr * section;
+ unsigned int i;
+ bfd_boolean res = TRUE;
+
+ if (!do_lto_syms)
+ return TRUE;
+
+ if (filedata->section_headers == NULL)
+ return TRUE;
+
+ for (i = 0, section = filedata->section_headers;
+ i < filedata->file_header.e_shnum;
+ i++, section++)
+ if (SECTION_NAME_VALID (section)
+ && CONST_STRNEQ (SECTION_NAME (section), ".gnu.lto_.symtab."))
+ res &= display_lto_symtab (filedata, section);
+
+ return res;
+}
+
/* Dump the symbol table. */
+
static bfd_boolean
process_symbol_table (Filedata * filedata)
{
switch (reloc_type)
{
case 10: /* R_MSP430_SYM_DIFF */
+ case 12: /* R_MSP430_GNU_SUB_ULEB128 */
if (uses_msp430x_relocs (filedata))
break;
/* Fall through. */
case 21: /* R_MSP430X_SYM_DIFF */
+ case 23: /* R_MSP430X_GNU_SUB_ULEB128 */
/* PR 21139. */
if (sym_index >= num_syms)
error (_("MSP430 SYM_DIFF reloc contains invalid symbol index %lu\n"),
case 5: /* R_MSP430_16_BYTE */
case 9: /* R_MSP430_8 */
+ case 11: /* R_MSP430_GNU_SET_ULEB128 */
if (uses_msp430x_relocs (filedata))
break;
goto handle_sym_diff;
case 2: /* R_MSP430_ABS16 */
case 15: /* R_MSP430X_ABS16 */
+ case 22: /* R_MSP430X_GNU_SET_ULEB128 */
if (! uses_msp430x_relocs (filedata))
break;
goto handle_sym_diff;
handle_sym_diff:
if (saved_sym != NULL)
{
- int reloc_size = reloc_type == 1 ? 4 : 2;
bfd_vma value;
+ unsigned int reloc_size = 0;
+ int leb_ret = 0;
+ switch (reloc_type)
+ {
+ case 1: /* R_MSP430_32 or R_MSP430_ABS32 */
+ reloc_size = 4;
+ break;
+ case 11: /* R_MSP430_GNU_SET_ULEB128 */
+ case 22: /* R_MSP430X_GNU_SET_ULEB128 */
+ if (reloc->r_offset < (size_t) (end - start))
+ read_leb128 (start + reloc->r_offset, end, FALSE,
+ &reloc_size, &leb_ret);
+ break;
+ default:
+ reloc_size = 2;
+ break;
+ }
- if (sym_index >= num_syms)
+ if (leb_ret != 0 || reloc_size == 0 || reloc_size > 8)
+ error (_("MSP430 ULEB128 field at 0x%lx contains invalid "
+ "ULEB128 value\n"),
+ (long) reloc->r_offset);
+ else if (sym_index >= num_syms)
error (_("MSP430 reloc contains invalid symbol index %lu\n"),
sym_index);
else
}
else
{
-#ifndef __MSVCRT__
- /* PR 11128: Use two separate invocations in order to work
- around bugs in the Solaris 8 implementation of printf. */
- printf (" [%6tx] ", data - start);
-#else
- printf (" [%6Ix] ", (size_t) (data - start));
-#endif
+ printf (" [%6lx] ", (unsigned long) (data - start));
}
if (maxlen > 0)
{
- char c;
+ char c = 0;
while (maxlen)
{
static ctf_sect_t *
shdr_to_ctf_sect (ctf_sect_t *buf, Elf_Internal_Shdr *shdr, Filedata *filedata)
{
- buf->cts_name = SECTION_NAME (shdr);
+ buf->cts_name = SECTION_NAME_PRINT (shdr);
buf->cts_size = shdr->sh_size;
buf->cts_entsize = shdr->sh_entsize;
it is passed, or a pointer to newly-allocated storage, in which case
dump_ctf() will free it when it no longer needs it. */
-static char *dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,
- char *s, void *arg)
+static char *
+dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,
+ char *s, void *arg)
{
const char *blanks = arg;
char *new_s;
return new_s;
}
+/* Dump CTF errors/warnings. */
+static void
+dump_ctf_errs (ctf_dict_t *fp)
+{
+ ctf_next_t *it = NULL;
+ char *errtext;
+ int is_warning;
+ int err;
+
+ /* Dump accumulated errors and warnings. */
+ while ((errtext = ctf_errwarning_next (fp, &it, &is_warning, &err)) != NULL)
+ {
+ error (_("%s: %s"), is_warning ? _("warning"): _("error"),
+ errtext);
+ free (errtext);
+ }
+ if (err != ECTF_NEXT_END)
+ error (_("CTF error: cannot get CTF errors: `%s'"), ctf_errmsg (err));
+}
+
+/* Dump one CTF archive member. */
+
+static int
+dump_ctf_archive_member (ctf_dict_t *ctf, const char *name, void *arg)
+{
+ ctf_dict_t *parent = (ctf_dict_t *) arg;
+ const char *things[] = {"Header", "Labels", "Data objects",
+ "Function objects", "Variables", "Types", "Strings",
+ ""};
+ const char **thing;
+ size_t i;
+ int err = 0;
+
+ /* Only print out the name of non-default-named archive members.
+ The name .ctf appears everywhere, even for things that aren't
+ really archives, so printing it out is liable to be confusing.
+
+ The parent, if there is one, is the default-owned archive member:
+ avoid importing it into itself. (This does no harm, but looks
+ confusing.) */
+
+ if (strcmp (name, ".ctf") != 0)
+ {
+ printf (_("\nCTF archive member: %s:\n"), name);
+ ctf_import (ctf, parent);
+ }
+
+ for (i = 0, thing = things; *thing[0]; thing++, i++)
+ {
+ ctf_dump_state_t *s = NULL;
+ char *item;
+
+ printf ("\n %s:\n", *thing);
+ while ((item = ctf_dump (ctf, &s, i, dump_ctf_indent_lines,
+ (void *) " ")) != NULL)
+ {
+ printf ("%s\n", item);
+ free (item);
+ }
+
+ if (ctf_errno (ctf))
+ {
+ error (_("Iteration failed: %s, %s\n"), *thing,
+ ctf_errmsg (ctf_errno (ctf)));
+ err = 1;
+ goto out;
+ }
+ }
+
+ out:
+ dump_ctf_errs (ctf);
+ return err;
+}
+
static bfd_boolean
dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
{
ctf_sect_t ctfsect, symsect, strsect, parentsect;
ctf_sect_t * symsectp = NULL;
ctf_sect_t * strsectp = NULL;
- ctf_file_t * ctf = NULL;
- ctf_file_t * parent = NULL;
+ ctf_archive_t * ctfa = NULL;
+ ctf_archive_t * parenta = NULL, *lookparent;
+ ctf_dict_t * parent = NULL;
- const char *things[] = {"Header", "Labels", "Data objects",
- "Function objects", "Variables", "Types", "Strings",
- ""};
- const char **thing;
int err;
bfd_boolean ret = FALSE;
- size_t i;
shdr_to_ctf_sect (&ctfsect, section, filedata);
data = get_section_contents (section, filedata);
ctfsect.cts_data = data;
if (!dump_ctf_symtab_name)
- dump_ctf_symtab_name = strdup (".symtab");
+ dump_ctf_symtab_name = strdup (".dynsym");
if (!dump_ctf_strtab_name)
- dump_ctf_strtab_name = strdup (".strtab");
+ dump_ctf_strtab_name = strdup (".dynstr");
if (dump_ctf_symtab_name && dump_ctf_symtab_name[0] != 0)
{
symsectp = shdr_to_ctf_sect (&symsect, symtab_sec, filedata);
symsect.cts_data = symdata;
}
- if (dump_ctf_strtab_name && dump_ctf_symtab_name[0] != 0)
+ if (dump_ctf_strtab_name && dump_ctf_strtab_name[0] != 0)
{
if ((strtab_sec = find_section (filedata, dump_ctf_strtab_name)) == NULL)
{
parentsect.cts_data = parentdata;
}
- /* Load the CTF file and dump it. */
+ /* Load the CTF file and dump it. It may be a raw CTF section, or an archive:
+ libctf papers over the difference, so we can pretend it is always an
+ archive. Possibly open the parent as well, if one was specified. */
- if ((ctf = ctf_bufopen (&ctfsect, symsectp, strsectp, &err)) == NULL)
+ if ((ctfa = ctf_arc_bufopen (&ctfsect, symsectp, strsectp, &err)) == NULL)
{
+ dump_ctf_errs (NULL);
error (_("CTF open failure: %s\n"), ctf_errmsg (err));
goto fail;
}
+ ctf_arc_symsect_endianness (ctfa, filedata->file_header.e_ident[EI_DATA]
+ != ELFDATA2MSB);
+
if (parentdata)
{
- if ((parent = ctf_bufopen (&parentsect, symsectp, strsectp, &err)) == NULL)
+ if ((parenta = ctf_arc_bufopen (&parentsect, symsectp, strsectp,
+ &err)) == NULL)
{
+ dump_ctf_errs (NULL);
error (_("CTF open failure: %s\n"), ctf_errmsg (err));
goto fail;
}
+ lookparent = parenta;
+ }
+ else
+ lookparent = ctfa;
- ctf_import (ctf, parent);
+ /* Assume that the applicable parent archive member is the default one.
+ (This is what all known implementations are expected to do, if they
+ put CTFs and their parents in archives together.) */
+ if ((parent = ctf_dict_open (lookparent, NULL, &err)) == NULL)
+ {
+ dump_ctf_errs (NULL);
+ error (_("CTF open failure: %s\n"), ctf_errmsg (err));
+ goto fail;
}
ret = TRUE;
printf (_("\nDump of CTF section '%s':\n"),
printable_section_name (filedata, section));
- for (i = 0, thing = things; *thing[0]; thing++, i++)
+ if ((err = ctf_archive_iter (ctfa, dump_ctf_archive_member, parent)) != 0)
{
- ctf_dump_state_t *s = NULL;
- char *item;
-
- printf ("\n %s:\n", *thing);
- while ((item = ctf_dump (ctf, &s, i, dump_ctf_indent_lines,
- (void *) " ")) != NULL)
- {
- printf ("%s\n", item);
- free (item);
- }
-
- if (ctf_errno (ctf))
- {
- error (_("Iteration failed: %s, %s\n"), *thing,
- ctf_errmsg (ctf_errno (ctf)));
- ret = FALSE;
- }
+ dump_ctf_errs (NULL);
+ error (_("CTF member open failure: %s\n"), ctf_errmsg (err));
+ ret = FALSE;
}
fail:
- ctf_file_close (ctf);
- ctf_file_close (parent);
+ ctf_dict_close (parent);
+ ctf_close (ctfa);
+ ctf_close (parenta);
free (parentdata);
free (data);
free (symdata);
static bfd_boolean
display_debug_section (int shndx, Elf_Internal_Shdr * section, Filedata * filedata)
{
- char * name = SECTION_NAME (section);
+ char * name = SECTION_NAME_VALID (section) ? SECTION_NAME (section) : "";
const char * print_name = printable_section_name (filedata, section);
bfd_size_type length;
bfd_boolean result = TRUE;
bfd_boolean any = FALSE;
for (i = 0; i < filedata->file_header.e_shnum; i++)
- if (streq (SECTION_NAME (filedata->section_headers + i), cur->name))
+ if (SECTION_NAME_VALID (filedata->section_headers + i)
+ && streq (SECTION_NAME (filedata->section_headers + i), cur->name))
{
request_dump_bynumber (&filedata->dump, i, cur->type);
any = TRUE;
const char * name;
/* 0 = special, 1 = string, 2 = uleb123, > 0x80 == table lookup. */
unsigned int type;
- const char ** table;
+ const char *const *table;
} arm_attr_public_tag;
-static const char * arm_attr_tag_CPU_arch[] =
+static const char *const arm_attr_tag_CPU_arch[] =
{"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2",
"v6K", "v7", "v6-M", "v6S-M", "v7E-M", "v8", "v8-R", "v8-M.baseline",
"v8-M.mainline", "", "", "", "v8.1-M.mainline"};
-static const char * arm_attr_tag_ARM_ISA_use[] = {"No", "Yes"};
-static const char * arm_attr_tag_THUMB_ISA_use[] =
+static const char *const arm_attr_tag_ARM_ISA_use[] = {"No", "Yes"};
+static const char *const arm_attr_tag_THUMB_ISA_use[] =
{"No", "Thumb-1", "Thumb-2", "Yes"};
-static const char * arm_attr_tag_FP_arch[] =
+static const char *const arm_attr_tag_FP_arch[] =
{"No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16", "VFPv4", "VFPv4-D16",
"FP for ARMv8", "FPv5/FP-D16 for ARMv8"};
-static const char * arm_attr_tag_WMMX_arch[] = {"No", "WMMXv1", "WMMXv2"};
-static const char * arm_attr_tag_Advanced_SIMD_arch[] =
+static const char *const arm_attr_tag_WMMX_arch[] = {"No", "WMMXv1", "WMMXv2"};
+static const char *const arm_attr_tag_Advanced_SIMD_arch[] =
{"No", "NEONv1", "NEONv1 with Fused-MAC", "NEON for ARMv8",
"NEON for ARMv8.1"};
-static const char * arm_attr_tag_PCS_config[] =
+static const char *const arm_attr_tag_PCS_config[] =
{"None", "Bare platform", "Linux application", "Linux DSO", "PalmOS 2004",
"PalmOS (reserved)", "SymbianOS 2004", "SymbianOS (reserved)"};
-static const char * arm_attr_tag_ABI_PCS_R9_use[] =
+static const char *const arm_attr_tag_ABI_PCS_R9_use[] =
{"V6", "SB", "TLS", "Unused"};
-static const char * arm_attr_tag_ABI_PCS_RW_data[] =
+static const char *const arm_attr_tag_ABI_PCS_RW_data[] =
{"Absolute", "PC-relative", "SB-relative", "None"};
-static const char * arm_attr_tag_ABI_PCS_RO_data[] =
+static const char *const arm_attr_tag_ABI_PCS_RO_data[] =
{"Absolute", "PC-relative", "None"};
-static const char * arm_attr_tag_ABI_PCS_GOT_use[] =
+static const char *const arm_attr_tag_ABI_PCS_GOT_use[] =
{"None", "direct", "GOT-indirect"};
-static const char * arm_attr_tag_ABI_PCS_wchar_t[] =
+static const char *const arm_attr_tag_ABI_PCS_wchar_t[] =
{"None", "??? 1", "2", "??? 3", "4"};
-static const char * arm_attr_tag_ABI_FP_rounding[] = {"Unused", "Needed"};
-static const char * arm_attr_tag_ABI_FP_denormal[] =
+static const char *const arm_attr_tag_ABI_FP_rounding[] = {"Unused", "Needed"};
+static const char *const arm_attr_tag_ABI_FP_denormal[] =
{"Unused", "Needed", "Sign only"};
-static const char * arm_attr_tag_ABI_FP_exceptions[] = {"Unused", "Needed"};
-static const char * arm_attr_tag_ABI_FP_user_exceptions[] = {"Unused", "Needed"};
-static const char * arm_attr_tag_ABI_FP_number_model[] =
+static const char *const arm_attr_tag_ABI_FP_exceptions[] = {"Unused", "Needed"};
+static const char *const arm_attr_tag_ABI_FP_user_exceptions[] = {"Unused", "Needed"};
+static const char *const arm_attr_tag_ABI_FP_number_model[] =
{"Unused", "Finite", "RTABI", "IEEE 754"};
-static const char * arm_attr_tag_ABI_enum_size[] =
+static const char *const arm_attr_tag_ABI_enum_size[] =
{"Unused", "small", "int", "forced to int"};
-static const char * arm_attr_tag_ABI_HardFP_use[] =
+static const char *const arm_attr_tag_ABI_HardFP_use[] =
{"As Tag_FP_arch", "SP only", "Reserved", "Deprecated"};
-static const char * arm_attr_tag_ABI_VFP_args[] =
+static const char *const arm_attr_tag_ABI_VFP_args[] =
{"AAPCS", "VFP registers", "custom", "compatible"};
-static const char * arm_attr_tag_ABI_WMMX_args[] =
+static const char *const arm_attr_tag_ABI_WMMX_args[] =
{"AAPCS", "WMMX registers", "custom"};
-static const char * arm_attr_tag_ABI_optimization_goals[] =
+static const char *const arm_attr_tag_ABI_optimization_goals[] =
{"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
"Aggressive Size", "Prefer Debug", "Aggressive Debug"};
-static const char * arm_attr_tag_ABI_FP_optimization_goals[] =
+static const char *const arm_attr_tag_ABI_FP_optimization_goals[] =
{"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
"Aggressive Size", "Prefer Accuracy", "Aggressive Accuracy"};
-static const char * arm_attr_tag_CPU_unaligned_access[] = {"None", "v6"};
-static const char * arm_attr_tag_FP_HP_extension[] =
+static const char *const arm_attr_tag_CPU_unaligned_access[] = {"None", "v6"};
+static const char *const arm_attr_tag_FP_HP_extension[] =
{"Not Allowed", "Allowed"};
-static const char * arm_attr_tag_ABI_FP_16bit_format[] =
+static const char *const arm_attr_tag_ABI_FP_16bit_format[] =
{"None", "IEEE 754", "Alternative Format"};
-static const char * arm_attr_tag_DSP_extension[] =
+static const char *const arm_attr_tag_DSP_extension[] =
{"Follow architecture", "Allowed"};
-static const char * arm_attr_tag_MPextension_use[] =
+static const char *const arm_attr_tag_MPextension_use[] =
{"Not Allowed", "Allowed"};
-static const char * arm_attr_tag_DIV_use[] =
+static const char *const arm_attr_tag_DIV_use[] =
{"Allowed in Thumb-ISA, v7-R or v7-M", "Not allowed",
"Allowed in v7-A with integer division extension"};
-static const char * arm_attr_tag_T2EE_use[] = {"Not Allowed", "Allowed"};
-static const char * arm_attr_tag_Virtualization_use[] =
+static const char *const arm_attr_tag_T2EE_use[] = {"Not Allowed", "Allowed"};
+static const char *const arm_attr_tag_Virtualization_use[] =
{"Not Allowed", "TrustZone", "Virtualization Extensions",
"TrustZone and Virtualization Extensions"};
-static const char * arm_attr_tag_MPextension_use_legacy[] =
+static const char *const arm_attr_tag_MPextension_use_legacy[] =
{"Not Allowed", "Allowed"};
-static const char * arm_attr_tag_MVE_arch[] =
+static const char *const arm_attr_tag_MVE_arch[] =
{"No MVE", "MVE Integer only", "MVE Integer and FP"};
#define LOOKUP(id, name) \
}
static unsigned char *
-display_msp430x_attribute (unsigned char * p,
+display_msp430_attribute (unsigned char * p,
const unsigned char * const end)
{
unsigned int val;
return p;
}
+static unsigned char *
+display_csky_attribute (unsigned char * p,
+ const unsigned char * const end)
+{
+ unsigned int tag;
+ unsigned int val;
+ READ_ULEB (tag, p, end);
+
+ if (tag >= Tag_CSKY_MAX)
+ {
+ return display_tag_value (-1, p, end);
+ }
+
+ switch (tag)
+ {
+ case Tag_CSKY_ARCH_NAME:
+ printf (" Tag_CSKY_ARCH_NAME:\t\t");
+ return display_tag_value (-1, p, end);
+ case Tag_CSKY_CPU_NAME:
+ printf (" Tag_CSKY_CPU_NAME:\t\t");
+ return display_tag_value (-1, p, end);
+
+ case Tag_CSKY_ISA_FLAGS:
+ printf (" Tag_CSKY_ISA_FLAGS:\t\t");
+ return display_tag_value (0, p, end);
+ case Tag_CSKY_ISA_EXT_FLAGS:
+ printf (" Tag_CSKY_ISA_EXT_FLAGS:\t");
+ return display_tag_value (0, p, end);
+
+ case Tag_CSKY_DSP_VERSION:
+ printf (" Tag_CSKY_DSP_VERSION:\t\t");
+ READ_ULEB (val, p, end);
+ if (val == VAL_CSKY_DSP_VERSION_EXTENSION)
+ printf ("DSP Extension\n");
+ else if (val == VAL_CSKY_DSP_VERSION_2)
+ printf ("DSP 2.0\n");
+ break;
+
+ case Tag_CSKY_VDSP_VERSION:
+ printf (" Tag_CSKY_VDSP_VERSION:\t");
+ READ_ULEB (val, p, end);
+ printf ("VDSP Version %d\n", val);
+ break;
+
+ case Tag_CSKY_FPU_VERSION:
+ printf (" Tag_CSKY_FPU_VERSION:\t\t");
+ READ_ULEB (val, p, end);
+ if (val == VAL_CSKY_FPU_VERSION_1)
+ printf ("ABIV1 FPU Version 1\n");
+ else if (val == VAL_CSKY_FPU_VERSION_2)
+ printf ("FPU Version 2\n");
+ break;
+
+ case Tag_CSKY_FPU_ABI:
+ printf (" Tag_CSKY_FPU_ABI:\t\t");
+ READ_ULEB (val, p, end);
+ if (val == VAL_CSKY_FPU_ABI_HARD)
+ printf ("Hard\n");
+ else if (val == VAL_CSKY_FPU_ABI_SOFTFP)
+ printf ("SoftFP\n");
+ else if (val == VAL_CSKY_FPU_ABI_SOFT)
+ printf ("Soft\n");
+ break;
+ case Tag_CSKY_FPU_ROUNDING:
+ READ_ULEB (val, p, end);
+ if (val == 1) {
+ printf (" Tag_CSKY_FPU_ROUNDING:\t");
+ printf ("Needed\n");
+ }
+ break;
+ case Tag_CSKY_FPU_DENORMAL:
+ READ_ULEB (val, p, end);
+ if (val == 1) {
+ printf (" Tag_CSKY_FPU_DENORMAL:\t");
+ printf ("Needed\n");
+ }
+ break;
+ case Tag_CSKY_FPU_Exception:
+ READ_ULEB (val, p, end);
+ if (val == 1) {
+ printf (" Tag_CSKY_FPU_Exception:\t");
+ printf ("Needed\n");
+ }
+ break;
+ case Tag_CSKY_FPU_NUMBER_MODULE:
+ printf (" Tag_CSKY_FPU_NUMBER_MODULE:\t");
+ return display_tag_value (-1, p, end);
+ case Tag_CSKY_FPU_HARDFP:
+ printf (" Tag_CSKY_FPU_HARDFP:\t\t");
+ READ_ULEB (val, p, end);
+ if (val & VAL_CSKY_FPU_HARDFP_HALF)
+ printf (" Half");
+ if (val & VAL_CSKY_FPU_HARDFP_SINGLE)
+ printf (" Single");
+ if (val & VAL_CSKY_FPU_HARDFP_DOUBLE)
+ printf (" Double");
+ printf ("\n");
+ break;
+ default:
+ return display_tag_value (tag, p, end);
+ }
+ return p;
+}
+
static bfd_boolean
process_attributes (Filedata * filedata,
const char * public_name,
data = (unsigned char *) get_data (NULL, filedata, offset, end - mips_pltgot,
1, _("Procedure Linkage Table data"));
if (data == NULL)
- return FALSE;
+ {
+ free (rels);
+ return FALSE;
+ }
printf ("\nPLT GOT:\n\n");
printf (_(" Reserved entries:\n"));
return _("NT_386_IOPERM (x86 I/O permissions)");
case NT_X86_XSTATE:
return _("NT_X86_XSTATE (x86 XSAVE extended state)");
+ case NT_X86_CET:
+ return _("NT_X86_CET (x86 CET state)");
case NT_S390_HIGH_GPRS:
return _("NT_S390_HIGH_GPRS (s390 upper register halves)");
case NT_S390_TIMER:
}
static void
-decode_x86_isa (unsigned int bitmask)
+decode_x86_compat_2_isa (unsigned int bitmask)
{
if (!bitmask)
{
bitmask &= ~ bit;
switch (bit)
{
- case GNU_PROPERTY_X86_ISA_1_CMOV:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_CMOV:
printf ("CMOV");
break;
- case GNU_PROPERTY_X86_ISA_1_SSE:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE:
printf ("SSE");
break;
- case GNU_PROPERTY_X86_ISA_1_SSE2:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE2:
printf ("SSE2");
break;
- case GNU_PROPERTY_X86_ISA_1_SSE3:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE3:
printf ("SSE3");
break;
- case GNU_PROPERTY_X86_ISA_1_SSSE3:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSSE3:
printf ("SSSE3");
break;
- case GNU_PROPERTY_X86_ISA_1_SSE4_1:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE4_1:
printf ("SSE4_1");
break;
- case GNU_PROPERTY_X86_ISA_1_SSE4_2:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_SSE4_2:
printf ("SSE4_2");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX:
printf ("AVX");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX2:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX2:
printf ("AVX2");
break;
- case GNU_PROPERTY_X86_ISA_1_FMA:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_FMA:
printf ("FMA");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512F:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512F:
printf ("AVX512F");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512CD:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512CD:
printf ("AVX512CD");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512ER:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512ER:
printf ("AVX512ER");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512PF:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512PF:
printf ("AVX512PF");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512VL:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512VL:
printf ("AVX512VL");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512DQ:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512DQ:
printf ("AVX512DQ");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512BW:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512BW:
printf ("AVX512BW");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_4FMAPS:
printf ("AVX512_4FMAPS");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_4VNNIW:
printf ("AVX512_4VNNIW");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512_BITALG:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_BITALG:
printf ("AVX512_BITALG");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512_IFMA:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_IFMA:
printf ("AVX512_IFMA");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512_VBMI:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_VBMI:
printf ("AVX512_VBMI");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_VBMI2:
printf ("AVX512_VBMI2");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512_VNNI:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_VNNI:
printf ("AVX512_VNNI");
break;
- case GNU_PROPERTY_X86_ISA_1_AVX512_BF16:
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_AVX512_BF16:
printf ("AVX512_BF16");
break;
default:
}
}
+static void
+decode_x86_isa (unsigned int bitmask)
+{
+ while (bitmask)
+ {
+ unsigned int bit = bitmask & (- bitmask);
+
+ bitmask &= ~ bit;
+ switch (bit)
+ {
+ case GNU_PROPERTY_X86_ISA_1_BASELINE:
+ printf ("x86-64-baseline");
+ break;
+ case GNU_PROPERTY_X86_ISA_1_V2:
+ printf ("x86-64-v2");
+ break;
+ case GNU_PROPERTY_X86_ISA_1_V3:
+ printf ("x86-64-v3");
+ break;
+ case GNU_PROPERTY_X86_ISA_1_V4:
+ printf ("x86-64-v4");
+ break;
+ default:
+ printf (_("<unknown: %x>"), bit);
+ break;
+ }
+ if (bitmask)
+ printf (", ");
+ }
+}
+
static void
decode_x86_feature_1 (unsigned int bitmask)
{
case GNU_PROPERTY_X86_FEATURE_1_SHSTK:
printf ("SHSTK");
break;
+ case GNU_PROPERTY_X86_FEATURE_1_LAM_U48:
+ printf ("LAM_U48");
+ break;
+ case GNU_PROPERTY_X86_FEATURE_1_LAM_U57:
+ printf ("LAM_U57");
+ break;
default:
printf (_("<unknown: %x>"), bit);
break;
case GNU_PROPERTY_X86_FEATURE_2_ZMM:
printf ("ZMM");
break;
+ case GNU_PROPERTY_X86_FEATURE_2_TMM:
+ printf ("TMM");
+ break;
+ case GNU_PROPERTY_X86_FEATURE_2_MASK:
+ printf ("MASK");
+ break;
case GNU_PROPERTY_X86_FEATURE_2_FXSR:
printf ("FXSR");
break;
}
goto next;
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED:
+ if (datasz != 4)
+ printf (_("x86 ISA used: <corrupt length: %#x> "),
+ datasz);
+ else
+ {
+ printf ("x86 ISA used: ");
+ decode_x86_compat_2_isa (bitmask);
+ }
+ goto next;
+
+ case GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED:
+ if (datasz != 4)
+ printf (_("x86 ISA needed: <corrupt length: %#x> "),
+ datasz);
+ else
+ {
+ printf ("x86 ISA needed: ");
+ decode_x86_compat_2_isa (bitmask);
+ }
+ goto next;
+
default:
break;
}
while (bytes --)
{
- unsigned long byte = (* name ++) & 0xff;
+ unsigned long long byte = *name++ & 0xff;
val |= byte << shift;
shift += 8;
case EM_MSP430:
return process_attributes (filedata, "mspabi", SHT_MSP430_ATTRIBUTES,
- display_msp430x_attribute,
+ display_msp430_attribute,
display_msp430_gnu_attribute);
case EM_RISCV:
display_tic6x_attribute,
display_generic_attribute);
+ case EM_CSKY:
+ return process_attributes (filedata, "csky", SHT_CSKY_ATTRIBUTES,
+ display_csky_attribute, NULL);
+
default:
return process_attributes (filedata, "gnu", SHT_GNU_ATTRIBUTES,
display_public_gnu_attributes,
if (! process_symbol_table (filedata))
res = FALSE;
+ if (! process_lto_symbol_tables (filedata))
+ res = FALSE;
+
if (! process_syminfo (filedata))
res = FALSE;