Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Support for position-independent code and natdynlink on ARM #5404
Original bug ID: 5404
I spent some time fixing the ARM compiler part to emit position-independent code in order to get proper support for natdynlink on ARM. The critical part is fixing the generated branches to use the PLT (cf. issue 5049), the other relocations seem to be handled properly, hence there's no need to use the GOT to access global variables. That does however require changes to the runtime interface as r12 is used as scratch register for the PLT slots. I fixed these by introducing two additional functions caml_invoke_gc and caml_c_invoke, which are similar to their caml_call_gc and caml_c_call counterparts, but do not use r12 for parameter passing. The old functions are provided for compatibility with existing code/libraries (and are used by the code generator when appropriate).
The attached patch contains the required changes to the runtime and the compiler toolchain. So far the stuff was tested with Debian squeeze armel running on QEMU and a NanosG20 SBC (ARM926EJ-S rev 5 (v5l)).
I did some tests on the ARM926EJ-S, and there seems to be no noticable performance hit (OLD is OCaml 3.12.1 without the patch, NEW is the patched OCaml generating PIC code):
File OLD NEW