diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index ed2b4c61d7..8ed7d8a082 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -269,6 +269,8 @@ void ElfReader::LoadRelocations2(int rel_seg) int flag_bits, seg_bits, type_bits; int cmd, flag, seg, type; int off_seg = 0, addr_seg, rel_base, rel_offset; + // last_type is the type of the previous relocation, which one of the lo16 encodings below + // depends on. int relocate_to, last_type, lo16 = 0; u32 op, addr; int rcount = 0; @@ -329,6 +331,15 @@ void ElfReader::LoadRelocations2(int rel_seg) return; buf += type_table_size; + // Note: flash0:/kd/loadcore.prx and flash0:/kd/sysmem.prx are relocated by the PSP's own + // reboot code, which reads this table through a different type mapping - + // {0, 3, 6, 7, 1, 2, 4, 5} indexed by the entry, see + // https://github.com/uofw/uofw/blob/master/src/reboot/elf.c and the same special case in + // JPCSP's Loader.relocateFromBufferA1. We don't apply it, because we don't emulate that + // reboot path - those two only get here through a --vsh boot, and would need the module + // filename plumbed down to tell them apart. Worth doing if VSH/LLE boot is ever taken + // further; harmless for every game module, which is everything else that lands here. + rel_base = 0; last_type = -1; while(buf