<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - inline assembly incompatibility between gcc and clang - mov with offset in intel dialect"
href="https://bugs.llvm.org/show_bug.cgi?id=32530">32530</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>inline assembly incompatibility between gcc and clang - mov with offset in intel dialect
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>superjoe30@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I believe I have found one of these "as-needed" cases for inline assembly:
<span class="quote">> LLVM’s support is often implemented on an ‘as-needed’ basis, to support C inline asm code which was supported by GCC. A mismatch in behavior between LLVM and GCC likely indicates a bug in LLVM.</span >
Here is a simple program to print "Hello, world!" on x86_64 Linux:
.intel_syntax noprefix
.text
.globl _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, offset msg
mov rdx, 14
syscall
mov rax, 60
mov rdi, 0
syscall
.data
msg:
.ascii "Hello, world!\n"
GCC:
$ gcc -o hello hello.s -nostdlib && ./hello
Hello, world!
Clang:
$ clang -o hello hello.s -nostdlib && ./hello
hello.s:8:24: error: unknown token in expression
mov rsi, offset msg
^
I believe the `offset` keyword is the only way to emit a `mov` with the
effective address instead of the dereferenced address.
Related to <a class="bz_bug_link
bz_status_NEW "
title="NEW - [x86asm intel syntax] `mov` with a symbol from a .set directive not handled correctly (?)"
href="show_bug.cgi?id=22511">https://bugs.llvm.org/show_bug.cgi?id=22511</a>
More details: <a href="http://stackoverflow.com/questions/43223287/">http://stackoverflow.com/questions/43223287/</a></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>