Exemplo n.º 1
0
        private void CreateSymbolSection()
        {
            symbolSection.Name             = ".symtab";
            symbolSection.Type             = SectionType.SymbolTable;
            symbolSection.AddressAlignment = linker.SectionAlignment;
            symbolSection.EntrySize        = SymbolEntry.GetEntrySize(linkerFormatType);
            symbolSection.Link             = stringSection;
            symbolSection.EmitMethod       = WriteSymbolSection;

            AddSection(symbolSection);

            stringSection.AddDependency(symbolSection);
            sectionHeaderStringSection.AddDependency(symbolSection);
        }
Exemplo n.º 2
0
        private void RegisterSymbolSection()
        {
            //if (!Linker.LinkerSettings.Symbols)
            //	return;

            symbolSection.Name      = ".symtab";
            symbolSection.Type      = SectionType.SymbolTable;
            symbolSection.EntrySize = SymbolEntry.GetEntrySize(LinkerFormatType);
            symbolSection.Link      = stringSection;
            symbolSection.Emitter   = () => { return(EmitSymbolSection()); };

            RegisterSection(symbolSection);

            stringSection.AddDependency(symbolSection);
            sectionHeaderStringSection.AddDependency(symbolSection);
        }
Exemplo n.º 3
0
        private void WriteSymbolSection(Section section, BinaryWriter writer)
        {
            Debug.Assert(section == symbolSection);

            // first entry is completely filled with zeros
            writer.WriteZeroBytes(SymbolEntry.GetEntrySize(linkerFormatType));

            uint count = 1;

            foreach (var symbol in linker.Symbols)
            {
                if (symbol.SectionKind == SectionKind.Unknown && symbol.LinkRequests.Count == 0)
                {
                    continue;
                }

                Debug.Assert(symbol.SectionKind != SectionKind.Unknown, "symbol.SectionKind != SectionKind.Unknown");

                if (!(symbol.IsExternalSymbol || linker.EmitAllSymbols))
                {
                    continue;
                }

                var symbolEntry = new SymbolEntry()
                {
                    Name                    = AddToStringTable(symbol.ExternalSymbolName ?? symbol.Name),
                    Value                   = symbol.VirtualAddress,
                    Size                    = symbol.Size,
                    SymbolBinding           = SymbolBinding.Global,
                    SymbolVisibility        = SymbolVisibility.Default,
                    SymbolType              = symbol.SectionKind == SectionKind.Text ? SymbolType.Function : SymbolType.Object,
                    SectionHeaderTableIndex = GetSection(symbol.SectionKind).Index
                };

                symbolEntry.Write(linkerFormatType, writer);
                symbolTableOffset.Add(symbol, count);

                count++;
            }

            section.Size = count * SymbolEntry.GetEntrySize(linkerFormatType);
        }