Welcome to mirror list, hosted at ThFree Co, Russian Federation.

IndirectionExtensions.cs « DependencyAnalysis « Compiler « src « ILCompiler.Compiler « src - github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9265f94f888fbb0fe63de018da85affdb79f0301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Internal.Runtime;
using Internal.TypeSystem;

using Debug = System.Diagnostics.Debug;

namespace ILCompiler.DependencyAnalysis
{
    static class IndirectionExtensions
    {
        /// <summary>
        /// Use this api to generate a reloc to a symbol that may be an indirection cell or not as a pointer
        /// </summary>
        /// <param name="symbol">symbol to reference</param>
        /// <param name="indirectionBit">value to OR in to the reloc to represent to runtime code that this pointer is an indirection. Defaults to IndirectionConstants.IndirectionCellPointer</param>
        /// <param name="delta">Delta from symbol start for value</param>
        public static void EmitPointerRelocOrIndirectionReference(ref this ObjectDataBuilder builder, ISymbolNode symbol, int delta = 0, int indirectionBit = IndirectionConstants.IndirectionCellPointer)
        {
            if (symbol.RepresentsIndirectionCell)
                delta |= indirectionBit;

            builder.EmitReloc(symbol, (builder.TargetPointerSize == 8) ? RelocType.IMAGE_REL_BASED_DIR64 : RelocType.IMAGE_REL_BASED_HIGHLOW, delta);
        }

        public static void EmitRelativeRelocOrIndirectionReference(ref this ObjectDataBuilder builder, ISymbolNode symbol, int delta = 0, int indirectionBit = IndirectionConstants.IndirectionCellPointer)
        {
            if (symbol.RepresentsIndirectionCell)
                delta = delta | indirectionBit;

            builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_RELPTR32, delta);
        }
    }
}