]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: non-executable stack support for Solaris
authorShawn Walker-Salas <shawn.walker@oracle.com>
Wed, 15 Jun 2016 20:44:03 +0000 (13:44 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 12 Oct 2016 06:41:25 +0000 (06:41 +0000)
Support the tagging of binaries created with the internal linker
on Solaris as having a non-executable stack by writing a PT_SUNWSTACK
program header.

Fixes #16074

Change-Id: I3888f2153083385d04a52f341570f93e5738b276
Reviewed-on: https://go-review.googlesource.com/24142
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/link/internal/ld/elf.go

index 70681b32623d7fe701f6fe2ba28e75f78c0326bc..636900e6ebabc83bf28ae53add75cd0e89a4e589 100644 (file)
@@ -238,6 +238,7 @@ const (
        PT_GNU_STACK         = 0x6474e551
        PT_GNU_RELRO         = 0x6474e552
        PT_PAX_FLAGS         = 0x65041580
+       PT_SUNWSTACK         = 0x6ffffffb
        PF_X                 = 0x1
        PF_W                 = 0x2
        PF_R                 = 0x4
@@ -2550,6 +2551,10 @@ func Asmbelf(ctxt *Link, symo int64) {
                ph.type_ = PT_PAX_FLAGS
                ph.flags = 0x2a00 // mprotect, randexec, emutramp disabled
                ph.align = uint64(SysArch.RegSize)
+       } else if Headtype == obj.Hsolaris {
+               ph := newElfPhdr()
+               ph.type_ = PT_SUNWSTACK
+               ph.flags = PF_W + PF_R
        }
 
 elfobj: