[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


http://llvm.org/bugs/show_bug.cgi?id=10397

           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
.LC0:
    .string    "Hello!"
    .text
.globl main
    .type    main, @function
main:
.LFB0:
    .cfi_startproc
    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)
.L2:
    movl    $.LC0, %edi
    call    puts
    jmp    .L2   ; <<<<<< THIS ONE
    .cfi_endproc
.LFE0:
    .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