Executing a shared library

clibraries

Some shared libraries provide an output when called from the command line as if they were executables. For example:

$ /lib/libc.so.6 
GNU C Library stable release version 2.13, by Roland McGrath et al.
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.5.2.
Compiled on a Linux 2.6.37 system on 2011-01-18.
[...]

In a shared library of my own written in C, how can I provide this output? I've executed now a library I just made and I get a segment fault.

Best Answer

Try defining a void __libc_main() or void _init().

Related Question