mirror of
https://github.com/golang/go
synced 2024-09-29 22:24:33 -06:00
cmd/link: add support for openbsd/ppc64
Add linker support for the openbsd/ppc64 port. Updates #56001 Change-Id: I18bc19b4086599996aebfbe68f2e85e1200589ca Reviewed-on: https://go-review.googlesource.com/c/go/+/475619 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Paul Murphy <murp@ibm.com> Reviewed-by: Eric Grosse <grosse@gmail.com>
This commit is contained in:
parent
4711299661
commit
7f92dcc88d
4
src/cmd/dist/build.go
vendored
4
src/cmd/dist/build.go
vendored
@ -589,7 +589,9 @@ func mustLinkExternal(goos, goarch string, cgoEnabled bool) bool {
|
|||||||
}
|
}
|
||||||
case "ppc64":
|
case "ppc64":
|
||||||
// Big Endian PPC64 cgo internal linking is not implemented for aix or linux.
|
// Big Endian PPC64 cgo internal linking is not implemented for aix or linux.
|
||||||
return true
|
if goos == "aix" || goos == "linux" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch goos {
|
switch goos {
|
||||||
|
@ -217,7 +217,7 @@ func determineLinkMode(ctxt *Link) {
|
|||||||
}
|
}
|
||||||
case LinkExternal:
|
case LinkExternal:
|
||||||
switch {
|
switch {
|
||||||
case buildcfg.GOARCH == "ppc64" && buildcfg.GOOS != "aix":
|
case buildcfg.GOARCH == "ppc64" && buildcfg.GOOS == "linux":
|
||||||
Exitf("external linking not supported for %s/ppc64", buildcfg.GOOS)
|
Exitf("external linking not supported for %s/ppc64", buildcfg.GOOS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ func Elfinit(ctxt *Link) {
|
|||||||
switch ctxt.Arch.Family {
|
switch ctxt.Arch.Family {
|
||||||
// 64-bit architectures
|
// 64-bit architectures
|
||||||
case sys.PPC64, sys.S390X:
|
case sys.PPC64, sys.S390X:
|
||||||
if ctxt.Arch.ByteOrder == binary.BigEndian {
|
if ctxt.Arch.ByteOrder == binary.BigEndian && ctxt.HeadType != objabi.Hopenbsd {
|
||||||
ehdr.Flags = 1 /* Version 1 ABI */
|
ehdr.Flags = 1 /* Version 1 ABI */
|
||||||
} else {
|
} else {
|
||||||
ehdr.Flags = 2 /* Version 2 ABI */
|
ehdr.Flags = 2 /* Version 2 ABI */
|
||||||
|
@ -270,9 +270,8 @@ func genstubs(ctxt *ld.Link, ldr *loader.Loader) {
|
|||||||
for _, s := range ctxt.Textp {
|
for _, s := range ctxt.Textp {
|
||||||
relocs := ldr.Relocs(s)
|
relocs := ldr.Relocs(s)
|
||||||
for i := 0; i < relocs.Count(); i++ {
|
for i := 0; i < relocs.Count(); i++ {
|
||||||
r := relocs.At(i)
|
switch r := relocs.At(i); r.Type() {
|
||||||
switch r.Type() {
|
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL24), objabi.R_CALLPOWER:
|
||||||
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL24):
|
|
||||||
switch ldr.SymType(r.Sym()) {
|
switch ldr.SymType(r.Sym()) {
|
||||||
case sym.SDYNIMPORT:
|
case sym.SDYNIMPORT:
|
||||||
// This call goes through the PLT, generate and call through a PLT stub.
|
// This call goes through the PLT, generate and call through a PLT stub.
|
||||||
@ -633,7 +632,7 @@ func addelfdynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s lo
|
|||||||
su.SetRelocAdd(rIdx, r.Add()+localEoffset)
|
su.SetRelocAdd(rIdx, r.Add()+localEoffset)
|
||||||
|
|
||||||
if targType == sym.SDYNIMPORT {
|
if targType == sym.SDYNIMPORT {
|
||||||
// Should have been handled in elfsetupplt
|
// Should have been handled in genstubs
|
||||||
ldr.Errorf(s, "unexpected R_PPC64_REL24 for dyn import")
|
ldr.Errorf(s, "unexpected R_PPC64_REL24 for dyn import")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1575,7 +1574,6 @@ func archrelocvariant(target *ld.Target, ldr *loader.Loader, r loader.Reloc, rv
|
|||||||
var o1 uint32
|
var o1 uint32
|
||||||
if target.IsBigEndian() {
|
if target.IsBigEndian() {
|
||||||
o1 = binary.BigEndian.Uint32(p[r.Off()-2:])
|
o1 = binary.BigEndian.Uint32(p[r.Off()-2:])
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
o1 = binary.LittleEndian.Uint32(p[r.Off():])
|
o1 = binary.LittleEndian.Uint32(p[r.Off():])
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func Init() (*sys.Arch, ld.Arch) {
|
|||||||
LinuxdynldMusl: musl,
|
LinuxdynldMusl: musl,
|
||||||
|
|
||||||
Freebsddynld: "XXX",
|
Freebsddynld: "XXX",
|
||||||
Openbsddynld: "XXX",
|
Openbsddynld: "/usr/libexec/ld.so",
|
||||||
Netbsddynld: "XXX",
|
Netbsddynld: "XXX",
|
||||||
Dragonflydynld: "XXX",
|
Dragonflydynld: "XXX",
|
||||||
Solarisdynld: "XXX",
|
Solarisdynld: "XXX",
|
||||||
@ -100,7 +100,8 @@ func archinit(ctxt *ld.Link) {
|
|||||||
*ld.FlagRound = 4096
|
*ld.FlagRound = 4096
|
||||||
}
|
}
|
||||||
|
|
||||||
case objabi.Hlinux: /* ppc64 elf */
|
case objabi.Hlinux, /* ppc64 elf */
|
||||||
|
objabi.Hopenbsd:
|
||||||
ld.Elfinit(ctxt)
|
ld.Elfinit(ctxt)
|
||||||
ld.HEADR = ld.ELFRESERVE
|
ld.HEADR = ld.ELFRESERVE
|
||||||
if *ld.FlagTextAddr == -1 {
|
if *ld.FlagTextAddr == -1 {
|
||||||
|
@ -99,7 +99,9 @@ func MustLinkExternal(goos, goarch string, withCgo bool) bool {
|
|||||||
case "ppc64":
|
case "ppc64":
|
||||||
// Big Endian PPC64 cgo internal linking is not implemented for aix or linux.
|
// Big Endian PPC64 cgo internal linking is not implemented for aix or linux.
|
||||||
// https://go.dev/issue/8912
|
// https://go.dev/issue/8912
|
||||||
return true
|
if goos == "aix" || goos == "linux" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch goos {
|
switch goos {
|
||||||
|
Loading…
Reference in New Issue
Block a user