This is the mail archive of the binutils@sourceware.org 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] Windows/PE: Do not create empty export table.


Presently, if a DLL has no exports, an export table will be created, but it will be empty. In MS LINK, no export table is created at all in this condition. Both behaviors are valid, as near as I can tell, and both produce a DLL that Windows seems to understand. But it's probably better to match MS LINK here.

This patch changes the behavior of ld on PECOFF to match MS LINK in this regard.

Credit goes to ReactOS developers and Herve Poussinaeu for suggesting this change, which they use locally in their GNU-based toolchain.

Tested on i386-pc-mingw32 by a build and test cycle, with no regressions.

OK to commit?
2004-08-06  Aaron W. LaFramboise <aaron98wiridge9@aaronwl.com>

	* pe-dll.c (process_def_file): Do not create empty export table.

	* ld-pe/exports.d: New file.
	* ld-pe/exports.s: New file.
	* ld-pe/pe.exp: New test for empty export table.

Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.107
diff -u -p -r1.107 pe-dll.c
--- ld/pe-dll.c	31 Jul 2008 07:27:52 -0000	1.107
+++ ld/pe-dll.c	7 Aug 2008 05:56:36 -0000
@@ -603,10 +603,9 @@ process_def_file (bfd *abfd ATTRIBUTE_UN
 	}
     }
 
-  /* If we are not building a DLL, when there are no exports
+  /* If there are no exports
      we do not build an export table at all.  */
-  if (!pe_dll_export_everything && pe_def_file->num_exports == 0
-      && info->executable)
+  if (!pe_dll_export_everything && pe_def_file->num_exports == 0)
     return;
 
   /* Now, maybe export everything else the default way.  */
Index: ld/testsuite/ld-pe/exports.d
===================================================================
RCS file: ld/testsuite/ld-pe/exports.d
diff -N ld/testsuite/ld-pe/exports.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/exports.d	7 Aug 2008 05:56:39 -0000
@@ -0,0 +1,4 @@
+#...
+The Data Directory
+Entry 0 00000000 00000000 Export Directory \[\.edata \(or where ever we found it\)\]
+#...
Index: ld/testsuite/ld-pe/exports.s
===================================================================
RCS file: ld/testsuite/ld-pe/exports.s
diff -N ld/testsuite/ld-pe/exports.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/exports.s	7 Aug 2008 05:56:39 -0000
@@ -0,0 +1,2 @@
+# Deliberately left empty.
+
Index: ld/testsuite/ld-pe/pe.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/pe.exp,v
retrieving revision 1.8
diff -u -p -r1.8 pe.exp
--- ld/testsuite/ld-pe/pe.exp	6 Aug 2007 14:41:51 -0000	1.8
+++ ld/testsuite/ld-pe/pe.exp	7 Aug 2008 05:56:39 -0000
@@ -38,6 +38,8 @@ if {[istarget x86_64-*-mingw*] } {
   set pe_tests {
     {".secrel32" "" "" {secrel1.s secrel2.s}
      {{objdump -s secrel.d}} "secrel.x"}
+    {"Empty export table" "" "" "exports.s"
+     {{objdump -p exports.d}} "exports.dll"}
   }
 }
 

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