Skip to contentSkip to conversation

powerpc/boot: Check for ld-option support

PATCH Applied Madhavan Srinivasan 2 participants 3 messages Apr 1, 2025 – Apr 21, 2025 PowerPC

lore
Share & tools
lore

Madhavan Srinivasan

author maintainer
#0 lore raw

PATCH 1/1 powerpc/boot: Check for ld-option support

Commit 579aee9fc594 ("powerpc: suppress some linker warnings in recent linker versions") enabled support to add linker option "--no-warn-rwx-segments",
if the version is greater than 2.39. Similar build warning were
reported recently from linker version 2.35.2.

ld: warning: arch/powerpc/boot/zImage.epapr has a LOAD segment with RWX permissions
ld: warning: arch/powerpc/boot/zImage.pseries has a LOAD segment with RWX permissions

Fix the warning by checking for "--no-warn-rwx-segments" option support in linker to enable it, instead of checking for the version range.

Fixes Commit 579aee9fc594 ("powerpc: suppress some linker warnings in recent linker versions")
---
 arch/powerpc/boot/wrapper | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/powerpc/boot/wrapper +2 -4
index 1db60fe13802..267ca6d4d9b3 100755
@@ -234,10 +234,8 @@ fi
 
 # suppress some warnings in recent ld versions
 nowarn="-z noexecstack"
-if ! ld_is_lld; then
-	if [ "$LD_VERSION" -ge "$(echo 2.39 | ld_version)" ]; then
-		nowarn="$nowarn --no-warn-rwx-segments"
-	fi
+if [ $(${CROSS}ld -v --no-warn-rwx-segments &>/dev/null; echo $?) -eq 0 ]; then
+	nowarn="$nowarn --no-warn-rwx-segments"
 fi
 
 platformo=$object/"$platform".o
Signature · 1 line
2.48.1
Tested-by on v1 1/1
#1 lore raw
Quoted 28 lines · Madhavan Srinivasan

Commit 579aee9fc594 ("powerpc: suppress some linker warnings in recent linker versions") enabled support to add linker option "--no-warn-rwx-segments",
if the version is greater than 2.39. Similar build warning were
reported recently from linker version 2.35.2.

ld: warning: arch/powerpc/boot/zImage.epapr has a LOAD segment with RWX permissions
ld: warning: arch/powerpc/boot/zImage.pseries has a LOAD segment with RWX permissions

Fix the warning by checking for "--no-warn-rwx-segments" option support in linker to enable it, instead of checking for the version range.

Fixes Commit 579aee9fc594 ("powerpc: suppress some linker warnings in recent linker versions")
---
  arch/powerpc/boot/wrapper | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
arch/powerpc/boot/wrapper +0 -0
index 1db60fe13802..267ca6d4d9b3 100755
@@ -234,10 +234,8 @@ fi
 
  # suppress some warnings in recent ld versions

arch/powerpc/boot/wrapper fi · line 241

Quoted 10 lines
arch/powerpc/boot/wrapper +2 -4
  nowarn="-z noexecstack"
-if ! ld_is_lld; then
-	if [ "$LD_VERSION" -ge "$(echo 2.39 | ld_version)" ]; then
-		nowarn="$nowarn --no-warn-rwx-segments"
-	fi
+if [ $(${CROSS}ld -v --no-warn-rwx-segments &>/dev/null; echo $?) -eq 0 ]; then
+	nowarn="$nowarn --no-warn-rwx-segments"
  fi
 
  platformo=$object/"$platform".o

Tested this patch, by applying on main-line kernel with commit HEAD: 1a9239bb4253f9076b5b4b2a1a4e8d7defd77a95, and no build warnings are observed.

Please add below tag:

Regards,

Venkat.

author maintainer Applied
#2 lore raw
In reply to Madhavan Srinivasan
Quoted 9 lines · Madhavan Srinivasan

Commit 579aee9fc594 ("powerpc: suppress some linker warnings in recent linker versions") enabled support to add linker option "--no-warn-rwx-segments",
if the version is greater than 2.39. Similar build warning were
reported recently from linker version 2.35.2.

ld: warning: arch/powerpc/boot/zImage.epapr has a LOAD segment with RWX permissions
ld: warning: arch/powerpc/boot/zImage.pseries has a LOAD segment with RWX permissions

[...]

Applied to powerpc/fixes.

[1/1] powerpc/boot: Check for ld-option support

      https://git.kernel.org/powerpc/c/b2accfe7ca5bc9f9af28e603b79bdd5ad8df5c0b

Thanks