From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31099 invoked by alias); 22 Jul 2010 11:26:31 -0000 Received: (qmail 30933 invoked by uid 48); 22 Jul 2010 11:26:19 -0000 Date: Thu, 22 Jul 2010 11:26:00 -0000 Message-ID: <20100722112619.30932.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug target/42240] wrong epilogue on naked function In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "anitha dot boyapati at atmel dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-07/txt/msg02353.txt.bz2 ------- Comment #9 from anitha dot boyapati at atmel dot com 2010-07-22 11:26 ------- I think the bug is not due to 'naked' function. When the naked attribute is removed for __init_seed(void), the following diff can be observed in the assembly file. ==================================================== --- test_without_naked.s 2010-07-22 15:53:13.178956400 +0530 +++ test_with_naked.s 2010-07-22 15:52:52.474373900 +0530 @@ -14,10 +14,11 @@ .L2: rjmp .L2 .size main, .-main + .section .init8,"ax",@progbits .global __init_seed .type __init_seed, @function __init_seed: -/* prologue: function */ +/* prologue: naked */ /* frame size = 0 */ ldi r24,lo8(__noinit_start+2) ldi r25,hi8(__noinit_start+2) @@ -41,7 +42,6 @@ sts (seedram)+1,r19 sts seedram,r18 /* epilogue start */ - ret .L11: ldi r18,lo8(0) ldi r19,hi8(0) ======================================================= It can be seen that in case of naked function, 'ret' is not generated. Hence the execution goes into infinite loop. The code generated for epilogue is wrong in few cases for either for naked/normal functions with -O2 enabled. However incase of normal functions, execution is not affected as 'ret' is executed before entering into block labelled .L11 (of main.s). .L11: ldi r18,lo8(0) ldi r19,hi8(0) rjmp .L6 -- anitha dot boyapati at atmel dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anitha dot boyapati at atmel | |dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42240