[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Weird optimization issue with avr-gcc 4.5.3, re "nake

From: William \"Chops\" Westfield
Subject: Re: [avr-gcc-list] Weird optimization issue with avr-gcc 4.5.3, re "naked."
Date: Fri, 27 Jan 2012 20:44:37 -0800

To condense and summarize:

optiboot, a very small bootloader, grows signficantly in binary size when going 
from gcc 4.5.2 to gcc 4.5.3.  This turns out to be because it "misses" code 
factoring optimizations in optiboot's main() function, which is declared with 
attribute "naked" to save space.  The missing optimizations are tied to 
"naked"; in sample programs the optimizations re-appear when the naked 
attribute is not used.

Root cause:
PR42240 is a patch that specifically disables "jump modification" in Naked 
functions, because they can interfere with proper exit handling of naked 
functions in .init sections.  The .init sections are one of the primary 
intended uses for "naked", while making main() naked is not a recommended 
practice (and in fact caused/uncovered other bugs in the optiboot code.)

optiboot will use the "OS_main" attribute instead of "naked."
It doesn't disable the optimization, the resulting code is "small enough", and 
the attribute is more exactly appropriate and correct as well.  It was probably 
an oversight that OS_main wasn't used in the first place.

Thanks to all who assisted, especially Herr Lay, who identified the root cause!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]