What would you think of this simpler patch instead? It works on you fp.c code 
at least and it should work for any level.

It's a simple proof of concept as of now because I'm not sure how the 
addresses of local variables are stored in tcc. Thus, I'm not sure that this 
doesn't break access to local variables as it is now. But if it does, it 
shouldn't be hard to fix the patch.

Best regards,

Thomas
diff --git a/arm-gen.c b/arm-gen.c
index 99f70cd..e6d6ec7 100644
--- a/arm-gen.c
+++ b/arm-gen.c
@@ -1185,7 +1185,7 @@ void gfunc_prolog(CType *func_type)
     o(0xED2D0A00|nf); /* save s0-s15 on stack if needed */
   }
   o(0xE92D5800); /* save fp, ip, lr */
-  o(0xE28DB00C); /* add fp, sp, #12 */
+  o(0xE1A0B00D); /* mov fp, sp */
   func_sub_sp_offset = ind;
   o(0xE1A00000); /* nop, leave space for stack adjustment in epilogue */
   {
@@ -1227,7 +1227,7 @@ from_stack:
         addr = (n + nf + sn) * 4;
         sn += size;
       }
-      sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | lvalue_type(type->t), addr);
+      sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | lvalue_type(type->t), addr+12);
     }
   }
   last_itod_magic=0;
@@ -1252,7 +1252,7 @@ void gfunc_epilog(void)
     }
   }
 #endif
-  o(0xE91BA800); /* restore fp, sp, pc */
+  o(0xE89BA800); /* restore fp, sp, pc */
   diff = (-loc + 3) & -4;
 #ifdef TCC_ARM_EABI
   if(!leaffunc)
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to