Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Cross-bitness in ZapRelocs #18665

Merged
merged 9 commits into from
Jun 27, 2018
Merged
6 changes: 6 additions & 0 deletions src/zap/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
#endif
#endif // !_TARGET_X86_ || FEATURE_PAL

#ifdef _TARGET_64BIT_
typedef unsigned __int64 TARGET_POINTER_TYPE;
#else
typedef unsigned int TARGET_POINTER_TYPE;
#endif

#include "utilcode.h"
#include "corjit.h"
#include "jithost.h"
Expand Down
10 changes: 5 additions & 5 deletions src/zap/zapimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,12 @@ void ZapImport::Save(ZapWriter * pZapWriter)
{
if (IsReadyToRunCompilation())
{
SIZE_T value = 0;
TARGET_POINTER_TYPE value = 0;
pZapWriter->Write(&value, sizeof(value));
return;
}

SIZE_T token = CORCOMPILE_TAG_TOKEN(GetBlob()->GetRVA());
TARGET_POINTER_TYPE token = CORCOMPILE_TAG_TOKEN(GetBlob()->GetRVA());
pZapWriter->Write(&token, sizeof(token));
}

Expand Down Expand Up @@ -639,7 +639,7 @@ class ZapStubDispatchCell : public ZapImport
{
ZapImage * pImage = ZapImage::GetImage(pZapWriter);

PVOID cell;
TARGET_POINTER_TYPE cell;
pImage->WriteReloc(&cell, 0, m_pDelayLoadHelper, 0, IMAGE_REL_BASED_PTR);
pZapWriter->Write(&cell, sizeof(cell));
}
Expand Down Expand Up @@ -745,7 +745,7 @@ class ZapExternalMethodCell : public ZapImport
{
ZapImage * pImage = ZapImage::GetImage(pZapWriter);

PVOID cell;
TARGET_POINTER_TYPE cell;
pImage->WriteReloc(&cell, 0, m_pDelayLoadHelper, 0, IMAGE_REL_BASED_PTR);
pZapWriter->Write(&cell, sizeof(cell));
}
Expand Down Expand Up @@ -1725,7 +1725,7 @@ class ZapDynamicHelperCell : public ZapImport
{
ZapImage * pImage = ZapImage::GetImage(pZapWriter);

PVOID cell;
TARGET_POINTER_TYPE cell;
pImage->WriteReloc(&cell, 0, m_pDelayLoadHelper, 0, IMAGE_REL_BASED_PTR);
pZapWriter->Write(&cell, sizeof(cell));
}
Expand Down
2 changes: 1 addition & 1 deletion src/zap/zapinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2574,7 +2574,7 @@ void ZapInfo::recordRelocation(void *location, void *target,
break;

case IMAGE_REL_BASED_PTR:
*(UNALIGNED TADDR *)location = (TADDR)targetOffset;
*(UNALIGNED TARGET_POINTER_TYPE *)location = (TARGET_POINTER_TYPE)targetOffset;
break;

#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
Expand Down
6 changes: 3 additions & 3 deletions src/zap/zaprelocs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void ZapBaseRelocs::WriteReloc(PVOID pSrc, int offset, ZapNode * pTarget, int ta
// Misaligned relocs disable ASLR on ARM. We should never ever emit them.
_ASSERTE(IS_ALIGNED(rva, TARGET_POINTER_SIZE));
#endif
*(UNALIGNED TADDR *)pLocation = pActualTarget;
*(UNALIGNED TARGET_POINTER_TYPE *)pLocation = (TARGET_POINTER_TYPE)pActualTarget;
break;

case IMAGE_REL_BASED_RELPTR:
Expand Down Expand Up @@ -92,7 +92,7 @@ void ZapBaseRelocs::WriteReloc(PVOID pSrc, int offset, ZapNode * pTarget, int ta
// description of IMAGE_REL_BASED_REL_THUMB_MOV32_PCREL
const UINT32 offsetCorrection = 12;

UINT32 imm32 = pActualTarget - (pSite + offsetCorrection);
UINT32 imm32 = UINT32(pActualTarget - (pSite + offsetCorrection));

PutThumb2Mov32((UINT16 *)pLocation, imm32);

Expand Down Expand Up @@ -122,7 +122,7 @@ void ZapBaseRelocs::WriteReloc(PVOID pSrc, int offset, ZapNode * pTarget, int ta
}
// IMAGE_REL_BASED_THUMB_BRANCH24 does not need base reloc entry
return;
#endif
#endif // defined(_TARGET_ARM_)
#if defined(_TARGET_ARM64_)
case IMAGE_REL_ARM64_BRANCH26:
{
Expand Down