[1/5] x86: don't truncate values in diagnostics and alike

Message ID c055e372-3117-fd63-2640-c64aef6541af@suse.com
State New
Headers show
Series
  • x86: assorted relocation handling related adjustment (part I)
Related show

Commit Message

Florian Weimer via Binutils April 22, 2021, 8:38 a.m.
Truncating an expression's X_add_number to just "long" can result in
confusing output (e.g. an apparently in-range number claimed to be out
of range). Use the abstraction that bfd provides for this.

Take the opportunity and also insert a missing "of".

gas/
2021-04-XX  Jan Beulich  <jbeulich@suse.com>

	* config/tc-i386.c (pe): Don't truncate expression value.
	(i386_finalize_displacement): Likewise.

Comments

Florian Weimer via Binutils April 22, 2021, 11:55 a.m. | #1
On Thu, Apr 22, 2021 at 1:38 AM Jan Beulich <jbeulich@suse.com> wrote:
>

> Truncating an expression's X_add_number to just "long" can result in

> confusing output (e.g. an apparently in-range number claimed to be out

> of range). Use the abstraction that bfd provides for this.

>

> Take the opportunity and also insert a missing "of".

>

> gas/

> 2021-04-XX  Jan Beulich  <jbeulich@suse.com>

>

>         * config/tc-i386.c (pe): Don't truncate expression value.

>         (i386_finalize_displacement): Likewise.

>

> --- a/gas/config/tc-i386.c

> +++ b/gas/config/tc-i386.c

> @@ -3297,8 +3297,8 @@ static void

>  pe (expressionS *e)

>  {

>    fprintf (stdout, "    operation     %d\n", e->X_op);

> -  fprintf (stdout, "    add_number    %ld (%lx)\n",

> -          (long) e->X_add_number, (long) e->X_add_number);

> +  fprintf (stdout, "    add_number    %" BFD_VMA_FMT "d (%" BFD_VMA_FMT "x)\n",

> +          e->X_add_number, e->X_add_number);

>    if (e->X_add_symbol)

>      {

>        fprintf (stdout, "    add_symbol    ");

> @@ -10922,8 +10922,8 @@ i386_finalize_displacement (segT exp_seg

>           i.types[this_operand].bitfield.disp32s = 0;

>           if (i.types[this_operand].bitfield.baseindex)

>             {

> -             as_bad (_("0x%lx out range of signed 32bit displacement"),

> -                     (long) exp->X_add_number);

> +             as_bad (_("0x%" BFD_VMA_FMT "x out of range of signed 32bit displacement"),

> +                     exp->X_add_number);

>               ret = 0;

>             }

>         }

>


OK.

Thanks.

-- 
H.J.

Patch

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -3297,8 +3297,8 @@  static void
 pe (expressionS *e)
 {
   fprintf (stdout, "    operation     %d\n", e->X_op);
-  fprintf (stdout, "    add_number    %ld (%lx)\n",
-	   (long) e->X_add_number, (long) e->X_add_number);
+  fprintf (stdout, "    add_number    %" BFD_VMA_FMT "d (%" BFD_VMA_FMT "x)\n",
+	   e->X_add_number, e->X_add_number);
   if (e->X_add_symbol)
     {
       fprintf (stdout, "    add_symbol    ");
@@ -10922,8 +10922,8 @@  i386_finalize_displacement (segT exp_seg
 	  i.types[this_operand].bitfield.disp32s = 0;
 	  if (i.types[this_operand].bitfield.baseindex)
 	    {
-	      as_bad (_("0x%lx out range of signed 32bit displacement"),
-		      (long) exp->X_add_number);
+	      as_bad (_("0x%" BFD_VMA_FMT "x out of range of signed 32bit displacement"),
+		      exp->X_add_number);
 	      ret = 0;
 	    }
 	}