Commit 8fc35238 authored by Jason A. Donenfeld's avatar Jason A. Donenfeld

ld: mark PE executables as terminal services aware

This has been the default in MSVC for a very long time, and it's hard to
imagine modern programs actually wanting the old legacy behavior. For
example, no modern programs try to install their junk into C:\windows
and therefore need to have an emulated writable windows directory.
That's not really even allowed by ACLs on modern systems.

Change-Id: Iadaca6815e39ea5c6b05c1cac5a95cfc35e5b48a
Reviewed-on: https://go-review.googlesource.com/c/go/+/191840
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
parent 2afe9d4d
......@@ -1172,6 +1172,9 @@ func (ctxt *Link) hostlink() {
} else {
argv = append(argv, "-mconsole")
}
// Mark as having awareness of terminal services, to avoid
// ancient compatibility hacks.
argv = append(argv, "-Wl,--tsaware")
case objabi.Haix:
argv = append(argv, "-pthread")
// prevent ld to reorder .text functions to keep the same
......
......@@ -96,6 +96,7 @@ const (
IMAGE_SUBSYSTEM_WINDOWS_CUI = 3
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE = 0x0040
IMAGE_DLLCHARACTERISTICS_NX_COMPAT = 0x0100
IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000
)
// TODO(crawshaw): add these constants to debug/pe.
......@@ -859,6 +860,10 @@ func (f *peFile) writeOptionalHeader(ctxt *Link) {
oh.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE | IMAGE_DLLCHARACTERISTICS_NX_COMPAT
}
// Mark as having awareness of terminal services, to avoid ancient compatibility hacks.
oh64.DllCharacteristics |= IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE
oh.DllCharacteristics |= IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE
// Disable stack growth as we don't want Windows to
// fiddle with the thread stack limits, which we set
// ourselves to circumvent the stack checks in the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment