]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - binutils/readelf.c
Use the thread_section_name helper class in fbsd_core_thread_name.
[thirdparty/binutils-gdb.git] / binutils / readelf.c
index 60694ff724eef58a87fc04315891c089d52c9d73..b2f75c0048bfce11205102dc543bc7ca5a6f669f 100644 (file)
 #include "elf/v850.h"
 #include "elf/vax.h"
 #include "elf/visium.h"
+#include "elf/wasm32.h"
 #include "elf/x86-64.h"
 #include "elf/xc16x.h"
 #include "elf/xgate.h"
@@ -480,7 +481,7 @@ print_symbol (signed int width, const char *symbol)
 
   if (width < 0)
     {
-      /* Keep the width positive.  This also helps.  */
+      /* Keep the width positive.  This helps the code below.  */
       width = - width;
       extra_padding = TRUE;
     }
@@ -809,6 +810,7 @@ guess_is_rela (unsigned int e_machine)
     case EM_XTENSA_OLD:
     case EM_MICROBLAZE:
     case EM_MICROBLAZE_OLD:
+    case EM_WEBASSEMBLY:
       return TRUE;
 
     case EM_68HC05:
@@ -1498,6 +1500,10 @@ dump_relocations (FILE * file,
          rtype = elf_tilepro_reloc_type (type);
          break;
 
+       case EM_WEBASSEMBLY:
+         rtype = elf_wasm32_reloc_type (type);
+         break;
+
        case EM_XGATE:
          rtype = elf_xgate_reloc_type (type);
          break;
@@ -2205,11 +2211,11 @@ get_machine_name (unsigned e_machine)
 
   switch (e_machine)
     {
+      /* Please keep this switch table sorted by increasing EM_ value.  */
+      /* 0 */
     case EM_NONE:              return _("None");
-    case EM_AARCH64:           return "AArch64";
     case EM_M32:               return "WE32100";
     case EM_SPARC:             return "Sparc";
-    case EM_SPU:               return "SPU";
     case EM_386:               return "Intel 80386";
     case EM_68K:               return "MC68000";
     case EM_88K:               return "MC88000";
@@ -2217,61 +2223,50 @@ get_machine_name (unsigned e_machine)
     case EM_860:               return "Intel 80860";
     case EM_MIPS:              return "MIPS R3000";
     case EM_S370:              return "IBM System/370";
+      /* 10 */
     case EM_MIPS_RS3_LE:       return "MIPS R4000 big-endian";
     case EM_OLD_SPARCV9:       return "Sparc v9 (old)";
     case EM_PARISC:            return "HPPA";
-    case EM_PPC_OLD:           return "Power PC (old)";
+    case EM_VPP550:            return "Fujitsu VPP500";
     case EM_SPARC32PLUS:       return "Sparc v8+" ;
     case EM_960:               return "Intel 90860";
     case EM_PPC:               return "PowerPC";
+      /* 20 */
     case EM_PPC64:             return "PowerPC64";
+    case EM_S390_OLD:
+    case EM_S390:              return "IBM S/390";
+    case EM_SPU:               return "SPU";
+      /* 30 */
+    case EM_V800:              return "Renesas V850 (using RH850 ABI)";
     case EM_FR20:              return "Fujitsu FR20";
-    case EM_FT32:              return "FTDI FT32";
     case EM_RH32:              return "TRW RH32";
     case EM_MCORE:             return "MCORE";
+      /* 40 */
     case EM_ARM:               return "ARM";
     case EM_OLD_ALPHA:         return "Digital Alpha (old)";
     case EM_SH:                        return "Renesas / SuperH SH";
     case EM_SPARCV9:           return "Sparc v9";
     case EM_TRICORE:           return "Siemens Tricore";
     case EM_ARC:               return "ARC";
-    case EM_ARC_COMPACT:       return "ARCompact";
-    case EM_ARC_COMPACT2:      return "ARCv2";
     case EM_H8_300:            return "Renesas H8/300";
     case EM_H8_300H:           return "Renesas H8/300H";
     case EM_H8S:               return "Renesas H8S";
     case EM_H8_500:            return "Renesas H8/500";
+      /* 50 */
     case EM_IA_64:             return "Intel IA-64";
     case EM_MIPS_X:            return "Stanford MIPS-X";
     case EM_COLDFIRE:          return "Motorola Coldfire";
-    case EM_ALPHA:             return "Alpha";
-    case EM_CYGNUS_D10V:
-    case EM_D10V:              return "d10v";
-    case EM_CYGNUS_D30V:
-    case EM_D30V:              return "d30v";
-    case EM_CYGNUS_M32R:
-    case EM_M32R:              return "Renesas M32R (formerly Mitsubishi M32r)";
-    case EM_CYGNUS_V850:
-    case EM_V800:              return "Renesas V850 (using RH850 ABI)";
-    case EM_V850:              return "Renesas V850";
-    case EM_CYGNUS_MN10300:
-    case EM_MN10300:           return "mn10300";
-    case EM_CYGNUS_MN10200:
-    case EM_MN10200:           return "mn10200";
-    case EM_MOXIE:             return "Moxie";
-    case EM_CYGNUS_FR30:
-    case EM_FR30:              return "Fujitsu FR30";
-    case EM_CYGNUS_FRV:                return "Fujitsu FR-V";
-    case EM_PJ_OLD:
-    case EM_PJ:                        return "picoJava";
+    case EM_68HC12:            return "Motorola MC68HC12 Microcontroller";
     case EM_MMA:               return "Fujitsu Multimedia Accelerator";
     case EM_PCP:               return "Siemens PCP";
     case EM_NCPU:              return "Sony nCPU embedded RISC processor";
     case EM_NDR1:              return "Denso NDR1 microprocesspr";
     case EM_STARCORE:          return "Motorola Star*Core processor";
     case EM_ME16:              return "Toyota ME16 processor";
+      /* 60 */
     case EM_ST100:             return "STMicroelectronics ST100 processor";
     case EM_TINYJ:             return "Advanced Logic Corp. TinyJ embedded processor";
+    case EM_X86_64:            return "Advanced Micro Devices X86-64";
     case EM_PDSP:              return "Sony DSP processor";
     case EM_PDP10:             return "Digital Equipment Corp. PDP-10";
     case EM_PDP11:             return "Digital Equipment Corp. PDP-11";
@@ -2279,75 +2274,89 @@ get_machine_name (unsigned e_machine)
     case EM_ST9PLUS:           return "STMicroelectronics ST9+ 8/16 bit microcontroller";
     case EM_ST7:               return "STMicroelectronics ST7 8-bit microcontroller";
     case EM_68HC16:            return "Motorola MC68HC16 Microcontroller";
-    case EM_68HC12:            return "Motorola MC68HC12 Microcontroller";
+      /* 70 */
     case EM_68HC11:            return "Motorola MC68HC11 Microcontroller";
     case EM_68HC08:            return "Motorola MC68HC08 Microcontroller";
     case EM_68HC05:            return "Motorola MC68HC05 Microcontroller";
     case EM_SVX:               return "Silicon Graphics SVx";
     case EM_ST19:              return "STMicroelectronics ST19 8-bit microcontroller";
     case EM_VAX:               return "Digital VAX";
-    case EM_VISIUM:            return "CDS VISIUMcore processor";
-    case EM_AVR_OLD:
-    case EM_AVR:               return "Atmel AVR 8-bit microcontroller";
     case EM_CRIS:              return "Axis Communications 32-bit embedded processor";
     case EM_JAVELIN:           return "Infineon Technologies 32-bit embedded cpu";
     case EM_FIREPATH:          return "Element 14 64-bit DSP processor";
     case EM_ZSP:               return "LSI Logic's 16-bit DSP processor";
+      /* 80 */
     case EM_MMIX:              return "Donald Knuth's educational 64-bit processor";
     case EM_HUANY:             return "Harvard Universitys's machine-independent object format";
     case EM_PRISM:             return "Vitesse Prism";
-    case EM_X86_64:            return "Advanced Micro Devices X86-64";
-    case EM_L1OM:              return "Intel L1OM";
-    case EM_K1OM:              return "Intel K1OM";
-    case EM_S390_OLD:
-    case EM_S390:              return "IBM S/390";
-    case EM_SCORE:             return "SUNPLUS S+Core";
-    case EM_XSTORMY16:         return "Sanyo XStormy16 CPU core";
+    case EM_AVR_OLD:
+    case EM_AVR:               return "Atmel AVR 8-bit microcontroller";
+    case EM_CYGNUS_FR30:
+    case EM_FR30:              return "Fujitsu FR30";
+    case EM_CYGNUS_D10V:
+    case EM_D10V:              return "d10v";
+    case EM_CYGNUS_D30V:
+    case EM_D30V:              return "d30v";
+    case EM_CYGNUS_V850:
+    case EM_V850:              return "Renesas V850";
+    case EM_CYGNUS_M32R:
+    case EM_M32R:              return "Renesas M32R (formerly Mitsubishi M32r)";
+    case EM_CYGNUS_MN10300:
+    case EM_MN10300:           return "mn10300";
+      /* 90 */
+    case EM_CYGNUS_MN10200:
+    case EM_MN10200:           return "mn10200";
+    case EM_PJ:                        return "picoJava";
     case EM_OR1K:              return "OpenRISC 1000";
-    case EM_CRX:               return "National Semiconductor CRX microprocessor";
-    case EM_ADAPTEVA_EPIPHANY: return "Adapteva EPIPHANY";
-    case EM_DLX:               return "OpenDLX";
-    case EM_IP2K_OLD:
-    case EM_IP2K:              return "Ubicom IP2xxx 8-bit microcontrollers";
-    case EM_IQ2000:            return "Vitesse IQ2000";
+    case EM_ARC_COMPACT:       return "ARCompact";
     case EM_XTENSA_OLD:
     case EM_XTENSA:            return "Tensilica Xtensa Processor";
     case EM_VIDEOCORE:         return "Alphamosaic VideoCore processor";
     case EM_TMM_GPP:           return "Thompson Multimedia General Purpose Processor";
     case EM_NS32K:             return "National Semiconductor 32000 series";
     case EM_TPC:               return "Tenor Network TPC processor";
-    case EM_ST200:             return "STMicroelectronics ST200 microcontroller";
+    case EM_SNP1K:             return "Trebia SNP 1000 processor";
+      /* 100 */
+    case EM_ST200:             return "STMicroelectronics ST200 microcontroller";  
+    case EM_IP2K_OLD:
+    case EM_IP2K:              return "Ubicom IP2xxx 8-bit microcontrollers";
     case EM_MAX:               return "MAX Processor";
     case EM_CR:                        return "National Semiconductor CompactRISC";
     case EM_F2MC16:            return "Fujitsu F2MC16";
     case EM_MSP430:            return "Texas Instruments msp430 microcontroller";
-    case EM_LATTICEMICO32:     return "Lattice Mico32";
-    case EM_M32C_OLD:
-    case EM_M32C:              return "Renesas M32c";
-    case EM_MT:                 return "Morpho Techologies MT processor";
     case EM_BLACKFIN:          return "Analog Devices Blackfin";
     case EM_SE_C33:            return "S1C33 Family of Seiko Epson processors";
     case EM_SEP:               return "Sharp embedded microprocessor";
     case EM_ARCA:              return "Arca RISC microprocessor";
+      /* 110 */
     case EM_UNICORE:           return "Unicore";
     case EM_EXCESS:            return "eXcess 16/32/64-bit configurable embedded CPU";
     case EM_DXP:               return "Icera Semiconductor Inc. Deep Execution Processor";
-    case EM_NIOS32:            return "Altera Nios";
     case EM_ALTERA_NIOS2:      return "Altera Nios II";
+    case EM_CRX:               return "National Semiconductor CRX microprocessor";
+    case EM_XGATE:             return "Motorola XGATE embedded processor";
     case EM_C166:
     case EM_XC16X:             return "Infineon Technologies xc16x";
     case EM_M16C:              return "Renesas M16C series microprocessors";
     case EM_DSPIC30F:          return "Microchip Technology dsPIC30F Digital Signal Controller";
     case EM_CE:                        return "Freescale Communication Engine RISC core";
+      /* 120 */
+    case EM_M32C:              return "Renesas M32c";
+      /* 130 */
     case EM_TSK3000:           return "Altium TSK3000 core";
     case EM_RS08:              return "Freescale RS08 embedded processor";
     case EM_ECOG2:             return "Cyan Technology eCOG2 microprocessor";
+    case EM_SCORE:             return "SUNPLUS S+Core";
     case EM_DSP24:             return "New Japan Radio (NJR) 24-bit DSP Processor";
     case EM_VIDEOCORE3:                return "Broadcom VideoCore III processor";
+    case EM_LATTICEMICO32:     return "Lattice Mico32";
     case EM_SE_C17:            return "Seiko Epson C17 family";
+      /* 140 */
     case EM_TI_C6000:          return "Texas Instruments TMS320C6000 DSP family";
     case EM_TI_C2000:          return "Texas Instruments TMS320C2000 DSP family";
     case EM_TI_C5500:          return "Texas Instruments TMS320C55x DSP family";
+    case EM_TI_PRU:            return "TI PRU I/O processor";
+      /* 160 */
     case EM_MMDSP_PLUS:                return "STMicroelectronics 64bit VLIW Data Signal Processor";
     case EM_CYPRESS_M8C:       return "Cypress M8C microprocessor";
     case EM_R32C:              return "Renesas R32C series microprocessors";
@@ -2358,38 +2367,47 @@ get_machine_name (unsigned e_machine)
     case EM_NDS32:             return "Andes Technology compact code size embedded RISC processor family";
     case EM_ECOG1X:            return "Cyan Technology eCOG1X family";
     case EM_MAXQ30:            return "Dallas Semiconductor MAXQ30 Core microcontrollers";
+      /* 170 */
     case EM_XIMO16:            return "New Japan Radio (NJR) 16-bit DSP Processor";
     case EM_MANIK:             return "M2000 Reconfigurable RISC Microprocessor";
     case EM_CRAYNV2:           return "Cray Inc. NV2 vector architecture";
-    case EM_CYGNUS_MEP:         return "Toshiba MeP Media Engine";
-    case EM_CR16:
-    case EM_MICROBLAZE:
-    case EM_MICROBLAZE_OLD:    return "Xilinx MicroBlaze";
-    case EM_RISCV:             return "RISC-V";
-    case EM_RL78:              return "Renesas RL78";
     case EM_RX:                        return "Renesas RX";
     case EM_METAG:             return "Imagination Technologies Meta processor architecture";
     case EM_MCST_ELBRUS:       return "MCST Elbrus general purpose hardware architecture";
     case EM_ECOG16:            return "Cyan Technology eCOG16 family";
+    case EM_CR16:
+    case EM_MICROBLAZE:
+    case EM_MICROBLAZE_OLD:    return "Xilinx MicroBlaze";
     case EM_ETPU:              return "Freescale Extended Time Processing Unit";
     case EM_SLE9X:             return "Infineon Technologies SLE9X core";
-    case EM_AVR32:             return "Atmel Corporation 32-bit microprocessor family";
+      /* 180 */
+    case EM_L1OM:              return "Intel L1OM";
+    case EM_K1OM:              return "Intel K1OM";
+    case EM_INTEL182:          return "Intel (reserved)";
+    case EM_AARCH64:           return "AArch64";
+    case EM_ARM184:            return "ARM (reserved)";
+    case EM_AVR32:             return "Atmel Corporation 32-bit microprocessor";
     case EM_STM8:              return "STMicroeletronics STM8 8-bit microcontroller";
     case EM_TILE64:            return "Tilera TILE64 multicore architecture family";
     case EM_TILEPRO:           return "Tilera TILEPro multicore architecture family";
-    case EM_TILEGX:            return "Tilera TILE-Gx multicore architecture family";
+      /* 190 */
     case EM_CUDA:              return "NVIDIA CUDA architecture";
-    case EM_XGATE:             return "Motorola XGATE embedded processor";
+    case EM_TILEGX:            return "Tilera TILE-Gx multicore architecture family";
     case EM_CLOUDSHIELD:       return "CloudShield architecture family";
     case EM_COREA_1ST:         return "KIPO-KAIST Core-A 1st generation processor family";
     case EM_COREA_2ND:         return "KIPO-KAIST Core-A 2nd generation processor family";
+    case EM_ARC_COMPACT2:      return "ARCv2";
     case EM_OPEN8:             return "Open8 8-bit RISC soft processor core";
+    case EM_RL78:              return "Renesas RL78";
     case EM_VIDEOCORE5:                return "Broadcom VideoCore V processor";
+    case EM_78K0R:             return "Renesas 78K0R";
+      /* 200 */
     case EM_56800EX:           return "Freescale 56800EX Digital Signal Controller (DSC)";
     case EM_BA1:               return "Beyond BA1 CPU architecture";
     case EM_BA2:               return "Beyond BA2 CPU architecture";
     case EM_XCORE:             return "XMOS xCORE processor family";
     case EM_MCHP_PIC:          return "Microchip 8-bit PIC(r) family";
+      /* 210 */
     case EM_KM32:              return "KM211 KM32 32-bit processor";
     case EM_KMX32:             return "KM211 KMX32 32-bit processor";
     case EM_KMX16:             return "KM211 KMX16 16-bit processor";
@@ -2400,9 +2418,29 @@ get_machine_name (unsigned e_machine)
     case EM_COOL:              return "Bluechip Systems CoolEngine";
     case EM_NORC:              return "Nanoradio Optimized RISC";
     case EM_CSR_KALIMBA:       return "CSR Kalimba architecture family";
+      /* 220 */
     case EM_Z80:               return "Zilog Z80";
-    case EM_AMDGPU:            return "AMD GPU architecture";
-    case EM_TI_PRU:            return "TI PRU I/O processor";
+    case EM_VISIUM:            return "CDS VISIUMcore processor";
+    case EM_FT32:               return "FTDI Chip FT32";
+    case EM_MOXIE:              return "Moxie";
+    case EM_AMDGPU:            return "AMD GPU";
+    case EM_RISCV:             return "RISC-V";
+    case EM_LANAI:             return "Lanai 32-bit processor";
+    case EM_BPF:               return "Linux BPF";
+
+      /* Large numbers...  */
+    case EM_MT:                 return "Morpho Techologies MT processor";
+    case EM_ALPHA:             return "Alpha";
+    case EM_WEBASSEMBLY:       return "Web Assembly";
+    case EM_DLX:               return "OpenDLX";  
+    case EM_XSTORMY16:         return "Sanyo XStormy16 CPU core";
+    case EM_IQ2000:            return "Vitesse IQ2000";
+    case EM_M32C_OLD:
+    case EM_NIOS32:            return "Altera Nios";
+    case EM_CYGNUS_MEP:         return "Toshiba MeP Media Engine";
+    case EM_ADAPTEVA_EPIPHANY: return "Adapteva EPIPHANY";
+    case EM_CYGNUS_FRV:                return "Fujitsu FR-V";
+
     default:
       snprintf (buff, sizeof (buff), _("<unknown>: 0x%x"), e_machine);
       return buff;
@@ -2470,6 +2508,9 @@ decode_ARC_machine_flags (unsigned e_flags, unsigned e_machine, char buf[])
     case E_ARC_OSABI_V3:
       strcat (buf, ", v3 no-legacy-syscalls ABI");
       break;
+    case E_ARC_OSABI_V4:
+      strcat (buf, ", v4 ABI");
+      break;
     default:
       strcat (buf, ", unrecognised ARC OSABI flag");
       break;
@@ -3293,6 +3334,7 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
            case E_MIPS_MACH_OCTEON2: strcat (buf, ", octeon2"); break;
            case E_MIPS_MACH_OCTEON3: strcat (buf, ", octeon3"); break;
            case E_MIPS_MACH_XLR:  strcat (buf, ", xlr"); break;
+           case E_MIPS_MACH_IAMR2:  strcat (buf, ", interaptiv-mr2"); break;
            case 0:
            /* We simply ignore the field in this case to avoid confusion:
               MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
@@ -3684,6 +3726,16 @@ get_arm_segment_type (unsigned long type)
     }
 }
 
+static const char *
+get_s390_segment_type (unsigned long type)
+{
+  switch (type)
+    {
+    case PT_S390_PGSTE: return "S390_PGSTE";
+    default:            return NULL;
+    }
+}
+
 static const char *
 get_mips_segment_type (unsigned long type)
 {
@@ -3787,7 +3839,12 @@ get_segment_type (unsigned long p_type)
     case PT_GNU_RELRO:  return "GNU_RELRO";
 
     default:
-      if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
+      if (p_type >= PT_GNU_MBIND_LO && p_type <= PT_GNU_MBIND_HI)
+       {
+         sprintf (buff, "GNU_MBIND+%#lx",
+                  p_type - PT_GNU_MBIND_LO);
+       }
+      else if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
        {
          const char * result;
 
@@ -3812,6 +3869,10 @@ get_segment_type (unsigned long p_type)
            case EM_TI_C6000:
              result = get_tic6x_segment_type (p_type);
              break;
+           case EM_S390:
+           case EM_S390_OLD:
+             result = get_s390_segment_type (p_type);
+             break;
            default:
              result = NULL;
              break;
@@ -3854,6 +3915,18 @@ get_segment_type (unsigned long p_type)
     }
 }
 
+static const char *
+get_arc_section_type_name (unsigned int sh_type)
+{
+  switch (sh_type)
+    {
+    case SHT_ARC_ATTRIBUTES:      return "ARC_ATTRIBUTES";
+    default:
+      break;
+    }
+  return NULL;
+}
+
 static const char *
 get_mips_section_type_name (unsigned int sh_type)
 {
@@ -4063,6 +4136,11 @@ get_section_type_name (unsigned int sh_type)
        {
          switch (elf_header.e_machine)
            {
+           case EM_ARC:
+           case EM_ARC_COMPACT:
+           case EM_ARC_COMPACT2:
+             result = get_arc_section_type_name (sh_type);
+             break;
            case EM_MIPS:
            case EM_MIPS_RS3_LE:
              result = get_mips_section_type_name (sh_type);
@@ -4756,9 +4834,19 @@ get_program_headers (FILE * file)
   if (program_headers != NULL)
     return TRUE;
 
-  phdrs = (Elf_Internal_Phdr *) cmalloc (elf_header.e_phnum,
-                                         sizeof (Elf_Internal_Phdr));
+  /* Be kind to memory checkers by looking for
+     e_phnum values which we know must be invalid.  */
+  if (elf_header.e_phnum
+      * (is_32bit_elf ? sizeof (Elf32_External_Phdr) : sizeof (Elf64_External_Phdr))
+      >= current_file_size)
+    {
+      error (_("Too many program headers - %#x - the file is not that big\n"),
+            elf_header.e_phnum);
+      return FALSE;
+    }
 
+  phdrs = (Elf_Internal_Phdr *) cmalloc (elf_header.e_phnum,
+                                        sizeof (Elf_Internal_Phdr));
   if (phdrs == NULL)
     {
       error (_("Out of memory reading %u program headers\n"),
@@ -4965,12 +5053,6 @@ process_program_headers (FILE * file)
             section in the DYNAMIC segment.  */
          dynamic_addr = segment->p_offset;
          dynamic_size = segment->p_filesz;
-         /* PR binutils/17512: Avoid corrupt dynamic section info in the segment.  */
-         if (dynamic_addr + dynamic_size >= current_file_size)
-           {
-             error (_("the dynamic segment offset + size exceeds the size of the file\n"));
-             dynamic_addr = dynamic_size = 0;
-           }
 
          /* Try to locate the .dynamic section. If there is
             a section header table, we can easily locate it.  */
@@ -5005,6 +5087,16 @@ process_program_headers (FILE * file)
                warn (_("the .dynamic section is not the first section"
                        " in the dynamic segment.\n"));
            }
+
+         /* PR binutils/17512: Avoid corrupt dynamic section info in the
+            segment.  Check this after matching against the section headers
+            so we don't warn on debuginfo file (which have NOBITS .dynamic
+            sections).  */
+         if (dynamic_addr + dynamic_size >= current_file_size)
+           {
+             error (_("the dynamic segment offset + size exceeds the size of the file\n"));
+             dynamic_addr = dynamic_size = 0;
+           }
          break;
 
        case PT_INTERP:
@@ -5492,7 +5584,9 @@ get_elf_section_flags (bfd_vma sh_flags)
       /* ARM specific.  */
       /* 21 */ { STRING_COMMA_LEN ("ENTRYSECT") },
       /* 22 */ { STRING_COMMA_LEN ("ARM_PURECODE") },
-      /* 23 */ { STRING_COMMA_LEN ("COMDEF") }
+      /* 23 */ { STRING_COMMA_LEN ("COMDEF") },
+      /* GNU specific.  */
+      /* 24 */ { STRING_COMMA_LEN ("GNU_MBIND") },
     };
 
   if (do_section_details)
@@ -5525,6 +5619,7 @@ get_elf_section_flags (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;
@@ -5618,6 +5713,7 @@ get_elf_section_flags (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 ((elf_header.e_machine == EM_X86_64
@@ -5964,7 +6060,8 @@ process_section_headers (FILE * file)
        request_dump_bynumber (i, DEBUG_DUMP);
       else if (do_debug_frames && streq (name, ".eh_frame"))
        request_dump_bynumber (i, DEBUG_DUMP);
-      else if (do_gdb_index && streq (name, ".gdb_index"))
+      else if (do_gdb_index && (streq (name, ".gdb_index")
+                               || streq (name, ".debug_names")))
        request_dump_bynumber (i, DEBUG_DUMP);
       /* Trace sections for Itanium VMS.  */
       else if ((do_debugging || do_trace_info || do_trace_abbrevs
@@ -6146,12 +6243,21 @@ process_section_headers (FILE * file)
              if (section->sh_info < 1 || section->sh_info >= elf_header.e_shnum)
                warn (_("[%2u]: Expected link to another section in info field"), i);
            }
-         else if (section->sh_type < SHT_LOOS && section->sh_info != 0)
+         else if (section->sh_type < SHT_LOOS
+                  && (section->sh_flags & SHF_GNU_MBIND) == 0
+                  && section->sh_info != 0)
            warn (_("[%2u]: Unexpected value (%u) in info field.\n"),
                  i, section->sh_info);
          break;
        }
 
+      /* Check the sh_size field.  */
+      if (section->sh_size > current_file_size
+         && section->sh_type != SHT_NOBITS
+         && section->sh_type != SHT_NULL
+         && section->sh_type < SHT_LOOS)
+       warn (_("Size of section %u is larger than the entire file!\n"), i);
+
       printf ("  [%2u] ", i);
       if (do_section_details)
        printf ("%s\n      ", printable_section_name (section));
@@ -8011,9 +8117,9 @@ get_unwind_section_word (struct arm_unw_aux_info *  aux,
     return FALSE;
 
   /* If the offset is invalid then fail.  */
-  if (word_offset > (sec->sh_size - 4)
-      /* PR 18879 */
-      || (sec->sh_size < 5 && word_offset >= sec->sh_size)
+  if (/* PR 21343 *//* PR 18879 */
+      sec->sh_size < 4
+      || word_offset > (sec->sh_size - 4)
       || ((bfd_signed_vma) word_offset) < 0)
     return FALSE;
 
@@ -9373,6 +9479,12 @@ process_dynamic_section (FILE * file)
             processing that.  This is overkill, I know, but it
             should work.  */
          section.sh_offset = offset_from_vma (file, entry->d_un.d_val, 0);
+         if ((bfd_size_type) section.sh_offset > current_file_size)
+           {
+             /* See PR 21379 for a reproducer.  */
+             error (_("Invalid DT_SYMTAB entry: %lx"), (long) section.sh_offset);
+             return FALSE;
+           }
 
          if (archive_file_offset != 0)
            section.sh_size = archive_file_size - section.sh_offset;
@@ -10102,8 +10214,9 @@ process_version_sections (FILE * file)
                printf (_("  Index: %d  Cnt: %d  "),
                        ent.vd_ndx, ent.vd_cnt);
 
-               /* Check for overflow.  */
-               if (ent.vd_aux + sizeof (* eaux) > (size_t) (endbuf - vstart))
+               /* Check for overflow and underflow.  */
+               if (ent.vd_aux + sizeof (* eaux) > (size_t) (endbuf - vstart)
+                   || (vstart + ent.vd_aux < vstart))
                  break;
 
                vstart += ent.vd_aux;
@@ -12055,6 +12168,8 @@ is_32bit_abs_reloc (unsigned int reloc_type)
       return reloc_type == 1; /* R_VAX_32.  */
     case EM_VISIUM:
       return reloc_type == 3;  /* R_VISIUM_32. */
+    case EM_WEBASSEMBLY:
+      return reloc_type == 1;  /* R_WASM32_32.  */
     case EM_X86_64:
     case EM_L1OM:
     case EM_K1OM:
@@ -12360,6 +12475,7 @@ is_none_reloc (unsigned int reloc_type)
     case EM_TI_C6000:/* R_C6000_NONE.  */
     case EM_X86_64:  /* R_X86_64_NONE.  */
     case EM_XC16X:
+    case EM_WEBASSEMBLY: /* R_WASM32_NONE.  */
       return reloc_type == 0;
 
     case EM_AARCH64:
@@ -13411,110 +13527,285 @@ display_tag_value (signed int tag,
   return p;
 }
 
-/* ARM EABI attributes section.  */
-typedef struct
+/* ARC ABI attributes section.  */
+
+static unsigned char *
+display_arc_attribute (unsigned char * p,
+                      const unsigned char * const end)
 {
   unsigned int tag;
-  const char * name;
-  /* 0 = special, 1 = string, 2 = uleb123, > 0x80 == table lookup.  */
-  unsigned int type;
-  const char ** table;
-} arm_attr_public_tag;
+  unsigned int len;
+  unsigned int val;
 
-static const char * arm_attr_tag_CPU_arch[] =
-  {"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2",
-   "v6K", "v7", "v6-M", "v6S-M", "v7E-M", "v8", "", "v8-M.baseline",
-   "v8-M.mainline"};
-static const char * arm_attr_tag_ARM_ISA_use[] = {"No", "Yes"};
-static const char * arm_attr_tag_THUMB_ISA_use[] =
-  {"No", "Thumb-1", "Thumb-2", "Yes"};
-static const char * 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[] =
-  {"No", "NEONv1", "NEONv1 with Fused-MAC", "NEON for ARMv8",
-   "NEON for ARMv8.1"};
-static const char * 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[] =
-  {"V6", "SB", "TLS", "Unused"};
-static const char * arm_attr_tag_ABI_PCS_RW_data[] =
-  {"Absolute", "PC-relative", "SB-relative", "None"};
-static const char * arm_attr_tag_ABI_PCS_RO_data[] =
-  {"Absolute", "PC-relative", "None"};
-static const char * arm_attr_tag_ABI_PCS_GOT_use[] =
-  {"None", "direct", "GOT-indirect"};
-static const char * 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[] =
-  {"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[] =
-  {"Unused", "Finite", "RTABI", "IEEE 754"};
-static const char * arm_attr_tag_ABI_enum_size[] =
-  {"Unused", "small", "int", "forced to int"};
-static const char * arm_attr_tag_ABI_HardFP_use[] =
-  {"As Tag_FP_arch", "SP only", "Reserved", "Deprecated"};
-static const char * arm_attr_tag_ABI_VFP_args[] =
-  {"AAPCS", "VFP registers", "custom", "compatible"};
-static const char * arm_attr_tag_ABI_WMMX_args[] =
-  {"AAPCS", "WMMX registers", "custom"};
-static const char * 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[] =
-  {"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[] =
-  {"Not Allowed", "Allowed"};
-static const char * arm_attr_tag_ABI_FP_16bit_format[] =
-  {"None", "IEEE 754", "Alternative Format"};
-static const char * arm_attr_tag_DSP_extension[] =
-  {"Follow architecture", "Allowed"};
-static const char * arm_attr_tag_MPextension_use[] =
-  {"Not Allowed", "Allowed"};
-static const char * 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[] =
-  {"Not Allowed", "TrustZone", "Virtualization Extensions",
-    "TrustZone and Virtualization Extensions"};
-static const char * arm_attr_tag_MPextension_use_legacy[] =
-  {"Not Allowed", "Allowed"};
+  tag = read_uleb128 (p, &len, end);
+  p += len;
 
-#define LOOKUP(id, name) \
-  {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
-static arm_attr_public_tag arm_attr_public_tags[] =
-{
-  {4, "CPU_raw_name", 1, NULL},
-  {5, "CPU_name", 1, NULL},
-  LOOKUP(6, CPU_arch),
-  {7, "CPU_arch_profile", 0, NULL},
-  LOOKUP(8, ARM_ISA_use),
-  LOOKUP(9, THUMB_ISA_use),
-  LOOKUP(10, FP_arch),
-  LOOKUP(11, WMMX_arch),
-  LOOKUP(12, Advanced_SIMD_arch),
-  LOOKUP(13, PCS_config),
-  LOOKUP(14, ABI_PCS_R9_use),
-  LOOKUP(15, ABI_PCS_RW_data),
-  LOOKUP(16, ABI_PCS_RO_data),
-  LOOKUP(17, ABI_PCS_GOT_use),
-  LOOKUP(18, ABI_PCS_wchar_t),
-  LOOKUP(19, ABI_FP_rounding),
-  LOOKUP(20, ABI_FP_denormal),
-  LOOKUP(21, ABI_FP_exceptions),
-  LOOKUP(22, ABI_FP_user_exceptions),
-  LOOKUP(23, ABI_FP_number_model),
-  {24, "ABI_align_needed", 0, NULL},
-  {25, "ABI_align_preserved", 0, NULL},
-  LOOKUP(26, ABI_enum_size),
+  switch (tag)
+    {
+    case Tag_ARC_PCS_config:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_PCS_config: ");
+      switch (val)
+       {
+       case 0:
+         printf (_("Absent/Non standard\n"));
+         break;
+       case 1:
+         printf (_("Bare metal/mwdt\n"));
+         break;
+       case 2:
+         printf (_("Bare metal/newlib\n"));
+         break;
+       case 3:
+         printf (_("Linux/uclibc\n"));
+         break;
+       case 4:
+         printf (_("Linux/glibc\n"));
+         break;
+       default:
+         printf (_("Unknown\n"));
+         break;
+       }
+      break;
+
+    case Tag_ARC_CPU_base:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_CPU_base: ");
+      switch (val)
+       {
+       default:
+       case TAG_CPU_NONE:
+         printf (_("Absent\n"));
+         break;
+       case TAG_CPU_ARC6xx:
+         printf ("ARC6xx\n");
+         break;
+       case TAG_CPU_ARC7xx:
+         printf ("ARC7xx\n");
+         break;
+       case TAG_CPU_ARCEM:
+         printf ("ARCEM\n");
+         break;
+       case TAG_CPU_ARCHS:
+         printf ("ARCHS\n");
+         break;
+       }
+      break;
+
+    case Tag_ARC_CPU_variation:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_CPU_variation: ");
+      switch (val)
+       {
+       default:
+         if (val > 0 && val < 16)
+             printf ("Core%d\n", val);
+         else
+             printf ("Unknown\n");
+         break;
+
+       case 0:
+         printf (_("Absent\n"));
+         break;
+       }
+      break;
+
+    case Tag_ARC_CPU_name:
+      printf ("  Tag_ARC_CPU_name: ");
+      p = display_tag_value (-1, p, end);
+      break;
+
+    case Tag_ARC_ABI_rf16:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_ABI_rf16: %s\n", val ? _("yes") : _("no"));
+      break;
+
+    case Tag_ARC_ABI_osver:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_ABI_osver: v%d\n", val);
+      break;
+
+    case Tag_ARC_ABI_pic:
+    case Tag_ARC_ABI_sda:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf (tag == Tag_ARC_ABI_sda ? "  Tag_ARC_ABI_sda: "
+             : "  Tag_ARC_ABI_pic: ");
+      switch (val)
+       {
+       case 0:
+         printf (_("Absent\n"));
+         break;
+       case 1:
+         printf ("MWDT\n");
+         break;
+       case 2:
+         printf ("GNU\n");
+         break;
+       default:
+         printf (_("Unknown\n"));
+         break;
+       }
+      break;
+
+    case Tag_ARC_ABI_tls:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_ABI_tls: %s\n", val ? "r25": "none");
+      break;
+
+    case Tag_ARC_ABI_enumsize:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_ABI_enumsize: %s\n", val ? _("default") :
+             _("smallest"));
+      break;
+
+    case Tag_ARC_ABI_exceptions:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_ABI_exceptions: %s\n", val ? _("OPTFP")
+             : _("default"));
+      break;
+
+    case Tag_ARC_ABI_double_size:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_ABI_double_size: %d\n", val);
+      break;
+
+    case Tag_ARC_ISA_config:
+      printf ("  Tag_ARC_ISA_config: ");
+      p = display_tag_value (-1, p, end);
+      break;
+
+    case Tag_ARC_ISA_apex:
+      printf ("  Tag_ARC_ISA_apex: ");
+      p = display_tag_value (-1, p, end);
+      break;
+
+    case Tag_ARC_ISA_mpy_option:
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_ARC_ISA_mpy_option: %d\n", val);
+      break;
+
+    default:
+      return display_tag_value (tag & 1, p, end);
+    }
+
+  return p;
+}
+
+/* ARM EABI attributes section.  */
+typedef struct
+{
+  unsigned int tag;
+  const char * name;
+  /* 0 = special, 1 = string, 2 = uleb123, > 0x80 == table lookup.  */
+  unsigned int type;
+  const char ** table;
+} arm_attr_public_tag;
+
+static const char * arm_attr_tag_CPU_arch[] =
+  {"Pre-v4", "v4", "v4T", "v5T", "v5TE", "v5TEJ", "v6", "v6KZ", "v6T2",
+   "v6K", "v7", "v6-M", "v6S-M", "v7E-M", "v8", "v8-R", "v8-M.baseline",
+   "v8-M.mainline"};
+static const char * arm_attr_tag_ARM_ISA_use[] = {"No", "Yes"};
+static const char * arm_attr_tag_THUMB_ISA_use[] =
+  {"No", "Thumb-1", "Thumb-2", "Yes"};
+static const char * 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[] =
+  {"No", "NEONv1", "NEONv1 with Fused-MAC", "NEON for ARMv8",
+   "NEON for ARMv8.1"};
+static const char * 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[] =
+  {"V6", "SB", "TLS", "Unused"};
+static const char * arm_attr_tag_ABI_PCS_RW_data[] =
+  {"Absolute", "PC-relative", "SB-relative", "None"};
+static const char * arm_attr_tag_ABI_PCS_RO_data[] =
+  {"Absolute", "PC-relative", "None"};
+static const char * arm_attr_tag_ABI_PCS_GOT_use[] =
+  {"None", "direct", "GOT-indirect"};
+static const char * 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[] =
+  {"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[] =
+  {"Unused", "Finite", "RTABI", "IEEE 754"};
+static const char * arm_attr_tag_ABI_enum_size[] =
+  {"Unused", "small", "int", "forced to int"};
+static const char * arm_attr_tag_ABI_HardFP_use[] =
+  {"As Tag_FP_arch", "SP only", "Reserved", "Deprecated"};
+static const char * arm_attr_tag_ABI_VFP_args[] =
+  {"AAPCS", "VFP registers", "custom", "compatible"};
+static const char * arm_attr_tag_ABI_WMMX_args[] =
+  {"AAPCS", "WMMX registers", "custom"};
+static const char * 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[] =
+  {"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[] =
+  {"Not Allowed", "Allowed"};
+static const char * arm_attr_tag_ABI_FP_16bit_format[] =
+  {"None", "IEEE 754", "Alternative Format"};
+static const char * arm_attr_tag_DSP_extension[] =
+  {"Follow architecture", "Allowed"};
+static const char * arm_attr_tag_MPextension_use[] =
+  {"Not Allowed", "Allowed"};
+static const char * 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[] =
+  {"Not Allowed", "TrustZone", "Virtualization Extensions",
+    "TrustZone and Virtualization Extensions"};
+static const char * arm_attr_tag_MPextension_use_legacy[] =
+  {"Not Allowed", "Allowed"};
+
+#define LOOKUP(id, name) \
+  {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
+static arm_attr_public_tag arm_attr_public_tags[] =
+{
+  {4, "CPU_raw_name", 1, NULL},
+  {5, "CPU_name", 1, NULL},
+  LOOKUP(6, CPU_arch),
+  {7, "CPU_arch_profile", 0, NULL},
+  LOOKUP(8, ARM_ISA_use),
+  LOOKUP(9, THUMB_ISA_use),
+  LOOKUP(10, FP_arch),
+  LOOKUP(11, WMMX_arch),
+  LOOKUP(12, Advanced_SIMD_arch),
+  LOOKUP(13, PCS_config),
+  LOOKUP(14, ABI_PCS_R9_use),
+  LOOKUP(15, ABI_PCS_RW_data),
+  LOOKUP(16, ABI_PCS_RO_data),
+  LOOKUP(17, ABI_PCS_GOT_use),
+  LOOKUP(18, ABI_PCS_wchar_t),
+  LOOKUP(19, ABI_FP_rounding),
+  LOOKUP(20, ABI_FP_denormal),
+  LOOKUP(21, ABI_FP_exceptions),
+  LOOKUP(22, ABI_FP_user_exceptions),
+  LOOKUP(23, ABI_FP_number_model),
+  {24, "ABI_align_needed", 0, NULL},
+  {25, "ABI_align_preserved", 0, NULL},
+  LOOKUP(26, ABI_enum_size),
   LOOKUP(27, ABI_HardFP_use),
   LOOKUP(28, ABI_VFP_args),
   LOOKUP(29, ABI_WMMX_args),
@@ -14769,6 +15060,8 @@ print_mips_ases (unsigned int mask)
     fputs ("\n\tMICROMIPS ASE", stdout);
   if (mask & AFL_ASE_XPA)
     fputs ("\n\tXPA ASE", stdout);
+  if (mask & AFL_ASE_MIPS16E2)
+    fputs ("\n\tMIPS16e2 ASE", stdout);
   if (mask == 0)
     fprintf (stdout, "\n\t%s", _("None"));
   else if ((mask & ~AFL_ASE_MASK) != 0)
@@ -14840,6 +15133,9 @@ print_mips_isa_ext (unsigned int isa_ext)
     case AFL_EXT_LOONGSON_2F:
       fputs ("ST Microelectronics Loongson 2F", stdout);
       break;
+    case AFL_EXT_INTERAPTIV_MR2:
+      fputs ("Imagination interAptiv MR2", stdout);
+      break;
     default:
       fprintf (stdout, "%s (%d)", _("Unknown"), isa_ext);
     }
@@ -14935,8 +15231,93 @@ process_mips_specific (FILE * file)
 
   /* We have a lot of special sections.  Thanks SGI!  */
   if (dynamic_section == NULL)
-    /* No information available.  */
-    return res;
+    {
+      /* No dynamic information available.  See if there is static GOT.  */
+      sect = find_section (".got");
+      if (sect != NULL)
+       {
+         unsigned char *data_end;
+         unsigned char *data;
+         bfd_vma ent, end;
+         int addr_size;
+
+         pltgot = sect->sh_addr;
+
+         ent = pltgot;
+         addr_size = (is_32bit_elf ? 4 : 8);
+         end = pltgot + sect->sh_size;
+
+         data = (unsigned char *) get_data (NULL, file, sect->sh_offset,
+                                            end - pltgot, 1,
+                                            _("Global Offset Table data"));
+         /* PR 12855: Null data is handled gracefully throughout.  */
+         data_end = data + (end - pltgot);
+
+         printf (_("\nStatic GOT:\n"));
+         printf (_(" Canonical gp value: "));
+         print_vma (ent + 0x7ff0, LONG_HEX);
+         printf ("\n\n");
+
+         /* In a dynamic binary GOT[0] is reserved for the dynamic
+            loader to store the lazy resolver pointer, however in
+            a static binary it may well have been omitted and GOT
+            reduced to a table of addresses.
+            PR 21344: Check for the entry being fully available
+            before fetching it.  */
+         if (data
+             && data + ent - pltgot + addr_size <= data_end
+             && byte_get (data + ent - pltgot, addr_size) == 0)
+           {
+             printf (_(" Reserved entries:\n"));
+             printf (_("  %*s %10s %*s\n"),
+                     addr_size * 2, _("Address"), _("Access"),
+                     addr_size * 2, _("Value"));
+             ent = print_mips_got_entry (data, pltgot, ent, data_end);
+             printf ("\n");
+             if (ent == (bfd_vma) -1)
+               goto sgot_print_fail;
+
+             /* Check for the MSB of GOT[1] being set, identifying a
+                GNU object.  This entry will be used by some runtime
+                loaders, to store the module pointer.  Otherwise this
+                is an ordinary local entry.
+                PR 21344: Check for the entry being fully available
+                before fetching it.  */
+             if (data
+                 && data + ent - pltgot + addr_size <= data_end
+                 && (byte_get (data + ent - pltgot, addr_size)
+                     >> (addr_size * 8 - 1)) != 0)
+               {
+                 ent = print_mips_got_entry (data, pltgot, ent, data_end);
+                 printf ("\n");
+                 if (ent == (bfd_vma) -1)
+                   goto sgot_print_fail;
+               }
+             printf ("\n");
+           }
+
+         if (ent < end)
+           {
+             printf (_(" Local entries:\n"));
+             printf ("  %*s %10s %*s\n",
+                     addr_size * 2, _("Address"), _("Access"),
+                     addr_size * 2, _("Value"));
+             while (ent < end)
+               {
+                 ent = print_mips_got_entry (data, pltgot, ent, data_end);
+                 printf ("\n");
+                 if (ent == (bfd_vma) -1)
+                   goto sgot_print_fail;
+               }
+             printf ("\n");
+           }
+
+       sgot_print_fail:
+         if (data)
+           free (data);
+       }
+      return res;
+    }
 
   for (entry = dynamic_section;
        /* PR 17531 file: 012-50589-0.004.  */
@@ -15304,6 +15685,15 @@ process_mips_specific (FILE * file)
          return FALSE;
        }
 
+      /* PR 21345 - print a slightly more helpful error message
+        if we are sure that the cmalloc will fail.  */
+      if (conflictsno * sizeof (* iconf) > current_file_size)
+       {
+         error (_("Overlarge number of conflicts detected: %lx\n"),
+                (long) conflictsno);
+         return FALSE;
+       }
+
       iconf = (Elf32_Conflict *) cmalloc (conflictsno, sizeof (* iconf));
       if (iconf == NULL)
        {
@@ -15402,8 +15792,7 @@ process_mips_specific (FILE * file)
       data = (unsigned char *) get_data (NULL, file, offset,
                                          global_end - pltgot, 1,
                                         _("Global Offset Table data"));
-      if (data == NULL)
-       return FALSE;
+      /* PR 12855: Null data is handled gracefully throughout.  */
       data_end = data + (global_end - pltgot);
 
       printf (_("\nPrimary GOT:\n"));
@@ -15419,7 +15808,14 @@ process_mips_specific (FILE * file)
       printf (_(" Lazy resolver\n"));
       if (ent == (bfd_vma) -1)
        goto got_print_fail;
+
+      /* Check for the MSB of GOT[1] being set, denoting a GNU object.
+        This entry will be used by some runtime loaders, to store the
+        module pointer.  Otherwise this is an ordinary local entry.
+        PR 21344: Check for the entry being fully available before
+        fetching it.  */
       if (data
+         && data + ent - pltgot + addr_size <= data_end
          && (byte_get (data + ent - pltgot, addr_size)
              >> (addr_size * 8 - 1)) != 0)
        {
@@ -15763,6 +16159,10 @@ get_note_type (unsigned e_type)
        return _("NT_S390_VXRS_LOW (s390 vector registers 0-15 upper half)");
       case NT_S390_VXRS_HIGH:
        return _("NT_S390_VXRS_HIGH (s390 vector registers 16-31)");
+      case NT_S390_GS_CB:
+       return _("NT_S390_GS_CB (s390 guarded-storage registers)");
+      case NT_S390_GS_BC:
+       return _("NT_S390_GS_BC (s390 guarded-storage broadcast control)");
       case NT_ARM_VFP:
        return _("NT_ARM_VFP (arm VFP registers)");
       case NT_ARM_TLS:
@@ -15797,6 +16197,10 @@ get_note_type (unsigned e_type)
        return _("NT_VERSION (version)");
       case NT_ARCH:
        return _("NT_ARCH (architecture)");
+      case NT_GNU_BUILD_ATTRIBUTE_OPEN:
+       return _("NT_GNU_BUILD_ATTRIBUTE_OPEN");
+      case NT_GNU_BUILD_ATTRIBUTE_FUNC:
+       return _("NT_GNU_BUILD_ATTRIBUTE_FUNC");
       default:
        break;
       }
@@ -15905,6 +16309,12 @@ get_gnu_elf_note_type (unsigned e_type)
       return _("NT_GNU_BUILD_ID (unique build ID bitstring)");
     case NT_GNU_GOLD_VERSION:
       return _("NT_GNU_GOLD_VERSION (gold version)");
+    case NT_GNU_PROPERTY_TYPE_0:
+      return _("NT_GNU_PROPERTY_TYPE_0");
+    case NT_GNU_BUILD_ATTRIBUTE_OPEN:
+      return _("NT_GNU_BUILD_ATTRIBUTE_OPEN");
+    case NT_GNU_BUILD_ATTRIBUTE_FUNC:
+      return _("NT_GNU_BUILD_ATTRIBUTE_FUNC");
     default:
       {
        static char buff[64];
@@ -15915,6 +16325,204 @@ get_gnu_elf_note_type (unsigned e_type)
     }
 }
 
+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_486: printf ("i486"); break;
+       case GNU_PROPERTY_X86_ISA_1_586: printf ("586"); break;
+       case GNU_PROPERTY_X86_ISA_1_686: printf ("686"); break;
+       case GNU_PROPERTY_X86_ISA_1_SSE: printf ("SSE"); break;
+       case GNU_PROPERTY_X86_ISA_1_SSE2: printf ("SSE2"); break;
+       case GNU_PROPERTY_X86_ISA_1_SSE3: printf ("SSE3"); break;
+       case GNU_PROPERTY_X86_ISA_1_SSSE3: printf ("SSSE3"); break;
+       case GNU_PROPERTY_X86_ISA_1_SSE4_1: printf ("SSE4_1"); break;
+       case GNU_PROPERTY_X86_ISA_1_SSE4_2: printf ("SSE4_2"); break;
+       case GNU_PROPERTY_X86_ISA_1_AVX: printf ("AVX"); break;
+       case GNU_PROPERTY_X86_ISA_1_AVX2: printf ("AVX2"); break;
+       case GNU_PROPERTY_X86_ISA_1_AVX512F: printf ("AVX512F"); break;
+       case GNU_PROPERTY_X86_ISA_1_AVX512CD: printf ("AVX512CD"); break;
+       case GNU_PROPERTY_X86_ISA_1_AVX512ER: printf ("AVX512ER"); break;
+       case GNU_PROPERTY_X86_ISA_1_AVX512PF: printf ("AVX512PF"); break;
+       case GNU_PROPERTY_X86_ISA_1_AVX512VL: printf ("AVX512VL"); break;
+       case GNU_PROPERTY_X86_ISA_1_AVX512DQ: printf ("AVX512DQ"); break;
+       case GNU_PROPERTY_X86_ISA_1_AVX512BW: printf ("AVX512BW"); break;
+       default: printf (_("<unknown: %x>"), bit); break;
+       }
+      if (bitmask)
+       printf (", ");
+    }
+}
+
+static void
+decode_x86_feature (unsigned int type, unsigned int bitmask)
+{
+  while (bitmask)
+    {
+      unsigned int bit = bitmask & (- bitmask);
+
+      bitmask &= ~ bit;
+      switch (bit)
+       {
+       case GNU_PROPERTY_X86_FEATURE_1_IBT:
+         switch (type)
+           {
+           case GNU_PROPERTY_X86_FEATURE_1_AND:
+             printf ("IBT");
+             break;
+           default:
+             /* This should never happen.  */
+             abort ();
+           }
+         break;
+       case GNU_PROPERTY_X86_FEATURE_1_SHSTK:
+         switch (type)
+           {
+           case GNU_PROPERTY_X86_FEATURE_1_AND:
+             printf ("SHSTK");
+             break;
+           default:
+             /* This should never happen.  */
+             abort ();
+           }
+         break;
+       default:
+         printf (_("<unknown: %x>"), bit);
+         break;
+       }
+      if (bitmask)
+       printf (", ");
+    }
+}
+
+static void
+print_gnu_property_note (Elf_Internal_Note * pnote)
+{
+  unsigned char * ptr = (unsigned char *) pnote->descdata;
+  unsigned char * ptr_end = ptr + pnote->descsz;
+  unsigned int    size = is_32bit_elf ? 4 : 8;
+
+  printf (_("      Properties: "));
+
+  if (pnote->descsz < 8 || (pnote->descsz % size) != 0)
+    {
+      printf (_("<corrupt GNU_PROPERTY_TYPE, size = %#lx>\n"), pnote->descsz);
+      return;
+    }
+
+  while (1)
+    {
+      unsigned int j;
+      unsigned int type = byte_get (ptr, 4);
+      unsigned int datasz = byte_get (ptr + 4, 4);
+
+      ptr += 8;
+
+      if ((ptr + datasz) > ptr_end)
+       {
+         printf (_("<corrupt type (%#x) datasz: %#x>\n"),
+                 type, datasz);
+         break;
+       }
+
+      if (type >= GNU_PROPERTY_LOPROC && type <= GNU_PROPERTY_HIPROC)
+       {
+         if (elf_header.e_machine == EM_X86_64
+             || elf_header.e_machine == EM_IAMCU
+             || elf_header.e_machine == EM_386)
+           {
+             switch (type)
+               {
+               case GNU_PROPERTY_X86_ISA_1_USED:
+                 printf ("x86 ISA used: ");
+                 if (datasz != 4)
+                   printf (_("<corrupt length: %#x> "), datasz);
+                 else
+                   decode_x86_isa (byte_get (ptr, 4));
+                 goto next;
+
+               case GNU_PROPERTY_X86_ISA_1_NEEDED:
+                 printf ("x86 ISA needed: ");
+                 if (datasz != 4)
+                   printf (_("<corrupt length: %#x> "), datasz);
+                 else
+                   decode_x86_isa (byte_get (ptr, 4));
+                 goto next;
+
+               case GNU_PROPERTY_X86_FEATURE_1_AND:
+                 printf ("x86 feature: ");
+                 if (datasz != 4)
+                   printf (_("<corrupt length: %#x> "), datasz);
+                 else
+                   decode_x86_feature (type, byte_get (ptr, 4));
+                 goto next;
+
+               default:
+                 break;
+               }
+           }
+       }
+      else
+       {
+         switch (type)
+           {
+           case GNU_PROPERTY_STACK_SIZE:
+             printf (_("stack size: "));
+             if (datasz != size)
+               printf (_("<corrupt length: %#x> "), datasz);
+             else
+               printf ("%#lx", (unsigned long) byte_get (ptr, size));
+             goto next;
+
+           case GNU_PROPERTY_NO_COPY_ON_PROTECTED:
+             printf ("no copy on protected ");
+             if (datasz)
+               printf (_("<corrupt length: %#x> "), datasz);
+             goto next;
+
+           default:
+             break;
+           }
+       }
+
+      if (type < GNU_PROPERTY_LOPROC)
+       printf (_("<unknown type %#x data: "), type);
+      else if (type < GNU_PROPERTY_LOUSER)
+       printf (_("<procesor-specific type %#x data: "), type);
+      else
+       printf (_("<application-specific type %#x data: "), type);
+      for (j = 0; j < datasz; ++j)
+       printf ("%02x ", ptr[j] & 0xff);
+      printf (">");
+
+next:
+      ptr += ((datasz + (size - 1)) & ~ (size - 1));
+      if (ptr == ptr_end)
+       break;
+      else
+       {
+         if (do_wide)
+           printf (", ");
+         else
+           printf ("\n\t");
+       }
+
+      if (ptr > (ptr_end - 8))
+       {
+         printf (_("<corrupt descsz: %#lx>\n"), pnote->descsz);
+         break;
+       }
+    }
+
+  printf ("\n");
+}
+
 static bfd_boolean
 print_gnu_note (Elf_Internal_Note *pnote)
 {
@@ -16015,6 +16623,10 @@ print_gnu_note (Elf_Internal_Note *pnote)
       }
       break;
 
+    case NT_GNU_PROPERTY_TYPE_0:
+      print_gnu_property_note (pnote);
+      break;
+      
     default:
       /* Handle unrecognised types.  An error message should have already been
         created by get_gnu_elf_note_type(), so all that we need to do is to
@@ -16403,15 +17015,410 @@ print_ia64_vms_note (Elf_Internal_Note * pnote)
   return TRUE;
 }
 
+/* Print the name of the symbol associated with a build attribute
+   that is attached to address OFFSET.  */
+
+static bfd_boolean
+print_symbol_for_build_attribute (FILE *         file,
+                                 unsigned long  offset,
+                                 bfd_boolean    is_open_attr)
+{
+  static FILE *             saved_file = NULL;
+  static char *             strtab;
+  static unsigned long      strtablen;
+  static Elf_Internal_Sym * symtab;
+  static unsigned long      nsyms;
+  Elf_Internal_Sym *        saved_sym = NULL;
+  Elf_Internal_Sym *        sym;
+
+  if (section_headers != NULL
+      && (saved_file == NULL || file != saved_file))
+    {
+      Elf_Internal_Shdr * symsec;
+
+      /* Load the symbol and string sections.  */
+      for (symsec = section_headers;
+          symsec < section_headers + elf_header.e_shnum;
+          symsec ++)
+       {
+         if (symsec->sh_type == SHT_SYMTAB)
+           {
+             symtab = GET_ELF_SYMBOLS (file, symsec, & nsyms);
+
+             if (symsec->sh_link < elf_header.e_shnum)
+               {
+                 Elf_Internal_Shdr * strtab_sec = section_headers + symsec->sh_link;
+
+                 strtab = (char *) get_data (NULL, file, strtab_sec->sh_offset,
+                                             1, strtab_sec->sh_size,
+                                             _("string table"));
+                 strtablen = strtab != NULL ? strtab_sec->sh_size : 0;
+               }
+           }
+       }
+      saved_file = file;
+    }
+
+  if (symtab == NULL || strtab == NULL)
+    {
+      printf ("\n");
+      return FALSE;
+    }
+
+  /* Find a symbol whose value matches offset.  */
+  for (sym = symtab; sym < symtab + nsyms; sym ++)
+    if (sym->st_value == offset)
+      {
+       if (sym->st_name >= strtablen)
+         /* Huh ?  This should not happen.  */
+         continue;
+
+       if (strtab[sym->st_name] == 0)
+         continue;
+
+       if (is_open_attr)
+         {
+           /* For OPEN attributes we prefer GLOBAL over LOCAL symbols
+              and FILE or OBJECT symbols over NOTYPE symbols.  We skip
+              FUNC symbols entirely.  */
+           switch (ELF_ST_TYPE (sym->st_info))
+             {
+             case STT_FILE:
+               saved_sym = sym;
+               /* We can stop searching now.  */
+               sym = symtab + nsyms;
+               continue;
+
+             case STT_OBJECT:
+               saved_sym = sym;
+               continue;
+
+             case STT_FUNC:
+               /* Ignore function symbols.  */
+               continue;
+
+             default:
+               break;
+             }
+
+           switch (ELF_ST_BIND (sym->st_info))
+             {
+             case STB_GLOBAL:
+               if (saved_sym == NULL
+                   || ELF_ST_TYPE (saved_sym->st_info) != STT_OBJECT)
+                 saved_sym = sym;
+               break;
+
+             case STB_LOCAL:
+               if (saved_sym == NULL)
+                 saved_sym = sym;
+               break;
+
+             default:
+               break;
+             }
+         }
+       else
+         {
+           if (ELF_ST_TYPE (sym->st_info) != STT_FUNC)
+             continue;
+
+           saved_sym = sym;
+           break;
+         }
+      }
+
+  printf (" (%s: %s)\n",
+         is_open_attr ? _("file") : _("func"),
+         saved_sym ? strtab + saved_sym->st_name : _("<no symbol found>)"));
+  return TRUE;
+}
+
+static bfd_boolean
+print_gnu_build_attribute_description (Elf_Internal_Note * pnote,
+                                      FILE *              file)
+{
+  static unsigned long global_offset = 0;
+  unsigned long        offset;
+  unsigned int         desc_size = is_32bit_elf ? 4 : 8;
+  bfd_boolean          is_open_attr = pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN;
+
+  if (pnote->descsz == 0)
+    {
+      if (is_open_attr)
+       {
+         printf (_("    Applies from offset %#lx\n"), global_offset);
+         return TRUE;
+       }
+      else
+       {
+         printf (_("    Applies to func at %#lx"), global_offset);
+         return print_symbol_for_build_attribute (file, global_offset, is_open_attr);
+       }
+    }
+
+  if (pnote->descsz != desc_size)
+    {
+      error (_("    <invalid description size: %lx>\n"), pnote->descsz);
+      printf (_("    <invalid descsz>"));
+      return FALSE;
+    }
+
+  offset = byte_get ((unsigned char *) pnote->descdata, desc_size);
+
+  if (is_open_attr)
+    {
+      printf (_("    Applies from offset %#lx"), offset);
+      global_offset = offset;
+    }
+  else
+    {
+      printf (_("    Applies to func at %#lx"), offset);
+    }
+
+  return print_symbol_for_build_attribute (file, offset, is_open_attr);
+}
+
+static bfd_boolean
+print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
+{
+  static const char string_expected [2] = { GNU_BUILD_ATTRIBUTE_TYPE_STRING, 0 };
+  static const char number_expected [2] = { GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC, 0 };
+  static const char bool_expected [3] = { GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE, GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE, 0 };
+  char         name_type;
+  char         name_attribute;
+  const char * expected_types;
+  const char * name = pnote->namedata;
+  const char * text;
+  signed int   left;
+
+  if (name == NULL || pnote->namesz < 2)
+    {
+      error (_("corrupt name field in GNU build attribute note: size = %ld\n"), pnote->namesz);
+      print_symbol (-20, _("  <corrupt name>"));
+      return FALSE;
+    }
+
+  left = 20;
+
+  /* Version 2 of the spec adds a "GA" prefix to the name field.  */
+  if (name[0] == 'G' && name[1] == 'A')
+    {
+      printf ("GA");
+      name += 2;
+      left -= 2;
+    }
+
+  switch ((name_type = * name))
+    {
+    case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC:
+    case GNU_BUILD_ATTRIBUTE_TYPE_STRING:
+    case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE:
+    case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE:
+      printf ("%c", * name);
+      left --;
+      break;
+    default:
+      error (_("unrecognised attribute type in name field: %d\n"), name_type);
+      print_symbol (-20, _("<unknown name type>"));
+      return FALSE;
+    }
+
+  ++ name;
+  text = NULL;
+
+  switch ((name_attribute = * name))
+    {
+    case GNU_BUILD_ATTRIBUTE_VERSION:
+      text = _("<version>");
+      expected_types = string_expected;
+      ++ name;
+      break;
+    case GNU_BUILD_ATTRIBUTE_STACK_PROT:
+      text = _("<stack prot>");
+      expected_types = "!+*";
+      ++ name;
+      break;
+    case GNU_BUILD_ATTRIBUTE_RELRO:
+      text = _("<relro>");
+      expected_types = bool_expected;
+      ++ name;
+      break;
+    case GNU_BUILD_ATTRIBUTE_STACK_SIZE:
+      text = _("<stack size>");
+      expected_types = number_expected;
+      ++ name;
+      break;
+    case GNU_BUILD_ATTRIBUTE_TOOL:
+      text = _("<tool>");
+      expected_types = string_expected;
+      ++ name;
+      break;
+    case GNU_BUILD_ATTRIBUTE_ABI:
+      text = _("<ABI>");
+      expected_types = "$*";
+      ++ name;
+      break;
+    case GNU_BUILD_ATTRIBUTE_PIC:
+      text = _("<PIC>");
+      expected_types = number_expected;
+      ++ name;
+      break;
+    case GNU_BUILD_ATTRIBUTE_SHORT_ENUM:
+      text = _("<short enum>");
+      expected_types = bool_expected;
+      ++ name;
+      break;
+    default:
+      if (ISPRINT (* name))
+       {
+         int len = strnlen (name, pnote->namesz - (name - pnote->namedata)) + 1;
+
+         if (len > left && ! do_wide)
+           len = left;
+         printf ("%.*s:", len, name);
+         left -= len;
+         name += len;
+       }
+      else
+       {
+         static char tmpbuf [128];
+
+         error (_("unrecognised byte in name field: %d\n"), * name);
+         sprintf (tmpbuf, _("<unknown:_%d>"), * name);
+         text = tmpbuf;
+         name ++;
+       }
+      expected_types = "*$!+";
+      break;
+    }
+
+  if (text)
+    left -= printf ("%s", text);
+
+  if (strchr (expected_types, name_type) == NULL)
+    warn (_("attribute does not have an expected type (%c)\n"), name_type);
+
+  if ((unsigned long)(name - pnote->namedata) > pnote->namesz)
+    {
+      error (_("corrupt name field: namesz: %lu but parsing gets to %ld\n"),
+            (unsigned long) pnote->namesz,
+            (long) (name - pnote->namedata));
+      return FALSE;
+    }
+
+  if (left < 1 && ! do_wide)
+    return TRUE;
+
+  switch (name_type)
+    {
+    case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC:
+      {
+       unsigned int        bytes;
+       unsigned long long  val = 0;
+       unsigned int        shift = 0;
+       char *              decoded = NULL;
+
+       bytes = pnote->namesz - (name - pnote->namedata);
+       if (bytes > 0)
+         /* The -1 is because the name field is always 0 terminated, and we
+            want to be able to ensure that the shift in the while loop below
+            will not overflow.  */
+         -- bytes;
+
+       if (bytes > sizeof (val))
+         {
+           fprintf (stderr, "namesz %lx name %p namedata %p\n",
+                    pnote->namesz, name, pnote->namedata);
+           error (_("corrupt numeric name field: too many bytes in the value: %x\n"),
+                  bytes);
+           bytes = sizeof (val);
+         }
+       /* We do not bother to warn if bytes == 0 as this can
+          happen with some early versions of the gcc plugin.  */
+
+       while (bytes --)
+         {
+           unsigned long byte = (* name ++) & 0xff;
+
+           val |= byte << shift;
+           shift += 8;
+         }
+
+       switch (name_attribute)
+         {
+         case GNU_BUILD_ATTRIBUTE_PIC:
+           switch (val)
+             {
+             case 0: decoded = "static"; break;
+             case 1: decoded = "pic"; break;
+             case 2: decoded = "PIC"; break;
+             case 3: decoded = "pie"; break;
+             case 4: decoded = "PIE"; break;
+             default: break;
+             }
+           break;
+         case GNU_BUILD_ATTRIBUTE_STACK_PROT:
+           switch (val)
+             {
+               /* Based upon the SPCT_FLAG_xxx enum values in gcc/cfgexpand.c.  */
+             case 0: decoded = "off"; break;
+             case 1: decoded = "on"; break;
+             case 2: decoded = "all"; break;
+             case 3: decoded = "strong"; break;
+             case 4: decoded = "explicit"; break;
+             default: break;
+             }
+           break;
+         default:
+           break;
+         }
+
+       if (decoded != NULL)
+         {
+           print_symbol (-left, decoded);
+           left = 0;
+         }
+       else if (val == 0)
+         {
+           printf ("0x0");
+           left -= 3;
+         }
+       else
+         {
+           if (do_wide)
+             left -= printf ("0x%llx", val);
+           else
+             left -= printf ("0x%-.*llx", left, val);
+         }
+      }
+      break;
+    case GNU_BUILD_ATTRIBUTE_TYPE_STRING:
+      left -= print_symbol (- left, name);
+      break;
+    case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE:
+      left -= print_symbol (- left, "true");
+      break;
+    case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE:
+      left -= print_symbol (- left, "false");
+      break;
+    }
+
+  if (do_wide && left > 0)
+    printf ("%-*s", left, " ");
+    
+  return TRUE;
+}
+
 /* Note that by the ELF standard, the name field is already null byte
    terminated, and namesz includes the terminating null byte.
    I.E. the value of namesz for the name "FSF" is 4.
 
    If the value of namesz is zero, there is no name present.  */
+
 static bfd_boolean
-process_note (Elf_Internal_Note * pnote,
-             FILE * file ATTRIBUTE_UNUSED,
-             Elf_Internal_Shdr * section ATTRIBUTE_UNUSED)
+process_note (Elf_Internal_Note *  pnote,
+             FILE *               file)
 {
   const char * name = pnote->namesz ? pnote->namedata : "(NONE)";
   const char * nt;
@@ -16457,8 +17464,17 @@ process_note (Elf_Internal_Note * pnote,
     nt = get_note_type (pnote->type);
 
   printf ("  ");
-  print_symbol (-20, name);
-  printf (" 0x%08lx\t%s\n", pnote->descsz, nt);
+
+  if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN
+      || pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC)
+    print_gnu_build_attribute_name (pnote);
+  else
+    print_symbol (-20, name);
+
+  if (do_wide)
+    printf (" 0x%08lx\t%s\t", pnote->descsz, nt);
+  else
+    printf (" 0x%08lx\t%s\n", pnote->descsz, nt);
 
   if (const_strneq (pnote->namedata, "IPF/VMS"))
     return print_ia64_vms_note (pnote);
@@ -16468,17 +17484,22 @@ process_note (Elf_Internal_Note * pnote,
     return print_stapsdt_note (pnote);
   else if (const_strneq (pnote->namedata, "CORE"))
     return print_core_note (pnote);
+  else if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN
+          || pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC)
+    return print_gnu_build_attribute_description (pnote, file);
 
-  else if (pnote->descsz)
+  if (pnote->descsz)
     {
       unsigned long i;
 
       printf (_("   description data: "));
       for (i = 0; i < pnote->descsz; i++)
        printf ("%02x ", pnote->descdata[i]);
-      printf ("\n");
     }
 
+  if (do_wide)
+    printf ("\n");
+
   return TRUE;
 }
 
@@ -16549,7 +17570,8 @@ process_notes_at (FILE *              file,
          /* PR 17531: file: 3443835e.  */
          if (inote.descdata < (char *) pnotes || inote.descdata > end)
            {
-             warn (_("Corrupt note: name size is too big: %lx\n"), inote.namesz);
+             warn (_("Corrupt note: name size is too big: (got: %lx, expected no more than: %lx)\n"),
+                   inote.namesz, (long)(end - inote.namedata));
              inote.descdata = inote.namedata;
              inote.namesz   = 0;
            }
@@ -16611,14 +17633,14 @@ process_notes_at (FILE *              file,
              break;
            }
 
-         strncpy (temp, inote.namedata, inote.namesz);
+         memcpy (temp, inote.namedata, inote.namesz);
          temp[inote.namesz] = 0;
 
          /* warn (_("'%s' NOTE name not properly null terminated\n"), temp);  */
          inote.namedata = temp;
        }
 
-      if (! process_note (& inote, file, section))
+      if (! process_note (& inote, file))
        res = FALSE;
 
       if (temp != NULL)
@@ -16828,6 +17850,12 @@ process_arch_specific (FILE * file)
 
   switch (elf_header.e_machine)
     {
+    case EM_ARC:
+    case EM_ARC_COMPACT:
+    case EM_ARC_COMPACT2:
+      return process_attributes (file, "ARC", SHT_ARC_ATTRIBUTES,
+                                display_arc_attribute,
+                                display_generic_attribute);
     case EM_ARM:
       return process_attributes (file, "aeabi", SHT_ARM_ATTRIBUTES,
                                 display_arm_attribute,
@@ -16838,7 +17866,7 @@ process_arch_specific (FILE * file)
       return process_mips_specific (file);
 
     case EM_MSP430:
-      return process_attributes (file, "mspabi", SHT_MSP430_ATTRIBUTES,
+     return process_attributes (file, "mspabi", SHT_MSP430_ATTRIBUTES,
                                 display_msp430x_attribute,
                                 display_generic_attribute);