diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake index 5427e4078da..f9c992f7114 100644 --- a/cmake/extensions.cmake +++ b/cmake/extensions.cmake @@ -1094,16 +1094,17 @@ endfunction(zephyr_check_compiler_flag_hardcoded) # Preprocessor directives work inside . Relative paths are resolved # relative to the calling file, like zephyr_sources(). # is one of -# NOINIT Inside the noinit output section. -# RWDATA Inside the data output section. -# RODATA Inside the rodata output section. -# ROM_START Inside the first output section of the image. This option is -# currently only available on ARM Cortex-M, ARM Cortex-R, -# x86, ARC, openisa_rv32m1, and RISC-V. -# Note: On RISC-V the rom_start section will be after vector section. -# RAM_SECTIONS Inside the RAMABLE_REGION GROUP. -# SECTIONS Near the end of the file. Don't use this when linking into -# RAMABLE_REGION, use RAM_SECTIONS instead. +# NOINIT Inside the noinit output section. +# RWDATA Inside the data output section. +# RODATA Inside the rodata output section. +# ROM_START Inside the first output section of the image. This option is +# currently only available on ARM Cortex-M, ARM Cortex-R, +# x86, ARC, openisa_rv32m1, and RISC-V. +# Note: On RISC-V the rom_start section will be after vector section. +# RAM_SECTIONS Inside the RAMABLE_REGION GROUP, not initialized. +# DATA_SECTIONS Inside the RAMABLE_REGION GROUP, initialized. +# SECTIONS Near the end of the file. Don't use this when linking into +# RAMABLE_REGION, use RAM_SECTIONS instead. # is an optional key to sort by inside of each location. The key must # be alphanumeric, and the keys are sorted alphabetically. If no key is # given, the key 'default' is used. Keys are case-sensitive. @@ -1118,8 +1119,8 @@ endfunction(zephyr_check_compiler_flag_hardcoded) # _mysection_end = .; # _mysection_size = ABSOLUTE(_mysection_end - _mysection_start); # -# When placing into SECTIONS or RAM_SECTIONS, the files must instead define -# their own output sections to achieve the same thing: +# When placing into SECTIONS, RAM_SECTIONS or DATA_SECTIONS, the files must +# instead define their own output sections to achieve the same thing: # SECTION_PROLOGUE(.mysection,,) # { # _mysection_start = .; @@ -1137,19 +1138,21 @@ endfunction(zephyr_check_compiler_flag_hardcoded) function(zephyr_linker_sources location) # Set up the paths to the destination files. These files are #included inside # the global linker.ld. - set(snippet_base "${__build_dir}/include/generated") - set(sections_path "${snippet_base}/snippets-sections.ld") - set(ram_sections_path "${snippet_base}/snippets-ram-sections.ld") - set(rom_start_path "${snippet_base}/snippets-rom-start.ld") - set(noinit_path "${snippet_base}/snippets-noinit.ld") - set(rwdata_path "${snippet_base}/snippets-rwdata.ld") - set(rodata_path "${snippet_base}/snippets-rodata.ld") + set(snippet_base "${__build_dir}/include/generated") + set(sections_path "${snippet_base}/snippets-sections.ld") + set(ram_sections_path "${snippet_base}/snippets-ram-sections.ld") + set(data_sections_path "${snippet_base}/snippets-data-sections.ld") + set(rom_start_path "${snippet_base}/snippets-rom-start.ld") + set(noinit_path "${snippet_base}/snippets-noinit.ld") + set(rwdata_path "${snippet_base}/snippets-rwdata.ld") + set(rodata_path "${snippet_base}/snippets-rodata.ld") # Clear destination files if this is the first time the function is called. get_property(cleared GLOBAL PROPERTY snippet_files_cleared) if (NOT DEFINED cleared) file(WRITE ${sections_path} "") file(WRITE ${ram_sections_path} "") + file(WRITE ${data_sections_path} "") file(WRITE ${rom_start_path} "") file(WRITE ${noinit_path} "") file(WRITE ${rwdata_path} "") @@ -1162,6 +1165,8 @@ function(zephyr_linker_sources location) set(snippet_path "${sections_path}") elseif("${location}" STREQUAL "RAM_SECTIONS") set(snippet_path "${ram_sections_path}") + elseif("${location}" STREQUAL "DATA_SECTIONS") + set(snippet_path "${data_sections_path}") elseif("${location}" STREQUAL "ROM_START") set(snippet_path "${rom_start_path}") elseif("${location}" STREQUAL "NOINIT") diff --git a/include/arch/arc/v2/linker.ld b/include/arch/arc/v2/linker.ld index 25ceca7c995..23a912a3a33 100644 --- a/include/arch/arc/v2/linker.ld +++ b/include/arch/arc/v2/linker.ld @@ -196,6 +196,11 @@ SECTIONS { #include #endif /* __MWDT_LINKER_CMD__ */ +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + __data_ram_end = .; MPU_MIN_SIZE_ALIGN /* Define linker symbols */ diff --git a/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld b/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld index 1501151572d..fd67ed4fe63 100644 --- a/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_a_r/scripts/linker.ld @@ -298,6 +298,11 @@ SECTIONS #include #include +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + __data_ram_end = .; diff --git a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld index b87806923df..30e80898485 100644 --- a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld @@ -323,6 +323,11 @@ SECTIONS #include +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + __data_ram_end = .; #ifndef CONFIG_USERSPACE diff --git a/include/arch/arm64/scripts/linker.ld b/include/arch/arm64/scripts/linker.ld index 47812a9f979..7f591b5db70 100644 --- a/include/arch/arm64/scripts/linker.ld +++ b/include/arch/arm64/scripts/linker.ld @@ -274,6 +274,11 @@ SECTIONS #include #include +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + __data_ram_end = .; diff --git a/include/arch/nios2/linker.ld b/include/arch/nios2/linker.ld index 80ea36c430c..70a3cc7f01d 100644 --- a/include/arch/nios2/linker.ld +++ b/include/arch/nios2/linker.ld @@ -228,6 +228,11 @@ SECTIONS #include +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + __data_ram_end = .; SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),) diff --git a/include/arch/posix/linker.ld b/include/arch/posix/linker.ld index 8221f8b805a..3cc2d44069f 100644 --- a/include/arch/posix/linker.ld +++ b/include/arch/posix/linker.ld @@ -48,6 +48,11 @@ SECTIONS #include +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + __data_ram_end = .; /* Located in generated directory. This file is populated by the diff --git a/include/arch/riscv/common/linker.ld b/include/arch/riscv/common/linker.ld index 06eab0162f4..7a98f14d1b6 100644 --- a/include/arch/riscv/common/linker.ld +++ b/include/arch/riscv/common/linker.ld @@ -247,6 +247,12 @@ SECTIONS * zephyr_linker_sources() Cmake function. */ #include + +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + __data_ram_end = .; MPU_MIN_SIZE_ALIGN diff --git a/include/arch/sparc/linker.ld b/include/arch/sparc/linker.ld index 3f666a1877d..217f2d08b6e 100644 --- a/include/arch/sparc/linker.ld +++ b/include/arch/sparc/linker.ld @@ -104,6 +104,12 @@ SECTIONS * zephyr_linker_sources() Cmake function. */ #include + +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + __data_ram_end = .; SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),) diff --git a/include/arch/x86/ia32/linker.ld b/include/arch/x86/ia32/linker.ld index cc8e7671295..6550a29a45f 100644 --- a/include/arch/x86/ia32/linker.ld +++ b/include/arch/x86/ia32/linker.ld @@ -476,6 +476,11 @@ SECTIONS #include #endif /* !CONFIG_LINKER_USE_PINNED_SECTION */ +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + MMU_PAGE_ALIGN __data_ram_end = .; diff --git a/include/arch/x86/intel64/linker.ld b/include/arch/x86/intel64/linker.ld index e149276b616..45d121adb18 100644 --- a/include/arch/x86/intel64/linker.ld +++ b/include/arch/x86/intel64/linker.ld @@ -184,6 +184,11 @@ SECTIONS #include #include +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + /* Must be last in RAM */ #include MMU_PAGE_ALIGN diff --git a/soc/riscv/openisa_rv32m1/linker.ld b/soc/riscv/openisa_rv32m1/linker.ld index 790782c973a..c46f6df67d1 100644 --- a/soc/riscv/openisa_rv32m1/linker.ld +++ b/soc/riscv/openisa_rv32m1/linker.ld @@ -183,6 +183,11 @@ SECTIONS #include #include +/* Located in generated directory. This file is populated by the + * zephyr_linker_sources() Cmake function. + */ +#include + __data_ram_end = .; __data_rom_start = LOADADDR(_DATA_SECTION_NAME);