From f80bcfaf5dc3847aa17281906ce52f33fa01953c Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 16 Jul 2017 14:43:48 -0700 Subject: [PATCH] DS Core: Add symbol loading --- CHANGES | 1 + src/ds/core.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/CHANGES b/CHANGES index 49d0e7871..858ec95e4 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ Bugfixes: - DS GX: Automatically normalize winding culling calculations (fixes mgba.io/i/699) Misc: - DS GX: Clean up and unify texture mapping + - DS Core: Add symbol loading 0.7.0: (Future) Features: diff --git a/src/ds/core.c b/src/ds/core.c index 66f005d42..a959ac6e3 100644 --- a/src/ds/core.c +++ b/src/ds/core.c @@ -9,11 +9,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -536,6 +538,30 @@ static void _DSCoreDetachDebugger(struct mCore* core) { DSDetachDebugger(core->board); core->debugger = NULL; } + +static void _DSCoreLoadSymbols(struct mCore* core, struct VFile* vf) { +#ifdef USE_ELF + bool closeAfter = false; + core->symbolTable = mDebuggerSymbolTableCreate(); +#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 + if (!vf) { + closeAfter = true; + vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.base, ".elf", O_RDONLY); + } +#endif + if (!vf) { + return; + } + struct ELF* elf = ELFOpen(vf); + if (elf) { + mCoreLoadELFSymbols(core->symbolTable, elf); + ELFClose(elf); + } + if (closeAfter) { + vf->close(vf); + } +#endif +} #endif static struct mCheatDevice* _DSCoreCheatDevice(struct mCore* core) { @@ -657,6 +683,7 @@ struct mCore* DSCoreCreate(void) { core->cliDebuggerSystem = _DSCoreCliDebuggerSystem; core->attachDebugger = _DSCoreAttachDebugger; core->detachDebugger = _DSCoreDetachDebugger; + core->loadSymbols = _DSCoreLoadSymbols; #endif core->cheatDevice = _DSCoreCheatDevice; core->savedataClone = _DSCoreSavedataClone;