From 35c5deb1d43b245c19059d1532929ee087e44a84 Mon Sep 17 00:00:00 2001 From: Paul Murphy Date: Wed, 7 Jan 2026 13:48:53 -0600 Subject: all: switch linux-ppc64 target to ELFv2 ABI Go is only capable of producing internally linked, static binaries on linux-ppc64. As such, binaries should run in either ELFv1 or ELFv2 ppc64 userspaces today. This opens the door to enabling cgo and external linking which will require ELFv2 support and userspace, eventually. Fixes #76244 Change-Id: I5ca15037cbe546f352e8693dcf14da51a308b8ca Reviewed-on: https://go-review.googlesource.com/c/go/+/734540 LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui Reviewed-by: Dmitri Shuralyov --- src/cmd/link/internal/ld/elf.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/link/internal/ld/elf.go b/src/cmd/link/internal/ld/elf.go index 12218feb31..8cd9e9f1b4 100644 --- a/src/cmd/link/internal/ld/elf.go +++ b/src/cmd/link/internal/ld/elf.go @@ -178,14 +178,7 @@ func Elfinit(ctxt *Link) { switch ctxt.Arch.Family { // 64-bit architectures - case sys.PPC64, sys.S390X: - if ctxt.Arch.ByteOrder == binary.BigEndian && ctxt.HeadType != objabi.Hopenbsd { - ehdr.Flags = 1 // Version 1 ABI - } else { - ehdr.Flags = 2 // Version 2 ABI - } - fallthrough - case sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS64, sys.RISCV64: + case sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X: if ctxt.Arch.Family == sys.MIPS64 { ehdr.Flags = 0x20000004 // MIPS 3 CPIC } @@ -195,6 +188,12 @@ func Elfinit(ctxt *Link) { if ctxt.Arch.Family == sys.RISCV64 { ehdr.Flags = 0x4 // RISCV Float ABI Double } + if ctxt.Arch.Family == sys.S390X { + ehdr.Flags = 1 // Version 1 ABI + } + if ctxt.Arch.Family == sys.PPC64 { + ehdr.Flags = 2 // Version 2 ABI + } elf64 = true ehdr.Phoff = ELF64HDRSIZE // Must be ELF64HDRSIZE: first PHdr must follow ELF header -- cgit v1.3