Bug in codegen_backend_x86_ops.c

Support and general discussion.
Post Reply
Manaphy
Posts: 15
Joined: Sat 18 May, 2019 7:26 pm

Bug in codegen_backend_x86_ops.c

Post by Manaphy »

The bug occurs in this function:

Code: Select all

void host_x86_MOV32_STACK_IMM(codeblock_t *block, int32_t offset, uint32_t imm_data)
{
        if (!offset)
        {
                codegen_alloc_bytes(block, 7);
                codegen_addbyte3(block, 0xc7, 0x04, 0x24); /*MOV [ESP], imm_data*/
                codegen_addlong(block, imm_data);
        }
        else if (offset >= -80 || offset < 0x80)
        {
                codegen_alloc_bytes(block, 8);
                codegen_addbyte4(block, 0xc7, 0x44, 0x24, offset & 0xff); /*MOV offset[ESP], imm_data*/
                codegen_addlong(block, imm_data);
        }
        else
        {
                codegen_alloc_bytes(block, 11);
                codegen_addbyte3(block, 0xc7, 0x84, 0x24); /*MOV offset[ESP], imm_data*/
                codegen_addlong(block, offset);
                codegen_addlong(block, imm_data);
        }
}
That else if block seems to catch every value of offset that is not zero, so the else block at the end is never called. I think this is a bug.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Bug in codegen_backend_x86_ops.c

Post by SarahWalker »

Good spot! Fixed in rev 1481.
Post Reply