Hello! Following code is Producing an infinit loop, so main() is never reached extern int main(void); int main(void){ while(1); } #include /*Seed aus SRAM Zellen*/ static uint16_t seedram __attribute__ ((section (".noinit"))); void __init_seed(void) __attribute__ ((naked, section (".init8"))); // Bestimme seed aus zufälligem RAM-Inhalt // !!! FUNKTION NICHT AUFRUFEN !!! // !!! FUNKTION WIRD AUTOMATISCH !!! // !!! IN .init8 vor main AUSGEFÜHRT !!! void __init_seed (void) { uint16_t s = 0; uint16_t *p = (uint16_t*) (RAMEND+1); extern uint16_t __noinit_start; while (p >= &__noinit_start + 1) s ^= *(--p); seedram = s; } is going to while (p >= &__noinit_start + 1) 8e: 81 e0 ldi r24, 0x01 ; 1 90: e2 30 cpi r30, 0x02 ; 2 92: f8 07 cpc r31, r24 94: c0 f7 brcc .-16 ; 0x86 <__init_seed+0x12> s ^= *(--p); seedram = s; 96: 30 93 01 01 sts 0x0101, r19 9a: 20 93 00 01 sts 0x0100, r18 } 9e: 20 e0 ldi r18, 0x00 ; 0 a0: 30 e0 ldi r19, 0x00 ; 0 a2: f9 cf rjmp .-14 ; 0x96 <__init_seed+0x22> at line a2: an infinit loop starts and never leaves this function. the Problem is only an Optimation levels O2 and O3 Orginal thread in german Forum: http://www.mikrocontroller.net/topic/158516 compiler call: avr-gcc -c -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=8000000UL -O2 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -std=c99 -MMD -MP -MF .dep/main.o.d main.c -o main.o linker call: avr-gcc -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=8000000UL -O2 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o -std=c99 -MMD -MP -MF .dep/main.elf.d main.o --output main.elf -Wl,-Map=main.map,--cref -lm Compiler version: D:\Daten\Projekte\Eclipse Workspace\test init>avr-gcc -v Using built-in specs. Target: avr Configured with: ../gcc-4.3.2/configure --enable-win32-registry=WinAVR-20090313 --with-gmp=/usr/local --with-mpfr=/usr/local --prefix=/c/WinAVR --target=avr --enable-languages=c,c++,objc --with-dwarf2 --enable-doc --disable-shared --disable-libada --disable-libssp --disable-nls --with-pkgversion='WinAVR20090313' --with-bugurl='URL:http://sourceforge.net/tracker/?atid=520074&group_id=68108&func=browse'Thread model: single gcc version 4.3.2 (WinAVR 20090313) Greetings Stefan -- Summary: wrong Epilog on nacked function Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: stefan dot dreyer at yahoo dot de GCC host triplet: Windows XP GCC target triplet: AVR http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42240