|
@@ -80,9 +80,11 @@ begin
|
|
sigcontext^.uc_mcontext^.ts.rdi:=res;
|
|
sigcontext^.uc_mcontext^.ts.rdi:=res;
|
|
sigcontext^.uc_mcontext^.ts.rsi:=sigcontext^.uc_mcontext^.ts.rip;
|
|
sigcontext^.uc_mcontext^.ts.rsi:=sigcontext^.uc_mcontext^.ts.rip;
|
|
sigcontext^.uc_mcontext^.ts.rdx:=sigcontext^.uc_mcontext^.ts.rbp;
|
|
sigcontext^.uc_mcontext^.ts.rdx:=sigcontext^.uc_mcontext^.ts.rbp;
|
|
- { the ABI expects the stack pointer to be 4 bytes off alignment }
|
|
|
|
- { due to the return address which has been pushed }
|
|
|
|
- dec(sigcontext^.uc_mcontext^.ts.rsp,sizeof(pointer));
|
|
|
|
|
|
+ { the ABI expects the stack pointer to be 8 bytes off alignment
|
|
|
|
+ due to the return address which has been pushed -- but take into account
|
|
|
|
+ that rsp may already unaligned in case of a leaf routine }
|
|
|
|
+ if (sigcontext^.uc_mcontext^.ts.rsp and 15)=0 then
|
|
|
|
+ dec(sigcontext^.uc_mcontext^.ts.rsp,sizeof(pointer));
|
|
{ return to run time error handler }
|
|
{ return to run time error handler }
|
|
sigcontext^.uc_mcontext^.ts.rip:=ptruint(@HandleErrorAddrFrame);
|
|
sigcontext^.uc_mcontext^.ts.rip:=ptruint(@HandleErrorAddrFrame);
|
|
{$else cpu64}
|
|
{$else cpu64}
|
|
@@ -90,9 +92,11 @@ begin
|
|
sigcontext^.uc_mcontext^.ts.eax:=res;
|
|
sigcontext^.uc_mcontext^.ts.eax:=res;
|
|
sigcontext^.uc_mcontext^.ts.edx:=sigcontext^.uc_mcontext^.ts.eip;
|
|
sigcontext^.uc_mcontext^.ts.edx:=sigcontext^.uc_mcontext^.ts.eip;
|
|
sigcontext^.uc_mcontext^.ts.ecx:=sigcontext^.uc_mcontext^.ts.ebp;
|
|
sigcontext^.uc_mcontext^.ts.ecx:=sigcontext^.uc_mcontext^.ts.ebp;
|
|
- { the ABI expects the stack pointer to be 8 bytes off alignment }
|
|
|
|
- { due to the return address which has been pushed }
|
|
|
|
- dec(sigcontext^.uc_mcontext^.ts.esp,sizeof(pointer));
|
|
|
|
|
|
+ { the ABI expects the stack pointer to be 4 bytes off alignment }
|
|
|
|
+ { due to the return address which has been pushed -- but take into account
|
|
|
|
+ that esp may already unaligned in case of a leaf routine }
|
|
|
|
+ if (sigcontext^.uc_mcontext^.ts.rsp and 15)=0 then
|
|
|
|
+ dec(sigcontext^.uc_mcontext^.ts.esp,sizeof(pointer));
|
|
{ return to run time error handler }
|
|
{ return to run time error handler }
|
|
sigcontext^.uc_mcontext^.ts.eip:=ptruint(@HandleErrorAddrFrame);
|
|
sigcontext^.uc_mcontext^.ts.eip:=ptruint(@HandleErrorAddrFrame);
|
|
{$endif cpu64}
|
|
{$endif cpu64}
|