public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/42240]  New: wrong Epilog on nacked function
@ 2009-12-01 16:18 stefan dot dreyer at yahoo dot de
  2010-07-31 10:22 ` [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 12+ messages in thread
From: stefan dot dreyer at yahoo dot de @ 2009-12-01 16:18 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3055 bytes --]

Hello!

Following code is Producing an infinit loop, so main() is never reached

extern int main(void);
int main(void){
        while(1);
}
#include <avr\io.h>
/*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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-01-26 22:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-42240-4@http.gcc.gnu.org/bugzilla/>
2010-11-04 11:14 ` [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function avr at gjlay dot de
2010-11-09 10:24 ` anitha.boyapati at atmel dot com
2010-11-09 10:26 ` anitha.boyapati at atmel dot com
2010-11-09 17:16 ` avr at gjlay dot de
2010-11-09 17:21 ` avr at gjlay dot de
2010-11-10 10:38 ` anitha.boyapati at atmel dot com
2010-11-10 13:01 ` avr at gjlay dot de
2011-02-27  9:33 ` denisc at gcc dot gnu.org
2011-03-03 16:59 ` denisc at gcc dot gnu.org
2011-04-14 15:38 ` gjl at gcc dot gnu.org
2012-01-26 23:44 ` gjl at gcc dot gnu.org
2009-12-01 16:18 [Bug c/42240] New: wrong Epilog on nacked function stefan dot dreyer at yahoo dot de
2010-07-31 10:22 ` [Bug target/42240] [4.3/4.4 Regression] wrong epilogue on naked function rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).