From: qmuntal Date: Mon, 3 Apr 2023 08:01:43 +0000 (+0200) Subject: cmd/link/internal/ld: don't set IMAGE_FILE_DEBUG_STRIPPED on PE binaries X-Git-Tag: go1.21rc1~1005 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=949fdd9f0dc53c32dc6a5a46ad7a85032df28055;p=gostls13.git cmd/link/internal/ld: don't set IMAGE_FILE_DEBUG_STRIPPED on PE binaries The IMAGE_FILE_DEBUG_STRIPPED characteristic is used to inform that the debugging information have been removed from the PE files and moved into a DBG file, but the Go linker doesn't generate DBG files. Having this characteristic can confuse debugging tools, so better don't set it. While here, remove also IMAGE_FILE_LINE_NUMS_STRIPPED, which is deprecated and should be zero [1]. Fixes #59391 [1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#characteristics Change-Id: Ia6b1dc3353bfa292a17c4bef17c9bac8dc95189a Reviewed-on: https://go-review.googlesource.com/c/go/+/481615 Reviewed-by: Alex Brainman TryBot-Result: Gopher Robot Reviewed-by: Than McIntosh Run-TryBot: Quim Muntal Reviewed-by: Bryan Mills --- diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go index 27f2b0305a..a3bb47d232 100644 --- a/src/cmd/link/internal/ld/pe.go +++ b/src/cmd/link/internal/ld/pe.go @@ -888,10 +888,8 @@ func (f *peFile) writeFileHeader(ctxt *Link) { // much more beneficial than having build timestamp in the header. fh.TimeDateStamp = 0 - if ctxt.LinkMode == LinkExternal { - fh.Characteristics = pe.IMAGE_FILE_LINE_NUMS_STRIPPED - } else { - fh.Characteristics = pe.IMAGE_FILE_EXECUTABLE_IMAGE | pe.IMAGE_FILE_DEBUG_STRIPPED + if ctxt.LinkMode != LinkExternal { + fh.Characteristics = pe.IMAGE_FILE_EXECUTABLE_IMAGE switch ctxt.Arch.Family { case sys.AMD64, sys.I386: if ctxt.BuildMode != BuildModePIE {