两个要点:一是要显式指定加载器,二是要指定入口点
okra@okra:/okra/foo/229.executeable_so$ cat main.c
#include <stdio.h>
#include <stdlib.h>
const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2";
void test(void)
{
puts("helloworld");
exit(0);
}
|
okra@okra:/okra/foo/229.executeable_so$ gcc -g -W -Wall -fPIC -o libfoo.so -shared -Wl,-e,test main.c
okra@okra:/okra/foo/229.executeable_so$ ./libfoo.so
helloworld
阅读(678) | 评论(0) | 转发(0) |