/// <inheritdoc />
        public override void Assemble(BinaryWriter writer)
        {
            // CONTRACT: ObjectFile

            // TODO: Emit .bss after the last progbits section.

            // Create a new context.
            Context context = this.ObjectFile.Architecture.CreateContext(this.ObjectFile);

            // Construct each section.
            context.Reset();
            context.Address = 0;		// Addresses relative to file.
            foreach (Section section in this.ObjectFile.Sections)
            {
                context.Section = section;
                string sectionName = String.Format("section.{0}.start", section.Identifier);
                var symbol = new Symbol(SymbolType.Private, sectionName);
                symbol.Define(context, context.Address);

                section.Construct(context);
            }

            // Emit each section and write it directly to the writer.
            context.Reset();
            context.Address = 0;		// Addresses relative to file.
            foreach (Section section in this.ObjectFile.Sections)
            {
                MathExt.CalculatePadding(writer.BaseStream.Position, section.Alignment);
                writer.Align(section.Alignment);
                section.Emit(writer, context);
            }

            // Test for illegal symbols.
            CheckSymbolSupport(context);

            writer.Flush();
        }