]> Cypherpunks repositories - gostls13.git/commit
cmd/link: put read-only data in __DATA_CONST segment
authorCherry Zhang <cherryyz@google.com>
Thu, 3 Sep 2020 16:59:09 +0000 (12:59 -0400)
committerCherry Zhang <cherryyz@google.com>
Fri, 11 Sep 2020 15:07:26 +0000 (15:07 +0000)
commitffd95aadcddc34ec2c83971346f04cf7234e0fca
tree97b9b8802d2417a3530c2a328522de6e8bda3d90
parenta531bd5a59177dfef354df8b5b5b529a2a55d015
cmd/link: put read-only data in __DATA_CONST segment

On darwin, we put read-only data in __TEXT segment on AMD64 in
exe (non-PIE) buildmode, and in __DATA on everywhere else. This
is not ideal: things in __DATA segment are not read-only, and
being mapped R/W may use more run-time resources.

In fact, newer darwin systems support a __DATA_CONST segment,
which the dynamic linker will map it read-only after applying
relocations. Use that.

Fixes #38830.

Change-Id: Ic281e6c6ca8ef5fec4bb7c5b71c50dd5393e78ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/253919
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/macho.go
src/cmd/link/internal/ld/target.go