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];
}
という仕組みでうまく動いているようだ。