Ejemplo n.º 1
0
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            int fieldTypePack = (_field.FieldType as MetadataType)?.GetClassLayout().PackingSize ?? 1;

            byte[] data = relocsOnly ? Array.Empty <byte>() : _field.GetFieldRvaData();
            return(new ObjectData(
                       data,
                       Array.Empty <Relocation>(),
                       Math.Max(factory.Target.PointerSize, fieldTypePack),
                       new ISymbolDefinitionNode[] { this }));
        }
Ejemplo n.º 2
0
        public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
        {
            if (relocsOnly)
            {
                return(new ObjectData(
                           data: Array.Empty <byte>(),
                           relocs: Array.Empty <Relocation>(),
                           alignment: 1,
                           definedSymbols: new ISymbolDefinitionNode[] { this }));
            }

            ObjectDataBuilder builder = new ObjectDataBuilder(factory, relocsOnly);

            builder.RequireInitialPointerAlignment();
            builder.AddSymbol(this);

            builder.EmitBytes(_field.GetFieldRvaData());

            return(builder.ToObjectData());
        }