[PATCH] i386: Use TESTB instead of TESTL in ____longjmp_chk()

H.J. Lu hjl.tools@gmail.com
Wed Aug 20 03:07:40 GMT 2025


On Mon, Aug 18, 2025 at 2:20 AM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> There is no need to use TESTL when checking the least-significant bit
> with a TEST instruction. Use TESTB, which is three bytes shorter:
>
>    f6 44 24 04 01          testb  $0x1,0x4(%esp)
>
> vs:
>
>    f7 44 24 04 01 00 00    testl  $0x1,0x4(%esp)
>    00
>
> for the same effect.
>
> No functional changes intended.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: H.J.Lu <hjl.tools@gmail.com>
> Cc: Carlos O'Donell <carlos@redhat.com>
> ---
>  sysdeps/unix/sysv/linux/i386/____longjmp_chk.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S b/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
> index e468d346d6..3e09f15662 100644
> --- a/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
> +++ b/sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
> @@ -67,7 +67,7 @@ ENTRY (____longjmp_chk)
>         /* Without working sigaltstack we cannot perform the test.  */
>         test    %eax, %eax
>         jne     .Lok2
> -       testl   $1, 4(%esp)
> +       testb   $1, 4(%esp)
>         jz      .Lfail
>
>         movl    (%esp), %eax
> --
> 2.50.1
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.

-- 
H.J.


More information about the Libc-alpha mailing list