1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:20:22 -07:00

cmd: enable -buildmode=pie on aix/ppc64

Change-Id: I939518462c931ba9feb125b2f299ef0706b124ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/168879
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Clément Chigot 2019-03-22 12:54:37 +01:00 committed by Ian Lance Taylor
parent 08692bed1e
commit cf952e9e62
4 changed files with 6 additions and 4 deletions

View File

@ -963,7 +963,8 @@ func (t *tester) supportedBuildmode(mode string) bool {
return false return false
case "pie": case "pie":
switch pair { switch pair {
case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x", case "aix/ppc64",
"linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x",
"android-amd64", "android-arm", "android-arm64", "android-386": "android-amd64", "android-arm", "android-arm64", "android-386":
return true return true
case "darwin-amd64": case "darwin-amd64":

View File

@ -164,6 +164,7 @@ func buildModeInit() {
codegenArg = "-shared" codegenArg = "-shared"
case "darwin/amd64": case "darwin/amd64":
codegenArg = "-shared" codegenArg = "-shared"
case "aix/ppc64":
default: default:
base.Fatalf("-buildmode=pie not supported on %s\n", platform) base.Fatalf("-buildmode=pie not supported on %s\n", platform)
} }

View File

@ -38,7 +38,7 @@ func (mode *BuildMode) Set(s string) error {
*mode = BuildModeExe *mode = BuildModeExe
case "pie": case "pie":
switch objabi.GOOS { switch objabi.GOOS {
case "android", "linux": case "aix", "android", "linux":
case "darwin", "freebsd": case "darwin", "freebsd":
switch objabi.GOARCH { switch objabi.GOARCH {
case "amd64": case "amd64":

View File

@ -179,7 +179,7 @@ func (ctxt *Link) CanUsePlugins() bool {
func (ctxt *Link) UseRelro() bool { func (ctxt *Link) UseRelro() bool {
switch ctxt.BuildMode { switch ctxt.BuildMode {
case BuildModeCArchive, BuildModeCShared, BuildModeShared, BuildModePIE, BuildModePlugin: case BuildModeCArchive, BuildModeCShared, BuildModeShared, BuildModePIE, BuildModePlugin:
return ctxt.IsELF return ctxt.IsELF || ctxt.HeadType == objabi.Haix
default: default:
return ctxt.linkShared || (ctxt.HeadType == objabi.Haix && ctxt.LinkMode == LinkExternal) return ctxt.linkShared || (ctxt.HeadType == objabi.Haix && ctxt.LinkMode == LinkExternal)
} }
@ -1173,7 +1173,7 @@ func (ctxt *Link) hostlink() {
} }
case BuildModePIE: case BuildModePIE:
// ELF. // ELF.
if ctxt.HeadType != objabi.Hdarwin { if ctxt.HeadType != objabi.Hdarwin && ctxt.HeadType != objabi.Haix {
if ctxt.UseRelro() { if ctxt.UseRelro() {
argv = append(argv, "-Wl,-z,relro") argv = append(argv, "-Wl,-z,relro")
} }