]> git.lizzy.rs Git - rust.git/commitdiff
fix arm stack alignment
authorJyun-Yan You <jyyou.tw@gmail.com>
Tue, 21 May 2013 18:14:22 +0000 (02:14 +0800)
committerJyun-Yan You <jyyou@cs.nctu.edu.tw>
Wed, 22 May 2013 00:49:16 +0000 (08:49 +0800)
src/libcore/rt/context.rs
src/rt/arch/arm/context.cpp

index f60ce3429579dc86f18f477c5dc98ef4d0eec5cb..0d011ce42bab9e1a8bde2bcbd7f80bb943440e84 100644 (file)
@@ -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; }
index 2c735e410fa4aa6b7fa24733634960119001a9fc..7d90668aad53a12f78ad7dcb82d2a8ab5ed83bd4 100644 (file)
@@ -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