]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: fix PE section attributes for windows/arm64
authorRuss Cox <rsc@golang.org>
Tue, 20 Apr 2021 19:00:35 +0000 (15:00 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 23 Apr 2021 21:42:57 +0000 (21:42 +0000)
The clang-mingw toolchain on windows/arm64 expects
.text to NOT be listed as containing initialized data and
.dwarf* to be listed as  containing initialized data.
Neither is true today, resulting in the go .text and .dwarf*
not being merged with the system .text and .dwarf*.
Having multiple .text and .dwarf* sections confuses all
kinds of tools.

Change-Id: I1b9832804c5f5d594bf19e8ee0a5ed31bc1d381d
Reviewed-on: https://go-review.googlesource.com/c/go/+/312032
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/ld/pe.go

index 729b6b2443ee3821ed416b5a40bc02c6e82cae5e..30654412b9880ff4b412d2ddd61e10943e90ecf5 100644 (file)
@@ -452,7 +452,7 @@ func (f *peFile) addDWARFSection(name string, size int) *peSection {
        off := f.stringTable.add(name)
        h := f.addSection(name, size, size)
        h.shortName = fmt.Sprintf("/%d", off)
-       h.characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE
+       h.characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE | IMAGE_SCN_CNT_INITIALIZED_DATA
        return h
 }
 
@@ -1593,7 +1593,7 @@ func addpersrc(ctxt *Link) {
 
 func asmbPe(ctxt *Link) {
        t := pefile.addSection(".text", int(Segtext.Length), int(Segtext.Length))
-       t.characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ
+       t.characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ
        if ctxt.LinkMode == LinkExternal {
                // some data symbols (e.g. masks) end up in the .text section, and they normally
                // expect larger alignment requirement than the default text section alignment.