summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Baladurin <k.baladurin@partner.samsung.com>2018-04-16 18:11:41 (GMT)
committerGleb Balykov <g.balykov@samsung.com>2018-09-18 12:49:14 (GMT)
commitd424bb734ce61bc98d1cfab815c48c5ad1d01d5e (patch)
tree5bde5d7331409e274ef179620376910b3b337c27 /src
parente15bd6545ad4d917eeafaf91a725b12f84c20ec2 (diff)
downloadcoreclr-d424bb734ce61bc98d1cfab815c48c5ad1d01d5e.zip
coreclr-d424bb734ce61bc98d1cfab815c48c5ad1d01d5e.tar.gz
coreclr-d424bb734ce61bc98d1cfab815c48c5ad1d01d5e.tar.bz2
[x86/Linux] Fix marshalling struct with 64-bit types (#17455)
* [x86/Linux] Fix marshalling struct with 64-bit types The System V ABI for i386 defines 4-byte alignment for 64-bit types. * [Linux/x86] Fix marshalling tests in the case of System V i386 ABI
Diffstat (limited to 'src')
-rw-r--r--src/vm/fieldmarshaler.cpp20
-rw-r--r--src/vm/fieldmarshaler.h6
2 files changed, 26 insertions, 0 deletions
diff --git a/src/vm/fieldmarshaler.cpp b/src/vm/fieldmarshaler.cpp
index 1e24399..dfbbb9a 100644
--- a/src/vm/fieldmarshaler.cpp
+++ b/src/vm/fieldmarshaler.cpp
@@ -285,7 +285,27 @@ do \
if (CorTypeInfo::IsPrimitiveType(corElemType))
{
pfwalk->m_managedSize = ((UINT32)CorTypeInfo::Size(corElemType)); // Safe cast - no primitive type is larger than 4gb!
+#if defined(_TARGET_X86_) && defined(UNIX_X86_ABI)
+ switch (corElemType)
+ {
+ // The System V ABI for i386 defines different packing for these types.
+ case ELEMENT_TYPE_I8:
+ case ELEMENT_TYPE_U8:
+ case ELEMENT_TYPE_R8:
+ {
+ pfwalk->m_managedAlignmentReq = 4;
+ break;
+ }
+
+ default:
+ {
+ pfwalk->m_managedAlignmentReq = pfwalk->m_managedSize;
+ break;
+ }
+ }
+#else // _TARGET_X86_ && UNIX_X86_ABI
pfwalk->m_managedAlignmentReq = pfwalk->m_managedSize;
+#endif
}
else if (corElemType == ELEMENT_TYPE_PTR)
{
diff --git a/src/vm/fieldmarshaler.h b/src/vm/fieldmarshaler.h
index 8c1f8fe..934f058 100644
--- a/src/vm/fieldmarshaler.h
+++ b/src/vm/fieldmarshaler.h
@@ -1626,7 +1626,13 @@ public:
UNUSED_METHOD_IMPL(VOID UpdateNativeImpl(OBJECTREF* pCLRValue, LPVOID pNativeValue, OBJECTREF *ppCleanupWorkListOnStack) const)
UNUSED_METHOD_IMPL(VOID UpdateCLRImpl(const VOID *pNativeValue, OBJECTREF *ppProtectedCLRValue, OBJECTREF *ppProtectedOldCLRValue) const)
+#if defined(_TARGET_X86_) && defined(UNIX_X86_ABI)
+ // The System V ABI for i386 defines 4-byte alignment for 64-bit types.
+ SCALAR_MARSHALER_IMPL(8, 4)
+#else
SCALAR_MARSHALER_IMPL(8, 8)
+#endif // _TARGET_X86_
+
COPY_TO_IMPL_BASE_STRUCT_ONLY()
VOID ScalarUpdateNativeImpl(LPVOID pCLR, LPVOID pNative) const