C++ dynamic code injection on an embedded system

1k views Asked by At

I am looking for a solution to the following problem:

  • a C++ software module is developed that runs on an embedded device (no possibility to use the file based function "dlopen" to load shared libraries), while the module is running it shall be extendable by dynamic program code
  • the dynamic code is written (realization of interface functions) and cross compiled (gcc) on a PC system before it is sent via a bus system to the previously described software module running on the embedded device
  • the software module on the embedded device shall hold the received dynamic program code in memory and should be able to call the functions therein

How do I solve this problem?

My first approach is the following:

  • Cross compile and link the dynamic code as a shared library (ELF file) on PC side
  • (after transmission) the ELF file is available on the embedded device in memory
  • Relocation of the ELF file -> here I have currently absolutely no idea how that could be made! are there free libraries to perform that kind of task?

I do not know if my ELF file approach can work? If so how should I perform the library relocation?

Is there any better/different approach to solve my problem?

1

There are 1 answers

0
Clifford On

VxWorks can do exactly that. Rather than shared libraries as such, object modules can be partially linked relocatable object (-r option in GNU ld) and then loaded at run-time to the target where the link is completed resolving links to the existing code on the target.