public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: allow link o32 objects with mach mips64r6 and mips32r6
@ 2023-02-07  2:44 YunQiang Su
  2023-02-13 15:47 ` Richard Sandiford
  2023-02-21  4:06 ` [PATCH] MIPS: make mipsisa32 and mipsisa64 link more systematic YunQiang Su
  0 siblings, 2 replies; 12+ messages in thread
From: YunQiang Su @ 2023-02-07  2:44 UTC (permalink / raw)
  To: binutils; +Cc: syq, macro, xry111, richard.sandiford, jiaxun.yang, YunQiang Su

The `-32 -mips32r6` and `-32 mips64r6` option of gnu as
will generate objects with different mach attributes.

   0x90001407, noreorder, pic, cpic, nan2008, o32, mips32r6
vs
   0xa0001507, noreorder, pic, cpic, 32bitmode, nan2008, o32, mips64r6

Let's allow link them togather, just like we did for r2 ones.

bfd/ChangeLog:

	* elfxx-mips.c (mips_mach_extends_p): allow link o32 objects
	with mach mips64r6 and mips32r6.
---
 bfd/elfxx-mips.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index e9fb61ff9e7..1790b78e822 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -14600,6 +14600,10 @@ mips_mach_extends_p (unsigned long base, unsigned long extension)
       && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
     return true;
 
+  if (base == bfd_mach_mipsisa32r6
+      && mips_mach_extends_p (bfd_mach_mipsisa64r6, extension))
+    return true;
+
   for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
     if (extension == mips_mach_extensions[i].extension)
       {
-- 
2.30.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] MIPS: allow link o32 objects with mach mips64r6 and mips32r6
  2023-02-07  2:44 [PATCH] MIPS: allow link o32 objects with mach mips64r6 and mips32r6 YunQiang Su
@ 2023-02-13 15:47 ` Richard Sandiford
  2023-02-21  4:06 ` [PATCH] MIPS: make mipsisa32 and mipsisa64 link more systematic YunQiang Su
  1 sibling, 0 replies; 12+ messages in thread
From: Richard Sandiford @ 2023-02-13 15:47 UTC (permalink / raw)
  To: YunQiang Su; +Cc: binutils, syq, macro, xry111, jiaxun.yang

Sorry for the slow reply.

YunQiang Su <yunqiang.su@cipunited.com> writes:
> The `-32 -mips32r6` and `-32 mips64r6` option of gnu as
> will generate objects with different mach attributes.
>
>    0x90001407, noreorder, pic, cpic, nan2008, o32, mips32r6
> vs
>    0xa0001507, noreorder, pic, cpic, 32bitmode, nan2008, o32, mips64r6
>
> Let's allow link them togather, just like we did for r2 ones.
>
> bfd/ChangeLog:
>
> 	* elfxx-mips.c (mips_mach_extends_p): allow link o32 objects
> 	with mach mips64r6 and mips32r6.

Looks good, but how about making this more systematic by applying
it to all mipsisa32 revisions?  E.g. have a second array of
mips_mach_extension objects that gives the mipsisa32 base and corresponding
mipsisa64 "extension" (ok, maybe not really an accurate term in this case,
but good enough).

Thanks,
Richard


> ---
>  bfd/elfxx-mips.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
> index e9fb61ff9e7..1790b78e822 100644
> --- a/bfd/elfxx-mips.c
> +++ b/bfd/elfxx-mips.c
> @@ -14600,6 +14600,10 @@ mips_mach_extends_p (unsigned long base, unsigned long extension)
>        && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
>      return true;
>  
> +  if (base == bfd_mach_mipsisa32r6
> +      && mips_mach_extends_p (bfd_mach_mipsisa64r6, extension))
> +    return true;
> +
>    for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
>      if (extension == mips_mach_extensions[i].extension)
>        {

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-02-07  2:44 [PATCH] MIPS: allow link o32 objects with mach mips64r6 and mips32r6 YunQiang Su
  2023-02-13 15:47 ` Richard Sandiford
@ 2023-02-21  4:06 ` YunQiang Su
  2023-02-27 14:56   ` Richard Sandiford
  2023-03-02  1:52   ` [PATCH v2] " YunQiang Su
  1 sibling, 2 replies; 12+ messages in thread
From: YunQiang Su @ 2023-02-21  4:06 UTC (permalink / raw)
  To: binutils; +Cc: syq, macro, xry111, richard.sandiford, jiaxun.yang, YunQiang Su

Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
to make mipsisa32 and mipsisa64 interlink more systemtic.

Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.

Note: R6 is not compatible with pre-R6.

bfd/ChangeLog:

	* elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
	  mipsisa64 interlink more systematic.
	  (mips_mach_32_64): new struct added.
	  (mips_mach_extends_32_64): new function added.
---
 bfd/elfxx-mips.c | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index e9fb61ff9e7..e9480ea3954 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -14505,6 +14505,16 @@ struct mips_mach_extension
   unsigned long extension, base;
 };
 
+/* An array describing how BFD machines relate to one another. The entries
+   are ordered topologically. */
+static const struct mips_mach_extension mips_mach_32_64[] =
+{
+  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
+  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
+  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
+  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
+  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
+};
 
 /* An array describing how BFD machines relate to one another.  The entries
    are ordered topologically with MIPS I extensions listed last.  */
@@ -14584,27 +14594,35 @@ static const struct mips_mach_extension mips_mach_extensions[] =
 
 /* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
 
+static bool
+mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
+{
+  size_t i;
+
+  if (extension == base)
+    return true;
+
+  for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++)
+    if (extension == mips_mach_32_64[i].extension)
+      return base == mips_mach_32_64[i].base;
+
+  return false;
+}
+
 static bool
 mips_mach_extends_p (unsigned long base, unsigned long extension)
 {
   size_t i;
+  unsigned long extension1 = extension;
 
-  if (extension == base)
-    return true;
-
-  if (base == bfd_mach_mipsisa32
-      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
-    return true;
-
-  if (base == bfd_mach_mipsisa32r2
-      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
+  if (mips_mach_extends_32_64 (base, extension))
     return true;
 
   for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
     if (extension == mips_mach_extensions[i].extension)
       {
 	extension = mips_mach_extensions[i].base;
-	if (extension == base)
+	if (mips_mach_extends_32_64 (base, extension))
 	  return true;
       }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-02-21  4:06 ` [PATCH] MIPS: make mipsisa32 and mipsisa64 link more systematic YunQiang Su
@ 2023-02-27 14:56   ` Richard Sandiford
  2023-03-02  1:52   ` [PATCH v2] " YunQiang Su
  1 sibling, 0 replies; 12+ messages in thread
From: Richard Sandiford @ 2023-02-27 14:56 UTC (permalink / raw)
  To: YunQiang Su; +Cc: binutils, syq, macro, xry111, jiaxun.yang

Sorry for the slow review, been away.

YunQiang Su <yunqiang.su@cipunited.com> writes:
> Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
> and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
> to make mipsisa32 and mipsisa64 interlink more systemtic.
>
> Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
> mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
> so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.
>
> Note: R6 is not compatible with pre-R6.
>
> bfd/ChangeLog:
>
> 	* elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
> 	  mipsisa64 interlink more systematic.
> 	  (mips_mach_32_64): new struct added.
> 	  (mips_mach_extends_32_64): new function added.
> ---
>  bfd/elfxx-mips.c | 38 ++++++++++++++++++++++++++++----------
>  1 file changed, 28 insertions(+), 10 deletions(-)
>
> diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
> index e9fb61ff9e7..e9480ea3954 100644
> --- a/bfd/elfxx-mips.c
> +++ b/bfd/elfxx-mips.c
> @@ -14505,6 +14505,16 @@ struct mips_mach_extension
>    unsigned long extension, base;
>  };
>  
> +/* An array describing how BFD machines relate to one another. The entries
> +   are ordered topologically. */

I don't this comment really applies to the new array.  How about:

/* An array that maps 64-bit architectures to the corresponding 32-bit
   architectures.  */

> +static const struct mips_mach_extension mips_mach_32_64[] =
> +{
> +  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
> +  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
> +  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
> +  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
> +  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
> +};
>  
>  /* An array describing how BFD machines relate to one another.  The entries
>     are ordered topologically with MIPS I extensions listed last.  */
> @@ -14584,27 +14594,35 @@ static const struct mips_mach_extension mips_mach_extensions[] =
>  
>  /* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
>  
> +static bool
> +mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
> +{
> +  size_t i;
> +
> +  if (extension == base)
> +    return true;
> +
> +  for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++)
> +    if (extension == mips_mach_32_64[i].extension)
> +      return base == mips_mach_32_64[i].base;
> +
> +  return false;
> +}
> +

I think this should go before the "Return true if..." comment and should
have its own comment.  How about:

/* Return true if bfd machine EXTENSION is the same as BASE, or if
   EXTENSION is the 64-bit equivalent of a 32-bit BASE.  */

OK with those changes, thanks.

Richard

>  static bool
>  mips_mach_extends_p (unsigned long base, unsigned long extension)
>  {
>    size_t i;
> +  unsigned long extension1 = extension;
>  
> -  if (extension == base)
> -    return true;
> -
> -  if (base == bfd_mach_mipsisa32
> -      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
> -    return true;
> -
> -  if (base == bfd_mach_mipsisa32r2
> -      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
> +  if (mips_mach_extends_32_64 (base, extension))
>      return true;
>  
>    for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
>      if (extension == mips_mach_extensions[i].extension)
>        {
>  	extension = mips_mach_extensions[i].base;
> -	if (extension == base)
> +	if (mips_mach_extends_32_64 (base, extension))
>  	  return true;
>        }

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-02-21  4:06 ` [PATCH] MIPS: make mipsisa32 and mipsisa64 link more systematic YunQiang Su
  2023-02-27 14:56   ` Richard Sandiford
@ 2023-03-02  1:52   ` YunQiang Su
  2023-03-05 13:38     ` YunQiang Su
  2023-04-03 14:03     ` Richard Sandiford
  1 sibling, 2 replies; 12+ messages in thread
From: YunQiang Su @ 2023-03-02  1:52 UTC (permalink / raw)
  To: binutils; +Cc: syq, macro, xry111, richard.sandiford, jiaxun.yang, YunQiang Su

Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
to make mipsisa32 and mipsisa64 interlink more systemtic.

Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.

Note: R6 is not compatible with pre-R6.

bfd/ChangeLog:

	* elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
	  mipsisa64 interlink more systematic.
	  (mips_mach_32_64): new struct added.
	  (mips_mach_extends_32_64): new function added.
---
 bfd/elfxx-mips.c | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 35bbd86044b..21e6396609b 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -14524,6 +14524,16 @@ struct mips_mach_extension
   unsigned long extension, base;
 };
 
+/* An array that maps 64-bit architectures to the corresponding 32-bit
+   architectures.  */
+static const struct mips_mach_extension mips_mach_32_64[] =
+{
+  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
+  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
+  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
+  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
+  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
+};
 
 /* An array describing how BFD machines relate to one another.  The entries
    are ordered topologically with MIPS I extensions listed last.  */
@@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] =
   { bfd_mach_mips3900, bfd_mach_mips3000 }
 };
 
-/* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
+/* Return true if bfd machine EXTENSION is the same as BASE, or if
+   EXTENSION is the 64-bit equivalent of a 32-bit BASE.  */
+
+static bool
+mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
+{
+  size_t i;
+
+  if (extension == base)
+    return true;
+
+  for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++)
+    if (extension == mips_mach_32_64[i].extension)
+      return base == mips_mach_32_64[i].base;
+
+  return false;
+}
 
 static bool
 mips_mach_extends_p (unsigned long base, unsigned long extension)
 {
   size_t i;
 
-  if (extension == base)
-    return true;
-
-  if (base == bfd_mach_mipsisa32
-      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
-    return true;
-
-  if (base == bfd_mach_mipsisa32r2
-      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
+  if (mips_mach_extends_32_64 (base, extension))
     return true;
 
   for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
     if (extension == mips_mach_extensions[i].extension)
       {
 	extension = mips_mach_extensions[i].base;
-	if (extension == base)
+	if (mips_mach_extends_32_64 (base, extension))
 	  return true;
       }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-03-02  1:52   ` [PATCH v2] " YunQiang Su
@ 2023-03-05 13:38     ` YunQiang Su
  2023-03-20  1:32       ` YunQiang Su
  2023-04-03 14:03     ` Richard Sandiford
  1 sibling, 1 reply; 12+ messages in thread
From: YunQiang Su @ 2023-03-05 13:38 UTC (permalink / raw)
  To: YunQiang Su; +Cc: binutils, macro, xry111, richard.sandiford, jiaxun.yang

@Rickard can you help to submit this patch to git?
I have no permission to do so.

YunQiang Su <yunqiang.su@cipunited.com> 于2023年3月2日周四 09:52写道:
>
> Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
> and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
> to make mipsisa32 and mipsisa64 interlink more systemtic.
>
> Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
> mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
> so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.
>
> Note: R6 is not compatible with pre-R6.
>
> bfd/ChangeLog:
>
>         * elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
>           mipsisa64 interlink more systematic.
>           (mips_mach_32_64): new struct added.
>           (mips_mach_extends_32_64): new function added.
> ---
>  bfd/elfxx-mips.c | 40 +++++++++++++++++++++++++++++-----------
>  1 file changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
> index 35bbd86044b..21e6396609b 100644
> --- a/bfd/elfxx-mips.c
> +++ b/bfd/elfxx-mips.c
> @@ -14524,6 +14524,16 @@ struct mips_mach_extension
>    unsigned long extension, base;
>  };
>
> +/* An array that maps 64-bit architectures to the corresponding 32-bit
> +   architectures.  */
> +static const struct mips_mach_extension mips_mach_32_64[] =
> +{
> +  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
> +  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
> +  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
> +  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
> +  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
> +};
>
>  /* An array describing how BFD machines relate to one another.  The entries
>     are ordered topologically with MIPS I extensions listed last.  */
> @@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] =
>    { bfd_mach_mips3900, bfd_mach_mips3000 }
>  };
>
> -/* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
> +/* Return true if bfd machine EXTENSION is the same as BASE, or if
> +   EXTENSION is the 64-bit equivalent of a 32-bit BASE.  */
> +
> +static bool
> +mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
> +{
> +  size_t i;
> +
> +  if (extension == base)
> +    return true;
> +
> +  for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++)
> +    if (extension == mips_mach_32_64[i].extension)
> +      return base == mips_mach_32_64[i].base;
> +
> +  return false;
> +}
>
>  static bool
>  mips_mach_extends_p (unsigned long base, unsigned long extension)
>  {
>    size_t i;
>
> -  if (extension == base)
> -    return true;
> -
> -  if (base == bfd_mach_mipsisa32
> -      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
> -    return true;
> -
> -  if (base == bfd_mach_mipsisa32r2
> -      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
> +  if (mips_mach_extends_32_64 (base, extension))
>      return true;
>
>    for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
>      if (extension == mips_mach_extensions[i].extension)
>        {
>         extension = mips_mach_extensions[i].base;
> -       if (extension == base)
> +       if (mips_mach_extends_32_64 (base, extension))
>           return true;
>        }
>
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-03-05 13:38     ` YunQiang Su
@ 2023-03-20  1:32       ` YunQiang Su
  2023-04-03  3:59         ` YunQiang Su
  0 siblings, 1 reply; 12+ messages in thread
From: YunQiang Su @ 2023-03-20  1:32 UTC (permalink / raw)
  To: YunQiang Su; +Cc: binutils, macro, xry111, richard.sandiford, jiaxun.yang

ping

YunQiang Su <syq@debian.org> 于2023年3月5日周日 21:38写道:
>
> @Rickard can you help to submit this patch to git?
> I have no permission to do so.
>
> YunQiang Su <yunqiang.su@cipunited.com> 于2023年3月2日周四 09:52写道:
> >
> > Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
> > and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
> > to make mipsisa32 and mipsisa64 interlink more systemtic.
> >
> > Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
> > mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
> > so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.
> >
> > Note: R6 is not compatible with pre-R6.
> >
> > bfd/ChangeLog:
> >
> >         * elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
> >           mipsisa64 interlink more systematic.
> >           (mips_mach_32_64): new struct added.
> >           (mips_mach_extends_32_64): new function added.
> > ---
> >  bfd/elfxx-mips.c | 40 +++++++++++++++++++++++++++++-----------
> >  1 file changed, 29 insertions(+), 11 deletions(-)
> >
> > diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
> > index 35bbd86044b..21e6396609b 100644
> > --- a/bfd/elfxx-mips.c
> > +++ b/bfd/elfxx-mips.c
> > @@ -14524,6 +14524,16 @@ struct mips_mach_extension
> >    unsigned long extension, base;
> >  };
> >
> > +/* An array that maps 64-bit architectures to the corresponding 32-bit
> > +   architectures.  */
> > +static const struct mips_mach_extension mips_mach_32_64[] =
> > +{
> > +  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
> > +  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
> > +  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
> > +  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
> > +  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
> > +};
> >
> >  /* An array describing how BFD machines relate to one another.  The entries
> >     are ordered topologically with MIPS I extensions listed last.  */
> > @@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] =
> >    { bfd_mach_mips3900, bfd_mach_mips3000 }
> >  };
> >
> > -/* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
> > +/* Return true if bfd machine EXTENSION is the same as BASE, or if
> > +   EXTENSION is the 64-bit equivalent of a 32-bit BASE.  */
> > +
> > +static bool
> > +mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
> > +{
> > +  size_t i;
> > +
> > +  if (extension == base)
> > +    return true;
> > +
> > +  for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++)
> > +    if (extension == mips_mach_32_64[i].extension)
> > +      return base == mips_mach_32_64[i].base;
> > +
> > +  return false;
> > +}
> >
> >  static bool
> >  mips_mach_extends_p (unsigned long base, unsigned long extension)
> >  {
> >    size_t i;
> >
> > -  if (extension == base)
> > -    return true;
> > -
> > -  if (base == bfd_mach_mipsisa32
> > -      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
> > -    return true;
> > -
> > -  if (base == bfd_mach_mipsisa32r2
> > -      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
> > +  if (mips_mach_extends_32_64 (base, extension))
> >      return true;
> >
> >    for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
> >      if (extension == mips_mach_extensions[i].extension)
> >        {
> >         extension = mips_mach_extensions[i].base;
> > -       if (extension == base)
> > +       if (mips_mach_extends_32_64 (base, extension))
> >           return true;
> >        }
> >
> > --
> > 2.30.2
> >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-03-20  1:32       ` YunQiang Su
@ 2023-04-03  3:59         ` YunQiang Su
  0 siblings, 0 replies; 12+ messages in thread
From: YunQiang Su @ 2023-04-03  3:59 UTC (permalink / raw)
  To: YunQiang Su; +Cc: binutils, macro, xry111, richard.sandiford, jiaxun.yang

ping

YunQiang Su <syq@debian.org> 于2023年3月20日周一 09:32写道:
>
> ping
>
> YunQiang Su <syq@debian.org> 于2023年3月5日周日 21:38写道:
> >
> > @Rickard can you help to submit this patch to git?
> > I have no permission to do so.
> >
> > YunQiang Su <yunqiang.su@cipunited.com> 于2023年3月2日周四 09:52写道:
> > >
> > > Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
> > > and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
> > > to make mipsisa32 and mipsisa64 interlink more systemtic.
> > >
> > > Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
> > > mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
> > > so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.
> > >
> > > Note: R6 is not compatible with pre-R6.
> > >
> > > bfd/ChangeLog:
> > >
> > >         * elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
> > >           mipsisa64 interlink more systematic.
> > >           (mips_mach_32_64): new struct added.
> > >           (mips_mach_extends_32_64): new function added.
> > > ---
> > >  bfd/elfxx-mips.c | 40 +++++++++++++++++++++++++++++-----------
> > >  1 file changed, 29 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
> > > index 35bbd86044b..21e6396609b 100644
> > > --- a/bfd/elfxx-mips.c
> > > +++ b/bfd/elfxx-mips.c
> > > @@ -14524,6 +14524,16 @@ struct mips_mach_extension
> > >    unsigned long extension, base;
> > >  };
> > >
> > > +/* An array that maps 64-bit architectures to the corresponding 32-bit
> > > +   architectures.  */
> > > +static const struct mips_mach_extension mips_mach_32_64[] =
> > > +{
> > > +  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
> > > +  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
> > > +  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
> > > +  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
> > > +  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
> > > +};
> > >
> > >  /* An array describing how BFD machines relate to one another.  The entries
> > >     are ordered topologically with MIPS I extensions listed last.  */
> > > @@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] =
> > >    { bfd_mach_mips3900, bfd_mach_mips3000 }
> > >  };
> > >
> > > -/* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
> > > +/* Return true if bfd machine EXTENSION is the same as BASE, or if
> > > +   EXTENSION is the 64-bit equivalent of a 32-bit BASE.  */
> > > +
> > > +static bool
> > > +mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
> > > +{
> > > +  size_t i;
> > > +
> > > +  if (extension == base)
> > > +    return true;
> > > +
> > > +  for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++)
> > > +    if (extension == mips_mach_32_64[i].extension)
> > > +      return base == mips_mach_32_64[i].base;
> > > +
> > > +  return false;
> > > +}
> > >
> > >  static bool
> > >  mips_mach_extends_p (unsigned long base, unsigned long extension)
> > >  {
> > >    size_t i;
> > >
> > > -  if (extension == base)
> > > -    return true;
> > > -
> > > -  if (base == bfd_mach_mipsisa32
> > > -      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
> > > -    return true;
> > > -
> > > -  if (base == bfd_mach_mipsisa32r2
> > > -      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
> > > +  if (mips_mach_extends_32_64 (base, extension))
> > >      return true;
> > >
> > >    for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
> > >      if (extension == mips_mach_extensions[i].extension)
> > >        {
> > >         extension = mips_mach_extensions[i].base;
> > > -       if (extension == base)
> > > +       if (mips_mach_extends_32_64 (base, extension))
> > >           return true;
> > >        }
> > >
> > > --
> > > 2.30.2
> > >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-03-02  1:52   ` [PATCH v2] " YunQiang Su
  2023-03-05 13:38     ` YunQiang Su
@ 2023-04-03 14:03     ` Richard Sandiford
  2023-04-10  6:48       ` YunQiang Su
  2023-04-10  6:51       ` [PATCH v3] " YunQiang Su
  1 sibling, 2 replies; 12+ messages in thread
From: Richard Sandiford @ 2023-04-03 14:03 UTC (permalink / raw)
  To: YunQiang Su; +Cc: binutils, syq, macro, xry111, jiaxun.yang

YunQiang Su <yunqiang.su@cipunited.com> writes:
> Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
> and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
> to make mipsisa32 and mipsisa64 interlink more systemtic.
>
> Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
> mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
> so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.
>
> Note: R6 is not compatible with pre-R6.
>
> bfd/ChangeLog:
>
> 	* elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
> 	  mipsisa64 interlink more systematic.
> 	  (mips_mach_32_64): new struct added.
> 	  (mips_mach_extends_32_64): new function added.

Sorry for the delay in pushing this.  Could you check whether it's
the right version though?  When I build locally I get:

> ---
>  bfd/elfxx-mips.c | 40 +++++++++++++++++++++++++++++-----------
>  1 file changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
> index 35bbd86044b..21e6396609b 100644
> --- a/bfd/elfxx-mips.c
> +++ b/bfd/elfxx-mips.c
> @@ -14524,6 +14524,16 @@ struct mips_mach_extension
>    unsigned long extension, base;
>  };
>  
> +/* An array that maps 64-bit architectures to the corresponding 32-bit
> +   architectures.  */
> +static const struct mips_mach_extension mips_mach_32_64[] =
> +{
> +  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
> +  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
> +  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
> +  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
> +  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
> +};
>  
>  /* An array describing how BFD machines relate to one another.  The entries
>     are ordered topologically with MIPS I extensions listed last.  */
> @@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] =
>    { bfd_mach_mips3900, bfd_mach_mips3000 }
>  };
>  
> -/* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
> +/* Return true if bfd machine EXTENSION is the same as BASE, or if
> +   EXTENSION is the 64-bit equivalent of a 32-bit BASE.  */
> +
> +static bool
> +mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
> +{
> +  size_t i;
> +
> +  if (extension == base)
> +    return true;
> +
> +  for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++)

error: ‘mips_mach_64_32’ undeclared (first use in this function); did you mean ‘mips_mach_32_64’?

It looks like the previous patch had the same thing (sorry for not
noticing).  Obviously it's a simple fix, but it would be good to have
some reassurance that the patch has been tested beyond my crude sanity
checks.

Thanks,
Richard

> +    if (extension == mips_mach_32_64[i].extension)
> +      return base == mips_mach_32_64[i].base;
> +
> +  return false;
> +}
>  
>  static bool
>  mips_mach_extends_p (unsigned long base, unsigned long extension)
>  {
>    size_t i;
>  
> -  if (extension == base)
> -    return true;
> -
> -  if (base == bfd_mach_mipsisa32
> -      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
> -    return true;
> -
> -  if (base == bfd_mach_mipsisa32r2
> -      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
> +  if (mips_mach_extends_32_64 (base, extension))
>      return true;
>  
>    for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
>      if (extension == mips_mach_extensions[i].extension)
>        {
>  	extension = mips_mach_extensions[i].base;



> -	if (extension == base)
> +	if (mips_mach_extends_32_64 (base, extension))
>  	  return true;
>        }

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-04-03 14:03     ` Richard Sandiford
@ 2023-04-10  6:48       ` YunQiang Su
  2023-04-10  6:51       ` [PATCH v3] " YunQiang Su
  1 sibling, 0 replies; 12+ messages in thread
From: YunQiang Su @ 2023-04-10  6:48 UTC (permalink / raw)
  To: YunQiang Su, binutils, syq, macro, xry111, jiaxun.yang,
	richard.sandiford

Richard Sandiford <richard.sandiford@arm.com> 于2023年4月3日周一 22:03写道:
>
> YunQiang Su <yunqiang.su@cipunited.com> writes:
> > Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
> > and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
> > to make mipsisa32 and mipsisa64 interlink more systemtic.
> >
> > Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
> > mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
> > so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.
> >
> > Note: R6 is not compatible with pre-R6.
> >
> > bfd/ChangeLog:
> >
> >       * elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
> >         mipsisa64 interlink more systematic.
> >         (mips_mach_32_64): new struct added.
> >         (mips_mach_extends_32_64): new function added.
>
> Sorry for the delay in pushing this.  Could you check whether it's
> the right version though?  When I build locally I get:
>
> > ---
> >  bfd/elfxx-mips.c | 40 +++++++++++++++++++++++++++++-----------
> >  1 file changed, 29 insertions(+), 11 deletions(-)
> >
> > diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
> > index 35bbd86044b..21e6396609b 100644
> > --- a/bfd/elfxx-mips.c
> > +++ b/bfd/elfxx-mips.c
> > @@ -14524,6 +14524,16 @@ struct mips_mach_extension
> >    unsigned long extension, base;
> >  };
> >
> > +/* An array that maps 64-bit architectures to the corresponding 32-bit
> > +   architectures.  */
> > +static const struct mips_mach_extension mips_mach_32_64[] =
> > +{
> > +  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
> > +  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
> > +  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
> > +  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
> > +  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
> > +};
> >
> >  /* An array describing how BFD machines relate to one another.  The entries
> >     are ordered topologically with MIPS I extensions listed last.  */
> > @@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] =
> >    { bfd_mach_mips3900, bfd_mach_mips3000 }
> >  };
> >
> > -/* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
> > +/* Return true if bfd machine EXTENSION is the same as BASE, or if
> > +   EXTENSION is the 64-bit equivalent of a 32-bit BASE.  */
> > +
> > +static bool
> > +mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
> > +{
> > +  size_t i;
> > +
> > +  if (extension == base)
> > +    return true;
> > +
> > +  for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++)
>
> error: ‘mips_mach_64_32’ undeclared (first use in this function); did you mean ‘mips_mach_32_64’?
>
> It looks like the previous patch had the same thing (sorry for not
> noticing).  Obviously it's a simple fix, but it would be good to have
> some reassurance that the patch has been tested beyond my crude sanity
> checks.
>
Yes, it is a typo.
Sorry for it. I won't happen anymore...

> Thanks,
> Richard
>
> > +    if (extension == mips_mach_32_64[i].extension)
> > +      return base == mips_mach_32_64[i].base;
> > +
> > +  return false;
> > +}
> >
> >  static bool
> >  mips_mach_extends_p (unsigned long base, unsigned long extension)
> >  {
> >    size_t i;
> >
> > -  if (extension == base)
> > -    return true;
> > -
> > -  if (base == bfd_mach_mipsisa32
> > -      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
> > -    return true;
> > -
> > -  if (base == bfd_mach_mipsisa32r2
> > -      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
> > +  if (mips_mach_extends_32_64 (base, extension))
> >      return true;
> >
> >    for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
> >      if (extension == mips_mach_extensions[i].extension)
> >        {
> >       extension = mips_mach_extensions[i].base;
>
>
>
> > -     if (extension == base)
> > +     if (mips_mach_extends_32_64 (base, extension))
> >         return true;
> >        }

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-04-03 14:03     ` Richard Sandiford
  2023-04-10  6:48       ` YunQiang Su
@ 2023-04-10  6:51       ` YunQiang Su
  2023-04-12 12:26         ` Richard Sandiford
  1 sibling, 1 reply; 12+ messages in thread
From: YunQiang Su @ 2023-04-10  6:51 UTC (permalink / raw)
  To: binutils
  Cc: syq, macro, xry111, richard.sandiford, jiaxun.yang, amodra, YunQiang Su

Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
to make mipsisa32 and mipsisa64 interlink more systemtic.

Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.

Note: R6 is not compatible with pre-R6.

bfd/ChangeLog:

	* elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
	  mipsisa64 interlink more systematic.
	  (mips_mach_32_64): new struct added.
	  (mips_mach_extends_32_64): new function added.
---
 bfd/elfxx-mips.c | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index d34a755807b..076538fbc53 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -14524,6 +14524,16 @@ struct mips_mach_extension
   unsigned long extension, base;
 };
 
+/* An array that maps 64-bit architectures to the corresponding 32-bit
+   architectures.  */
+static const struct mips_mach_extension mips_mach_32_64[] =
+{
+  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
+  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
+  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
+  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
+  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
+};
 
 /* An array describing how BFD machines relate to one another.  The entries
    are ordered topologically with MIPS I extensions listed last.  */
@@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] =
   { bfd_mach_mips3900, bfd_mach_mips3000 }
 };
 
-/* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
+/* Return true if bfd machine EXTENSION is the same as BASE, or if
+   EXTENSION is the 64-bit equivalent of a 32-bit BASE.  */
 
 static bool
-mips_mach_extends_p (unsigned long base, unsigned long extension)
+mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
 {
   size_t i;
 
   if (extension == base)
     return true;
 
-  if (base == bfd_mach_mipsisa32
-      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
-    return true;
+  for (i = 0; i < ARRAY_SIZE (mips_mach_32_64); i++)
+    if (extension == mips_mach_32_64[i].extension)
+      return base == mips_mach_32_64[i].base;
+
+  return false;
+}
+
+static bool
+mips_mach_extends_p (unsigned long base, unsigned long extension)
+{
+  size_t i;
 
-  if (base == bfd_mach_mipsisa32r2
-      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
+  if (mips_mach_extends_32_64 (base, extension))
     return true;
 
   for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
     if (extension == mips_mach_extensions[i].extension)
       {
 	extension = mips_mach_extensions[i].base;
-	if (extension == base)
+	if (mips_mach_extends_32_64 (base, extension))
 	  return true;
       }
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] MIPS: make mipsisa32 and mipsisa64 link more systematic
  2023-04-10  6:51       ` [PATCH v3] " YunQiang Su
@ 2023-04-12 12:26         ` Richard Sandiford
  0 siblings, 0 replies; 12+ messages in thread
From: Richard Sandiford @ 2023-04-12 12:26 UTC (permalink / raw)
  To: YunQiang Su; +Cc: binutils, syq, macro, xry111, jiaxun.yang, amodra

YunQiang Su <yunqiang.su@cipunited.com> writes:
> Introduce `static const struct mips_mach_extension mips_mach_32_64[]`
> and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`,
> to make mipsisa32 and mipsisa64 interlink more systemtic.
>
> Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and
> mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1),
> so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64.
>
> Note: R6 is not compatible with pre-R6.
>
> bfd/ChangeLog:
>
> 	* elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and
> 	  mipsisa64 interlink more systematic.
> 	  (mips_mach_32_64): new struct added.
> 	  (mips_mach_extends_32_64): new function added.

Thanks, pushed to trunk.

Richard

> ---
>  bfd/elfxx-mips.c | 34 ++++++++++++++++++++++++++--------
>  1 file changed, 26 insertions(+), 8 deletions(-)
>
> diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
> index d34a755807b..076538fbc53 100644
> --- a/bfd/elfxx-mips.c
> +++ b/bfd/elfxx-mips.c
> @@ -14524,6 +14524,16 @@ struct mips_mach_extension
>    unsigned long extension, base;
>  };
>  
> +/* An array that maps 64-bit architectures to the corresponding 32-bit
> +   architectures.  */
> +static const struct mips_mach_extension mips_mach_32_64[] =
> +{
> +  { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
> +  { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
> +  { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
> +  { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
> +  { bfd_mach_mipsisa64,   bfd_mach_mipsisa32 }
> +};
>  
>  /* An array describing how BFD machines relate to one another.  The entries
>     are ordered topologically with MIPS I extensions listed last.  */
> @@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] =
>    { bfd_mach_mips3900, bfd_mach_mips3000 }
>  };
>  
> -/* Return true if bfd machine EXTENSION is an extension of machine BASE.  */
> +/* Return true if bfd machine EXTENSION is the same as BASE, or if
> +   EXTENSION is the 64-bit equivalent of a 32-bit BASE.  */
>  
>  static bool
> -mips_mach_extends_p (unsigned long base, unsigned long extension)
> +mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
>  {
>    size_t i;
>  
>    if (extension == base)
>      return true;
>  
> -  if (base == bfd_mach_mipsisa32
> -      && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
> -    return true;
> +  for (i = 0; i < ARRAY_SIZE (mips_mach_32_64); i++)
> +    if (extension == mips_mach_32_64[i].extension)
> +      return base == mips_mach_32_64[i].base;
> +
> +  return false;
> +}
> +
> +static bool
> +mips_mach_extends_p (unsigned long base, unsigned long extension)
> +{
> +  size_t i;
>  
> -  if (base == bfd_mach_mipsisa32r2
> -      && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
> +  if (mips_mach_extends_32_64 (base, extension))
>      return true;
>  
>    for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
>      if (extension == mips_mach_extensions[i].extension)
>        {
>  	extension = mips_mach_extensions[i].base;
> -	if (extension == base)
> +	if (mips_mach_extends_32_64 (base, extension))
>  	  return true;
>        }

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-04-12 12:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07  2:44 [PATCH] MIPS: allow link o32 objects with mach mips64r6 and mips32r6 YunQiang Su
2023-02-13 15:47 ` Richard Sandiford
2023-02-21  4:06 ` [PATCH] MIPS: make mipsisa32 and mipsisa64 link more systematic YunQiang Su
2023-02-27 14:56   ` Richard Sandiford
2023-03-02  1:52   ` [PATCH v2] " YunQiang Su
2023-03-05 13:38     ` YunQiang Su
2023-03-20  1:32       ` YunQiang Su
2023-04-03  3:59         ` YunQiang Su
2023-04-03 14:03     ` Richard Sandiford
2023-04-10  6:48       ` YunQiang Su
2023-04-10  6:51       ` [PATCH v3] " YunQiang Su
2023-04-12 12:26         ` Richard Sandiford

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).