]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: enable DEP for Windows executables
authorJason A. Donenfeld <Jason@zx2c4.com>
Sat, 26 Oct 2019 20:41:31 +0000 (22:41 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Sun, 27 Oct 2019 09:49:02 +0000 (09:49 +0000)
There's no reason not to enable DEP in 2019, especially given Go's
minimum operating system level.

RELNOTE=yes

Change-Id: I9c3bbc5b05a1654876a218123dd57b9c9077b780
Reviewed-on: https://go-review.googlesource.com/c/go/+/203601
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/pe.go

index 3924de530ba933ea57fa01bdd33f35e7e820aa8c..1edf8cf4078fc76b8ab61acee777fc3c53797c32 100644 (file)
@@ -1188,6 +1188,9 @@ func (ctxt *Link) hostlink() {
                // ancient compatibility hacks.
                argv = append(argv, "-Wl,--tsaware")
 
+               // Enable DEP
+               argv = append(argv, "-Wl,--nxcompat")
+
                argv = append(argv, fmt.Sprintf("-Wl,--major-os-version=%d", PeMinimumTargetMajorVersion))
                argv = append(argv, fmt.Sprintf("-Wl,--minor-os-version=%d", PeMinimumTargetMinorVersion))
                argv = append(argv, fmt.Sprintf("-Wl,--major-subsystem-version=%d", PeMinimumTargetMajorVersion))
index 12363626ae3a80ef2bd0c19b9c9753f6ea42cd14..b5851a94a0fb1d3f9d266dd115ae2b62105393e1 100644 (file)
@@ -861,14 +861,18 @@ func (f *peFile) writeOptionalHeader(ctxt *Link) {
 
        switch ctxt.Arch.Family {
        case sys.ARM:
-               oh64.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE | IMAGE_DLLCHARACTERISTICS_NX_COMPAT
-               oh.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE | IMAGE_DLLCHARACTERISTICS_NX_COMPAT
+               oh64.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
+               oh.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
        }
 
        // 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
 
+       // Enable DEP
+       oh64.DllCharacteristics |= IMAGE_DLLCHARACTERISTICS_NX_COMPAT
+       oh.DllCharacteristics |= IMAGE_DLLCHARACTERISTICS_NX_COMPAT
+
        // 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