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 tiscalinet dot it
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 02 Jun 2003 09:31:42 +0100
- Subject: Re: LoadLibrary may fail if DLL is built with gcc -shared
- References: <004901c32783$7dbad0a0$c1770b3e@io>
Hi Fabrizio,
>> Please could you try applying the attached (untested) patch,
> I tried it, but unfortunately the result is the same. However, I
> wrote another patch. According to the few tests I've made, it seems
> to work. It can be summarized as:
>
> pe-dll.c (fill_edata): scan table pe_dll->exports, which is sorted
> alphabetically, instead of exported_symbols, which is sorted by ordinal
Thanks very much. I have applied your patch, together with an
extended comment, to pe-dll.c
Cheers
Nick
2003-06-02 Fabrizio Gennari <fabrizio.ge@tiscalinet.it>
* pe-dll.c (fill_edata): Scan table pe_dll->exports, which is
sorted alphabetically, instead of exported_symbols, which is
sorted by ordinal.
Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.56
diff -c -3 -p -r1.56 pe-dll.c
*** ld/pe-dll.c 2 Apr 2003 17:39:24 -0000 1.56
--- ld/pe-dll.c 2 Jun 2003 08:37:59 -0000
*************** fill_edata (abfd, info)
*** 959,965 ****
bfd *abfd;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
{
! int i, hint;
unsigned char *edirectory;
unsigned long *eaddresses;
unsigned long *enameptrs;
--- 959,965 ----
bfd *abfd;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
{
! int s, hint;
unsigned char *edirectory;
unsigned long *eaddresses;
unsigned long *enameptrs;
*************** fill_edata (abfd, info)
*** 1000,1012 ****
fill_exported_offsets (abfd, info);
! /* Ok, now for the filling in part. */
hint = 0;
! for (i = 0; i < export_table_size; i++)
{
! int s = exported_symbols[i];
!
! if (s != -1)
{
struct sec *ssec = exported_symbol_sections[s];
unsigned long srva = (exported_symbol_offsets[s]
--- 1000,1015 ----
fill_exported_offsets (abfd, info);
! /* Ok, now for the filling in part.
! Scan alphabetically - ie the ordering in the exports[] table,
! rather than by ordinal - the ordering in the exported_symbol[]
! table. See dlltool.c and:
! http://sources.redhat.com/ml/binutils/2003-04/msg00379.html
! for more information. */
hint = 0;
! for (s = 0; s < NE; s++)
{
! if (pe_def_file->exports[s].ordinal != -1)
{
struct sec *ssec = exported_symbol_sections[s];
unsigned long srva = (exported_symbol_offsets[s]