[llvm-bugs] [Bug 35371] New: [OrcJIT] Incorrect symbol resolution of libc function addresses on MacOS
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Nov 20 16:23:53 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35371
Bug ID: 35371
Summary: [OrcJIT] Incorrect symbol resolution of libc function
addresses on MacOS
Product: libraries
Version: 3.9
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: OrcJIT
Assignee: unassignedbugs at nondot.org
Reporter: 1101.debian at gmail.com
CC: llvm-bugs at lists.llvm.org
Created attachment 19450
--> https://bugs.llvm.org/attachment.cgi?id=19450&action=edit
JIT runner source code
(Related to https://bugs.llvm.org/show_bug.cgi?id=35370).
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:
https://bugs.llvm.org/show_bug.cgi?id=35370
--
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/20171121/c4d07b7b/attachment-0001.html>
More information about the llvm-bugs
mailing list