aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog14
-rw-r--r--bfd/elf32-csky.c360
-rw-r--r--binutils/ChangeLog9
-rw-r--r--binutils/readelf.c121
-rw-r--r--binutils/testsuite/binutils-all/strip-3.d2
-rw-r--r--elfcpp/ChangeLog4
-rw-r--r--elfcpp/elfcpp.h4
-rw-r--r--gas/ChangeLog29
-rw-r--r--gas/config/tc-csky.c90
-rw-r--r--gas/testsuite/gas/csky/802j.d1
-rw-r--r--gas/testsuite/gas/csky/all.d1
-rw-r--r--gas/testsuite/gas/csky/bsr1.d1
-rw-r--r--gas/testsuite/gas/csky/csky_vdsp.d1
-rw-r--r--gas/testsuite/gas/csky/cskyv2_all.d1
-rw-r--r--gas/testsuite/gas/csky/cskyv2_ck803r2.d1
-rw-r--r--gas/testsuite/gas/csky/cskyv2_ck860.d3
-rw-r--r--gas/testsuite/gas/csky/cskyv2_dsp.d3
-rw-r--r--gas/testsuite/gas/csky/cskyv2_elrw.d1
-rw-r--r--gas/testsuite/gas/csky/cskyv2_float.d1
-rw-r--r--gas/testsuite/gas/csky/enhance_dsp.d1
-rw-r--r--gas/testsuite/gas/csky/java.d1
-rw-r--r--gas/testsuite/gas/csky/v1_float.d1
-rw-r--r--gas/testsuite/gas/csky/v2_float_part1.d1
-rw-r--r--gas/testsuite/gas/csky/v2_float_part2.d1
-rw-r--r--gas/testsuite/gas/csky/v2_tls_gd.d1
-rw-r--r--gas/testsuite/gas/csky/v2_tls_ie.d1
-rw-r--r--gas/testsuite/gas/csky/v2_tls_ld.d1
-rw-r--r--gas/testsuite/gas/csky/v2_tls_le.d3
-rw-r--r--gas/testsuite/gas/elf/elf.exp3
-rw-r--r--gas/testsuite/gas/elf/section2.e-csky9
-rw-r--r--include/ChangeLog54
-rw-r--r--include/elf/csky.h75
-rw-r--r--include/opcode/csky.h55
-rw-r--r--ld/ChangeLog8
-rw-r--r--ld/emulparams/cskyelf.sh1
-rw-r--r--ld/testsuite/ld-csky/tls-le-v1.d2
-rw-r--r--ld/testsuite/ld-csky/tls-le.d2
-rw-r--r--ld/testsuite/ld-elf/non-contiguous.ld1
-rw-r--r--opcodes/ChangeLog12
-rw-r--r--opcodes/csky-dis.c44
-rw-r--r--opcodes/csky-opc.h4
41 files changed, 827 insertions, 101 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 51bfbda..6fa6ee0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,17 @@
+2020-08-28 Cooper Qu <cooper.qu@linux.alibaba.com>
+
+ * 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.
+
2020-08-28 Nick Clifton <nickc@redhat.com>
PR19011
diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c
index 7806ec7..80155cd 100644
--- a/bfd/elf32-csky.c
+++ b/bfd/elf32-csky.c
@@ -56,14 +56,15 @@ typedef struct csky_arch_for_merge
static struct csky_arch_for_merge csky_archs[] =
{
/* 510 and 610 merge to 610 without warning. */
- { "510", CSKY_ARCH_510, CSKY_V1, 0, 0},
- { "610", CSKY_ARCH_610, CSKY_V1, 1, 0},
+ { "ck510", CSKY_ARCH_510, CSKY_V1, 0, 0},
+ { "ck610", CSKY_ARCH_610, CSKY_V1, 1, 0},
/* 801, 802, 803, 807, 810 merge to largest one. */
- { "801", CSKY_ARCH_801, CSKY_V2, 0, 1},
- { "802", CSKY_ARCH_802, CSKY_V2, 1, 1},
- { "803", CSKY_ARCH_803, CSKY_V2, 2, 1},
- { "807", CSKY_ARCH_807, CSKY_V2, 3, 1},
- { "810", CSKY_ARCH_810, CSKY_V2, 4, 1},
+ { "ck801", CSKY_ARCH_801, CSKY_V2, 0, 1},
+ { "ck802", CSKY_ARCH_802, CSKY_V2, 1, 1},
+ { "ck803", CSKY_ARCH_803, CSKY_V2, 2, 1},
+ { "ck807", CSKY_ARCH_807, CSKY_V2, 3, 1},
+ { "ck810", CSKY_ARCH_810, CSKY_V2, 4, 1},
+ { "ck860", CSKY_ARCH_860, CSKY_V2, 5, 1},
{ NULL, 0, 0, 0, 0}
};
@@ -2802,6 +2803,199 @@ csky_find_arch_with_eflag (const unsigned long arch_eflag)
return csky_arch;
}
+static csky_arch_for_merge *
+csky_find_arch_with_name (const char *name)
+{
+ csky_arch_for_merge *csky_arch = NULL;
+ const char *msg;
+
+ if (name == NULL)
+ return NULL;
+
+ for (csky_arch = csky_archs; csky_arch->name != NULL; csky_arch++)
+ {
+ if (strncmp (csky_arch->name, name, strlen (csky_arch->name)) == 0)
+ break;
+ }
+ if (csky_arch == NULL)
+ {
+ msg = _("warning: unrecognised arch name '%#x'");
+ (*_bfd_error_handler) (msg, name);
+ bfd_set_error (bfd_error_wrong_format);
+ }
+ return csky_arch;
+}
+
+static bfd_boolean
+elf32_csky_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
+{
+ bfd *obfd = info->output_bfd;
+ obj_attribute *in_attr;
+ obj_attribute *out_attr;
+ obj_attribute tattr;
+ csky_arch_for_merge *old_arch = NULL;
+ csky_arch_for_merge *new_arch = NULL;
+ int i;
+ bfd_boolean result = TRUE;
+ const char *msg = NULL;
+
+ const char *sec_name = get_elf_backend_data (ibfd)->obj_attrs_section;
+
+ /* Skip the linker stubs file. This preserves previous behavior
+ of accepting unknown attributes in the first input file - but
+ is that a bug? */
+ if (ibfd->flags & BFD_LINKER_CREATED)
+ return TRUE;
+
+ /* Skip any input that hasn't attribute section.
+ This enables to link object files without attribute section with
+ any others. */
+ if (bfd_get_section_by_name (ibfd, sec_name) == NULL)
+ {
+ return TRUE;
+ }
+
+ if (!elf_known_obj_attributes_proc (obfd)[0].i)
+ {
+ /* This is the first object. Copy the attributes. */
+ out_attr = elf_known_obj_attributes_proc (obfd);
+
+ /* If Tag_CSKY_CPU_NAME is already set, save it. */
+ memcpy (&tattr, &out_attr[Tag_CSKY_ARCH_NAME], sizeof (tattr));
+
+ _bfd_elf_copy_obj_attributes (ibfd, obfd);
+
+ out_attr = elf_known_obj_attributes_proc (obfd);
+
+ /* Restore Tag_CSKY_CPU_NAME. */
+ memcpy (&out_attr[Tag_CSKY_ARCH_NAME], &tattr, sizeof (tattr));
+
+ /* Use the Tag_null value to indicate the attributes have been
+ initialized. */
+ out_attr[0].i = 1;
+ }
+
+ in_attr = elf_known_obj_attributes_proc (ibfd);
+ out_attr = elf_known_obj_attributes_proc (obfd);
+
+ for (i = LEAST_KNOWN_OBJ_ATTRIBUTE; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++)
+ {
+ /* Merge this attribute with existing attributes. */
+ switch (i)
+ {
+ case Tag_CSKY_CPU_NAME:
+ case Tag_CSKY_ARCH_NAME:
+ /* Do arch merge. */
+ new_arch = csky_find_arch_with_name (in_attr[Tag_CSKY_ARCH_NAME].s);
+ old_arch = csky_find_arch_with_name (out_attr[Tag_CSKY_ARCH_NAME].s);
+
+ if (new_arch != NULL && old_arch != NULL)
+ {
+ if (new_arch->class != old_arch->class)
+ {
+ msg = _("%pB: machine flag conflict with target");
+ (*_bfd_error_handler) (msg, ibfd);
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
+ else if (new_arch->class_level != old_arch->class_level)
+ {
+ csky_arch_for_merge *newest_arch =
+ ((new_arch->class_level > old_arch->class_level) ?
+ new_arch : old_arch);
+
+ if (new_arch->do_warning || old_arch->do_warning)
+ {
+ msg = _("warning: file %pB's arch flag %s conflict "
+ "with target %s,set target arch flag to %s");
+ (*_bfd_error_handler) (msg, ibfd, new_arch->name,
+ old_arch->name,
+ (newest_arch->name));
+ bfd_set_error (bfd_error_wrong_format);
+ }
+
+ if (out_attr[Tag_CSKY_ARCH_NAME].s != NULL)
+ bfd_release (obfd, out_attr[Tag_CSKY_ARCH_NAME].s);
+
+ out_attr[Tag_CSKY_ARCH_NAME].s =
+ _bfd_elf_attr_strdup (obfd, newest_arch->name);
+ }
+ }
+
+ break;
+
+ case Tag_CSKY_ISA_FLAGS:
+ case Tag_CSKY_ISA_EXT_FLAGS:
+ /* Do ISA merge. */
+ break;
+
+ case Tag_CSKY_VDSP_VERSION:
+ if (out_attr[i].i == 0)
+ out_attr[i].i = in_attr[i].i;
+ else if (out_attr[i].i != in_attr[i].i)
+ {
+ _bfd_error_handler
+ (_("Error: %pB and %pB has different VDSP version"), ibfd, obfd);
+ result = FALSE;
+ }
+ break;
+
+ case Tag_CSKY_FPU_VERSION:
+ if (out_attr[i].i <= in_attr[i].i
+ && out_attr[i].i == 0)
+ out_attr[i].i = in_attr[i].i;
+ break;
+
+ case Tag_CSKY_DSP_VERSION:
+ if (out_attr[i].i == 0)
+ out_attr[i].i = in_attr[i].i;
+ else if (out_attr[i].i != in_attr[i].i)
+ {
+ _bfd_error_handler
+ (_("Error: %pB and %pB has different DSP version"), ibfd, obfd);
+ result = FALSE;
+ }
+ break;
+
+ case Tag_CSKY_FPU_ABI:
+ if (out_attr[i].i != in_attr[i].i
+ && (out_attr[i].i == 0
+ || (out_attr[i].i == VAL_CSKY_FPU_ABI_SOFT
+ && in_attr[i].i == VAL_CSKY_FPU_ABI_SOFTFP)))
+ {
+ out_attr[i].i = in_attr[i].i;
+ }
+ else if (out_attr[i].i == VAL_CSKY_FPU_ABI_HARD
+ && (out_attr[i].i != in_attr[i].i
+ && in_attr[i].i != 0))
+ {
+ _bfd_error_handler
+ (_("Error: %pB and %pB has different FPU ABI"), ibfd, obfd);
+ result = FALSE;
+ }
+ break;
+
+ default:
+ result =
+ result && _bfd_elf_merge_unknown_attribute_low (ibfd, obfd, i);
+ break;
+ }
+
+ /* If out_attr was copied from in_attr then it won't have a type yet. */
+ if (in_attr[i].type && !out_attr[i].type)
+ out_attr[i].type = in_attr[i].type;
+ }
+
+ /* Merge Tag_compatibility attributes and any common GNU ones. */
+ if (!_bfd_elf_merge_object_attributes (ibfd, info))
+ return FALSE;
+
+ /* Check for any attributes not known on CSKY. */
+ result &= _bfd_elf_merge_unknown_attribute_list (ibfd, obfd);
+
+ return result;
+}
+
/* Merge backend specific data from an object file to the output
object file when linking. */
@@ -2813,6 +3007,9 @@ csky_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
flagword new_flags;
csky_arch_for_merge *old_arch = NULL;
csky_arch_for_merge *new_arch = NULL;
+ flagword newest_flag = 0;
+ const char *sec_name;
+ obj_attribute *out_attr;
/* Check if we have the same endianness. */
if (! _bfd_generic_verify_endian_match (ibfd, info))
@@ -2822,76 +3019,79 @@ csky_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
- new_flags = elf_elfheader (ibfd)->e_flags;
- old_flags = elf_elfheader (obfd)->e_flags;
+ /* Merge ".csky.attribute" section. */
+ if (!elf32_csky_merge_attributes (ibfd, info))
+ return FALSE;
if (! elf_flags_init (obfd))
{
/* First call, no flags set. */
elf_flags_init (obfd) = TRUE;
- elf_elfheader (obfd)->e_flags = new_flags;
}
- else if (new_flags == old_flags)
- /* Do nothing. */
- ;
- else if (new_flags == 0 || old_flags == 0)
- /* When one flag is 0, assign the other one's flag. */
- elf_elfheader (obfd)->e_flags = new_flags | old_flags;
- else
+
+ /* Try to merge e_flag. */
+ new_flags = elf_elfheader (ibfd)->e_flags;
+ old_flags = elf_elfheader (obfd)->e_flags;
+ out_attr = elf_known_obj_attributes_proc (obfd);
+
+ /* the flags like"e , f ,g ..." , we take collection. */
+ newest_flag = (old_flags & (~CSKY_ARCH_MASK))
+ | (new_flags & (~CSKY_ARCH_MASK));
+
+ sec_name = get_elf_backend_data (ibfd)->obj_attrs_section;
+ if (bfd_get_section_by_name (ibfd, sec_name) == NULL)
{
- flagword newest_flag = 0;
+ /* Input BFDs have no ".csky.attribute" section. */
+ new_arch = csky_find_arch_with_eflag (new_flags & CSKY_ARCH_MASK);
+ old_arch = csky_find_arch_with_name (out_attr[Tag_CSKY_ARCH_NAME].s);
- if ((new_flags & CSKY_ARCH_MASK) != 0
- && (old_flags & CSKY_ARCH_MASK) != 0)
+ if (new_arch != NULL && old_arch != NULL)
{
- new_arch = csky_find_arch_with_eflag (new_flags & CSKY_ARCH_MASK);
- old_arch = csky_find_arch_with_eflag (old_flags & CSKY_ARCH_MASK);
- /* Collect flags like e, f, g. */
- newest_flag = (old_flags & (~CSKY_ARCH_MASK))
- | (new_flags & (~CSKY_ARCH_MASK));
- if (new_arch != NULL && old_arch != NULL)
+ if (new_arch->class != old_arch->class)
{
- if (new_arch->class != old_arch->class)
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB: machine flag conflict with target"), ibfd);
+ bfd_set_error (bfd_error_wrong_format);
+ return FALSE;
+ }
+ else if (new_arch->class_level != old_arch->class_level)
+ {
+ csky_arch_for_merge *newest_arch =
+ (new_arch->class_level > old_arch->class_level
+ ? new_arch : old_arch);
+
+ if (new_arch->do_warning || old_arch->do_warning)
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%pB: machine flag conflict with target"), ibfd);
+ (_("warning: file %pB's arch flag %s conflicts with "
+ "target ck%s, using %s"),
+ ibfd, new_arch->name, old_arch->name,
+ newest_arch->name);
bfd_set_error (bfd_error_wrong_format);
- return FALSE;
}
- else if (new_arch->class_level != old_arch->class_level)
- {
- csky_arch_for_merge *newest_arch
- = (new_arch->class_level > old_arch->class_level
- ? new_arch : old_arch);
- if (new_arch->do_warning || old_arch->do_warning)
- {
- _bfd_error_handler
- /* xgettext:c-format */
- (_("warning: file %pB's arch flag ck%s conflicts with "
- "target ck%s, using ck%s"),
- ibfd, new_arch->name, old_arch->name,
- newest_arch->name);
- bfd_set_error (bfd_error_wrong_format);
- }
- newest_flag |= newest_arch->arch_eflag;
- }
- else
- newest_flag |= ((new_flags & (CSKY_ARCH_MASK | CSKY_ABI_MASK))
- | (old_flags
- & (CSKY_ARCH_MASK | CSKY_ABI_MASK)));
+ if (out_attr[Tag_CSKY_ARCH_NAME].s != NULL)
+ bfd_release (obfd, out_attr[Tag_CSKY_ARCH_NAME].s);
+
+ out_attr[Tag_CSKY_ARCH_NAME].s =
+ _bfd_elf_attr_strdup (obfd, newest_arch->name);
}
else
newest_flag |= ((new_flags & (CSKY_ARCH_MASK | CSKY_ABI_MASK))
| (old_flags & (CSKY_ARCH_MASK | CSKY_ABI_MASK)));
}
else
- newest_flag |= ((new_flags & (CSKY_ARCH_MASK | CSKY_ABI_MASK))
- | (old_flags & (CSKY_ARCH_MASK | CSKY_ABI_MASK)));
-
- elf_elfheader (obfd)->e_flags = newest_flag;
+ {
+ if (new_arch && new_arch->name != NULL)
+ out_attr[Tag_CSKY_ARCH_NAME].s =
+ _bfd_elf_attr_strdup (obfd, new_arch->name);
+ }
}
+
+ elf_elfheader (obfd)->e_flags = newest_flag;
+
return TRUE;
}
@@ -5035,6 +5235,47 @@ csky_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
return TRUE;
}
+/* Determine whether an object attribute tag takes an integer, a
+ string or both. */
+
+static int
+elf32_csky_obj_attrs_arg_type (int tag)
+{
+ switch (tag)
+ {
+ case Tag_compatibility:
+ return ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL;
+ case Tag_CSKY_ARCH_NAME:
+ case Tag_CSKY_CPU_NAME:
+ case Tag_CSKY_FPU_NUMBER_MODULE:
+ return ATTR_TYPE_FLAG_STR_VAL;
+ case Tag_CSKY_ISA_FLAGS:
+ case Tag_CSKY_ISA_EXT_FLAGS:
+ case Tag_CSKY_DSP_VERSION:
+ case Tag_CSKY_VDSP_VERSION:
+ case Tag_CSKY_FPU_VERSION:
+ case Tag_CSKY_FPU_ABI:
+ case Tag_CSKY_FPU_ROUNDING:
+ case Tag_CSKY_FPU_HARDFP:
+ case Tag_CSKY_FPU_Exception:
+ case Tag_CSKY_FPU_DENORMAL:
+ return ATTR_TYPE_FLAG_INT_VAL;
+ default:
+ break;
+ }
+
+ return (tag & 1) != 0 ? ATTR_TYPE_FLAG_STR_VAL : ATTR_TYPE_FLAG_INT_VAL;
+}
+
+/* Attribute numbers >=64 (mod 128) can be safely ignored. */
+
+static bfd_boolean
+elf32_csky_obj_attrs_handle_unknown (bfd *abfd ATTRIBUTE_UNUSED,
+ int tag ATTRIBUTE_UNUSED)
+{
+ return TRUE;
+}
+
/* End of external entry points for sizing and building linker stubs. */
/* CPU-related basic API. */
@@ -5088,4 +5329,15 @@ csky_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
#define elf_backend_grok_prstatus csky_elf_grok_prstatus
#define elf_backend_grok_psinfo csky_elf_grok_psinfo
+/* Attribute sections. */
+#undef elf_backend_obj_attrs_vendor
+#define elf_backend_obj_attrs_vendor "csky"
+#undef elf_backend_obj_attrs_section
+#define elf_backend_obj_attrs_section ".csky.attributes"
+#undef elf_backend_obj_attrs_arg_type
+#define elf_backend_obj_attrs_arg_type elf32_csky_obj_attrs_arg_type
+#undef elf_backend_obj_attrs_section_type
+#define elf_backend_obj_attrs_section_type SHT_CSKY_ATTRIBUTES
+#define elf_backend_obj_attrs_handle_unknown elf32_csky_obj_attrs_handle_unknown
+
#include "elf32-target.h"
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
diff --git a/elfcpp/ChangeLog b/elfcpp/ChangeLog
index efb82c5..e65f69b 100644
--- a/elfcpp/ChangeLog
+++ b/elfcpp/ChangeLog
@@ -1,3 +1,7 @@
+2020-08-26 Cooper Qu <cooper.qu@linux.alibaba.com>
+
+ * elfcpp.h (enum SHT): New enum SHT_CSKY_ATTRIBUTES.
+
2020-07-04 Nick Clifton <nickc@redhat.com>
Binutils 2.35 branch created.
diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index 9c7c629..65d803c 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -413,6 +413,10 @@ enum SHT
// AARCH64-specific section type.
SHT_AARCH64_ATTRIBUTES = 0x70000003,
+ // CSKY-specific section types.
+ // Object file compatibility attributes.
+ SHT_CSKY_ATTRIBUTES = 0x70000001,
+
// Link editor is to sort the entries in this section based on the
// address specified in the associated symbol table entry.
SHT_ORDERED = 0x7fffffff
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 92dd978..8d3a92f 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,32 @@
+2020-08-28 Cooper Qu <cooper.qu@linux.alibaba.com>
+
+ * 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.
+
2020-08-27 Alan Modra <amodra@gmail.com>
PR 26467
diff --git a/gas/config/tc-csky.c b/gas/config/tc-csky.c
index f621fa9..9f2975e 100644
--- a/gas/config/tc-csky.c
+++ b/gas/config/tc-csky.c
@@ -212,7 +212,7 @@ enum
unsigned int mach_flag = 0;
unsigned int arch_flag = 0;
unsigned int other_flag = 0;
-unsigned int isa_flag = 0;
+BFD_HOST_U_64_BIT isa_flag = 0;
unsigned int dsp_flag = 0;
typedef struct stack_size_entry
@@ -233,7 +233,7 @@ struct csky_cpu_info
{
const char *name;
unsigned int mach_flag;
- unsigned int isa_flag;
+ BFD_HOST_U_64_BIT isa_flag;
};
typedef enum
@@ -249,7 +249,7 @@ struct csky_macro_info
const char *name;
/* How many operands : if operands == 5, all of 1,2,3,4 are ok. */
long oprnd_num;
- int isa_flag;
+ BFD_HOST_U_64_BIT isa_flag;
/* Do the work. */
void (*handle_func)(void);
};
@@ -1186,6 +1186,78 @@ md_show_usage (FILE *fp)
-mvdsp enable vector DSP instructions\n"));
}
+static void set_csky_attribute (void)
+{
+ if (mach_flag & CSKY_ARCH_DSP)
+ {
+ if (dsp_flag & CSKY_DSP_FLAG_V2)
+ {
+ /* Set DSPV2. */
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_DSP_VERSION,
+ VAL_CSKY_DSP_VERSION_2);
+ }
+ else if (isa_flag & CSKY_ISA_DSP)
+ {
+ /* Set DSP extension. */
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_DSP_VERSION,
+ VAL_CSKY_DSP_VERSION_EXTENSION);
+ }
+ /* Set VDSP attribute. */
+ if (isa_flag & CSKY_ISA_VDSP)
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_VDSP_VERSION,
+ VAL_CSKY_VDSP_VERSION_1);
+
+ else if (isa_flag & CSKY_ISA_VDSP_2)
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_VDSP_VERSION,
+ VAL_CSKY_VDSP_VERSION_2);
+
+ }
+
+ if (mach_flag & CSKY_ARCH_FLOAT)
+ {
+ unsigned int val = VAL_CSKY_FPU_HARDFP_SINGLE;
+ if (IS_CSKY_ARCH_V1 (mach_flag)) {
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_FPU_VERSION,
+ VAL_CSKY_FPU_VERSION_1);
+ }
+ else
+ {
+ if (isa_flag & CSKY_ISA_FLOAT_3E4)
+ {
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_FPU_VERSION,
+ VAL_CSKY_FPU_VERSION_2);
+ val |= VAL_CSKY_FPU_HARDFP_DOUBLE;
+ }
+ else
+ {
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_FPU_VERSION,
+ VAL_CSKY_FPU_VERSION_2);
+ }
+
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_FPU_HARDFP,
+ val);
+ bfd_elf_add_obj_attr_string (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_FPU_NUMBER_MODULE,
+ "IEEE 754");
+ }
+ }
+
+
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_ISA_FLAGS, isa_flag);
+
+ bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_ISA_EXT_FLAGS, (isa_flag >> 32));
+}
+
/* Target-specific initialization and option handling. */
void
@@ -1263,6 +1335,8 @@ md_begin (void)
for (p_arch = csky_archs; p_arch->arch_flag != 0; p_arch++)
if ((mach_flag & CSKY_ARCH_MASK) == (p_arch->arch_flag & CSKY_ARCH_MASK))
{
+ bfd_elf_add_obj_attr_string (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_ARCH_NAME, p_arch->name);
bfd_mach_flag = p_arch->bfd_mach_flag;
break;
}
@@ -1271,6 +1345,8 @@ md_begin (void)
for (p_cpu = csky_cpus; p_cpu->mach_flag != 0; p_cpu++)
if ((mach_flag & CPU_ARCH_MASK) == p_cpu->mach_flag)
{
+ bfd_elf_add_obj_attr_string (stdoutput, OBJ_ATTR_PROC,
+ Tag_CSKY_CPU_NAME, p_cpu->name);
isa_flag |= p_cpu->isa_flag;
break;
}
@@ -1298,6 +1374,7 @@ md_begin (void)
{
/* In 803, dspv1 is conflict with dspv2. We keep dspv2. */
as_warn ("option -mdsp conflicts with -medsp, only enabling -medsp");
+ dsp_flag &= ~CSKY_DSP_FLAG_V1;
isa_flag &= ~(CSKY_ISA_MAC_DSP | CSKY_ISA_DSP);
isa_flag |= CSKY_ISA_DSP_ENHANCE;
}
@@ -1306,6 +1383,7 @@ md_begin (void)
{
if (dsp_flag & CSKY_DSP_FLAG_V2)
{
+ dsp_flag &= ~CSKY_DSP_FLAG_V2;
isa_flag &= ~CSKY_ISA_DSP_ENHANCE;
as_warn ("-medsp option is only supported by ck803s, ignoring -medsp");
}
@@ -1370,7 +1448,7 @@ md_begin (void)
else
do_intr_stack = 1;
}
- /* TODO: add isa_flag(SIMP/CACHE/APS). */
+ /* Add isa_flag(SIMP/CACHE/APS). */
isa_flag |= (mach_flag & CSKY_ARCH_MAC) ? CSKY_ISA_MAC : 0;
isa_flag |= (mach_flag & CSKY_ARCH_MP) ? CSKY_ISA_MP : 0;
isa_flag |= (mach_flag & CSKY_ARCH_CP) ? CSKY_ISA_CP : 0;
@@ -1418,9 +1496,11 @@ md_begin (void)
str_hash_insert (csky_macros_hash,
v2_lrw_macro_opcode.name, &v2_lrw_macro_opcode, 0);
/* Set e_flag to ELF Head. */
- bfd_set_private_flags (stdoutput, mach_flag);
+ bfd_set_private_flags (stdoutput, mach_flag & ~(0xffff));
/* Set bfd_mach to bfd backend data. */
bfd_set_arch_mach (stdoutput, bfd_arch_csky, bfd_mach_flag);
+
+ set_csky_attribute ();
}
/* The C-SKY assembler emits mapping symbols $t and $d to mark the
diff --git a/gas/testsuite/gas/csky/802j.d b/gas/testsuite/gas/csky/802j.d
index af7c857..c75666b 100644
--- a/gas/testsuite/gas/csky/802j.d
+++ b/gas/testsuite/gas/csky/802j.d
@@ -11,3 +11,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*1460\s*nie
\s*[0-9a-f]*:\s*1461\s*nir
\s*[0-9a-f]*:\s*3ae0\s*jmpix\s*r2,\s*16.*
+#...
diff --git a/gas/testsuite/gas/csky/all.d b/gas/testsuite/gas/csky/all.d
index c5da5b0..606bcc0 100644
--- a/gas/testsuite/gas/csky/all.d
+++ b/gas/testsuite/gas/csky/all.d
@@ -148,3 +148,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*1e37\s*or\s*r7, r7, r3
\s*[0-9a-f]*:\s*1715\s*xor\s*r5, r5, r1
\s*[0-9a-f]*:\s*1726\s*xor\s*r6, r6, r2
+#...
diff --git a/gas/testsuite/gas/csky/bsr1.d b/gas/testsuite/gas/csky/bsr1.d
index 91ba60d..69bef88 100644
--- a/gas/testsuite/gas/csky/bsr1.d
+++ b/gas/testsuite/gas/csky/bsr1.d
@@ -10,3 +10,4 @@ Disassembly of section \.text:
\s*[0-9a-f]:\s*f7fe\s*br\s*0x0\s*\/\/\s*0\s*\<lable*\>
\s*[0-9a-f]:\s*e7fd\s*bt\s*0x0\s*\/\/\s*0\s*\<lable*\>
\s*[0-9a-f]:\s*effc\s*bf\s*0x0\s*\/\/\s*0\s*\<lable*\>
+#...
diff --git a/gas/testsuite/gas/csky/csky_vdsp.d b/gas/testsuite/gas/csky/csky_vdsp.d
index 0e2eaa2..3af4413 100644
--- a/gas/testsuite/gas/csky/csky_vdsp.d
+++ b/gas/testsuite/gas/csky/csky_vdsp.d
@@ -362,3 +362,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*f8830fa2\s*vicl\.8\s*vr2,\s*vr3,\s*vr4
\s*[0-9a-f]*:\s*f8930fa2\s*vicl\.16\s*vr2,\s*vr3,\s*vr4
\s*[0-9a-f]*:\s*fa830fa2\s*vicl\.32\s*vr2,\s*vr3,\s*vr4
+#...
diff --git a/gas/testsuite/gas/csky/cskyv2_all.d b/gas/testsuite/gas/csky/cskyv2_all.d
index 5092690..bb688ec 100644
--- a/gas/testsuite/gas/csky/cskyv2_all.d
+++ b/gas/testsuite/gas/csky/cskyv2_all.d
@@ -323,3 +323,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*cc480000\s*lrs\.w\s*r2,\s*\[0x0\].*
\s*[0-9a-f]*:\s*ec430002\s*ori\s*r2,\s*r3,\s*2
\s*[0-9a-f]*:\s*ec43000a\s*ori\s*r2,\s*r3,\s*10
+#...
diff --git a/gas/testsuite/gas/csky/cskyv2_ck803r2.d b/gas/testsuite/gas/csky/cskyv2_ck803r2.d
index 298022a..8ef9e90 100644
--- a/gas/testsuite/gas/csky/cskyv2_ck803r2.d
+++ b/gas/testsuite/gas/csky/cskyv2_ck803r2.d
@@ -10,3 +10,4 @@ Disassembly of section \.text:
#...
\s*[0-9a-f]*:\s*6c03\s*mov\s*r0,\s*r0
\s*[0-9a-f]*:\s*e820fffd\s*bnezad\s*r0,\s*0.*
+#...
diff --git a/gas/testsuite/gas/csky/cskyv2_ck860.d b/gas/testsuite/gas/csky/cskyv2_ck860.d
index 2beb884..639bdbf 100644
--- a/gas/testsuite/gas/csky/cskyv2_ck860.d
+++ b/gas/testsuite/gas/csky/cskyv2_ck860.d
@@ -38,4 +38,5 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*c2000420\s*sync.s
\s*[0-9a-f]*:\s*c0000420\s*sync
\s*[0-9a-f]*:\s*d8437000\s*ldex.w\s*r2,\s*\(r3,\s*0x0\)
-\s*[0-9a-f]*:\s*dc437000\s*stex.w\s*r2,\s*\(r3,\s*0x0\) \ No newline at end of file
+\s*[0-9a-f]*:\s*dc437000\s*stex.w\s*r2,\s*\(r3,\s*0x0\)
+#...
diff --git a/gas/testsuite/gas/csky/cskyv2_dsp.d b/gas/testsuite/gas/csky/cskyv2_dsp.d
index f2e3d33..3bc52fe 100644
--- a/gas/testsuite/gas/csky/cskyv2_dsp.d
+++ b/gas/testsuite/gas/csky/cskyv2_dsp.d
@@ -1,4 +1,4 @@
-# name: csky - all
+# name: csky - dsp
#as: -mcpu=ck810e -W
#objdump: -D
@@ -16,3 +16,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*c4319080\s*mulshs\s*r17,\s*r1
\s*[0-9a-f]*:\s*c6ec9440\s*mulswa\s*r12,\s*r23
\s*[0-9a-f]*:\s*c4a39480\s*mulsws\s*r3,\s*r5
+#...
diff --git a/gas/testsuite/gas/csky/cskyv2_elrw.d b/gas/testsuite/gas/csky/cskyv2_elrw.d
index 5a52d5a..d0acefb 100644
--- a/gas/testsuite/gas/csky/cskyv2_elrw.d
+++ b/gas/testsuite/gas/csky/cskyv2_elrw.d
@@ -8,3 +8,4 @@
#...
\s*[0-9a-f]*:\s*c0004020\s*rte
\s*[0-9a-f]*:\s*00001234\s*\.long\s*0x00001234
+#...
diff --git a/gas/testsuite/gas/csky/cskyv2_float.d b/gas/testsuite/gas/csky/cskyv2_float.d
index f1039c9..b1ed9cb 100644
--- a/gas/testsuite/gas/csky/cskyv2_float.d
+++ b/gas/testsuite/gas/csky/cskyv2_float.d
@@ -57,3 +57,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*f4041aab\s*fuitod\s*fr11,\s*fr4
\s*[0-9a-f]*:\s*f4081ac2\s*fdtos\s*fr2,\s*fr8
\s*[0-9a-f]*:\s*f40b1ae5\s*fstod\s*fr5,\s*fr11
+#...
diff --git a/gas/testsuite/gas/csky/enhance_dsp.d b/gas/testsuite/gas/csky/enhance_dsp.d
index 96d26ab..17b33ea 100644
--- a/gas/testsuite/gas/csky/enhance_dsp.d
+++ b/gas/testsuite/gas/csky/enhance_dsp.d
@@ -216,3 +216,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*f8838ce2\s*mulsca\.s16\.e\s*r2,\s*r3,\s*r4
\s*[0-9a-f]*:\s*f8838ce2\s*mulsca\.s16\.e\s*r2,\s*r3,\s*r4
\s*[0-9a-f]*:\s*f8838442\s*mula\.32\.l\s*r2,\s*r3,\s*r4
+#...
diff --git a/gas/testsuite/gas/csky/java.d b/gas/testsuite/gas/csky/java.d
index f433d52..c0791bf 100644
--- a/gas/testsuite/gas/csky/java.d
+++ b/gas/testsuite/gas/csky/java.d
@@ -10,3 +10,4 @@ Disassembly of section \.text:
\s*[0-9a-f]:\s*14ae\s*bpop\.w\s*r3
\s*[0-9a-f]:\s*14ec\s*bpush\.h\s*r3
\s*[0-9a-f]:\s*14ee\s*bpush\.w\s*r3
+#...
diff --git a/gas/testsuite/gas/csky/v1_float.d b/gas/testsuite/gas/csky/v1_float.d
index 995a77d..4c08897 100644
--- a/gas/testsuite/gas/csky/v1_float.d
+++ b/gas/testsuite/gas/csky/v1_float.d
@@ -220,3 +220,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*ffe08002\s*\.long\s*0xffe08002
\s*[0-9a-f]*:\s*ffe20002\s*\.long\s*0xffe20002
\s*[0-9a-f]*:\s*ffe18002\s*\.long\s*0xffe18002
+#...
diff --git a/gas/testsuite/gas/csky/v2_float_part1.d b/gas/testsuite/gas/csky/v2_float_part1.d
index aa0b0a4..c3f5d56 100644
--- a/gas/testsuite/gas/csky/v2_float_part1.d
+++ b/gas/testsuite/gas/csky/v2_float_part1.d
@@ -52,3 +52,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*f4830202\s*fmuls\s*fr2,\s*fr3,\s*fr4
\s*[0-9a-f]*:\s*f4830022\s*fsubs\s*fr2,\s*fr3,\s*fr4
\s*[0-9a-f]*:\s*f4830002\s*fadds\s*fr2,\s*fr3,\s*fr4
+#...
diff --git a/gas/testsuite/gas/csky/v2_float_part2.d b/gas/testsuite/gas/csky/v2_float_part2.d
index 94b04e0..78fa37b 100644
--- a/gas/testsuite/gas/csky/v2_float_part2.d
+++ b/gas/testsuite/gas/csky/v2_float_part2.d
@@ -18,3 +18,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*4048f5c3\s*\.long\s*0x4048f5c3
\s*[0-9a-f]*:\s*51eb851f\s*\.long\s*0x51eb851f
\s*[0-9a-f]*:\s*40091eb8\s*\.long\s*0x40091eb8
+#...
diff --git a/gas/testsuite/gas/csky/v2_tls_gd.d b/gas/testsuite/gas/csky/v2_tls_gd.d
index 226beaa..6680d6e 100644
--- a/gas/testsuite/gas/csky/v2_tls_gd.d
+++ b/gas/testsuite/gas/csky/v2_tls_gd.d
@@ -8,3 +8,4 @@ Disassembly of section \.text:
#...
\s*[0-9a-f]*:\s*R_CKCORE_TLS_GD32\s*xxx.*
\s*[0-9a-f]*:\s*R_CKCORE_PLT32\s*__tls_get_addr
+#...
diff --git a/gas/testsuite/gas/csky/v2_tls_ie.d b/gas/testsuite/gas/csky/v2_tls_ie.d
index db77387..d55d1ce 100644
--- a/gas/testsuite/gas/csky/v2_tls_ie.d
+++ b/gas/testsuite/gas/csky/v2_tls_ie.d
@@ -7,3 +7,4 @@
Disassembly of section \.text:
#...
\s*[0-9a-f]*:\s*R_CKCORE_TLS_IE32\s*xxx.*
+#...
diff --git a/gas/testsuite/gas/csky/v2_tls_ld.d b/gas/testsuite/gas/csky/v2_tls_ld.d
index 9f12ace..4843a41 100644
--- a/gas/testsuite/gas/csky/v2_tls_ld.d
+++ b/gas/testsuite/gas/csky/v2_tls_ld.d
@@ -9,3 +9,4 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*R_CKCORE_TLS_LDM32\s*xxx.*
\s*[0-9a-f]*:\s*R_CKCORE_PLT32\s*__tls_get_addr
\s*[0-9a-f]*:\s*R_CKCORE_TLS_LDO32\s*xxx
+#...
diff --git a/gas/testsuite/gas/csky/v2_tls_le.d b/gas/testsuite/gas/csky/v2_tls_le.d
index c34d6d7..e4ab536 100644
--- a/gas/testsuite/gas/csky/v2_tls_le.d
+++ b/gas/testsuite/gas/csky/v2_tls_le.d
@@ -1,4 +1,4 @@
-# name: csky - v2 TLS IE
+# name: csky - v2 TLS LE
#as: -mcpu=ck810 -W
#objdump: -Dr
@@ -7,3 +7,4 @@
Disassembly of section \.text:
#...
\s*[0-9a-f]*:\s*R_CKCORE_TLS_LE32\s*xxx
+#...
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 2f9893b..8520421 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -65,6 +65,9 @@ if { [is_elf_format] } then {
if {[istarget "avr*-*-*"]} {
set dump_opts {{as -mno-link-relax}}
}
+ if {[istarget "csky*-*-*"]} {
+ set target_machine -csky
+ }
if {[istarget "m32r*-*-*"]} then {
set target_machine -m32r
}
diff --git a/gas/testsuite/gas/elf/section2.e-csky b/gas/testsuite/gas/elf/section2.e-csky
new file mode 100644
index 0000000..115bae2
--- /dev/null
+++ b/gas/testsuite/gas/elf/section2.e-csky
@@ -0,0 +1,9 @@
+
+Symbol table '.symtab' contains 6 entries:
+ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name
+ +0: 0+0 +0 +NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+0 +0 +SECTION +LOCAL +DEFAULT +1
+ +2: 0+0 +0 +SECTION +LOCAL +DEFAULT +2
+ +3: 0+0 +0 +SECTION +LOCAL +DEFAULT +3
+ +4: 0+0 +0 +SECTION +LOCAL +DEFAULT +4
+ +5: 0+0 +0 +SECTION +LOCAL +DEFAULT +5
diff --git a/include/ChangeLog b/include/ChangeLog
index c53e405..4da03f8 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,57 @@
+2020-08-28 Cooper Qu <cooper.qu@linux.alibaba.com>
+
+ * 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.
+
2020-08-27 Nick Alcock <nick.alcock@oracle.com>
* ctf-api.h (ctf_errwarning_next): New err parameter.
diff --git a/include/elf/csky.h b/include/elf/csky.h
index a057139..cbce6c0 100644
--- a/include/elf/csky.h
+++ b/include/elf/csky.h
@@ -94,4 +94,79 @@ START_RELOC_NUMBERS (elf_csky_reloc_type)
RELOC_NUMBER (R_CKCORE_PCREL_BLOOP_IMM12BY4, 64)
END_RELOC_NUMBERS (R_CKCORE_MAX)
+/* Additional section types. */
+#define SHT_CSKY_ATTRIBUTES 0x70000001 /* Section holds attributes. */
+
+/* Object attribute tags. */
+enum
+{
+ /* 0-3 are generic. */
+ /* Arch name for this object file. */
+ Tag_CSKY_ARCH_NAME = 4,
+ Tag_CSKY_CPU_NAME = 5,
+
+ /* ISA flags for this object file. */
+ Tag_CSKY_ISA_FLAGS,
+ Tag_CSKY_ISA_EXT_FLAGS,
+
+ /* CSKY DSP version used by this object file. */
+ Tag_CSKY_DSP_VERSION,
+
+ /* CSKY VDSP version used by this object file. */
+ Tag_CSKY_VDSP_VERSION,
+
+ /* CSKY FPU version used by this object file. */
+ Tag_CSKY_FPU_VERSION = 0x10,
+ /* FPU ABI. params: Soft GR/Hard GR/Hard FR. */
+ Tag_CSKY_FPU_ABI,
+ /* Rounding Support. */
+ Tag_CSKY_FPU_ROUNDING,
+ /* Denormal Support. */
+ Tag_CSKY_FPU_DENORMAL,
+ /* Exeception Support. */
+ Tag_CSKY_FPU_Exception,
+ /* Number Module Support("IEEE 754"). */
+ Tag_CSKY_FPU_NUMBER_MODULE,
+ /* Half/Single/Double. */
+ Tag_CSKY_FPU_HARDFP,
+
+ Tag_CSKY_MAX,
+};
+
+/* Object attribute values. */
+enum
+{
+ /* Values defined for Tag_CSKY_DSP_VERSION. */
+ VAL_CSKY_DSP_VERSION_EXTENSION = 1, /* hi-lo DSP extension. */
+ VAL_CSKY_DSP_VERSION_2 = 2, /* CK803s EDSP. */
+};
+
+enum
+{
+ /* Values defined for Tag_CSKY_VDSP_VERSION. */
+ VAL_CSKY_VDSP_VERSION_1 = 1, /* VDSP version 1. */
+ VAL_CSKY_VDSP_VERSION_2 /* VDSP version 1. */
+};
+
+enum
+{
+ /* Values defined for Tag_CSKY_FPU_VERSION. */
+ VAL_CSKY_FPU_VERSION_1 = 1, /* ABIV1 FPU. */
+ VAL_CSKY_FPU_VERSION_2, /* ABIV2 FPU. */
+};
+
+enum
+{
+ VAL_CSKY_FPU_ABI_SOFT = 1,
+ VAL_CSKY_FPU_ABI_SOFTFP,
+ VAL_CSKY_FPU_ABI_HARD,
+};
+
+enum
+{
+ VAL_CSKY_FPU_HARDFP_HALF = 1,
+ VAL_CSKY_FPU_HARDFP_SINGLE = 2,
+ VAL_CSKY_FPU_HARDFP_DOUBLE = 4,
+};
+
#endif /* _ELF_CSKY_H */
diff --git a/include/opcode/csky.h b/include/opcode/csky.h
index 098bdc9..493e822 100644
--- a/include/opcode/csky.h
+++ b/include/opcode/csky.h
@@ -22,41 +22,42 @@
#include "dis-asm.h"
/* The following bitmasks control instruction set architecture. */
-#define CSKYV1_ISA_E1 (1 << 0)
-#define CSKYV2_ISA_E1 (1 << 1)
-#define CSKYV2_ISA_1E2 (1 << 2)
-#define CSKYV2_ISA_2E3 (1 << 3)
-#define CSKYV2_ISA_3E7 (1 << 4)
-#define CSKYV2_ISA_7E10 (1 << 5)
-#define CSKYV2_ISA_3E3R1 (1 << 6)
-#define CSKYV2_ISA_3E3R2 (1 << 7)
-#define CSKYV2_ISA_10E60 (1 << 8)
-
-#define CSKY_ISA_TRUST (1 << 11)
-#define CSKY_ISA_CACHE (1 << 12)
-#define CSKY_ISA_NVIC (1 << 13)
-#define CSKY_ISA_CP (1 << 14)
-#define CSKY_ISA_MP (1 << 15)
-#define CSKY_ISA_MP_1E2 (1 << 16)
-#define CSKY_ISA_JAVA (1 << 17)
-#define CSKY_ISA_MAC (1 << 18)
-#define CSKY_ISA_MAC_DSP (1 << 19)
+#define CSKYV1_ISA_E1 (1L << 0)
+#define CSKYV2_ISA_E1 (1L << 1)
+#define CSKYV2_ISA_1E2 (1L << 2)
+#define CSKYV2_ISA_2E3 (1L << 3)
+#define CSKYV2_ISA_3E7 (1L << 4)
+#define CSKYV2_ISA_7E10 (1L << 5)
+#define CSKYV2_ISA_3E3R1 (1L << 6)
+#define CSKYV2_ISA_3E3R2 (1L << 7)
+#define CSKYV2_ISA_10E60 (1L << 8)
+
+#define CSKY_ISA_TRUST (1L << 11)
+#define CSKY_ISA_CACHE (1L << 12)
+#define CSKY_ISA_NVIC (1L << 13)
+#define CSKY_ISA_CP (1L << 14)
+#define CSKY_ISA_MP (1L << 15)
+#define CSKY_ISA_MP_1E2 (1L << 16)
+#define CSKY_ISA_JAVA (1L << 17)
+#define CSKY_ISA_MAC (1L << 18)
+#define CSKY_ISA_MAC_DSP (1L << 19)
/* Base ISA for csky v1 and v2. */
-#define CSKY_ISA_DSP (1 << 20)
-#define CSKY_ISA_DSP_1E2 (1 << 21)
-#define CSKY_ISA_DSP_ENHANCE (1 << 22)
+#define CSKY_ISA_DSP (1L << 20)
+#define CSKY_ISA_DSP_1E2 (1L << 21)
+#define CSKY_ISA_DSP_ENHANCE (1L << 22)
/* Base float instruction (803f & 810f). */
-#define CSKY_ISA_FLOAT_E1 (1 << 25)
+#define CSKY_ISA_FLOAT_E1 (1L << 25)
/* M_FLOAT support (810f). */
-#define CSKY_ISA_FLOAT_1E2 (1 << 26)
+#define CSKY_ISA_FLOAT_1E2 (1L << 26)
/* 803 support (803f). */
-#define CSKY_ISA_FLOAT_1E3 (1 << 27)
+#define CSKY_ISA_FLOAT_1E3 (1L << 27)
/* 807 support (803f & 807f). */
-#define CSKY_ISA_FLOAT_3E4 (1 << 28)
+#define CSKY_ISA_FLOAT_3E4 (1L << 28)
/* Vector DSP support. */
-#define CSKY_ISA_VDSP (1 << 29)
+#define CSKY_ISA_VDSP (1L << 29)
+#define CSKY_ISA_VDSP_2 (1L << 30)
/* The following bitmasks control cpu architecture for CSKY. */
#define CSKY_ABI_V1 (1 << 28)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 568e221..16274e8 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2020-08-28 Cooper Qu <cooper.qu@linux.alibaba.com>
+
+ * 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.
+
2020-08-28 Nick Clifton <nickc@redhat.com>
PR 19011
diff --git a/ld/emulparams/cskyelf.sh b/ld/emulparams/cskyelf.sh
index d572ac8..b940c6c 100644
--- a/ld/emulparams/cskyelf.sh
+++ b/ld/emulparams/cskyelf.sh
@@ -10,6 +10,7 @@ MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
TEXT_START_ADDR=0x8000
CHECK_RELOCS_AFTER_OPEN_INPUT=yes
NONPAGED_TEXT_START_ADDR=0
+ATTRS_SECTIONS='.csky.attributes 0 : { KEEP (*(.csky.attributes)) KEEP (*(.csky.attributes)) }'
ARCH=csky
EMBEDDED=yes
EXTRA_EM_FILE=cskyelf
diff --git a/ld/testsuite/ld-csky/tls-le-v1.d b/ld/testsuite/ld-csky/tls-le-v1.d
index 034d5d9..d13c403 100644
--- a/ld/testsuite/ld-csky/tls-le-v1.d
+++ b/ld/testsuite/ld-csky/tls-le-v1.d
@@ -12,3 +12,5 @@ Idx Name Size VMA LMA File off Algn
.*
1 .tbss .*
.*
+ 2 .csky.attributes .*
+ .*
diff --git a/ld/testsuite/ld-csky/tls-le.d b/ld/testsuite/ld-csky/tls-le.d
index 8a0d90f..0a241b3 100644
--- a/ld/testsuite/ld-csky/tls-le.d
+++ b/ld/testsuite/ld-csky/tls-le.d
@@ -11,3 +11,5 @@ Idx Name Size VMA LMA File off Algn
.*
1 .tbss .*
.*
+ 2 .csky.attributes .*
+ .*
diff --git a/ld/testsuite/ld-elf/non-contiguous.ld b/ld/testsuite/ld-elf/non-contiguous.ld
index fc72253..cfd3f24 100644
--- a/ld/testsuite/ld-elf/non-contiguous.ld
+++ b/ld/testsuite/ld-elf/non-contiguous.ld
@@ -23,6 +23,7 @@ SECTIONS
*(.note.renesas)
*(.MIPS.abiflags)
*(.MSP430.attributes)
+ *(.csky.attributes)
*(.gnu.attributes)
}
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 9bf8562..71826bd 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,15 @@
+2020-08-28 Cooper Qu <cooper.qu@linux.alibaba.com>
+
+ * 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.
+
2020-08-26 Jose E. Marchesi <jemarch@gnu.org>
* disassemble.c (enum epbf_isa_attr): Add ISA_XBPFBE, ISA_EBPFMAX.
diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
index 537725b..6becad0 100644
--- a/opcodes/csky-dis.c
+++ b/opcodes/csky-dis.c
@@ -23,6 +23,7 @@
#include "config.h"
#include <stdio.h>
#include "bfd_stdint.h"
+#include <elf/csky.h>
#include "disassemble.h"
#include "elf-bfd.h"
#include "opcode/csky.h"
@@ -32,6 +33,7 @@
#define CSKY_INST_TYPE unsigned long
#define HAS_SUB_OPERAND (unsigned int)0xffffffff
+#define CSKY_DEFAULT_ISA 0xffffffff
enum sym_type
{
@@ -47,6 +49,7 @@ struct csky_dis_info
disassemble_info *info;
/* Opcode information. */
struct csky_opcode_info const *opinfo;
+ BFD_HOST_U_64_BIT isa;
/* The value of operand to show. */
int value;
/* Whether to look up/print a symbol name. */
@@ -159,10 +162,8 @@ csky_find_inst_info (struct csky_opcode_info const **pinfo,
p = g_opcodeP;
while (p->mnemonic)
{
- /* FIXME: Skip 860's instruction in other CPUs. It is not suitable.
- These codes need to be optimized. */
- if (((CSKY_ARCH_MASK & mach_flag) != CSKY_ARCH_860)
- && (p->isa_flag32 & CSKYV2_ISA_10E60))
+ if (!(p->isa_flag16 & dis_info.isa)
+ && !(p->isa_flag32 & dis_info.isa))
{
p++;
continue;
@@ -235,9 +236,28 @@ csky_symbol_is_valid (asymbol *sym,
disassembler_ftype
csky_get_disassembler (bfd *abfd)
{
- if (abfd != NULL)
- mach_flag = elf_elfheader (abfd)->e_flags;
- return print_insn_csky;
+ obj_attribute *attr;
+ const char *sec_name = NULL;
+ if (!abfd)
+ return NULL;
+
+ mach_flag = elf_elfheader (abfd)->e_flags;
+
+ sec_name = get_elf_backend_data (abfd)->obj_attrs_section;
+ /* Skip any input that hasn't attribute section.
+ This enables to link object files without attribute section with
+ any others. */
+ if (bfd_get_section_by_name (abfd, sec_name) != NULL)
+ {
+ attr = elf_known_obj_attributes_proc (abfd);
+ dis_info.isa = attr[Tag_CSKY_ISA_EXT_FLAGS].i;
+ dis_info.isa <<= 32;
+ dis_info.isa |= attr[Tag_CSKY_ISA_FLAGS].i;
+ }
+ else
+ dis_info.isa = CSKY_DEFAULT_ISA;
+
+ return print_insn_csky;
}
static int
@@ -937,10 +957,16 @@ print_insn_csky (bfd_vma memaddr, struct disassemble_info *info)
if (mach_flag != INIT_MACH_FLAG && mach_flag != BINARY_MACH_FLAG)
info->mach = mach_flag;
else if (mach_flag == INIT_MACH_FLAG)
- mach_flag = info->mach;
+ {
+ mach_flag = info->mach;
+ dis_info.isa = CSKY_DEFAULT_ISA;
+ }
if (mach_flag == BINARY_MACH_FLAG && info->endian == BFD_ENDIAN_UNKNOWN)
- info->endian = BFD_ENDIAN_LITTLE;
+ {
+ info->endian = BFD_ENDIAN_LITTLE;
+ dis_info.isa = CSKY_DEFAULT_ISA;
+ }
/* First check the full symtab for a mapping symbol, even if there
are no usable non-mapping symbols for this address. */
diff --git a/opcodes/csky-opc.h b/opcodes/csky-opc.h
index 796d375..95df44d 100644
--- a/opcodes/csky-opc.h
+++ b/opcodes/csky-opc.h
@@ -262,8 +262,8 @@ struct csky_opcode
/* Encodings for 32-bit opcodes. */
struct csky_opcode_info op32[OP_TABLE_NUM];
/* Instruction set flag. */
- unsigned int isa_flag16;
- unsigned int isa_flag32;
+ BFD_HOST_U_64_BIT isa_flag16;
+ BFD_HOST_U_64_BIT isa_flag32;
/* Whether this insn needs relocation, 0: no, !=0: yes. */
signed int reloc16;
signed int reloc32;