To condense and summarize:

Problem:
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.)

Resolution:
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!

BillW


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to