]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
Xilinx: ARM: Fix memory corruption bug in pele timer_init
authorJoe Hershberger <joe.hershberger@ni.com>
Tue, 20 Mar 2012 22:38:48 +0000 (17:38 -0500)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 21 Mar 2012 18:37:10 +0000 (13:37 -0500)
Global variables (.bss) must not be accessed before relocation.
That memory is now overlayed with the .rel.dyn ELF relocation table.
Even if that was allowed, it would have no positive effect since
initialized value would not be relocated into RAM.  It would be 0
again.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
arch/arm/cpu/armv7/pele/timer.c

index 1884448a8356c2ed750840a9dc2f4819291ed8e7..237fe4427d0eaeae15417e1722ac07a95ea28954 100644 (file)
@@ -89,8 +89,9 @@ int timer_init()
        /* Enable the decrementer */
        val |= XSCUTIMER_CONTROL_ENABLE_MASK;
        XScuTimer_WriteReg(XSCUTIMER_CONTROL_OFFSET, val);
-       
-       reset_timer_masked();
+
+       /* This must not be called before relocation */
+       /*reset_timer_masked();*/
 
        return 0;
 }
@@ -133,7 +134,7 @@ ulong get_tbclk(void)
 void reset_timer_masked(void)
 {
        /* reset time */
-       lastdec = XScuTimer_GetCounterValue() /  (TIMER_TICK_HZ/CONFIG_SYS_HZ);
+       lastdec = XScuTimer_GetCounterValue() / (TIMER_TICK_HZ/CONFIG_SYS_HZ);
        timestamp = 0;
 }