我尝试从头开始,模拟exe导出函数,然后dll去链接。发现原生的MinGW好像不行,于是下载了xunxun的-enable-plugin版本的gcc,在这里下的:
http://mingw.5.n7.nabble.com/gcc-enable-plugin-experimental-built-on-windows-td14088.html
测试生成的exe确实有导出函数,但是dll去链接就是不行:
测试代码:
-----------------------------------------------------------------------------------------------
ollydbg.cpp:
extern "C" int __cdecl Plugingetvalue(int type)
{
return 0;
}
int main()
{
return 0;
}
-----------------------------------------------------------------------------------------------
testdll.cpp:
extern "C" int __cdecl Plugingetvalue(int type);
int main()
{
return Plugingetvalue(1);
}
-----------------------------------------------------------------------------------------------
makefile:
exe: obj
gcc -o ollydbg.exe ollydbg.o -Wl,--output-def,ollydbg.def,--out-implib,OLLYDBG110.a
obj:
gcc -c -o ollydbg.o -Wl,--export-all-symbols ollydbg.cpp
testdll:
gcc -o testdll.dll -shared D:\MinGW_GCC4.6.1_test\MinGW\OLLYDBG110.a testdll.cpp
错误提示:
gcc -o testdll.dll -shared D:\MinGW_GCC4.6.1_test\MinGW\OLLYDBG110.a testdll.cpp
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccKm6nLu.o:testdll.cpp:(.text+0x16): undefine
d reference to `Plugingetvalue'
collect2: ld returned 1 exit status
makefile:6: recipe for target `dll' failed
mingw32-make: *** [dll] Error 1