public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* LoadLibrary may fail if DLL is built with gcc -shared
@ 2003-04-20 10:42 fabrizio.ge
  2003-04-25 14:07 ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: fabrizio.ge @ 2003-04-20 10:42 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1899 bytes --]

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




[-- Attachment #2: created_with_dllwrap.txt --]
[-- Type: text/plain, Size: 4763 bytes --]


testdll.dll:     file format pei-i386

Characteristics 0x2206
	executable
	line numbers stripped
	debugging information removed
	DLL

Time/Date		Sun Apr 20 12:40:28 2003

ImageBase		63780000
SectionAlignment	00001000
FileAlignment		00000200
MajorOSystemVersion	4
MinorOSystemVersion	0
MajorImageVersion	1
MinorImageVersion	0
MajorSubsystemVersion	4
MinorSubsystemVersion	0
Win32Version		00000000
SizeOfImage		00006000
SizeOfHeaders		00000400
CheckSum		00006b38
Subsystem		00000003	(Windows CUI)
DllCharacteristics	00000000
SizeOfStackReserve	00200000
SizeOfStackCommit	00001000
SizeOfHeapReserve	00100000
SizeOfHeapCommit	00001000
LoaderFlags		00000000
NumberOfRvaAndSizes	00000010

The Data Directory
Entry 0 00003000 0000004c Export Directory [.edata (or where ever we found it)]
Entry 1 00004000 00000168 Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00005000 00000064 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00000000 00000000 Import Address Table Directory
Entry d 00000000 00000000 Delay Import Directory
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved

There is an import table in .idata at 0x63784000

The Import Tables (interpreted .idata section contents)
 vma:            Hint    Time      Forward  DLL       First
                 Table   Stamp     Chain    Name      Thunk
 00004000	00004040 00000000 00000000 00004148 00004074

	DLL Name: cygwin1.dll
	vma:  Hint/Ord Member-Name Bound-To
	40a4	  614  calloc
	40b0	  666  cygwin_detach_dll
	40c4	  668  cygwin_internal
	40d8	  687  dll_dllcrt0
	40e8	  771  free
	40f0	  974  malloc
	40fc	 1039  printf
	4108	 1124  realloc

 00004014	00004068 00000000 00000000 00004158 0000409c

	DLL Name: KERNEL32.dll
	vma:  Hint/Ord Member-Name Bound-To
	4114	  299  GetModuleHandleA

 00004028	00000000 00000000 00000000 00000000 00000000

There is an export table in .edata at 0x63783000

The Export Tables (interpreted .edata section contents)

Export Flags 			0
Time/Date stamp 		3ea2791b
Major/Minor 			0/0
Name 				00003028 testdll.dll
Ordinal Base 			1
Number in:
	Export Address Table 		00000002
	[Name Pointer/Ordinal] Table	00000002
Table Addresses
	Export Address Table 		00003034
	Name Pointer Table 		0000303c
	Ordinal Table 			00003044

Export Address Table -- Ordinal Base 1
	[   0] +base[   1] 102c Export RVA
	[   1] +base[   2] 1050 Export RVA

[Ordinal/Name Pointer] Table
	[   1] a
	[   0] b


PE File Base Relocations (interpreted .reloc section contents)

Virtual Address: 00001000 Chunk size 100 (0x64) Number of fixups 46
	reloc    0 offset   17 [1017] HIGHLOW
	reloc    1 offset   35 [1035] HIGHLOW
	reloc    2 offset   59 [1059] HIGHLOW
	reloc    3 offset   77 [1077] HIGHLOW
	reloc    4 offset   7f [107f] HIGHLOW
	reloc    5 offset   88 [1088] HIGHLOW
	reloc    6 offset  11a [111a] HIGHLOW
	reloc    7 offset  12c [112c] HIGHLOW
	reloc    8 offset  134 [1134] HIGHLOW
	reloc    9 offset  13e [113e] HIGHLOW
	reloc   10 offset  144 [1144] HIGHLOW
	reloc   11 offset  14f [114f] HIGHLOW
	reloc   12 offset  159 [1159] HIGHLOW
	reloc   13 offset  182 [1182] HIGHLOW
	reloc   14 offset  1a2 [11a2] HIGHLOW
	reloc   15 offset  1c3 [11c3] HIGHLOW
	reloc   16 offset  1d2 [11d2] HIGHLOW
	reloc   17 offset  231 [1231] HIGHLOW
	reloc   18 offset  238 [1238] HIGHLOW
	reloc   19 offset  23f [123f] HIGHLOW
	reloc   20 offset  250 [1250] HIGHLOW
	reloc   21 offset  261 [1261] HIGHLOW
	reloc   22 offset  268 [1268] HIGHLOW
	reloc   23 offset  26f [126f] HIGHLOW
	reloc   24 offset  279 [1279] HIGHLOW
	reloc   25 offset  280 [1280] HIGHLOW
	reloc   26 offset  28a [128a] HIGHLOW
	reloc   27 offset  291 [1291] HIGHLOW
	reloc   28 offset  298 [1298] HIGHLOW
	reloc   29 offset  2a1 [12a1] HIGHLOW
	reloc   30 offset  2ba [12ba] HIGHLOW
	reloc   31 offset  2c1 [12c1] HIGHLOW
	reloc   32 offset  2c8 [12c8] HIGHLOW
	reloc   33 offset  2cf [12cf] HIGHLOW
	reloc   34 offset  2e7 [12e7] HIGHLOW
	reloc   35 offset  322 [1322] HIGHLOW
	reloc   36 offset  379 [1379] HIGHLOW
	reloc   37 offset  381 [1381] HIGHLOW
	reloc   38 offset  389 [1389] HIGHLOW
	reloc   39 offset  3a2 [13a2] HIGHLOW
	reloc   40 offset  3b2 [13b2] HIGHLOW
	reloc   41 offset  3c2 [13c2] HIGHLOW
	reloc   42 offset  3d2 [13d2] HIGHLOW
	reloc   43 offset  422 [1422] HIGHLOW
	reloc   44 offset  432 [1432] HIGHLOW
	reloc   45 offset    0 [1000] ABSOLUTE


[-- Attachment #3: created_with_gcc_-shared.txt --]
[-- Type: text/plain, Size: 8381 bytes --]


testdll.dll:     file format pei-i386

Characteristics 0x2206
	executable
	line numbers stripped
	debugging information removed
	DLL

Time/Date		Sun Apr 20 12:40:52 2003

ImageBase		00000000
SectionAlignment	00001000
FileAlignment		00000200
MajorOSystemVersion	4
MinorOSystemVersion	0
MajorImageVersion	1
MinorImageVersion	0
MajorSubsystemVersion	4
MinorSubsystemVersion	0
Win32Version		00000000
SizeOfImage		00009000
SizeOfHeaders		00000400
CheckSum		0000759d
Subsystem		00000003	(Windows CUI)
DllCharacteristics	00000000
SizeOfStackReserve	00200000
SizeOfStackCommit	00001000
SizeOfHeapReserve	00100000
SizeOfHeapCommit	00001000
LoaderFlags		00000000
NumberOfRvaAndSizes	00000010

The Data Directory
Entry 0 00006000 00000048 Export Directory [.edata (or where ever we found it)]
Entry 1 00007000 00000258 Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00008000 0000011c Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00000000 00000000 Import Address Table Directory
Entry d 00000000 00000000 Delay Import Directory
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved

There is an import table in .idata at 0x7000

The Import Tables (interpreted .idata section contents)
 vma:            Hint    Time      Forward  DLL       First
                 Table   Stamp     Chain    Name      Thunk
 00007000	00007040 00000000 00000000 0000722c 00007098

	DLL Name: cygwin1.dll
	vma:  Hint/Ord Member-Name Bound-To
	70ec	  568  abort
	70f4	  614  calloc
	7100	  666  cygwin_detach_dll
	7114	  668  cygwin_internal
	7128	  687  dll_dllcrt0
	7138	  771  free
	7140	  974  malloc
	714c	  994  memset
	7158	 1039  printf
	7164	 1082  pthread_mutex_lock
	717c	 1085  pthread_mutex_unlock
	7194	 1124  realloc
	71a0	 1287  strlen
	71ac	 1310  strtoul

 00007014	00007080 00000000 00000000 00007248 000070d8

	DLL Name: KERNEL32.dll
	vma:  Hint/Ord Member-Name Bound-To
	71b8	    0  AddAtomA
	71c4	  148  FindAtomA
	71d0	  193  GetAtomNameA
	71e0	  299  GetModuleHandleA

 00007028	00000000 00000000 00000000 00000000 00000000

There is an export table in .edata at 0x6000

The Export Tables (interpreted .edata section contents)

Export Flags 			0
Time/Date stamp 		3ea27934
Major/Minor 			0/0
Name 				0000603c testdll
Ordinal Base 			1
Number in:
	Export Address Table 		00000002
	[Name Pointer/Ordinal] Table	00000002
Table Addresses
	Export Address Table 		00006028
	Name Pointer Table 		00006030
	Ordinal Table 			00006038

Export Address Table -- Ordinal Base 1
	[   0] +base[   1] 107c Export RVA
	[   1] +base[   2] 10a0 Export RVA

[Ordinal/Name Pointer] Table
	[   0] b
	[   1] a


PE File Base Relocations (interpreted .reloc section contents)

Virtual Address: 00001000 Chunk size 80 (0x50) Number of fixups 36
	reloc    0 offset    f [100f] HIGHLOW
	reloc    1 offset   16 [1016] HIGHLOW
	reloc    2 offset   39 [1039] HIGHLOW
	reloc    3 offset   67 [1067] HIGHLOW
	reloc    4 offset   85 [1085] HIGHLOW
	reloc    5 offset   a9 [10a9] HIGHLOW
	reloc    6 offset  1cf [11cf] HIGHLOW
	reloc    7 offset  1d4 [11d4] HIGHLOW
	reloc    8 offset  1d8 [11d8] HIGHLOW
	reloc    9 offset  1dc [11dc] HIGHLOW
	reloc   10 offset  1e0 [11e0] HIGHLOW
	reloc   11 offset  1e4 [11e4] HIGHLOW
	reloc   12 offset  1e8 [11e8] HIGHLOW
	reloc   13 offset  1ec [11ec] HIGHLOW
	reloc   14 offset  1f0 [11f0] HIGHLOW
	reloc   15 offset  1f4 [11f4] HIGHLOW
	reloc   16 offset  1f8 [11f8] HIGHLOW
	reloc   17 offset  1fc [11fc] HIGHLOW
	reloc   18 offset  200 [1200] HIGHLOW
	reloc   19 offset  204 [1204] HIGHLOW
	reloc   20 offset  2e7 [12e7] HIGHLOW
	reloc   21 offset  2f2 [12f2] HIGHLOW
	reloc   22 offset  303 [1303] HIGHLOW
	reloc   23 offset  3bf [13bf] HIGHLOW
	reloc   24 offset  3ca [13ca] HIGHLOW
	reloc   25 offset  3db [13db] HIGHLOW
	reloc   26 offset  469 [1469] HIGHLOW
	reloc   27 offset  474 [1474] HIGHLOW
	reloc   28 offset  495 [1495] HIGHLOW
	reloc   29 offset  4d0 [14d0] HIGHLOW
	reloc   30 offset  4f1 [14f1] HIGHLOW
	reloc   31 offset  f91 [1f91] HIGHLOW
	reloc   32 offset  f9b [1f9b] HIGHLOW
	reloc   33 offset  fc1 [1fc1] HIGHLOW
	reloc   34 offset  fe3 [1fe3] HIGHLOW
	reloc   35 offset    0 [1000] ABSOLUTE

Virtual Address: 00002000 Chunk size 148 (0x94) Number of fixups 70
	reloc    0 offset   1b [201b] HIGHLOW
	reloc    1 offset   28 [2028] HIGHLOW
	reloc    2 offset  161 [2161] HIGHLOW
	reloc    3 offset  268 [2268] HIGHLOW
	reloc    4 offset  281 [2281] HIGHLOW
	reloc    5 offset  369 [2369] HIGHLOW
	reloc    6 offset  382 [2382] HIGHLOW
	reloc    7 offset  42d [242d] HIGHLOW
	reloc    8 offset  4af [24af] HIGHLOW
	reloc    9 offset  4cc [24cc] HIGHLOW
	reloc   10 offset  4d3 [24d3] HIGHLOW
	reloc   11 offset  55a [255a] HIGHLOW
	reloc   12 offset  562 [2562] HIGHLOW
	reloc   13 offset  56a [256a] HIGHLOW
	reloc   14 offset  575 [2575] HIGHLOW
	reloc   15 offset  57b [257b] HIGHLOW
	reloc   16 offset  5f0 [25f0] HIGHLOW
	reloc   17 offset  607 [2607] HIGHLOW
	reloc   18 offset  60f [260f] HIGHLOW
	reloc   19 offset  618 [2618] HIGHLOW
	reloc   20 offset  6aa [26aa] HIGHLOW
	reloc   21 offset  6bc [26bc] HIGHLOW
	reloc   22 offset  6c4 [26c4] HIGHLOW
	reloc   23 offset  6ce [26ce] HIGHLOW
	reloc   24 offset  6d4 [26d4] HIGHLOW
	reloc   25 offset  6df [26df] HIGHLOW
	reloc   26 offset  6e9 [26e9] HIGHLOW
	reloc   27 offset  712 [2712] HIGHLOW
	reloc   28 offset  722 [2722] HIGHLOW
	reloc   29 offset  732 [2732] HIGHLOW
	reloc   30 offset  742 [2742] HIGHLOW
	reloc   31 offset  752 [2752] HIGHLOW
	reloc   32 offset  762 [2762] HIGHLOW
	reloc   33 offset  772 [2772] HIGHLOW
	reloc   34 offset  782 [2782] HIGHLOW
	reloc   35 offset  792 [2792] HIGHLOW
	reloc   36 offset  7b2 [27b2] HIGHLOW
	reloc   37 offset  7d3 [27d3] HIGHLOW
	reloc   38 offset  7e2 [27e2] HIGHLOW
	reloc   39 offset  841 [2841] HIGHLOW
	reloc   40 offset  848 [2848] HIGHLOW
	reloc   41 offset  84f [284f] HIGHLOW
	reloc   42 offset  860 [2860] HIGHLOW
	reloc   43 offset  871 [2871] HIGHLOW
	reloc   44 offset  878 [2878] HIGHLOW
	reloc   45 offset  87f [287f] HIGHLOW
	reloc   46 offset  889 [2889] HIGHLOW
	reloc   47 offset  890 [2890] HIGHLOW
	reloc   48 offset  89a [289a] HIGHLOW
	reloc   49 offset  8a1 [28a1] HIGHLOW
	reloc   50 offset  8a8 [28a8] HIGHLOW
	reloc   51 offset  8b1 [28b1] HIGHLOW
	reloc   52 offset  8ca [28ca] HIGHLOW
	reloc   53 offset  8d1 [28d1] HIGHLOW
	reloc   54 offset  8d8 [28d8] HIGHLOW
	reloc   55 offset  8df [28df] HIGHLOW
	reloc   56 offset  8f7 [28f7] HIGHLOW
	reloc   57 offset  932 [2932] HIGHLOW
	reloc   58 offset  989 [2989] HIGHLOW
	reloc   59 offset  991 [2991] HIGHLOW
	reloc   60 offset  999 [2999] HIGHLOW
	reloc   61 offset  9b2 [29b2] HIGHLOW
	reloc   62 offset  9c2 [29c2] HIGHLOW
	reloc   63 offset  a12 [2a12] HIGHLOW
	reloc   64 offset  a22 [2a22] HIGHLOW
	reloc   65 offset  a32 [2a32] HIGHLOW
	reloc   66 offset  a42 [2a42] HIGHLOW
	reloc   67 offset  a52 [2a52] HIGHLOW
	reloc   68 offset  a84 [2a84] HIGHLOW
	reloc   69 offset  a90 [2a90] HIGHLOW

Virtual Address: 00004000 Chunk size 56 (0x38) Number of fixups 24
	reloc    0 offset   1c [401c] HIGHLOW
	reloc    1 offset   3c [403c] HIGHLOW
	reloc    2 offset   6c [406c] HIGHLOW
	reloc    3 offset   94 [4094] HIGHLOW
	reloc    4 offset   b4 [40b4] HIGHLOW
	reloc    5 offset   dc [40dc] HIGHLOW
	reloc    6 offset  104 [4104] HIGHLOW
	reloc    7 offset  124 [4124] HIGHLOW
	reloc    8 offset  144 [4144] HIGHLOW
	reloc    9 offset  16c [416c] HIGHLOW
	reloc   10 offset  18c [418c] HIGHLOW
	reloc   11 offset  1ac [41ac] HIGHLOW
	reloc   12 offset  1cc [41cc] HIGHLOW
	reloc   13 offset  1fc [41fc] HIGHLOW
	reloc   14 offset  228 [4228] HIGHLOW
	reloc   15 offset  254 [4254] HIGHLOW
	reloc   16 offset  280 [4280] HIGHLOW
	reloc   17 offset  2ac [42ac] HIGHLOW
	reloc   18 offset  2d8 [42d8] HIGHLOW
	reloc   19 offset  304 [4304] HIGHLOW
	reloc   20 offset  330 [4330] HIGHLOW
	reloc   21 offset  360 [4360] HIGHLOW
	reloc   22 offset  38c [438c] HIGHLOW
	reloc   23 offset    0 [4000] ABSOLUTE


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: LoadLibrary may fail if DLL is built with gcc -shared
  2003-04-20 10:42 LoadLibrary may fail if DLL is built with gcc -shared fabrizio.ge
@ 2003-04-25 14:07 ` Nick Clifton
  2003-05-04 11:45   ` Fabrizio Gennari
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2003-04-25 14:07 UTC (permalink / raw)
  To: fabrizio.ge; +Cc: binutils

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);  
  }
  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: LoadLibrary may fail if DLL is built with gcc -shared
  2003-04-25 14:07 ` Nick Clifton
@ 2003-05-04 11:45   ` Fabrizio Gennari
  0 siblings, 0 replies; 4+ messages in thread
From: Fabrizio Gennari @ 2003-05-04 11:45 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 721 bytes --]


----- Original Message -----
From: "Nick Clifton" <nickc@redhat.com>
To: <fabrizio.ge@tiscali.it>
Cc: <binutils@sources.redhat.com>
Sent: Friday, April 25, 2003 4:04 PM
Subject: Re: LoadLibrary may fail if DLL is built with gcc -shared


> Please could you try applying the attached (untested) patch,
> rebuilding the linker and then seeing if it creates a DLL which works
> for you.
>
I'm afraid 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

The patch should be attached

Bye
Fabrizio



[-- Attachment #2: ld-patch.txt --]
[-- Type: text/plain, Size: 871 bytes --]

Index: pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.56
diff -u -r1.56 pe-dll.c
--- pe-dll.c	2 Apr 2003 17:39:24 -0000	1.56
+++ pe-dll.c	4 May 2003 11:31:58 -0000
@@ -959,7 +959,7 @@
      bfd *abfd;
      struct bfd_link_info *info ATTRIBUTE_UNUSED;
 {
-  int i, hint;
+  int s, hint;
   unsigned char *edirectory;
   unsigned long *eaddresses;
   unsigned long *enameptrs;
@@ -1002,11 +1002,9 @@
 
   /* Ok, now for the filling in part.  */
   hint = 0;
-  for (i = 0; i < export_table_size; i++)
+  for (s = 0; s < NE; s++)
     {
-      int s = exported_symbols[i];
-
-      if (s != -1)
+      if (pe_def_file->exports[s].ordinal != -1)
 	{
 	  struct sec *ssec = exported_symbol_sections[s];
 	  unsigned long srva = (exported_symbol_offsets[s]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: LoadLibrary may fail if DLL is built with gcc -shared
       [not found] <004901c32783$7dbad0a0$c1770b3e@io>
@ 2003-06-02  8:42 ` Nick Clifton
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2003-06-02  8:42 UTC (permalink / raw)
  To: fabrizio.ge; +Cc: binutils

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]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-06-02  8:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-20 10:42 LoadLibrary may fail if DLL is built with gcc -shared fabrizio.ge
2003-04-25 14:07 ` Nick Clifton
2003-05-04 11:45   ` Fabrizio Gennari
     [not found] <004901c32783$7dbad0a0$c1770b3e@io>
2003-06-02  8:42 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).