mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2025-01-25 23:41:29 +01:00
Add support for handling relocations which leads to high addresses (and require a big jump)
This commit is contained in:
parent
a4b503c375
commit
9a15e549c7
@ -145,15 +145,42 @@ bool DynamicLinkingHelper::fillRelocations(std::vector<dyn_linking_relocation_en
|
||||
return false;
|
||||
} else {
|
||||
//DEBUG_FUNCTION_LINE("OSDynLoad_FindExport successful for %s on import %s: %08X\n",functionEntry->functionName,importEntry->importName,functionEntry->address);
|
||||
|
||||
/*
|
||||
90 61 ff e0 stw r3,-32(r1)
|
||||
3c 60 12 34 lis r3,4660
|
||||
60 63 56 78 ori r3,r3,22136
|
||||
7c 69 03 a6 mtctr r3
|
||||
80 61 ff e0 lwz r3,-32(r1)
|
||||
4e 80 04 20 bctr*/
|
||||
functionEntry->big_jump[0] = 0x9061FFE0;
|
||||
functionEntry->big_jump[1] = 0x3C600000 | ((((u32) functionEntry->address) >> 16) & 0x0000FFFF); // lis r3, real_addr@h
|
||||
functionEntry->big_jump[2] = 0x60630000 | (((u32) functionEntry->address) & 0x0000ffff); // ori r3, r3, real_addr@l
|
||||
functionEntry->big_jump[3] = 0x7C6903A6; // mtctr r3
|
||||
functionEntry->big_jump[4] = 0x8061FFE0; // lwz r3,-32(r1)
|
||||
functionEntry->big_jump[5] = 0x4E800420; // bctr
|
||||
DCFlushRange((void*)functionEntry->big_jump, sizeof(functionEntry->big_jump));
|
||||
ICInvalidateRange((unsigned char*)functionEntry->big_jump, sizeof(functionEntry->big_jump));
|
||||
|
||||
//DEBUG_FUNCTION_LINE("Created jump code address: %08X big_jump: %08X for %s \n",functionEntry->address,functionEntry->big_jump,functionEntry->functionName);
|
||||
//dumpHex(functionEntry->big_jump,sizeof(functionEntry->big_jump));
|
||||
}
|
||||
} else {
|
||||
//DEBUG_FUNCTION_LINE("We cached the address of function %s :%08X\n",functionEntry->functionName,functionEntry->address);
|
||||
}
|
||||
//DEBUG_FUNCTION_LINE("We would link now: type: %02X offset: %08X addend: %d destination: %08X target: %08X for %s\n",curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, functionEntry->address,functionEntry->functionName);
|
||||
|
||||
//DEBUG_FUNCTION_LINE("Linking: t: %02X o: %08X a: %d dest: %08X tar: %08X big_j: %08X\n",curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, functionEntry->address, (u32) functionEntry->big_jump);
|
||||
|
||||
DEBUG_FUNCTION_LINE("Resolving relocation to %s\n",functionEntry->functionName);
|
||||
|
||||
if(!curEntry->importEntry->isData && (u32) functionEntry->address > 0x04000000) {
|
||||
ElfTools::elfLinkOne(curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, (u32) functionEntry->big_jump);
|
||||
} else {
|
||||
ElfTools::elfLinkOne(curEntry->type, curEntry->offset, curEntry->addend, curEntry->destination, (u32) functionEntry->address);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PluginLoader::flushCache();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Clearing cache.\n");
|
||||
|
@ -442,7 +442,7 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
|
||||
case R_PPC_ADDR16_HA:
|
||||
case R_PPC_SECTOFF_HA:
|
||||
case R_PPC_EMB_NADDR16_HA: {
|
||||
*(short *)target = (value >> 16) + ((value >> 15) & 1);
|
||||
*(short *)target = (((value >> 16) + ((value & 0x8000) ? 1 : 0))) & 0xFFFF;
|
||||
break;
|
||||
}
|
||||
case R_PPC_ADDR16_LO:
|
||||
|
@ -35,6 +35,7 @@ extern "C" {
|
||||
typedef struct _dyn_linking_function_t {
|
||||
char functionName[DYN_LINK_FUNCTION_NAME_LENGTH+1];
|
||||
void * address;
|
||||
u32 big_jump[6];
|
||||
} dyn_linking_function_t;
|
||||
|
||||
typedef struct _dyn_linking_import_t {
|
||||
|
Loading…
x
Reference in New Issue
Block a user