mirror of
https://github.com/autc04/Retro68.git
synced 2025-02-07 03:31:40 +00:00
Fix crashes caused by 68K relocations past the end of sections; still no idea what's going on.
This commit is contained in:
parent
380fef0114
commit
bbc3a1f049
@ -62,10 +62,10 @@ void Section::SetRela(Elf_Scn *scn)
|
|||||||
GElf_Rela rela;
|
GElf_Rela rela;
|
||||||
gelf_getrela(data, i, &rela);
|
gelf_getrela(data, i, &rela);
|
||||||
|
|
||||||
if(rela.r_offset < shdr.sh_addr || rela.r_offset >= shdr.sh_addr + shdr.sh_size)
|
if(rela.r_offset < shdr.sh_addr || rela.r_offset > shdr.sh_addr + shdr.sh_size - 4)
|
||||||
{
|
{
|
||||||
// For some reason, there sometimes are relocations beyond the end of the sections
|
// FIXME: There are sometimes relocations beyond the end of the sections
|
||||||
// in LD output. That's bad. Let's ignore it.
|
// in LD output for some reason. That's bad. Let's ignore it.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
relocs.push_back(rela);
|
relocs.push_back(rela);
|
||||||
|
@ -94,7 +94,7 @@ pascal void* Retro68LoadSegment(uint8_t *p)
|
|||||||
Handle RELA = NULL;
|
Handle RELA = NULL;
|
||||||
RELA = GetResource('RELA', id);
|
RELA = GetResource('RELA', id);
|
||||||
assert(RELA);
|
assert(RELA);
|
||||||
Retro68ApplyRelocations(base + 40, codeSize, *RELA, displacements);
|
Retro68ApplyRelocations(base + 40, codeSize - 40, *RELA, displacements);
|
||||||
HPurge(RELA);
|
HPurge(RELA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ void Retro68ApplyRelocations(uint8_t *base, uint32_t size, void *relocations, ui
|
|||||||
uint8_t kind = val & 0x3;
|
uint8_t kind = val & 0x3;
|
||||||
|
|
||||||
assert(addrPtr >= base);
|
assert(addrPtr >= base);
|
||||||
assert(addrPtr < base + size);
|
assert(addrPtr <= base + size - 4);
|
||||||
|
|
||||||
uint8_t *addr = (uint8_t*) READ_UNALIGNED_LONGWORD(addrPtr);
|
uint8_t *addr = (uint8_t*) READ_UNALIGNED_LONGWORD(addrPtr);
|
||||||
addr += displacements[kind];
|
addr += displacements[kind];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user