diff mbox

[avr,4.9,committed] : ad PR63223

Message ID 54479006.6030909@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay Oct. 22, 2014, 11:07 a.m. UTC
This addendum to PR63223 reverses the order in which __do_global_dtors 
traverses .dtors:  The order is from first to last so that it matches trunk 
implementation and is inverse direction as __do_global_ctors (which is from 
last .ctors entry to first).

Applied as http://gcc.gnu.org/r216551

Johann

	PR target/63223
	* config/avr/lib1funcs.S (__do_global_dtors): Reverse execution
	order to first...last.
diff mbox

Patch

Index: config/avr/lib1funcs.S
===================================================================
--- config/avr/lib1funcs.S	(revision 216548)
+++ config/avr/lib1funcs.S	(working copy)
@@ -2390,27 +2390,29 @@  ENDF __do_global_ctors
 #ifdef L_dtors
 	.section .fini6,"ax",@progbits
 DEFUN __do_global_dtors
-    ldi     r17, pm_hi8(__dtors_start)
-    ldi     r28, pm_lo8(__dtors_end)
-    ldi     r29, pm_hi8(__dtors_end)
+    ldi     r17, pm_hi8(__dtors_end)
+    ldi     r28, pm_lo8(__dtors_start)
+    ldi     r29, pm_hi8(__dtors_start)
 #ifdef __AVR_HAVE_EIJMP_EICALL__
-    ldi     r16, pm_hh8(__dtors_end)
+    ldi     r16, pm_hh8(__dtors_start)
 #endif /* HAVE_EIJMP */
     rjmp    .L__do_global_dtors_start
 .L__do_global_dtors_loop:
-    sbiw    r28, 1
 #ifdef __AVR_HAVE_EIJMP_EICALL__
-    sbc     r16, __zero_reg__
     mov     r24, r16
 #endif /* HAVE_EIJMP */
     mov_h   r31, r29
     mov_l   r30, r28
     XCALL   __tablejump2__
+    adiw    r28, 1
+#ifdef __AVR_HAVE_EIJMP_EICALL__
+    adc     r16, __zero_reg__
+#endif /* HAVE_EIJMP */
 .L__do_global_dtors_start:
-    cpi     r28, pm_lo8(__dtors_start)
+    cpi     r28, pm_lo8(__dtors_end)
     cpc     r29, r17
 #ifdef __AVR_HAVE_EIJMP_EICALL__
-    ldi     r24, pm_hh8(__dtors_start)
+    ldi     r24, pm_hh8(__dtors_end)
     cpc     r16, r24
 #endif /* HAVE_EIJMP */
     brne    .L__do_global_dtors_loop