C++ dynamic code injection on an embedded system

核能气质少年 提交于 2019-12-20 04:48:32

问题


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:


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.



来源:https://stackoverflow.com/questions/21020866/c-dynamic-code-injection-on-an-embedded-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!