我只是有一個有趣的想法。我使用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