Skip to content

Commit 0e07c8a

Browse files
committed
NSO: As in new-analysis branch - symtab is optional
1 parent fa053a0 commit 0e07c8a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

LibCpp2IL/NintendoSwitch/NsoFile.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,26 @@ private void ReadSymbolTable()
182182
{
183183
LibLogger.Verbose($"\tReading NSO symbol table...");
184184

185-
var hash = GetDynamicEntry(ElfDynamicType.DT_HASH) ?? throw new("No hash table found in NSO");
185+
var hash = GetDynamicEntry(ElfDynamicType.DT_HASH);
186+
187+
if (hash == null)
188+
{
189+
LibLogger.WarnNewline("\tNo DT_HASH found in NSO, symbols will not be resolved");
190+
return;
191+
}
192+
186193
Position = MapVirtualAddressToRaw(hash.Value);
187194
ReadUInt32(); //Ignored
188195
var symbolCount = ReadUInt32();
189196

190-
var symTab = GetDynamicEntry(ElfDynamicType.DT_SYMTAB) ?? throw new("No symbol table found in NSO");
197+
var symTab = GetDynamicEntry(ElfDynamicType.DT_SYMTAB);
198+
199+
if (symTab == null)
200+
{
201+
LibLogger.WarnNewline("\tNo DT_SYMTAB found in NSO, symbols will not be resolved");
202+
return;
203+
}
204+
191205
_symbolTable = ReadReadableArrayAtVirtualAddress<ElfDynamicSymbol64>((ulong) MapVirtualAddressToRaw(symTab.Value), symbolCount);
192206

193207
LibLogger.VerboseNewline($"Got {_symbolTable.Length} symbols");
@@ -375,4 +389,4 @@ public override ulong GetVirtualAddressOfPrimaryExecutableSection()
375389
return _header.TextSegment.MemoryOffset;
376390
}
377391
}
378-
}
392+
}

0 commit comments

Comments
 (0)