Win64, Windows unit: some declarations are compiled improperly
Original Reporter info from Mantis: Marcin Wiazowski
-
Reporter name:
Original Reporter info from Mantis: Marcin Wiazowski
- Reporter name:
Description:
There is a bug in the way, in which Windows unit is compiled for Win64 target (potentially, also other units may be affected).
Please see the attached Reproduce demo. It displays field offsets of some records, that are declared in Windows unit. In particular, the TImageOptionalHeader record is interesting. In 32-bit mode, it's redirected to IMAGE_OPTIONAL_HEADER32 declaration. In 64-bit mode, it should be redirected to IMAGE_OPTIONAL_HEADER64 declaration - while it seems that it's still redirected to IMAGE_OPTIONAL_HEADER32 declaration (for some reason, that is unknown to me).
The attached output_Delphi64.txt contains:
Field at offset 0x0048: SizeOfStackReserve
Field at offset 0x0050: SizeOfStackCommit
Field at offset 0x0058: SizeOfHeapReserve
Field at offset 0x0060: SizeOfHeapCommit
The attached output_FPC64.txt contains:
Field at offset 0x0048: SizeOfStackReserve
Field at offset 0x004C: SizeOfStackCommit
Field at offset 0x0050: SizeOfHeapReserve
Field at offset 0x0054: SizeOfHeapCommit
Although SizeOfStackReserve, SizeOfStackCommit, SizeOfHeapReserve and SizeOfHeapCommit fields should be compiled as 64-bit fields, they are compiled as 32-bit fields by FPC. When the attached Reproduce demo is compiled for Win32 and Win64 targets, generated results are basically same (although they shouldn't). Adding the "-Mdelphi" compilation command does not change anything.
Tested with FPC 3.0.4, 3.2.0 (r44252) and 3.3.1 (r44253).