Running SO files

Mike Frysinger vapier@gentoo.org
Sun Jun 1 12:07:00 GMT 2008


On Sunday 01 June 2008, Segher Boessenkool wrote:
> > 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.

no it isnt ... it's standard ELF

> The SO needs an entry point, 

yes

> and a ".interp" section.

no ... an .interp is only needed if the ELF itself is not capable of direct 
execution.  and the kernel doesnt parse the section headers looking 
for ".interp", it parses the dynamic table for DT_INTERP.

> > 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.

generally speaking, a SO wouldnt be usable anyways if it werent +x.  userspace 
needs to mmap() it with exec access so that the functions in it are 
executable.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/binutils/attachments/20080601/f5ef3bc4/attachment.sig>


More information about the Binutils mailing list