Go version

go1.22.4

Output of go env in your module/workspace:

*

What did you do?

look .reloc section in pe file: go.exe and another executable files compiled by go program.

What did you see happen?

.reloc section in compiled file (go.exe). Each block represents the base relocations for a 4K page. Some blocks in .reloc section in go.exe don't start on a 32-bit boundary.

It's related to source code is src\cmd\link\internal\ld\pe.go:

        blockSize := uint32(sizeOfPEbaseRelocBlock + len(b.entries)*2)
        out.Write32(p)
        out.Write32(blockSize)

Corrected code must add empty entry at the end of block, if len(b.entries) is odd.

What did you expect to see?

from PE Format description at microsoft site: Each block represents the base relocations for a 4K page. Each block must start on a 32-bit boundary. Probably it's old rule, because old processors required aligned 32-bit access for 32-bit fields.

Comment From: gopherbot

Change https://go.dev/cl/595896 mentions this issue: cmd/link: align .reloc block starts by 32 bits for PE target

Comment From: cherrymui

cc @golang/windows