@@ -606,6 +606,15 @@ function(section_to_string)
606
606
list (APPEND to_be_kept "section ${setting} " )
607
607
endforeach ()
608
608
endif ()
609
+ # In ilink if a block with min_size=X does not match any input sections,
610
+ # its _init block may be discarded despite being needed for spacing with
611
+ # other _init blocks. To get around tihs, lets tag min_size blocks as keep.
612
+ if (CONFIG_IAR_ZEPHYR_INIT
613
+ AND DEFINED group_parent_vma AND DEFINED group_parent_lma
614
+ AND DEFINED i_min_size
615
+ AND NOT ${noinit} )
616
+ list (APPEND to_be_kept "block ${name_clean} _${idx} _init" )
617
+ endif ()
609
618
if (DEFINED symbols )
610
619
list (LENGTH symbols symbols_count )
611
620
if (${symbols_count} GREATER 0 )
@@ -784,47 +793,48 @@ function(section_to_string)
784
793
list (JOIN current_sections ", " SELECTORS )
785
794
set (TEMP "${TEMP} \n do not initialize {\n ${SELECTORS} \n };" )
786
795
elseif (DEFINED group_parent_vma AND DEFINED group_parent_lma )
787
- if (DEFINED current_sections )
788
- if (CONFIG_IAR_DATA_INIT )
789
- set (TEMP "${TEMP} \n initialize by copy\n " )
790
- set (TEMP "${TEMP} {\n " )
791
- foreach (section ${current_sections} )
792
- set (TEMP "${TEMP} ${section} ,\n " )
793
- endforeach ()
794
- set (TEMP "${TEMP} };" )
796
+ if (CONFIG_IAR_DATA_INIT AND DEFINED current_sections )
797
+ set (TEMP "${TEMP} \n initialize by copy\n " )
798
+ set (TEMP "${TEMP} {\n " )
799
+ foreach (section ${current_sections} )
800
+ set (TEMP "${TEMP} ${section} ,\n " )
801
+ endforeach ()
802
+ set (TEMP "${TEMP} };" )
795
803
796
- set (TEMP "${TEMP} \n\" ${name} _init\" : place in ${group_parent_lma} {\n " )
797
- foreach (section ${current_sections} )
798
- set (TEMP "${TEMP} ${section} _init,\n " )
799
- endforeach ()
800
- set (TEMP "${TEMP} };" )
801
- elseif (CONFIG_IAR_ZEPHYR_INIT )
802
- # Generate the _init block and the initialize manually statement.
803
- # Note that we need to have the X_init block defined even if we have
804
- # no sections, since there will come a "place in XXX" statement later.
805
-
806
- # "${TEMP}" is there too keep the ';' else it will be a list
807
- string (REGEX REPLACE "(block[ \t\r\n ]+)([^ \t\r\n ]+)" "\\ 1\\ 2_init" INIT_TEMP "${TEMP} " )
808
- string (REGEX REPLACE "(rw)([ \t\r\n ]+)(section[ \t\r\n ]+)([^ \t\r\n ,]+)" "\\ 1\\ 2\\ 3\\ 4_init" INIT_TEMP "${INIT_TEMP} " )
809
- string (REGEX REPLACE "(rw)([ \t\r\n ]+)(section[ \t\r\n ]+)" "ro\\ 2\\ 3" INIT_TEMP "${INIT_TEMP} " )
810
- string (REGEX REPLACE "alphabetical order, " "" INIT_TEMP "${INIT_TEMP} " )
811
- string (REGEX REPLACE "{ readwrite }" "{ }" INIT_TEMP "${INIT_TEMP} " )
812
-
813
- # If any content is marked as keep, is has to be applied to the init block
814
- # too, esp. for blocks that are not referenced (e.g. empty blocks wiht min_size)
815
- if (to_be_kept )
816
- list (APPEND to_be_kept "block ${name_clean} _init" )
817
- endif ()
818
- set (TEMP "${TEMP} \n ${INIT_TEMP} \n " )
804
+ set (TEMP "${TEMP} \n\" ${name} _init\" : place in ${group_parent_lma} {\n " )
805
+ foreach (section ${current_sections} )
806
+ set (TEMP "${TEMP} ${section} _init,\n " )
807
+ endforeach ()
808
+ set (TEMP "${TEMP} };" )
809
+ elseif (CONFIG_IAR_ZEPHYR_INIT )
810
+ # Generate the _init block and the initialize manually statement.
811
+ # Note that we need to have the X_init block defined even if we have
812
+ # no sections, since there will come a "place in XXX" statement later.
813
+
814
+ # "${TEMP}" is there too keep the ';' else it will be a list
815
+ string (REGEX REPLACE "(block[ \t\r\n ]+)([^ \t\r\n ]+)" "\\ 1\\ 2_init" INIT_TEMP "${TEMP} " )
816
+ string (REGEX REPLACE "(rw)([ \t\r\n ]+)(section[ \t\r\n ]+)([^ \t\r\n ,]+)" "\\ 1\\ 2\\ 3\\ 4_init" INIT_TEMP "${INIT_TEMP} " )
817
+ string (REGEX REPLACE "(rw)([ \t\r\n ]+)(section[ \t\r\n ]+)" "ro\\ 2\\ 3" INIT_TEMP "${INIT_TEMP} " )
818
+ string (REGEX REPLACE "alphabetical order, " "" INIT_TEMP "${INIT_TEMP} " )
819
+ string (REGEX REPLACE "{ readwrite }" "{ }" INIT_TEMP "${INIT_TEMP} " )
820
+ set (TEMP "${TEMP} \n ${INIT_TEMP} \n " )
821
+
822
+ # If any content is marked as keep, is has to be applied to the init block
823
+ # too, esp. for blocks that are not referenced (e.g. empty blocks with min_size)
824
+ if (to_be_kept )
825
+ list (APPEND to_be_kept "block ${name_clean} _init" )
826
+ endif ()
827
+
828
+ if (DEFINED current_sections )
819
829
set (TEMP "${TEMP} \n initialize manually with copy friendly\n " )
820
830
set (TEMP "${TEMP} {\n " )
821
831
foreach (section ${current_sections} )
822
832
set (TEMP "${TEMP} ${section} ,\n " )
823
833
endforeach ()
824
834
set (TEMP "${TEMP} };" )
825
835
endif ()
826
- set (current_sections )
827
836
endif ()
837
+ set (current_sections )
828
838
endif ()
829
839
830
840
# Finally, add the keeps.
0 commit comments