diff --git a/templates/staticExecutable/static-executable-h2-picolibc.lcs.template b/templates/staticExecutable/static-executable-h2-picolibc.lcs.template index c4106bc97..c04a59ef9 100755 --- a/templates/staticExecutable/static-executable-h2-picolibc.lcs.template +++ b/templates/staticExecutable/static-executable-h2-picolibc.lcs.template @@ -35,28 +35,41 @@ SECTIONS /* Need to pre-align so that the symbols come after padding */ . = ALIGN(8); - .init_array : + PROVIDE_HIDDEN ( __bothinit_array_start = . ); + .preinit_array : { - /* lists of constructors and destructors */ PROVIDE_HIDDEN ( __preinit_array_start = . ); - PROVIDE_HIDDEN ( __bothinit_array_start = . ); KEEP (*(.preinit_array)) PROVIDE_HIDDEN ( __preinit_array_end = . ); - - PROVIDE_HIDDEN ( __init_array_start = . ); - /* run .ctors first */ + } + .ctors : + { + PROVIDE_HIDDEN ( __ctors_start = . ); KEEP (*( SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP (*(.ctors)) + PROVIDE_HIDDEN ( __ctors_end = . ); + } + .init_array : + { + PROVIDE_HIDDEN ( __init_array_start = . ); KEEP (*( SORT_BY_INIT_PRIORITY(.init_array.*))) - KEEP (*(.init_array .ctors)) + KEEP (*(.init_array)) PROVIDE_HIDDEN ( __init_array_end = . ); - PROVIDE_HIDDEN ( __bothinit_array_end = . ); } + PROVIDE_HIDDEN ( __bothinit_array_end = . ); + .dtors : + { + PROVIDE_HIDDEN ( __dtors_start = . ); + KEEP (*(SORT_BY_INIT_PRIORITY(.dtors.*))) + KEEP (*(.dtors)) + PROVIDE_HIDDEN ( __dtors_end = . ); + } .fini_array : { PROVIDE_HIDDEN ( __fini_array_start = . ); - KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) - KEEP (*(.fini_array .dtors)) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) + KEEP (*(.fini_array)) KEEP (*(.fini_array*)) PROVIDE_HIDDEN ( __fini_array_end = . ); }