Hi All!
I have a problem. I need to build a sherd object that, like libc do, can print some information when you execute it like a normal executable.
Anyone can help me ?
Thank you
Paolo
Assuming you are on an ELF GNU/Linux system...
Link normally, but add -Wl,-e,the_name_of_your_entry_point for example this Makefile fragment:
--- 8< --- dop.so: dop.c gcc -Wall -W -fPIC -shared -o dop.so dop.c -lc -Wl,-e,my_main --- 8< ---
and add code like this:
--- 8< --- const char my_interp[] __attribute__((section(".interp"))) = "/lib/ld.so.1";
void my_main(int argc, char **argv) { int i;
printf("Called as:"); for (i = 0; i < argc; i++) printf(" %s", argv[i]); printf("\n");
exit(0); } --- 8< ---
Have fun,
Segher