This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Running SO files


I have noticed that some shared object (.so) files can be executed. For
example, I can type:

$ /lib/libc.so.6

which prints a message with the version of GNU C library and other
information. How does this work? How is it possible to execute a shared
object file?

It's a little hack in the Linux kernel. The SO needs an entry point, and a ".interp" section.

Does it have a main/start function?

It does. It's calling convention is just like normal main() on some platforms, but pretty strange on others.

 How can I create such a
file (one that can be executed)?

At http://git.infradead.org/users/segher/profall.git?a=tree you can look
at a tiny example of this. It's pretty horrible code, don't go blind :-)


I have also noticed that this is not true
for every SO file. I would appreciate any information on how this works.

You can't "run" a SO if it's not marked +x. The Linux kernel will happily
try to run any SO that is executable, but will segfault it just as happily
unless you get all the little bits right.


Happy hacking,


Segher



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]