Core: Fix loading ELF files that have unexpected empty program headers
Vicki Pfau vi@endrift.com
Tue, 24 Nov 2020 01:37:54 -0800
2 files changed,
4 insertions(+),
0 deletions(-)
M
CHANGES
→
CHANGES
@@ -56,6 +56,7 @@ - CMake: Fix build with downstream minizip that exports incompatible symbols
- CMake: Link with correct OpenGL library (fixes mgba.io/i/1872) - Core: Ensure ELF regions can be written before trying - Core: Fix threading improperly setting paused state while interrupted + - Core: Fix loading ELF files that have unexpected empty program headers - Debugger: Don't skip undefined instructions when debugger attached - Debugger: Close trace log when done tracing - Debugger: Fix change watchpoints (fixes mgba.io/i/1947)
M
src/core/core.c
→
src/core/core.c
@@ -382,6 +382,9 @@ size_t i;
for (i = 0; i < ELFProgramHeadersSize(&ph); ++i) { size_t bsize, esize; Elf32_Phdr* phdr = ELFProgramHeadersGetPointer(&ph, i); + if (!phdr->p_filesz) { + continue; + } void* block = mCoreGetMemoryBlockMasked(core, phdr->p_paddr, &bsize, mCORE_MEMORY_WRITE | mCORE_MEMORY_WORM); char* bytes = ELFBytes(elf, &esize); if (block && bsize >= phdr->p_filesz && esize > phdr->p_offset && esize >= phdr->p_filesz + phdr->p_offset) {