如何动态加载可重定位ELF可执行文件?

发布于 2024-08-23 03:40:11 字数 351 浏览 4 评论 0原文

我试图为ARM平台编写elf可执行加载程序。我在这里有一些疑问

1)如何生成可重定位或位置独立的ELF可执行文件(编译器和链接器选项是什么)2)如何加载上面生成的ELF可执行文件。

作为一个开始,我做了一些工作并且工作正常。我使用 RO_Base 的固定地址,并且在构建时不分割段(不使用任何 --split 选项),这样我就可以获得连续的代码、数据、bss 部分。之后,我将精灵加载到与 RO_Base 相同的地址,并作为新线程执行代码。这工作正常。我还没有进行任何重定位等...

现在我想让它动态化,并且能够通过生成可重定位 ELF 并将 Loader 修改为适当的更改来加载到任何地址。 请帮助我让它发挥作用。

谢谢,

I trying to write elf executable loader program for ARM platform.I have some Queries here

1) How to generate relocatable or position independent ELF executable(what are the compiler & linker options) 2) How to load this above generated ELF executable file.

As astart , i did some work and it is working fine. I am using a fixed address for RO_Base and not splitting the Segments while building(not using any --split option), so that I am getting a contiguous code,data,bss sections. after this I am loading the elf to the same address as RO_Base and executing the code as new thread. this is working fine. I have not done any relocations etc...

Now I want to make it dynamic and able to load to any address by generating relocatable ELF and modifying the Loader to appropriate changes.
Please help me in making it work.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆依然 2024-08-30 03:40:11

只需对链接器使用 -r 标志即可使文件可重定位。

使用类似 this 的内容来重新定位内存中的文件。

Just use -r flag to linker to make file relocatable.

Use something like this to relocate file in memory.

梦幻的心爱 2024-08-30 03:40:11

这是一个很大的话题。我将参考 John R. Levine 的“链接器和加载器”。这是本书的手稿第七章搬迁,希望对你有帮助

It is a big topic. I will come to the reference "Linkers and Loaders" by John R. Levine. Here is the manuscript of the book, Chapter 7 Relocation, I hope it helpful

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文