1
0
mirror of https://github.com/golang/go synced 2024-11-23 11:30:06 -07:00

cmd/link: fix incorrect DOS header on Windows binaries

The previous DOS header placed on Windows binaries was incorrect, as
it had e_crlc (number of relocations) set to 4, instead of e_cparhdr
(size of header in 16-bit words) set to 4. This resulted in execution
starting at the beginning of the file, instead of where the DOS stub
code actually exists.

Fixes #57834
This commit is contained in:
Kevin Parsons 2023-01-01 11:04:25 -08:00
parent 1c65b69bd1
commit c715ad290a

View File

@ -152,6 +152,7 @@ const (
// DOS stub that prints out
// "This program cannot be run in DOS mode."
// See IMAGE_DOS_HEADER in the Windows SDK for the format of the header used here.
var dosstub = []uint8{
0x4d,
0x5a,
@ -159,12 +160,12 @@ var dosstub = []uint8{
0x00,
0x03,
0x00,
0x00,
0x00,
0x04,
0x00,
0x00,
0x00,
0x00,
0x00,
0xff,
0xff,
0x00,