This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [Patch]: ld crash on i386/pe when linking with a dll that has no exports
On Nov 25, 2009, at 6:23 PM, Christopher Faylor wrote:
> On Wed, Nov 25, 2009 at 10:20:54AM +0100, Tristan Gingold wrote:
>> Hi,
>>
>> we got a crash when linking with a dll whose export directory is empty:
>> ...
>> NumberOfRvaAndSizes 00000010
>>
>> 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. */
> return FALSE;
>
> a few lines above it?
No. As you can see in the above example, num_entries (== NumberOfRvaAndSizes) == 16.
> If this test is inadequate then it seems like num_entries isn't needed
> and should be deleted.
Well, it may avoid weird behavior if NumberOfRvaAndSizes == 0. In this case the dll must be seriously
broken.
Tristan.