This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: LoadLibrary may fail if DLL is built with gcc -shared
- From: Nick Clifton <nickc at redhat dot com>
- To: fabrizio dot ge at tiscali dot it
- Cc: binutils at sources dot redhat dot com
- Date: 25 Apr 2003 15:04:34 +0100
- Subject: Re: LoadLibrary may fail if DLL is built with gcc -shared
- References: <3E9BA3F80000A65F@mail-2.tiscali.it>
Hi Fabrizio,
> 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.
Please could you try applying the attached (untested) patch,
rebuilding the linker and then seeing if it creates a DLL which works
for you.
Cheers
Nick
Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.56
diff -c -3 -p -w -r1.56 pe-dll.c
*** ld/pe-dll.c 2 Apr 2003 17:39:24 -0000 1.56
--- ld/pe-dll.c 25 Apr 2003 14:05:35 -0000
*************** pe_export_sort (va, vb)
*** 362,367 ****
--- 362,370 ----
def_file_export *a = (def_file_export *) va;
def_file_export *b = (def_file_export *) vb;
+ if ((a->ordinal != -1) && (b->ordinal != -1))
+ return a->ordinal < b->ordinal;
+
return strcmp (a->name, b->name);
}