Shamil Kurmangaleev
2012-Mar-13 13:27 UTC
[LLVMdev] MC JIT on ARM can't generate valid code for external functions call
Hello. We found the following problem with MC JIT, on ARM it can't generate valid code for instruction "bl <external_function>" like: bl printf Because the ELF file in memory generated by MC JIT does not have the .plt section, but we need to have the following code to be emitted in it: .plt:00008290 STR LR, [SP,#-4]! .plt:00008294 LDR LR, =_GLOBAL_OFFSET_TABLE_ ; PIC mode .plt:00008298 NOP .plt:0000829C LDR PC, [LR,#8]! Also GOT section doesn't exists. To fix this we need to generate the valid entries in GOT and PLT sections We propose adding these sections and generating a thunk, same as in the usual compilation pipeline. What is the best way to fix these issues? --- Kurmangaleev Shamil,
Joerg Sonnenberger
2012-Mar-13 13:47 UTC
[LLVMdev] MC JIT on ARM can't generate valid code for external functions call
On Tue, Mar 13, 2012 at 05:27:58PM +0400, Shamil Kurmangaleev wrote:> Because the ELF file in memory generated by MC JIT does not have the > .plt section, but we need to have the following code to be emitted in it:Why do you need it to emit PIC? You know the offsets of all functions it is calling. Joerg
kursh
2012-Mar-13 20:19 UTC
[LLVMdev] MC JIT on ARM can't generate valid code for external functions call
Instruction BL in the ARM mode can jump by offset +/- 32 MB only. If using absolute offset, we need generate a few additional instructions same as: load offset into register and jump to address from register, or save LR, and load into PC offset. But in both cases change size of code in the function will lead to possibility invalidate offsets computed in the "ARM constant island placement and branch shortening pass" and we still need in the thunk. --- Kurmangaleev Shamil 13.03.2012 17:47, Joerg Sonnenberger пишет: On Tue, Mar 13, 2012 at 05:27:58PM +0400, Shamil Kurmangaleev wrote: Because the ELF file in memory generated by MC JIT does not have the .plt section, but we need to have the following code to be emitted in it: Why do you need it to emit PIC? You know the offsets of all functions it is calling. Joerg _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu [1] http://llvm.cs.uiuc.edu [2] http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev [3] Links: ------ [1] mailto:LLVMdev at cs.uiuc.edu [2] http://llvm.cs.uiuc.edu [3] http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120314/ea508aab/attachment.html>
Kaylor, Andrew
2012-Mar-13 22:24 UTC
[LLVMdev] MC JIT on ARM can't generate valid code for external functions call
There is a patch in progress (http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120220/137666.html -- I think it's still just in progress) which refactors the MCJIT dynamic loading and adds some new features. I believe that support for external functions on ARM is one of the features that was added. -Andy -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Shamil Kurmangaleev Sent: Tuesday, March 13, 2012 6:28 AM To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] MC JIT on ARM can't generate valid code for external functions call Hello. We found the following problem with MC JIT, on ARM it can't generate valid code for instruction "bl <external_function>" like: bl printf Because the ELF file in memory generated by MC JIT does not have the .plt section, but we need to have the following code to be emitted in it: .plt:00008290 STR LR, [SP,#-4]! .plt:00008294 LDR LR, =_GLOBAL_OFFSET_TABLE_ ; PIC mode .plt:00008298 NOP .plt:0000829C LDR PC, [LR,#8]! Also GOT section doesn't exists. To fix this we need to generate the valid entries in GOT and PLT sections We propose adding these sections and generating a thunk, same as in the usual compilation pipeline. What is the best way to fix these issues? --- Kurmangaleev Shamil, _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Maybe Matching Threads
- [LLVMdev] MC JIT on ARM can't generate valid code for external functions call
- [LLVMdev] [Patch] Let MC/ELF generate Thumb/Thumb-2 are properly
- [LLVMdev] [Patch] Let MC/ELF generate Thumb/Thumb-2 are properly
- [LLVMdev] [Patch] Let MC/ELF generate Thumb/Thumb-2 are properly
- [LLVMdev] [Patch] Let MC/ELF generate Thumb/Thumb-2 are properly