From 81037fc7c02777f706fa145673f11c1d6e6ec052 Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Tue, 4 Dec 2018 14:28:13 +0800 Subject: [PATCH 1/2] RISC-V: Support ELF attribute for gas and readelf --- bfd/ChangeLog | 14 +++++ bfd/elfnn-riscv.c | 29 ++++++++++ bfd/elfxx-riscv.c | 89 +++++++++++++++++++++++++++++++ bfd/elfxx-riscv.h | 3 ++ binutils/ChangeLog | 10 ++++ binutils/readelf.c | 97 ++++++++++++++++++++++++++++++++++ gas/ChangeLog | 31 +++++++++++ gas/config/tc-riscv.c | 82 ++++++++++++++++++++++++++++ gas/config/tc-riscv.h | 6 +++ gas/testsuite/gas/elf/elf.exp | 3 ++ gas/testsuite/gas/elf/section2.e-riscv | 9 ++++ gas/testsuite/gas/riscv/attribute-01.d | 6 +++ gas/testsuite/gas/riscv/attribute-02.d | 6 +++ gas/testsuite/gas/riscv/attribute-03.d | 6 +++ gas/testsuite/gas/riscv/attribute-04.d | 6 +++ gas/testsuite/gas/riscv/attribute-04.s | 1 + gas/testsuite/gas/riscv/attribute-05.d | 11 ++++ gas/testsuite/gas/riscv/attribute-05.s | 6 +++ gas/testsuite/gas/riscv/attribute-06.d | 6 +++ gas/testsuite/gas/riscv/attribute-06.s | 1 + gas/testsuite/gas/riscv/attribute-07.d | 6 +++ gas/testsuite/gas/riscv/attribute-07.s | 1 + gas/testsuite/gas/riscv/attribute-08.d | 6 +++ gas/testsuite/gas/riscv/attribute-08.s | 1 + gas/testsuite/gas/riscv/empty.l | 1 + include/ChangeLog | 9 ++++ include/elf/riscv.h | 16 ++++++ 27 files changed, 462 insertions(+) create mode 100644 gas/testsuite/gas/elf/section2.e-riscv create mode 100644 gas/testsuite/gas/riscv/attribute-01.d create mode 100644 gas/testsuite/gas/riscv/attribute-02.d create mode 100644 gas/testsuite/gas/riscv/attribute-03.d create mode 100644 gas/testsuite/gas/riscv/attribute-04.d create mode 100644 gas/testsuite/gas/riscv/attribute-04.s create mode 100644 gas/testsuite/gas/riscv/attribute-05.d create mode 100644 gas/testsuite/gas/riscv/attribute-05.s create mode 100644 gas/testsuite/gas/riscv/attribute-06.d create mode 100644 gas/testsuite/gas/riscv/attribute-06.s create mode 100644 gas/testsuite/gas/riscv/attribute-07.d create mode 100644 gas/testsuite/gas/riscv/attribute-07.s create mode 100644 gas/testsuite/gas/riscv/attribute-08.d create mode 100644 gas/testsuite/gas/riscv/attribute-08.s create mode 100644 gas/testsuite/gas/riscv/empty.l diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8a37271..05301d4 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,17 @@ +2018-12-07 Kito Cheng + Nelson Chu + + * elfnn-riscv.c (riscv_elf_obj_attrs_arg_type): New function. + (elf_backend_obj_attrs_vendor): Define. + (elf_backend_obj_attrs_section_type): Likewise. + (elf_backend_obj_attrs_section): Likewise. + * elfxx-riscv.c (riscv_estimate_digit): New function. + (riscv_estimate_arch_strlen1): Likewise. + (riscv_estimate_arch_strlen): Likewise. + (riscv_arch_str1): Likewise. + (riscv_arch_str): Likewise. + * elfxx-riscv.h (riscv_arch_str): Declare. + 2018-12-06 Alan Modra * elf32-ppc.c (ppc_elf_howto_raw ): Correct diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index a3599d7..9e3d459 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -3654,6 +3654,26 @@ riscv_elf_object_p (bfd *abfd) return TRUE; } +/* Determine whether an object attribute tag takes an integer, a + string or both. */ + +static int +riscv_elf_obj_attrs_arg_type (int tag) +{ + switch (tag) + { + case Tag_priv_spec: + case Tag_priv_spec_minor: + case Tag_priv_spec_revision: + case Tag_unaligned_access: + case Tag_stack_align: + return ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_NO_DEFAULT; + case Tag_arch: + return ATTR_TYPE_FLAG_STR_VAL; + default: + return (tag & 1) != 0 ? ATTR_TYPE_FLAG_STR_VAL : ATTR_TYPE_FLAG_INT_VAL; + } +} #define TARGET_LITTLE_SYM riscv_elfNN_vec #define TARGET_LITTLE_NAME "elfNN-littleriscv" @@ -3696,4 +3716,13 @@ riscv_elf_object_p (bfd *abfd) #define elf_backend_rela_normal 1 #define elf_backend_default_execstack 0 +#undef elf_backend_obj_attrs_vendor +#define elf_backend_obj_attrs_vendor "riscv" +#undef elf_backend_obj_attrs_arg_type +#define elf_backend_obj_attrs_arg_type riscv_elf_obj_attrs_arg_type +#undef elf_backend_obj_attrs_section_type +#define elf_backend_obj_attrs_section_type SHT_RISCV_ATTRIBUTES +#undef elf_backend_obj_attrs_section +#define elf_backend_obj_attrs_section ".riscv.attributes" + #include "elfNN-target.h" diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index a88c7fa..6fc7db3 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1485,3 +1485,92 @@ riscv_release_subset_list (riscv_subset_list_t *subset_list) subset_list->tail = NULL; } + +/* Return the number of digits for the input. */ + +static size_t +riscv_estimate_digit (unsigned num) +{ + size_t digit = 0; + if (num == 0) + return 1; + + for (digit = 0; num ; num /= 10) + digit++; + + return digit; +} + +/* Auxiliary function for estimate string length of subset list. */ + +static size_t +riscv_estimate_arch_strlen1 (const riscv_subset_t *subset) +{ + if (subset == NULL) + return 6; /* For rv32/rv64/rv128 and string terminator. */ + + return riscv_estimate_arch_strlen1 (subset->next) + + strlen (subset->name) + + riscv_estimate_digit (subset->major_version) + + 1 /* For version seperator: 'p'. */ + + riscv_estimate_digit (subset->minor_version) + + 1 /* For underscore. */; +} + +/* Estimate the string length of this subset list. */ + +static size_t +riscv_estimate_arch_strlen (const riscv_subset_list_t *subset_list) +{ + return riscv_estimate_arch_strlen1 (subset_list->head); +} + +/* Auxiliary function for convert subset info to string. */ + +static void +riscv_arch_str1 (riscv_subset_t *subset, + char *attr_str, char *buf, size_t bufsz) +{ + const char *underline = "_"; + + if (subset == NULL) + return; + + /* No underline between rvXX and i/e. */ + if ((strcasecmp (subset->name, "i") == 0) + || (strcasecmp (subset->name, "e") == 0)) + underline = ""; + + snprintf (buf, bufsz, "%s%s%dp%d", + underline, + subset->name, + subset->major_version, + subset->minor_version); + + strncat (attr_str, buf, bufsz); + + /* Skip 'i' extension after 'e'. */ + if ((strcasecmp (subset->name, "e") == 0) + && subset->next + && (strcasecmp (subset->next->name, "i") == 0)) + riscv_arch_str1 (subset->next->next, attr_str, buf, bufsz); + else + riscv_arch_str1 (subset->next, attr_str, buf, bufsz); +} + +/* Convert subset info to string with explicity version info. */ + +char * +riscv_arch_str (unsigned xlen, const riscv_subset_list_t *subset) +{ + size_t arch_str_len = riscv_estimate_arch_strlen (subset); + char *attr_str = xmalloc (arch_str_len); + char *buf = xmalloc (arch_str_len); + + snprintf (attr_str, arch_str_len, "rv%u", xlen); + + riscv_arch_str1 (subset->head, attr_str, buf, arch_str_len); + free (buf); + + return attr_str; +} diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h index 64e41b8..742726a 100644 --- a/bfd/elfxx-riscv.h +++ b/bfd/elfxx-riscv.h @@ -83,3 +83,6 @@ riscv_supported_std_ext (void); extern void riscv_release_subset_list (riscv_subset_list_t *); + +extern char * +riscv_arch_str (unsigned, const riscv_subset_list_t *); diff --git a/binutils/ChangeLog b/binutils/ChangeLog index b61ea26..e80b3f7 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,13 @@ +2018-12-07 Kito Cheng + Nelson Chu + + * readelf.c (get_riscv_section_type_name) New function. + (get_section_type_name): Add handler for RISC-V. + (riscv_attr_tag_t): Declare. + (riscv_attr_tag): New. + (display_riscv_attribute): New function. + (process_attributes): Add handler for RISC-V. + 2018-12-03 Nick Clifton PR 23941 diff --git a/binutils/readelf.c b/binutils/readelf.c index 9969e46..51d890b 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -4202,6 +4202,16 @@ get_v850_section_type_name (unsigned int sh_type) } static const char * +get_riscv_section_type_name (unsigned int sh_type) +{ + switch (sh_type) + { + case SHT_RISCV_ATTRIBUTES: return "RISCV_ATTRIBUTES"; + default: return NULL; + } +} + +static const char * get_section_type_name (Filedata * filedata, unsigned int sh_type) { static char buff[32]; @@ -4281,6 +4291,9 @@ get_section_type_name (Filedata * filedata, unsigned int sh_type) case EM_CYGNUS_V850: result = get_v850_section_type_name (sh_type); break; + case EM_RISCV: + result = get_riscv_section_type_name (sh_type); + break; default: result = NULL; break; @@ -15359,6 +15372,85 @@ display_msp430x_attribute (unsigned char * p, return p; } +struct riscv_attr_tag_t { + const char *name; + int tag; +}; + +static struct riscv_attr_tag_t riscv_attr_tag[] = +{ +#define T(tag) {"Tag_" #tag, Tag_##tag} + T(arch), + T(priv_spec), + T(priv_spec_minor), + T(priv_spec_revision), + T(unaligned_access), + T(stack_align), +#undef T +}; + +static unsigned char * +display_riscv_attribute (unsigned char * p, + const unsigned char * const end) +{ + unsigned int len; + int val; + int tag; + struct riscv_attr_tag_t *attr = NULL; + unsigned i; + + tag = read_uleb128 (p, &len, end); + p += len; + + /* Find the name of attribute. */ + for (i = 0; i < ARRAY_SIZE (riscv_attr_tag); i++) + { + if (riscv_attr_tag[i].tag == tag) + { + attr = &riscv_attr_tag[i]; + break; + } + } + + printf (" %s: ", attr->name); + + switch (tag) + { + case Tag_priv_spec: + case Tag_priv_spec_minor: + case Tag_priv_spec_revision: + val = read_uleb128 (p, &len, end); + p += len; + printf (_("%d\n"), val); + break; + case Tag_unaligned_access: + val = read_uleb128 (p, &len, end); + p += len; + switch (val) + { + case 0: + printf (_("No unaligned access\n")); + break; + case 1: + printf (_("Unaligned access\n")); + break; + } + break; + case Tag_stack_align: + val = read_uleb128 (p, &len, end); + p += len; + printf (_("%d-bytes\n"), val); + break; + case Tag_arch: + p = display_tag_value (-1, p, end); + break; + default: + return display_tag_value (tag & 1, p, end); + } + + return p; +} + static bfd_boolean process_attributes (Filedata * filedata, const char * public_name, @@ -18905,6 +18997,11 @@ process_arch_specific (Filedata * filedata) display_msp430x_attribute, display_generic_attribute); + case EM_RISCV: + return process_attributes (filedata, "riscv", SHT_RISCV_ATTRIBUTES, + display_riscv_attribute, + display_generic_attribute); + case EM_NDS32: return process_nds32_specific (filedata); diff --git a/gas/ChangeLog b/gas/ChangeLog index 72ae3bc..76fa9e4 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,34 @@ +2018-12-07 Kito Cheng + Nelson Chu + + * config/tc-riscv.c (riscv_write_out_arch_attr): New function. + (riscv_set_public_attributes): Likewise. + (riscv_md_end): Likewise. + (riscv_convert_symbolic_attribute): Likewise. + (s_riscv_attribute): Likewise. + (riscv_pseudo_table): Add .attribute to the table. + * config/tc-riscv.h (md_end): Define as riscv_md_end + (riscv_md_end): Declare. + (CONVERT_SYMBOLIC_ATTRIBUTE): Define as + riscv_convert_symbolic_attribute. + (riscv_convert_symbolic_attribute): Declare. + * testsuite/gas/elf/elf.exp: Adjust test case for section2.e. + * testsuite/gas/elf/section2.e-riscv: New. + * testsuite/gas/riscv/attribute-01.d: New test + * testsuite/gas/riscv/attribute-02.d: Likewise. + * testsuite/gas/riscv/attribute-03.d: Likewise. + * testsuite/gas/riscv/attribute-04.d: Likewise. + * testsuite/gas/riscv/attribute-04.s: Likewise. + * testsuite/gas/riscv/attribute-05.d: Likewise. + * testsuite/gas/riscv/attribute-05.s: Likewise. + * testsuite/gas/riscv/attribute-06.d: Likewise. + * testsuite/gas/riscv/attribute-06.s: Likewise. + * testsuite/gas/riscv/attribute-07.d: Likewise. + * testsuite/gas/riscv/attribute-07.s: Likewise. + * testsuite/gas/riscv/attribute-08.d: Likewise. + * testsuite/gas/riscv/attribute-08.s: Likewise. + * testsuite/gas/riscv/empty.l: Likewise. + 2018-12-06 Alan Modra * config/tc-ppc.c (md_assemble): Adjust relocs for VLE before diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 92ddf80..6c0f86d 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -3015,6 +3015,87 @@ s_riscv_insn (int x ATTRIBUTE_UNUSED) demand_empty_rest_of_line (); } +/* Update arch attributes. */ + +static void +riscv_write_out_arch_attr (void) +{ + const char *arch_str = riscv_arch_str (xlen, &riscv_subsets); + + bfd_elf_add_proc_attr_string (stdoutput, Tag_arch, arch_str); + + xfree ((void *)arch_str); +} + +/* Add the default contents for the .riscv.attributes section. */ + +static void +riscv_set_public_attributes (void) +{ + /* Always re-write arch attribute for normalize the arch string. */ + riscv_write_out_arch_attr (); +} + +/* Called after all assembly has been done. */ + +void +riscv_md_end (void) +{ + riscv_set_public_attributes (); +} + +/* Given a symbolic attribute NAME, return the proper integer value. + Returns -1 if the attribute is not known. */ + +int +riscv_convert_symbolic_attribute (const char *name) +{ + static const struct + { + const char * name; + const int tag; + } + attribute_table[] = + { + /* When you modify this table you should + also modify the list in doc/c-riscv.texi. */ +#define T(tag) {#tag, Tag_##tag}, {"Tag_" #tag, Tag_##tag} + T(arch), + T(priv_spec), + T(priv_spec_minor), + T(priv_spec_revision), + T(unaligned_access), + T(stack_align), +#undef T + }; + + unsigned int i; + + if (name == NULL) + return -1; + + for (i = 0; i < ARRAY_SIZE (attribute_table); i++) + if (strcmp (name, attribute_table[i].name) == 0) + return attribute_table[i].tag; + + return -1; +} + +/* Parse a .attribute directive. */ + +static void +s_riscv_attribute (int ignored ATTRIBUTE_UNUSED) +{ + int tag = obj_elf_vendor_attribute (OBJ_ATTR_PROC); + + if (tag == Tag_arch) + { + obj_attribute *attr; + attr = elf_known_obj_attributes_proc (stdoutput); + riscv_set_arch (attr[Tag_arch].s); + } +} + /* Pseudo-op table. */ static const pseudo_typeS riscv_pseudo_table[] = @@ -3030,6 +3111,7 @@ static const pseudo_typeS riscv_pseudo_table[] = {"uleb128", s_riscv_leb128, 0}, {"sleb128", s_riscv_leb128, 1}, {"insn", s_riscv_insn, 0}, + {"attribute", s_riscv_attribute, 0}, { NULL, NULL, 0 }, }; diff --git a/gas/config/tc-riscv.h b/gas/config/tc-riscv.h index 41a18be..7e33240 100644 --- a/gas/config/tc-riscv.h +++ b/gas/config/tc-riscv.h @@ -120,4 +120,10 @@ extern void riscv_elf_final_processing (void); /* Adjust debug_line after relaxation. */ #define DWARF2_USE_FIXED_ADVANCE_PC 1 +#define md_end riscv_md_end +#define CONVERT_SYMBOLIC_ATTRIBUTE riscv_convert_symbolic_attribute + +extern void riscv_md_end (void); +extern int riscv_convert_symbolic_attribute (const char *); + #endif /* TC_RISCV */ diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp index 9715ac8..05c3194 100644 --- a/gas/testsuite/gas/elf/elf.exp +++ b/gas/testsuite/gas/elf/elf.exp @@ -76,6 +76,9 @@ if { [is_elf_format] } then { if {[istarget "rx-*-*"]} then { set target_machine -rx } + if {[istarget "riscv*-*-*"]} then { + set target_machine -riscv + } if {[istarget "v850*-*-*"]} then { set target_machine -v850 } diff --git a/gas/testsuite/gas/elf/section2.e-riscv b/gas/testsuite/gas/elf/section2.e-riscv new file mode 100644 index 0000000..115bae2 --- /dev/null +++ b/gas/testsuite/gas/elf/section2.e-riscv @@ -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/gas/testsuite/gas/riscv/attribute-01.d b/gas/testsuite/gas/riscv/attribute-01.d new file mode 100644 index 0000000..927432f --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-01.d @@ -0,0 +1,6 @@ +#as: -march=rv32g +#readelf: -A +#source: empty.s +Attribute Section: riscv +File Attributes + Tag_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0" diff --git a/gas/testsuite/gas/riscv/attribute-02.d b/gas/testsuite/gas/riscv/attribute-02.d new file mode 100644 index 0000000..8ae463d --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-02.d @@ -0,0 +1,6 @@ +#as: -march=rv32gxargle +#readelf: -A +#source: empty.s +Attribute Section: riscv +File Attributes + Tag_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0_xargle2p0" diff --git a/gas/testsuite/gas/riscv/attribute-03.d b/gas/testsuite/gas/riscv/attribute-03.d new file mode 100644 index 0000000..478899b --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-03.d @@ -0,0 +1,6 @@ +#as: -march=rv32gxargle_xfoo +#readelf: -A +#source: empty.s +Attribute Section: riscv +File Attributes + Tag_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0_xargle2p0_xfoo2p0" diff --git a/gas/testsuite/gas/riscv/attribute-04.d b/gas/testsuite/gas/riscv/attribute-04.d new file mode 100644 index 0000000..9c3b5f7 --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-04.d @@ -0,0 +1,6 @@ +#as: +#readelf: -A +#source: attribute-04.s +Attribute Section: riscv +File Attributes + Tag_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0" diff --git a/gas/testsuite/gas/riscv/attribute-04.s b/gas/testsuite/gas/riscv/attribute-04.s new file mode 100644 index 0000000..2636227 --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-04.s @@ -0,0 +1 @@ + .attribute arch,"rv32g" diff --git a/gas/testsuite/gas/riscv/attribute-05.d b/gas/testsuite/gas/riscv/attribute-05.d new file mode 100644 index 0000000..4e81012 --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-05.d @@ -0,0 +1,11 @@ +#as: +#readelf: -A +#source: attribute-05.s +Attribute Section: riscv +File Attributes + Tag_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0" + Tag_priv_spec: 1 + Tag_priv_spec_minor: 2 + Tag_priv_spec_revision: 3 + Tag_unaligned_access: Unaligned access + Tag_stack_align: 16-bytes diff --git a/gas/testsuite/gas/riscv/attribute-05.s b/gas/testsuite/gas/riscv/attribute-05.s new file mode 100644 index 0000000..3b3b7f6 --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-05.s @@ -0,0 +1,6 @@ + .attribute arch, "rv32g" + .attribute priv_spec, 1 + .attribute priv_spec_minor, 2 + .attribute priv_spec_revision, 3 + .attribute unaligned_access, 1 + .attribute stack_align, 16 diff --git a/gas/testsuite/gas/riscv/attribute-06.d b/gas/testsuite/gas/riscv/attribute-06.d new file mode 100644 index 0000000..07ba41b --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-06.d @@ -0,0 +1,6 @@ +#as: -march=rv32g2p0 +#readelf: -A +#source: attribute-06.s +Attribute Section: riscv +File Attributes + Tag_arch: "rv32i2p0" diff --git a/gas/testsuite/gas/riscv/attribute-06.s b/gas/testsuite/gas/riscv/attribute-06.s new file mode 100644 index 0000000..de50251 --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-06.s @@ -0,0 +1 @@ + .attribute arch, "rv32i" diff --git a/gas/testsuite/gas/riscv/attribute-07.d b/gas/testsuite/gas/riscv/attribute-07.d new file mode 100644 index 0000000..0ae81de --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-07.d @@ -0,0 +1,6 @@ +#as: -march=rv64g2p0 +#readelf: -A +#source: attribute-07.s +Attribute Section: riscv +File Attributes + Tag_arch: "rv64i2p0" diff --git a/gas/testsuite/gas/riscv/attribute-07.s b/gas/testsuite/gas/riscv/attribute-07.s new file mode 100644 index 0000000..35e6ae3 --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-07.s @@ -0,0 +1 @@ + .attribute arch, "rv64i" diff --git a/gas/testsuite/gas/riscv/attribute-08.d b/gas/testsuite/gas/riscv/attribute-08.d new file mode 100644 index 0000000..7ae4575 --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-08.d @@ -0,0 +1,6 @@ +#as: +#readelf: -A +#source: attribute-08.s +Attribute Section: riscv +File Attributes + Tag_arch: "rv32e1p9" diff --git a/gas/testsuite/gas/riscv/attribute-08.s b/gas/testsuite/gas/riscv/attribute-08.s new file mode 100644 index 0000000..44e7a8d --- /dev/null +++ b/gas/testsuite/gas/riscv/attribute-08.s @@ -0,0 +1 @@ + .attribute arch, "rv32e1p9" diff --git a/gas/testsuite/gas/riscv/empty.l b/gas/testsuite/gas/riscv/empty.l new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/gas/testsuite/gas/riscv/empty.l @@ -0,0 +1 @@ + diff --git a/include/ChangeLog b/include/ChangeLog index 3b7c66d..5d67c2d 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,12 @@ +2018-12-07 Kito Cheng + + * elf/riscv.h (SHT_RISCV_ATTRIBUTES): Define. + (Tag_arch): Likewise. + (Tag_priv_spec): Likewise. + (Tag_priv_spec_minor): Likewise. + (Tag_priv_spec_revision): Likewise. + (Tag_unaligned_access): Likewise. + 2018-12-06 Alan Modra * opcode/ppc.h (E_OPCODE_MASK, E_LI_MASK, E_LI_INSN): Define. diff --git a/include/elf/riscv.h b/include/elf/riscv.h index d036e83..1f8b2f2 100644 --- a/include/elf/riscv.h +++ b/include/elf/riscv.h @@ -116,4 +116,20 @@ END_RELOC_NUMBERS (R_RISCV_max) /* The name of the global pointer symbol. */ #define RISCV_GP_SYMBOL "__global_pointer$" +/* Additional section types. */ +#define SHT_RISCV_ATTRIBUTES 0x70000003 /* Section holds attributes. */ + +/* Object attributes. */ + +enum +{ + /* 0-3 are generic. */ + Tag_arch = 4, + Tag_priv_spec, + Tag_priv_spec_minor, + Tag_priv_spec_revision, + Tag_unaligned_access, + Tag_stack_align +}; + #endif /* _ELF_RISCV_H */ -- 1.8.3.1