LoadLibrary may fail if DLL is built with gcc -shared
fabrizio.ge@tiscali.it
fabrizio.ge@tiscali.it
Sun Apr 20 10:42:00 GMT 2003
I am trying to build a DLL. The file testdll.c is:
#include <stdlib.h>
void not_exported(void){
printf("not_exported\n");
}
void b(void){
printf("Called b\n");
not_exported();
}
void a(void){
printf("Called a\n");
}
and the testdll.def file is
LIBRARY testdll
EXPORTS
; Explicit exports can go here
b @1
a @2
First, I build it with the command
dllwrap --dllname=testdll.dll --def=testdll.def testdll.c
Then I build the test program test-explicit.c
#include <windows.h>
int main(){
HINSTANCE handle;
FARPROC f;
handle=LoadLibrary("testdll.dll");
if (handle==0){
printf("handle=0\n");
exit(1);
}
f=GetProcAddress(handle,"b");
if (f==0){
printf("b=0\n");
exit(1);
}
f=GetProcAddress(handle,"a");
if (f==0){
printf("a=0\n");
exit(1);
}
exit(0);
}
with the command
gcc -o test-explicit.exe text-explicit.c
and run test-explicit.exe. No output, as expected.
But, if the DLL is built with the command
gcc -shared -o testdll.dll testdll.c testdll.def
and test-explicit.exe is run, the output is
a=0
.
It seems thet the DLL created by gcc -shared is broken... Implicit linking
works in both cases.
Included are outputs of objdump -p : it seems that the only relevant difference
is that, in the DLL created by dllwrap, exported symbols are in alphabetical
order, while in the DLL created by gcc -shared, they are in numerical order.
In fact, if the function "a" is renamed to "c", everything works.
I am using Cygwin environment with gcc 3.2 20020927 and ld 2.13.90 20030308.
Bye
Fabrizio
__________________________________________________________________
Tiscali ADSL, fino a 9 MESI GRATIS sull'offerta Tiscali ADSL Light Mega!
Tiscali ADSL non teme confronti! Abbonati subito.
http://point.tiscali.it/adsl/index.shtml
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: created_with_dllwrap.txt
URL: <https://sourceware.org/pipermail/binutils/attachments/20030420/d2fecc7b/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: created_with_gcc_-shared.txt
URL: <https://sourceware.org/pipermail/binutils/attachments/20030420/d2fecc7b/attachment-0001.txt>
More information about the Binutils
mailing list