https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86680
--- Comment #11 from Florian La Roche <florian.laroche at googlemail dot com> --- Below my current code that disables optimization for this one function and thus generates ok code length. best regards, Florian La Roche #if __GNUC__ > 4 #define __gcc_no_ivopts __attribute__ ((optimize("no-ivopts"))) #else #define __gcc_no_ivopts #endif extern unsigned long __bss_start[], __bss_end[]; void __gcc_no_ivopts clear_bss(void) { unsigned long *bss = __bss_start; #if 1 while (bss < __bss_end) *bss++ = 0UL; #else unsigned long i, end = (__bss_end - __bss_start) * sizeof(unsigned long); for (i = 0; i < end; i += sizeof(unsigned long)) *bss++ = 0UL; #endif }