From 37352fcfa2a6a5d724626e7526257d6836eafa58 Mon Sep 17 00:00:00 2001 From: SaeHie Park Date: Thu, 9 Feb 2017 18:36:10 +0900 Subject: [PATCH] [x86/Linux] Fix UMThunkStub stack alignment (dotnet/coreclr#9365) Fixes out going call in UMThunkStub to be 16 byte stack aligned Commit migrated from https://github.com/dotnet/coreclr/commit/eaee80011c9523ebe82cbadf1a693217e439fbfd --- src/coreclr/src/vm/i386/umthunkstub.S | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/vm/i386/umthunkstub.S b/src/coreclr/src/vm/i386/umthunkstub.S index 22a4329..5a557d4 100644 --- a/src/coreclr/src/vm/i386/umthunkstub.S +++ b/src/coreclr/src/vm/i386/umthunkstub.S @@ -28,7 +28,7 @@ NESTED_ENTRY UMThunkStub, _TEXT, UnhandledExceptionHandlerUnix #define UMThunkStub_UMENTRYTHUNK_OFFSET (UMThunkStub_SAVEDREG+4) #define UMThunkStub_THREAD_OFFSET (UMThunkStub_UMENTRYTHUNK_OFFSET+4) #define UMThunkStub_INT_ARG_OFFSET (UMThunkStub_THREAD_OFFSET+4) -#define UMThunkStub_FIXEDALLOCSIZE (UMThunkStub_LOCALVARS) +#define UMThunkStub_FIXEDALLOCSIZE (UMThunkStub_LOCALVARS+4) // extra 4 is for stack alignment // return address <-- entry ESP // saved ebp <-- EBP @@ -37,6 +37,7 @@ NESTED_ENTRY UMThunkStub, _TEXT, UnhandledExceptionHandlerUnix // saved edi // UMEntryThunk* // Thread* +// dummy 4 byte for 16 byte stack alignment // {optional stack args passed to callee} <-- new esp PROLOG_BEG @@ -122,11 +123,13 @@ LOCAL_LABEL(InvalidTransition): LOCAL_LABEL(DoTrapReturningThreadsTHROW): // extern "C" VOID STDCALL UMThunkStubRareDisableWorker(Thread *pThread, UMEntryThunk *pUMEntryThunk) + sub esp, (2*4) // add padding to ensure 16 byte stack alignment mov eax, dword ptr [ebp - UMThunkStub_UMENTRYTHUNK_OFFSET] push eax mov eax, dword ptr [ebp - UMThunkStub_THREAD_OFFSET] push eax call C_FUNC(UMThunkStubRareDisableWorker) + add esp, (2*4) // restore to before stack alignment jmp LOCAL_LABEL(InCooperativeMode) -- 2.7.4