[LLVMbugs] [Bug 10707] New: Caller forgets to adjust stack in varargs stdcall calls

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 19 08:14:05 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10707

           Summary: Caller forgets to adjust stack in varargs stdcall
                    calls
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=7098)
 --> (http://llvm.org/bugs/attachment.cgi?id=7098)
testcase .ll

With the stdcall calling convention, the caller has to adjust the stack after a
call (by the amount of parameters passed).  This works fine except when the
call
is to a varargs function.  In that case the stack adjustment doesn't happen!
This causes some wine test cases to crash horribly.

For example (compiling the attached testcase like this: llc crypt_sha.ll),

        calll   C0             <= Normal call taking no arguments
        movl    32(%esp), %esi <= No stack adjust - OK because no arguments
...
        calll   C1         <= Normal call with one argument
        subl    $4, %esp   <= Stack adjust - yay!
...
        calll   C2         <= Normal call with two arguments
        subl    $8, %esp   <= Stack adjust - yay!
...
        calll   C3         <= Normal call with three arguments
        subl    $12, %esp  <= Stack adjust - yay!
...
        calll   varg         <= Varargs call with no arguments
        movl    %esi, (%esp) <= No stack adjust - OK because no arguments
...
        calll   varg          <= Varargs call with one argument
        movl    %edi, 4(%esp) <= No stack adjust - kaboom!
...
        calll   varg          <= Varargs call with two arguments
        movl    %ebx, 8(%esp) <= No stack adjust - kaboom!
...
        calll   varg          <= Varargs call with three arguments
        calll   C0            <= No stack adjust - kaboom!

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list