mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2024-12-26 16:11:51 +01:00
Fix R_PPC_REL24 relocations
This commit is contained in:
parent
f5c8df9416
commit
30d7e3b7bd
@ -91,14 +91,15 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (freeSlot != NULL) {
|
if (freeSlot == nullptr) {
|
||||||
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin data list is full\n");
|
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin data list is full\n");
|
||||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, distance);
|
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, (target - (uint32_t) &(freeSlot->trampolin[0])));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (target - (uint32_t) &(freeSlot->trampolin[0]) > 0x1FFFFFC) {
|
if (target - (uint32_t) &(freeSlot->trampolin[0]) > 0x1FFFFFC) {
|
||||||
DEBUG_FUNCTION_LINE("**Cannot link 24-bit jump (too far to tramp buffer).");
|
DEBUG_FUNCTION_LINE("**Cannot link 24-bit jump (too far to tramp buffer).");
|
||||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, distance);
|
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, (target - (uint32_t) &(freeSlot->trampolin[0])));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,12 +114,11 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
|||||||
freeSlot->status = RELOC_TRAMP_FIXED;
|
freeSlot->status = RELOC_TRAMP_FIXED;
|
||||||
} else {
|
} else {
|
||||||
// Relocations for the imports may be overridden
|
// Relocations for the imports may be overridden
|
||||||
freeSlot->status = RELOC_TRAMP_IMPORT_IN_PROGRESS;
|
freeSlot->status = RELOC_TRAMP_IMPORT_DONE;
|
||||||
}
|
}
|
||||||
auto symbolValue = (uint32_t) &(freeSlot->trampolin[0]);
|
auto symbolValue = (uint32_t) &(freeSlot->trampolin[0]);
|
||||||
value = symbolValue + addend;
|
value = symbolValue + addend;
|
||||||
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
||||||
DEBUG_FUNCTION_LINE("Created tramp\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,14 +196,14 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (freeSlot != NULL) {
|
if (freeSlot == nullptr) {
|
||||||
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin data list is full\n");
|
DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin data list is full\n");
|
||||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, distance);
|
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, (target - (uint32_t) &(freeSlot->trampolin[0])));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (target - (uint32_t) &(freeSlot->trampolin[0]) > 0x1FFFFFC) {
|
if (target - (uint32_t) &(freeSlot->trampolin[0]) > 0x1FFFFFC) {
|
||||||
DEBUG_FUNCTION_LINE("**Cannot link 24-bit jump (too far to tramp buffer).");
|
DEBUG_FUNCTION_LINE("**Cannot link 24-bit jump (too far to tramp buffer).");
|
||||||
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, distance);
|
DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, (target - (uint32_t) &(freeSlot->trampolin[0])));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,12 +218,11 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des
|
|||||||
freeSlot->status = RELOC_TRAMP_FIXED;
|
freeSlot->status = RELOC_TRAMP_FIXED;
|
||||||
} else {
|
} else {
|
||||||
// Relocations for the imports may be overridden
|
// Relocations for the imports may be overridden
|
||||||
freeSlot->status = RELOC_TRAMP_IMPORT_IN_PROGRESS;
|
freeSlot->status = RELOC_TRAMP_IMPORT_DONE;
|
||||||
}
|
}
|
||||||
auto symbolValue = (uint32_t) &(freeSlot->trampolin[0]);
|
auto symbolValue = (uint32_t) &(freeSlot->trampolin[0]);
|
||||||
value = symbolValue + addend;
|
value = symbolValue + addend;
|
||||||
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
distance = static_cast<int32_t>(value) - static_cast<int32_t>(target);
|
||||||
DEBUG_FUNCTION_LINE("Created tramp\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user