コード例 #1
0
        public void Emit(BaseOpcodeEncoder opcode, Operand symbolOperand, int patchOffset, int referenceOffset = 0)
        {
            int pos = (int)codeStream.Position + patchOffset;

            Emit(opcode);

            if (symbolOperand.IsLabel)
            {
                linker.Link(LinkType.AbsoluteAddress, PatchType.I4, SectionKind.Text, MethodName, pos, SectionKind.ROData, symbolOperand.Name, referenceOffset);
            }
            else if (symbolOperand.IsStaticField)
            {
                var section = symbolOperand.Field.Data != null ? SectionKind.ROData : SectionKind.BSS;

                linker.Link(LinkType.AbsoluteAddress, PatchType.I4, SectionKind.Text, MethodName, pos, section, symbolOperand.Field.FullName, referenceOffset);
            }
            else if (symbolOperand.IsSymbol)
            {
                var section = symbolOperand.Method != null ? SectionKind.Text : SectionKind.ROData;

                // First try finding the symbol in the expected section
                // If no symbol found, look in all sections
                // Otherwise create the symbol in the expected section
                var symbol = (linker.FindSymbol(symbolOperand.Name, section) ?? linker.FindSymbol(symbolOperand.Name)) ?? linker.GetSymbol(symbolOperand.Name, section);

                linker.Link(LinkType.AbsoluteAddress, PatchType.I4, SectionKind.Text, MethodName, pos, symbol, referenceOffset);
            }
        }
コード例 #2
0
 /// <summary>
 /// Emits the specified opcode.
 /// </summary>
 /// <param name="opcode">The opcode.</param>
 public void Emit(BaseOpcodeEncoder opcode)
 {
     opcode.WriteTo(CodeStream);
 }