X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=binutils%2Freadelf.c;h=7c5a0266bddf92162b1d915be051926a17fffb67;hb=67ce483baa43121a17195efe4b14a183e9fd8232;hp=cf395dbe2d6998abc481a918d9f5370441c02200;hpb=f954747f10467071b0acde07ee5f5e268ab606a6;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/readelf.c b/binutils/readelf.c index cf395dbe2d..7c5a0266bd 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -119,6 +119,7 @@ #include "elf/m32r.h" #include "elf/m68k.h" #include "elf/m68hc11.h" +#include "elf/s12z.h" #include "elf/mcore.h" #include "elf/mep.h" #include "elf/metag.h" @@ -131,6 +132,7 @@ #include "elf/mt.h" #include "elf/msp430.h" #include "elf/nds32.h" +#include "elf/nfp.h" #include "elf/nios2.h" #include "elf/or1k.h" #include "elf/pj.h" @@ -515,7 +517,8 @@ print_symbol (signed int width, const char *symbol) width = - width; extra_padding = TRUE; } - assert (width != 0); + else if (width == 0) + return 0; if (do_wide) /* Set the remaining width to a very large value. @@ -775,6 +778,7 @@ guess_is_rela (unsigned int e_machine) case EM_CYGNUS_M32R: case EM_SCORE: case EM_XGATE: + case EM_NFP: return FALSE; /* Targets that use RELA relocations. */ @@ -1271,6 +1275,10 @@ dump_relocations (Filedata * filedata, rtype = elf_m68hc11_reloc_type (type); break; + case EM_S12Z: + rtype = elf_s12z_reloc_type (type); + break; + case EM_68K: rtype = elf_m68k_reloc_type (type); break; @@ -1559,6 +1567,13 @@ dump_relocations (Filedata * filedata, case EM_TI_PRU: rtype = elf_pru_reloc_type (type); break; + + case EM_NFP: + if (EF_NFP_MACH (filedata->file_header.e_flags) == E_NFP_MACH_3200) + rtype = elf_nfp3200_reloc_type (type); + else + rtype = elf_nfp_reloc_type (type); + break; } if (rtype == NULL) @@ -2471,6 +2486,7 @@ get_machine_name (unsigned e_machine) case EM_RISCV: return "RISC-V"; case EM_LANAI: return "Lanai 32-bit processor"; case EM_BPF: return "Linux BPF"; + case EM_NFP: return "Netronome Flow Processor"; /* Large numbers... */ case EM_MT: return "Morpho Techologies MT processor"; @@ -2484,6 +2500,7 @@ get_machine_name (unsigned e_machine) case EM_CYGNUS_MEP: return "Toshiba MeP Media Engine"; case EM_ADAPTEVA_EPIPHANY: return "Adapteva EPIPHANY"; case EM_CYGNUS_FRV: return "Fujitsu FR-V"; + case EM_S12Z: return "Freescale S12Z"; default: snprintf (buff, sizeof (buff), _(": 0x%x"), e_machine); @@ -2577,6 +2594,12 @@ decode_ARM_machine_flags (unsigned e_flags, char buf[]) e_flags &= ~ EF_ARM_RELEXEC; } + if (e_flags & EF_ARM_PIC) + { + strcat (buf, ", position independent"); + e_flags &= ~ EF_ARM_PIC; + } + /* Now handle EABI specific flags. */ switch (eabi) { @@ -3433,10 +3456,25 @@ get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine) decode_NDS32_machine_flags (e_flags, buf, sizeof buf); break; + case EM_NFP: + switch (EF_NFP_MACH (e_flags)) + { + case E_NFP_MACH_3200: + strcat (buf, ", NFP-32xx"); + break; + case E_NFP_MACH_6000: + strcat (buf, ", NFP-6xxx"); + break; + } + break; + case EM_RISCV: if (e_flags & EF_RISCV_RVC) strcat (buf, ", RVC"); + if (e_flags & EF_RISCV_RVE) + strcat (buf, ", RVE"); + switch (e_flags & EF_RISCV_FLOAT_ABI) { case EF_RISCV_FLOAT_ABI_SOFT: @@ -3717,6 +3755,7 @@ get_osabi_name (Filedata * filedata, unsigned int osabi) switch (osabi) { case ELFOSABI_ARM: return "ARM"; + case ELFOSABI_ARM_FDPIC: return "ARM FDPIC"; default: break; } @@ -4127,6 +4166,18 @@ get_msp430x_section_type_name (unsigned int sh_type) } } +static const char * +get_nfp_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_NFP_MECONFIG: return "NFP_MECONFIG"; + case SHT_NFP_INITREG: return "NFP_INITREG"; + case SHT_NFP_UDEBUG: return "NFP_UDEBUG"; + default: return NULL; + } +} + static const char * get_v850_section_type_name (unsigned int sh_type) { @@ -4166,7 +4217,7 @@ get_section_type_name (Filedata * filedata, unsigned int sh_type) case SHT_PREINIT_ARRAY: return "PREINIT_ARRAY"; case SHT_GNU_HASH: return "GNU_HASH"; case SHT_GROUP: return "GROUP"; - case SHT_SYMTAB_SHNDX: return "SYMTAB SECTION INDICIES"; + case SHT_SYMTAB_SHNDX: return "SYMTAB SECTION INDICES"; case SHT_GNU_verdef: return "VERDEF"; case SHT_GNU_verneed: return "VERNEED"; case SHT_GNU_versym: return "VERSYM"; @@ -4213,6 +4264,9 @@ get_section_type_name (Filedata * filedata, unsigned int sh_type) case EM_MSP430: result = get_msp430x_section_type_name (sh_type); break; + case EM_NFP: + result = get_nfp_section_type_name (sh_type); + break; case EM_V800: case EM_V850: case EM_CYGNUS_V850: @@ -5431,7 +5485,7 @@ get_32bit_elf_symbols (Filedata * filedata, shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata, entry->hdr->sh_offset, 1, entry->hdr->sh_size, - _("symbol table section indicies")); + _("symbol table section indices")); if (shndx == NULL) goto exit_point; /* PR17531: file: heap-buffer-overflow */ @@ -5544,7 +5598,7 @@ get_64bit_elf_symbols (Filedata * filedata, shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata, entry->hdr->sh_offset, 1, entry->hdr->sh_size, - _("symbol table section indicies")); + _("symbol table section indices")); if (shndx == NULL) goto exit_point; /* PR17531: file: heap-buffer-overflow */ @@ -6454,8 +6508,7 @@ process_section_headers (Filedata * filedata) } else if (do_section_details) { - printf (" %-15.15s ", - get_section_type_name (filedata, section->sh_type)); + putchar (' '); print_vma (section->sh_addr, LONG_HEX); if ((long) section->sh_offset == section->sh_offset) printf (" %16.16lx", (unsigned long) section->sh_offset); @@ -6789,7 +6842,7 @@ process_section_groups (Filedata * filedata) error (_("section [%5u] in group section [%5u] > maximum section [%5u]\n"), entry, i, filedata->file_header.e_shnum - 1); if (num_group_errors == 10) - warn (_("Further error messages about overlarge group section indicies suppressed\n")); + warn (_("Further error messages about overlarge group section indices suppressed\n")); } continue; } @@ -11212,7 +11265,7 @@ get_symbol_version_string (Filedata * filedata, vers_data = byte_get (data, 2); - if ((vers_data & VERSYM_HIDDEN) == 0 && vers_data <= 1) + if ((vers_data & VERSYM_HIDDEN) == 0 && vers_data == 0) return NULL; /* Usually we'd only see verdef for defined symbols, and verneed for @@ -11247,12 +11300,14 @@ get_symbol_version_string (Filedata * filedata, ivd.vd_ndx = 0; ivd.vd_aux = 0; ivd.vd_next = 0; + ivd.vd_flags = 0; } else { ivd.vd_ndx = BYTE_GET (evd.vd_ndx); ivd.vd_aux = BYTE_GET (evd.vd_aux); ivd.vd_next = BYTE_GET (evd.vd_next); + ivd.vd_flags = BYTE_GET (evd.vd_flags); } off += ivd.vd_next; @@ -11261,6 +11316,9 @@ get_symbol_version_string (Filedata * filedata, if (ivd.vd_ndx == (vers_data & VERSYM_VERSION)) { + if (ivd.vd_ndx == 1 && ivd.vd_flags == VER_FLG_BASE) + return NULL; + off -= ivd.vd_next; off += ivd.vd_aux; @@ -12263,6 +12321,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) case EM_68HC11: case EM_68HC12: return reloc_type == 6; /* R_M68HC11_32. */ + case EM_S12Z: + return reloc_type == 6; /* R_S12Z_EXT32. */ case EM_MCORE: return reloc_type == 1; /* R_MCORE_ADDR32. */ case EM_CYGNUS_MEP: @@ -12297,7 +12357,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) case EM_OR1K: return reloc_type == 1; /* R_OR1K_32. */ case EM_PARISC: - return (reloc_type == 1 /* R_PARISC_DIR32. */ + return (reloc_type == 1 /* R_PARISC_DIR32. */ + || reloc_type == 2 /* R_PARISC_DIR21L. */ || reloc_type == 41); /* R_PARISC_SECREL32. */ case EM_PJ: case EM_PJ_OLD: @@ -12597,6 +12658,8 @@ is_16bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) return reloc_type == 9; /* R_NIOS_16. */ case EM_OR1K: return reloc_type == 2; /* R_OR1K_16. */ + case EM_RISCV: + return reloc_type == 55; /* R_RISCV_SET16. */ case EM_TI_PRU: return reloc_type == 8; /* R_PRU_BFD_RELOC_16. */ case EM_TI_C6000: @@ -12613,6 +12676,36 @@ is_16bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) } } +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 8-bit absolute RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_8bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) +{ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 54; /* R_RISCV_SET8. */ + default: + return FALSE; + } +} + +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 6-bit absolute RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_6bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) +{ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 53; /* R_RISCV_SET6. */ + default: + return FALSE; + } +} + /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is a 32-bit inplace add RELA relocation used in DWARF debug sections. */ @@ -12741,6 +12834,21 @@ is_8bit_inplace_sub_reloc (Filedata * filedata, unsigned int reloc_type) } } +/* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is + a 6-bit inplace sub RELA relocation used in DWARF debug sections. */ + +static bfd_boolean +is_6bit_inplace_sub_reloc (Filedata * filedata, unsigned int reloc_type) +{ + switch (filedata->file_header.e_machine) + { + case EM_RISCV: + return reloc_type == 52; /* R_RISCV_SUB6. */ + default: + return FALSE; + } +} + /* Returns TRUE iff RELOC_TYPE is a NONE relocation used for discarded relocation entries (possibly formerly used for SHT_GROUP sections). */ @@ -12944,6 +13052,9 @@ apply_relocations (Filedata * filedata, reloc_size = 3; else if (is_16bit_abs_reloc (filedata, reloc_type)) reloc_size = 2; + else if (is_8bit_abs_reloc (filedata, reloc_type) + || is_6bit_abs_reloc (filedata, reloc_type)) + reloc_size = 1; else if ((reloc_subtract = is_32bit_inplace_sub_reloc (filedata, reloc_type)) || is_32bit_inplace_add_reloc (filedata, reloc_type)) @@ -12972,6 +13083,12 @@ apply_relocations (Filedata * filedata, reloc_size = 1; reloc_inplace = TRUE; } + else if ((reloc_subtract = is_6bit_inplace_sub_reloc (filedata, + reloc_type))) + { + reloc_size = 1; + reloc_inplace = TRUE; + } else { static unsigned int prev_reloc = 0; @@ -13044,7 +13161,12 @@ apply_relocations (Filedata * filedata, || filedata->file_header.e_machine == EM_CYGNUS_D30V) && reloc_type == 12) || reloc_inplace) - addend += byte_get (rloc, reloc_size); + { + if (is_6bit_inplace_sub_reloc (filedata, reloc_type)) + addend += byte_get (rloc, reloc_size) & 0x3f; + else + addend += byte_get (rloc, reloc_size); + } if (is_32bit_pcrel_reloc (filedata, reloc_type) || is_64bit_pcrel_reloc (filedata, reloc_type)) @@ -13055,6 +13177,16 @@ apply_relocations (Filedata * filedata, byte_put (rloc, (addend + sym->st_value) - rp->r_offset, reloc_size); } + else if (is_6bit_abs_reloc (filedata, reloc_type) + || is_6bit_inplace_sub_reloc (filedata, reloc_type)) + { + if (reloc_subtract) + addend -= sym->st_value; + else + addend += sym->st_value; + addend = (addend & 0x3f) | (byte_get (rloc, reloc_size) & 0xc0); + byte_put (rloc, addend, reloc_size); + } else if (reloc_subtract) byte_put (rloc, addend - sym->st_value, reloc_size); else @@ -15447,6 +15579,12 @@ print_mips_ases (unsigned int mask) fputs ("\n\tXPA ASE", stdout); if (mask & AFL_ASE_MIPS16E2) fputs ("\n\tMIPS16e2 ASE", stdout); + if (mask & AFL_ASE_CRC) + fputs ("\n\tCRC ASE", stdout); + if (mask & AFL_ASE_GINV) + fputs ("\n\tGINV ASE", stdout); + if (mask & AFL_ASE_LOONGSON_MMI) + fputs ("\n\tLoongson MMI ASE", stdout); if (mask == 0) fprintf (stdout, "\n\t%s", _("None")); else if ((mask & ~AFL_ASE_MASK) != 0) @@ -16543,7 +16681,7 @@ get_note_type (Filedata * filedata, unsigned e_type) case NT_PPC_TM_CVMX: return _("NT_PPC_TM_CVMX (ppc checkpointed Altivec registers)"); case NT_PPC_TM_CVSX: - return _("NT_PPC_TM_VSX (ppc checkpointed VSX registers)"); + return _("NT_PPC_TM_CVSX (ppc checkpointed VSX registers)"); case NT_PPC_TM_SPR: return _("NT_PPC_TM_SPR (ppc TM special purpose registers)"); case NT_PPC_TM_CTAR: @@ -17568,6 +17706,20 @@ get_symbol_for_build_attribute (Filedata * filedata, return saved_sym; } +/* Returns true iff addr1 and addr2 are in the same section. */ + +static bfd_boolean +same_section (Filedata * filedata, unsigned long addr1, unsigned long addr2) +{ + Elf_Internal_Shdr * a1; + Elf_Internal_Shdr * a2; + + a1 = find_section_by_address (filedata, addr1); + a2 = find_section_by_address (filedata, addr2); + + return a1 == a2 && a1 != NULL; +} + static bfd_boolean print_gnu_build_attribute_description (Elf_Internal_Note * pnote, Filedata * filedata) @@ -17649,8 +17801,14 @@ print_gnu_build_attribute_description (Elf_Internal_Note * pnote, if (is_open_attr) { - /* FIXME: Need to properly allow for section alignment. 16 is just the alignment used on x86_64. */ - if (global_end > 0 && start > BFD_ALIGN (global_end, 16)) + /* FIXME: Need to properly allow for section alignment. + 16 is just the alignment used on x86_64. */ + if (global_end > 0 + && start > BFD_ALIGN (global_end, 16) + /* Build notes are not guaranteed to be organised in order of + increasing address, but we should find the all of the notes + for one section in the same place. */ + && same_section (filedata, start, global_end)) warn (_("Gap in build notes detected from %#lx to %#lx\n"), global_end + 1, start - 1); @@ -18869,7 +19027,7 @@ process_archive (Filedata * filedata, bfd_boolean is_thin_archive) l += strnlen (arch.sym_table + l, arch.sym_size - l) + 1; } - if (arch.uses_64bit_indicies) + if (arch.uses_64bit_indices) l = (l + 7) & ~ 7; else l += l & 1;