]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: switch convert_to_bignum() to taking just an expression
authorJan Beulich <jbeulich@suse.com>
Fri, 13 Jun 2025 06:40:01 +0000 (08:40 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 13 Jun 2025 06:40:01 +0000 (08:40 +0200)
Both callers, despite spelling things differently, now pass the same
input for its 2nd parameter. Therefore, as was supposed to be the case
anyway, this 2nd parameter isn't needed anymore - the function can
calculate "sign" all by itself from the incoming expression. Instead
make the function return the resulting value, for emit_expr_with_reloc()
to consume for setting its "extra_digit" local variable.

gas/read.c

index 1b483d683d5d36ba8cbc267f557dd1c6426f05c8..db9c76270ee734a95f6c7b25bfcfeeec5b875368 100644 (file)
@@ -1437,14 +1437,15 @@ read_a_source_file (const char *name)
 #endif
 }
 
-/* Convert O_constant expression EXP into the equivalent O_big representation.
-   Take the sign of the number from SIGN rather than X_add_number.  */
+/* Convert O_constant expression EXP into the equivalent O_big
+   representation.  */
 
-static void
-convert_to_bignum (expressionS *exp, int sign)
+static bool
+convert_to_bignum (expressionS *exp)
 {
   valueT value;
   unsigned int i;
+  bool sign = !exp->X_unsigned && exp->X_extrabit;
 
   value = exp->X_add_number;
   for (i = 0; i < sizeof (exp->X_add_number) / CHARS_PER_LITTLENUM; i++)
@@ -1459,6 +1460,8 @@ convert_to_bignum (expressionS *exp, int sign)
   exp->X_op = O_big;
   exp->X_add_number = i;
   exp->X_unsigned = !sign;
+
+  return sign;
 }
 
 /* For most MRI pseudo-ops, the line actually ends at the first
@@ -4652,8 +4655,7 @@ emit_expr_with_reloc (expressionS *exp,
      pass to md_number_to_chars, handle it as a bignum.  */
   if (op == O_constant && nbytes > sizeof (valueT))
     {
-      extra_digit = exp->X_unsigned ? 0 : -exp->X_extrabit;
-      convert_to_bignum (exp, -extra_digit);
+      extra_digit = -convert_to_bignum (exp);
       op = O_big;
     }
 
@@ -5379,7 +5381,7 @@ emit_leb128_expr (expressionS *exp, int sign)
       /* We're outputting a signed leb128 and the sign of X_add_number
         doesn't reflect the sign of the original value.  Convert EXP
         to a correctly-extended bignum instead.  */
-      convert_to_bignum (exp, !exp->X_unsigned && exp->X_extrabit);
+      convert_to_bignum (exp);
       op = O_big;
     }