MachO: Improve Sections accuracy
This commit is contained in:
@@ -119,35 +119,33 @@ namespace Il2CppInspector
|
|||||||
case MachO cmd when cmd == lc_Segment:
|
case MachO cmd when cmd == lc_Segment:
|
||||||
var segment = ReadObject<MachOSegmentCommand<TWord>>();
|
var segment = ReadObject<MachOSegmentCommand<TWord>>();
|
||||||
|
|
||||||
// Code and data
|
// Sections in each segment
|
||||||
if (segment.Name == "__TEXT" || segment.Name == "__DATA") {
|
for (int s = 0; s < segment.NumSections; s++) {
|
||||||
for (int s = 0; s < segment.NumSections; s++) {
|
var section = ReadObject<MachOSection<TWord>>();
|
||||||
var section = ReadObject<MachOSection<TWord>>();
|
machoSections.Add(section);
|
||||||
machoSections.Add(section);
|
|
||||||
|
|
||||||
// Create universal section
|
// Create universal section
|
||||||
sections.Add(new Section {
|
sections.Add(new Section {
|
||||||
VirtualStart = conv.ULong(section.Address),
|
VirtualStart = conv.ULong(section.Address),
|
||||||
VirtualEnd = conv.ULong(section.Address) + conv.ULong(section.Size) - 1,
|
VirtualEnd = conv.ULong(section.Address) + conv.ULong(section.Size) - 1,
|
||||||
ImageStart = section.ImageOffset,
|
ImageStart = section.ImageOffset,
|
||||||
ImageEnd = section.ImageOffset + (uint) conv.Int(section.Size) - 1,
|
ImageEnd = section.ImageOffset + (uint) conv.Int(section.Size) - 1,
|
||||||
|
|
||||||
IsData = segment.Name == "__DATA" && section.Name != "__bss",
|
IsData = segment.Name == "__TEXT" || segment.Name == "__DATA",
|
||||||
IsExec = segment.Name == "__TEXT",
|
IsExec = segment.Name == "__TEXT",
|
||||||
IsBSS = segment.Name == "__DATA" && section.Name == "__bss",
|
IsBSS = segment.Name == "__DATA" && (section.Name == "__bss" || section.Name == "__common"),
|
||||||
|
|
||||||
Name = section.Name
|
Name = section.Name
|
||||||
});
|
});
|
||||||
|
|
||||||
// First code section
|
// First code section
|
||||||
if (section.Name == "__text") {
|
if (section.Name == "__text") {
|
||||||
GlobalOffset = (ulong) Convert.ChangeType(section.Address, typeof(ulong)) - section.ImageOffset;
|
GlobalOffset = (ulong) Convert.ChangeType(section.Address, typeof(ulong)) - section.ImageOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialization (pre-main) functions
|
// Initialization (pre-main) functions
|
||||||
if (section.Name == "__mod_init_func") {
|
if (section.Name == "__mod_init_func") {
|
||||||
funcTab = section;
|
funcTab = section;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user