linker: Add ROM_SECTIONS location

Currently iterable sections as per the documentation are added with
zephyr_linker_sources(SECTIONS ...) after bss/noinit.
This commit allows putting sections after common-rom.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2024-04-25 09:14:53 +02:00 committed by Anas Nashif
commit 99366dd2be
26 changed files with 116 additions and 2 deletions

View file

@ -420,6 +420,10 @@ SECTIONS
lnkr_pinned_rodata_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(pinned.rodata,,)
@ -649,6 +653,10 @@ SECTIONS
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
#endif

View file

@ -1182,6 +1182,7 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
# 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.
# ROM_SECTIONS Inside the ROMABLE_REGION GROUP, not initialized.
# RAM_SECTIONS Inside the RAMABLE_REGION GROUP, not initialized.
# DATA_SECTIONS Inside the RAMABLE_REGION GROUP, initialized.
# RAMFUNC_SECTION Inside the RAMFUNC RAMABLE_REGION GROUP, not initialized.
@ -1210,8 +1211,8 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
# _mysection_end = .;
# _mysection_size = ABSOLUTE(_mysection_end - _mysection_start);
#
# When placing into SECTIONS, RAM_SECTIONS or DATA_SECTIONS, the files must
# instead define their own output sections to achieve the same thing:
# When placing into SECTIONS, ROM_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 = .;
@ -1231,6 +1232,7 @@ function(zephyr_linker_sources location)
# the global linker.ld.
set(snippet_base "${__build_dir}/include/generated")
set(sections_path "${snippet_base}/snippets-sections.ld")
set(rom_sections_path "${snippet_base}/snippets-rom-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")
@ -1250,6 +1252,7 @@ function(zephyr_linker_sources location)
get_property(cleared GLOBAL PROPERTY snippet_files_cleared)
if (NOT DEFINED cleared)
file(WRITE ${sections_path} "")
file(WRITE ${rom_sections_path} "")
file(WRITE ${ram_sections_path} "")
file(WRITE ${data_sections_path} "")
file(WRITE ${rom_start_path} "")
@ -1269,6 +1272,8 @@ function(zephyr_linker_sources location)
# Choose destination file, based on the <location> argument.
if ("${location}" STREQUAL "SECTIONS")
set(snippet_path "${sections_path}")
elseif("${location}" STREQUAL "ROM_SECTIONS")
set(snippet_path "${rom_sections_path}")
elseif("${location}" STREQUAL "RAM_SECTIONS")
set(snippet_path "${ram_sections_path}")
elseif("${location}" STREQUAL "DATA_SECTIONS")

View file

@ -106,6 +106,10 @@ SECTIONS {
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#ifdef __MWDT_LINKER_CMD__
SECTION_DATA_PROLOGUE(tdata,,)
{

View file

@ -197,6 +197,10 @@ SECTIONS
} GROUP_LINK_IN(ROMABLE_REGION)
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
#include <zephyr/linker/cplusplus-rom.ld>

View file

@ -202,6 +202,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

View file

@ -170,6 +170,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

View file

@ -79,6 +79,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

View file

@ -143,6 +143,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
{

View file

@ -34,6 +34,10 @@ SECTION_PROLOGUE(rom_start,,)
} GROUP_LINK_IN(ROMABLE_REGION)
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
{

View file

@ -190,6 +190,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

View file

@ -46,6 +46,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

View file

@ -215,6 +215,10 @@ SECTIONS
lnkr_pinned_rodata_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(pinned.rodata,,)
@ -350,6 +354,10 @@ SECTIONS
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
#endif

View file

@ -105,6 +105,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

View file

@ -156,6 +156,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

View file

@ -235,6 +235,10 @@ SECTIONS
} >RAMABLE_REGION
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>

View file

@ -445,6 +445,10 @@ SECTIONS
} >RAM :sram0_phdr
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
.rodata : ALIGN(4)
{

View file

@ -378,6 +378,11 @@ SECTIONS {
__common_rom_region_start = SEGSTART_CACHED;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
__rodata_region_end = .;
__common_rom_region_end = .;
__rodata_region_end = .;

View file

@ -323,6 +323,10 @@ SECTIONS {
#define RAMABLE_REGION RAM
#define ROMABLE_REGION RAM
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
.fw_ready : {
KEEP(*(".fw_ready"));

View file

@ -201,6 +201,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

View file

@ -365,6 +365,10 @@ SECTIONS
} >sdram0 :sdram0_phdr
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
.fw_ready : ALIGN(4)
{

View file

@ -371,6 +371,10 @@ SECTIONS
} >sdram0 :sdram0_phdr
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
.fw_ready : ALIGN(4)
{

View file

@ -365,6 +365,10 @@ SECTIONS
} >sdram0 :sdram0_phdr
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
.fw_ready : ALIGN(4)
{

View file

@ -365,6 +365,10 @@ SECTIONS
} >sdram0 :sdram0_phdr
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
.fw_ready : ALIGN(4)
{

View file

@ -161,6 +161,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

View file

@ -326,6 +326,10 @@ SECTIONS
} >iram_text_start :iram_text_start_phdr
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
.fw_ready : ALIGN(4)
{

View file

@ -125,6 +125,10 @@ SECTIONS
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
*/
#include <snippets-rom-sections.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)