diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2016-02-01 17:15:37 +0100 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2016-02-01 22:00:29 +0100 |
commit | 63160ef45ea92a3105e8854c69318985b63d34d5 (patch) | |
tree | 545e3f8f8e5f8c949c888a41bb954035dab3bab2 /src/vm/peimagelayout.cpp | |
parent | e3d17312531d35e52cef1158932be6717029b161 (diff) | |
download | coreclr-63160ef45ea92a3105e8854c69318985b63d34d5.tar.gz coreclr-63160ef45ea92a3105e8854c69318985b63d34d5.tar.bz2 coreclr-63160ef45ea92a3105e8854c69318985b63d34d5.zip |
Fix ReadyToRun on Unix
While making the ready to run tests run on Unix, I have discovered that the feature
doesn't really work on Unix. First, I have found that the test was generating the
native images into the NI subfolder, but the corerun on Unix doesn't use this
notation and expects these images to live side by side with the IL executables.
So, the test to verify that an image cannot be loaded multiple times was failing,
since the main exe loaded the IL test.dll instead of the native one and so explicit
load of the native test.dll wasn't considered a secondary load of the same image.
After fixing the test, I have found that attempt to load a ready to run image is
failing with an assert.
There were these issues:
- the loaded native image was not marked as relocated
- the EPILOG_WITH_TRANSITION_BLOCK_RETURN macro was missing popping argument registers
- One of the asserts and one getter didn't take into account the fact that the ready to
run native image is not considered to have native header.
- The assembler helpers DelayLoad_Helper and DelayLoad_MethodCall were passing a hex
number as a parameter to the PROLOG_WITH_TRANSITION_BLOCK, but it was using the "h"
suffix notation. There is a known issue in the clang assembler which causes such
suffix to be swallowed so the macro was getting just "10" instead of "10h". The fix
was to use 0x prefix instead.
This change fixes the problem. The ready to run tests pass with it correctly.
Diffstat (limited to 'src/vm/peimagelayout.cpp')
-rw-r--r-- | src/vm/peimagelayout.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/vm/peimagelayout.cpp b/src/vm/peimagelayout.cpp index 3b9bf5ec4d..3868386860 100644 --- a/src/vm/peimagelayout.cpp +++ b/src/vm/peimagelayout.cpp @@ -99,6 +99,8 @@ void PEImageLayout::ApplyBaseRelocations() { STANDARD_VM_CONTRACT; + SetRelocated(); + // // Note that this is not a univeral routine for applying relocations. It handles only the subset // required by NGen images. Also, it assumes that the image format is valid. @@ -540,23 +542,11 @@ MappedImageLayout::MappedImageLayout(HANDLE hFile, PEImage* pOwner) TESTHOOKCALL(ImageMapped(GetPath(),m_FileView,IM_IMAGEMAP)); IfFailThrow(Init((void *) m_FileView)); - // This should never happen in correctly setup system, but do a quick check right anyway to - // avoid running too far with bogus data -#ifdef MDIL - // In MDIL we need to be permissive of MSIL assemblies pretending to be native images, - // to support forced fall back to JIT - if ((HasNativeHeader() && !IsNativeMachineFormat()) || !HasCorHeader()) - ThrowHR(COR_E_BADIMAGEFORMAT); - - if (HasNativeHeader()) - ApplyBaseRelocations(); -#else - if (!IsNativeMachineFormat() || !HasCorHeader() || !HasNativeHeader()) + if (!IsNativeMachineFormat() || !HasCorHeader() || (!HasNativeHeader() && !HasReadyToRunHeader())) ThrowHR(COR_E_BADIMAGEFORMAT); //Do base relocation for PE, if necessary. ApplyBaseRelocations(); -#endif // MDIL } #else //FEATURE_PREJIT //Do nothing. The file cannot be mapped unless it is an ngen image. |