]> git.proxmox.com Git - mirror_qemu.git/commitdiff
target-i386: Don't left shift negative constant
authorEduardo Habkost <ehabkost@redhat.com>
Tue, 29 Sep 2015 20:34:23 +0000 (17:34 -0300)
committerEduardo Habkost <ehabkost@redhat.com>
Tue, 27 Oct 2015 17:52:11 +0000 (15:52 -0200)
Left shift of negative values is undefined behavior. Detected by clang:
  qemu/target-i386/translate.c:2423:26: runtime error:
    left shift of negative value -8

This changes the code to reverse the sign after the left shift.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
target-i386/translate.c

index 764b1e44b75e474cd65909c08365541046688982..862f8e09fbd8dc414cb427ed81c00d7f3902e238 100644 (file)
@@ -2432,7 +2432,7 @@ static void gen_pusha(DisasContext *s)
 {
     int i;
     gen_op_movl_A0_reg(R_ESP);
-    gen_op_addl_A0_im(-8 << s->dflag);
+    gen_op_addl_A0_im(-(8 << s->dflag));
     if (!s->ss32)
         tcg_gen_ext16u_tl(cpu_A0, cpu_A0);
     tcg_gen_mov_tl(cpu_T[1], cpu_A0);