Skip to content

Commit cbe9308

Browse files
committed
cmake: linker generator: ld: Files for section input patterns
For CONFIG_USERSPACE the input from gen_app_partitions.py there is a need to be able to specify input files as well as input sections patterns for zephyr_linker_section_configure(). This is used for app partitions from libraries (which generate input patterns like foo.a:*(.data*)). This adds documentation to zephyr_linker_section_configure() to clarify what INPUT allows, and also adds some parsing tricks to ld_script.cmake to properly add the file patterns when they are missing. Signed-off-by: Björn Bergman <bjorn.bergman@iar.com>
1 parent 55c3678 commit cbe9308

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

cmake/linker/ld/ld_script.cmake

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,23 @@ function(section_to_string)
304304
set(current_offset ${offset})
305305
endif()
306306

307-
if(keep AND sort)
308-
set(TEMP "${TEMP}\n KEEP(*(${SORT_TYPE_${sort}}(${setting})));")
309-
elseif(SETTINGS_SORT)
310-
message(WARNING "Not tested")
311-
set(TEMP "${TEMP}\n *(${SORT_TYPE_${sort}}(${setting}));")
312-
elseif(keep)
313-
set(TEMP "${TEMP}\n KEEP(*(${setting}));")
307+
#setting may have file-pattern or not.
308+
if(setting MATCHES "(.+)\\((.+)\\)")
309+
set(file_pattern "${CMAKE_MATCH_1}")
310+
set(section_pattern "${CMAKE_MATCH_2}")
314311
else()
315-
set(TEMP "${TEMP}\n *(${setting})")
312+
set(file_pattern "*")
313+
set(section_pattern "${setting}")
316314
endif()
315+
316+
if(sort)
317+
set(section_pattern "${SORT_TYPE_${sort}}(${section_pattern})")
318+
endif()
319+
set(pattern "${file_pattern}(${section_pattern})")
320+
if(keep)
321+
set(pattern "KEEP(${pattern})")
322+
endif()
323+
set(TEMP "${TEMP}\n ${pattern};")
317324
endforeach()
318325

319326
if(DEFINED symbol_end)

cmake/modules/extensions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5308,6 +5308,10 @@ endfunction()
53085308
# ANY : ANY section flag in scatter file.
53095309
# The FLAGS and ANY arguments only has effect for scatter files.
53105310
# INPUT <input> : Input section name or list of input section names.
5311+
# <input> is either just a section name ".data*" or
5312+
# <file-pattern>(<section-patterns>... )
5313+
# <file-pattern> is [library.a:]file
5314+
# e.g. foo.a:bar.o(.data*)
53115315
#
53125316
function(zephyr_linker_section_configure)
53135317
set(options "ANY;FIRST;KEEP")

0 commit comments

Comments
 (0)