mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: enable -buildmode=plugin for ppc64le
This enables support for the buildmode plugin on ppc64le. Fixes #20756 Change-Id: I83241ff63f9b5c366fe0496cf46a3f67d75d08ac Reviewed-on: https://go-review.googlesource.com/55850 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
dc3b8a193c
commit
e9cbabb334
5 changed files with 21 additions and 7 deletions
2
src/cmd/dist/test.go
vendored
2
src/cmd/dist/test.go
vendored
|
|
@ -840,7 +840,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", "linux-s390x":
|
case "linux-386", "linux-amd64", "linux-arm", "linux-s390x", "linux-ppc64le":
|
||||||
return true
|
return true
|
||||||
case "darwin-amd64":
|
case "darwin-amd64":
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -356,7 +356,7 @@ func BuildModeInit() {
|
||||||
codegenArg = "-fPIC"
|
codegenArg = "-fPIC"
|
||||||
} else {
|
} else {
|
||||||
switch platform {
|
switch platform {
|
||||||
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x",
|
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le",
|
||||||
"android/amd64", "android/arm", "android/arm64", "android/386":
|
"android/amd64", "android/arm", "android/arm64", "android/386":
|
||||||
case "darwin/amd64":
|
case "darwin/amd64":
|
||||||
// Skip DWARF generation due to #21647
|
// Skip DWARF generation due to #21647
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ func (mode *BuildMode) Set(s string) error {
|
||||||
switch objabi.GOOS {
|
switch objabi.GOOS {
|
||||||
case "linux":
|
case "linux":
|
||||||
switch objabi.GOARCH {
|
switch objabi.GOARCH {
|
||||||
case "386", "amd64", "arm", "arm64", "s390x":
|
case "386", "amd64", "arm", "arm64", "s390x", "ppc64le":
|
||||||
default:
|
default:
|
||||||
return badmode()
|
return badmode()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,8 +168,12 @@ func (ctxt *Link) DynlinkingGo() bool {
|
||||||
if !ctxt.Loaded {
|
if !ctxt.Loaded {
|
||||||
panic("DynlinkingGo called before all symbols loaded")
|
panic("DynlinkingGo called before all symbols loaded")
|
||||||
}
|
}
|
||||||
canUsePlugins := ctxt.Syms.ROLookup("plugin.Open", 0) != nil
|
return Buildmode == BuildmodeShared || *FlagLinkshared || Buildmode == BuildmodePlugin || ctxt.CanUsePlugins()
|
||||||
return Buildmode == BuildmodeShared || *FlagLinkshared || Buildmode == BuildmodePlugin || canUsePlugins
|
}
|
||||||
|
|
||||||
|
// CanUsePlugins returns whether a plugins can be used
|
||||||
|
func (ctxt *Link) CanUsePlugins() bool {
|
||||||
|
return ctxt.Syms.ROLookup("plugin.Open", 0) != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseRelro returns whether to make use of "read only relocations" aka
|
// UseRelro returns whether to make use of "read only relocations" aka
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ func genplt(ctxt *ld.Link) {
|
||||||
|
|
||||||
func genaddmoduledata(ctxt *ld.Link) {
|
func genaddmoduledata(ctxt *ld.Link) {
|
||||||
addmoduledata := ctxt.Syms.ROLookup("runtime.addmoduledata", 0)
|
addmoduledata := ctxt.Syms.ROLookup("runtime.addmoduledata", 0)
|
||||||
if addmoduledata.Type == ld.STEXT {
|
if addmoduledata.Type == ld.STEXT && ld.Buildmode != ld.BuildmodePlugin {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
addmoduledata.Attr |= ld.AttrReachable
|
addmoduledata.Attr |= ld.AttrReachable
|
||||||
|
|
@ -147,6 +147,7 @@ func genaddmoduledata(ctxt *ld.Link) {
|
||||||
rel.Off = int32(initfunc.Size)
|
rel.Off = int32(initfunc.Size)
|
||||||
rel.Siz = 8
|
rel.Siz = 8
|
||||||
rel.Sym = ctxt.Syms.Lookup(".TOC.", 0)
|
rel.Sym = ctxt.Syms.Lookup(".TOC.", 0)
|
||||||
|
rel.Sym.Attr |= ld.AttrReachable
|
||||||
rel.Type = objabi.R_ADDRPOWER_PCREL
|
rel.Type = objabi.R_ADDRPOWER_PCREL
|
||||||
o(0x3c4c0000)
|
o(0x3c4c0000)
|
||||||
// addi r2, r2, .TOC.-func@l
|
// addi r2, r2, .TOC.-func@l
|
||||||
|
|
@ -159,7 +160,13 @@ func genaddmoduledata(ctxt *ld.Link) {
|
||||||
rel = ld.Addrel(initfunc)
|
rel = ld.Addrel(initfunc)
|
||||||
rel.Off = int32(initfunc.Size)
|
rel.Off = int32(initfunc.Size)
|
||||||
rel.Siz = 8
|
rel.Siz = 8
|
||||||
rel.Sym = ctxt.Syms.Lookup("local.moduledata", 0)
|
if !ctxt.CanUsePlugins() {
|
||||||
|
rel.Sym = ctxt.Syms.Lookup("local.moduledata", 0)
|
||||||
|
} else {
|
||||||
|
rel.Sym = ctxt.Syms.Lookup("runtime.firstmoduledata", 0)
|
||||||
|
}
|
||||||
|
rel.Sym.Attr |= ld.AttrReachable
|
||||||
|
rel.Sym.Attr |= ld.AttrLocal
|
||||||
rel.Type = objabi.R_ADDRPOWER_GOT
|
rel.Type = objabi.R_ADDRPOWER_GOT
|
||||||
o(0x3c620000)
|
o(0x3c620000)
|
||||||
// ld r3, local.moduledata@got@l(r3)
|
// ld r3, local.moduledata@got@l(r3)
|
||||||
|
|
@ -182,6 +189,9 @@ func genaddmoduledata(ctxt *ld.Link) {
|
||||||
// blr
|
// blr
|
||||||
o(0x4e800020)
|
o(0x4e800020)
|
||||||
|
|
||||||
|
if ld.Buildmode == ld.BuildmodePlugin {
|
||||||
|
ctxt.Textp = append(ctxt.Textp, addmoduledata)
|
||||||
|
}
|
||||||
initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0)
|
initarray_entry := ctxt.Syms.Lookup("go.link.addmoduledatainit", 0)
|
||||||
ctxt.Textp = append(ctxt.Textp, initfunc)
|
ctxt.Textp = append(ctxt.Textp, initfunc)
|
||||||
initarray_entry.Attr |= ld.AttrReachable
|
initarray_entry.Attr |= ld.AttrReachable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue