linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] powerpc: Fix a wrong version calculation issue in ld_version
@ 2023-01-04 20:24 Ojaswin Mujoo
  2023-01-15 10:44 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Ojaswin Mujoo @ 2023-01-04 20:24 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Andreas Schwab, linuxppc-dev

** The Issue **

The ld_version() function seems to compute the wrong version value for
certain ld versions like the following:

$ ld --version GNU ld (GNU Binutils; SUSE Linux Enterprise 15)
2.37.20211103-150100.7.37

For input 2.37.20211103, the value computed is 202348030000 which is way
more the value for a higher version like 2.39.0, that is 23900000.

This issue was highlighted because with the above ld version, powerpc
kernel build started failing with ld error: "unrecognized option
--no-warn-rwx-segments".  This was caused due to the recent patch
579aee9fc594 added --no-warn-rwx-segments linker flag if the ld version
was greater than 2.39.

Due to the bug in ld_version(), ld version 2.37.20111103 was
wrongly calculated to be greater than 2.39 and the unsupported flag was
added.

** The fix **

If version is of the form x.y.z and length(z) == 8, then most probably
it is a date [yyyymmdd] commonly used for release snapshots and not an
actual new version. Hence, ignore the date part replacing it with 0.

Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
---

* Changes since v1 [1] *

- Instead of using the mm part of the date ignore it completely
  replacing it with zero

[1] https://lore.kernel.org/r/20230103095740.916038-1-ojaswin@linux.ibm.com 

 arch/powerpc/boot/wrapper | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index af04cea82b94..352d7de24018 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -210,6 +210,10 @@ ld_version()
 	gsub(".*version ", "");
 	gsub("-.*", "");
 	split($1,a, ".");
+	if( length(a[3]) == "8" )
+		# a[3] is probably a date of format yyyymmdd used for release snapshots. We
+		# can assume it to be zero as it does not signify a new version as such.
+		a[3] = 0;
 	print a[1]*100000000 + a[2]*1000000 + a[3]*10000;
 	exit
     }'
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] powerpc: Fix a wrong version calculation issue in ld_version
  2023-01-04 20:24 [PATCH v2] powerpc: Fix a wrong version calculation issue in ld_version Ojaswin Mujoo
@ 2023-01-15 10:44 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2023-01-15 10:44 UTC (permalink / raw)
  To: Ojaswin Mujoo, Michael Ellerman; +Cc: linuxppc-dev, Andreas Schwab

On Thu, 5 Jan 2023 01:54:37 +0530, Ojaswin Mujoo wrote:
> ** The Issue **
> 
> The ld_version() function seems to compute the wrong version value for
> certain ld versions like the following:
> 
> $ ld --version GNU ld (GNU Binutils; SUSE Linux Enterprise 15)
> 2.37.20211103-150100.7.37
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc: Fix a wrong version calculation issue in ld_version
      https://git.kernel.org/powerpc/c/3287ebd7fd01e853ca4da8be675322429400e2bd

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-15 10:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04 20:24 [PATCH v2] powerpc: Fix a wrong version calculation issue in ld_version Ojaswin Mujoo
2023-01-15 10:44 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).