This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] dll autoimport broken when linking with msft import lib

Following up on this thread:

I just confirmed it is not a arm-wince-pe only bug, but it is present also on cygwin.

Attached is a tar.gz that shows the problem. You will need an import lib generated by any Microsoft toolchain.
I used zlib.lib from ** <> from, so I could redistribute the test lib.

The proposed attached patch changes the subsection for import fixup entries from .idata$3 to .idata$2.

For everyone not following the discussion before:

The problem shows up because msft's import libs export the import descriptor terminator as a named symbol (__NULL_IMPORT_DESCRIPTOR),
that gets linked *before* the fu*.o import descriptor generated for auto-importing. I see no reason for the auto-import descriptor being
at the .idata$3 subsection.

.idata$3 0x0001503c 0x14 /usr/local/lib/gcc/arm-wince-pe/4.1.1/../../../../arm-wince-pe/lib/zlibce.lib(zlibce.dll.c)

              0x0001503c                __NULL_IMPORT_DESCRIPTOR
.idata$3       0x00015050       0x14 fu000001.o
              0x00015064        0x4 LONG 0x0
              0x00015068        0x4 LONG 0x0
              0x0001506c        0x4 LONG 0x0
              0x00015070        0x4 LONG 0x0
              0x00015074        0x4 LONG 0x0

The os loader will see __NULL_IMPORT_DESCRIPTOR, which is an import descriptor terminator, and will not process the fu000001.o
import descriptor.

Pedro Alves

Attachment: dllimportbug.tar.gz
Description: application/gzip

Index: ld/pe-dll.c
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.83
diff -u -r1.83 pe-dll.c
--- ld/pe-dll.c	31 Jan 2006 22:08:14 -0000	1.83
+++ ld/pe-dll.c	6 May 2006 10:58:22 -0000
@@ -95,7 +95,7 @@
     For each reference of data symbol to be imported from DLL (to set of which
     belong symbols with name <sym>, if __imp_<sym> is found in implib), the
     import fixup entry is generated. That entry is of type
-    IMAGE_IMPORT_DESCRIPTOR and stored in .idata$3 subsection. Each
+    IMAGE_IMPORT_DESCRIPTOR and stored in .idata$2 subsection. Each
     fixup entry contains pointer to symbol's address within .text section
     (marked with __fuN_<sym> symbol, where N is integer), pointer to DLL name
     (so, DLL name is referenced by multiple entries), and pointer to symbol
@@ -2048,7 +2048,7 @@
   return fixup_name;
-/*	.section	.idata$3
+/*	.section	.idata$2
   	.rva		__nm_thnk_SYM (singleton thunk with name of func)
  	.long		0
  	.long		0
@@ -2079,7 +2079,7 @@
   symptr = 0;
   symtab = xmalloc (6 * sizeof (asymbol *));
-  id3 = quick_section (abfd, ".idata$3", SEC_HAS_CONTENTS, 2);
+  id3 = quick_section (abfd, ".idata$2", SEC_HAS_CONTENTS, 2);
   quick_symbol (abfd, U ("_nm_thnk_"), name, "", UNDSEC, BSF_GLOBAL, 0);
   quick_symbol (abfd, U (""), dll_symname, "_iname", UNDSEC, BSF_GLOBAL, 0);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]