mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-01 02:05:21 +02:00
Load ELF debug info regardless of the symbol auto-save setting
bAutoSaveLoadSymbols is about writing .ppsym files back out and reading them in again. It had also come to gate reading debug info that's simply sitting next to the game, which is a different thing and shouldn't need asking for: the main ELF's own symbols were already loaded unconditionally, but the companion ELF's symbols and all line info were not. Now the ELF is always the baseline - main or companion, symbols and line info - and the setting only adds the .ppsym half on top of it. Line info also loads from the module being loaded, not just from a companion, so an ELF launched directly brings its own. A PRX has no .debug section for it to find (prxgen strips them), so that's a cheap no-op for the usual EBOOT case, which the companion path still covers. That second source needs the two shapes distinguished, so AddModule takes an explicit address delta rather than assuming a base: a companion links at zero and wants the module's base added, while an ELF loaded at the addresses it asked for already has final ones (bRelocate is just e_type != ET_EXEC). Rows that don't land inside the module after that are dropped either way, which is a better check than the old "offset smaller than the module" one. Splitting the companion's identity check out of the symbol loader lets line info reuse it, and drops an accidental requirement along the way: it used to reject any companion without a symbol table, so an ELF built with -g but stripped of its symbols would have contributed no line numbers either. Verified with --auto-save-load-symbols off: CrossCraft's companion app.elf loads 3734 symbols and 98383 line rows where it previously loaded neither. The direct-ELF path is not verified at runtime - it needs a bootable ELF that carries DWARF, and there isn't one to hand. Both candidates here (pspautotests' .elf builds and CrossCraft's own app.elf) are linked at address 0 and fail to boot on that alone, which is pre-existing loader behaviour and nothing to do with this. pspautotests 314/314, UnitTest 55/55. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
co-authored by
Claude Opus 5
parent
14b6623330
commit
a6dd949df4
@@ -1371,15 +1371,28 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
|
||||
|
||||
if (module->memoryBlockAddr != 0) {
|
||||
g_symbolMap->AddModule(moduleName, module->memoryBlockAddr, module->memoryBlockSize, module->crc);
|
||||
|
||||
// Line info out of the module we just loaded. That covers an ELF launched directly -
|
||||
// pspautotests' .elf builds, or homebrew you built yourself - where the debug sections are
|
||||
// right here in the file. A PRX has none (prxgen strips every .debug section), so it's a
|
||||
// cheap no-op for the usual EBOOT case, which the companion below handles instead.
|
||||
// A relocated module's ELF addresses are relative to where it ended up; one loaded at the
|
||||
// addresses it asked for already has final ones.
|
||||
const u32 lineDelta = reader.DidRelocate() ? reader.GetVaddr() : 0;
|
||||
g_lineInfo.AddModule(std::string_view((const char *)ptr, elfSize), module->memoryBlockAddr, module->memoryBlockSize, lineDelta);
|
||||
|
||||
// Homebrew commonly ships the unstripped ELF next to the EBOOT; prxgen strips the symbols
|
||||
// out of the PRX we actually load, so without this every function in it is just
|
||||
// z_un_<address>. See LoadCompanionElfDebugInfo.
|
||||
LoadCompanionElfDebugInfo(PSP_CoreParameter().fileToStart, module->memoryBlockAddr, module->memoryBlockSize);
|
||||
|
||||
// Only the .ppsym files follow the setting - it's about writing symbols back out, not about
|
||||
// reading debug info that's already sitting next to the game.
|
||||
if (g_Config.bAutoSaveLoadSymbols) {
|
||||
int idx = g_symbolMap->GetModuleIndexByName(moduleName);
|
||||
if (idx > 0) {
|
||||
g_symbolMap->LoadModuleSymbols(idx, SymbolMap::GetModuleSymbolsPath(moduleName, module->crc));
|
||||
}
|
||||
// Homebrew commonly ships the unstripped ELF next to the EBOOT; prxgen strips the
|
||||
// symbols out of the PRX we actually load, so without this every function in it is
|
||||
// just z_un_<address>. See LoadCompanionElfSymbols.
|
||||
LoadCompanionElfSymbols(PSP_CoreParameter().fileToStart, module->memoryBlockAddr, module->memoryBlockSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user