Skip to content

Commit a464a4d

Browse files
committed
iar: linker_script: Parse LD style INPUT specifications
Add support for LD-style file specifications in the IAR generator for `zephyr_linker_section_configure(INPUT` Signed-off-by: Robin Kastberg <robin.kastberg@iar.com>
1 parent fc56305 commit a464a4d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

cmake/linker/iar/config_file_script.cmake

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,27 @@ function(section_to_string)
712712
# message(FATAL_ERROR "How to handle this? lma=${lma} vma=${vma}")
713713
# endif()
714714

715-
set(TEMP "${TEMP}${section_type} ${part}section ${setting}")
716-
set_property(GLOBAL APPEND PROPERTY ILINK_CURRENT_SECTIONS "section ${setting}")
715+
716+
# Setting may have file-pattern or not.
717+
# <file-pattern>(<section-patterns>... )
718+
# <file-pattern> is [library.a:]file
719+
# e.g. foo.a:bar.o(.data*)
720+
if(setting MATCHES "^([^\\(]+)\\((.+)\\)$")
721+
set(file_pattern "${CMAKE_MATCH_1}")
722+
set(section_pattern "${CMAKE_MATCH_2}")
723+
724+
# This contains library:object specification.
725+
# This is translated from LD lib.a:obj.o to IARs obj.o(lib.a).
726+
if(file_pattern MATCHES "^([^:]+):(.+)$")
727+
set(file_pattern "${CMAKE_MATCH_2}(${CMAKE_MATCH_1})")
728+
endif()
729+
set(pattern "section ${section_pattern} object ${file_pattern}")
730+
else()
731+
set(pattern "section ${setting}")
732+
endif()
733+
734+
set(TEMP "${TEMP}${section_type} ${part} ${pattern}")
735+
set_property(GLOBAL APPEND PROPERTY ILINK_CURRENT_SECTIONS "${pattern}")
717736
set(section_type "")
718737

719738
if("${setting}" STREQUAL "${last_input}")

0 commit comments

Comments
 (0)