#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
+#include <wchar.h>
#if __GNUC__ >= 2
/* Define BFD64 here, even if our default architecture is 32 bit ELF
#define RELOC_MACROS_GEN_FUNC
+#include "elf/aarch64.h"
#include "elf/alpha.h"
#include "elf/arc.h"
#include "elf/arm.h"
return 0;
}
-/* Display a symbol on stdout. Handles the display of non-printing characters.
+/* Display a symbol on stdout. Handles the display of control characters and
+ multibye characters.
- If DO_WIDE is not true then format the symbol to be at most WIDTH characters,
- truncating as necessary. If WIDTH is negative then format the string to be
- exactly - WIDTH characters, truncating or padding as necessary.
+ Display at most abs(WIDTH) characters, truncating as necessary, unless do_wide is true.
+
+ 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 (int width, const char *symbol)
{
- const char *c;
bfd_boolean extra_padding = FALSE;
- unsigned int num_printed = 0;
+ int num_printed = 0;
+ mbstate_t state;
+ int width_remaining;
- if (do_wide)
- {
- /* Set the width to a very large value. This simplifies the
- code below. */
- width = INT_MAX;
- }
- else if (width < 0)
+ if (width < 0)
{
/* Keep the width positive. This also helps. */
width = - width;
extra_padding = TRUE;
- }
-
- while (width)
- {
- int len;
-
- c = symbol;
-
- /* Look for non-printing symbols inside the symbol's name.
- This test is triggered in particular by the names generated
- by the assembler for local labels. */
- while (ISPRINT (*c))
- c++;
-
- len = c - symbol;
+ }
- if (len)
- {
- if (len > width)
- len = width;
+ if (do_wide)
+ /* Set the remaining width to a very large value.
+ This simplifies the code below. */
+ width_remaining = INT_MAX;
+ else
+ width_remaining = width;
- printf ("%.*s", len, symbol);
+ /* Initialise the multibyte conversion state. */
+ memset (& state, 0, sizeof (state));
- width -= len;
- num_printed += len;
- }
+ while (width_remaining)
+ {
+ size_t n;
+ wchar_t w;
+ const char c = *symbol++;
- if (*c == 0 || width == 0)
+ if (c == 0)
break;
- /* Now display the non-printing character, if
- there is room left in which to dipslay it. */
- if ((unsigned char) *c < 32)
+ /* Do not print control characters directly as they can affect terminal
+ settings. Such characters usually appear in the names generated
+ by the assembler for local labels. */
+ if (ISCNTRL (c))
{
- if (width < 2)
+ if (width_remaining < 2)
break;
- printf ("^%c", *c + 0x40);
-
- width -= 2;
+ printf ("^%c", c + 0x40);
+ width_remaining -= 2;
num_printed += 2;
}
+ else if (ISPRINT (c))
+ {
+ putchar (c);
+ width_remaining --;
+ num_printed ++;
+ }
else
{
- if (width < 6)
- break;
-
- printf ("<0x%.2x>", (unsigned char) *c);
+ /* Let printf do the hard work of displaying multibyte characters. */
+ printf ("%.1s", symbol - 1);
+ width_remaining --;
+ num_printed ++;
- width -= 6;
- num_printed += 6;
+ /* Try to find out how many bytes made up the character that was
+ just printed. Advance the symbol pointer past the bytes that
+ were displayed. */
+ n = mbrtowc (& w, symbol - 1, MB_CUR_MAX, & state);
+ if (n != (size_t) -1 && n != (size_t) -2 && n > 0)
+ symbol += (n - 1);
}
-
- symbol = c + 1;
}
- if (extra_padding && width > 0)
+ if (extra_padding && num_printed < width)
{
/* Fill in the remaining spaces. */
- printf ("%-*s", width, " ");
- num_printed += 2;
+ printf ("%-*s", width - num_printed, " ");
+ num_printed = width;
}
return num_printed;
/* Targets that use RELA relocations. */
case EM_68K:
case EM_860:
+ case EM_AARCH64:
case EM_ADAPTEVA_EPIPHANY:
case EM_ALPHA:
case EM_ALTERA_NIOS2:
rtype = NULL;
break;
+ case EM_AARCH64:
+ rtype = elf_aarch64_reloc_type (type);
+ break;
+
case EM_M32R:
case EM_CYGNUS_M32R:
rtype = elf_m32r_reloc_type (type);
switch (e_machine)
{
case EM_NONE: return _("None");
+ case EM_AARCH64: return "AArch64";
case EM_M32: return "WE32100";
case EM_SPARC: return "Sparc";
case EM_SPU: return "SPU";
case EM_IA_64: return "Intel IA-64";
case EM_MIPS_X: return "Stanford MIPS-X";
case EM_COLDFIRE: return "Motorola Coldfire";
- case EM_68HC12: return "Motorola M68HC12";
case EM_ALPHA: return "Alpha";
case EM_CYGNUS_D10V:
case EM_D10V: return "d10v";
case EM_ST9PLUS: return "STMicroelectronics ST9+ 8/16 bit microcontroller";
case EM_ST7: return "STMicroelectronics ST7 8-bit microcontroller";
case EM_68HC16: return "Motorola MC68HC16 Microcontroller";
+ case EM_68HC12: return "Motorola MC68HC12 Microcontroller";
case EM_68HC11: return "Motorola MC68HC11 Microcontroller";
case EM_68HC08: return "Motorola MC68HC08 Microcontroller";
case EM_68HC05: return "Motorola MC68HC05 Microcontroller";
}
}
+static const char *
+get_aarch64_segment_type (unsigned long type)
+{
+ switch (type)
+ {
+ case PT_AARCH64_ARCHEXT:
+ return "AARCH64_ARCHEXT";
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
static const char *
get_arm_segment_type (unsigned long type)
{
switch (elf_header.e_machine)
{
+ case EM_AARCH64:
+ result = get_aarch64_segment_type (p_type);
+ break;
case EM_ARM:
result = get_arm_segment_type (p_type);
break;
return NULL;
}
+static const char *
+get_aarch64_section_type_name (unsigned int sh_type)
+{
+ switch (sh_type)
+ {
+ case SHT_AARCH64_ATTRIBUTES:
+ return "AARCH64_ATTRIBUTES";
+ default:
+ break;
+ }
+ return NULL;
+}
+
static const char *
get_arm_section_type_name (unsigned int sh_type)
{
case EM_K1OM:
result = get_x86_64_section_type_name (sh_type);
break;
+ case EM_AARCH64:
+ result = get_aarch64_section_type_name (sh_type);
+ break;
case EM_ARM:
result = get_arm_section_type_name (sh_type);
break;
i < elf_header.e_shnum;
i++, section++)
{
+ printf (" [%2u] ", i);
if (do_section_details)
{
- printf (" [%2u] %s\n",
- i,
- SECTION_NAME (section));
- if (is_32bit_elf || do_wide)
- printf (" %-15.15s ",
- get_section_type_name (section->sh_type));
+ print_symbol (INT_MAX, SECTION_NAME (section));
+ printf ("\n ");
}
else
- printf ((do_wide ? " [%2u] %-17s %-15s "
- : " [%2u] %-17.17s %-15.15s "),
- i,
- SECTION_NAME (section),
- get_section_type_name (section->sh_type));
-
+ {
+ print_symbol (-17, SECTION_NAME (section));
+ }
+
+ printf (do_wide ? " %-15s " : " %-15.15s ",
+ get_section_type_name (section->sh_type));
+
if (is_32bit_elf)
{
const char * link_too_big = NULL;
sprintf (buff, "OS [0x%04x]", type & 0xffff);
else if (type >= SHN_LORESERVE)
sprintf (buff, "RSV[0x%04x]", type & 0xffff);
+ else if (type >= elf_header.e_shnum)
+ sprintf (buff, "bad section index[%3d]", type);
else
sprintf (buff, "%3d", type);
break;
return reloc_type == 1; /* R_860_32. */
case EM_960:
return reloc_type == 2; /* R_960_32. */
+ case EM_AARCH64:
+ return reloc_type == 258; /* R_AARCH64_ABS32 */
case EM_ALPHA:
return reloc_type == 1; /* R_ALPHA_REFLONG. */
case EM_ARC:
return reloc_type == 2; /* R_386_PC32. */
case EM_68K:
return reloc_type == 4; /* R_68K_PC32. */
+ case EM_AARCH64:
+ return reloc_type == 261; /* R_AARCH64_PREL32 */
case EM_ADAPTEVA_EPIPHANY:
return reloc_type == 6;
case EM_ALPHA:
{
switch (elf_header.e_machine)
{
+ case EM_AARCH64:
+ return reloc_type == 257; /* R_AARCH64_ABS64. */
case EM_ALPHA:
return reloc_type == 2; /* R_ALPHA_REFQUAD. */
case EM_IA_64:
{
switch (elf_header.e_machine)
{
+ case EM_AARCH64:
+ return reloc_type == 260; /* R_AARCH64_PREL64. */
case EM_ALPHA:
return reloc_type == 11; /* R_ALPHA_SREL64. */
case EM_IA_64:
case EM_XC16X:
case EM_C166:
return reloc_type == 2; /* R_XC16C_ABS_16. */
+ case EM_CYGNUS_MN10200:
+ case EM_MN10200:
+ return reloc_type == 2; /* R_MN10200_16. */
case EM_CYGNUS_MN10300:
case EM_MN10300:
return reloc_type == 2; /* R_MN10300_16. */
case EM_XC16X:
case EM_C166: /* R_XC16X_NONE. */
return reloc_type == 0;
+ case EM_AARCH64:
+ return reloc_type == 0 || reloc_type == 256;
case EM_XTENSA_OLD:
case EM_XTENSA:
return (reloc_type == 0 /* R_XTENSA_NONE. */
static const char * arm_attr_tag_CPU_arch[] =
{"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2",
- "v6K", "v7", "v6-M", "v6S-M", "v7E-M"};
+ "v6K", "v7", "v6-M", "v6S-M", "v7E-M", "v8"};
static const char * arm_attr_tag_ARM_ISA_use[] = {"No", "Yes"};
static const char * arm_attr_tag_THUMB_ISA_use[] =
{"No", "Thumb-1", "Thumb-2"};
static const char * arm_attr_tag_FP_arch[] =
- {"No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16", "VFPv4", "VFPv4-D16"};
+ {"No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16", "VFPv4", "VFPv4-D16",
+ "FP for ARMv8"};
static const char * arm_attr_tag_WMMX_arch[] = {"No", "WMMXv1", "WMMXv2"};
static const char * arm_attr_tag_Advanced_SIMD_arch[] =
- {"No", "NEONv1", "NEONv1 with Fused-MAC"};
+ {"No", "NEONv1", "NEONv1 with Fused-MAC", "NEON for ARMv8"};
static const char * arm_attr_tag_PCS_config[] =
{"None", "Bare platform", "Linux application", "Linux DSO", "PalmOS 2004",
"PalmOS (reserved)", "SymbianOS 2004", "SymbianOS (reserved)"};
return _("NT_LWPSINFO (lwpsinfo_t structure)");
case NT_WIN32PSTATUS:
return _("NT_WIN32PSTATUS (win32_pstatus structure)");
+ case NT_SIGINFO:
+ return _("NT_SIGINFO (siginfo_t data)");
+ case NT_FILE:
+ return _("NT_FILE (mapped files)");
default:
break;
}
return buff;
}
+static int
+print_core_note (Elf_Internal_Note *pnote)
+{
+ unsigned int addr_size = is_32bit_elf ? 4 : 8;
+ bfd_vma count, page_size;
+ unsigned char *descdata, *filenames, *descend;
+
+ if (pnote->type != NT_FILE)
+ return 1;
+
+#ifndef BFD64
+ if (!is_32bit_elf)
+ {
+ printf (_(" Cannot decode 64-bit note in 32-bit build\n"));
+ /* Still "successful". */
+ return 1;
+ }
+#endif
+
+ if (pnote->descsz < 2 * addr_size)
+ {
+ printf (_(" Malformed note - too short for header\n"));
+ return 0;
+ }
+
+ descdata = (unsigned char *) pnote->descdata;
+ descend = descdata + pnote->descsz;
+
+ if (descdata[pnote->descsz - 1] != '\0')
+ {
+ printf (_(" Malformed note - does not end with \\0\n"));
+ return 0;
+ }
+
+ count = byte_get (descdata, addr_size);
+ descdata += addr_size;
+
+ page_size = byte_get (descdata, addr_size);
+ descdata += addr_size;
+
+ if (pnote->descsz < 2 * addr_size + count * 3 * addr_size)
+ {
+ printf (_(" Malformed note - too short for supplied file count\n"));
+ return 0;
+ }
+
+ printf (_(" Page size: "));
+ print_vma (page_size, DEC);
+ printf ("\n");
+
+ printf (_(" %*s%*s%*s\n"),
+ (int) (2 + 2 * addr_size), _("Start"),
+ (int) (4 + 2 * addr_size), _("End"),
+ (int) (4 + 2 * addr_size), _("Page Offset"));
+ filenames = descdata + count * 3 * addr_size;
+ while (--count > 0)
+ {
+ bfd_vma start, end, file_ofs;
+
+ if (filenames == descend)
+ {
+ printf (_(" Malformed note - filenames end too early\n"));
+ return 0;
+ }
+
+ start = byte_get (descdata, addr_size);
+ descdata += addr_size;
+ end = byte_get (descdata, addr_size);
+ descdata += addr_size;
+ file_ofs = byte_get (descdata, addr_size);
+ descdata += addr_size;
+
+ printf (" ");
+ print_vma (start, FULL_HEX);
+ printf (" ");
+ print_vma (end, FULL_HEX);
+ printf (" ");
+ print_vma (file_ofs, FULL_HEX);
+ printf ("\n %s\n", filenames);
+
+ filenames += 1 + strlen ((char *) filenames);
+ }
+
+ return 1;
+}
+
static const char *
get_gnu_elf_note_type (unsigned e_type)
{
return print_gnu_note (pnote);
else if (const_strneq (pnote->namedata, "stapsdt"))
return print_stapsdt_note (pnote);
+ else if (const_strneq (pnote->namedata, "CORE"))
+ return print_core_note (pnote);
else
return 1;
}
unsigned long current_pos;
printf (_("Index of archive %s: (%ld entries, 0x%lx bytes in the symbol table)\n"),
- file_name, arch.index_num, arch.sym_size);
+ file_name, (long) arch.index_num, arch.sym_size);
current_pos = ftell (file);
for (i = l = 0; i < arch.index_num; i++)
if (qualified_name != NULL)
{
- printf (_("Binary %s contains:\n"), qualified_name);
+ printf (_("Contents of binary %s at offset "), qualified_name);
+ (void) print_vma (arch.index_array[i], PREFIX_HEX);
+ putchar ('\n');
free (qualified_name);
}
}
l += strlen (arch.sym_table + l) + 1;
}
- if (l & 01)
- ++l;
+ if (arch.uses_64bit_indicies)
+ l = (l + 7) & ~ 7;
+ else
+ l += l & 1;
+
if (l < arch.sym_size)
- error (_("%s: symbols remain in the index symbol table, but without corresponding entries in the index table\n"),
- file_name);
+ error (_("%s: %ld bytes remain in the symbol table, but without corresponding entries in the index table\n"),
+ file_name, arch.sym_size - l);
if (fseek (file, current_pos, SEEK_SET) != 0)
{