linker: add an initialized DATA_SECTIONS linker location option
Current location options for linker source files includes init and noinit ram data, but only a noinit ram section. This makes it impossible for application code to define an initialized RAM output section, such as with the Z_ITERABLE_SECTION_RAM() helpers. Adding a DATA_SECTIONS linker source option for this use case. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
114b84a58b
commit
ef93bbad57
12 changed files with 81 additions and 19 deletions
|
@ -1101,7 +1101,8 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
|
||||||
# currently only available on ARM Cortex-M, ARM Cortex-R,
|
# currently only available on ARM Cortex-M, ARM Cortex-R,
|
||||||
# x86, ARC, openisa_rv32m1, and RISC-V.
|
# x86, ARC, openisa_rv32m1, and RISC-V.
|
||||||
# Note: On RISC-V the rom_start section will be after vector section.
|
# Note: On RISC-V the rom_start section will be after vector section.
|
||||||
# RAM_SECTIONS Inside the RAMABLE_REGION GROUP.
|
# 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
|
# SECTIONS Near the end of the file. Don't use this when linking into
|
||||||
# RAMABLE_REGION, use RAM_SECTIONS instead.
|
# RAMABLE_REGION, use RAM_SECTIONS instead.
|
||||||
# <sort_key> is an optional key to sort by inside of each location. The key must
|
# <sort_key> is an optional key to sort by inside of each location. The key must
|
||||||
|
@ -1118,8 +1119,8 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
|
||||||
# _mysection_end = .;
|
# _mysection_end = .;
|
||||||
# _mysection_size = ABSOLUTE(_mysection_end - _mysection_start);
|
# _mysection_size = ABSOLUTE(_mysection_end - _mysection_start);
|
||||||
#
|
#
|
||||||
# When placing into SECTIONS or RAM_SECTIONS, the files must instead define
|
# When placing into SECTIONS, RAM_SECTIONS or DATA_SECTIONS, the files must
|
||||||
# their own output sections to achieve the same thing:
|
# instead define their own output sections to achieve the same thing:
|
||||||
# SECTION_PROLOGUE(.mysection,,)
|
# SECTION_PROLOGUE(.mysection,,)
|
||||||
# {
|
# {
|
||||||
# _mysection_start = .;
|
# _mysection_start = .;
|
||||||
|
@ -1140,6 +1141,7 @@ function(zephyr_linker_sources location)
|
||||||
set(snippet_base "${__build_dir}/include/generated")
|
set(snippet_base "${__build_dir}/include/generated")
|
||||||
set(sections_path "${snippet_base}/snippets-sections.ld")
|
set(sections_path "${snippet_base}/snippets-sections.ld")
|
||||||
set(ram_sections_path "${snippet_base}/snippets-ram-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(rom_start_path "${snippet_base}/snippets-rom-start.ld")
|
||||||
set(noinit_path "${snippet_base}/snippets-noinit.ld")
|
set(noinit_path "${snippet_base}/snippets-noinit.ld")
|
||||||
set(rwdata_path "${snippet_base}/snippets-rwdata.ld")
|
set(rwdata_path "${snippet_base}/snippets-rwdata.ld")
|
||||||
|
@ -1150,6 +1152,7 @@ function(zephyr_linker_sources location)
|
||||||
if (NOT DEFINED cleared)
|
if (NOT DEFINED cleared)
|
||||||
file(WRITE ${sections_path} "")
|
file(WRITE ${sections_path} "")
|
||||||
file(WRITE ${ram_sections_path} "")
|
file(WRITE ${ram_sections_path} "")
|
||||||
|
file(WRITE ${data_sections_path} "")
|
||||||
file(WRITE ${rom_start_path} "")
|
file(WRITE ${rom_start_path} "")
|
||||||
file(WRITE ${noinit_path} "")
|
file(WRITE ${noinit_path} "")
|
||||||
file(WRITE ${rwdata_path} "")
|
file(WRITE ${rwdata_path} "")
|
||||||
|
@ -1162,6 +1165,8 @@ function(zephyr_linker_sources location)
|
||||||
set(snippet_path "${sections_path}")
|
set(snippet_path "${sections_path}")
|
||||||
elseif("${location}" STREQUAL "RAM_SECTIONS")
|
elseif("${location}" STREQUAL "RAM_SECTIONS")
|
||||||
set(snippet_path "${ram_sections_path}")
|
set(snippet_path "${ram_sections_path}")
|
||||||
|
elseif("${location}" STREQUAL "DATA_SECTIONS")
|
||||||
|
set(snippet_path "${data_sections_path}")
|
||||||
elseif("${location}" STREQUAL "ROM_START")
|
elseif("${location}" STREQUAL "ROM_START")
|
||||||
set(snippet_path "${rom_start_path}")
|
set(snippet_path "${rom_start_path}")
|
||||||
elseif("${location}" STREQUAL "NOINIT")
|
elseif("${location}" STREQUAL "NOINIT")
|
||||||
|
|
|
@ -196,6 +196,11 @@ SECTIONS {
|
||||||
#include <linker/cplusplus-ram.ld>
|
#include <linker/cplusplus-ram.ld>
|
||||||
#endif /* __MWDT_LINKER_CMD__ */
|
#endif /* __MWDT_LINKER_CMD__ */
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
MPU_MIN_SIZE_ALIGN
|
MPU_MIN_SIZE_ALIGN
|
||||||
/* Define linker symbols */
|
/* Define linker symbols */
|
||||||
|
|
|
@ -298,6 +298,11 @@ SECTIONS
|
||||||
#include <linker/kobject-data.ld>
|
#include <linker/kobject-data.ld>
|
||||||
#include <linker/cplusplus-ram.ld>
|
#include <linker/cplusplus-ram.ld>
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -323,6 +323,11 @@ SECTIONS
|
||||||
|
|
||||||
#include <linker/cplusplus-ram.ld>
|
#include <linker/cplusplus-ram.ld>
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
|
|
||||||
#ifndef CONFIG_USERSPACE
|
#ifndef CONFIG_USERSPACE
|
||||||
|
|
|
@ -274,6 +274,11 @@ SECTIONS
|
||||||
#include <linker/kobject-data.ld>
|
#include <linker/kobject-data.ld>
|
||||||
#include <linker/cplusplus-ram.ld>
|
#include <linker/cplusplus-ram.ld>
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,11 @@ SECTIONS
|
||||||
|
|
||||||
#include <linker/cplusplus-ram.ld>
|
#include <linker/cplusplus-ram.ld>
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
|
|
||||||
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
|
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
|
||||||
|
|
|
@ -48,6 +48,11 @@ SECTIONS
|
||||||
|
|
||||||
#include <arch/posix/native_tasks.ld>
|
#include <arch/posix/native_tasks.ld>
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
|
|
||||||
/* Located in generated directory. This file is populated by the
|
/* Located in generated directory. This file is populated by the
|
||||||
|
|
|
@ -247,6 +247,12 @@ SECTIONS
|
||||||
* zephyr_linker_sources() Cmake function.
|
* zephyr_linker_sources() Cmake function.
|
||||||
*/
|
*/
|
||||||
#include <snippets-ram-sections.ld>
|
#include <snippets-ram-sections.ld>
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
|
|
||||||
MPU_MIN_SIZE_ALIGN
|
MPU_MIN_SIZE_ALIGN
|
||||||
|
|
|
@ -104,6 +104,12 @@ SECTIONS
|
||||||
* zephyr_linker_sources() Cmake function.
|
* zephyr_linker_sources() Cmake function.
|
||||||
*/
|
*/
|
||||||
#include <snippets-ram-sections.ld>
|
#include <snippets-ram-sections.ld>
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
|
|
||||||
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
|
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
|
||||||
|
|
|
@ -476,6 +476,11 @@ SECTIONS
|
||||||
#include <linker/kobject-data.ld>
|
#include <linker/kobject-data.ld>
|
||||||
#endif /* !CONFIG_LINKER_USE_PINNED_SECTION */
|
#endif /* !CONFIG_LINKER_USE_PINNED_SECTION */
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
MMU_PAGE_ALIGN
|
MMU_PAGE_ALIGN
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,11 @@ SECTIONS
|
||||||
#include <linker/cplusplus-ram.ld>
|
#include <linker/cplusplus-ram.ld>
|
||||||
#include <arch/x86/pagetables.ld>
|
#include <arch/x86/pagetables.ld>
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
/* Must be last in RAM */
|
/* Must be last in RAM */
|
||||||
#include <linker/kobject-data.ld>
|
#include <linker/kobject-data.ld>
|
||||||
MMU_PAGE_ALIGN
|
MMU_PAGE_ALIGN
|
||||||
|
|
|
@ -183,6 +183,11 @@ SECTIONS
|
||||||
#include <linker/common-ram.ld>
|
#include <linker/common-ram.ld>
|
||||||
#include <linker/cplusplus-ram.ld>
|
#include <linker/cplusplus-ram.ld>
|
||||||
|
|
||||||
|
/* Located in generated directory. This file is populated by the
|
||||||
|
* zephyr_linker_sources() Cmake function.
|
||||||
|
*/
|
||||||
|
#include <snippets-data-sections.ld>
|
||||||
|
|
||||||
__data_ram_end = .;
|
__data_ram_end = .;
|
||||||
__data_rom_start = LOADADDR(_DATA_SECTION_NAME);
|
__data_rom_start = LOADADDR(_DATA_SECTION_NAME);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue