build: Use cmake for READONLY attribute handling

Signed-off-by: Dávid Házi <david.hazi@arm.com>
Change-Id: Ia696ffa789505fa47e5c44ae1234a460c15eb758
diff --git a/toolchain_GNUARM.cmake b/toolchain_GNUARM.cmake
index 217e36f..d9b9084 100644
--- a/toolchain_GNUARM.cmake
+++ b/toolchain_GNUARM.cmake
@@ -152,8 +152,13 @@
 # has a linker issue that required system calls are missing,
 # such as _read and _write. Add stub functions of required
 # system calls to solve this issue.
+#
+# READONLY linker script attribute is not supported in older
+# GNU Arm compilers. For these version the preprocessor will
+# remove the READONLY string from the linker scripts.
 if (GCC_VERSION VERSION_GREATER_EQUAL 11.3.1)
     set(CONFIG_GNU_SYSCALL_STUB_ENABLED TRUE)
+    set(CONFIG_GNU_LINKER_READONLY_ATTRIBUTE TRUE)
 endif()
 
 if (CMAKE_SYSTEM_PROCESSOR)
@@ -233,6 +238,11 @@
             -P
             -xc
     )
+
+    target_compile_definitions(${target}_scatter
+        PRIVATE
+            $<$<NOT:$<BOOL:${CONFIG_GNU_LINKER_READONLY_ATTRIBUTE}>>:READONLY=>
+    )
 endmacro()
 
 macro(add_convert_to_bin_target target)