From 15c67e21daee0a5055c8fc0144e7efe0345d1929 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 18 Dec 2014 16:06:57 -0500 Subject: [PATCH] cmd/ld: set ELF ABI version for ppc64x On ppc64, there are three ELF ABI versions an ELF file can request. Previously, we used 0, which means "unspecified". On our test machines, this meant to use the default (v1 for big endian and v2 for little endian), but apparently some systems can pick the wrong ABI if neither is requested. Leaving this as 0 also confuses libbfd, which confuses gdb, objdump, etc. Fix these problems by specifying ABI v1 for big endian and v2 for little endian. Change-Id: I4d3d5478f37f11baab3681a07daff3da55802322 Reviewed-on: https://go-review.googlesource.com/1800 Reviewed-by: Minux Ma --- src/cmd/ld/elf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/ld/elf.c b/src/cmd/ld/elf.c index 6ac6b6ee82..c20232c550 100644 --- a/src/cmd/ld/elf.c +++ b/src/cmd/ld/elf.c @@ -44,8 +44,12 @@ elfinit(void) switch(thechar) { // 64-bit architectures - case '6': case '9': + if(ctxt->arch->endian == BigEndian) + hdr.flags = 1; /* Version 1 ABI */ + else + hdr.flags = 2; /* Version 2 ABI */ + case '6': elf64 = 1; hdr.phoff = ELF64HDRSIZE; /* Must be be ELF64HDRSIZE: first PHdr must follow ELF header */ hdr.shoff = ELF64HDRSIZE; /* Will move as we add PHeaders */ -- 2.50.0