嵌入式系统上的C ++动态代码注入 [英] C++ dynamic code injection on an embedded system

查看:165
本文介绍了嵌入式系统上的C ++动态代码注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找以下问题的解决方案:

  • 开发了一个在嵌入式设备上运行的C ++软件模块(不可能使用基于文件的功能"dlopen"来加载共享库),而在该模块运行时,它应该可以通过动态程序代码进行扩展.
  • 在通过总线系统将动态代码发送到嵌入式设备上运行的先前描述的软件模块之前,在PC系统上编写动态代码(实现接口功能)并进行交叉编译(gcc)
  • 嵌入式设备上的软件模块应将接收到的动态程序代码保存在内存中,并且应该能够调用其中的功能

我该如何解决这个问题?

我的第一种方法是:

  • 交叉编译动态代码并将其链接为PC端上的共享库(ELF文件)
  • (传输后)ELF文件在内存中的嵌入式设备上可用
  • ELF文件的重定位->在这里,我目前绝对不知道该怎么做!有免费的图书馆来执行这种任务吗?

我不知道我的ELF文件方法是否可以工作?如果是这样,我应该如何执行库重定位?

是否有更好/不同的方法来解决我的问题?

解决方案

VxWorks可以做到这一点.对象模块可以部分链接可重定位的对象(GNU ld中的-r选项),而不是共享库,然后在运行时将其加载到目标,并在此链接完成后解析到目标上现有代码的链接.

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?

解决方案

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.

这篇关于嵌入式系统上的C ++动态代码注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆