mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-13 13:13:36 +00:00
Correct unload of imported vars.
From level99procrastinator, just slightly adjusted.
This commit is contained in:
parent
5bb6395d2b
commit
49aff7c75d
@ -539,8 +539,14 @@ void WriteVarSymbol(u32 exportAddress, u32 relocAddress, u8 type, bool reverse =
|
||||
case R_MIPS_LO16:
|
||||
{
|
||||
// Sign extend the existing low value (e.g. from addiu.)
|
||||
const u32 exportOffsetLo = exportAddress + (s16)(u16)(relocData & 0xFFFF);
|
||||
u32 full = exportOffsetLo;
|
||||
const u32 offsetLo = (s32)(s16)(u16)(relocData & 0xFFFF);
|
||||
u32 full = exportAddress;
|
||||
// This is only used in the error case (no hi/wrong hi.)
|
||||
if (!reverse) {
|
||||
full = offsetLo + exportAddress;
|
||||
} else {
|
||||
full = offsetLo - exportAddress;
|
||||
}
|
||||
|
||||
// The ABI requires that these come in pairs, at least.
|
||||
if (lastHI16Relocs.empty()) {
|
||||
@ -553,9 +559,9 @@ void WriteVarSymbol(u32 exportAddress, u32 relocAddress, u8 type, bool reverse =
|
||||
for (auto it = lastHI16Relocs.begin(), end = lastHI16Relocs.end(); it != end; ++it)
|
||||
{
|
||||
if (!reverse) {
|
||||
full = (it->data << 16) + exportOffsetLo;
|
||||
full = (it->data << 16) + offsetLo + exportAddress;
|
||||
} else {
|
||||
full = (it->data << 16) - exportOffsetLo;
|
||||
full = (it->data << 16) + offsetLo - exportAddress;
|
||||
}
|
||||
// The low instruction will be a signed add, which means (full & 0x8000) will subtract.
|
||||
// We add 1 in that case so that it ends up the right value.
|
||||
|
Loading…
x
Reference in New Issue
Block a user