Index: kernel/meson.build
===================================================================
--- kernel/meson.build	(revision b7493ea040db937909bd4dace68408be294f972e)
+++ kernel/meson.build	(revision 62721d57bbe9b7d3eafd9678e67746a1b73e076b)
@@ -89,4 +89,7 @@
 	'-T', meson.current_build_dir() / '_link.ld',
 ]
+# The kernel is built as ELF but then copied as a blob of bytes and
+# the permissions are not relevant anyway (needed for binutils 2.39+).
+kernel_link_args += ldflags_ignore_rwx_segments
 
 if CONFIG_LTO
Index: meson/arch/arm64/meson.build
===================================================================
--- meson/arch/arm64/meson.build	(revision b7493ea040db937909bd4dace68408be294f972e)
+++ meson/arch/arm64/meson.build	(revision 62721d57bbe9b7d3eafd9678e67746a1b73e076b)
@@ -48,5 +48,5 @@
 # -mstrict-align option is therefore not needed.
 arch_boot_c_args = arch_uspace_c_args + [ '-fpic', '-fvisibility=hidden', '-fno-function-sections' ]
-arch_boot_link_args = [ '-Wl,-shared', '-Wl,--no-gc-sections' ]
+arch_boot_link_args = [ '-Wl,-shared', '-Wl,--no-gc-sections' ] + ldflags_ignore_rwx_segments
 
 if MACHINE == 'virt'
Index: meson/arch/ia64/meson.build
===================================================================
--- meson/arch/ia64/meson.build	(revision b7493ea040db937909bd4dace68408be294f972e)
+++ meson/arch/ia64/meson.build	(revision 62721d57bbe9b7d3eafd9678e67746a1b73e076b)
@@ -38,5 +38,5 @@
 arch_uspace_link_args = [ '-nostdlib', '-lgcc' ]
 arch_kernel_link_args = [ '-nostdlib', '-Wl,-EL' ]
-arch_boot_link_args = []
+arch_boot_link_args = ldflags_ignore_rwx_segments
 
 
Index: meson/arch/ppc32/meson.build
===================================================================
--- meson/arch/ppc32/meson.build	(revision b7493ea040db937909bd4dace68408be294f972e)
+++ meson/arch/ppc32/meson.build	(revision 62721d57bbe9b7d3eafd9678e67746a1b73e076b)
@@ -37,5 +37,6 @@
 arch_kernel_link_args = [ '-nostdlib', '-Wl,-z,max-page-size=0x1000', '-Wl,--no-check-sections', '-Wl,--no-gc-sections' ]
 arch_uspace_link_args = [ '-nostdlib', '-lgcc', '-Wl,-z,max-page-size=0x1000' ]
-arch_boot_link_args = []
+arch_uspace_link_args += ldflags_ignore_rwx_segments
+arch_boot_link_args = ldflags_ignore_rwx_segments
 
 rd_essential += [
Index: meson/arch/riscv64/meson.build
===================================================================
--- meson/arch/riscv64/meson.build	(revision b7493ea040db937909bd4dace68408be294f972e)
+++ meson/arch/riscv64/meson.build	(revision 62721d57bbe9b7d3eafd9678e67746a1b73e076b)
@@ -33,5 +33,5 @@
 arch_kernel_link_args = [ '-nostdlib' ]
 arch_uspace_link_args = [ '-nostdlib', '-lgcc' ]
-arch_boot_link_args = []
+arch_boot_link_args = ldflags_ignore_rwx_segments
 
 rd_essential += [
Index: meson/part/compiler_args/meson.build
===================================================================
--- meson/part/compiler_args/meson.build	(revision b7493ea040db937909bd4dace68408be294f972e)
+++ meson/part/compiler_args/meson.build	(revision 62721d57bbe9b7d3eafd9678e67746a1b73e076b)
@@ -128,2 +128,15 @@
 	add_project_link_arguments(extra_cflags, language : [ lang ])
 endforeach
+
+# This flag is needed at several places, hence we define it here.
+#
+# For backwards compatibility we try to detect --no-warn-rwx-segments.
+# However, the autodetection done by Meson also results in
+# "cannot find entry symbol _start; defaulting to 00000000004000b0"
+# thus the option is never supported alone. So when detecting we also
+# specify --entry=main so that the stub source provided by Meson is build
+# correctly.
+ldflags_ignore_rwx_segments = []
+if cc.has_link_argument('-Wl,--no-warn-rwx-segments,--entry=main')
+    ldflags_ignore_rwx_segments += ['-Wl,--no-warn-rwx-segments']
+endif
