DS Core: Backport symbol loading changes from GBA core (fixes #1834)

This commit is contained in:
Vicki Pfau 2020-07-30 19:08:55 -07:00
parent 99d7c588e7
commit c62d913e23
2 changed files with 15 additions and 2 deletions

View File

@ -29,6 +29,7 @@ Misc:
- DS Core: Add symbol loading - DS Core: Add symbol loading
- DS Video: Simplify VRAM mapping - DS Video: Simplify VRAM mapping
- DS GX: Reject and log polygons that clip to more than 10 vertices - DS GX: Reject and log polygons that clip to more than 10 vertices
- DS Core: Backport symbol loading changes from GBA core (fixes mgba.io/i/1834)
0.9.0: (Future) 0.9.0: (Future)
Features: Features:

View File

@ -83,6 +83,7 @@ static bool _DSCoreInit(struct mCore* core) {
core->board = ds; core->board = ds;
core->timing = &ds->ds9.timing; core->timing = &ds->ds9.timing;
core->debugger = NULL; core->debugger = NULL;
core->symbolTable = NULL;
dscore->arm7 = arm7; dscore->arm7 = arm7;
dscore->arm9 = arm9; dscore->arm9 = arm9;
dscore->debuggerPlatform = NULL; dscore->debuggerPlatform = NULL;
@ -596,27 +597,38 @@ static void _DSCoreDetachDebugger(struct mCore* core) {
} }
static void _DSCoreLoadSymbols(struct mCore* core, struct VFile* vf) { static void _DSCoreLoadSymbols(struct mCore* core, struct VFile* vf) {
#ifdef USE_ELF
bool closeAfter = false; bool closeAfter = false;
core->symbolTable = mDebuggerSymbolTableCreate(); core->symbolTable = mDebuggerSymbolTableCreate();
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
#ifdef USE_ELF
if (!vf) { if (!vf) {
closeAfter = true; closeAfter = true;
vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.base, ".elf", O_RDONLY); vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.base, ".elf", O_RDONLY);
} }
#endif
if (!vf) {
closeAfter = true;
vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.base, ".sym", O_RDONLY);
}
#endif #endif
if (!vf) { if (!vf) {
return; return;
} }
#ifdef USE_ELF
struct ELF* elf = ELFOpen(vf); struct ELF* elf = ELFOpen(vf);
if (elf) { if (elf) {
#ifdef USE_DEBUGGERS
mCoreLoadELFSymbols(core->symbolTable, elf); mCoreLoadELFSymbols(core->symbolTable, elf);
#endif
ELFClose(elf); ELFClose(elf);
} else
#endif
{
mDebuggerLoadARMIPSSymbols(core->symbolTable, vf);
} }
if (closeAfter) { if (closeAfter) {
vf->close(vf); vf->close(vf);
} }
#endif
} }
static bool _DSCoreLookupIdentifier(struct mCore* core, const char* name, int32_t* value, int* segment) { static bool _DSCoreLookupIdentifier(struct mCore* core, const char* name, int32_t* value, int* segment) {