我只是有一个有趣的想法。我使用objdump来转储一个简单的二进制文件,我在二进制文件中看到很多函数。是否有可能创建另一个与这些功能链接的C程序?假设我知道输入和输出的参数。是否有可能链接一些正常的二进制功能?
一些详细信息: 文件1:test.c的
#include <stdio.h>
int add(int x,int y)
{
return x+y;
}
int main(int argc, const char *argv[])
{
printf("%d\n",add(3,4));
return 0;
}
文件2:test1.c
#include <stdio.h>
int main(int argc, const char *argv[])
{
printf("%d\n",add(8,8));
return 0;
}
gcc test.c -o test.exe
gcc test1.c test.exe -o test1.exe
输出:
ld: in test.exe, can't link with a main executable
collect2: ld returned 1 exit status
我对共享库和LD_PRELOAD方法感兴趣。有什么更详细的地方可以阅读吗? – Patrick 2012-01-15 07:12:39
http://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick可能会帮助你... – Jason 2012-01-15 07:18:06
以下是一些更多信息:http://lca2009.linux.org.au/slides /172.pdf – Jason 2012-01-15 07:20:47