From: Joel Sing Date: Thu, 13 Apr 2023 19:47:36 +0000 (+1000) Subject: cmd/link/internal/ld: disable execute-only for external linking on openbsd/arm64 X-Git-Tag: go1.21rc1~889 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=dd53a439206e9b4bf194eb00fb28577a03d86df5;p=gostls13.git cmd/link/internal/ld: disable execute-only for external linking on openbsd/arm64 The Go arm64 assembler places constants into the text section of a binary. OpenBSD 7.3 enabled xonly by default on OpenBSD/arm64. This means that any externally linked Go binary now segfaults. Disable execute-only when invoking the external linker on openbsd/arm64, in order to work around this issue. Updates #59615 Change-Id: I1a291293da3c6e4409b21873d066ea15e9bfe280 Reviewed-on: https://go-review.googlesource.com/c/go/+/484555 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Reviewed-by: Aaron Bieber Run-TryBot: Joel Sing Reviewed-by: Than McIntosh --- diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index b2a7daba23..c88a955a0c 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1407,6 +1407,12 @@ func (ctxt *Link) hostlink() { case objabi.Hopenbsd: argv = append(argv, "-Wl,-nopie") argv = append(argv, "-pthread") + if ctxt.Arch.InFamily(sys.ARM64) { + // Disable execute-only on openbsd/arm64 - the Go arm64 assembler + // currently stores constants in the text section rather than in rodata. + // See issue #59615. + argv = append(argv, "-Wl,--no-execute-only") + } case objabi.Hwindows: if windowsgui { argv = append(argv, "-mwindows")