diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/ARMEmitter.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/ARMEmitter.cs index adc1ef8d3cb9a3..33fd589ebef706 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/ARMEmitter.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_ARM/ARMEmitter.cs @@ -193,9 +193,15 @@ public void EmitMOV(Register destination, ISymbolNode symbol) // b.w symbol public void EmitJMP(ISymbolNode symbol) + { + EmitJMP(symbol, 0); + } + + // b.w symbol with addend + public void EmitJMP(ISymbolNode symbol, int addend) { Debug.Assert(!symbol.RepresentsIndirectionCell); - Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_THUMB_BRANCH24); + Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_THUMB_BRANCH24, addend); Builder.EmitByte(0); Builder.EmitByte(0xF0); Builder.EmitByte(0); diff --git a/src/coreclr/tools/Common/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/Common/Compiler/ObjectWriter/ObjectWriter.cs index 6cf90bb47ccb97..a9ef9d7cd02b12 100644 --- a/src/coreclr/tools/Common/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/Common/Compiler/ObjectWriter/ObjectWriter.cs @@ -152,20 +152,6 @@ or IMAGE_REL_BASED_THUMB_BRANCH24 or IMAGE_REL_BASED_THUMB_MOV32_PCREL && // Resolve the relocation to already defined symbol and write it into data fixed (byte *pData = data) { - // RyuJIT generates the Thumb bit in the addend and we also get it from - // the symbol value. The AAELF ABI specification defines the R_ARM_THM_JUMP24 - // and R_ARM_THM_MOVW_PREL_NC relocations using the formula ((S + A) | T) – P. - // The thumb bit is thus supposed to be only added once. - // For R_ARM_THM_JUMP24 the thumb bit cannot be encoded, so mask it out. - // - // R2R doesn't use add the thumb bit to the symbol value, so we don't need to do this here. -#if !READYTORUN - long maskThumbBitOut = relocType is IMAGE_REL_BASED_THUMB_BRANCH24 or IMAGE_REL_BASED_THUMB_MOV32_PCREL ? 1 : 0; - long maskThumbBitIn = relocType is IMAGE_REL_BASED_THUMB_MOV32_PCREL ? 1 : 0; -#else - long maskThumbBitOut = 0; - long maskThumbBitIn = 0; -#endif long adjustedAddend = addend; adjustedAddend -= relocType switch @@ -176,9 +162,8 @@ or IMAGE_REL_BASED_THUMB_BRANCH24 or IMAGE_REL_BASED_THUMB_MOV32_PCREL && _ => 0 }; - adjustedAddend += definedSymbol.Value & ~maskThumbBitOut; + adjustedAddend += definedSymbol.Value; adjustedAddend += Relocation.ReadValue(relocType, (void*)pData); - adjustedAddend |= definedSymbol.Value & maskThumbBitIn; adjustedAddend -= offset; if (relocType is IMAGE_REL_BASED_THUMB_BRANCH24 && !Relocation.FitsInThumb2BlRel24((int)adjustedAddend)) @@ -387,18 +372,15 @@ public void EmitObject(Stream outputFileStream, IReadOnlyCollection