[Pkg-golang-commits] [golang] 01/02: backport armhf fix from upstream

Michael Hudson-Doyle mwhudson-guest at moszumanska.debian.org
Wed Feb 7 09:11:37 UTC 2018


This is an automated email from the git hooks/post-receive script.

mwhudson-guest pushed a commit to branch golang-1.10
in repository golang.

commit 04cc890e5513df3b5df677d625a7974764ea8dde
Author: Michael Hudson-Doyle <michael.hudson at canonical.com>
Date:   Wed Feb 7 22:08:50 2018 +1300

    backport armhf fix from upstream
---
 debian/changelog                                   |  9 ++
 ...ternal-loadelf-fix-logic-for-computing-EL.patch | 95 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 105 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 9ab6ae8..21701e1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+golang-1.10 (1.10~rc1-2) UNRELEASED; urgency=medium
+
+  * d/patches/0004-cmd-link-internal-loadelf-fix-logic-for-computing-EL.patch:
+    Backport from upstream to fix build issues on armhf (causes ftbfs on
+    Ubuntu but not Debian for some reason, but could produce broken binaries
+    on Debian too).
+
+ -- Michael Hudson-Doyle <mwhudson at debian.org>  Wed, 07 Feb 2018 22:07:10 +1300
+
 golang-1.10 (1.10~rc1-1) unstable; urgency=medium
 
   * New upstream version 1.10~rc1.
diff --git a/debian/patches/0004-cmd-link-internal-loadelf-fix-logic-for-computing-EL.patch b/debian/patches/0004-cmd-link-internal-loadelf-fix-logic-for-computing-EL.patch
new file mode 100644
index 0000000..a8f0257
--- /dev/null
+++ b/debian/patches/0004-cmd-link-internal-loadelf-fix-logic-for-computing-EL.patch
@@ -0,0 +1,95 @@
+From b2d3d6e676450cc1a5d5a611d3711dce2800bc0d Mon Sep 17 00:00:00 2001
+From: Michael Hudson-Doyle <michael.hudson at canonical.com>
+Date: Wed, 7 Feb 2018 15:46:26 +1300
+Subject: [PATCH] cmd/link/internal/loadelf: fix logic for computing ELF flags
+ on ARM
+
+The linker contains complicated logic for figuring out which float ABI to
+indicate it is using on (32 bit) ARM systems: it parses a special section in
+host object files to look for a flag indicating use of the hard float ABI. When
+loadelf got split into its own package a bug was introduced: if the last host
+object file does not contain a float ABI related tag, the ELF header's flag was
+set to 0, rather than using the value from the last object file which contained
+an ABI tag. Fix the code to only change the value used for the ELF header if a
+tag was found.
+
+This fixes an extremely confusing build failure on Ubuntu's armhf builders.
+
+Change-Id: I0845d68d082d1383e4cae84ea85164cdc6bcdddb
+Reviewed-on: https://go-review.googlesource.com/92515
+Run-TryBot: Michael Hudson-Doyle <michael.hudson at canonical.com>
+TryBot-Result: Gobot Gobot <gobot at golang.org>
+Reviewed-by: Ian Lance Taylor <iant at golang.org>
+---
+ src/cmd/link/internal/loadelf/ldelf.go | 27 +++++++++++++++++----------
+ 1 file changed, 17 insertions(+), 10 deletions(-)
+
+--- a/src/cmd/link/internal/loadelf/ldelf.go
++++ b/src/cmd/link/internal/loadelf/ldelf.go
+@@ -405,13 +405,10 @@
+ // find the one we are looking for. This format is slightly documented in "ELF
+ // for the ARM Architecture" but mostly this is derived from reading the source
+ // to gold and readelf.
+-func parseArmAttributes(e binary.ByteOrder, initEhdrFlags uint32, data []byte) (ehdrFlags uint32, err error) {
+-	// We assume the soft-float ABI unless we see a tag indicating otherwise.
+-	if initEhdrFlags == 0x5000002 {
+-		ehdrFlags = 0x5000202
+-	}
++func parseArmAttributes(e binary.ByteOrder, data []byte) (found bool, ehdrFlags uint32, err error) {
++	found = false
+ 	if data[0] != 'A' {
+-		return 0, fmt.Errorf(".ARM.attributes has unexpected format %c\n", data[0])
++		return false, 0, fmt.Errorf(".ARM.attributes has unexpected format %c\n", data[0])
+ 	}
+ 	data = data[1:]
+ 	for len(data) != 0 {
+@@ -421,7 +418,7 @@
+ 
+ 		nulIndex := bytes.IndexByte(sectiondata, 0)
+ 		if nulIndex < 0 {
+-			return 0, fmt.Errorf("corrupt .ARM.attributes (section name not NUL-terminated)\n")
++			return false, 0, fmt.Errorf("corrupt .ARM.attributes (section name not NUL-terminated)\n")
+ 		}
+ 		name := string(sectiondata[:nulIndex])
+ 		sectiondata = sectiondata[nulIndex+1:]
+@@ -442,15 +439,16 @@
+ 			for !attrList.done() {
+ 				attr := attrList.armAttr()
+ 				if attr.tag == TagABIVFPArgs && attr.ival == 1 {
++					found = true
+ 					ehdrFlags = 0x5000402 // has entry point, Version5 EABI, hard-float ABI
+ 				}
+ 			}
+ 			if attrList.err != nil {
+-				return 0, fmt.Errorf("could not parse .ARM.attributes\n")
++				return false, 0, fmt.Errorf("could not parse .ARM.attributes\n")
+ 			}
+ 		}
+ 	}
+-	return ehdrFlags, nil
++	return found, ehdrFlags, nil
+ }
+ 
+ // Load loads the ELF file pn from f.
+@@ -686,11 +684,20 @@
+ 			if err := elfmap(elfobj, sect); err != nil {
+ 				return errorf("%s: malformed elf file: %v", pn, err)
+ 			}
+-			ehdrFlags, err = parseArmAttributes(e, initEhdrFlags, sect.base[:sect.size])
++			// We assume the soft-float ABI unless we see a tag indicating otherwise.
++			if initEhdrFlags == 0x5000002 {
++				ehdrFlags = 0x5000202
++			} else {
++				ehdrFlags = initEhdrFlags
++			}
++			found, newEhdrFlags, err := parseArmAttributes(e, sect.base[:sect.size])
+ 			if err != nil {
+ 				// TODO(dfc) should this return an error?
+ 				log.Printf("%s: %v", pn, err)
+ 			}
++			if found {
++				ehdrFlags = newEhdrFlags
++			}
+ 		}
+ 		if (sect.type_ != ElfSectProgbits && sect.type_ != ElfSectNobits) || sect.flags&ElfSectFlagAlloc == 0 {
+ 			continue
diff --git a/debian/patches/series b/debian/patches/series
index aa84d76..d6ec71b 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 0001-os-signal-skip-TestTerminalSignal-if-posix_openpt-fa.patch
 0002-reproducible-BUILD_PATH_PREFIX_MAP.patch
 0003-cmd-vendor-github.com-google-pprof-cherry-pick-fix-t.patch
+0004-cmd-link-internal-loadelf-fix-logic-for-computing-EL.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-golang/golang.git



More information about the pkg-golang-commits mailing list