Fix stack alignment on 8 bytes at function call
authorThomas Preud'homme <robotux@celest.fr>
Sun, 27 Jan 2013 00:08:01 +0000 (27 01:08 +0100)
committerThomas Preud'homme <robotux@celest.fr>
Sun, 27 Jan 2013 00:08:01 +0000 (27 01:08 +0100)
Ensure stack pointer is correctly adjusted in prolog to be aligned on 8
bytes after the change of frame linking.

arm-gen.c

index e3e502b..fb157b0 100644 (file)
--- a/arm-gen.c
+++ b/arm-gen.c
@@ -1231,7 +1231,7 @@ from_stack:
   }
   last_itod_magic=0;
   leaffunc = 1;
-  loc = -12;
+  loc = 0;
 }
 
 /* generate function epilog */
@@ -1255,9 +1255,9 @@ void gfunc_epilog(void)
   diff = (-loc + 3) & -4;
 #ifdef TCC_ARM_EABI
   if(!leaffunc)
-    diff = (diff + 7) & -8;
+    diff = ((diff + 11) & -8) - 4;
 #endif
-  if(diff > 12) {
+  if(diff > 0) {
     x=stuff_const(0xE24BD000, diff); /* sub sp,fp,# */
     if(x)
       *(uint32_t *)(cur_text_section->data + func_sub_sp_offset) = x;