Mach-O: support chained import format 2/3 and handle STABS 0x2c symbols (#48)

This commit is contained in:
bfloat16
2026-02-27 01:42:26 +08:00
committed by GitHub
parent 4730a0c028
commit 7f60c05233
2 changed files with 28 additions and 5 deletions

View File

@@ -61,7 +61,16 @@ namespace Il2CppInspector
N_FNAME = 0x22,
N_FUN = 0x24,
N_STSYM = 0x26,
N_LCSYM = 0x28,
N_MAIN = 0x2A,
N_ROSYM = 0x2C,
N_BNSYM = 0x2E,
N_PC = 0x30,
N_NSYMS = 0x32,
N_NOMAP = 0x34,
N_OBJ = 0x38,
N_OPT = 0x3C,
N_RSYM = 0x40,
N_ENSYM = 0x4E,
N_SO = 0x64,
N_OSO = 0x66,
@@ -187,6 +196,13 @@ namespace Il2CppInspector
public uint SymbolsFormat;
}
public enum MachODyldChainedImportFormat : uint
{
DYLD_CHAINED_IMPORT = 1,
DYLD_CHAINED_IMPORT_ADDEND = 2,
DYLD_CHAINED_IMPORT_ADDEND64 = 3
}
[VersionedStruct]
public partial struct MachODyldChainedStartsInSegment
{

View File

@@ -284,9 +284,13 @@ namespace Il2CppInspector
|| ntype == MachO_NType.N_SO || ntype == MachO_NType.N_OSO)
continue;
var type = ntype == MachO_NType.N_FUN? SymbolType.Function
: ntype == MachO_NType.N_STSYM || ntype == MachO_NType.N_GSYM || ntype == MachO_NType.N_SECT? SymbolType.Name
: SymbolType.Unknown;
var type = ntype switch
{
MachO_NType.N_FUN or MachO_NType.N_MAIN => SymbolType.Function,
MachO_NType.N_STSYM or MachO_NType.N_GSYM or MachO_NType.N_SECT
or MachO_NType.N_LCSYM or MachO_NType.N_ROSYM => SymbolType.Name,
_ => SymbolType.Unknown
};
if (type == SymbolType.Unknown) {
AnsiConsole.WriteLine($"Unknown symbol type: {((int) ntype):x2} {value:x16} {name}");
@@ -306,10 +310,13 @@ namespace Il2CppInspector
return;
}
if (chainedFixupsHeader.ImportsFormat != 1 /* DYLD_CHAINED_IMPORT */)
var importsFormat = (MachODyldChainedImportFormat)chainedFixupsHeader.ImportsFormat;
if (importsFormat != MachODyldChainedImportFormat.DYLD_CHAINED_IMPORT
&& importsFormat != MachODyldChainedImportFormat.DYLD_CHAINED_IMPORT_ADDEND
&& importsFormat != MachODyldChainedImportFormat.DYLD_CHAINED_IMPORT_ADDEND64)
{
AnsiConsole.WriteLine($"Unsupported chained fixups import format: {chainedFixupsHeader.ImportsFormat}");
return;
// Rebase chains can still be processed even if bind import entries are in an unknown format.
}
//var importsBase = info.Offset + chainedFixupsHeader.ImportsOffset;