#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";
}
}
+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;
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. */
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)
{