vararg calls with libffi on x86_64

Andrew Haley aph@redhat.com
Fri Apr 29 18:13:00 GMT 2005


Andreas Degert writes:
 > Hello,
 > 
 > I hope this is the correct ML for libffi patches.
 > 
 > In the libffi README is a note that vararg functions are not supported
 > yet. Anyhow, they work on x86 nevertheless, and the appended patch
 > makes them work on x86_64 too.
 > 
 > Background: according to the amd64 abi documentation
 > (http://www.x86-64.org/documentation), in vararg calls rax has to be
 > set to the (maximum) number of used SSE registers. Setting rax to 8 is
 > not an efficient solution but at least it makes the calls work.
 > 
 > Is this patch acceptable? (warning: the appended patch should be taken
 > literally since it's not against the original repository, but in
 > effect it consists only of one line...)

I agree.  It's very little extra overhead for the non-varargs case,
and it'll make varargs functions work.

To Anthony for approval ...

Andrew.

 > Index: libffi/src/x86/unix64.S
 > ===================================================================
 > RCS file: /cvsroot/ctypes/ctypes/source/gcc/libffi/src/x86/unix64.S,v
 > retrieving revision 1.1
 > retrieving revision 1.2
 > diff -u -r1.1 -r1.2
 > --- libffi/src/x86/unix64.S     18 Jun 2004 20:07:15 -0000      1.1
 > +++ libffi/src/x86/unix64.S     22 Apr 2005 15:17:51 -0000      1.2
 > @@ -87,6 +87,13 @@
 >  .LCFI5:
 >         addq    $176, %rsp
 >  .LCFI6:
 > +       /* Set %rax to max. number of used SSE registers for vararg calls.
 > +          See also:
 > +           http://article.gmane.org/gmane.comp.python.ctypes/1702
 > +           http://article.gmane.org/gmane.comp.python.ctypes/1703
 > +        */
 > +       movq    $8, %rax
 > +
 >         /* Call the user function.  */
 >         call    *-48(%rbp)



More information about the Gcc-patches mailing list