在任意初始化的内存块周围加载 ELF 二进制文件 [英] Load ELF binary around an arbitrary initialized memory block

查看:49
本文介绍了在任意初始化的内存块周围加载 ELF 二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个项目,该项目要求我将一些数据加载到运行时确定的内存地址处的内存中,然后将一个 ELF 二进制文件加载到相同的地址空间中.我知道我可以将 ELF 编译为与位置无关的,但是如何分配内存块然后然后加载和运行二进制文件而不覆盖内存块或移动到不同的地址空间?

I'm working on a project that will require me to load some data into memory at memory addresses determined at runtime and then load an ELF binary into the same address space. I know I can compile the ELF as position-independent, but how can I allocate my memory block and then load and run the binary without overwriting the memory block or moving into a different address space?

推荐答案

您能否将 ELF 二进制文件编译为共享库,然后将其动态链接到您的原始进程中?动态链接器应该尊重现有的 malloc/mmap 内存分配,而不是踩到它们.

Can you compile the ELF binary as a shared library and then dynamically link it into your original process? The dynamic linker should respect exisiting malloc/mmap memory allocations and not step on them.

这篇关于在任意初始化的内存块周围加载 ELF 二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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