<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 - [OrcJIT] Incorrect symbol resolution of libc function addresses on MacOS"
href="https://bugs.llvm.org/show_bug.cgi?id=35371">35371</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[OrcJIT] Incorrect symbol resolution of libc function addresses on MacOS
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</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>OrcJIT
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>1101.debian@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19450" name="attach_19450" title="JIT runner source code">attachment 19450</a> <a href="attachment.cgi?id=19450&action=edit" title="JIT runner source code">[details]</a></span>
JIT runner source code
(Related to <a class="bz_bug_link
bz_status_NEW "
title="NEW - Cannot use object files with OrcJIT on MacOS"
href="show_bug.cgi?id=35370">https://bugs.llvm.org/show_bug.cgi?id=35370</a>).
I feed an object file to the ObjectLinkingLayer and the run the 'main' function
that is defined in the object file. It works on Linux but does not on MacOS.
On MacOS it simply crashes saying:
error: memory read failed for 0x8af86200
After debugging, I discovered what leads to this behavior. The crash happens
around this code:
/// Disasm from LLDB
0x1035a9287: cmpl $0x1, -0x8(%rbp)
0x1035a928b: movl %eax, -0x24(%rbp)
0x1035a928e: jne 0x1035a92b1
0x1035a9294: leaq -0x1190(%rip), %rdi
0x1035a929b: movb $0x0, %al
0x1035a929d: callq 0x8adf0180
This assembly corresponds to the following code extracted from the object file
using otool (otool -tV main.o):
/// Original code
000000000032 callq _printf
000000000037 cmpl $0x1, -0x8(%rbp)
00000000003b movl %eax, -0x24(%rbp)
00000000003e jne 0x61
000000000044 leaq 0x160(%rip), %rdi ## literal pool for: "no test
specified\n"
00000000004b movb $0x0, %al
00000000004d callq _printf
After few iterations, I discovered that the instruction in the original code
preceding the first instruction in the disassembled code from LLDB is always
has something to do with a libc function. In fact, if I remove any such calls
then everything works just fine.
Also, it works correctly on Linux.
Note: the code is working if I compile jit runner with address sanitizer
enabled.
Another note: I am not sure if it is the actual bug in the Orc itself or I am
doing something wrong.
I attach the JIT runner (main.cpp).
I compiled it using the following command:
clang++ `llvm-config --cxxflags` `llvm-config --libs` -lz -lncurses main.cpp -o
jitter
The I built simple 'hello world' program:
clang++ -c main.cpp
And fed it to the runner:
./jitter main.o
P.S. I tried to reproduce it using LLVM 5.0 but hit another problem:
<a class="bz_bug_link
bz_status_NEW "
title="NEW - Cannot use object files with OrcJIT on MacOS"
href="show_bug.cgi?id=35370">https://bugs.llvm.org/show_bug.cgi?id=35370</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>