diff --git a/src/vm/dllimport.cpp b/src/vm/dllimport.cpp index eed690454d30..84e9003f0123 100644 --- a/src/vm/dllimport.cpp +++ b/src/vm/dllimport.cpp @@ -3836,10 +3836,10 @@ static void CreateNDirectStubWorker(StubState* pss, // For functions with value type class, managed and unmanaged calling convention differ fMarshalReturnValueFirst = HasRetBuffArgUnmanagedFixup(&msig); #elif defined(_TARGET_ARM_) - fMarshalReturnValueFirst = HasRetBuffArg(&msig); + fMarshalReturnValueFirst = (isInstanceMethod && isReturnTypeValueType) && HasRetBuffArg(&msig); #else // On Windows-X86, the native signature might need a return buffer when the managed doesn't (specifically when the native signature is a member function). - fMarshalReturnValueFirst = HasRetBuffArg(&msig) || (isInstanceMethod && isReturnTypeValueType); + fMarshalReturnValueFirst = (!SF_IsReverseStub(dwStubFlags) && HasRetBuffArg(&msig)) || (isInstanceMethod && isReturnTypeValueType); #endif // UNIX_X86_ABI #elif defined(_TARGET_AMD64_) || defined (_TARGET_ARM64_) fMarshalReturnValueFirst = isInstanceMethod && isReturnTypeValueType;