From ef161ab2bb87207f52c7db9472fd5a027dbe5f12 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Wed, 20 Apr 2016 16:27:04 -0700 Subject: Enable ReadyToRun feature for arm64 --- src/zap/zapimport.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'src/zap/zapimport.cpp') diff --git a/src/zap/zapimport.cpp b/src/zap/zapimport.cpp index 4e7b151d74..98e7afee6a 100644 --- a/src/zap/zapimport.cpp +++ b/src/zap/zapimport.cpp @@ -2082,6 +2082,72 @@ DWORD ZapIndirectHelperThunk::SaveWorker(ZapWriter * pZapWriter) // bx r12 *(WORD *)p = 0x4760; p += 2; +#elif defined(_TARGET_ARM64_) + if (IsDelayLoadHelper()) + { + if (IsVSD()) + { + // x11 contains indirection cell + // Do nothing x11 contains our first param + } + else + { + // mov x11, x12 + *(DWORD*)p = 0xaa0c03eb; + p += 4; + } + + // movz x8, #index + DWORD index = GetSectionIndex(); + _ASSERTE(index <= 0x7F); + *(DWORD*)p = 0xd2800008 | (index << 5); + p += 4; + + // move Module* -> x9 + // ldr x9, [PC+0x14] + *(DWORD*)p = 0x58000289; + p += 4; + + //ldr x9, [x9] + *(DWORD*)p = 0xf9400129; + p += 4; + } + else + if (IsLazyHelper()) + { + // Move Module* -> x1 + // ldr x1, [PC+0x14] + *(DWORD*)p = 0x58000289; + p += 4; + + // ldr x1, [x1] + *(DWORD*)p = 0xf9400021; + p += 4; + } + + // branch to helper + + // mov x12, [helper] + // ldr x12, [PC+0x14] + *(DWORD*)p = 0x58000289; + p += 4; + + // ldr x12, [x12] + *(DWORD *)p = 0xf940018c; + p += 4; + + // br x12 + *(DWORD *)p = 0xd61f0180; + p += 4; + + // [Module*] + if (pImage != NULL) + pImage->WriteReloc(buffer, (int)(p - buffer), pImage->GetImportTable()->GetHelperImport(READYTORUN_HELPER_Module), 0, IMAGE_REL_BASED_PTR); + p += 8; + // [helper] + if (pImage != NULL) + pImage->WriteReloc(buffer, (int)(p - buffer), pImage->GetImportTable()->GetHelperImport(GetReadyToRunHelper()), 0, IMAGE_REL_BASED_PTR); + p += 8; #else PORTABILITY_ASSERT("ZapIndirectHelperThunk::SaveWorker"); #endif -- cgit v1.2.3