[LLVMdev] MC JIT on ARM can't generate valid code for external functions call

Shamil Kurmangaleev kursh at ispras.ru
Tue Mar 13 06:27:58 PDT 2012


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,




More information about the llvm-dev mailing list