about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/rt/context.rs4
-rw-r--r--src/rt/arch/arm/context.cpp6
2 files changed, 7 insertions, 3 deletions
diff --git a/src/libcore/rt/context.rs b/src/libcore/rt/context.rs
index f60ce342957..0d011ce42ba 100644
--- a/src/libcore/rt/context.rs
+++ b/src/libcore/rt/context.rs
@@ -165,7 +165,9 @@ fn new_regs() -> ~Registers { ~([0, .. 32]) }
 
 #[cfg(target_arch = "arm")]
 fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp: *mut uint) {
-    let sp = mut_offset(sp, -1);
+    let sp = align_down(sp);
+    // sp of arm eabi is 8-byte aligned
+    let sp = mut_offset(sp, -2);
 
     // The final return address. 0 indicates the bottom of the stack
     unsafe { *sp = 0; }
diff --git a/src/rt/arch/arm/context.cpp b/src/rt/arch/arm/context.cpp
index 2c735e410fa..7d90668aad5 100644
--- a/src/rt/arch/arm/context.cpp
+++ b/src/rt/arch/arm/context.cpp
@@ -26,9 +26,11 @@ void context::call(void *f, void *arg, void *stack)
 
   // set up the stack
   uint32_t *sp = ( uint32_t *)stack;
-  //sp = align_down(sp);
+  sp = align_down(sp);
   // The final return address. 0 indicates the bottom of the stack
-  *--sp = 0;
+  // sp of arm eabi is 8-byte aligned
+  sp -= 2;
+  *sp = 0;
 
   regs.data[0] = ( uint32_t )arg; // r0
   regs.data[13] = ( uint32_t )sp; //#52 sp, r13