This is the mail archive of the
mailing list for the binutils project.
Re: [Patch]: ld crash on i386/pe when linking with a dll that has no exports
- From: Christopher Faylor <cgf-use-the-mailinglist-please at sourceware dot org>
- To: Binutils <binutils at sourceware dot org>, Tristan Gingold <gingold at adacore dot com>
- Date: Wed, 25 Nov 2009 12:23:46 -0500
- Subject: Re: [Patch]: ld crash on i386/pe when linking with a dll that has no exports
- References: <842AE515-1B58-4F20-ADCA-6D178269B4F4@adacore.com>
On Wed, Nov 25, 2009 at 10:20:54AM +0100, Tristan Gingold wrote:
>we got a crash when linking with a dll whose export directory is empty:
>The Data Directory
>Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
>Entry 1 00016000 0000003c Import Directory [parts of .idata]
>In fact there is no guard against such values in ld/pe-dll.c(pe_implied_import_dll) and this function
>assumes that the export directory entry is not empty if present.
>This patch fixes this crash.
Isn't this supposed to be handled by the
if (num_entries < 1) /* No exports. */
a few lines above it?
If this test is inadequate then it seems like num_entries isn't needed
and should be deleted.
>2009-11-25 Tristan Gingold <email@example.com>
> * pe-dll.c (pe_implied_import_dll): Return early if there is no
> export entries.
>*** ld/pe-dll.c 15 Nov 2009 07:52:42 -0000 1.123
>--- ld/pe-dll.c 25 Nov 2009 09:12:43 -0000
>*** 3001,3006 ****
>--- 3001,3010 ----
> export_size = pe_get32 (dll, opthdr_ofs + 100);
>+ /* No exports. */
>+ if (export_size == 0)
>+ 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));