2010 06 15 14 04 init & fini

=== so.c ===

#include <stdio.h>
#include <stdlib.h>

int hello_init()
{
  printf("init hello\n");
  return 0;
}

int hello()
{
  printf("hello world\n");
  return 0;
}

int hello_fini()
{
  printf("fini hello\n");
  return 0;
}

=== test.c ===

#include <stdio.h>
#include <stdlib.h>

int main()
{
  hello();
  return 0;
}
=======

gcc -g -fPIC -shared -o libtest.so -Wl,-init,hello_init,-fini,hello_fini so.c

gcc -g test.c -L. -ltest

export LD_LIBRARY_PATH=`pwd`

# ./a.out
init hello
hello world
fini hello