http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45263
--- Comment #7 from Michael Schulze <mschulze at ivs dot cs.ovgu.de> 2010-11-30 15:16:20 UTC --- Created attachment 22579 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22579 alternative patch using register r15 instead of r20 avoids pushing/poping In reaction to bug 29141, which is still pending and not fixed, I offer a patch that corrects the handling of global constructors. The fix proposed in bug 29141 leads to wrong handling of global constructors since gcc version 4.4.0. And this is independent of the 64kB boundary because the handling is always wrong. With the first provided patch the register r20 was always pushed and popped but this is not necessary. The global-constructors patch avoids this and uses r15 instead of r20. Due to the compiler abi the register r15 is left unchanged by called routines, and it has to be saved/restored by routines that use it. I applied the global-constructor patch and then the compiler generates correct code for the execution of global constructors regardless of whether the constructor is located below or above 64kB. I tested the patch by my own but I think it needs further tests. Please try it out. I think without such a patch independent of using my one or the r20 patch, this bug is a show stopper since gcc version 4.4.0.