PR27116, Spelling errors found by Debian style checker
[deliverable/binutils-gdb.git] / binutils / readelf.c
index 8e8ade8fbe0b74ebf3835573fbc57ab795c7859d..d6e7a7b38355a487a9b6eb0e623a2ef9340c9656 100644 (file)
@@ -1,5 +1,5 @@
 /* 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>
@@ -61,6 +61,7 @@
 #include "elfcomm.h"
 #include "dwarf.h"
 #include "ctf-api.h"
+#include "demangle.h"
 
 #include "elf/common.h"
 #include "elf/external.h"
@@ -199,7 +200,8 @@ struct dump_list_entry
 
 /* A dynamic array of flags indicating for which sections a dump
    has been requested via command line switches.  */
-struct dump_data {
+struct dump_data
+{
   dump_type *          dump_sects;
   unsigned int         num_dump_sects;
 };
@@ -214,6 +216,7 @@ static bfd_boolean show_name = FALSE;
 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;
@@ -230,8 +233,12 @@ static bfd_boolean do_ctf = FALSE;
 static bfd_boolean do_arch = FALSE;
 static bfd_boolean do_notes = FALSE;
 static bfd_boolean do_archive_index = 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;
@@ -265,8 +272,10 @@ typedef struct filedata
   bfd_size_type        dynamic_size;
   size_t               dynamic_nent;
   Elf_Internal_Dyn *   dynamic_section;
+  Elf_Internal_Shdr *  dynamic_strtab_section;
   char *               dynamic_strings;
   unsigned long        dynamic_strings_length;
+  Elf_Internal_Shdr *  dynamic_symtab_section;
   unsigned long        num_dynamic_syms;
   Elf_Internal_Sym *   dynamic_symbols;
   bfd_vma              version_info[16];
@@ -326,11 +335,19 @@ static const char * get_symbol_version_string
 
 #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!  */
 
@@ -529,20 +546,25 @@ print_vma (bfd_vma vma, print_mode mode)
 
    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)
     {
@@ -558,13 +580,31 @@ print_symbol (signed int width, const char *symbol)
        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;
@@ -614,6 +654,9 @@ print_symbol (signed int width, const char *symbol)
        }
     }
 
+  if (do_dots)
+    num_printed += printf ("[...]");
+
   if (extra_padding && num_printed < width)
     {
       /* Fill in the remaining spaces.  */
@@ -621,6 +664,7 @@ print_symbol (signed int width, const char *symbol)
       num_printed = width;
     }
 
+  free ((void *) alloced_symbol);
   return num_printed;
 }
 
@@ -633,7 +677,7 @@ printable_section_name (Filedata * filedata, const Elf_Internal_Shdr * sec)
 {
 #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;
@@ -695,7 +739,8 @@ find_section (Filedata * filedata, const char * name)
     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;
@@ -761,7 +806,8 @@ find_section_in_set (Filedata * filedata, const char * name, unsigned int * set)
          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;
        }
     }
@@ -1246,32 +1292,10 @@ dump_relocations (Filedata *          filedata,
        }
       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 ",
-                 offset, inf);
-#else
          printf (do_wide
-                 ? "%16.16I64x  %16.16I64x "
-                 : "%12.12I64x  %12.12I64x ",
+                 ? "%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);
-#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)
@@ -1715,7 +1739,8 @@ dump_relocations (Filedata *          filedata,
                  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)
@@ -2207,6 +2232,7 @@ get_dynamic_type (Filedata * filedata, unsigned long type)
     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))
@@ -2538,10 +2564,26 @@ get_machine_name (unsigned e_machine)
     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";
@@ -2556,7 +2598,6 @@ get_machine_name (unsigned e_machine)
     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);
@@ -4017,6 +4058,10 @@ get_segment_type (Filedata * filedata, unsigned long p_type)
     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))
        {
@@ -4250,7 +4295,7 @@ get_tic6x_section_type_name (unsigned int sh_type)
 }
 
 static const char *
-get_msp430x_section_type_name (unsigned int sh_type)
+get_msp430_section_type_name (unsigned int sh_type)
 {
   switch (sh_type)
     {
@@ -4297,6 +4342,16 @@ get_riscv_section_type_name (unsigned int 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)
 {
@@ -4367,7 +4422,7 @@ 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);
@@ -4380,6 +4435,9 @@ get_section_type_name (Filedata * filedata, unsigned int 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;
@@ -4449,62 +4507,78 @@ get_section_type_name (Filedata * filedata, unsigned int sh_type)
     }
 }
 
-#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'},
-  {"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}
 };
 
@@ -4525,7 +4599,15 @@ usage (FILE * stream)
   -e --headers           Equivalent to: -h -l -S\n\
   -s --syms              Display the symbol table\n\
      --symbols           An alias for --syms\n\
-  --dyn-syms             Display the dynamic symbol table\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\
@@ -4534,6 +4616,7 @@ usage (FILE * stream)
   -A --arch-specific     Display architecture specific information (if any)\n\
   -c --archive-index     Display the symbol/file index in an archive\n\
   -D --use-dynamic       Use the dynamic section info when displaying symbols\n\
+  -L --lint|--enable-checks  Display warning messages for possible problems\n\
   -x --hex-dump=<number|name>\n\
                          Dump the contents of section <number|name> as bytes\n\
   -p --string-dump=<number|name>\n\
@@ -4541,9 +4624,9 @@ usage (FILE * stream)
   -R --relocated-dump=<number|name>\n\
                          Dump the contents of section <number|name> as relocated bytes\n\
   -z --decompress        Decompress section before dumping it\n\
-  -w[lLiaprmfFsoRtUuTgAckK] or\n\
+  -w[lLiaprmfFsoORtUuTgAckK] or\n\
   --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,\n\
-               =frames-interp,=str,=loc,=Ranges,=pubtypes,\n\
+               =frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,\n\
                =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,\n\
                =addr,=cu_index,=links,=follow-links]\n\
                          Display the contents of DWARF debug sections\n"));
@@ -4551,6 +4634,7 @@ usage (FILE * stream)
   --dwarf-depth=N        Do not display DIEs at depth N or greater\n\
   --dwarf-start=N        Display DIEs starting with N, at the same depth\n\
                          or deeper\n"));
+#ifdef ENABLE_LIBCTF
   fprintf (stream, _("\
   --ctf=<number|name>    Display CTF info from section <number|name>\n\
   --ctf-parent=<number|name>\n\
@@ -4559,6 +4643,7 @@ usage (FILE * stream)
                          Use section <number|name> as the CTF external symtab\n\n\
   --ctf-strings=<number|name>\n\
                          Use section <number|name> as the CTF external strtab\n\n"));
+#endif
 
 #ifdef SUPPORT_DISASSEMBLY
   fprintf (stream, _("\
@@ -4568,6 +4653,7 @@ usage (FILE * stream)
   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"));
@@ -4662,7 +4748,7 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
     usage (stderr);
 
   while ((c = getopt_long
-         (argc, argv, "ADHINR:SVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
+         (argc, argv, "ACDHILNR:STVWacdeghi:lnp:rstuvw::x:z", options, NULL)) != EOF)
     {
       switch (c)
        {
@@ -4687,6 +4773,7 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
          do_arch = TRUE;
          do_notes = TRUE;
          break;
+
        case 'g':
          do_section_groups = TRUE;
          break;
@@ -4736,6 +4823,9 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
        case 'c':
          do_archive_index = TRUE;
          break;
+       case 'L':
+         do_checks = TRUE;
+         break;
        case 'x':
          request_dump (dumpdata, HEX_DUMP);
          break;
@@ -4750,7 +4840,7 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
          break;
        case 'w':
          do_dump = TRUE;
-         if (optarg == 0)
+         if (optarg == NULL)
            {
              do_debugging = TRUE;
              dwarf_select_sections_all ();
@@ -4763,7 +4853,7 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
          break;
        case OPTION_DEBUG_DUMP:
          do_dump = TRUE;
-         if (optarg == 0)
+         if (optarg == NULL)
            do_debugging = TRUE;
          else
            {
@@ -4793,17 +4883,23 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
          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);
@@ -4818,6 +4914,35 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
        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);
@@ -4831,8 +4956,20 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv)
       && !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)
-    usage (stderr);
+      && !do_dyn_syms && !do_lto_syms)
+    {
+      if (do_checks)
+       {
+         check_all = TRUE;
+         do_dynamic = do_syms = do_reloc = do_unwind = do_sections = TRUE;
+         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);
+    }
 }
 
 static const char *
@@ -5344,13 +5481,13 @@ process_program_headers (Filedata * filedata)
              filedata->dynamic_addr = sec->sh_offset;
              filedata->dynamic_size = sec->sh_size;
 
-             if (filedata->dynamic_addr < segment->p_offset
-                 || filedata->dynamic_addr > segment->p_offset + segment->p_filesz)
-               warn (_("the .dynamic section is not contained"
-                       " within the dynamic segment\n"));
-             else if (filedata->dynamic_addr > segment->p_offset)
-               warn (_("the .dynamic section is not the first section"
-                       " in the dynamic segment.\n"));
+             /* The PT_DYNAMIC segment, which is used by the run-time
+                loader,  should exactly match the .dynamic section.  */
+             if (do_checks
+                 && (filedata->dynamic_addr != segment->p_offset
+                     || filedata->dynamic_size != segment->p_filesz))
+               warn (_("\
+the .dynamic section is not the same as the dynamic segment\n"));
            }
 
          /* PR binutils/17512: Avoid corrupt dynamic section info in the
@@ -5875,6 +6012,8 @@ get_elf_section_flags (Filedata * filedata, bfd_vma sh_flags)
       /* 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)
@@ -5907,7 +6046,6 @@ get_elf_section_flags (Filedata * filedata, bfd_vma sh_flags)
            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;
@@ -5959,10 +6097,28 @@ get_elf_section_flags (Filedata * filedata, bfd_vma sh_flags)
                  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)
@@ -6005,7 +6161,6 @@ get_elf_section_flags (Filedata * filedata, bfd_vma sh_flags)
            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
@@ -6015,14 +6170,37 @@ get_elf_section_flags (Filedata * filedata, bfd_vma sh_flags)
                *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)
                {
@@ -6277,17 +6455,20 @@ process_section_headers (Filedata * filedata)
   while (0)
 
 #define CHECK_ENTSIZE(section, i, type)                                        \
-  CHECK_ENTSIZE_VALUES (section, i, sizeof (Elf32_External_##type),        \
+  CHECK_ENTSIZE_VALUES (section, i, sizeof (Elf32_External_##type),    \
                        sizeof (Elf64_External_##type))
 
   for (i = 0, section = filedata->section_headers;
        i < filedata->file_header.e_shnum;
        i++, section++)
     {
-      char * name = SECTION_NAME (section);
+      char * name = SECTION_NAME_PRINT (section);
 
-      if (section->sh_type == SHT_DYNSYM)
+      /* Run some sanity checks on the headers and
+        possibly fill in some file data as well.  */
+      switch (section->sh_type)
        {
+       case SHT_DYNSYM:
          if (filedata->dynamic_symbols != NULL)
            {
              error (_("File contains multiple dynamic symbol tables\n"));
@@ -6297,45 +6478,77 @@ process_section_headers (Filedata * filedata)
          CHECK_ENTSIZE (section, i, Sym);
          filedata->dynamic_symbols
            = GET_ELF_SYMBOLS (filedata, section, &filedata->num_dynamic_syms);
-       }
-      else if (section->sh_type == SHT_STRTAB
-              && streq (name, ".dynstr"))
-       {
-         if (filedata->dynamic_strings != NULL)
+         filedata->dynamic_symtab_section = section;
+         break;
+
+       case SHT_STRTAB:
+         if (streq (name, ".dynstr"))
            {
-             error (_("File contains multiple dynamic string tables\n"));
-             continue;
+             if (filedata->dynamic_strings != NULL)
+               {
+                 error (_("File contains multiple dynamic string tables\n"));
+                 continue;
+               }
+
+             filedata->dynamic_strings
+               = (char *) get_data (NULL, filedata, section->sh_offset,
+                                    1, section->sh_size, _("dynamic strings"));
+             filedata->dynamic_strings_length
+               = filedata->dynamic_strings == NULL ? 0 : section->sh_size;
+             filedata->dynamic_strtab_section = section;
            }
+         break;
+
+       case SHT_SYMTAB_SHNDX:
+         {
+           elf_section_list * entry = xmalloc (sizeof * entry);
+
+           entry->hdr = section;
+           entry->next = filedata->symtab_shndx_list;
+           filedata->symtab_shndx_list = entry;
+         }
+         break;
+
+       case SHT_SYMTAB:
+         CHECK_ENTSIZE (section, i, Sym);
+         break;
+
+       case SHT_GROUP:
+         CHECK_ENTSIZE_VALUES (section, i, GRP_ENTRY_SIZE, GRP_ENTRY_SIZE);
+         break;
+
+       case SHT_REL:
+         CHECK_ENTSIZE (section, i, Rel);
+         if (do_checks && section->sh_size == 0)
+           warn (_("Section '%s': zero-sized relocation section\n"), name);
+         break;
+
+       case SHT_RELA:
+         CHECK_ENTSIZE (section, i, Rela);
+         if (do_checks && section->sh_size == 0)
+           warn (_("Section '%s': zero-sized relocation section\n"), name);
+         break;
+
+       case SHT_NOTE:
+       case SHT_PROGBITS:
+         /* Having a zero sized section is not illegal according to the
+            ELF standard, but it might be an indication that something
+            is wrong.  So issue a warning if we are running in lint mode.  */
+         if (do_checks && section->sh_size == 0)
+           warn (_("Section '%s': has a size of zero - is this intended ?\n"), name);
+         break;
+
+       default:
+         break;
+       }
 
-         filedata->dynamic_strings
-           = (char *) get_data (NULL, filedata, section->sh_offset,
-                                1, section->sh_size, _("dynamic strings"));
-         filedata->dynamic_strings_length
-           = filedata->dynamic_strings == NULL ? 0 : section->sh_size;
-       }
-      else if (section->sh_type == SHT_SYMTAB_SHNDX)
-       {
-         elf_section_list * entry = xmalloc (sizeof * entry);
-
-         entry->hdr = section;
-         entry->next = filedata->symtab_shndx_list;
-         filedata->symtab_shndx_list = entry;
-       }
-      else if (section->sh_type == SHT_SYMTAB)
-       CHECK_ENTSIZE (section, i, Sym);
-      else if (section->sh_type == SHT_GROUP)
-       CHECK_ENTSIZE_VALUES (section, i, GRP_ENTRY_SIZE, GRP_ENTRY_SIZE);
-      else if (section->sh_type == SHT_REL)
-       CHECK_ENTSIZE (section, i, Rel);
-      else if (section->sh_type == SHT_RELA)
-       CHECK_ENTSIZE (section, i, Rela);
-      else if ((do_debugging || do_debug_info || do_debug_abbrevs
-               || do_debug_lines || do_debug_pubnames || do_debug_pubtypes
-               || do_debug_aranges || do_debug_frames || do_debug_macinfo
-               || do_debug_str || do_debug_loc || do_debug_ranges
-               || do_debug_addr || do_debug_cu_index || do_debug_links)
-              && (const_strneq (name, ".debug_")
-                   || const_strneq (name, ".zdebug_")))
+      if ((do_debugging || do_debug_info || do_debug_abbrevs
+          || do_debug_lines || do_debug_pubnames || do_debug_pubtypes
+          || do_debug_aranges || do_debug_frames || do_debug_macinfo
+          || do_debug_str || do_debug_str_offsets || do_debug_loc || do_debug_ranges
+          || do_debug_addr || do_debug_cu_index || do_debug_links)
+         && (const_strneq (name, ".debug_")
+             || const_strneq (name, ".zdebug_")))
        {
           if (name[1] == 'z')
             name += sizeof (".zdebug_") - 1;
@@ -6359,6 +6572,7 @@ process_section_headers (Filedata * filedata)
              || (do_debug_macinfo  && const_strneq (name, "macinfo"))
              || (do_debug_macinfo  && const_strneq (name, "macro"))
              || (do_debug_str      && const_strneq (name, "str"))
+             || (do_debug_str_offsets && const_strneq (name, "str_offsets"))
              || (do_debug_loc      && const_strneq (name, "loc"))
              || (do_debug_loc      && const_strneq (name, "loclists"))
              || (do_debug_addr     && const_strneq (name, "addr"))
@@ -6584,7 +6798,7 @@ process_section_headers (Filedata * filedata)
       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));
@@ -6954,8 +7168,7 @@ process_section_groups (Filedata * filedata)
          if (symtab_sec != sec)
            {
              symtab_sec = sec;
-             if (symtab)
-               free (symtab);
+             free (symtab);
              symtab = GET_ELF_SYMBOLS (filedata, symtab_sec, & num_syms);
            }
 
@@ -6982,10 +7195,10 @@ process_section_groups (Filedata * filedata)
                  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;
-             if (strtab)
-               free (strtab);
+             free (strtab);
              strtab = NULL;
              strtab_size = 0;
            }
@@ -6995,8 +7208,7 @@ process_section_groups (Filedata * filedata)
              if (symtab_sec->sh_link >= filedata->file_header.e_shnum)
                {
                  strtab_sec = NULL;
-                 if (strtab)
-                   free (strtab);
+                 free (strtab);
                  strtab = NULL;
                  strtab_size = 0;
                }
@@ -7004,8 +7216,7 @@ process_section_groups (Filedata * filedata)
                       != (sec = filedata->section_headers + symtab_sec->sh_link))
                {
                  strtab_sec = sec;
-                 if (strtab)
-                   free (strtab);
+                 free (strtab);
 
                  strtab = (char *) get_data (NULL, filedata, strtab_sec->sh_offset,
                                              1, strtab_sec->sh_size,
@@ -7113,17 +7324,14 @@ process_section_groups (Filedata * filedata)
              group->root = g;
            }
 
-         if (start)
-           free (start);
+         free (start);
 
          group++;
        }
     }
 
-  if (symtab)
-    free (symtab);
-  if (strtab)
-    free (strtab);
+  free (symtab);
+  free (strtab);
   return TRUE;
 }
 
@@ -7311,8 +7519,7 @@ process_ia64_vms_dynamic_relocs (Filedata * filedata)
        }
     }
 
-  if (strtab != NULL)
-    free (strtab);
+  free (strtab);
 
   return res;
 }
@@ -7458,8 +7665,7 @@ process_relocs (Filedata * filedata)
                                    symtab, nsyms, strtab, strtablen,
                                    is_rela,
                                    symsec->sh_type == SHT_DYNSYM);
-                 if (strtab)
-                   free (strtab);
+                 free (strtab);
                  free (symtab);
                }
              else
@@ -7918,7 +8124,8 @@ ia64_process_unwind (Filedata * filedata)
                {
                  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;
                }
 
@@ -7926,14 +8133,19 @@ ia64_process_unwind (Filedata * filedata)
                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;
        }
@@ -7944,11 +8156,14 @@ ia64_process_unwind (Filedata * filedata)
          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;
        }
@@ -7985,19 +8200,15 @@ ia64_process_unwind (Filedata * filedata)
              && aux.table_len > 0)
            dump_ia64_unwind (filedata, & aux);
 
-         if (aux.table)
-           free ((char *) aux.table);
-         if (aux.info)
-           free ((char *) aux.info);
+         free ((char *) aux.table);
+         free ((char *) aux.info);
          aux.table = NULL;
          aux.info = NULL;
        }
     }
 
-  if (aux.symtab)
-    free (aux.symtab);
-  if (aux.strtab)
-    free ((char *) aux.strtab);
+  free (aux.symtab);
+  free ((char *) aux.strtab);
 
   return res;
 }
@@ -8182,6 +8393,7 @@ slurp_hppa_unwind_table (Filedata *                  filedata,
   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]));
 
@@ -8301,8 +8513,6 @@ slurp_hppa_unwind_table (Filedata *                  filedata,
       free (rela);
     }
 
-  aux->table_len = nentries;
-
   return TRUE;
 }
 
@@ -8336,7 +8546,8 @@ hppa_process_unwind (Filedata * filedata)
                           &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;
     }
 
@@ -8345,7 +8556,8 @@ hppa_process_unwind (Filedata * filedata)
 
   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;
 
@@ -8367,16 +8579,13 @@ hppa_process_unwind (Filedata * filedata)
                res = FALSE;
            }
 
-         if (aux.table)
-           free ((char *) aux.table);
+         free ((char *) aux.table);
          aux.table = NULL;
        }
     }
 
-  if (aux.symtab)
-    free (aux.symtab);
-  if (aux.strtab)
-    free ((char *) aux.strtab);
+  free (aux.symtab);
+  free ((char *) aux.strtab);
 
   return res;
 }
@@ -8436,11 +8645,8 @@ arm_print_vma_and_name (Filedata *                 filedata,
 static void
 arm_free_section (struct arm_section *arm_sec)
 {
-  if (arm_sec->data != NULL)
-    free (arm_sec->data);
-
-  if (arm_sec->rela != NULL)
-    free (arm_sec->rela);
+  free (arm_sec->data);
+  free (arm_sec->rela);
 }
 
 /* 1) If SEC does not match the one cached in ARM_SEC, then free the current
@@ -9474,10 +9680,8 @@ arm_process_unwind (Filedata * filedata)
          }
       }
 
-  if (aux.symtab)
-    free (aux.symtab);
-  if (aux.strtab)
-    free ((char *) aux.strtab);
+  free (aux.symtab);
+  free ((char *) aux.strtab);
 
   return res;
 }
@@ -9682,20 +9886,29 @@ dynamic_section_parisc_val (Elf_Internal_Dyn * entry)
 
 #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 */
 
@@ -10006,16 +10219,10 @@ get_num_dynamic_syms (Filedata * filedata)
     no_hash:
       if (num_of_syms == 0)
        {
-         if (filedata->buckets)
-           {
-             free (filedata->buckets);
-             filedata->buckets = NULL;
-           }
-         if (filedata->chains)
-           {
-             free (filedata->chains);
-             filedata->chains = NULL;
-           }
+         free (filedata->buckets);
+         filedata->buckets = NULL;
+         free (filedata->chains);
+         filedata->chains = NULL;
          filedata->nbuckets = 0;
        }
     }
@@ -10026,7 +10233,6 @@ get_num_dynamic_syms (Filedata * filedata)
       bfd_vma i, maxchain = 0xffffffff, bitmaskwords;
       bfd_vma buckets_vma;
       unsigned long hn;
-      bfd_boolean gnu_hash_error = FALSE;
 
       if (fseek (filedata->handle,
                 (filedata->archive_file_offset
@@ -10036,14 +10242,12 @@ get_num_dynamic_syms (Filedata * filedata)
                 SEEK_SET))
        {
          error (_("Unable to seek to start of dynamic information\n"));
-         gnu_hash_error = TRUE;
          goto no_gnu_hash;
        }
 
       if (fread (nb, 16, 1, filedata->handle) != 1)
        {
          error (_("Failed to read in number of buckets\n"));
-         gnu_hash_error = TRUE;
          goto no_gnu_hash;
        }
 
@@ -10062,7 +10266,6 @@ get_num_dynamic_syms (Filedata * filedata)
                 SEEK_SET))
        {
          error (_("Unable to seek to start of dynamic information\n"));
-         gnu_hash_error = TRUE;
          goto no_gnu_hash;
        }
 
@@ -10070,29 +10273,20 @@ get_num_dynamic_syms (Filedata * filedata)
        = get_dynamic_data (filedata, filedata->ngnubuckets, 4);
 
       if (filedata->gnubuckets == NULL)
-       {
-         gnu_hash_error = TRUE;
-         goto no_gnu_hash;
-       }
+       goto no_gnu_hash;
 
       for (i = 0; i < filedata->ngnubuckets; i++)
        if (filedata->gnubuckets[i] != 0)
          {
            if (filedata->gnubuckets[i] < filedata->gnusymidx)
-             {
-               gnu_hash_error = TRUE;
-               goto no_gnu_hash;
-             }
+             goto no_gnu_hash;
 
            if (maxchain == 0xffffffff || filedata->gnubuckets[i] > maxchain)
              maxchain = filedata->gnubuckets[i];
          }
 
       if (maxchain == 0xffffffff)
-       {
-         gnu_hash_error = TRUE;
-         goto no_gnu_hash;
-       }
+       goto no_gnu_hash;
 
       maxchain -= filedata->gnusymidx;
 
@@ -10105,7 +10299,6 @@ get_num_dynamic_syms (Filedata * filedata)
                 SEEK_SET))
        {
          error (_("Unable to seek to start of dynamic information\n"));
-         gnu_hash_error = TRUE;
          goto no_gnu_hash;
        }
 
@@ -10114,15 +10307,11 @@ get_num_dynamic_syms (Filedata * filedata)
          if (fread (nb, 4, 1, filedata->handle) != 1)
            {
              error (_("Failed to determine last chain length\n"));
-             gnu_hash_error = TRUE;
              goto no_gnu_hash;
            }
 
          if (maxchain + 1 == 0)
-           {
-             gnu_hash_error = TRUE;
-             goto no_gnu_hash;
-           }
+           goto no_gnu_hash;
 
          ++maxchain;
        }
@@ -10136,7 +10325,6 @@ get_num_dynamic_syms (Filedata * filedata)
                 SEEK_SET))
        {
          error (_("Unable to seek to start of dynamic information\n"));
-         gnu_hash_error = TRUE;
          goto no_gnu_hash;
        }
 
@@ -10144,10 +10332,7 @@ get_num_dynamic_syms (Filedata * filedata)
       filedata->ngnuchains = maxchain;
 
       if (filedata->gnuchains == NULL)
-       {
-         gnu_hash_error = TRUE;
-         goto no_gnu_hash;
-       }
+       goto no_gnu_hash;
 
       if (filedata->dynamic_info_DT_MIPS_XHASH)
        {
@@ -10159,11 +10344,12 @@ get_num_dynamic_syms (Filedata * filedata)
                     SEEK_SET))
            {
              error (_("Unable to seek to start of dynamic information\n"));
-             gnu_hash_error = TRUE;
              goto no_gnu_hash;
            }
 
          filedata->mipsxlat = get_dynamic_data (filedata, maxchain, 4);
+         if (filedata->mipsxlat == NULL)
+           goto no_gnu_hash;
        }
 
       for (hn = 0; hn < filedata->ngnubuckets; ++hn)
@@ -10176,7 +10362,8 @@ get_num_dynamic_syms (Filedata * filedata)
              {
                if (filedata->dynamic_info_DT_MIPS_XHASH)
                  {
-                   if (filedata->mipsxlat[off] >= num_of_syms)
+                   if (off < filedata->ngnuchains
+                       && filedata->mipsxlat[off] >= num_of_syms)
                      num_of_syms = filedata->mipsxlat[off] + 1;
                  }
                else
@@ -10190,24 +10377,15 @@ get_num_dynamic_syms (Filedata * filedata)
                   && (filedata->gnuchains[off++] & 1) == 0);
          }
 
-    no_gnu_hash:
-      if (gnu_hash_error)
+      if (num_of_syms == 0)
        {
-         if (filedata->mipsxlat)
-           {
-             free (filedata->mipsxlat);
-             filedata->mipsxlat = NULL;
-           }
-         if (filedata->gnuchains)
-           {
-             free (filedata->gnuchains);
-             filedata->gnuchains = NULL;
-           }
-         if (filedata->gnubuckets)
-           {
-             free (filedata->gnubuckets);
-             filedata->gnubuckets = NULL;
-           }
+       no_gnu_hash:
+         free (filedata->mipsxlat);
+         filedata->mipsxlat = NULL;
+         free (filedata->gnuchains);
+         filedata->gnuchains = NULL;
+         free (filedata->gnubuckets);
+         filedata->gnubuckets = NULL;
          filedata->ngnubuckets = 0;
          filedata->ngnuchains = 0;
        }
@@ -10310,6 +10488,18 @@ process_dynamic_section (Filedata * filedata)
                  section.sh_size = (num_of_syms
                                     * filedata->dynamic_info[DT_SYMENT]);
                  section.sh_entsize = filedata->dynamic_info[DT_SYMENT];
+
+                 if (do_checks
+                     && filedata->dynamic_symtab_section != NULL
+                     && ((filedata->dynamic_symtab_section->sh_offset
+                          != section.sh_offset)
+                         || (filedata->dynamic_symtab_section->sh_size
+                             != section.sh_size)
+                         || (filedata->dynamic_symtab_section->sh_entsize
+                             != section.sh_entsize)))
+                   warn (_("\
+the .dynsym section doesn't match the DT_SYMTAB and DT_SYMENT tags\n"));
+
                  section.sh_name = filedata->string_table_length;
                  filedata->dynamic_symbols
                    = GET_ELF_SYMBOLS (filedata, &section,
@@ -10347,6 +10537,15 @@ process_dynamic_section (Filedata * filedata)
            offset = offset_from_vma (filedata,
                                      filedata->dynamic_info[DT_STRTAB],
                                      str_tab_len);
+           if (do_checks
+               && filedata->dynamic_strtab_section
+               && ((filedata->dynamic_strtab_section->sh_offset
+                    != (file_ptr) offset)
+                   || (filedata->dynamic_strtab_section->sh_size
+                       != str_tab_len)))
+             warn (_("\
+the .dynstr section doesn't match the DT_STRTAB and DT_STRSZ tags\n"));
+
            filedata->dynamic_strings
              = (char *) get_data (NULL, filedata, offset, 1, str_tab_len,
                                   _("dynamic string table"));
@@ -10893,6 +11092,28 @@ process_dynamic_section (Filedata * filedata)
            }
          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)]
@@ -11230,7 +11451,7 @@ process_version_sections (Filedata * filedata)
                  }
 
                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))
@@ -12027,9 +12248,10 @@ print_dynamic_symbol (Filedata *filedata, unsigned long si,
        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,
@@ -12037,6 +12259,22 @@ print_dynamic_symbol (Filedata *filedata, unsigned long si,
                                  || 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)
@@ -12060,35 +12298,285 @@ print_dynamic_symbol (Filedata *filedata, unsigned long si,
          si, printable_section_name (filedata, section), section->sh_info);
 }
 
-/* Dump the symbol table.  */
-static bfd_boolean
-process_symbol_table (Filedata * filedata)
+static const char *
+get_lto_kind (unsigned int kind)
 {
-  Elf_Internal_Shdr * section;
+  switch (kind)
+    {
+    case 0: return "DEF";
+    case 1: return "WEAKDEF";
+    case 2: return "UNDEF";
+    case 3: return "WEAKUNDEF";
+    case 4: return "COMMON";
+    default:
+      break;
+    }
 
-  if (!do_syms && !do_dyn_syms && !do_histogram)
-    return TRUE;
+  static char buffer[30];
+  error (_("Unknown LTO symbol definition encountered: %u\n"), kind);
+  sprintf (buffer, "<unknown: %u>", kind);
+  return buffer;
+}
 
-  if ((filedata->dynamic_info[DT_HASH] || filedata->dynamic_info_DT_GNU_HASH)
-      && do_syms
-      && do_using_dynamic
-      && filedata->dynamic_strings != NULL
-      && filedata->dynamic_symbols != NULL)
+static const char *
+get_lto_visibility (unsigned int visibility)
+{
+  switch (visibility)
     {
-      unsigned long si;
+    case 0: return "DEFAULT";
+    case 1: return "PROTECTED";
+    case 2: return "INTERNAL";
+    case 3: return "HIDDEN";
+    default:
+      break;
+    }
 
-      printf (ngettext ("\nSymbol table for image contains %lu entry:\n",
-                       "\nSymbol table for image contains %lu entries:\n",
-                       filedata->num_dynamic_syms),
-             filedata->num_dynamic_syms);
-      if (is_32bit_elf)
-       printf (_("   Num:    Value  Size Type    Bind   Vis      Ndx Name\n"));
-      else
-       printf (_("   Num:    Value          Size Type    Bind   Vis      Ndx Name\n"));
+  static char buffer[30];
+  error (_("Unknown LTO symbol visibility encountered: %u\n"), visibility);
+  sprintf (buffer, "<unknown: %u>", visibility);
+  return buffer;
+}
 
-      for (si = 0; si < filedata->num_dynamic_syms; si++)
-       print_dynamic_symbol (filedata, si, filedata->dynamic_symbols, NULL,
-                             filedata->dynamic_strings,
+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)
+{
+  Elf_Internal_Shdr * section;
+
+  if (!do_syms && !do_dyn_syms && !do_histogram)
+    return TRUE;
+
+  if ((filedata->dynamic_info[DT_HASH] || filedata->dynamic_info_DT_GNU_HASH)
+      && do_syms
+      && do_using_dynamic
+      && filedata->dynamic_strings != NULL
+      && filedata->dynamic_symbols != NULL)
+    {
+      unsigned long si;
+
+      printf (ngettext ("\nSymbol table for image contains %lu entry:\n",
+                       "\nSymbol table for image contains %lu entries:\n",
+                       filedata->num_dynamic_syms),
+             filedata->num_dynamic_syms);
+      if (is_32bit_elf)
+       printf (_("   Num:    Value  Size Type    Bind   Vis      Ndx Name\n"));
+      else
+       printf (_("   Num:    Value          Size Type    Bind   Vis      Ndx Name\n"));
+
+      for (si = 0; si < filedata->num_dynamic_syms; si++)
+       print_dynamic_symbol (filedata, si, filedata->dynamic_symbols, NULL,
+                             filedata->dynamic_strings,
                              filedata->dynamic_strings_length);
     }
   else if ((do_dyn_syms || (do_syms && !do_using_dynamic))
@@ -12467,10 +12955,12 @@ target_specific_reloc_handling (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"),
@@ -12485,12 +12975,14 @@ target_specific_reloc_handling (Filedata *           filedata,
 
          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;
@@ -12498,10 +12990,30 @@ target_specific_reloc_handling (Filedata *           filedata,
          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
@@ -13861,18 +14373,12 @@ dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata)
            }
          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)
                {
@@ -14110,10 +14616,11 @@ dump_section_as_bytes (Elf_Internal_Shdr *  section,
   return FALSE;
 }
 
+#ifdef ENABLE_LIBCTF
 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;
 
@@ -14124,8 +14631,9 @@ shdr_to_ctf_sect (ctf_sect_t *buf, Elf_Internal_Shdr *shdr, Filedata *filedata)
    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;
@@ -14135,6 +14643,80 @@ static char *dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,
   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)
 {
@@ -14148,26 +14730,22 @@ 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)
     {
@@ -14184,7 +14762,7 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
       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)
        {
@@ -14216,23 +14794,42 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
       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;
@@ -14240,36 +14837,24 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata)
   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);
   free (strdata);
   return ret;
 }
+#endif
 
 static bfd_boolean
 load_specific_debug_section (enum dwarf_section_display_enum  debug,
@@ -14597,18 +15182,15 @@ free_debug_section (enum dwarf_section_display_enum debug)
   section->address = 0;
   section->size = 0;
 
-  if (section->reloc_info != NULL)
-    {
-      free (section->reloc_info);
-      section->reloc_info = NULL;
-      section->num_relocs = 0;
-    }
+  free (section->reloc_info);
+  section->reloc_info = NULL;
+  section->num_relocs = 0;
 }
 
 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;
@@ -14697,7 +15279,8 @@ initialise_dumps_byname (Filedata * filedata)
       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;
@@ -14758,11 +15341,13 @@ process_section_contents (Filedata * filedata)
            res = FALSE;
        }
 
+#ifdef ENABLE_LIBCTF
       if (dump & CTF_DUMP)
        {
          if (! dump_section_as_ctf (section, filedata))
            res = FALSE;
        }
+#endif
     }
 
   /* Check to see if the user requested a
@@ -15032,77 +15617,77 @@ typedef struct
   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) \
@@ -15348,6 +15933,44 @@ display_gnu_attribute (unsigned char * p,
   return display_tag_value (tag, p, end);
 }
 
+static unsigned char *
+display_m68k_gnu_attribute (unsigned char * p,
+                           unsigned int tag,
+                           const unsigned char * const end)
+{
+  unsigned int val;
+
+  if (tag == Tag_GNU_M68K_ABI_FP)
+    {
+      printf ("  Tag_GNU_M68K_ABI_FP: ");
+      if (p == end)
+       {
+         printf (_("<corrupt>\n"));
+         return p;
+       }
+      READ_ULEB (val, p, end);
+
+      if (val > 3)
+       printf ("(%#x), ", val);
+
+      switch (val & 3)
+       {
+       case 0:
+         printf (_("unspecified hard/soft float\n"));
+         break;
+       case 1:
+         printf (_("hard float\n"));
+         break;
+       case 2:
+         printf (_("soft float\n"));
+         break;
+       }
+      return p;
+    }
+
+  return display_tag_value (tag & 1, p, end);
+}
+
 static unsigned char *
 display_power_gnu_attribute (unsigned char * p,
                             unsigned int tag,
@@ -15965,7 +16588,7 @@ display_raw_attribute (unsigned char * p, unsigned char const * const end)
 }
 
 static unsigned char *
-display_msp430x_attribute (unsigned char * p,
+display_msp430_attribute (unsigned char * p,
                           const unsigned char * const end)
 {
   unsigned int val;
@@ -16149,6 +16772,110 @@ display_riscv_attribute (unsigned char *p,
   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,
@@ -16706,8 +17433,7 @@ process_mips_specific (Filedata * filedata)
            }
 
        sgot_print_fail:
-         if (data)
-           free (data);
+         free (data);
        }
       return res;
     }
@@ -16877,47 +17603,28 @@ process_mips_specific (Filedata * filedata)
                                                 sect->sh_size, _("options"));
       if (eopt)
        {
-         Elf_Internal_Options * iopt;
-         Elf_Internal_Options * option;
-         Elf_Internal_Options * iopt_end;
-
-         iopt = (Elf_Internal_Options *)
-              cmalloc ((sect->sh_size / sizeof (eopt)), sizeof (* iopt));
-         if (iopt == NULL)
-           {
-             error (_("Out of memory allocating space for MIPS options\n"));
-             free (eopt);
-             return FALSE;
-           }
+         Elf_Internal_Options option;
 
          offset = cnt = 0;
-         option = iopt;
-         iopt_end = iopt + (sect->sh_size / sizeof (eopt));
-         
          while (offset <= sect->sh_size - sizeof (* eopt))
            {
              Elf_External_Options * eoption;
+             unsigned int optsize;
 
              eoption = (Elf_External_Options *) ((char *) eopt + offset);
 
-             option->kind = BYTE_GET (eoption->kind);
-             option->size = BYTE_GET (eoption->size);
-             option->section = BYTE_GET (eoption->section);
-             option->info = BYTE_GET (eoption->info);
+             optsize = BYTE_GET (eoption->size);
 
              /* PR 17531: file: ffa0fa3b.  */
-             if (option->size < sizeof (* eopt)
-                 || offset + option->size > sect->sh_size)
+             if (optsize < sizeof (* eopt)
+                 || optsize > sect->sh_size - offset)
                {
                  error (_("Invalid size (%u) for MIPS option\n"),
-                        option->size);
-                 free (iopt);
+                        optsize);
                  free (eopt);
                  return FALSE;
                }
-             offset += option->size;
-
-             ++option;
+             offset += optsize;
              ++cnt;
            }
 
@@ -16926,18 +17633,25 @@ process_mips_specific (Filedata * filedata)
                            cnt),
                  printable_section_name (filedata, sect), cnt);
 
-         option = iopt;
          offset = 0;
-
          while (cnt-- > 0)
            {
              size_t len;
+             Elf_External_Options * eoption;
+
+             eoption = (Elf_External_Options *) ((char *) eopt + offset);
+
+             option.kind = BYTE_GET (eoption->kind);
+             option.size = BYTE_GET (eoption->size);
+             option.section = BYTE_GET (eoption->section);
+             option.info = BYTE_GET (eoption->info);
 
-             switch (option->kind)
+             switch (option.kind)
                {
                case ODK_NULL:
                  /* This shouldn't happen.  */
-                 printf (" NULL       %d %lx", option->section, option->info);
+                 printf (" NULL       %" PRId16 " %" PRIx32,
+                         option.section, option.info);
                  break;
 
                case ODK_REGINFO:
@@ -16948,7 +17662,8 @@ process_mips_specific (Filedata * filedata)
                      Elf32_RegInfo reginfo;
 
                      /* 32bit form.  */
-                     if (option + 2 > iopt_end)
+                     if (option.size < (sizeof (Elf_External_Options)
+                                        + sizeof (Elf32_External_RegInfo)))
                        {
                          printf (_("<corrupt>\n"));
                          error (_("Truncated MIPS REGINFO option\n"));
@@ -16956,7 +17671,7 @@ process_mips_specific (Filedata * filedata)
                          break;
                        }
 
-                     ereg = (Elf32_External_RegInfo *) (option + 1);
+                     ereg = (Elf32_External_RegInfo *) (eoption + 1);
 
                      reginfo.ri_gprmask = BYTE_GET (ereg->ri_gprmask);
                      reginfo.ri_cprmask[0] = BYTE_GET (ereg->ri_cprmask[0]);
@@ -16965,10 +17680,11 @@ process_mips_specific (Filedata * filedata)
                      reginfo.ri_cprmask[3] = BYTE_GET (ereg->ri_cprmask[3]);
                      reginfo.ri_gp_value = BYTE_GET (ereg->ri_gp_value);
 
-                     printf ("GPR %08lx  GP 0x%lx\n",
-                             reginfo.ri_gprmask,
-                             (unsigned long) reginfo.ri_gp_value);
-                     printf ("            CPR0 %08lx  CPR1 %08lx  CPR2 %08lx  CPR3 %08lx\n",
+                     printf ("GPR %08" PRIx32 "  GP 0x%" PRIx32 "\n",
+                             reginfo.ri_gprmask, reginfo.ri_gp_value);
+                     printf ("          "
+                             "  CPR0 %08" PRIx32 "  CPR1 %08" PRIx32
+                             "  CPR2 %08" PRIx32 "  CPR3 %08" PRIx32 "\n",
                              reginfo.ri_cprmask[0], reginfo.ri_cprmask[1],
                              reginfo.ri_cprmask[2], reginfo.ri_cprmask[3]);
                    }
@@ -16978,7 +17694,8 @@ process_mips_specific (Filedata * filedata)
                      Elf64_External_RegInfo * ereg;
                      Elf64_Internal_RegInfo reginfo;
 
-                     if (option + 2 > iopt_end)
+                     if (option.size < (sizeof (Elf_External_Options)
+                                        + sizeof (Elf64_External_RegInfo)))
                        {
                          printf (_("<corrupt>\n"));
                          error (_("Truncated MIPS REGINFO option\n"));
@@ -16986,7 +17703,7 @@ process_mips_specific (Filedata * filedata)
                          break;
                        }
 
-                     ereg = (Elf64_External_RegInfo *) (option + 1);
+                     ereg = (Elf64_External_RegInfo *) (eoption + 1);
                      reginfo.ri_gprmask    = BYTE_GET (ereg->ri_gprmask);
                      reginfo.ri_cprmask[0] = BYTE_GET (ereg->ri_cprmask[0]);
                      reginfo.ri_cprmask[1] = BYTE_GET (ereg->ri_cprmask[1]);
@@ -16994,54 +17711,53 @@ process_mips_specific (Filedata * filedata)
                      reginfo.ri_cprmask[3] = BYTE_GET (ereg->ri_cprmask[3]);
                      reginfo.ri_gp_value   = BYTE_GET (ereg->ri_gp_value);
 
-                     printf ("GPR %08lx  GP 0x",
-                             reginfo.ri_gprmask);
-                     printf_vma (reginfo.ri_gp_value);
-                     printf ("\n");
-
-                     printf ("            CPR0 %08lx  CPR1 %08lx  CPR2 %08lx  CPR3 %08lx\n",
+                     printf ("GPR %08" PRIx32 "  GP 0x%" PRIx64 "\n",
+                             reginfo.ri_gprmask, reginfo.ri_gp_value);
+                     printf ("          "
+                             "  CPR0 %08" PRIx32 "  CPR1 %08" PRIx32
+                             "  CPR2 %08" PRIx32 "  CPR3 %08" PRIx32 "\n",
                              reginfo.ri_cprmask[0], reginfo.ri_cprmask[1],
                              reginfo.ri_cprmask[2], reginfo.ri_cprmask[3]);
                    }
-                 ++option;
+                 offset += option.size;
                  continue;
 
                case ODK_EXCEPTIONS:
                  fputs (" EXCEPTIONS fpe_min(", stdout);
-                 process_mips_fpe_exception (option->info & OEX_FPU_MIN);
+                 process_mips_fpe_exception (option.info & OEX_FPU_MIN);
                  fputs (") fpe_max(", stdout);
-                 process_mips_fpe_exception ((option->info & OEX_FPU_MAX) >> 8);
+                 process_mips_fpe_exception ((option.info & OEX_FPU_MAX) >> 8);
                  fputs (")", stdout);
 
-                 if (option->info & OEX_PAGE0)
+                 if (option.info & OEX_PAGE0)
                    fputs (" PAGE0", stdout);
-                 if (option->info & OEX_SMM)
+                 if (option.info & OEX_SMM)
                    fputs (" SMM", stdout);
-                 if (option->info & OEX_FPDBUG)
+                 if (option.info & OEX_FPDBUG)
                    fputs (" FPDBUG", stdout);
-                 if (option->info & OEX_DISMISS)
+                 if (option.info & OEX_DISMISS)
                    fputs (" DISMISS", stdout);
                  break;
 
                case ODK_PAD:
                  fputs (" PAD       ", stdout);
-                 if (option->info & OPAD_PREFIX)
+                 if (option.info & OPAD_PREFIX)
                    fputs (" PREFIX", stdout);
-                 if (option->info & OPAD_POSTFIX)
+                 if (option.info & OPAD_POSTFIX)
                    fputs (" POSTFIX", stdout);
-                 if (option->info & OPAD_SYMBOL)
+                 if (option.info & OPAD_SYMBOL)
                    fputs (" SYMBOL", stdout);
                  break;
 
                case ODK_HWPATCH:
                  fputs (" HWPATCH   ", stdout);
-                 if (option->info & OHW_R4KEOP)
+                 if (option.info & OHW_R4KEOP)
                    fputs (" R4KEOP", stdout);
-                 if (option->info & OHW_R8KPFETCH)
+                 if (option.info & OHW_R8KPFETCH)
                    fputs (" R8KPFETCH", stdout);
-                 if (option->info & OHW_R5KEOP)
+                 if (option.info & OHW_R5KEOP)
                    fputs (" R5KEOP", stdout);
-                 if (option->info & OHW_R5KCVTL)
+                 if (option.info & OHW_R5KCVTL)
                    fputs (" R5KCVTL", stdout);
                  break;
 
@@ -17057,43 +17773,43 @@ process_mips_specific (Filedata * filedata)
 
                case ODK_HWAND:
                  fputs (" HWAND     ", stdout);
-                 if (option->info & OHWA0_R4KEOP_CHECKED)
+                 if (option.info & OHWA0_R4KEOP_CHECKED)
                    fputs (" R4KEOP_CHECKED", stdout);
-                 if (option->info & OHWA0_R4KEOP_CLEAN)
+                 if (option.info & OHWA0_R4KEOP_CLEAN)
                    fputs (" R4KEOP_CLEAN", stdout);
                  break;
 
                case ODK_HWOR:
                  fputs (" HWOR      ", stdout);
-                 if (option->info & OHWA0_R4KEOP_CHECKED)
+                 if (option.info & OHWA0_R4KEOP_CHECKED)
                    fputs (" R4KEOP_CHECKED", stdout);
-                 if (option->info & OHWA0_R4KEOP_CLEAN)
+                 if (option.info & OHWA0_R4KEOP_CLEAN)
                    fputs (" R4KEOP_CLEAN", stdout);
                  break;
 
                case ODK_GP_GROUP:
-                 printf (" GP_GROUP  %#06lx  self-contained %#06lx",
-                         option->info & OGP_GROUP,
-                         (option->info & OGP_SELF) >> 16);
+                 printf (" GP_GROUP  %#06x  self-contained %#06x",
+                         option.info & OGP_GROUP,
+                         (option.info & OGP_SELF) >> 16);
                  break;
 
                case ODK_IDENT:
-                 printf (" IDENT     %#06lx  self-contained %#06lx",
-                         option->info & OGP_GROUP,
-                         (option->info & OGP_SELF) >> 16);
+                 printf (" IDENT     %#06x  self-contained %#06x",
+                         option.info & OGP_GROUP,
+                         (option.info & OGP_SELF) >> 16);
                  break;
 
                default:
                  /* This shouldn't happen.  */
-                 printf (" %3d ???     %d %lx",
-                         option->kind, option->section, option->info);
+                 printf (" %3d ???     %" PRId16 " %" PRIx32,
+                         option.kind, option.section, option.info);
                  break;
                }
 
              len = sizeof (* eopt);
-             while (len < option->size)
+             while (len < option.size)
                {
-                 unsigned char datum = * ((unsigned char *) eopt + offset + len);
+                 unsigned char datum = *((unsigned char *) eoption + len);
 
                  if (ISPRINT (datum))
                    printf ("%c", datum);
@@ -17103,10 +17819,8 @@ process_mips_specific (Filedata * filedata)
                }
              fputs ("\n", stdout);
 
-             offset += option->size;
-             ++option;
+             offset += option.size;
            }
-         free (iopt);
          free (eopt);
        }
       else
@@ -17339,8 +18053,7 @@ process_mips_specific (Filedata * filedata)
        }
 
     got_print_fail:
-      if (data)
-       free (data);
+      free (data);
     }
 
   if (mips_pltgot != 0 && jmprel != 0 && pltrel != 0 && pltrelsz != 0)
@@ -17372,7 +18085,10 @@ process_mips_specific (Filedata * filedata)
       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"));
@@ -17417,8 +18133,7 @@ process_mips_specific (Filedata * filedata)
        }
       printf ("\n");
 
-      if (data)
-       free (data);
+      free (data);
       free (rels);
     }
 
@@ -17431,18 +18146,21 @@ process_nds32_specific (Filedata * filedata)
   Elf_Internal_Shdr *sect = NULL;
 
   sect = find_section (filedata, ".nds32_e_flags");
-  if (sect != NULL)
+  if (sect != NULL && sect->sh_size >= 4)
     {
-      unsigned int *flag;
+      unsigned char *buf;
+      unsigned int flag;
 
       printf ("\nNDS32 elf flags section:\n");
-      flag = get_data (NULL, filedata, sect->sh_offset, 1,
-                      sect->sh_size, _("NDS32 elf flags section"));
+      buf = get_data (NULL, filedata, sect->sh_offset, 1, 4,
+                     _("NDS32 elf flags section"));
 
-      if (! flag)
+      if (buf == NULL)
        return FALSE;
 
-      switch ((*flag) & 0x3)
+      flag = byte_get (buf, 4);
+      free (buf);
+      switch (flag & 0x3)
        {
        case 0:
          printf ("(VEC_SIZE):\tNo entry.\n");
@@ -17616,6 +18334,8 @@ get_note_type (Filedata * filedata, unsigned e_type)
        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:
@@ -17885,7 +18605,7 @@ decode_x86_compat_isa (unsigned int bitmask)
 }
 
 static void
-decode_x86_isa (unsigned int bitmask)
+decode_x86_compat_2_isa (unsigned int bitmask)
 {
   if (!bitmask)
     {
@@ -17900,79 +18620,79 @@ decode_x86_isa (unsigned int 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:
@@ -17984,6 +18704,37 @@ decode_x86_isa (unsigned int bitmask)
     }
 }
 
+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)
 {
@@ -18006,6 +18757,12 @@ 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;
@@ -18049,6 +18806,12 @@ decode_x86_feature_2 (unsigned int bitmask)
        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;
@@ -18227,6 +18990,28 @@ print_gnu_property_note (Filedata * filedata, Elf_Internal_Note * pnote)
                    }
                  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;
                }
@@ -19345,7 +20130,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
 
        while (bytes --)
          {
-           unsigned long byte = (* name ++) & 0xff;
+           unsigned long long byte = *name++ & 0xff;
 
            val |= byte << shift;
            shift += 8;
@@ -19687,11 +20472,8 @@ process_notes_at (Filedata *           filedata,
       if (! process_note (& inote, filedata))
        res = FALSE;
 
-      if (temp != NULL)
-       {
-         free (temp);
-         temp = NULL;
-       }
+      free (temp);
+      temp = NULL;
     }
 
   free (pnotes);
@@ -19913,7 +20695,7 @@ process_arch_specific (Filedata * filedata)
 
     case EM_MSP430:
      return process_attributes (filedata, "mspabi", SHT_MSP430_ATTRIBUTES,
-                               display_msp430x_attribute,
+                               display_msp430_attribute,
                                display_msp430_gnu_attribute);
 
     case EM_RISCV:
@@ -19924,6 +20706,10 @@ process_arch_specific (Filedata * filedata)
     case EM_NDS32:
       return process_nds32_specific (filedata);
 
+    case EM_68K:
+      return process_attributes (filedata, NULL, SHT_GNU_ATTRIBUTES, NULL,
+                                display_m68k_gnu_attribute);
+
     case EM_PPC:
     case EM_PPC64:
       return process_attributes (filedata, NULL, SHT_GNU_ATTRIBUTES, NULL,
@@ -19945,6 +20731,10 @@ process_arch_specific (Filedata * filedata)
                                 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,
@@ -20197,6 +20987,9 @@ process_object (Filedata * filedata)
   if (! process_symbol_table (filedata))
     res = FALSE;
 
+  if (! process_lto_symbol_tables (filedata))
+    res = FALSE;
+
   if (! process_syminfo (filedata))
     res = FALSE;
 
@@ -20245,38 +21038,23 @@ process_object (Filedata * filedata)
   filedata->string_table = NULL;
   filedata->string_table_length = 0;
 
-  if (filedata->dump.dump_sects != NULL)
-    {
-      free (filedata->dump.dump_sects);
-      filedata->dump.dump_sects = NULL;
-      filedata->dump.num_dump_sects = 0;
-    }
+  free (filedata->dump.dump_sects);
+  filedata->dump.dump_sects = NULL;
+  filedata->dump.num_dump_sects = 0;
 
-  if (filedata->dynamic_strings)
-    {
-      free (filedata->dynamic_strings);
-      filedata->dynamic_strings = NULL;
-      filedata->dynamic_strings_length = 0;
-    }
+  free (filedata->dynamic_strings);
+  filedata->dynamic_strings = NULL;
+  filedata->dynamic_strings_length = 0;
 
-  if (filedata->dynamic_symbols)
-    {
-      free (filedata->dynamic_symbols);
-      filedata->dynamic_symbols = NULL;
-      filedata->num_dynamic_syms = 0;
-    }
+  free (filedata->dynamic_symbols);
+  filedata->dynamic_symbols = NULL;
+  filedata->num_dynamic_syms = 0;
 
-  if (filedata->dynamic_syminfo)
-    {
-      free (filedata->dynamic_syminfo);
-      filedata->dynamic_syminfo = NULL;
-    }
+  free (filedata->dynamic_syminfo);
+  filedata->dynamic_syminfo = NULL;
 
-  if (filedata->dynamic_section)
-    {
-      free (filedata->dynamic_section);
-      filedata->dynamic_section = NULL;
-    }
+  free (filedata->dynamic_section);
+  filedata->dynamic_section = NULL;
 
   while (filedata->symtab_shndx_list != NULL)
     {
@@ -20285,11 +21063,8 @@ process_object (Filedata * filedata)
       filedata->symtab_shndx_list = next;
     }
 
-  if (filedata->section_headers_groups)
-    {
-      free (filedata->section_headers_groups);
-      filedata->section_headers_groups = NULL;
-    }
+  free (filedata->section_headers_groups);
+  filedata->section_headers_groups = NULL;
 
   if (filedata->section_groups)
     {
@@ -20667,7 +21442,7 @@ process_file (char * file_name)
     }
   else
     {
-      if (do_archive_index)
+      if (do_archive_index && !check_all)
        error (_("File %s is not an archive so its index cannot be displayed.\n"),
               file_name);
 
@@ -20733,9 +21508,14 @@ main (int argc, char ** argv)
   parse_args (& cmdline, argc, argv);
 
   if (optind < (argc - 1))
+    /* When displaying information for more than one file,
+       prefix the information with the file name.  */
     show_name = TRUE;
   else if (optind >= argc)
     {
+      /* Ensure that the warning is always displayed.  */
+      do_checks = TRUE;
+
       warn (_("Nothing to do.\n"));
       usage (stderr);
     }
@@ -20745,8 +21525,7 @@ main (int argc, char ** argv)
     if (! process_file (argv[optind++]))
       err = TRUE;
 
-  if (cmdline.dump_sects != NULL)
-    free (cmdline.dump_sects);
+  free (cmdline.dump_sects);
 
   free (dump_ctf_symtab_name);
   free (dump_ctf_strtab_name);
This page took 0.070149 seconds and 4 git commands to generate.