c - Executing a shared library on Unix -


some unix shared libraries provide output when called command line if executables. example:

$ /lib/libc.so.6  gnu c library stable release version 2.13, roland mcgrath et al. copyright (c) 2011 free software foundation, inc. free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose. compiled gnu cc version 4.5.2. compiled on linux 2.6.37 system on 2011-01-18. [...] 

in shared library of own written in c, how can provide output? i've executed library made , segment fault.

note: asked on unix.stackechange.com https://unix.stackexchange.com/questions/7066/executing-a-shared-library

the below definition of main responsible printing output see. defined in csu/version.c of source tree of glibc. hope helps.

 #ifdef have_elf /* function entry point shared object.    running library program here.  */  extern void __libc_main (void) __attribute__ ((noreturn)); void __libc_main (void) {   __libc_print_version ();   _exit (0); } #endif 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -