1
0
mirror of https://github.com/golang/go synced 2024-09-29 20:14:29 -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:
Joel Sing 2023-03-03 01:24:00 +11:00
parent 4711299661
commit 7f92dcc88d
6 changed files with 14 additions and 11 deletions

View File

@ -589,7 +589,9 @@ func mustLinkExternal(goos, goarch string, cgoEnabled bool) bool {
}
case "ppc64":
// Big Endian PPC64 cgo internal linking is not implemented for aix or linux.
return true
if goos == "aix" || goos == "linux" {
return true
}
}
switch goos {

View File

@ -217,7 +217,7 @@ func determineLinkMode(ctxt *Link) {
}
case LinkExternal:
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)
}
}

View File

@ -243,7 +243,7 @@ func Elfinit(ctxt *Link) {
switch ctxt.Arch.Family {
// 64-bit architectures
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 */
} else {
ehdr.Flags = 2 /* Version 2 ABI */

View File

@ -270,9 +270,8 @@ func genstubs(ctxt *ld.Link, ldr *loader.Loader) {
for _, s := range ctxt.Textp {
relocs := ldr.Relocs(s)
for i := 0; i < relocs.Count(); i++ {
r := relocs.At(i)
switch r.Type() {
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL24):
switch r := relocs.At(i); r.Type() {
case objabi.ElfRelocOffset + objabi.RelocType(elf.R_PPC64_REL24), objabi.R_CALLPOWER:
switch ldr.SymType(r.Sym()) {
case sym.SDYNIMPORT:
// 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)
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")
}
@ -1575,7 +1574,6 @@ func archrelocvariant(target *ld.Target, ldr *loader.Loader, r loader.Reloc, rv
var o1 uint32
if target.IsBigEndian() {
o1 = binary.BigEndian.Uint32(p[r.Off()-2:])
} else {
o1 = binary.LittleEndian.Uint32(p[r.Off():])
}

View File

@ -71,7 +71,7 @@ func Init() (*sys.Arch, ld.Arch) {
LinuxdynldMusl: musl,
Freebsddynld: "XXX",
Openbsddynld: "XXX",
Openbsddynld: "/usr/libexec/ld.so",
Netbsddynld: "XXX",
Dragonflydynld: "XXX",
Solarisdynld: "XXX",
@ -100,7 +100,8 @@ func archinit(ctxt *ld.Link) {
*ld.FlagRound = 4096
}
case objabi.Hlinux: /* ppc64 elf */
case objabi.Hlinux, /* ppc64 elf */
objabi.Hopenbsd:
ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE
if *ld.FlagTextAddr == -1 {

View File

@ -99,7 +99,9 @@ func MustLinkExternal(goos, goarch string, withCgo bool) bool {
case "ppc64":
// Big Endian PPC64 cgo internal linking is not implemented for aix or linux.
// https://go.dev/issue/8912
return true
if goos == "aix" || goos == "linux" {
return true
}
}
switch goos {