PATCH for ld on Cygwin: avoid core dump when linked-to DLL has no exports
Eric Hanchrow
offby1@blarg.net
Wed Apr 30 19:02:00 GMT 2003
This patch works around, or perhaps even fixes, a problem that I
recently had. I was trying to link against a DLL that (by accident)
had no exports, like this:
ld sans_exports.dll
I was seeing a seg fault as the linker was attempting to read from
`expdata', even though that pointed to uninitialized memory.
I'm not certain that this is the best solution, but it seems
reasonable.
--- ./ChangeLog~ 2003-03-07 18:50:18.000000000 -0800
+++ ./ChangeLog 2003-04-30 10:00:02.000000000 -0700
@@ -1,3 +1,8 @@
+2003-04-30 Eric Hanchrow <erich@votehere.net>
+
+ * pe-dll.c (pe_implied_import_dll): Don't crash when export_size
+ is zero; instead print error and return FALSE.
+
2003-03-04 Dmitry Diky <diwil@mail.ru>
* Makefile.am: Add new devices x1122 x1132 emulation
--- ./pe-dll.c~ 2003-02-28 22:00:15.000000000 -0800
+++ ./pe-dll.c 2003-04-29 17:03:34.000000000 -0700
@@ -2531,6 +2531,13 @@
export_rva = pe_get32 (dll, opthdr_ofs + 96);
export_size = pe_get32 (dll, opthdr_ofs + 100);
+
+ if (0 == export_size)
+ {
+ einfo ("%X%s: this DLL has no exports\n", filename);
+ return FALSE;
+ }
+
nsections = pe_get16 (dll, pe_header_offset + 4 + 2);
secptr = (pe_header_offset + 4 + 20 +
pe_get16 (dll, pe_header_offset + 4 + 16));
--
But users will not now with glad cries glom on to a language that
gives them no more than what Scheme or Pascal gave them.
-- Guy Steele, http://www.sun.com/research/jtech/pubs/98-oopsla-growing.ps
More information about the Binutils
mailing list