Skip to content

x86: Warning for DLLs that are for a different version of Windows

Summary

When a unit tries to statically import a DLL under Windows using $linklib, this patch changes the behaviour slightly and throws a warning instead of an error when building for i386-win32 and the DLL is for x86_64-win64 and vice versa. This should allow for the successful building of the i386-win32 compiler under 64-bit Windows.

System

  • Operating system: Windows
  • Processor architecture: i386, x86_64

What is the current bug behavior?

If a DLL is imported with $linklib and it is for the wrong version of Windows (common if you try to build the 32-bit compiler under 64-bit Windows), an error is thrown that often causes 'make all' to fail when building the Oracle package.

What is the behavior after applying this patch?

With this patch, if the DLL is simply for the wrong version of Windows rather than being malformed, a warning is thrown instead.

Additional notes

Previously, the error was "Invalid DLL [DLLName], invalid header size" - this has now been changed to "Invalid DLL [DLLName], invalid header size or unsupported machine type" to indicate that the failure might have also been due to a magic number mismatch (the reason for the error previously) rather than the header size being different (although chances are, the optional header size will be different too).

The optional header size is also different between i386 and x86_64 due to the native word size and the presence of an extra "data_start" field for i386. As a result, the checks to throw a warning over an error are very strict:

  • When building for i386-win32, if the DLL has COFF magic number $8664 and optional header size 240, then the warning "DLL [DLLName] is 64-bit" is thrown.
  • When building for x86_64-win64, if the DLL has COFF magic number $14c and optional header size 224, then the warning "DLL [DLLName] is 32-bit" is thrown.
  • Any other combination will throw the above error.

Comments explain the specific values, since the global constants can't be used as they refer to the 'correct' platform.

Edited by J. Gareth "Kit" Moreton

Merge request reports