]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
RISC-V: widen LEB128 support
authorJan Beulich <jbeulich@suse.com>
Fri, 31 Jan 2025 09:04:01 +0000 (10:04 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 31 Jan 2025 09:04:01 +0000 (10:04 +0100)
Do away with at least one of the limitations - all other targets permit
multiple values to be specified with a single directive. Re-arrange the
logic further to also overcome an internal error in
riscv_insert_uleb128_fixes(), as e.g. observed by the all/sleb128-2
testcase. This way there's also no need to parse expressions twice,
thus also not raising the same diagnostics (if any) twice.

Note how this addresses a pre-existing XFAIL (where the comment wasn't
really applicable either for RISC-V).

Also update documentation, also to mention that differences between
symbols may be used with .uleb128 (albeit I'm uncertain whether there
are limitations).

gas/config/tc-riscv.c
gas/doc/c-riscv.texi
gas/testsuite/gas/elf/dwarf2-6.d

index e219dd21af89bc349b67119a38e7b0791b11f535..79ff0832bedd5ff92c9db2f297ca9f3364b77b3c 100644 (file)
@@ -5441,19 +5441,22 @@ riscv_elf_final_processing (void)
 static void
 s_riscv_leb128 (int sign)
 {
-  expressionS exp;
-  char *save_in = input_line_pointer;
+  do
+    {
+      expressionS exp;
 
-  expression (&exp);
-  if (sign && exp.X_op != O_constant)
-    as_bad (_("non-constant .sleb128 is not supported"));
-  else if (!sign && exp.X_op != O_constant && exp.X_op != O_subtract)
-    as_bad (_(".uleb128 only supports constant or subtract expressions"));
+      expression (&exp);
+      if (sign && exp.X_op != O_constant)
+       as_bad (_("non-constant .sleb128 is not supported"));
+      else if (!sign && exp.X_op != O_constant && exp.X_op != O_subtract)
+       as_bad (_(".uleb128 only supports constant or subtract expressions"));
+      else
+       emit_leb128_expr (&exp, sign);
+    }
+  while (*input_line_pointer++ == ',');
 
+  input_line_pointer--;
   demand_empty_rest_of_line ();
-
-  input_line_pointer = save_in;
-  return s_leb128 (sign);
 }
 
 /* Parse the .insn directive.  There are three formats,
index d2e47455e7c7733aa7eaab12572737f3fe80a7ed..10cb772b2ed9683920e06e5a874fe4ba99ba830a 100644 (file)
@@ -139,12 +139,13 @@ meant to be used by the compiler in shared libraries for DWARF debug info for
 thread local variables.
 
 @cindex LEB128 directives
-@item .uleb128 @var{value}
-@itemx .sleb128 @var{value}
-Emits a signed or unsigned LEB128 value at the current position.  This only
+@item .uleb128 @var{values}
+@itemx .sleb128 @var{values}
+Emits signed or unsigned LEB128 values at the current position.  This only
 accepts constant expressions, because symbol addresses can change with
 relaxation, and we don't support relocations to modify LEB128 values at link
-time.
+time.  An exception are differences between symbols, which may be used with
+@code{.uleb128}.
 
 @cindex Option directive
 @cindex @code{option} directive
index 90747c90515bfbd958f9c13b6e96fbcf3c0bd399..f7af5783c0efc41e34f9fada4029bf4939e6cf42 100644 (file)
@@ -2,7 +2,7 @@
 #readelf: -wlL
 #name: DWARF2 6
 # These targets either do not support or do not evaluate the subtraction of symbols at assembly time.
-#xfail: cr16-* crx-* riscv*-*
+#xfail: cr16-* crx-*
 
 Raw dump of debug contents of section .debug_line: