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

Cross-bitness in ZapRelocs #18665

merged 9 commits into from
Jun 27, 2018

Conversation

echesakov
Copy link

TADDR is defined as typedef ULONG_PTR TADDR in VM and it seems to me that it's almost impossible to use target-specific typedef for TADDR. In this PR I identified small number of places in src/zap where TADDR is used for writing relocation records to PE image and replaced those with DWORD keeping the rest of CoreCLR untouched. As usually, I validated these changes on CoreLib and CoreFX assemblies (incl. test assemblies) by checking that output of x86_arm and x64_arm crossgens are identical.

@jkotas Do you think this is a right approach?

@@ -363,12 +363,12 @@ void ZapImport::Save(ZapWriter * pZapWriter)
if (IsReadyToRunCompilation())
{
SIZE_T value = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use type that is of the right target pointer size, not SIZE_T.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(multiple places)

@@ -2574,7 +2574,11 @@ void ZapInfo::recordRelocation(void *location, void *target,
break;

case IMAGE_REL_BASED_PTR:
#ifdef _TARGET_64BIT_
*(UNALIGNED TADDR *)location = (TADDR)targetOffset;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use int64 instead TADDR now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(multiple places)

@@ -362,12 +362,12 @@ void ZapImport::Save(ZapWriter * pZapWriter)
{
if (IsReadyToRunCompilation())
{
SIZE_T value = 0;
target_size_t value = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks odd to use target_size_t for all these since none of them are actually sizes.

Would TARGET_POINTER or TARGET_POINTER_TYPE be a better name?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason I had in mind when picked target_size_t is to be consistent with clrjit where we already have target_size_t typedef. I renamed this to TARGET_POINTER_TYPE in src/zap

@echesakov echesakov changed the title [WIP] Cross-bitness in ZapRelocs Cross-bitness in ZapRelocs Jun 27, 2018
@jkotas jkotas merged commit 1a24a27 into dotnet:master Jun 27, 2018
@echesakov echesakov deleted the CrossBitnessZapWriteRelocs branch June 28, 2018 03:10
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Cast to UINT32 to avoid warnings on Windows in ZapBaseRelocs::WriteReloc in src/zap/zaprelocs.cpp

* Replace TADDR with DWORD in ZapInfo::recordRelocation IMAGE_REL_BASED_PTR in src/zap/zapinfo.cpp

* Replace sizeof(cell) with TARGET_POINTER_SIZE in src/zap/zapimport.cpp

* Replace TADDR with DWORD in ZapBaseRelocs::WriteReloc IMAGE_REL_BASED_PTR in src/zap/zaprelocs.cpp

* Define target_size_t type

* Replace TADDR with target_size_t in ZapInfo::recordRelocation in src/zap/zapinfo.cpp

* Replace SIZE_T PVOID with target_size_t in src/zap/zapimport.cpp

* Replace TADDR with target_size_t in src/zap/zaprelocs.cpp

* Rename target_size_t to TARGET_POINTER_TYPE


Commit migrated from dotnet/coreclr@1a24a27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants