re PR target/45263 (registers used in __do_global_ctors can get clobbered)
authorGeorg-Johann Lay <avr@gjlay.de>
Wed, 13 Apr 2011 16:36:50 +0000 (16:36 +0000)
committerGeorg-Johann Lay <gjl@gcc.gnu.org>
Wed, 13 Apr 2011 16:36:50 +0000 (16:36 +0000)
PR target/45263
* config/avr/libgcc.S (__do_global_ctors, __do_global_dtors): Save
R20 around calls of __tablejump_elpm__

From-SVN: r172384

gcc/ChangeLog
gcc/config/avr/libgcc.S

index ee201f84c6e01e8b3c346058a62d9922ef58f0b9..f2b85c1d23c8d682052c0f3f6ff54859c7886f99 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-01  Georg-Johann Lay  <avr@gjlay.de>
+
+       PR target/45263
+       * config/avr/libgcc.S (__do_global_ctors, __do_global_dtors): Save
+       R20 around calls of __tablejump_elpm__
+
 2011-04-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/48591
index 4a15f94a72122b352eab5b211efcbd414d44a449..2e8d9514a79642957d5c89e6136205c16fe4b105 100644 (file)
@@ -791,22 +791,22 @@ __do_clear_bss:
 #if defined(__AVR_HAVE_RAMPZ__)
 __do_global_ctors:
        ldi     r17, hi8(__ctors_start)
-       ldi     r16, hh8(__ctors_start)
        ldi     r28, lo8(__ctors_end)
        ldi     r29, hi8(__ctors_end)
-       ldi     r20, hh8(__ctors_end)
+       ldi     r16, hh8(__ctors_end)
        rjmp    .L__do_global_ctors_start
 .L__do_global_ctors_loop:
        sbiw    r28, 2
-       sbc     r20, __zero_reg__
+       sbc     r16, __zero_reg__
        mov_h   r31, r29
        mov_l   r30, r28
-       out     __RAMPZ__, r20
+       out     __RAMPZ__, r16
        XCALL   __tablejump_elpm__
 .L__do_global_ctors_start:
        cpi     r28, lo8(__ctors_start)
        cpc     r29, r17
-       cpc     r20, r16
+       ldi     r24, hh8(__ctors_start)
+       cpc     r16, r24
        brne    .L__do_global_ctors_loop
 #else
 __do_global_ctors:
@@ -832,22 +832,22 @@ __do_global_ctors:
 #if defined(__AVR_HAVE_RAMPZ__)
 __do_global_dtors:
        ldi     r17, hi8(__dtors_end)
-       ldi     r16, hh8(__dtors_end)
        ldi     r28, lo8(__dtors_start)
        ldi     r29, hi8(__dtors_start)
-       ldi     r20, hh8(__dtors_start)
+       ldi     r16, hh8(__dtors_start)
        rjmp    .L__do_global_dtors_start
 .L__do_global_dtors_loop:
        sbiw    r28, 2
-       sbc     r20, __zero_reg__
+       sbc     r16, __zero_reg__
        mov_h   r31, r29
        mov_l   r30, r28
-       out     __RAMPZ__, r20
+       out     __RAMPZ__, r16
        XCALL   __tablejump_elpm__
 .L__do_global_dtors_start:
        cpi     r28, lo8(__dtors_end)
        cpc     r29, r17
-       cpc     r20, r16
+       ldi     r24, hh8(__dtors_end)
+       cpc     r16, r24
        brne    .L__do_global_dtors_loop
 #else
 __do_global_dtors: