Skip to content

Commit fe0b165

Browse files
bjorniuppsalakartben
authored andcommitted
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 9ac12b6 commit fe0b165

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
@@ -5327,6 +5327,10 @@ endfunction()
53275327
# ANY : ANY section flag in scatter file.
53285328
# The FLAGS and ANY arguments only has effect for scatter files.
53295329
# INPUT <input> : Input section name or list of input section names.
5330+
# <input> is either just a section name ".data*" or
5331+
# <file-pattern>(<section-patterns>... )
5332+
# <file-pattern> is [library.a:]file
5333+
# e.g. foo.a:bar.o(.data*)
53305334
#
53315335
function(zephyr_linker_section_configure)
53325336
set(options "ANY;FIRST;KEEP")

0 commit comments

Comments
 (0)