Skip to content

Commit b2d3fdc

Browse files
mmahadevan108mbolivar-nordic
authored andcommitted
cmake: Add support to add symbols to ramfunc section
This PR allows the user to add symbols to the ramfunc section. The use for this could be as follows: zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT RAMFUNC_SECTION quick_access_code.ld ) quick_access_code.ld (as shown below) can define additional symbols to go into the ramfunc section . = ALIGN(4); KEEP(*(CodeQuickAccess)) Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent f9a3f02 commit b2d3fdc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

arch/common/ramfunc.ld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ SECTION_DATA_PROLOGUE(.ramfunc,,)
1313
__ramfunc_start = .;
1414
*(.ramfunc)
1515
*(".ramfunc.*")
16+
17+
#include <snippets-ramfunc-section.ld>
18+
1619
MPU_ALIGN(__ramfunc_size);
1720
__ramfunc_end = .;
1821
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)

cmake/modules/extensions.cmake

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
11451145
# Note: On RISC-V the rom_start section will be after vector section.
11461146
# RAM_SECTIONS Inside the RAMABLE_REGION GROUP, not initialized.
11471147
# DATA_SECTIONS Inside the RAMABLE_REGION GROUP, initialized.
1148+
# RAMFUNC_SECTION Inside the RAMFUNC RAMABLE_REGION GROUP, not initialized.
11481149
# SECTIONS Near the end of the file. Don't use this when linking into
11491150
# RAMABLE_REGION, use RAM_SECTIONS instead.
11501151
# <sort_key> is an optional key to sort by inside of each location. The key must
@@ -1153,9 +1154,9 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
11531154
#
11541155
# Use NOINIT, RWDATA, and RODATA unless they don't work for your use case.
11551156
#
1156-
# When placing into NOINIT, RWDATA, RODATA, ROM_START, the contents of the files
1157-
# will be placed inside an output section, so assume the section definition is
1158-
# already present, e.g.:
1157+
# When placing into NOINIT, RWDATA, RODATA, ROM_START, RAMFUNC_SECTION the
1158+
# contents of the files will be placed inside an output section, so assume
1159+
# the section definition is already present, e.g.:
11591160
# _mysection_start = .;
11601161
# KEEP(*(.mysection));
11611162
# _mysection_end = .;
@@ -1188,6 +1189,7 @@ function(zephyr_linker_sources location)
11881189
set(noinit_path "${snippet_base}/snippets-noinit.ld")
11891190
set(rwdata_path "${snippet_base}/snippets-rwdata.ld")
11901191
set(rodata_path "${snippet_base}/snippets-rodata.ld")
1192+
set(ramfunc_path "${snippet_base}/snippets-ramfunc-section.ld")
11911193

11921194
# Clear destination files if this is the first time the function is called.
11931195
get_property(cleared GLOBAL PROPERTY snippet_files_cleared)
@@ -1199,6 +1201,7 @@ function(zephyr_linker_sources location)
11991201
file(WRITE ${noinit_path} "")
12001202
file(WRITE ${rwdata_path} "")
12011203
file(WRITE ${rodata_path} "")
1204+
file(WRITE ${ramfunc_path} "")
12021205
set_property(GLOBAL PROPERTY snippet_files_cleared true)
12031206
endif()
12041207

@@ -1217,6 +1220,8 @@ function(zephyr_linker_sources location)
12171220
set(snippet_path "${rwdata_path}")
12181221
elseif("${location}" STREQUAL "RODATA")
12191222
set(snippet_path "${rodata_path}")
1223+
elseif("${location}" STREQUAL "RAMFUNC_SECTION")
1224+
set(snippet_path "${ramfunc_path}")
12201225
else()
12211226
message(fatal_error "Must choose valid location for linker snippet.")
12221227
endif()

0 commit comments

Comments
 (0)