aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorCooper Qu <cooper.qu@linux.alibaba.com>2020-08-26 11:21:14 +0800
committerLifang Xia <lifang_xia@c-sky.com>2020-08-28 17:23:24 +0800
commit0861f561ebdd283e389c2c2fdb099bffadffecfa (patch)
treee5f13278de132426df58f2af728f1c7b747b790c /binutils
parent6194b866b7a89969d8c66f8a97d40acc028373b1 (diff)
downloadfsf-binutils-gdb-0861f561ebdd283e389c2c2fdb099bffadffecfa.zip
fsf-binutils-gdb-0861f561ebdd283e389c2c2fdb099bffadffecfa.tar.gz
fsf-binutils-gdb-0861f561ebdd283e389c2c2fdb099bffadffecfa.tar.bz2
CSKY: Support attribute section.
bfd * elf32-csky.c (csky_archs): Fix arch names. (csky_find_arch_with_name): New. (elf32_csky_merge_attributes): New. (csky_elf_merge_private_bfd_data): Add process of merge attribute section. (elf32_csky_obj_attrs_arg_type): New. (elf32_csky_obj_attrs_handle_unknown): New. (elf_backend_obj_attrs_vendor): Define. (elf_backend_obj_attrs_section): Define. (elf_backend_obj_attrs_arg_type): Define. (elf_backend_obj_attrs_section_type): Define. binutils/ * readelf.c (get_csky_section_type_name): New. (get_section_type_name): Add handler for CSKY. (display_csky_attribute): New. (process_arch_specific): Add handler for CSKY. * testsuite/binutils-all/strip-3.d: Remove .csky.attributes section. elfcpp/ * elfcpp.h (enum SHT): New enum SHT_CSKY_ATTRIBUTES. gas/ * gas/config/tc-csky.c (md_begin): Set attributes. (isa_flag): Change type to unsigned 64 bits. (struct csky_cpu_info): Likewise. (struct csky_macro_info): Likewise. (set_csky_attribute): New. * testsuite/gas/csky/802j.d: Ignore .csky.attributes section. * testsuite/gas/csky/all.d: Likewise. * testsuite/gas/csky/bsr1.d: Likewise. * testsuite/gas/csky/csky_vdsp.d: Likewise. * testsuite/gas/csky/cskyv2_all.d: Likewise. * testsuite/gas/csky/cskyv2_ck803r2.d: Likewise. * testsuite/gas/csky/cskyv2_ck860.d: Likewise. * testsuite/gas/csky/cskyv2_dsp.d: Likewise. * testsuite/gas/csky/cskyv2_elrw.d: Likewise. * testsuite/gas/csky/cskyv2_float.d: Likewise. * testsuite/gas/csky/enhance_dsp.d: Likewise. * testsuite/gas/csky/java.d: Likewise. * testsuite/gas/csky/v1_float.d: Likewise. * testsuite/gas/csky/v2_float_part1.d: Likewise. * testsuite/gas/csky/v2_float_part2.d: Likewise. * testsuite/gas/csky/v2_tls_gd.d: Likewise. * testsuite/gas/csky/v2_tls_ie.d: Likewise. * testsuite/gas/csky/v2_tls_ld.d: Likewise. * testsuite/gas/csky/v2_tls_le.d: Likewise. * testsuite/gas/elf/elf.exp: Add handler for CSKY. * testsuite/gas/elf/section2.e-csky: New. include/ * elf/csky.h (SHT_CSKY_ATTRIBUTES): Define. (Tag_CSKY_ARCH_NAME): New enum constant. (Tag_CSKY_CPU_NAME): Likewise. (Tag_CSKY_ISA_FLAGS): Likewise. (Tag_CSKY_DSP_VERSION): Likewise. (Tag_CSKY_VDSP_VERSION): Likewise. (Tag_CSKY_FPU_VERSION): Likewise. (Tag_CSKY_FPU_ABI): Likewise. (Tag_CSKY_FPU_ROUNDING): Likewise. (Tag_CSKY_FPU_DENORMAL): Likewise. (Tag_CSKY_FPU_Exception): Likewise. (Tag_CSKY_FPU_NUMBER_MODULE): Likewise. (Tag_CSKY_FPU_HARDFP): Likewise. (Tag_CSKY_MAX): Likewise. (VAL_CSKY_DSP_VERSION_EXTENSION): Likewise. (VAL_CSKY_DSP_VERSION_2): Likewise. (VAL_CSKY_VDSP_VERSION_1): Likewise. (VAL_CSKY_VDSP_VERSION_2): Likewise. (VAL_CSKY_FPU_ABI_SOFT): Likewise. (VAL_CSKY_FPU_ABI_SOFTFP): Likewise. (VAL_CSKY_FPU_ABI_HARD): Likewise. (VAL_CSKY_FPU_HARDFP_HALF): Likewise. (VAL_CSKY_FPU_HARDFP_SINGLE): Likewise. (VAL_CSKY_FPU_HARDFP_DOUBLE): Likewise. * opcode/csky.h (CSKY_ISA_VDSP_V2): Define. CSKYV1_ISA_E1: Change to long constant type. CSKYV2_ISA_E1: Likewise. CSKYV2_ISA_1E2: Likewise. CSKYV2_ISA_2E3: Likewise. CSKYV2_ISA_3E7: Likewise. CSKYV2_ISA_7E10: Likewise. CSKYV2_ISA_3E3R1: Likewise. CSKYV2_ISA_3E3R2: Likewise. CSKYV2_ISA_10E60: Likewise. CSKY_ISA_TRUST: Likewise. CSKY_ISA_CACHE: Likewise. CSKY_ISA_NVIC: Likewise. CSKY_ISA_CP: Likewise. CSKY_ISA_MP: Likewise. CSKY_ISA_MP_1E2: Likewise. CSKY_ISA_JAVA: Likewise. CSKY_ISA_MAC: Likewise. CSKY_ISA_MAC_DSP: Likewise. CSKY_ISA_DSP: Likewise. CSKY_ISA_DSP_1E2: Likewise. CSKY_ISA_DSP_ENHANCE: Likewise. CSKY_ISA_FLOAT_E1: Likewise. CSKY_ISA_FLOAT_1E2: Likewise. CSKY_ISA_FLOAT_1E3: Likewise. CSKY_ISA_FLOAT_3E4: Likewise. CSKY_ISA_VDSP: Likewise. ld/ * emulparams/cskyelf.sh: Support attribute section. * testsuite/ld-csky/tls-le-v1.d: Match .csky.attributes section. * ld/testsuite/ld-csky/tls-le.d: Likewise. * testsuite/ld-elf/non-contiguous.ld: Ignore .csky.attributes section. opcodes/ * csky-dis.c (CSKY_DEFAULT_ISA): Define. (csky_dis_info): Add member isa. (csky_find_inst_info): Skip instructions that do not belong to current CPU. (csky_get_disassembler): Get infomation from attribute section. (print_insn_csky): Set defualt ISA flag. * csky.h (CSKY_ISA_VDSP_2): Rename from CSKY_ISA_VDSP_V2. * csky-opc.h (struct csky_opcode): Change isa_flag16 and isa_flag32'type to unsigned 64 bits.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog9
-rw-r--r--binutils/readelf.c121
-rw-r--r--binutils/testsuite/binutils-all/strip-3.d2
3 files changed, 131 insertions, 1 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 22d95e2..8a6cadc 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,12 @@
+2020-08-28 Cooper Qu <cooper.qu@linux.alibaba.com>
+
+ * readelf.c (get_csky_section_type_name): New.
+ (get_section_type_name): Add handler for CSKY.
+ (display_csky_attribute): New.
+ (process_arch_specific): Add handler for CSKY.
+ * testsuite/binutils-all/strip-3.d: Remove .csky.attributes
+ section.
+
2020-08-27 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* readelf.c (get_msp430x_section_type_name): Rename to ...
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 3758ff1..f02848e 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4315,6 +4315,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)
{
static char buff[32];
@@ -4397,6 +4407,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;
@@ -16358,6 +16371,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,
@@ -20146,6 +20263,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,
diff --git a/binutils/testsuite/binutils-all/strip-3.d b/binutils/testsuite/binutils-all/strip-3.d
index 2a886d2..cb2f78e 100644
--- a/binutils/testsuite/binutils-all/strip-3.d
+++ b/binutils/testsuite/binutils-all/strip-3.d
@@ -1,6 +1,6 @@
#PROG: strip
#source: empty.s
-#strip: -R .text -R .data -R .bss -R .ARM.attributes -R .reginfo -R .gnu.attributes -R .MIPS.abiflags -R .pdr -R .xtensa.info -R .ARC.attributes -R .note.gnu.property -R .riscv.attributes
+#strip: -R .text -R .data -R .bss -R .ARM.attributes -R .reginfo -R .gnu.attributes -R .MIPS.abiflags -R .pdr -R .xtensa.info -R .ARC.attributes -R .note.gnu.property -R .riscv.attributes -R .csky.attributes
#readelf: -S --wide
#name: strip empty file
#target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi