<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [MC] X86 intel syntax: push immediate misassembled to a 16 bit push"
href="https://llvm.org/bugs/show_bug.cgi?id=27508">27508</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[MC] X86 intel syntax: push immediate misassembled to a 16 bit push
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>teeemcee@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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 (<a href="http://llvm.org/">http://llvm.org/</a>):
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>