From 39a8b6ac9054e52b0f2aafb5294cacf27c7f59ca Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 29 Dec 2017 19:08:36 -0800 Subject: [PATCH] Fix RhGetCodeTarget for Unix x64 (#5168) --- src/Native/Runtime/MiscHelpers.cpp | 11 +++++++++-- tests/src/Simple/Reflection/Reflection.cs | 5 +---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Native/Runtime/MiscHelpers.cpp b/src/Native/Runtime/MiscHelpers.cpp index dae325e0a..05811e91d 100644 --- a/src/Native/Runtime/MiscHelpers.cpp +++ b/src/Native/Runtime/MiscHelpers.cpp @@ -448,8 +448,15 @@ COOP_PINVOKE_HELPER(UInt8 *, RhGetCodeTarget, (UInt8 * pCodeOrg)) #ifdef _TARGET_AMD64_ UInt8 * pCode = pCodeOrg; - // is this "add rcx,8"? - if (pCode[0] == 0x48 && pCode[1] == 0x83 && pCode[2] == 0xc1 && pCode[3] == 0x08) + // is this "add rcx/rdi,8"? + if (pCode[0] == 0x48 && + pCode[1] == 0x83 && +#ifdef UNIX_AMD64_ABI + pCode[2] == 0xc7 && +#else + pCode[2] == 0xc1 && +#endif + pCode[3] == 0x08) { // unboxing sequence unboxingStub = true; diff --git a/tests/src/Simple/Reflection/Reflection.cs b/tests/src/Simple/Reflection/Reflection.cs index f24a855a8..7f05486d6 100644 --- a/tests/src/Simple/Reflection/Reflection.cs +++ b/tests/src/Simple/Reflection/Reflection.cs @@ -358,14 +358,11 @@ internal class ReflectionTest Type byRefLikeType = GetTestType(nameof(TestByRefLikeTypeMethod), nameof(ByRefLike)); MethodInfo toStringMethod = byRefLikeType.GetMethod("ToString"); - /*var toString = (ToStringDelegate)*/toStringMethod.CreateDelegate(typeof(ToStringDelegate)); + var toString = (ToStringDelegate)toStringMethod.CreateDelegate(typeof(ToStringDelegate)); - // Doesn't work on Unix: https://github.com/dotnet/corert/issues/4379 -#if false ByRefLike foo = new ByRefLike(123); if (toString(ref foo) != "123") throw new Exception(); -#endif } }