+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
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}
};
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. */
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))
|| 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;
}
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. */
#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"
+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 ...
}
}
+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)
{
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;
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,
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,
#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
+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.
// 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
+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
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
{
const char *name;
unsigned int mach_flag;
- unsigned int isa_flag;
+ BFD_HOST_U_64_BIT isa_flag;
};
typedef enum
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);
};
-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
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;
}
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;
}
{
/* 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;
}
{
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");
}
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;
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
\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.*
+#...
\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
+#...
\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*\>
+#...
\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
+#...
\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
+#...
#...
\s*[0-9a-f]*:\s*6c03\s*mov\s*r0,\s*r0
\s*[0-9a-f]*:\s*e820fffd\s*bnezad\s*r0,\s*0.*
+#...
\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\)
+#...
-# name: csky - all
+# name: csky - dsp
#as: -mcpu=ck810e -W
#objdump: -D
\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
+#...
#...
\s*[0-9a-f]*:\s*c0004020\s*rte
\s*[0-9a-f]*:\s*00001234\s*\.long\s*0x00001234
+#...
\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
+#...
\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
+#...
\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
+#...
\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
+#...
\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
+#...
\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
+#...
#...
\s*[0-9a-f]*:\s*R_CKCORE_TLS_GD32\s*xxx.*
\s*[0-9a-f]*:\s*R_CKCORE_PLT32\s*__tls_get_addr
+#...
Disassembly of section \.text:
#...
\s*[0-9a-f]*:\s*R_CKCORE_TLS_IE32\s*xxx.*
+#...
\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
+#...
-# name: csky - v2 TLS IE
+# name: csky - v2 TLS LE
#as: -mcpu=ck810 -W
#objdump: -Dr
Disassembly of section \.text:
#...
\s*[0-9a-f]*:\s*R_CKCORE_TLS_LE32\s*xxx
+#...
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
}
--- /dev/null
+
+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
+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.
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 */
#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)
+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
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
.*
1 .tbss .*
.*
+ 2 .csky.attributes .*
+ .*
.*
1 .tbss .*
.*
+ 2 .csky.attributes .*
+ .*
*(.note.renesas)
*(.MIPS.abiflags)
*(.MSP430.attributes)
+ *(.csky.attributes)
*(.gnu.attributes)
}
+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.
#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"
#define CSKY_INST_TYPE unsigned long
#define HAS_SUB_OPERAND (unsigned int)0xffffffff
+#define CSKY_DEFAULT_ISA 0xffffffff
enum sym_type
{
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. */
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;
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
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. */
/* 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;