@@ -613,9 +613,6 @@ function(section_to_string)
613613
614614 if (keep)
615615 list (APPEND to_be_kept "block ${name_clean} _${idx} " )
616- foreach (setting ${input} )
617- list (APPEND to_be_kept "section ${setting} " )
618- endforeach ()
619616 endif ()
620617 # In ilink if a block with min_size=X does not match any input sections,
621618 # its _init block may be discarded despite being needed for spacing with
@@ -740,8 +737,27 @@ function(section_to_string)
740737
741738 set (section_type "" )
742739
743- set (TEMP "${TEMP}${section_type} ${part} section ${setting} " )
744- set_property (GLOBAL APPEND PROPERTY ILINK_CURRENT_SECTIONS "section ${setting} " )
740+ # Setting may have file-pattern or not.
741+ # <file-pattern>(<section-patterns>... )
742+ # <file-pattern> is [library.a:]file
743+ # e.g. foo.a:bar.o(.data*)
744+ if (setting MATCHES "^([^\\ (]+)\\ ((.+)\\ )$" )
745+ set (file_pattern "${CMAKE_MATCH_1} " )
746+ set (section_pattern "${CMAKE_MATCH_2} " )
747+
748+ # This contains library:object specification.
749+ # This is translated from LD lib.a:obj.o to IARs obj.o(lib.a).
750+ if (file_pattern MATCHES "^([^:]+):(.+)$" )
751+ set (file_pattern "${CMAKE_MATCH_2} (${CMAKE_MATCH_1} )" )
752+ endif ()
753+ set (pattern "section ${section_pattern} object ${file_pattern} " )
754+ else ()
755+ set (pattern "section ${setting} " )
756+ endif ()
757+
758+ set (TEMP "${TEMP}${section_type} ${part} ${pattern} " )
759+ set_property (GLOBAL APPEND PROPERTY ILINK_CURRENT_SECTIONS "${pattern} " )
760+
745761 set (section_type "" )
746762
747763 if ("${setting} " STREQUAL "${last_input} " )
@@ -750,6 +766,10 @@ function(section_to_string)
750766 set (TEMP "${TEMP} , " )
751767 endif ()
752768
769+ if (keep)
770+ list (APPEND to_be_kept "${pattern} " )
771+ endif ()
772+
753773 # set(TEMP "${TEMP}\n *.o(${setting})")
754774 endforeach ()
755775
0 commit comments