]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LoongArch: fix internal error when as handling unsupported modifier.
authorLulu Cai <cailulu@loongson.cn>
Wed, 15 Nov 2023 11:20:53 +0000 (19:20 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Wed, 22 Nov 2023 06:39:35 +0000 (14:39 +0800)
bfd/elfxx-loongarch.c
gas/config/loongarch-parse.y
gas/testsuite/gas/loongarch/reloc_type.d [new file with mode: 0644]
gas/testsuite/gas/loongarch/reloc_type.l [new file with mode: 0644]
gas/testsuite/gas/loongarch/reloc_type.s [new file with mode: 0644]

index a970a257aa9b324fba66a1c1b88dba6b9599df40..7f298c08fd3215f96dbab920d04d1499e96c2b2f 100644 (file)
@@ -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;
 }
 
index f4e1a63b972eb3d3963e82032eacfacddb267185..f786fdaee5f3064660f495e3dd4f578503c5bf09 100644 (file)
@@ -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 (file)
index 0000000..0a8f778
--- /dev/null
@@ -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 (file)
index 0000000..e981f6f
--- /dev/null
@@ -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 (file)
index 0000000..2ce2777
--- /dev/null
@@ -0,0 +1,3 @@
+.L1:
+  nop
+  addi.d $a0,$a1,%reloc(x)