]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist,cmd/link: enable PIE buildmode on openbsd/arm64
authorJoel Sing <joel@sing.id.au>
Sat, 2 Mar 2024 08:53:20 +0000 (19:53 +1100)
committerJoel Sing <joel@sing.id.au>
Sat, 16 Mar 2024 02:25:22 +0000 (02:25 +0000)
The PIE buildmode works correctly on openbsd/arm64, hence enable it.

Updates #59866

Change-Id: I2f3c2839893659391539fafa12891d64f867e189
Reviewed-on: https://go-review.googlesource.com/c/go/+/570375
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Joel Sing <joel@sing.id.au>

src/cmd/dist/test.go
src/cmd/link/internal/ld/lib.go
src/internal/platform/supported.go

index 8f4b081ad10811c042e02551f6af2beaa1e34626..95d9cab816bae68e47927ba2a0e2c1c1f9f036f7 100644 (file)
@@ -1637,6 +1637,7 @@ func buildModeSupported(compiler, buildmode, goos, goarch string) bool {
                        "darwin/amd64", "darwin/arm64",
                        "ios/amd64", "ios/arm64",
                        "aix/ppc64",
+                       "openbsd/arm64",
                        "windows/386", "windows/amd64", "windows/arm", "windows/arm64":
                        return true
                }
index c68da4070b4762266920bc2bc428179c1b3d8de8..35b9ca01d2147fd20ed291aeb485a87ede57aaa5 100644 (file)
@@ -1436,13 +1436,15 @@ func (ctxt *Link) hostlink() {
                        }
                }
        case objabi.Hopenbsd:
-               argv = append(argv, "-Wl,-nopie")
+               argv = append(argv, "-pthread")
+               if ctxt.BuildMode != BuildModePIE {
+                       argv = append(argv, "-Wl,-nopie")
+               }
                if linkerFlagSupported(ctxt.Arch, argv[0], "", "-Wl,-z,nobtcfi") {
                        // -Wl,-z,nobtcfi is only supported on OpenBSD 7.4+, remove guard
                        // when OpenBSD 7.5 is released and 7.3 is no longer supported.
                        argv = append(argv, "-Wl,-z,nobtcfi")
                }
-               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.
index 82c66e21952a741a15fd4f37f1f5ce7a92c67124..8f43cbf25f9bfd0778d568c13b520ccbd2a4b462 100644 (file)
@@ -192,6 +192,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
                        "darwin/amd64", "darwin/arm64",
                        "ios/amd64", "ios/arm64",
                        "aix/ppc64",
+                       "openbsd/arm64",
                        "windows/386", "windows/amd64", "windows/arm", "windows/arm64":
                        return true
                }