Load ELF binary around an arbitrary initialized memory block

孤街醉人 提交于 2019-12-24 20:07:04

问题


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?


回答1:


Exec replaces the entire memory space and I don't think there's much you can do about that. But maybe you could use shared memory to share the data between your old and new processes?




回答2:


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.



来源:https://stackoverflow.com/questions/13107143/load-elf-binary-around-an-arbitrary-initialized-memory-block

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