[2/6] x86: make offset_in_range()'s warning contents useful (again)

Message ID 0c9cb550-5e15-1c87-c8d4-ea08c0467760@suse.com
State New
Headers show
Series
  • x86: further value overflow diagnostic adjustments
Related show

Commit Message

Luis Machado via Binutils June 14, 2021, 10:25 a.m.
In case there is something which gets shortened (perhaps only on a BFD64
build targeting a 32-bit binary), seeing the full original value is
often helpful to understand what's actually going wrong. Of course for
non-64-bit binaries we better wouldn't be seeing such warnings at all,
as they're often indicative of a behavioral difference between BFD64 and
!BFD64 builds.

Prior to "gas: drop sprint_value()", which introduced the use of
bfd_sprintf_vma(), the output had other shortcomings.

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

	* config/tc-i386.c (offset_in_range): Replace uses of
	bfd_sprintf_vma.

Comments

Luis Machado via Binutils June 17, 2021, 2:40 p.m. | #1
On Mon, Jun 14, 2021 at 3:25 AM Jan Beulich <jbeulich@suse.com> wrote:
>

> In case there is something which gets shortened (perhaps only on a BFD64

> build targeting a 32-bit binary), seeing the full original value is

> often helpful to understand what's actually going wrong. Of course for

> non-64-bit binaries we better wouldn't be seeing such warnings at all,

> as they're often indicative of a behavioral difference between BFD64 and

> !BFD64 builds.

>

> Prior to "gas: drop sprint_value()", which introduced the use of

> bfd_sprintf_vma(), the output had other shortcomings.

>

> gas/

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

>

>         * config/tc-i386.c (offset_in_range): Replace uses of

>         bfd_sprintf_vma.

>

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

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

> @@ -2564,13 +2564,9 @@ offset_in_range (offsetT val, int size)

>      }

>

>    if ((val & ~mask) != 0 && (-val & ~mask) != 0)

> -    {

> -      char buf1[40], buf2[40];

> +    as_warn (_("%"BFD_VMA_FMT"x shortened to %"BFD_VMA_FMT"x"),

> +             val, val & mask);

>

> -      bfd_sprintf_vma (stdoutput, buf1, val);

> -      bfd_sprintf_vma (stdoutput, buf2, val & mask);

> -      as_warn (_("%s shortened to %s"), buf1, buf2);

> -    }

>    return val & mask;

>  }

>

>


OK.

Thanks.

-- 
H.J.

Patch

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2564,13 +2564,9 @@  offset_in_range (offsetT val, int size)
     }
 
   if ((val & ~mask) != 0 && (-val & ~mask) != 0)
-    {
-      char buf1[40], buf2[40];
+    as_warn (_("%"BFD_VMA_FMT"x shortened to %"BFD_VMA_FMT"x"),
+             val, val & mask);
 
-      bfd_sprintf_vma (stdoutput, buf1, val);
-      bfd_sprintf_vma (stdoutput, buf2, val & mask);
-      as_warn (_("%s shortened to %s"), buf1, buf2);
-    }
   return val & mask;
 }