Commit a6b480bc authored by Bill O'Farrell's avatar Bill O'Farrell Committed by Michael Munday

cmd/go: implement -buildmode=plugin for s390x

Simple change to allow plugins for linux on s390x

Change-Id: I5c262ab81aac10d1dcb03381a48e5b9694b7a87a
Reviewed-on: https://go-review.googlesource.com/37451
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent febafe60
...@@ -785,7 +785,7 @@ func (t *tester) supportedBuildmode(mode string) bool { ...@@ -785,7 +785,7 @@ func (t *tester) supportedBuildmode(mode string) bool {
// linux-arm64 is missing because it causes the external linker // linux-arm64 is missing because it causes the external linker
// to crash, see https://golang.org/issue/17138 // to crash, see https://golang.org/issue/17138
switch pair { switch pair {
case "linux-386", "linux-amd64", "linux-arm": case "linux-386", "linux-amd64", "linux-arm", "linux-s390x":
return true return true
} }
return false return false
......
...@@ -347,7 +347,7 @@ func BuildModeInit() { ...@@ -347,7 +347,7 @@ func BuildModeInit() {
codegenArg = "-fPIC" codegenArg = "-fPIC"
} else { } else {
switch platform { switch platform {
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x",
"android/amd64", "android/arm", "android/arm64", "android/386": "android/amd64", "android/arm", "android/arm64", "android/386":
default: default:
base.Fatalf("-buildmode=plugin not supported on %s\n", platform) base.Fatalf("-buildmode=plugin not supported on %s\n", platform)
......
...@@ -84,7 +84,7 @@ func (mode *BuildMode) Set(s string) error { ...@@ -84,7 +84,7 @@ func (mode *BuildMode) Set(s string) error {
switch obj.GOOS { switch obj.GOOS {
case "linux": case "linux":
switch obj.GOARCH { switch obj.GOARCH {
case "386", "amd64", "arm", "arm64": case "386", "amd64", "arm", "arm64", "s390x":
default: default:
return badmode() return badmode()
} }
......
...@@ -52,7 +52,7 @@ func gentext(ctxt *ld.Link) { ...@@ -52,7 +52,7 @@ func gentext(ctxt *ld.Link) {
return return
} }
addmoduledata := ctxt.Syms.Lookup("runtime.addmoduledata", 0) addmoduledata := ctxt.Syms.Lookup("runtime.addmoduledata", 0)
if addmoduledata.Type == obj.STEXT { if addmoduledata.Type == obj.STEXT && ld.Buildmode != ld.BuildmodePlugin {
// we're linking a module containing the runtime -> no need for // we're linking a module containing the runtime -> no need for
// an init function // an init function
return return
...@@ -89,7 +89,9 @@ func gentext(ctxt *ld.Link) { ...@@ -89,7 +89,9 @@ func gentext(ctxt *ld.Link) {
// undef (for debugging) // undef (for debugging)
ld.Adduint32(ctxt, initfunc, 0) ld.Adduint32(ctxt, initfunc, 0)
if ld.Buildmode == ld.BuildmodePlugin {
ctxt.Textp = append(ctxt.Textp, addmoduledata)
}
ctxt.Textp = append(ctxt.Textp, initfunc) ctxt.Textp = append(ctxt.Textp, initfunc)
initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0) initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0)
initarray_entry.Attr |= ld.AttrLocal initarray_entry.Attr |= ld.AttrLocal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment