set THUMB_CODE bit (#21180)
authorYaroslav Yamshchikov <y.yamshchiko@samsung.com>
Tue, 4 Feb 2020 02:46:54 +0000 (05:46 +0300)
committerGitHub <noreply@github.com>
Tue, 4 Feb 2020 02:46:54 +0000 (18:46 -0800)
src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/DelayLoadHelperImport.cs
src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/RuntimeFunctionsTableNode.cs

index c49d91d..75a7bf5 100644 (file)
@@ -5,6 +5,7 @@
 using System.Collections.Generic;
 
 using Internal.Text;
+using Internal.TypeSystem;
 using Internal.ReadyToRunConstants;
 
 namespace ILCompiler.DependencyAnalysis.ReadyToRun
@@ -57,8 +58,14 @@ namespace ILCompiler.DependencyAnalysis.ReadyToRun
         {
             // This needs to be an empty target pointer since it will be filled in with Module*
             // when loaded by CoreCLR
+            int codeDelta = 0;
+            if (factory.Target.Architecture == TargetArchitecture.ARM)
+            {
+                // THUMB_CODE
+                codeDelta = 1;
+            }
             dataBuilder.EmitReloc(_delayLoadHelper,
-                factory.Target.PointerSize == 4 ? RelocType.IMAGE_REL_BASED_HIGHLOW : RelocType.IMAGE_REL_BASED_DIR64);
+                factory.Target.PointerSize == 4 ? RelocType.IMAGE_REL_BASED_HIGHLOW : RelocType.IMAGE_REL_BASED_DIR64, codeDelta);
         }
 
         public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory factory)
index 013fa3f..9901498 100644 (file)
@@ -81,7 +81,13 @@ namespace ILCompiler.DependencyAnalysis.ReadyToRun
                     FrameInfo frameInfo = method.FrameInfos[frameIndex];
 
                     // StartOffset of the runtime function
-                    runtimeFunctionsBuilder.EmitReloc(method, RelocType.IMAGE_REL_BASED_ADDR32NB, delta: frameInfo.StartOffset);
+                    int codeDelta = 0;
+                    if (Target.Architecture == TargetArchitecture.ARM)
+                    {
+                        // THUMB_CODE
+                        codeDelta = 1;
+                    }
+                    runtimeFunctionsBuilder.EmitReloc(method, RelocType.IMAGE_REL_BASED_ADDR32NB, delta: frameInfo.StartOffset + codeDelta);
                     if (!relocsOnly && Target.Architecture == TargetArchitecture.X64)
                     {
                         // On Amd64, the 2nd word contains the EndOffset of the runtime function