LoginSignup
0
0

More than 5 years have passed since last update.

elfsharp > ReadStringTable()

Last updated at Posted at 2015-08-21

ELFの処理の上位

ELF.cs
internal ELF(string fileName)
        {
            this.fileName = fileName;
            if(ELFReader.CheckELFType(fileName) == Class.NotELF)
            {
                throw new ArgumentException("Given file is not proper ELF file.");
            }
            stream = GetNewStream();
            ReadHeader();            
            ReadStringTable();
            ReadSections();
            ReadSegmentHeaders();
        }

ここでコールされている ReadStringTable() の実装は以下の通り。

 private void ReadStringTable()
        {
            if(!HasSectionHeader || !HasSectionsStringTable)
            {                
                return;
            }
            var header = ReadSectionHeader(stringTableIndex);
            if(header.Type != SectionType.StringTable)
            {
                throw new InvalidOperationException("Given index of section header does not point at string table which was expected.");
            }
            SectionsStringTable = new StringTable<T>(header, readerSource);
        }

上記で問題となる stringTableIndex は ReadFields() で読込む。

ReadStringTable()内でReadSectionHeader()がコールされている。
ReadSectionHeader()内でReadStringTable()で読み込んだtableが使われる、という一種無限ループ状態になっているかと思ったが、

if (table != null) {
    Name = table[NameIndex];
}

という仕組みでうまく動いているようだ。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0