diff options
| author | Ian Lance Taylor <iant@golang.org> | 2023-02-24 15:52:58 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-02-25 00:15:17 +0000 |
| commit | ffb07d0c66db2f3f33faedf2927f9aa476d47720 (patch) | |
| tree | 51e57fcc3b8f87a187ed3f68481fabb372759638 /src/cmd | |
| parent | 203e59ad41bd288e1d92b6f617c2f55e70d3c8e3 (diff) | |
| download | go-ffb07d0c66db2f3f33faedf2927f9aa476d47720.tar.xz | |
cmd/link: don't emit PAX_FLAGS segment on Linux
We started emitting this segment in 2012 in CL 6326054 for #47.
It disabled three kinds of protection: mprotect, randexec, and emutramp.
The randexec protection was deprecated some time ago, replaced by PIE.
The emutramp and mprotect protection was because we used to rely on being
able to create writable executable memory to implement function closures,
but that is not true since https://go.dev/s/go11func was implemented.
Change-Id: I5e3a5279d76d642b0423d26195b891479a235763
Reviewed-on: https://go-review.googlesource.com/c/go/+/471199
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/link/internal/ld/elf.go | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/src/cmd/link/internal/ld/elf.go b/src/cmd/link/internal/ld/elf.go index 5eeb4a9993..842570d5ef 100644 --- a/src/cmd/link/internal/ld/elf.go +++ b/src/cmd/link/internal/ld/elf.go @@ -2135,25 +2135,15 @@ func asmbElf(ctxt *Link) { } } - if ctxt.HeadType == objabi.Hlinux { + if ctxt.HeadType == objabi.Hlinux || 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) - - ph = newElfPhdr() - ph.Type = elf.PT_PAX_FLAGS - ph.Flags = 0x2a00 // mprotect, randexec, emutramp disabled - ph.Align = uint64(ctxt.Arch.RegSize) } else if ctxt.HeadType == objabi.Hsolaris { 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: |
