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

            int nodeIndex   = 0;
            int symbolIndex = 0;

            while (nodeIndex < _nodes.Count || symbolIndex < _symbols.Count)
            {
                if (nodeIndex >= _nodes.Count || symbolIndex < _symbols.Count && MapFileItem.Comparer.Instance.Compare(_symbols[symbolIndex], _nodes[nodeIndex]) < 0)
                {
                    // No more nodes or next symbol is below next node - emit symbol
                    MapFileSymbol symbol  = _symbols[symbolIndex++];
                    Section       section = _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
                    MapFileNode node    = _nodes[nodeIndex++];
                    Section     section = _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 < _symbols.Count && MapFileItem.Comparer.Instance.Compare(node, _symbols[symbolIndex]) == 0)
                    {
                        MapFileSymbol symbol = _symbols[symbolIndex++];
                        writer.Write($"{symbol.Name}");
                    }
                    writer.Write(",");
                    writer.WriteLine($"{node.Name}");
                }
            }
        }
Exemplo n.º 2
0
        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 < _nodes.Count || symbolIndex < _symbols.Count)
            {
                if (nodeIndex >= _nodes.Count || symbolIndex < _symbols.Count && MapFileItem.Comparer.Instance.Compare(_symbols[symbolIndex], _nodes[nodeIndex]) < 0)
                {
                    // No more nodes or next symbol is below next node - emit symbol
                    MapFileSymbol symbol  = _symbols[symbolIndex++];
                    Section       section = _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
                    MapFileNode node    = _nodes[nodeIndex++];
                    Section     section = _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 < _symbols.Count && MapFileItem.Comparer.Instance.Compare(node, _symbols[symbolIndex]) == 0)
                    {
                        MapFileSymbol symbol = _symbols[symbolIndex++];
                        writer.Write($"{symbol.Name}");
                    }
                    writer.WriteLine($"  ({node.Name})");
                }
            }
        }
Exemplo n.º 3
0
 public void AddSymbol(MapFileSymbol symbol)
 {
     _symbols.Add(symbol);
 }