public override Dictionary <int, ElfSymbol> LoadSymbolsSection(ElfSection symSection) { ElfImageLoader.trace.Inform("== Symbols from {0} ==", symSection.Name); var stringtableSection = symSection.LinkedSection; var rdr = CreateReader(symSection.FileOffset); var symbols = new Dictionary <int, ElfSymbol>(); for (ulong i = 0; i < symSection.Size / symSection.EntrySize; ++i) { if (!Elf32_Sym.TryLoad(rdr, out var sym)) { ElfImageLoader.trace.Warn("Unable to load symbol entry {0} from {1}", i, symSection.Name); continue; } var symName = RemoveModuleSuffix(ReadAsciiString(stringtableSection.FileOffset + sym.st_name)); ElfImageLoader.trace.Verbose(" {0,3} {1,-25} {2,-12} {3,6} {4,-15} {5:X8} {6,9}", i, string.IsNullOrWhiteSpace(symName) ? "<empty>" : symName, (ElfSymbolType)(sym.st_info & 0xF), sym.st_shndx, GetSectionName(sym.st_shndx), sym.st_value, sym.st_size); symbols.Add((int)i, new ElfSymbol { Name = RemoveModuleSuffix(ReadAsciiString(stringtableSection.FileOffset + sym.st_name)), Type = (ElfSymbolType)(sym.st_info & 0xF), SectionIndex = sym.st_shndx, Value = sym.st_value, Size = sym.st_size, }); } return(symbols); }
public override ElfSymbol LoadSymbol(ulong offsetSymtab, ulong symbolIndex, ulong entrySize, ulong offsetStringTable) { var rdr = CreateReader(offsetSymtab + entrySize * symbolIndex); if (Elf32_Sym.TryLoad(rdr, out var sym)) { return(new ElfSymbol { Name = RemoveModuleSuffix(ReadAsciiString(offsetStringTable + sym.st_name)), Type = (ElfSymbolType)(sym.st_info & 0xF), Bind = sym.st_info >> 4, SectionIndex = sym.st_shndx, Value = sym.st_value, Size = sym.st_size, }); } else { return(null); } }