]> Cypherpunks repositories - gostls13.git/commit
cmd/link: set SizeOfRawData rather than VirtualSize in COFF files for .bss section
authorJason A. Donenfeld <Jason@zx2c4.com>
Sat, 13 Feb 2021 23:04:48 +0000 (00:04 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 23 Feb 2021 15:03:26 +0000 (15:03 +0000)
commita51daac840482d71d89742871b860a023dbdba0e
tree7a3690da623b0c5ae50bc00139c76c0c96665042
parente5159b2a2f0fdd47c644d1655f5a7b57ec7dd509
cmd/link: set SizeOfRawData rather than VirtualSize in COFF files for .bss section

GCC and Clang both set the SizeOfRawData field rather than the
VirtualSize field for communicating the size of the .bss section. As a
consequence, LLD does not look at VirtualSize and collapses the .bss
section into whatever is around it, resulting in runtime crashes. This
commit changes the logic so that if the requested "file size" is 0, then
the SizeOfRawData field is set rather than the VirtualSize field as the
sole length marker.

Fixes #44250.
Fixes #39326.
Updates #38755.
Updates #36439.
Updates #43800.

Change-Id: Ied89ddaa0a717fed840238244c6e4848845aeeb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/291630
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/pe.go