Exemplo n.º 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;
            }
        }
Exemplo n.º 2
0
        /// <summary>Get all relocations in the section</summary>
        /// <returns>Stream of all relocations from current section</returns>
        public IEnumerator <RelocationSectionItem> GetEnumerator()
        {
            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;
            Boolean   is64Bit = header.Is64Bit;

            for (UInt64 loop = 0; loop < itemsCount; loop++)
            {
                if (is64Bit)
                {
                    Elf.Elf64_Rel rel = header.PtrToStructure <Elf.Elf64_Rel>(offset);
                    yield return(new RelocationSectionItem(rel));
                }
                else
                {
                    Elf.Elf32_Rel rel = header.PtrToStructure <Elf.Elf32_Rel>(offset);
                    yield return(new RelocationSectionItem(rel));
                }
                offset += sizeOfStruct;
            }
        }