cmd/link: mark stacks as non-executable on freebsd

Fixes #48112

Change-Id: I673a5fe61171e5ba3d8ce58daac79391fb4758f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/346872
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Keith Randall 2021-09-01 08:33:42 -07:00
parent d8b156773c
commit 782aa42255

View file

@ -2025,6 +2025,11 @@ func asmbElf(ctxt *Link) {
ph := newElfPhdr()
ph.Type = elf.PT_SUNWSTACK
ph.Flags = elf.PF_W + elf.PF_R
} else if ctxt.HeadType == objabi.Hfreebsd {
ph := newElfPhdr()
ph.Type = elf.PT_GNU_STACK
ph.Flags = elf.PF_W + elf.PF_R
ph.Align = uint64(ctxt.Arch.RegSize)
}
elfobj: