gas: run the hwcaps-bump tests with 64-bit sparc objects only.
[deliverable/binutils-gdb.git] / binutils / readelf.c
index 69942cf711c652e868a5b8adf1dbc4e5b47c4fa0..e782e9561f2069d7ec2e7ac8b63ab73fb34d6183 100644 (file)
 #include "elf/metag.h"
 #include "elf/microblaze.h"
 #include "elf/mips.h"
+#include "elf/riscv.h"
 #include "elf/mmix.h"
 #include "elf/mn10200.h"
 #include "elf/mn10300.h"
@@ -775,6 +776,7 @@ guess_is_rela (unsigned int e_machine)
     case EM_OR1K:
     case EM_PPC64:
     case EM_PPC:
+    case EM_RISCV:
     case EM_RL78:
     case EM_RX:
     case EM_S390:
@@ -1314,6 +1316,10 @@ dump_relocations (FILE * file,
          rtype = elf_mips_reloc_type (type);
          break;
 
+       case EM_RISCV:
+         rtype = elf_riscv_reloc_type (type);
+         break;
+
        case EM_ALPHA:
          rtype = elf_alpha_reloc_type (type);
          break;
@@ -2327,6 +2333,7 @@ get_machine_name (unsigned e_machine)
     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";
@@ -2363,7 +2370,6 @@ get_machine_name (unsigned e_machine)
     case EM_CSR_KALIMBA:       return "CSR Kalimba architecture family";
     case EM_Z80:               return "Zilog Z80";
     case EM_AMDGPU:            return "AMD GPU architecture";
-    case EM_RISCV:             return "RISC-V";
     default:
       snprintf (buff, sizeof (buff), _("<unknown>: 0x%x"), e_machine);
       return buff;
@@ -3308,6 +3314,13 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
          decode_NDS32_machine_flags (e_flags, buf, sizeof buf);
          break;
 
+       case EM_RISCV:
+         if (e_flags & EF_RISCV_RVC)
+           strcat (buf, ", RVC");
+         if (e_flags & EF_RISCV_SOFT_FLOAT)
+           strcat (buf, ", soft-float ABI");
+         break;
+
        case EM_SH:
          switch ((e_flags & EF_SH_MACH_MASK))
            {
@@ -5965,7 +5978,7 @@ process_section_headers (FILE * file)
        case SHT_REL:
        case SHT_RELA:
          if (section->sh_link < 1
-             || section->sh_link > elf_header.e_shnum
+             || section->sh_link >= elf_header.e_shnum
              || (section_headers[section->sh_link].sh_type != SHT_SYMTAB
                  && section_headers[section->sh_link].sh_type != SHT_DYNSYM))
            warn (_("[%2u]: Link field (%u) should index a symtab section.\n"),
@@ -5979,7 +5992,7 @@ process_section_headers (FILE * file)
        case SHT_GNU_verdef:
        case SHT_GNU_LIBLIST:
          if (section->sh_link < 1
-             || section->sh_link > elf_header.e_shnum
+             || section->sh_link >= elf_header.e_shnum
              || section_headers[section->sh_link].sh_type != SHT_STRTAB)
            warn (_("[%2u]: Link field (%u) should index a string section.\n"),
                  i, section->sh_link);
@@ -6012,7 +6025,7 @@ process_section_headers (FILE * file)
        case SHT_REL:
        case SHT_RELA:
          if (section->sh_info < 1
-             || section->sh_info > elf_header.e_shnum
+             || section->sh_info >= elf_header.e_shnum
              || (section_headers[section->sh_info].sh_type != SHT_PROGBITS
                  && section_headers[section->sh_info].sh_type != SHT_NOBITS
                  && section_headers[section->sh_info].sh_type != SHT_NOTE
@@ -6059,7 +6072,7 @@ process_section_headers (FILE * file)
            ;
          else if (section->sh_flags & SHF_INFO_LINK)
            {
-             if (section->sh_info < 1 || section->sh_info > elf_header.e_shnum)
+             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)
@@ -11788,6 +11801,8 @@ is_32bit_abs_reloc (unsigned int reloc_type)
       return reloc_type == 1; /* R_PPC64_ADDR32.  */
     case EM_PPC:
       return reloc_type == 1; /* R_PPC_ADDR32.  */
+    case EM_RISCV:
+      return reloc_type == 1; /* R_RISCV_32.  */
     case EM_RL78:
       return reloc_type == 1; /* R_RL78_DIR32.  */
     case EM_RX:
@@ -11941,6 +11956,8 @@ is_64bit_abs_reloc (unsigned int reloc_type)
       return reloc_type == 80; /* R_PARISC_DIR64.  */
     case EM_PPC64:
       return reloc_type == 38; /* R_PPC64_ADDR64.  */
+    case EM_RISCV:
+      return reloc_type == 2; /* R_RISCV_64.  */
     case EM_SPARC32PLUS:
     case EM_SPARCV9:
     case EM_SPARC:
@@ -12112,6 +12129,7 @@ is_none_reloc (unsigned int reloc_type)
     case EM_PARISC:  /* R_PARISC_NONE.  */
     case EM_PPC64:   /* R_PPC64_NONE.  */
     case EM_PPC:     /* R_PPC_NONE.  */
+    case EM_RISCV:   /* R_RISCV_NONE.  */
     case EM_S390:    /* R_390_NONE.  */
     case EM_S390_OLD:
     case EM_SH:      /* R_SH_NONE.  */
This page took 0.027739 seconds and 4 git commands to generate.