Open Quuxplusone opened 7 years ago
Attached min.c
(2780 bytes, text/x-csrc): Code to reproduce the problem
Might not be a bug, because using LLVMRelocPIC for the relocation model solves the problem.
Hi Vlad,
Sorry for the late response. Were you able to solve this?
For now, even in LLM 10, JIT'd code on Linux requires use of the large code model to avoid direct PC-relative calls (calls should be indirect through registers instead). If you're seeing a direct branch my first inclination would be to check the code model.
This situation should change soon: We already support the small code model for MachO objects linked with JITLink (LLVM's new JIT linker). Hopefully we will get an ELF version of JITLink soon and we will be able to avoid this issue on Linux too.
min.c
(2780 bytes, text/x-csrc)Created attachment 18271 Code to reproduce the problem
Debian 8, using llvm 4.0, as well as the trunk, when running the attached code I get a segfault.
It looks like the generated call is of the near, ip-relative type, and when the symbol is resolved, the offset is incorrect, as it can't fit into 32-bit allowed for that type of instruction.
$ clang -g min.c
llvm-config --cflags --ldflags --system-libs --libs core orcjit native
-rdynamic -lstdc++ -o min $ gdb min $ (gdb) run $ Program received signal SIGSEGV, Segmentation fault. $ 0x00007ffff7ff0001 in ?? () $ (gdb) x/i 0x00007ffff7ff0001 $ => 0x7ffff7ff0001: callq 0x800000edbd50