Skip to content

Commit 99366dd

Browse files
pdgendtnashif
authored andcommitted
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>
1 parent eea1573 commit 99366dd

File tree

26 files changed

+116
-2
lines changed

26 files changed

+116
-2
lines changed

boards/qemu/x86/qemu_x86_tiny.ld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ SECTIONS
420420
lnkr_pinned_rodata_start = .;
421421

422422
#include <zephyr/linker/common-rom.ld>
423+
/* Located in generated directory. This file is populated by calling
424+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
425+
*/
426+
#include <snippets-rom-sections.ld>
423427
#include <zephyr/linker/thread-local-storage.ld>
424428

425429
SECTION_PROLOGUE(pinned.rodata,,)
@@ -649,6 +653,10 @@ SECTIONS
649653

650654
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
651655
#include <zephyr/linker/common-rom.ld>
656+
/* Located in generated directory. This file is populated by calling
657+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
658+
*/
659+
#include <snippets-rom-sections.ld>
652660
#include <zephyr/linker/thread-local-storage.ld>
653661
#endif
654662

cmake/modules/extensions.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
11821182
# ROM_START Inside the first output section of the image. This option is
11831183
# currently only available on ARM Cortex-M, ARM Cortex-R,
11841184
# x86, ARC, openisa_rv32m1, and RISC-V.
1185+
# ROM_SECTIONS Inside the ROMABLE_REGION GROUP, not initialized.
11851186
# RAM_SECTIONS Inside the RAMABLE_REGION GROUP, not initialized.
11861187
# DATA_SECTIONS Inside the RAMABLE_REGION GROUP, initialized.
11871188
# RAMFUNC_SECTION Inside the RAMFUNC RAMABLE_REGION GROUP, not initialized.
@@ -1210,8 +1211,8 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
12101211
# _mysection_end = .;
12111212
# _mysection_size = ABSOLUTE(_mysection_end - _mysection_start);
12121213
#
1213-
# When placing into SECTIONS, RAM_SECTIONS or DATA_SECTIONS, the files must
1214-
# instead define their own output sections to achieve the same thing:
1214+
# When placing into SECTIONS, ROM_SECTIONS, RAM_SECTIONS or DATA_SECTIONS, the
1215+
# files must instead define their own output sections to achieve the same thing:
12151216
# SECTION_PROLOGUE(.mysection,,)
12161217
# {
12171218
# _mysection_start = .;
@@ -1231,6 +1232,7 @@ function(zephyr_linker_sources location)
12311232
# the global linker.ld.
12321233
set(snippet_base "${__build_dir}/include/generated")
12331234
set(sections_path "${snippet_base}/snippets-sections.ld")
1235+
set(rom_sections_path "${snippet_base}/snippets-rom-sections.ld")
12341236
set(ram_sections_path "${snippet_base}/snippets-ram-sections.ld")
12351237
set(data_sections_path "${snippet_base}/snippets-data-sections.ld")
12361238
set(rom_start_path "${snippet_base}/snippets-rom-start.ld")
@@ -1250,6 +1252,7 @@ function(zephyr_linker_sources location)
12501252
get_property(cleared GLOBAL PROPERTY snippet_files_cleared)
12511253
if (NOT DEFINED cleared)
12521254
file(WRITE ${sections_path} "")
1255+
file(WRITE ${rom_sections_path} "")
12531256
file(WRITE ${ram_sections_path} "")
12541257
file(WRITE ${data_sections_path} "")
12551258
file(WRITE ${rom_start_path} "")
@@ -1269,6 +1272,8 @@ function(zephyr_linker_sources location)
12691272
# Choose destination file, based on the <location> argument.
12701273
if ("${location}" STREQUAL "SECTIONS")
12711274
set(snippet_path "${sections_path}")
1275+
elseif("${location}" STREQUAL "ROM_SECTIONS")
1276+
set(snippet_path "${rom_sections_path}")
12721277
elseif("${location}" STREQUAL "RAM_SECTIONS")
12731278
set(snippet_path "${ram_sections_path}")
12741279
elseif("${location}" STREQUAL "DATA_SECTIONS")

include/zephyr/arch/arc/v2/linker.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ SECTIONS {
106106
__rodata_region_start = .;
107107

108108
#include <zephyr/linker/common-rom.ld>
109+
/* Located in generated directory. This file is populated by calling
110+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
111+
*/
112+
#include <snippets-rom-sections.ld>
109113
#ifdef __MWDT_LINKER_CMD__
110114
SECTION_DATA_PROLOGUE(tdata,,)
111115
{

include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ SECTIONS
197197
} GROUP_LINK_IN(ROMABLE_REGION)
198198

199199
#include <zephyr/linker/common-rom.ld>
200+
/* Located in generated directory. This file is populated by calling
201+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
202+
*/
203+
#include <snippets-rom-sections.ld>
200204
#include <zephyr/linker/thread-local-storage.ld>
201205
#include <zephyr/linker/cplusplus-rom.ld>
202206

include/zephyr/arch/arm/cortex_m/scripts/linker.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ SECTIONS
202202
__rodata_region_start = .;
203203

204204
#include <zephyr/linker/common-rom.ld>
205+
/* Located in generated directory. This file is populated by calling
206+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
207+
*/
208+
#include <snippets-rom-sections.ld>
205209
#include <zephyr/linker/thread-local-storage.ld>
206210

207211
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

include/zephyr/arch/arm64/scripts/linker.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ SECTIONS
170170
__rodata_region_start = .;
171171

172172
#include <zephyr/linker/common-rom.ld>
173+
/* Located in generated directory. This file is populated by calling
174+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
175+
*/
176+
#include <snippets-rom-sections.ld>
173177
#include <zephyr/linker/thread-local-storage.ld>
174178

175179
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

include/zephyr/arch/mips/linker.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ SECTIONS
7979

8080
__rodata_region_start = .;
8181
#include <zephyr/linker/common-rom.ld>
82+
/* Located in generated directory. This file is populated by calling
83+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
84+
*/
85+
#include <snippets-rom-sections.ld>
8286
#include <zephyr/linker/thread-local-storage.ld>
8387

8488
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

include/zephyr/arch/nios2/linker.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ SECTIONS
143143
__rodata_region_start = .;
144144

145145
#include <zephyr/linker/common-rom.ld>
146+
/* Located in generated directory. This file is populated by calling
147+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
148+
*/
149+
#include <snippets-rom-sections.ld>
146150

147151
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
148152
{

include/zephyr/arch/posix/linker.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ SECTION_PROLOGUE(rom_start,,)
3434
} GROUP_LINK_IN(ROMABLE_REGION)
3535

3636
#include <zephyr/linker/common-rom.ld>
37+
/* Located in generated directory. This file is populated by calling
38+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
39+
*/
40+
#include <snippets-rom-sections.ld>
3741

3842
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
3943
{

include/zephyr/arch/riscv/common/linker.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ SECTIONS
190190

191191
__rodata_region_start = .;
192192
#include <zephyr/linker/common-rom.ld>
193+
/* Located in generated directory. This file is populated by calling
194+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
195+
*/
196+
#include <snippets-rom-sections.ld>
193197
#include <zephyr/linker/thread-local-storage.ld>
194198

195199
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)

0 commit comments

Comments
 (0)