------- 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

Reply via email to