Browse Source

* Made a stupid mistake in r19460: restoring rbp from rbp-relative reference will obviously crash. This went unnoticed however, because PASCALMAIN does not return and wrong code is never executed. Fixed by storing rbp in non-volatile register instead of local var.

git-svn-id: trunk@19501 -
sergei 14 years ago
parent
commit
8e41ecfd54
1 changed files with 3 additions and 4 deletions
  1. 3 4
      rtl/win64/system.pp

+ 3 - 4
rtl/win64/system.pp

@@ -181,7 +181,6 @@ var
 procedure Exe_entry;[public,alias:'_FPC_EXE_Entry'];
   var
     ST : pointer;
-    save_rbp: pointer;
   begin
      IsLibrary:=false;
      { install the handlers for exe only ?
@@ -189,7 +188,6 @@ procedure Exe_entry;[public,alias:'_FPC_EXE_Entry'];
      install_exception_handlers;
      ExitCode:=0;
      asm
-        movq  %rbp,save_rbp
         movq %rsp,%rax
         movq %rax,st
      end;
@@ -198,10 +196,11 @@ procedure Exe_entry;[public,alias:'_FPC_EXE_Entry'];
         xorq %rax,%rax
         movw %ss,%ax
         movl %eax,_SS(%rip)
+        movq %rbp,%rsi
         xorq %rbp,%rbp
         call PASCALMAIN
-        movq save_rbp,%rbp
-     end;
+        movq %rsi,%rbp
+     end ['RSI','RBP'];     { <-- specifying RSI allows compiler to save/restore it properly }
      { if we pass here there was no error ! }
      system_exit;
   end;