public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* [patch libffi]: Fix _ffi_call_win64 stack allocation
@ 2009-09-28 18:41 Kai Tietz
  2009-09-28 21:16 ` Anthony Green
  0 siblings, 1 reply; 3+ messages in thread
From: Kai Tietz @ 2009-09-28 18:41 UTC (permalink / raw)
  To: GCC Patches, libffi-discuss; +Cc: Andrew Haley

[-- Attachment #1: Type: text/plain, Size: 867 bytes --]

Hello,

this patch fixes a stack allocation bug in _ffi_call_win64. The issue
is that the stack was one time allocated by ___chkstk and then again
stack was probed and allocated by a random value of %rax. Gcc's
___chkstk isn't the same as VC's. VC's version just probes the given
size in %rax on stack, but doesn't allocate it, but gcc's version
probes and allocates. Also VC's version doesn't clobber any register,
but gcc's version clobbers rax, r10, and r11. For more details see
gcc/config/i386/cygwin.asm file.

ChangeLog

2009-09-28  Kai Tietz  <kai.tietz@onevision.com>

	* src/x86/win64.S (_ffi_call_win64 stack): Remove for gnu
	assembly version use of ___chkstk.

Tested for x86_64-pc-mingw32 without regressions. Ok for apply?

Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

[-- Attachment #2: libffi_w64.diff --]
[-- Type: application/octet-stream, Size: 547 bytes --]

Index: gcc/libffi/src/x86/win64.S
===================================================================
--- gcc.orig/libffi/src/x86/win64.S	2009-06-14 15:38:04.000000000 +0200
+++ gcc/libffi/src/x86/win64.S	2009-09-28 20:29:39.380689400 +0200
@@ -235,7 +235,6 @@
 #else        
 .text
 
-.extern ___chkstk
 .extern _ffi_closure_win64_inner
 
 # ffi_closure_win64 will be called with these registers set:
@@ -315,7 +314,6 @@
 	mov	CIF_BYTES(%rbp),%eax
 	add	$15, %rax
 	and	$-16, %rax
-	callq	___chkstk
 	cmpq	$0x1000, %rax
 	jb	Lch_done
 Lch_probe:

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch libffi]: Fix _ffi_call_win64 stack allocation
  2009-09-28 18:41 [patch libffi]: Fix _ffi_call_win64 stack allocation Kai Tietz
@ 2009-09-28 21:16 ` Anthony Green
  2009-09-28 22:28   ` Kai Tietz
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony Green @ 2009-09-28 21:16 UTC (permalink / raw)
  To: Kai Tietz; +Cc: GCC Patches, libffi-discuss, Andrew Haley

Kai Tietz wrote:
> Hello,
>
> this patch fixes a stack allocation bug in _ffi_call_win64. The issue
> is that the stack was one time allocated by ___chkstk and then again
> stack was probed and allocated by a random value of %rax. Gcc's
> ___chkstk isn't the same as VC's. VC's version just probes the given
> size in %rax on stack, but doesn't allocate it, but gcc's version
> probes and allocates. Also VC's version doesn't clobber any register,
> but gcc's version clobbers rax, r10, and r11. For more details see
> gcc/config/i386/cygwin.asm file.
>
> ChangeLog
>
> 2009-09-28  Kai Tietz  <kai.tietz@onevision.com>
>
> 	* src/x86/win64.S (_ffi_call_win64 stack): Remove for gnu
> 	assembly version use of ___chkstk.
>
> Tested for x86_64-pc-mingw32 without regressions. Ok for apply?
>   
Yes, thanks.

AG


> Kai
>
>   

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch libffi]: Fix _ffi_call_win64 stack allocation
  2009-09-28 21:16 ` Anthony Green
@ 2009-09-28 22:28   ` Kai Tietz
  0 siblings, 0 replies; 3+ messages in thread
From: Kai Tietz @ 2009-09-28 22:28 UTC (permalink / raw)
  To: Anthony Green; +Cc: GCC Patches, libffi-discuss, Andrew Haley

2009/9/28 Anthony Green <green@redhat.com>:
> Kai Tietz wrote:
>>
>> Hello,
>>
>> this patch fixes a stack allocation bug in _ffi_call_win64. The issue
>> is that the stack was one time allocated by ___chkstk and then again
>> stack was probed and allocated by a random value of %rax. Gcc's
>> ___chkstk isn't the same as VC's. VC's version just probes the given
>> size in %rax on stack, but doesn't allocate it, but gcc's version
>> probes and allocates. Also VC's version doesn't clobber any register,
>> but gcc's version clobbers rax, r10, and r11. For more details see
>> gcc/config/i386/cygwin.asm file.
>>
>> ChangeLog
>>
>> 2009-09-28  Kai Tietz  <kai.tietz@onevision.com>
>>
>>        * src/x86/win64.S (_ffi_call_win64 stack): Remove for gnu
>>        assembly version use of ___chkstk.
>>
>> Tested for x86_64-pc-mingw32 without regressions. Ok for apply?
>>
>
> Yes, thanks.
>
> AG
>
>
>> Kai
>>
>>
>
>

Applied to gcc's trunk at revision 152256. For libffi trunk I have no
write-privileges.

Thanks,
Kai


-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-09-28 22:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-28 18:41 [patch libffi]: Fix _ffi_call_win64 stack allocation Kai Tietz
2009-09-28 21:16 ` Anthony Green
2009-09-28 22:28   ` Kai Tietz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).