From a5f3a7fbcb71caa246e70d1dcb6f3c4bfb137221 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 9 May 2023 22:09:57 -0700 Subject: [PATCH] cmake/linker_script: Fix cmake linker scripts to define _end The generated scripts don't include a definition for any symbol indicating the end of statically allocated memory (such as "_end"). Add a shared cmake fragment, ram-end.cmake, which contains the necessary instructions to define _end and z_mapped_end consistently to align with the other sample linker scripts. Signed-off-by: Keith Packard (cherry picked from commit bbec614b78b3a083fc7a559ae3ac00a5af24973d) --- cmake/linker_script/arm/linker.cmake | 2 ++ cmake/linker_script/common/ram-end.cmake | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 cmake/linker_script/common/ram-end.cmake diff --git a/cmake/linker_script/arm/linker.cmake b/cmake/linker_script/arm/linker.cmake index b7d736f00bf04d..15a2ebd1130e35 100644 --- a/cmake/linker_script/arm/linker.cmake +++ b/cmake/linker_script/arm/linker.cmake @@ -135,6 +135,8 @@ if(NOT CONFIG_USERSPACE) zephyr_linker_section_configure(SECTION .noinit INPUT ".kernel_noinit.*") endif() +include(${COMMON_ZEPHYR_LINKER_DIR}/ram-end.cmake) + zephyr_linker_symbol(OBJECT REGION_RAM SYMBOL __kernel_ram_start EXPR "(@__bss_start@)") zephyr_linker_symbol(OBJECT REGION_RAM SYMBOL __kernel_ram_end EXPR "(${RAM_ADDR} + ${RAM_SIZE})") zephyr_linker_symbol(OBJECT REGION_RAM SYMBOL __kernel_ram_size EXPR "(@__kernel_ram_end@ - @__bss_start@)") diff --git a/cmake/linker_script/common/ram-end.cmake b/cmake/linker_script/common/ram-end.cmake new file mode 100644 index 00000000000000..bb210e199f6633 --- /dev/null +++ b/cmake/linker_script/common/ram-end.cmake @@ -0,0 +1,7 @@ +zephyr_linker_section(NAME .last_ram_section VMA RAM LMA RAM_REGION TYPE BSS) +zephyr_linker_section_configure( + SECTION .last_ram_section + INPUT "" + SYMBOLS _end z_mapped_end + KEEP + )