[go] cmd/link/internal/ld: always pass ASLR options on windows to ext linker

53 views
Skip to first unread message

Than McIntosh (Gerrit)

unread,
Feb 8, 2022, 1:02:16 PM2/8/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Than McIntosh has uploaded this change for review.

View Change

cmd/link/internal/ld: always pass ASLR options on windows to ext linker

DO NOT SUBMIT

When doing external linking on windows, the existing Go linker code
assumed that the external linker defaulted to --no-dynamicbase (if no
explicit option was given). This assumption doesn't hold for LLD,
which sets --dynamicbase by default for 64-bit apps. Change the linker
code to explicitly pass --dynamicbase either way, so as to take the
external linker default out of the equation. This also applies to the
"--high-entropy-va" option as well.

Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
---
M src/cmd/link/internal/ld/lib.go
1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 46e97e0..50cf490 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1321,12 +1321,18 @@
}

// Enable ASLR on Windows.
- addASLRargs := func(argv []string) []string {
+ addASLRargs := func(argv []string, val bool) []string {
+ dbopt := "--no-dynamic-base"
+ heopt := "--no-high-entropy-va"
+ if val {
+ dbopt = "--dynamicbase"
+ heopt = "--high-entropy-va"
+ }
// Enable ASLR.
- argv = append(argv, "-Wl,--dynamicbase")
+ argv = append(argv, "-Wl,"+dbopt)
// enable high-entropy ASLR on 64-bit.
if ctxt.Arch.PtrSize >= 8 {
- argv = append(argv, "-Wl,--high-entropy-va")
+ argv = append(argv, "-Wl,"+heopt)
}
return argv
}
@@ -1343,7 +1349,7 @@
switch ctxt.HeadType {
case objabi.Hdarwin, objabi.Haix:
case objabi.Hwindows:
- argv = addASLRargs(argv)
+ argv = addASLRargs(argv, *flagAslr)
default:
// ELF.
if ctxt.UseRelro() {
@@ -1360,9 +1366,7 @@
}
argv = append(argv, "-shared")
if ctxt.HeadType == objabi.Hwindows {
- if *flagAslr {
- argv = addASLRargs(argv)
- }
+ argv = addASLRargs(argv, *flagAslr)
} else {
// Pass -z nodelete to mark the shared library as
// non-closeable: a dlclose will do nothing.

To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
Gerrit-Change-Number: 384156
Gerrit-PatchSet: 1
Gerrit-Owner: Than McIntosh <th...@google.com>
Gerrit-MessageType: newchange

Than McIntosh (Gerrit)

unread,
Feb 8, 2022, 1:14:15 PM2/8/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Than McIntosh uploaded patch set #2 to this change.

View Change

cmd/link/internal/ld: always pass ASLR options on windows to ext linker

DO NOT SUBMIT

When doing external linking on windows, the existing Go linker code
assumed that the external linker defaulted to --no-dynamicbase (if no
explicit option was given). This assumption doesn't hold for LLD,
which sets --dynamicbase by default for 64-bit apps. Change the linker
code to explicitly pass --dynamicbase either way, so as to take the
external linker default out of the equation. This also applies to the
"--high-entropy-va" option as well.

Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
---
M src/cmd/link/internal/ld/lib.go
1 file changed, 30 insertions(+), 7 deletions(-)

To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
Gerrit-Change-Number: 384156
Gerrit-PatchSet: 2
Gerrit-Owner: Than McIntosh <th...@google.com>
Gerrit-MessageType: newpatchset

Than McIntosh (Gerrit)

unread,
Feb 8, 2022, 1:16:01 PM2/8/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Patch set 2:Run-TryBot +1Trust +1

View Change

1 comment:

  • Patchset:

    • Patch Set #2:

      TRY=windows-amd64-longtest,windows-arm64-10,windows-386-2012

To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
Gerrit-Change-Number: 384156
Gerrit-PatchSet: 2
Gerrit-Owner: Than McIntosh <th...@google.com>
Gerrit-Reviewer: Than McIntosh <th...@google.com>
Gerrit-Comment-Date: Tue, 08 Feb 2022 18:15:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Than McIntosh (Gerrit)

unread,
Feb 9, 2022, 11:44:10 AM2/9/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Than McIntosh.

Than McIntosh uploaded patch set #3 to this change.

View Change

cmd/link/internal/ld: always pass ASLR options on windows to ext linker

DO NOT SUBMIT

When doing external linking on windows, the existing Go linker code
assumed that the external linker defaulted to --no-dynamicbase (if no
explicit option was given). This assumption doesn't hold for LLD,
which turns on --dynamicbase by default for 64-bit apps. Change the linker

code to explicitly pass --dynamicbase either way, so as to take the
external linker default out of the equation. This also applies to the
"--high-entropy-va" option as well.

Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
---
M src/cmd/link/internal/ld/lib.go
1 file changed, 51 insertions(+), 8 deletions(-)

To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
Gerrit-Change-Number: 384156
Gerrit-PatchSet: 3
Gerrit-Owner: Than McIntosh <th...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Than McIntosh <th...@google.com>
Gerrit-Attention: Than McIntosh <th...@google.com>
Gerrit-MessageType: newpatchset

Than McIntosh (Gerrit)

unread,
Feb 9, 2022, 11:46:47 AM2/9/22
to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

Patch set 3:Run-TryBot +1Trust +1

View Change

    To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
    Gerrit-Change-Number: 384156
    Gerrit-PatchSet: 3
    Gerrit-Owner: Than McIntosh <th...@google.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-Reviewer: Than McIntosh <th...@google.com>
    Gerrit-Comment-Date: Wed, 09 Feb 2022 16:46:41 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Than McIntosh (Gerrit)

    unread,
    Feb 9, 2022, 12:57:00 PM2/9/22
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Than McIntosh uploaded patch set #4 to this change.

    View Change

    cmd/link/internal/ld: always pass ASLR options on windows to ext linker

    DO NOT SUBMIT

    When doing external linking on windows, the existing Go linker code
    assumed that the external linker defaulted to --no-dynamicbase (if no
    explicit option was given). This assumption doesn't hold for LLD,
    which turns on --dynamicbase by default for 64-bit apps. Change the linker
    code to explicitly pass --dynamicbase either way, so as to take the
    external linker default out of the equation. This also applies to the
    "--high-entropy-va" option as well.

    Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
    ---
    M src/cmd/link/internal/ld/lib.go
    1 file changed, 56 insertions(+), 9 deletions(-)

    To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
    Gerrit-Change-Number: 384156
    Gerrit-PatchSet: 4
    Gerrit-Owner: Than McIntosh <th...@google.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-Reviewer: Than McIntosh <th...@google.com>
    Gerrit-MessageType: newpatchset

    Than McIntosh (Gerrit)

    unread,
    Feb 9, 2022, 1:32:31 PM2/9/22
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Than McIntosh uploaded patch set #5 to this change.

    View Change

    cmd/link/internal/ld: always pass ASLR options on windows to ext linker

    When doing external linking on windows, the existing Go linker code
    assumed that the external linker defaulted to --no-dynamicbase (if no
    explicit option was given). This assumption doesn't hold for LLD,
    which turns on --dynamicbase by default for 64-bit apps. Change the linker
    code to explicitly pass --dynamicbase either way, so as to take the
    external linker default out of the equation. This also applies to the
    "--high-entropy-va" option as well.

    Updates #35006.


    Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
    ---
    M src/cmd/link/internal/ld/lib.go
    1 file changed, 60 insertions(+), 9 deletions(-)

    To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
    Gerrit-Change-Number: 384156
    Gerrit-PatchSet: 5

    Than McIntosh (Gerrit)

    unread,
    Feb 9, 2022, 1:39:19 PM2/9/22
    to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

    Patch set 5:Run-TryBot +1Trust +1

    View Change

      To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
      Gerrit-Change-Number: 384156
      Gerrit-PatchSet: 5
      Gerrit-Owner: Than McIntosh <th...@google.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-Reviewer: Than McIntosh <th...@google.com>
      Gerrit-Comment-Date: Wed, 09 Feb 2022 18:39:14 +0000

      Than McIntosh (Gerrit)

      unread,
      Feb 9, 2022, 2:21:02 PM2/9/22
      to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

      Patch set 6:Run-TryBot +1Trust +1

      View Change

        To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
        Gerrit-Change-Number: 384156
        Gerrit-PatchSet: 6
        Gerrit-Owner: Than McIntosh <th...@google.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Than McIntosh <th...@google.com>
        Gerrit-Comment-Date: Wed, 09 Feb 2022 19:20:57 +0000

        Than McIntosh (Gerrit)

        unread,
        Feb 10, 2022, 8:58:16 AM2/10/22
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

        Attention is currently required from: Than McIntosh.

        Than McIntosh uploaded patch set #7 to this change.

        View Change

        cmd/link/internal/ld: always pass ASLR options on windows to ext linker

        When doing external linking on windows, the existing Go linker code
        assumed that the external linker defaulted to --no-dynamicbase (if no
        explicit option was given). This assumption doesn't hold for LLD,
        which turns on --dynamicbase by default for 64-bit apps. Change the linker
        code to explicitly pass --dynamicbase either way, so as to take the
        external linker default out of the equation. This also applies to the
        "--high-entropy-va" option as well.

        Updates #35006.

        Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
        ---
        M src/cmd/link/internal/ld/lib.go
        1 file changed, 55 insertions(+), 9 deletions(-)

        To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
        Gerrit-Change-Number: 384156
        Gerrit-PatchSet: 7
        Gerrit-Owner: Than McIntosh <th...@google.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Than McIntosh <th...@google.com>
        Gerrit-Attention: Than McIntosh <th...@google.com>
        Gerrit-MessageType: newpatchset

        Than McIntosh (Gerrit)

        unread,
        Feb 10, 2022, 8:58:27 AM2/10/22
        to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

        Patch set 7:Run-TryBot +1Trust +1

        View Change

          To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
          Gerrit-Change-Number: 384156
          Gerrit-PatchSet: 7
          Gerrit-Owner: Than McIntosh <th...@google.com>
          Gerrit-Reviewer: Gopher Robot <go...@golang.org>
          Gerrit-Reviewer: Than McIntosh <th...@google.com>
          Gerrit-Comment-Date: Thu, 10 Feb 2022 13:58:22 +0000

          Than McIntosh (Gerrit)

          unread,
          Feb 10, 2022, 9:54:30 AM2/10/22
          to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

          View Change

          1 comment:

          • Patchset:

            • Patch Set #7:

              OK, after a number of iterations on this patch, it looks like things are a good deal more complicated than I thought.

              With the existing GCC 5.X C compilers installed on our builders, the default (if no other options used) is to have ASLR disabled; if you pass "--dynamicbase" then this turns on ALSR. There is no way to explicitly _disable_ dynamic base on the command line, however: the linker does not accept "--no-dynamicbase" or "--disable-dynamicbase", and [perversely] while it accepts "--dynamicbase=0", this doesn't seem to have any effect. So the _only_ way to get no ASLR is to avoid using any options.

              With the more modern compilers (both the clang/lld/LLVM vintage and with GCC 11+) the default is ASLR, so if you don't pass anything, you get ASLR. If you want to disable ASLR, you can pass "--no-dynamicbase" or "--disable-dynamicbase" but "--dynamicbase=0" does not work.

          To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
          Gerrit-Change-Number: 384156
          Gerrit-PatchSet: 7
          Gerrit-Owner: Than McIntosh <th...@google.com>
          Gerrit-Reviewer: Gopher Robot <go...@golang.org>
          Gerrit-Reviewer: Than McIntosh <th...@google.com>
          Gerrit-Comment-Date: Thu, 10 Feb 2022 14:54:25 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Gerrit-MessageType: comment

          Than McIntosh (Gerrit)

          unread,
          Feb 10, 2022, 10:10:10 AM2/10/22
          to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

          Than McIntosh uploaded patch set #8 to this change.

          View Change

          cmd/link/internal/ld: always pass ASLR options on windows to ext linker

          When doing external linking on windows, the existing Go linker code
          assumed that the external linker defaulted to --no-dynamicbase (if no
          explicit option was given). This assumption doesn't hold for LLD,
          which turns on --dynamicbase by default for 64-bit apps. Change the linker
          code to explicitly pass --dynamicbase either way, so as to take the
          external linker default out of the equation. This also applies to the
          "--high-entropy-va" option as well.

          Updates #35006.

          Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
          ---
          M src/cmd/link/internal/ld/lib.go
          1 file changed, 66 insertions(+), 10 deletions(-)

          To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
          Gerrit-Change-Number: 384156
          Gerrit-PatchSet: 8
          Gerrit-Owner: Than McIntosh <th...@google.com>
          Gerrit-Reviewer: Gopher Robot <go...@golang.org>
          Gerrit-Reviewer: Than McIntosh <th...@google.com>
          Gerrit-MessageType: newpatchset

          Than McIntosh (Gerrit)

          unread,
          Feb 10, 2022, 10:10:57 AM2/10/22
          to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

          Patch set 8:Run-TryBot +1Trust +1

          View Change

            To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
            Gerrit-Change-Number: 384156
            Gerrit-PatchSet: 8
            Gerrit-Owner: Than McIntosh <th...@google.com>
            Gerrit-Reviewer: Gopher Robot <go...@golang.org>
            Gerrit-Reviewer: Than McIntosh <th...@google.com>
            Gerrit-Comment-Date: Thu, 10 Feb 2022 15:10:53 +0000

            Than McIntosh (Gerrit)

            unread,
            Feb 10, 2022, 10:37:10 AM2/10/22
            to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

            Attention is currently required from: Than McIntosh.

            Than McIntosh uploaded patch set #9 to this change.

            View Change

            cmd/link/internal/ld: revise recipe for ASLR enable on windows


            When doing external linking on windows, the existing Go linker code
            assumed that the external linker defaulted to --no-dynamicbase (if no
            explicit option was given). This assumption doesn't hold for LLD,
            which turns on --dynamicbase by default for 64-bit apps. Change the
            linker to detect whether a more modern toolchain is in use and to
            explicitly pass --dynamicbase either way , so as to take the external

            linker default out of the equation. This also applies to the
            "--high-entropy-va" option as well.

            Updates #35006.

            Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
            ---
            M src/cmd/link/internal/ld/lib.go
            1 file changed, 67 insertions(+), 10 deletions(-)

            To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
            Gerrit-Change-Number: 384156
            Gerrit-PatchSet: 9
            Gerrit-Owner: Than McIntosh <th...@google.com>
            Gerrit-Reviewer: Gopher Robot <go...@golang.org>
            Gerrit-Reviewer: Than McIntosh <th...@google.com>
            Gerrit-Attention: Than McIntosh <th...@google.com>
            Gerrit-MessageType: newpatchset

            Than McIntosh (Gerrit)

            unread,
            Feb 10, 2022, 12:50:22 PM2/10/22
            to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

            Patch set 9:Run-TryBot +1Trust +1

            View Change

              To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

              Gerrit-Project: go
              Gerrit-Branch: master
              Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
              Gerrit-Change-Number: 384156
              Gerrit-PatchSet: 9
              Gerrit-Owner: Than McIntosh <th...@google.com>
              Gerrit-Reviewer: Gopher Robot <go...@golang.org>
              Gerrit-Reviewer: Than McIntosh <th...@google.com>
              Gerrit-Comment-Date: Thu, 10 Feb 2022 17:50:17 +0000

              Than McIntosh (Gerrit)

              unread,
              Mar 8, 2022, 8:53:42 AM3/8/22
              to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

              Patch set 10:Run-TryBot +1Trust +1

              View Change

                To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                Gerrit-Change-Number: 384156
                Gerrit-PatchSet: 10
                Gerrit-Owner: Than McIntosh <th...@google.com>
                Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                Gerrit-Reviewer: Than McIntosh <th...@google.com>
                Gerrit-Comment-Date: Tue, 08 Mar 2022 13:53:38 +0000

                Than McIntosh (Gerrit)

                unread,
                Mar 8, 2022, 10:20:48 AM3/8/22
                to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

                View Change

                1 comment:

                To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                Gerrit-Change-Number: 384156
                Gerrit-PatchSet: 10
                Gerrit-Owner: Than McIntosh <th...@google.com>
                Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                Gerrit-Reviewer: Than McIntosh <th...@google.com>
                Gerrit-Comment-Date: Tue, 08 Mar 2022 15:20:44 +0000

                Than McIntosh (Gerrit)

                unread,
                Mar 8, 2022, 10:21:51 AM3/8/22
                to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

                Than McIntosh uploaded patch set #11 to this change.

                View Change

                cmd/link/internal/ld: revise recipe for ASLR enable on windows

                When doing external linking on windows, the existing Go linker code
                assumed that the external linker defaulted to "--no-dynamicbase" (if
                no explicit option was given). This assumption doesn't hold for LLD,
                which turns on "--dynamicbase" by default for 64-bit apps. Change the
                linker to detect whether a more modern toolchain is in use and to
                explicitly pass "--dynamicbase" either way , so as to take the
                external linker default out of the equation. This also applies to the
                "--high-entropy-va" option as well.

                Updates #35006.

                Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                ---
                M src/cmd/link/internal/ld/lib.go
                1 file changed, 67 insertions(+), 10 deletions(-)

                To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                Gerrit-Change-Number: 384156
                Gerrit-PatchSet: 11
                Gerrit-Owner: Than McIntosh <th...@google.com>
                Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                Gerrit-Reviewer: Than McIntosh <th...@google.com>
                Gerrit-MessageType: newpatchset

                Than McIntosh (Gerrit)

                unread,
                Mar 8, 2022, 10:22:53 AM3/8/22
                to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

                Patch set 11:Run-TryBot +1Trust +1

                View Change

                1 comment:

                To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                Gerrit-Project: go
                Gerrit-Branch: master
                Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                Gerrit-Change-Number: 384156
                Gerrit-PatchSet: 11
                Gerrit-Owner: Than McIntosh <th...@google.com>
                Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                Gerrit-Reviewer: Than McIntosh <th...@google.com>
                Gerrit-Comment-Date: Tue, 08 Mar 2022 15:22:50 +0000

                Than McIntosh (Gerrit)

                unread,
                Mar 26, 2022, 12:26:27 PM3/26/22
                to goph...@pubsubhelper.golang.org, Cherry Mui, Gopher Robot, golang-co...@googlegroups.com

                Attention is currently required from: Cherry Mui.

                Patch set 18:Trust +1

                View Change

                  To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                  Gerrit-Project: go
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                  Gerrit-Change-Number: 384156
                  Gerrit-PatchSet: 18
                  Gerrit-Owner: Than McIntosh <th...@google.com>
                  Gerrit-Reviewer: Cherry Mui <cher...@google.com>
                  Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                  Gerrit-Reviewer: Than McIntosh <th...@google.com>
                  Gerrit-Attention: Cherry Mui <cher...@google.com>
                  Gerrit-Comment-Date: Sat, 26 Mar 2022 16:26:22 +0000

                  Than McIntosh (Gerrit)

                  unread,
                  Mar 28, 2022, 6:55:06 AM3/28/22
                  to goph...@pubsubhelper.golang.org, Cherry Mui, Gopher Robot, golang-co...@googlegroups.com

                  Attention is currently required from: Cherry Mui.

                  Patch set 19:Run-TryBot +1Trust +1

                  View Change

                    To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                    Gerrit-Project: go
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                    Gerrit-Change-Number: 384156
                    Gerrit-PatchSet: 19
                    Gerrit-Owner: Than McIntosh <th...@google.com>
                    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
                    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                    Gerrit-Reviewer: Than McIntosh <th...@google.com>
                    Gerrit-Attention: Cherry Mui <cher...@google.com>
                    Gerrit-Comment-Date: Mon, 28 Mar 2022 10:55:02 +0000

                    Cherry Mui (Gerrit)

                    unread,
                    Mar 28, 2022, 11:33:41 AM3/28/22
                    to Than McIntosh, goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

                    Attention is currently required from: Than McIntosh.

                    Patch set 19:Code-Review +2

                    View Change

                    2 comments:

                    To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                    Gerrit-Project: go
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                    Gerrit-Change-Number: 384156
                    Gerrit-PatchSet: 19
                    Gerrit-Owner: Than McIntosh <th...@google.com>
                    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
                    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                    Gerrit-Reviewer: Than McIntosh <th...@google.com>
                    Gerrit-Attention: Than McIntosh <th...@google.com>
                    Gerrit-Comment-Date: Mon, 28 Mar 2022 15:33:35 +0000

                    Than McIntosh (Gerrit)

                    unread,
                    Mar 28, 2022, 11:36:24 AM3/28/22
                    to goph...@pubsubhelper.golang.org, Cherry Mui, Gopher Robot, golang-co...@googlegroups.com

                    View Change

                    2 comments:

                    • File src/cmd/link/internal/ld/lib.go:

                      • Done

                      • Fixed.

                    To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                    Gerrit-Project: go
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                    Gerrit-Change-Number: 384156
                    Gerrit-PatchSet: 19
                    Gerrit-Owner: Than McIntosh <th...@google.com>
                    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
                    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                    Gerrit-Reviewer: Than McIntosh <th...@google.com>
                    Gerrit-Comment-Date: Mon, 28 Mar 2022 15:36:19 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Cherry Mui <cher...@google.com>
                    Gerrit-MessageType: comment

                    Than McIntosh (Gerrit)

                    unread,
                    Mar 28, 2022, 11:38:14 AM3/28/22
                    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

                    Than McIntosh uploaded patch set #20 to this change.

                    View Change

                    cmd/link/internal/ld: revise recipe for ASLR enable on windows

                    When doing external linking on windows, the existing Go linker code
                    assumed that the external linker defaulted to "--no-dynamicbase" (if
                    no explicit option was given). This assumption doesn't hold for LLD,
                    which turns on "--dynamicbase" by default for 64-bit apps. Change the
                    linker to detect whether a more modern toolchain is in use and to
                    explicitly pass "--dynamicbase" either way , so as to take the
                    external linker default out of the equation. This also applies to the
                    "--high-entropy-va" option as well.

                    Updates #35006.

                    Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                    ---
                    M src/cmd/link/internal/ld/lib.go
                    1 file changed, 67 insertions(+), 10 deletions(-)

                    To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                    Gerrit-Project: go
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                    Gerrit-Change-Number: 384156
                    Gerrit-PatchSet: 20
                    Gerrit-Owner: Than McIntosh <th...@google.com>
                    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
                    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                    Gerrit-Reviewer: Than McIntosh <th...@google.com>
                    Gerrit-MessageType: newpatchset

                    Than McIntosh (Gerrit)

                    unread,
                    Mar 28, 2022, 11:39:55 AM3/28/22
                    to goph...@pubsubhelper.golang.org, Cherry Mui, Gopher Robot, golang-co...@googlegroups.com

                    Patch set 21:Run-TryBot +1Trust +1

                    View Change

                    1 comment:

                    • Patchset:

                      • Patch Set #21:

                        TRY=windows-amd64-longtest,windows-amd64-race,windows-arm64-11

                    To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                    Gerrit-Project: go
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                    Gerrit-Change-Number: 384156
                    Gerrit-PatchSet: 21
                    Gerrit-Owner: Than McIntosh <th...@google.com>
                    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
                    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                    Gerrit-Reviewer: Than McIntosh <th...@google.com>
                    Gerrit-Comment-Date: Mon, 28 Mar 2022 15:39:51 +0000

                    Than McIntosh (Gerrit)

                    unread,
                    Mar 31, 2022, 8:34:13 AM3/31/22
                    to goph...@pubsubhelper.golang.org, Gopher Robot, Cherry Mui, golang-co...@googlegroups.com

                    Patch set 22:Run-TryBot +1Trust +1

                    View Change

                      To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                      Gerrit-Project: go
                      Gerrit-Branch: master
                      Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                      Gerrit-Change-Number: 384156
                      Gerrit-PatchSet: 22
                      Gerrit-Owner: Than McIntosh <th...@google.com>
                      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
                      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                      Gerrit-Reviewer: Than McIntosh <th...@google.com>
                      Gerrit-Comment-Date: Thu, 31 Mar 2022 12:34:10 +0000

                      Than McIntosh (Gerrit)

                      unread,
                      Mar 31, 2022, 3:40:35 PM3/31/22
                      to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Gopher Robot, Cherry Mui, golang-co...@googlegroups.com

                      Than McIntosh submitted this change.

                      View Change



                      19 is the latest approved patch-set.
                      The change was submitted with unreviewed changes in the following files:

                      ```
                      The name of the file: src/cmd/link/internal/ld/lib.go
                      Insertions: 3, Deletions: 3.

                      The diff is too large to show. Please review the diff.
                      ```

                      Approvals: Cherry Mui: Looks good to me, approved Than McIntosh: Trusted; Run TryBots Gopher Robot: TryBots succeeded
                      cmd/link/internal/ld: revise recipe for ASLR enable on windows

                      When doing external linking on windows, the existing Go linker code
                      assumed that the external linker defaulted to "--no-dynamicbase" (if
                      no explicit option was given). This assumption doesn't hold for LLD,
                      which turns on "--dynamicbase" by default for 64-bit apps. Change the
                      linker to detect whether a more modern toolchain is in use and to
                      explicitly pass "--dynamicbase" either way , so as to take the
                      external linker default out of the equation. This also applies to the
                      "--high-entropy-va" option as well.

                      Updates #35006.

                      Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                      Reviewed-on: https://go-review.googlesource.com/c/go/+/384156
                      Reviewed-by: Cherry Mui <cher...@google.com>
                      Trust: Than McIntosh <th...@google.com>
                      Run-TryBot: Than McIntosh <th...@google.com>
                      TryBot-Result: Gopher Robot <go...@golang.org>
                      ---
                      M src/cmd/link/internal/ld/lib.go
                      1 file changed, 72 insertions(+), 10 deletions(-)

                      diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
                      index 6f9c7c2..4295bb8 100644
                      --- a/src/cmd/link/internal/ld/lib.go
                      +++ b/src/cmd/link/internal/ld/lib.go
                      @@ -1353,13 +1353,52 @@
                      argv = append(argv, "-Wl,-bbigtoc")
                      }

                      - // Enable ASLR on Windows.
                      - addASLRargs := func(argv []string) []string {
                      - // Enable ASLR.
                      - argv = append(argv, "-Wl,--dynamicbase")
                      + // Enable/disable ASLR on Windows.
                      + addASLRargs := func(argv []string, val bool) []string {
                      + // Old/ancient versions of GCC support "--dynamicbase" and
                      + // "--high-entropy-va" but don't enable it by default. In
                      + // addition, they don't accept "--disable-dynamicbase" or
                      + // "--no-dynamicbase", so the only way to disable ASLR is to
                      + // not pass any flags at all.
                      + //
                      + // More modern versions of GCC (and also clang) enable ASLR
                      + // by default. With these compilers, however you can turn it
                      + // off if you want using "--disable-dynamicbase" or
                      + // "--no-dynamicbase".
                      + //
                      + // The strategy below is to try using "--disable-dynamicbase";
                      + // if this succeeds, then assume we're working with more
                      + // modern compilers and act accordingly. If it fails, assume
                      + // an ancient compiler with ancient defaults.
                      + var dbopt string
                      + var heopt string
                      + dbon := "--dynamicbase"
                      + heon := "--high-entropy-va"
                      + dboff := "--disable-dynamicbase"
                      + heoff := "--disable-high-entropy-va"
                      + if val {
                      + dbopt = dbon
                      + heopt = heon
                      + } else {
                      + // Test to see whether "--disable-dynamicbase" works.
                      + newer := linkerFlagSupported(ctxt.Arch, argv[0], "", "-Wl,"+dboff)
                      + if newer {
                      + // Newer compiler, which supports both on/off options.
                      + dbopt = dboff
                      + heopt = heoff
                      + } else {
                      + // older toolchain: we have to say nothing in order to
                      + // get a no-ASLR binary.
                      + dbopt = ""
                      + heopt = ""
                      + }
                      + }
                      + if dbopt != "" {
                      + argv = append(argv, "-Wl,"+dbopt)
                      + }
                      // enable high-entropy ASLR on 64-bit.
                      - if ctxt.Arch.PtrSize >= 8 {
                      - argv = append(argv, "-Wl,--high-entropy-va")
                      + if ctxt.Arch.PtrSize >= 8 && heopt != "" {
                      + argv = append(argv, "-Wl,"+heopt)
                      }
                      return argv
                      }
                      @@ -1376,7 +1415,7 @@
                      switch ctxt.HeadType {
                      case objabi.Hdarwin, objabi.Haix:
                      case objabi.Hwindows:
                      - argv = addASLRargs(argv)
                      + argv = addASLRargs(argv, *flagAslr)
                      default:
                      // ELF.
                      if ctxt.UseRelro() {
                      @@ -1393,9 +1432,7 @@
                      }
                      argv = append(argv, "-shared")
                      if ctxt.HeadType == objabi.Hwindows {
                      - if *flagAslr {
                      - argv = addASLRargs(argv)
                      - }
                      + argv = addASLRargs(argv, *flagAslr)
                      } else {
                      // Pass -z nodelete to mark the shared library as
                      // non-closeable: a dlclose will do nothing.

                      To view, visit change 384156. To unsubscribe, or for help writing mail filters, visit settings.

                      Gerrit-Project: go
                      Gerrit-Branch: master
                      Gerrit-Change-Id: I3e12cf6d331c9d003e3d2bd566d45de5710588b9
                      Gerrit-Change-Number: 384156
                      Gerrit-PatchSet: 23
                      Gerrit-Owner: Than McIntosh <th...@google.com>
                      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
                      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
                      Gerrit-Reviewer: Than McIntosh <th...@google.com>
                      Gerrit-MessageType: merged
                      Reply all
                      Reply to author
                      Forward
                      0 new messages