This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Running SO files
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: "Rodrigo Dominguez" <roddomi at hotmail dot com>
- Cc: <binutils at sourceware dot org>
- Date: Sun, 1 Jun 2008 13:05:00 +0200
- Subject: Re: Running SO files
- References: <BAY109-DAV8EACDD15DAF3301A270CBB9BE0@phx.gbl>
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