private void WriteMapCsv(StreamWriter writer)
        {
            writer.WriteLine("Rva,Length,Relocs,Section,Symbol,Node Type");

            int nodeIndex   = 0;
            int symbolIndex = 0;

            while (nodeIndex < _outputInfoBuilder.Nodes.Count || symbolIndex < _outputInfoBuilder.Symbols.Count)
            {
                if (nodeIndex >= _outputInfoBuilder.Nodes.Count ||
                    symbolIndex < _outputInfoBuilder.Symbols.Count &&
                    OutputItem.Comparer.Instance.Compare(_outputInfoBuilder.Symbols[symbolIndex], _outputInfoBuilder.Nodes[nodeIndex]) < 0)
                {
                    // No more nodes or next symbol is below next node - emit symbol
                    OutputSymbol symbol  = _outputInfoBuilder.Symbols[symbolIndex++];
                    Section      section = _outputInfoBuilder.Sections[symbol.SectionIndex];
                    writer.Write($"0x{symbol.Offset + section.RVAWhenPlaced:X8},");
                    writer.Write(",");
                    writer.Write(",");
                    writer.Write($"{section.Name},");
                    writer.Write(",");
                    writer.WriteLine(symbol.Name);
                }
                else
                {
                    // Emit node and optionally symbol
                    OutputNode node    = _outputInfoBuilder.Nodes[nodeIndex++];
                    Section    section = _outputInfoBuilder.Sections[node.SectionIndex];

                    writer.Write($"0x{node.Offset + section.RVAWhenPlaced:X8},");
                    writer.Write($"{node.Length},");
                    writer.Write($"{node.Relocations},");
                    writer.Write($"{section.Name},");
                    if (symbolIndex < _outputInfoBuilder.Symbols.Count && OutputItem.Comparer.Instance.Compare(node, _outputInfoBuilder.Symbols[symbolIndex]) == 0)
                    {
                        OutputSymbol symbol = _outputInfoBuilder.Symbols[symbolIndex++];
                        writer.Write($"{symbol.Name}");
                    }
                    writer.Write(",");
                    writer.WriteLine($"{node.Name}");
                }
            }
        }
        private void WriteMap(StreamWriter writer)
        {
            WriteTitle(writer, "Node & Symbol Map");
            WriteTitle(writer, "RVA        | LENGTH   | RELOCS | SECTION | SYMBOL (NODE)");

            int nodeIndex   = 0;
            int symbolIndex = 0;

            while (nodeIndex < _outputInfoBuilder.Nodes.Count || symbolIndex < _outputInfoBuilder.Symbols.Count)
            {
                if (nodeIndex >= _outputInfoBuilder.Nodes.Count ||
                    symbolIndex < _outputInfoBuilder.Symbols.Count &&
                    OutputItem.Comparer.Instance.Compare(_outputInfoBuilder.Symbols[symbolIndex], _outputInfoBuilder.Nodes[nodeIndex]) < 0)
                {
                    // No more nodes or next symbol is below next node - emit symbol
                    OutputSymbol symbol  = _outputInfoBuilder.Symbols[symbolIndex++];
                    Section      section = _outputInfoBuilder.Sections[symbol.SectionIndex];
                    writer.Write($"0x{symbol.Offset + section.RVAWhenPlaced:X8} | ");
                    writer.Write("         | ");
                    writer.Write("       | ");
                    writer.Write($"{GetNameHead(section),-SectionNameHeadLength} | ");
                    writer.WriteLine(symbol.Name);
                }
                else
                {
                    // Emit node and optionally symbol
                    OutputNode node    = _outputInfoBuilder.Nodes[nodeIndex++];
                    Section    section = _outputInfoBuilder.Sections[node.SectionIndex];

                    writer.Write($"0x{node.Offset + section.RVAWhenPlaced:X8} | ");
                    writer.Write($"0x{node.Length:X6} | ");
                    writer.Write($"{node.Relocations,6} | ");
                    writer.Write($"{GetNameHead(section),-SectionNameHeadLength} | ");
                    if (symbolIndex < _outputInfoBuilder.Symbols.Count && OutputItem.Comparer.Instance.Compare(node, _outputInfoBuilder.Symbols[symbolIndex]) == 0)
                    {
                        OutputSymbol symbol = _outputInfoBuilder.Symbols[symbolIndex++];
                        writer.Write($"{symbol.Name}");
                    }
                    writer.WriteLine($"  ({node.Name})");
                }
            }
        }
Beispiel #3
0
 public void AddSymbol(OutputSymbol symbol)
 {
     _symbols.Add(symbol);
 }