Core: Fix ELF loading regression (fixes #1669)

This commit is contained in:
Vicki Pfau 2020-02-16 20:52:02 -08:00
parent f1d5e39f88
commit 5f3dc723f6
2 changed files with 5 additions and 1 deletions

View File

@ -1,3 +1,7 @@
0.8.2: (Future)
Other fixes:
- Core: Fix ELF loading regression (fixes mgba.io/i/1669)
0.8.1: (2020-02-16) 0.8.1: (2020-02-16)
Emulation fixes: Emulation fixes:
- GB Serialize: Fix timing bug loading channel 4 timing - GB Serialize: Fix timing bug loading channel 4 timing

View File

@ -370,7 +370,7 @@ bool mCoreLoadELF(struct mCore* core, struct ELF* elf) {
Elf32_Phdr* phdr = ELFProgramHeadersGetPointer(&ph, i); Elf32_Phdr* phdr = ELFProgramHeadersGetPointer(&ph, i);
void* block = mCoreGetMemoryBlock(core, phdr->p_paddr, &bsize); void* block = mCoreGetMemoryBlock(core, phdr->p_paddr, &bsize);
char* bytes = ELFBytes(elf, &esize); char* bytes = ELFBytes(elf, &esize);
if (block && bsize >= phdr->p_filesz && bsize > phdr->p_offset && esize >= phdr->p_filesz + phdr->p_offset) { if (block && bsize >= phdr->p_filesz && esize > phdr->p_offset && esize >= phdr->p_filesz + phdr->p_offset) {
memcpy(block, &bytes[phdr->p_offset], phdr->p_filesz); memcpy(block, &bytes[phdr->p_offset], phdr->p_filesz);
} else { } else {
return false; return false;