From 04c396d6c521c47fb166d4b891b5e2d7e1ffad90 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Wed, 30 Mar 2016 11:16:53 -0700 Subject: [PATCH] Fix issue 2963 Commit migrated from https://github.com/dotnet/coreclr/commit/92598312071231d0fdc955e68a6fd6d1b1d38936 --- src/coreclr/src/zap/zapcode.cpp | 12 ++++++++++++ src/coreclr/src/zap/zapinfo.cpp | 2 ++ src/coreclr/src/zap/zaprelocs.cpp | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/coreclr/src/zap/zapcode.cpp b/src/coreclr/src/zap/zapcode.cpp index ca1c023..c0cd3c9 100644 --- a/src/coreclr/src/zap/zapcode.cpp +++ b/src/coreclr/src/zap/zapcode.cpp @@ -1939,6 +1939,18 @@ DWORD ZapLazyHelperThunk::SaveWorker(ZapWriter * pZapWriter) if (pImage != NULL) pImage->WriteReloc(buffer, (int)(p - buffer), m_pTarget, 0, IMAGE_REL_BASED_THUMB_BRANCH24); p += 4; +#elif defined(_TARGET_ARM64_) + // ldr x1, [PC+8] + *(DWORD *)(p) =0x58000041; + p += 4; + // b JIT_StrCns + *(DWORD *)(p) = 0x14000000; + if (pImage != NULL) + pImage->WriteReloc(buffer, (int)(p - buffer), m_pTarget, 0, IMAGE_REL_ARM64_BRANCH26); + p += 4; + if (pImage != NULL) + pImage->WriteReloc(buffer, (int)(p - buffer), m_pArg, 0, IMAGE_REL_BASED_PTR); + p += 8; #else PORTABILITY_ASSERT("ZapLazyHelperThunk::Save"); #endif diff --git a/src/coreclr/src/zap/zapinfo.cpp b/src/coreclr/src/zap/zapinfo.cpp index cf8e9b7..eba2932 100644 --- a/src/coreclr/src/zap/zapinfo.cpp +++ b/src/coreclr/src/zap/zapinfo.cpp @@ -2607,6 +2607,8 @@ WORD ZapInfo::getRelocTypeHint(void * target) if (m_zapper->m_pOpt->m_fNGenLastRetry) return (WORD)-1; return IMAGE_REL_BASED_THUMB_BRANCH24; +#elif defined(_TARGET_ARM64_) + return IMAGE_REL_ARM64_BRANCH26; #else // No hints return (WORD)-1; diff --git a/src/coreclr/src/zap/zaprelocs.cpp b/src/coreclr/src/zap/zaprelocs.cpp index 14f913a..2e48106 100644 --- a/src/coreclr/src/zap/zaprelocs.cpp +++ b/src/coreclr/src/zap/zaprelocs.cpp @@ -107,6 +107,20 @@ void ZapBaseRelocs::WriteReloc(PVOID pSrc, int offset, ZapNode * pTarget, int ta // IMAGE_REL_BASED_THUMB_BRANCH24 does not need base reloc entry return; #endif +#if defined(_TARGET_ARM64_) + case IMAGE_REL_ARM64_BRANCH26: + { + TADDR pSite = (TADDR)m_pImage->GetBaseAddress() + rva; + + INT64 relOffset = (INT64)(pActualTarget - (pSite + sizeof(INT64))); + if (!FitsInRel28(relOffset)) + { + ThrowHR(COR_E_OVERFLOW); + } + PutArm64Rel28((UINT32 *)pLocation,(INT32)relOffset); + } + return; +#endif default: _ASSERTE(!"Unknown relocation type"); -- 2.7.4