[x86/Linux] Revise VirtualMethodFixupStub (dotnet/coreclr#9929)
authorJonghyun Park <parjong@gmail.com>
Fri, 3 Mar 2017 23:56:06 +0000 (08:56 +0900)
committerJan Vorlicek <janvorli@microsoft.com>
Fri, 3 Mar 2017 23:56:06 +0000 (00:56 +0100)
* [x86/Linux] Revise VirtualMethodFixupStub

Commit migrated from https://github.com/dotnet/coreclr/commit/ad9153147dcc2045041c178a49a69cc441758c79

src/coreclr/src/vm/i386/asmhelpers.S

index 921e09f..060bb02 100644 (file)
@@ -821,8 +821,8 @@ NESTED_END DelayLoad_MethodCall, _TEXT
 //  to optionally patch the target of the jump so that we do not take this slow path again.
 //
 NESTED_ENTRY VirtualMethodFixupStub, _TEXT, NoHandler
-    // Pop the return address. It points right after the call instruction in the thunk.
-    pop     eax
+    // Get the return address. It points right after the call instruction in the thunk.
+    mov     eax, [esp]
     // Calculate the address of the thunk
     sub     eax, 5
 
@@ -836,9 +836,12 @@ NESTED_ENTRY VirtualMethodFixupStub, _TEXT, NoHandler
     // Set frame pointer
     PROLOG_END
 
+    sub     esp, 8
     push    eax         // address of the thunk
     push    ecx         // this ptr
+    CHECK_STACK_ALIGNMENT
     call    C_FUNC(VirtualMethodFixupWorker)
+    add     esp, 8
 
     // Restore stack pointer
     EPILOG_BEG
@@ -850,6 +853,9 @@ NESTED_ENTRY VirtualMethodFixupStub, _TEXT, NoHandler
     // Pop ebp frame
     EPILOG_END
 
+    // Pop return address
+    add   esp, 4
+
 PATCH_LABEL VirtualMethodFixupPatchLabel
     // Proceed to execute the actual method.
     jmp     eax