]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: mark stacks as non-executable on freebsd
authorKeith Randall <khr@golang.org>
Wed, 1 Sep 2021 15:33:42 +0000 (08:33 -0700)
committerKeith Randall <khr@golang.org>
Thu, 2 Sep 2021 15:14:50 +0000 (15:14 +0000)
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>

src/cmd/link/internal/ld/elf.go

index 93f974c5e032dc7ed0b9059014cca4b2e64000c0..fb75c761a14cbc68dee095ba51d34c776821357c 100644 (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: