public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: fix internal error when gas handling unsupported relocation type name.
@ 2023-11-14  1:28 Lulu Cai
  2023-11-14 13:38 ` Xi Ruoyao
  2023-11-15 11:20 ` [PATCH] LoongArch: fix internal error when as handling unsupported modifier Lulu Cai
  0 siblings, 2 replies; 3+ messages in thread
From: Lulu Cai @ 2023-11-14  1:28 UTC (permalink / raw)
  To: binutils
  Cc: xuchenghua, chenglulu, liuzhensong, mengqinggang, xry111,
	i.swmail, maskray, Lulu Cai

---
 bfd/elfxx-loongarch.c                    | 3 ---
 gas/config/loongarch-parse.y             | 6 +++++-
 gas/testsuite/gas/loongarch/reloc_type.d | 3 +++
 gas/testsuite/gas/loongarch/reloc_type.l | 2 ++
 gas/testsuite/gas/loongarch/reloc_type.s | 3 +++
 5 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 gas/testsuite/gas/loongarch/reloc_type.d
 create mode 100644 gas/testsuite/gas/loongarch/reloc_type.l
 create mode 100644 gas/testsuite/gas/loongarch/reloc_type.s

diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c
index a970a257aa9..7f298c08fd3 100644
--- a/bfd/elfxx-loongarch.c
+++ b/bfd/elfxx-loongarch.c
@@ -1629,9 +1629,6 @@ loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 	return lht->bfd_type;
     }
 
-  (*_bfd_error_handler) (_("%pB: unsupported relocation type name %s"),
-			 abfd, l_r_name);
-  bfd_set_error (bfd_error_bad_value);
   return BFD_RELOC_NONE;
 }
 
diff --git a/gas/config/loongarch-parse.y b/gas/config/loongarch-parse.y
index f4e1a63b972..2104afe87e8 100644
--- a/gas/config/loongarch-parse.y
+++ b/gas/config/loongarch-parse.y
@@ -132,7 +132,11 @@ reloc (const char *op_c_str, const char *id_c_str, offsetT addend)
   if (0 == strcmp (op_c_str, "plt"))
     btype = BFD_RELOC_LARCH_B26;
   else
-    btype = loongarch_larch_reloc_name_lookup (NULL, op_c_str);
+    {
+      btype = loongarch_larch_reloc_name_lookup (NULL, op_c_str);
+      if (btype == BFD_RELOC_NONE)
+	as_fatal (_("unsupported relocation type name %s"), op_c_str);
+    }
 
   if (id_c_str)
   {
diff --git a/gas/testsuite/gas/loongarch/reloc_type.d b/gas/testsuite/gas/loongarch/reloc_type.d
new file mode 100644
index 00000000000..0a8f77825a0
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/reloc_type.d
@@ -0,0 +1,3 @@
+#as:
+#source: reloc_type.s
+#error_output: reloc_type.l
diff --git a/gas/testsuite/gas/loongarch/reloc_type.l b/gas/testsuite/gas/loongarch/reloc_type.l
new file mode 100644
index 00000000000..5f048ca0a7d
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/reloc_type.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*Fatal error: unsupported relocation type name (.*)$
diff --git a/gas/testsuite/gas/loongarch/reloc_type.s b/gas/testsuite/gas/loongarch/reloc_type.s
new file mode 100644
index 00000000000..2ce277779db
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/reloc_type.s
@@ -0,0 +1,3 @@
+.L1:
+  nop
+  addi.d $a0,$a1,%reloc(x)
-- 
2.31.1


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

* Re: [PATCH] LoongArch: fix internal error when gas handling unsupported relocation type name.
  2023-11-14  1:28 [PATCH] LoongArch: fix internal error when gas handling unsupported relocation type name Lulu Cai
@ 2023-11-14 13:38 ` Xi Ruoyao
  2023-11-15 11:20 ` [PATCH] LoongArch: fix internal error when as handling unsupported modifier Lulu Cai
  1 sibling, 0 replies; 3+ messages in thread
From: Xi Ruoyao @ 2023-11-14 13:38 UTC (permalink / raw)
  To: Lulu Cai, binutils
  Cc: xuchenghua, chenglulu, liuzhensong, mengqinggang, i.swmail, maskray

On Tue, 2023-11-14 at 09:28 +0800, Lulu Cai wrote:
> diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c
> index a970a257aa9..7f298c08fd3 100644
> --- a/bfd/elfxx-loongarch.c
> +++ b/bfd/elfxx-loongarch.c
> @@ -1629,9 +1629,6 @@ loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
>  	return lht->bfd_type;
>      }
>  
> -  (*_bfd_error_handler) (_("%pB: unsupported relocation type name %s"),
> -			 abfd, l_r_name);
> -  bfd_set_error (bfd_error_bad_value);

Ok, this should not be an internal error.

>    return BFD_RELOC_NONE;
>  }
>  
> diff --git a/gas/config/loongarch-parse.y b/gas/config/loongarch-parse.y
> index f4e1a63b972..2104afe87e8 100644
> --- a/gas/config/loongarch-parse.y
> +++ b/gas/config/loongarch-parse.y
> @@ -132,7 +132,11 @@ reloc (const char *op_c_str, const char *id_c_str, offsetT addend)
>    if (0 == strcmp (op_c_str, "plt"))
>      btype = BFD_RELOC_LARCH_B26;
>    else
> -    btype = loongarch_larch_reloc_name_lookup (NULL, op_c_str);
> +    {
> +      btype = loongarch_larch_reloc_name_lookup (NULL, op_c_str);
> +      if (btype == BFD_RELOC_NONE)
> +	as_fatal (_("unsupported relocation type name %s"), op_c_str);

Maybe "unsupported modifier %s" is better because %xxx is called
"modifier" in the GAS manual, and we also have "%plt" which is not a
relocation type name.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

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

* [PATCH] LoongArch: fix internal error when as handling unsupported modifier.
  2023-11-14  1:28 [PATCH] LoongArch: fix internal error when gas handling unsupported relocation type name Lulu Cai
  2023-11-14 13:38 ` Xi Ruoyao
@ 2023-11-15 11:20 ` Lulu Cai
  1 sibling, 0 replies; 3+ messages in thread
From: Lulu Cai @ 2023-11-15 11:20 UTC (permalink / raw)
  To: binutils
  Cc: xuchenghua, chenglulu, liuzhensong, mengqinggang, xry111,
	i.swmail, maskray, Lulu Cai

---
 bfd/elfxx-loongarch.c                    | 3 ---
 gas/config/loongarch-parse.y             | 6 +++++-
 gas/testsuite/gas/loongarch/reloc_type.d | 3 +++
 gas/testsuite/gas/loongarch/reloc_type.l | 2 ++
 gas/testsuite/gas/loongarch/reloc_type.s | 3 +++
 5 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 gas/testsuite/gas/loongarch/reloc_type.d
 create mode 100644 gas/testsuite/gas/loongarch/reloc_type.l
 create mode 100644 gas/testsuite/gas/loongarch/reloc_type.s

diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c
index a970a257aa9..7f298c08fd3 100644
--- a/bfd/elfxx-loongarch.c
+++ b/bfd/elfxx-loongarch.c
@@ -1629,9 +1629,6 @@ loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 	return lht->bfd_type;
     }
 
-  (*_bfd_error_handler) (_("%pB: unsupported relocation type name %s"),
-			 abfd, l_r_name);
-  bfd_set_error (bfd_error_bad_value);
   return BFD_RELOC_NONE;
 }
 
diff --git a/gas/config/loongarch-parse.y b/gas/config/loongarch-parse.y
index f4e1a63b972..f786fdaee5f 100644
--- a/gas/config/loongarch-parse.y
+++ b/gas/config/loongarch-parse.y
@@ -132,7 +132,11 @@ reloc (const char *op_c_str, const char *id_c_str, offsetT addend)
   if (0 == strcmp (op_c_str, "plt"))
     btype = BFD_RELOC_LARCH_B26;
   else
-    btype = loongarch_larch_reloc_name_lookup (NULL, op_c_str);
+    {
+      btype = loongarch_larch_reloc_name_lookup (NULL, op_c_str);
+      if (btype == BFD_RELOC_NONE)
+	as_fatal (_("unsupported modifier %s"), op_c_str);
+    }
 
   if (id_c_str)
   {
diff --git a/gas/testsuite/gas/loongarch/reloc_type.d b/gas/testsuite/gas/loongarch/reloc_type.d
new file mode 100644
index 00000000000..0a8f77825a0
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/reloc_type.d
@@ -0,0 +1,3 @@
+#as:
+#source: reloc_type.s
+#error_output: reloc_type.l
diff --git a/gas/testsuite/gas/loongarch/reloc_type.l b/gas/testsuite/gas/loongarch/reloc_type.l
new file mode 100644
index 00000000000..e981f6f2aa5
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/reloc_type.l
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*Fatal error: unsupported modifier (.*)$
diff --git a/gas/testsuite/gas/loongarch/reloc_type.s b/gas/testsuite/gas/loongarch/reloc_type.s
new file mode 100644
index 00000000000..2ce277779db
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/reloc_type.s
@@ -0,0 +1,3 @@
+.L1:
+  nop
+  addi.d $a0,$a1,%reloc(x)
-- 
2.36.0


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

end of thread, other threads:[~2023-11-15 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-14  1:28 [PATCH] LoongArch: fix internal error when gas handling unsupported relocation type name Lulu Cai
2023-11-14 13:38 ` Xi Ruoyao
2023-11-15 11:20 ` [PATCH] LoongArch: fix internal error when as handling unsupported modifier Lulu Cai

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