[LLVMbugs] [Bug 10397] New: X86 Disassembler Gives Wrong Sign for short JMP

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 18 13:31:38 PDT 2011


           Summary: X86 Disassembler Gives Wrong Sign for short JMP
           Product: new-bugs
           Version: 2.9
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: lally.singh at gmail.com
                CC: llvmbugs at cs.uiuc.edu

I'm disassembling an executable, but the MCInst for a JMP instruction seems to
have the wrong offset (or rather, doesn't preserve the original sign).

The original assembly (from gcc -S):
    .file    "hello.c"
    .section    .rodata
    .string    "Hello!"
.globl main
    .type    main, @function
    pushq    %rbp
    .cfi_def_cfa_offset 16
    movq    %rsp, %rbp
    .cfi_offset 6, -16
    .cfi_def_cfa_register 6
    subq    $16, %rsp
    movl    %edi, -4(%rbp)
    movq    %rsi, -16(%rbp)
    movl    $.LC0, %edi
    call    puts
    jmp    .L2   ; <<<<<< THIS ONE
    .size    main, .-main
    .ident    "GCC: (Ubuntu 4.4.3-4ubuntu5) 4.4.3"
    .section    .note.GNU-stack,"", at progbits

Main disassembles to:
Seeking to offset 1316 for executable's 27 bytes.
 55 48 89 e5 48 83 ec 10 89 7d fc 48 89 75 f0 bf
 2c 06 40 00 e8 db fe ff ff eb f4
0 [1899]:     pushq    %rbp
1 [1302]:     movq    %rsp, %rbp
4 [2311]:     subq    $16, %rsp
8 [1275]:     movl    %edi, -4(%rbp)
11 [1291]:     movq    %rsi, -16(%rbp)
15 [1280]:     movl    $4195884, %edi
20 [275]:     callq    -293
25 [936]:     jmp    244   ; <<<< BAD!

The 244 as the argument to JMP seems to be the 2's complement inverse of what
it should be.

Linux 64-bit x86.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list