English 中文(简体)
Linux user-space ELF loader
原标题:

I need to do a rather unusual thing: manually execute an elf executable. I.e. load all sections into right places, query main() and call it (and cleanup then). Executable will be statically linked, so there will be no need to link libraries. I also control base address, so no worries about possible conflicts.

So, is there are any libraries for that?

I found OSKit and its liboskit_exec, but project seems to be dead since 2002.

I m OK with taking parts of projects (respecting licenses, of course) and tailoring them to my need, but as I m quite a noob in the linux world, I dont even know where to find those parts! :)

PS. I need that for ARM platform.

UPD Well, the matter of loading elfs seems to require some good knowledge about it (sigh), so I m out to read some specs and manuals. And I think I will stick to bionic/linker and libelfsh. Thanks guys!

Summarized findings:

最佳回答

A quick apt-cache search suggests libelf1, libelfg0 and/or libelfsh0. I think the elfsh program (in the namesake package) might be an interesting practical example of how to use libelfsh0.

I haven t tried any myself, but I hope they might be helpful. Good luck :-)

问题回答

Google s Android, in it s "bionic" libc implementation, has a completely reimplemented ELF loader. It s reasonably clean, and probably a better source than gilbc if you re looking for something simple.

Take a look at libelf for reading the executable format. You are going to have trouble with this I think.

Sounds like, as you don t need libraries for anything, why not just mmap your executable, set data about various memory areas and jmp/b in?

I don t know if ARM has an NX-bit equivalent, but worth checking.

This tool contains an ELF loader: http://bitwagon.com/rtldi/rtldi.html

I reused the code from rtldi for an ELF chainloader in another project. The code is here: http://svn.gna.org/viewcvs/plash/trunk/chroot-jail/elf-chainloader/?rev=877 and there is some background here: http://plash.beasts.org/wiki/Story16. (Apparently I have to break these links because stackoverflow won t let me post >1 link!)





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签