aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-03-10 15:37:17 -0500
committerGopher Robot <gobot@golang.org>2023-03-15 13:31:05 +0000
commitbbf795ebb114918a8e8dc7fd4d825cd5928d3f4d (patch)
tree814cd8f52220d444b6bf621b8b2c798ec643858d /src/cmd/link
parenta8cd10f2ab66d15ec43c6c6f688c3362f638237f (diff)
downloadgo-bbf795ebb114918a8e8dc7fd4d825cd5928d3f4d.tar.xz
internal/platform: add a function to report whether default builds are PIE
This consolidates a condition that was previously repeated (in different approximations) in several different places in the code. For #58807. Change-Id: Idd308759f6262b1f5c61f79022965612319edf94 Reviewed-on: https://go-review.googlesource.com/c/go/+/475457 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/link')
-rw-r--r--src/cmd/link/internal/ld/dwarf_test.go15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/cmd/link/internal/ld/dwarf_test.go b/src/cmd/link/internal/ld/dwarf_test.go
index abbfec0c41..103ca5a4ab 100644
--- a/src/cmd/link/internal/ld/dwarf_test.go
+++ b/src/cmd/link/internal/ld/dwarf_test.go
@@ -8,6 +8,7 @@ import (
"debug/dwarf"
"debug/pe"
"fmt"
+ "internal/platform"
"internal/testenv"
"io"
"os"
@@ -891,12 +892,6 @@ func TestRuntimeTypeAttrInternal(t *testing.T) {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
- // TODO(#58807): factor this condition out into a function in
- // internal/platform so that it won't get out of sync with cmd/link.
- if runtime.GOOS == "android" || runtime.GOOS == "windows" {
- t.Skipf("skipping on %s; test is incompatible with relocatable binaries", runtime.GOOS)
- }
-
testRuntimeTypeAttr(t, "-ldflags=-linkmode=internal")
}
@@ -914,10 +909,6 @@ func TestRuntimeTypeAttrExternal(t *testing.T) {
t.Skip("-linkmode=external not supported on ppc64")
}
- if runtime.GOOS == "windows" {
- t.Skip("skipping on windows; test is incompatible with relocatable binaries")
- }
-
testRuntimeTypeAttr(t, "-ldflags=-linkmode=external")
}
@@ -985,9 +976,7 @@ func main() {
t.Fatalf("*main.X DIE had no runtime type attr. DIE: %v", dies[0])
}
- // TODO(#58807): factor this condition out into a function in
- // internal/platform so that it won't get out of sync with cmd/link.
- if (runtime.GOOS == "darwin" && runtime.GOARCH == "arm64") || runtime.GOOS == "android" {
+ if platform.DefaultPIE(runtime.GOOS, runtime.GOARCH) {
return // everything is PIE, addresses are relocated
}
if rtAttr.(uint64)+types.Addr != addr {