@ -335,6 +335,7 @@ function(group_to_string)
@@ -335,6 +335,7 @@ function(group_to_string)
get_property ( name_clean GLOBAL PROPERTY ${ section } _NAME_CLEAN )
get_property ( parent GLOBAL PROPERTY ${ section } _PARENT )
get_property ( noinit GLOBAL PROPERTY ${ section } _NOINIT )
# T h i s i s o n l y a t r i c k t o g e t t h e m e m o r i e s
get_property ( parent_type GLOBAL PROPERTY ${ parent } _OBJ_TYPE )
if ( ${ parent_type } STREQUAL GROUP )
@ -351,7 +352,7 @@ function(group_to_string)
@@ -351,7 +352,7 @@ function(group_to_string)
endif ( )
set ( ${ STRING_STRING } "${${STRING_STRING}}\" ${ name } \": place in ${ ILINK_CURRENT_NAME } { block ${ name_clean } };\n " )
if ( DEFINED vma AND DEFINED lma )
if ( DEFINED vma AND DEFINED lma AND NOT ${ noinit } )
set ( ${ STRING_STRING } "${${STRING_STRING}}\" ${ name } _init\ ": place in ${lma} { block ${name_clean}_init };\n" )
endif ( )
@ -518,18 +519,8 @@ function(section_to_string)
@@ -518,18 +519,8 @@ function(section_to_string)
set_property ( GLOBAL APPEND PROPERTY ILINK_SYMBOL_ICF "__${name_clean}_end = END(${name_clean})" )
endif ( )
endif ( )
# A d d k e e p t o t h e s e c t i o n s t h a t h a v e ' K E E P : T R U E '
foreach ( idx ${ indicies } )
get_property ( keep GLOBAL PROPERTY ${ STRING_SECTION } _SETTING_ ${ idx } _KEEP )
get_property ( input GLOBAL PROPERTY ${ STRING_SECTION } _SETTING_ ${ idx } _INPUT )
foreach ( setting ${ input } )
if ( keep )
# k e e p { s e c t i o n . a b c * } ;
set ( TEMP "${TEMP}keep { section ${setting} };\n" )
endif ( )
endforeach ( )
endforeach ( )
# s e c t i o n p a t t e r n s a n d b l o c k s t o k e e p { }
set ( to_be_kept "" )
if ( DEFINED first_index_section )
set ( TEMP "${TEMP}${first_index_section}\n" )
@ -606,6 +597,12 @@ function(section_to_string)
@@ -606,6 +597,12 @@ function(section_to_string)
# G e t t h e n e x t o f f s e t a n d u s e t h a t a s t h i s o n e s s i z e !
get_property ( offset GLOBAL PROPERTY ${ STRING_SECTION } _SETTING_ ${ idx_next } _OFFSET )
if ( keep )
list ( APPEND to_be_kept "block ${name_clean}_${idx}" )
foreach ( setting ${ input } )
list ( APPEND to_be_kept "section ${setting}" )
endforeach ( )
endif ( )
if ( DEFINED symbols )
list ( LENGTH symbols symbols_count )
if ( ${ symbols_count } GREATER 0 )
@ -810,7 +807,14 @@ function(section_to_string)
@@ -810,7 +807,14 @@ function(section_to_string)
get_property ( current_sections GLOBAL PROPERTY ILINK_CURRENT_SECTIONS )
if ( DEFINED group_parent_vma AND DEFINED group_parent_lma )
if ( DEFINED current_sections )
if ( ${ noinit } )
list ( JOIN current_sections ", " SELECTORS )
set ( TEMP "${TEMP}\ndo not initialize {\n${SELECTORS}\n};" )
else ( )
# G e n e r a t e t h e _ i n i t b l o c k a n d t h e i n i t i a l i z e m a n u a l l y s t a t e m e n t .
# N o t e t h a t w e n e e d t o h a v e t h e X _ i n i t b l o c k d e f i n e d e v e n i f w e h a v e
# n o s e c t i o n s , s i n c e t h e r e w i l l c o m e a " p l a c e i n X X X " s t a t e m e n t l a t e r .
# " $ { T E M P } " i s t h e r e t o o k e e p t h e ' ; ' e l s e i t w i l l b e a l i s t
string ( REGEX REPLACE "(block[ \t\r\n]+)([^ \t\r\n]+)" "\\1\\2_init" INIT_TEMP "${TEMP}" )
string ( REGEX REPLACE "(rw)([ \t\r\n]+)(section[ \t\r\n]+)([^ \t\r\n,]+)" "\\1\\2\\3\\4_init" INIT_TEMP "${INIT_TEMP}" )
@ -818,7 +822,13 @@ function(section_to_string)
@@ -818,7 +822,13 @@ function(section_to_string)
string ( REGEX REPLACE "alphabetical order, " "" INIT_TEMP "${INIT_TEMP}" )
string ( REGEX REPLACE "{ readwrite }" "{ }" INIT_TEMP "${INIT_TEMP}" )
# I f a n y c o n t e n t i s m a r k e d a s k e e p , i s h a s t o b e a p p l i e d t o t h e i n i t b l o c k
# t o o , e s p . f o r b l o c k s t h a t a r e n o t referenced ( e.g. empty blocks wiht min_size )
if ( to_be_kept )
list ( APPEND to_be_kept "block ${name_clean}_init" )
endif ( )
set ( TEMP "${TEMP}\n${INIT_TEMP}\n" )
if ( DEFINED current_sections )
set ( TEMP "${TEMP}\ninitialize manually with copy friendly\n" )
set ( TEMP "${TEMP}{\n" )
foreach ( section ${ current_sections } )
@ -826,9 +836,15 @@ function(section_to_string)
@@ -826,9 +836,15 @@ function(section_to_string)
endforeach ( )
set ( TEMP "${TEMP}};" )
set ( current_sections )
endif ( )
endif ( )
endif ( )
# F i n a l l y , a d d t h e k e e p s .
if ( to_be_kept )
list ( JOIN to_be_kept ", " K )
set ( TEMP "${TEMP}\nkeep { ${K} };\n" )
endif ( )
set ( ${ STRING_STRING } "${${STRING_STRING}}\n${TEMP}\n" PARENT_SCOPE )
endfunction ( )