You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
specifically looking at the first 4 bytes of the file match using Windows_Pattern : constant Bytes := (77, 90, 144, 0);
This is typically works, but it's not actually correct - only MZ / 0x4d5a is required, the 3rd & 4th bytes are actually just e_cblp, or "Bytes on last page of file". It seems typically that's set to 0x90, but not exclusively. I'm not sure anything actually uses it.
However, I've just run into an issue where gprconfig refuses to recognise a compiler that was linked with lld where it's set to 0x78 (apparently the lld linker does actually set it?) (best not ask exactly why I'm doing this)
gprconfig uses the following to determine whether a file is a valid Windows executable
gprbuild/gpr/src/gpr-knowledge.adb
Lines 397 to 423 in 48f5161
specifically looking at the first 4 bytes of the file match using
Windows_Pattern : constant Bytes := (77, 90, 144, 0);
This is typically works, but it's not actually correct - only
MZ
/0x4d5a
is required, the 3rd & 4th bytes are actually juste_cblp
, or "Bytes on last page of file". It seems typically that's set to 0x90, but not exclusively. I'm not sure anything actually uses it.However, I've just run into an issue where gprconfig refuses to recognise a compiler that was linked with
lld
where it's set to0x78
(apparently thelld
linker does actually set it?) (best not ask exactly why I'm doing this)The correct method of determining a valid binary is to lookup the COFF File header at position 0x3c and then find the machine type - https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#coff-file-header-object-and-image
I implemented this routine in Perl a while back, which may prove of interest.
The text was updated successfully, but these errors were encountered: