relocate.c: some cleanup

This commit is contained in:
Wolfgang Thaller 2020-12-28 15:15:09 +01:00
parent 4c7b83bb75
commit 5fdd7b411f
1 changed files with 7 additions and 25 deletions

View File

@ -135,12 +135,12 @@ void Retro68ApplyRelocations(uint8_t *base, uint32_t size, void *relocations, ui
assert(addrPtr >= base);
assert(addrPtr <= base + size - 4);
uint8_t *addr = (uint8_t*) READ_UNALIGNED_LONGWORD(addrPtr);
uint32_t addr = READ_UNALIGNED_LONGWORD(addrPtr);
addr += displacements[kind];
if(relative)
addr -= (uint32_t) addrPtr;
WRITE_UNALIGNED_LONGWORD(addrPtr, (uint32_t) addr);
WRITE_UNALIGNED_LONGWORD(addrPtr, addr);
}
reloc++;
@ -245,8 +245,8 @@ void Retro68Relocate()
// this crashes with some implementations of the memory manager
// if we guess wrong, so let's don't for now.
// Therefore, all Retro68-compiled code resources have to be locked,
// or they might get relocated as soon as the global variables are
// relocated below.
// or they might get moved as soon as the global variables are
// allocated below.
// TODO: figure out a way to reliably determine the offset from the
// start of the resource (to pass it from Elf2Mac, probably).
@ -278,11 +278,9 @@ void Retro68Relocate()
}
/*
Relocation records consist of 4 bytes each.
The lower three bytes are the offset of the longword being relocated.
the first byte of each longword specifies which segment
the relocation leads to; the corresponding displacements are taken
from the following table:
Relocation records logically consist of
* the offset of the longword being relocated
* the displacement base, specified as an index into the following table:
*/
long displacements[4] = {
displacement, // code
@ -315,22 +313,6 @@ void Retro68Relocate()
RealApplyRelocations(base, relocatableSize, reloc, displacements);
// We're basically done.
/*// Now check whether we're on 68040 or later and need to flush the cache.
// only do this if SysEnvirons is available.
// if SysEnvirons is not available, that means we're on an old System or ROM
// and likely not using a 68040, so we won't do this
if (hasSysEnvirons)
{
SysEnvRec env;
env.processor = 0;
SysEnvirons(0, &env);
if(env.processor >= env68040)
{
rState->needFlushCache = true;
FlushCodeCache();
}
}*/
if(hasFlushCodeCache)
FlushCodeCache();