From 973251ae0c69a35721f6115345d3f57b2847979f Mon Sep 17 00:00:00 2001
From: Alex Kube <alexander.j.kube@gmail.com>
Date: Wed, 23 Oct 2019 21:20:13 +0430
Subject: [PATCH 9/9] ld: replace glibc dynamic linker with musl

Rework of patch by Khem Raj <raj.khem@gmail.com>
for go 1.10.  Should be applied conditionally on
musl being the system C library.

Adapted to Go 1.13 from patches originally submitted to
the meta/recipes-devtools/go tree by
Matt Madison <matt@madison.systems>.

Upstream-Status: Inappropriate [Real fix should be portable across libcs]

Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
---
 src/cmd/link/internal/amd64/obj.go  | 2 +-
 src/cmd/link/internal/arm/obj.go    | 2 +-
 src/cmd/link/internal/arm64/obj.go  | 2 +-
 src/cmd/link/internal/mips/obj.go   | 2 +-
 src/cmd/link/internal/mips64/obj.go | 2 +-
 src/cmd/link/internal/ppc64/obj.go  | 2 +-
 src/cmd/link/internal/s390x/obj.go  | 2 +-
 src/cmd/link/internal/x86/obj.go    | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

--- a/src/cmd/link/internal/amd64/obj.go
+++ b/src/cmd/link/internal/amd64/obj.go
@@ -59,7 +59,7 @@ func Init() (*sys.Arch, ld.Arch) {
 		PEreloc1:         pereloc1,
 		TLSIEtoLE:        tlsIEtoLE,
 
-		Linuxdynld:     "/lib64/ld-linux-x86-64.so.2",
+		Linuxdynld:     "/lib64/ld-musl-x86-64.so.1",
 		Freebsddynld:   "/libexec/ld-elf.so.1",
 		Openbsddynld:   "/usr/libexec/ld.so",
 		Netbsddynld:    "/libexec/ld.elf_so",
--- a/src/cmd/link/internal/arm/obj.go
+++ b/src/cmd/link/internal/arm/obj.go
@@ -59,7 +59,7 @@ func Init() (*sys.Arch, ld.Arch) {
 		Machoreloc1:      machoreloc1,
 		PEreloc1:         pereloc1,
 
-		Linuxdynld:     "/lib/ld-linux.so.3", // 2 for OABI, 3 for EABI
+		Linuxdynld:     "/lib/ld-musl-armhf.so.1",
 		Freebsddynld:   "/usr/libexec/ld-elf.so.1",
 		Openbsddynld:   "/usr/libexec/ld.so",
 		Netbsddynld:    "/libexec/ld.elf_so",
--- a/src/cmd/link/internal/arm64/obj.go
+++ b/src/cmd/link/internal/arm64/obj.go
@@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) {
 		Gentext:          gentext,
 		Machoreloc1:      machoreloc1,
 
-		Linuxdynld: "/lib/ld-linux-aarch64.so.1",
+		Linuxdynld: "/lib/ld-musl-aarch64.so.1",
 
 		Freebsddynld:   "/usr/libexec/ld-elf.so.1",
 		Openbsddynld:   "/usr/libexec/ld.so",
--- a/src/cmd/link/internal/mips/obj.go
+++ b/src/cmd/link/internal/mips/obj.go
@@ -60,7 +60,7 @@ func Init() (*sys.Arch, ld.Arch) {
 		Gentext:          gentext,
 		Machoreloc1:      machoreloc1,
 
-		Linuxdynld: "/lib/ld.so.1",
+		Linuxdynld: "/lib/ld-musl-mipsle.so.1",
 
 		Freebsddynld:   "XXX",
 		Openbsddynld:   "XXX",
--- a/src/cmd/link/internal/mips64/obj.go
+++ b/src/cmd/link/internal/mips64/obj.go
@@ -59,7 +59,7 @@ func Init() (*sys.Arch, ld.Arch) {
 		Gentext:          gentext,
 		Machoreloc1:      machoreloc1,
 
-		Linuxdynld:     "/lib64/ld64.so.1",
+		Linuxdynld:     "/lib64/ld-musl-mips64le.so.1",
 		Freebsddynld:   "XXX",
 		Openbsddynld:   "XXX",
 		Netbsddynld:    "XXX",
--- a/src/cmd/link/internal/ppc64/obj.go
+++ b/src/cmd/link/internal/ppc64/obj.go
@@ -63,7 +63,7 @@ func Init() (*sys.Arch, ld.Arch) {
 		Xcoffreloc1:      xcoffreloc1,
 
 		// TODO(austin): ABI v1 uses /usr/lib/ld.so.1,
-		Linuxdynld: "/lib64/ld64.so.1",
+		Linuxdynld: "/lib64/ld-musl-powerpc64le.so.1",
 
 		Freebsddynld:   "XXX",
 		Openbsddynld:   "XXX",
--- a/src/cmd/link/internal/s390x/obj.go
+++ b/src/cmd/link/internal/s390x/obj.go
@@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) {
 		Gentext:          gentext,
 		Machoreloc1:      machoreloc1,
 
-		Linuxdynld: "/lib64/ld64.so.1",
+		Linuxdynld: "/lib64/ld-musl-s390x.so.1",
 
 		// not relevant for s390x
 		Freebsddynld:   "XXX",
--- a/src/cmd/link/internal/x86/obj.go
+++ b/src/cmd/link/internal/x86/obj.go
@@ -58,7 +58,7 @@ func Init() (*sys.Arch, ld.Arch) {
 		Machoreloc1:      machoreloc1,
 		PEreloc1:         pereloc1,
 
-		Linuxdynld:   "/lib/ld-linux.so.2",
+		Linuxdynld:   "/lib/ld-musl-i386.so.1",
 		Freebsddynld: "/usr/libexec/ld-elf.so.1",
 		Openbsddynld: "/usr/libexec/ld.so",
 		Netbsddynld:  "/usr/libexec/ld.elf_so",
