Add Mach-O relocation processing stub

This commit is contained in:
Katy Coe
2019-10-22 23:41:18 +02:00
parent 8299414fba
commit dda58af124
2 changed files with 27 additions and 2 deletions

View File

@@ -75,7 +75,7 @@ namespace Il2CppInspector
public uint ImageOffset; public uint ImageOffset;
public uint Align; public uint Align;
public uint ImageRelocOffset; public uint ImageRelocOffset;
public uint NumRelocEntries; public int NumRelocEntries;
public uint Flags; public uint Flags;
public uint Reserved1; public uint Reserved1;
public TWord Reserved2; public TWord Reserved2;
@@ -104,4 +104,16 @@ namespace Il2CppInspector
public ushort n_desc; public ushort n_desc;
public TWord n_value; public TWord n_value;
} }
internal class MachO_relocation_info
{
public int r_address;
public uint r_data;
public uint r_symbolnum => r_data & 0x00ffffff;
public bool r_pcrel => ((r_data >> 24) & 1) == 1;
public uint r_length => (r_data >> 25) & 3;
public bool r_extern => ((r_data >> 27) & 1) == 1;
public uint r_type => r_data >> 28;
}
} }

View File

@@ -129,7 +129,20 @@ namespace Il2CppInspector
} }
// Must find LC_FUNCTION_STARTS load command // Must find LC_FUNCTION_STARTS load command
return (funcTab != null); if (funcTab == null)
return false;
// Process relocations
foreach (var section in sections) {
var rels = ReadArray<MachO_relocation_info>(section.ImageRelocOffset, section.NumRelocEntries);
// TODO: Implement
if (rels.Any()) {
Console.WriteLine("Mach-O file contains relocations (feature not yet implemented)");
break;
}
}
return true;
} }
public override uint[] GetFunctionTable() { public override uint[] GetFunctionTable() {