From d5ece1cb074b2c7082c9a2948ac598dd0ad40657 Mon Sep 17 00:00:00 2001
From: James Hogan <james.hogan@imgtec.com>
Date: Sat, 26 Dec 2015 22:47:52 +0000
Subject: [PATCH 1/2] Fix ld-version.sh to handle large 3rd version part

The ld-version.sh script doesn't handle versions with large (>= 10) 3rd
version components, because the 2nd component is only multiplied by 10
times that of the 3rd component.

For example the following version string:
GNU ld (Codescape GNU Tools 2015.06-05 for MIPS MTI Linux) 2.24.90

gives a bogus version number:
 20000000
+ 2400000
+  900000 = 23300000

Breakage, confusion and mole-whacking ensues.

Increase the multipliers of the first two version components by a factor
of 10 to give space for a 3rd components of up to 99, and update the
sole user of ld-ifversion (MIPS VDSO) accordingly.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/11931/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---
 arch/mips/vdso/Makefile | 2 +-
 scripts/ld-version.sh   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
index 14568900fc1d1..ee3617c0c5e2e 100644
--- a/arch/mips/vdso/Makefile
+++ b/arch/mips/vdso/Makefile
@@ -26,7 +26,7 @@ aflags-vdso := $(ccflags-vdso) \
 # the comments on that file.
 #
 ifndef CONFIG_CPU_MIPSR6
-  ifeq ($(call ld-ifversion, -lt, 22500000, y),y)
+  ifeq ($(call ld-ifversion, -lt, 225000000, y),y)
     $(warning MIPS VDSO requires binutils >= 2.25)
     obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y))
     ccflags-vdso += -DDISABLE_MIPS_VDSO
diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
index 198580d245e03..0b67edc5bc6fb 100755
--- a/scripts/ld-version.sh
+++ b/scripts/ld-version.sh
@@ -3,6 +3,6 @@
 	{
 	gsub(".*)", "");
 	split($1,a, ".");
-	print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5];
+	print a[1]*100000000 + a[2]*1000000 + a[3]*10000 + a[4]*100 + a[5];
 	exit
 	}

From 8083013fc3201b75535afc39338cc7d2cad32e37 Mon Sep 17 00:00:00 2001
From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Thu, 7 Jan 2016 19:55:24 +0200
Subject: [PATCH 2/2] ld-version: Fix it on Fedora

On Fedora 23, ld --version outputs:
GNU ld version 2.25-15.fc23

But ld-version.sh fails to parse this, so e.g.  mips build fails to
enable VDSO, printing a warning that binutils >= 2.24 is required.

To fix, teach ld-version to parse this format.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: Michal Marek <mmarek@suse.com>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/12023/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---
 scripts/ld-version.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
index 0b67edc5bc6fb..d154f0877fd80 100755
--- a/scripts/ld-version.sh
+++ b/scripts/ld-version.sh
@@ -2,6 +2,8 @@
 # extract linker version number from stdin and turn into single number
 	{
 	gsub(".*)", "");
+	gsub(".*version ", "");
+	gsub("-.*", "");
 	split($1,a, ".");
 	print a[1]*100000000 + a[2]*1000000 + a[3]*10000 + a[4]*100 + a[5];
 	exit