예제 #1
0
        /// <summary>Get all symbols in the section</summary>
        /// <returns>Stream of all symbols in the current section</returns>
        public IEnumerator <SymbolSectionItem> GetEnumerator()
        {
            //Byte[] payload = this._section.GetData();

            UInt64 offset       = base.Section.sh_offset;
            UInt64 maxOffset    = base.Section.sh_offset + base.Section.sh_size;
            UInt64 sizeOfStruct = this.SizeOfStruct;
            UInt64 itemsCount   = (maxOffset - offset) / sizeOfStruct;

            ElfHeader     header      = base.Section.File.Header;
            StringSection stringTable = this.SectionSymbolNames;
            Boolean       is64Bit     = header.Is64Bit;

            for (UInt64 loop = 0; loop < itemsCount; loop++)
            {
                SymbolSectionItem result;
                if (is64Bit)
                {
                    Elf.Elf64_Sym symbol = header.PtrToStructure <Elf.Elf64_Sym>(offset);
                    result = new SymbolSectionItem(symbol);
                }
                else
                {
                    Elf.Elf32_Sym symbol = header.PtrToStructure <Elf.Elf32_Sym>(offset);
                    result = new SymbolSectionItem(symbol);
                }

                result.Name = stringTable[result.st_name];

                yield return(result);

                offset += sizeOfStruct;
            }
        }
예제 #2
0
 internal SymbolSectionItem(Elf.Elf64_Sym item)
 {
     this.st_name  = item.st_name;
     this.st_info  = item.st_info;
     this.st_other = item.st_other;
     this.st_shndx = item.st_shndx;
     this.st_value = item.st_value;
     this.st_size  = item.st_size;
 }