[llvm-bugs] [Bug 27508] New: [MC] X86 intel syntax: push immediate misassembled to a 16 bit push
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Mon Apr 25 03:49:27 PDT 2016
    
    
  
https://llvm.org/bugs/show_bug.cgi?id=27508
            Bug ID: 27508
           Summary: [MC] X86 intel syntax: push immediate misassembled to
                    a 16 bit push
           Product: libraries
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: teeemcee at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified
When assembling with intel syntax for i386, pushing an immediate which has a
value between -128 and 127 causes a pushw instruction to be emitted (decrements
esp by 2 bytes) instead of the correct pushl (decrements by 4 bytes). pushw is
selected by the 0x66 prefix.
    > echo 'push 0' | llvm-mc -triple i386-unknown-unknown
--x86-asm-syntax=intel -filetype obj | llvm-objdump -d -
    ...
           0:    66 6a 00     pushw    $0
(Outputting -filetype asm directly shows the same result)
Each of pushw and pushl has two different opcodes, 0x6a for 8 bit immediate,
and 0x68 for a 16 or 32bit immediate.
If the value doesn't fit in 8 bits, the correct opcode is emitted:
    > echo 'push 128' | llvm-mc -triple i386-unknown-unknown
--x86-asm-syntax=intel -filetype obj | llvm-objdump -d -
    ...
           0:    68 80 00 00 00     pushl    $128
There's no problem when using at&t syntax:
    > echo 'push $0' | llvm-mc -triple i386-unknown-unknown
--x86-asm-syntax=att -filetype obj | llvm-objdump -d -
    ...
           0:    6a 00     pushl    $0
Nor when targetting x86_64:
    > echo 'push 0' | llvm-mc -triple x86_64-unknown-unknown
--x86-asm-syntax=intel -filetype obj | llvm-objdump -d -
    ...
           0:    6a 00     pushq    $0
llvm-mc is latest stable:
    LLVM (http://llvm.org/):
      LLVM version 3.8.0
      Optimized build.
      Built Mar  8 2016 (17:36:36).
      Default target: x86_64-unknown-linux-gnu
      Host CPU: amdfam10
I actually couldn't figure out what the intel syntax equivalent for pushw is,
if any exists. Anyone know? It doesn't appear to be very popular on
i386/x86_64.
-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160425/fc878af6/attachment.html>
    
    
More information about the llvm-bugs
mailing list