diff --git a/components/esp_system/ld/esp32/sections.ld.in b/components/esp_system/ld/esp32/sections.ld.in index 8e3c76efac..62793100e8 100644 --- a/components/esp_system/ld/esp32/sections.ld.in +++ b/components/esp_system/ld/esp32/sections.ld.in @@ -352,8 +352,13 @@ SECTIONS KEEP (*(.preinit_array)) __preinit_array_end = ABSOLUTE(.); ALIGNED_SYMBOL(4, __init_array_start) +#if CONFIG_IDF_TOOLCHAIN_CLANG + KEEP (*(SORT_BY_INIT_PRIORITY(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array.*))) + KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array)) +#else KEEP (*(SORT_BY_INIT_PRIORITY(EXCLUDE_FILE (*crtend.* *crtbegin.*) .ctors.*))) KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .ctors)) +#endif __init_array_end = ABSOLUTE(.); __bothinit_array_end = ABSOLUTE(.); diff --git a/components/esp_system/ld/esp32s2/sections.ld.in b/components/esp_system/ld/esp32s2/sections.ld.in index d74e3cb96d..158df7fb8a 100644 --- a/components/esp_system/ld/esp32s2/sections.ld.in +++ b/components/esp_system/ld/esp32s2/sections.ld.in @@ -356,8 +356,13 @@ SECTIONS KEEP (*(.preinit_array)) __preinit_array_end = ABSOLUTE(.); ALIGNED_SYMBOL(4, __init_array_start) +#if CONFIG_IDF_TOOLCHAIN_CLANG + KEEP (*(SORT_BY_INIT_PRIORITY(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array.*))) + KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array)) +#else KEEP (*(SORT_BY_INIT_PRIORITY(EXCLUDE_FILE (*crtend.* *crtbegin.*) .ctors.*))) KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .ctors)) +#endif __init_array_end = ABSOLUTE(.); __bothinit_array_end = ABSOLUTE(.); diff --git a/components/esp_system/ld/esp32s3/sections.ld.in b/components/esp_system/ld/esp32s3/sections.ld.in index 61ca1a846b..b7facdb8c5 100644 --- a/components/esp_system/ld/esp32s3/sections.ld.in +++ b/components/esp_system/ld/esp32s3/sections.ld.in @@ -365,8 +365,13 @@ SECTIONS KEEP (*(.preinit_array)) __preinit_array_end = ABSOLUTE(.); ALIGNED_SYMBOL(4, __init_array_start) +#if CONFIG_IDF_TOOLCHAIN_CLANG + KEEP (*(SORT_BY_INIT_PRIORITY(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array.*))) + KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array)) +#else KEEP (*(SORT_BY_INIT_PRIORITY(EXCLUDE_FILE (*crtend.* *crtbegin.*) .ctors.*))) KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .ctors)) +#endif __init_array_end = ABSOLUTE(.); __bothinit_array_end = ABSOLUTE(.);