diff options
author | Than McIntosh <thanm@google.com> | 2022-07-01 08:39:12 -0400 |
---|---|---|
committer | Than McIntosh <thanm@google.com> | 2022-07-07 14:33:55 +0000 |
commit | 0c7fcf6bd1fd8df2bfae3a482f1261886f6313c1 (patch) | |
tree | d9a0ee0e8eea699ea1a5a2faa9b821824175ca8b | |
parent | eaf21256545ae04a35fa070763faa6eb2098591d (diff) | |
download | go-0c7fcf6bd1fd8df2bfae3a482f1261886f6313c1.tar.gz go-0c7fcf6bd1fd8df2bfae3a482f1261886f6313c1.zip |
cmd/link: explicitly disable PIE for windows/amd64 -race mode
Turn off PIE explicitly for windows/amd64 when -race is in effect,
since at the moment the race detector runtime doesn't seem to handle
PIE binaries correctly. Note that newer C compilers on windows
produce PIE binaries by default, so the Go linker needs to explicitly
turn off PIE when invoking the external linker in this case.
Updates #53539.
Change-Id: Ib990621f22cf61a5fa383584bab81d3dfd7552e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/415676
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
-rw-r--r-- | src/cmd/link/internal/ld/lib.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 565ff9d634..18910ddb85 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1426,10 +1426,23 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-Wl,-pagezero_size,4000000") } } + if *flagRace && ctxt.HeadType == objabi.Hwindows { + // Current windows/amd64 race detector tsan support + // library can't handle PIE mode (see #53539 for more details). + // For now, explicitly disable PIE (since some compilers + // default to it) if -race is in effect. + argv = addASLRargs(argv, false) + } case BuildModePIE: switch ctxt.HeadType { case objabi.Hdarwin, objabi.Haix: case objabi.Hwindows: + if *flagAslr && *flagRace { + // Current windows/amd64 race detector tsan support + // library can't handle PIE mode (see #53539 for more details). + // Disable alsr if -race in effect. + *flagAslr = false + } argv = addASLRargs(argv, *flagAslr) default: // ELF. |