dlsym() fails with an executable shared library

Segher Boessenkool segher@kernel.crashing.org
Thu Dec 8 13:55:00 GMT 2011


>> gcc -Wall -W -fPIC -shared -o library.so test.c -lc -Wl,-e,my_main
>
> This is a workable approach, but my_main must act as the entry  
> point of
> the program.  The entry point is not called with argc and argv.   
> Take a
> look at crt1.o on your system to see what the entry point must do.

Or look at http://git.infradead.org/users/segher/profall.git .

[ This thing runs its first command line arg, but LD_PRELOADs itself to
it (and anything it forks).  It makes each of those exacutables write
gmon.out files, whether they were linked with -pg or not. ]


Segher



More information about the Gcc-help mailing list