* [PATCH] RISC-V: Fix the merged orders of Z* extension for linker.
@ 2021-01-04 3:12 Nelson Chu
2021-01-04 3:19 ` Nelson Chu
0 siblings, 1 reply; 2+ messages in thread
From: Nelson Chu @ 2021-01-04 3:12 UTC (permalink / raw)
To: binutils
Similar to the commit 6729e2c2af2bd94408430734316597843718a484,
we have to check the first char of the Z* extensions, to make
sure that they follow the order of the standard extensions.
bfd/
* elfxx-riscv.c (riscv_compare_subsets): Removed static.
* elfxx-riscv.h: Add declaration.
* elfnn-riscv.c (riscv_merge_multi_letter_ext): Use
riscv_compare_subsets to check the orders.
(riscv_skip_prefix): Removed.
(riscv_prefix_cmp): Removed.
---
bfd/elfnn-riscv.c | 35 +----------------------------------
bfd/elfxx-riscv.c | 2 +-
bfd/elfxx-riscv.h | 3 +++
3 files changed, 5 insertions(+), 35 deletions(-)
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index dff0d4d..047f31b 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -3410,39 +3410,6 @@ riscv_merge_std_ext (bfd *ibfd,
return TRUE;
}
-/* If C is a prefix class, then return the EXT string without the prefix.
- Otherwise return the entire EXT string. */
-
-static const char *
-riscv_skip_prefix (const char *ext, riscv_isa_ext_class_t c)
-{
- switch (c)
- {
- case RV_ISA_CLASS_X: return &ext[1];
- case RV_ISA_CLASS_S: return &ext[1];
- case RV_ISA_CLASS_Z: return &ext[1];
- default: return ext;
- }
-}
-
-/* Compare prefixed extension names canonically. */
-
-static int
-riscv_prefix_cmp (const char *a, const char *b)
-{
- riscv_isa_ext_class_t ca = riscv_get_prefix_class (a);
- riscv_isa_ext_class_t cb = riscv_get_prefix_class (b);
-
- /* Extension name without prefix */
- const char *anp = riscv_skip_prefix (a, ca);
- const char *bnp = riscv_skip_prefix (b, cb);
-
- if (ca == cb)
- return strcasecmp (anp, bnp);
-
- return (int)ca - (int)cb;
-}
-
/* Merge multi letter extensions. PIN is a pointer to the head of the input
object subset list. Likewise for POUT and the output object. Return TRUE
on success and FALSE when a conflict is found. */
@@ -3460,7 +3427,7 @@ riscv_merge_multi_letter_ext (bfd *ibfd,
while (in && out)
{
- cmp = riscv_prefix_cmp (in->name, out->name);
+ cmp = riscv_compare_subsets (in->name, out->name);
if (cmp < 0)
{
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 101e27f..d3b6472 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1037,7 +1037,7 @@ static int riscv_ext_order[26] = {0};
or greater than zero if `subset2` is found, respectively, to be less
than, to match, or be greater than `subset1`. */
-static int
+int
riscv_compare_subsets (const char *subset1, const char *subset2)
{
int order1 = riscv_ext_order[(*subset1 - 'a')];
diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h
index 3a7c7b7..4d7a6dc 100644
--- a/bfd/elfxx-riscv.h
+++ b/bfd/elfxx-riscv.h
@@ -116,3 +116,6 @@ riscv_get_priv_spec_class_from_numbers (unsigned int,
extern const char *
riscv_get_priv_spec_name (enum riscv_priv_spec_class);
+
+extern int
+riscv_compare_subsets (const char *, const char *);
--
2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] RISC-V: Fix the merged orders of Z* extension for linker.
2021-01-04 3:12 [PATCH] RISC-V: Fix the merged orders of Z* extension for linker Nelson Chu
@ 2021-01-04 3:19 ` Nelson Chu
0 siblings, 0 replies; 2+ messages in thread
From: Nelson Chu @ 2021-01-04 3:19 UTC (permalink / raw)
To: Binutils
Committed, thanks.
Nelson
On Mon, Jan 4, 2021 at 11:12 AM Nelson Chu <nelson.chu@sifive.com> wrote:
>
> Similar to the commit 6729e2c2af2bd94408430734316597843718a484,
> we have to check the first char of the Z* extensions, to make
> sure that they follow the order of the standard extensions.
>
> bfd/
> * elfxx-riscv.c (riscv_compare_subsets): Removed static.
> * elfxx-riscv.h: Add declaration.
> * elfnn-riscv.c (riscv_merge_multi_letter_ext): Use
> riscv_compare_subsets to check the orders.
> (riscv_skip_prefix): Removed.
> (riscv_prefix_cmp): Removed.
> ---
> bfd/elfnn-riscv.c | 35 +----------------------------------
> bfd/elfxx-riscv.c | 2 +-
> bfd/elfxx-riscv.h | 3 +++
> 3 files changed, 5 insertions(+), 35 deletions(-)
>
> diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
> index dff0d4d..047f31b 100644
> --- a/bfd/elfnn-riscv.c
> +++ b/bfd/elfnn-riscv.c
> @@ -3410,39 +3410,6 @@ riscv_merge_std_ext (bfd *ibfd,
> return TRUE;
> }
>
> -/* If C is a prefix class, then return the EXT string without the prefix.
> - Otherwise return the entire EXT string. */
> -
> -static const char *
> -riscv_skip_prefix (const char *ext, riscv_isa_ext_class_t c)
> -{
> - switch (c)
> - {
> - case RV_ISA_CLASS_X: return &ext[1];
> - case RV_ISA_CLASS_S: return &ext[1];
> - case RV_ISA_CLASS_Z: return &ext[1];
> - default: return ext;
> - }
> -}
> -
> -/* Compare prefixed extension names canonically. */
> -
> -static int
> -riscv_prefix_cmp (const char *a, const char *b)
> -{
> - riscv_isa_ext_class_t ca = riscv_get_prefix_class (a);
> - riscv_isa_ext_class_t cb = riscv_get_prefix_class (b);
> -
> - /* Extension name without prefix */
> - const char *anp = riscv_skip_prefix (a, ca);
> - const char *bnp = riscv_skip_prefix (b, cb);
> -
> - if (ca == cb)
> - return strcasecmp (anp, bnp);
> -
> - return (int)ca - (int)cb;
> -}
> -
> /* Merge multi letter extensions. PIN is a pointer to the head of the input
> object subset list. Likewise for POUT and the output object. Return TRUE
> on success and FALSE when a conflict is found. */
> @@ -3460,7 +3427,7 @@ riscv_merge_multi_letter_ext (bfd *ibfd,
>
> while (in && out)
> {
> - cmp = riscv_prefix_cmp (in->name, out->name);
> + cmp = riscv_compare_subsets (in->name, out->name);
>
> if (cmp < 0)
> {
> diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
> index 101e27f..d3b6472 100644
> --- a/bfd/elfxx-riscv.c
> +++ b/bfd/elfxx-riscv.c
> @@ -1037,7 +1037,7 @@ static int riscv_ext_order[26] = {0};
> or greater than zero if `subset2` is found, respectively, to be less
> than, to match, or be greater than `subset1`. */
>
> -static int
> +int
> riscv_compare_subsets (const char *subset1, const char *subset2)
> {
> int order1 = riscv_ext_order[(*subset1 - 'a')];
> diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h
> index 3a7c7b7..4d7a6dc 100644
> --- a/bfd/elfxx-riscv.h
> +++ b/bfd/elfxx-riscv.h
> @@ -116,3 +116,6 @@ riscv_get_priv_spec_class_from_numbers (unsigned int,
>
> extern const char *
> riscv_get_priv_spec_name (enum riscv_priv_spec_class);
> +
> +extern int
> +riscv_compare_subsets (const char *, const char *);
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-04 3:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04 3:12 [PATCH] RISC-V: Fix the merged orders of Z* extension for linker Nelson Chu
2021-01-04 3:19 ` Nelson Chu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).