protected void RelocateFromHeaders()
{
if ((BaseAddress & 0xFFFF) != 0)
{
//throw(new NotImplementedException("Can't relocate with the BaseAddress.LO16 != 0"));
}
// Relocate from program headers
int RelocProgramIndex = 0;
foreach (var ProgramHeader in ElfLoader.ProgramHeaders)
{
if (RelocOutput != null) RelocOutput.WriteLine("Program Header: %d".Sprintf(RelocProgramIndex++));
switch (ProgramHeader.Type)
{
case Elf.ProgramHeader.TypeEnum.Reloc1:
Logger.Warning("SKIPPING Elf.ProgramHeader.TypeEnum.Reloc1!");
break;
case Elf.ProgramHeader.TypeEnum.Reloc2:
throw(new NotImplementedException());
}
}
int RelocSectionIndex = 0;
foreach (var SectionHeader in ElfLoader.SectionHeaders)
{
//RelocOutput.WriteLine("Section Header: %d : %s".Sprintf(RelocSectionIndex++, SectionHeader.ToString()));
if (RelocOutput != null) RelocOutput.WriteLine("Section Header: %d".Sprintf(RelocSectionIndex++));
switch (SectionHeader.Type)
{
case Elf.SectionHeader.TypeEnum.Relocation:
Console.Error.WriteLine("Not implemented Elf.SectionHeader.TypeEnum.Relocation");
//throw (new NotImplementedException("Not implemented Elf.SectionHeader.TypeEnum.Relocation"));
//break;
/*
RelocateRelocs(
ElfLoader.SectionHeaderFileStream(SectionHeader).ReadStructVectorUntilTheEndOfStream<Elf.Reloc>()
);
*/
break;
case Elf.SectionHeader.TypeEnum.PrxRelocation:
Console.WriteLine("PrxRelocation : {0}", SectionHeader);
RelocateRelocs(
ElfLoader.SectionHeaderFileStream(SectionHeader).ReadStructVectorUntilTheEndOfStream<Elf.Reloc>()
);
break;
case Elf.SectionHeader.TypeEnum.PrxRelocation_FW5:
throw (new Exception("Not implemented ElfSectionHeader.Type.PrxRelocation_FW5"));
}
}
if (RelocOutput != null)
{
RelocOutput.Flush();
_RelocOutputStream.Flush();
RelocOutput.Close();
_RelocOutputStream.Close();
_RelocOutput = null;
_RelocOutputStream = null;
}
}