any plan for prxtool update?
any plan for prxtool update?
looks like the current version of prxtool doesn't fully support some of the later firmwares, any plan to fix that?
I believe I am using the newest build. I think prxtool is a very useful tool because it has the ability to detect data references and gives me some level of information about it. So good jobs you guys! This feature doesn't work anymore (I don't know since which firmware). It is a bit annoying without it. Just for the update, it appears to work again under the latest firmware, although I have no idea whether or not it gives the correct addresses.
Anyway, I went through the source code a bit last night. I think this is likely caused by the new relocation format. It there a quick fix for that by disabling/changing a small portion of the source code?
Oh, forgive me if you think I am a little captious.
Anyway, I went through the source code a bit last night. I think this is likely caused by the new relocation format. It there a quick fix for that by disabling/changing a small portion of the source code?
Oh, forgive me if you think I am a little captious.
It happens since 3.70 when sony changed again the format, since that version prxtool doesn't find variable addresses exactly (that's probably why no data is printed), and doesn't detect functions that are passed as parameters (like thread ones, callbacks, etc).
For variables you actually have to add the data section address to the variable address to get the proper address.
For variables you actually have to add the data section address to the variable address to get the proper address.
I think this is no longer the case for fw3.70+ (according to you). Variable addresses appear to be the real addresses, as their values are all above 0x8804000.moonlight wrote:For variables you actually have to add the data section address to the variable address to get the proper address.
Can I modify some part of the source to make it work? It is not my work, probably gonna take a while... Any time-saving suggestions would be appreciated!
moonlight, did you ever actually work out how the relocations decode in your travels? I really never have the desire to actually reverse the code myself :)
And I guess as moonlight says the variables should need the data section address adding to them, sure they did last time. But I have been long out of the psp dev scene so not really paid much attention.
And I guess as moonlight says the variables should need the data section address adding to them, sure they did last time. But I have been long out of the psp dev scene so not really paid much attention.
I "reversed engineered" the subroutine at address 0x55FC of the loadcore.prx (FW 5.0), and I found pretty interesting things about the new relocation format:
Running my code on the chkreg.prx, it produced the following output:
I supposed it worked fine, and the next step is to put it on the prxtool
Code: Select all
static
int load_unk (struct elf_program *programs, uint32 prgidx, uint8 *data, uint32 size)
{
uint32 nbits;
uint8 part1s, part2s;
uint32 block1s, block2s;
uint8 block1[256], block2[256];
uint8 *ndata, *end;
uint32 vaddr, temp1, temp2;
uint32 part1, part2, lastpart2;
uint32 addend = 0, offset = 0;
uint32 ofsbase = 0xFFFFFFFF;
uint32 addrbase;
char *type;
end = data + size;
for (nbits = 1; (1 << nbits) < prgidx; nbits++) {
if (nbits >= 33) {
error (__FILE__ ": invalid number of bits for indexes");
return 0;
}
}
if (read_uint16_le (data) != 0) {
error (__FILE__ ": invalid header for relocation");
return 0;
}
part1s = data[2];
part2s = data[3];
block1s = data[4];
data += 4;
if (block1s) {
memcpy (block1, data, block1s);
data += block1s;
}
block2s = *data;
if (block2s) {
memcpy (block2, data, block2s);
data += block2s;
}
lastpart2 = block2s;
for (ndata = data; ndata < end; data = ndata) {
uint32 cmd = read_uint16_le (data);
temp1 = (cmd << (16 - part1s)) & 0xFFFF;
temp1 = (temp1 >> (16 -part1s)) & 0xFFFF;
ndata = data + 2;
if (temp1 >= block1s) {
error (__FILE__ ": invalid index for the first part");
return 0;
}
part1= block1[temp1];
if ((part1 & 0x01) == 0) {
ofsbase = (cmd << (16 - part1s - nbits)) & 0xFFFF;
ofsbase = (ofsbase >> (16 - nbits)) & 0xFFFF;
if (!(ofsbase < prgidx)) {
error (__FILE__ ": invalid offset base");
return 0;
}
offset = cmd >> (part1s + nbits);
if ((part1 & 0x06) == 0) continue;
if ((part1 & 0x06) != 4) {
error (__FILE__ ": invalid size");
return 0;
}
offset = read_uint32_le (ndata);
ndata = data + 6;
} else {
temp2 = (cmd << (16 - (part1s + nbits + part2s))) & 0xFFFF;
temp2 = (temp2 >> (16 - part2s)) & 0xFFFF;
if (temp2 >= block2s) {
error (__FILE__ ": invalid index for the second part");
return 0;
}
addrbase = (cmd << (16 - part1s - nbits)) & 0xFFFF;
addrbase = (addrbase >> (16 - nbits)) & 0xFFFF;
if (!(addrbase < prgidx)) {
error (__FILE__ ": invalid address base");
return 0;
}
part2 = block2[temp2];
switch (part1 & 0x06) {
case 0:
if (cmd & 0x8000) {
cmd |= ~0xFFFF;
cmd >>= part1s + part2s + nbits;
cmd |= ~0xFFFF;
} else {
cmd >>= part1s + part2s + nbits;
}
offset += cmd;
break;
case 2:
if (cmd & 0x8000) cmd |= ~0xFFFF;
cmd = (cmd >> (part1s + part2s + nbits)) << 16;
cmd |= read_uint16_le (&data[2]);
offset += cmd;
ndata = data + 4;
break;
case 4:
offset = read_uint32_le (ndata);
ndata = data + 6;
break;
default:
error (__FILE__ ": invalid part1 size");
return 0;
}
if (!(offset < programs[ofsbase].filesz)) {
error (__FILE__ ": invalid relocation offset");
return 0;
}
switch (part1 & 0x38) {
case 0x00:
addend = 0;
break;
case 0x08:
if ((lastpart2 ^ 0x04) != 0) {
addend = 0;
}
break;
case 0x10:
addend = read_uint16_le (ndata);
ndata += 2;
break;
case 0x18:
read_uint32_le (ndata);
return 0;
default:
error (__FILE__ ": invalid addendum size");
return 0;
}
lastpart2 = part2;
vaddr = programs[addrbase].vaddr;
data = (uint8 *) &programs[ofsbase].data[offset];
switch (part2) {
case 2:
temp2 = read_uint32_le (data) + vaddr;
type = "mips32";
break;
case 0:
continue;
case 3:
temp1 = read_uint32_le (data);
temp2 = offset + programs[ofsbase].vaddr;
temp2 &= 0xF0000000;
temp2 = (((((temp1 & 0x3FFFFFF) << 2) | temp2) + vaddr) >> 2) & 0x3FFFFFF;
temp1 &= ~0x3FFFFFF;
temp2 |= temp1;
type = "mips26";
break;
case 4:
temp1 = read_uint32_le (data);
temp2 = (temp1 << 16) + ((int) ((short) addend)) + vaddr;
temp2 = temp2 >> 15;
temp2 = ((temp2 + 1) >> 1) & 0xFFFF;
temp2 |= (temp1 & ~0xFFFF);
type = "hi16";
break;
case 1:
case 5:
temp1 = read_uint32_le (data);
temp2 = (int) ((short) temp1);
temp2 = (vaddr + temp2) & 0xFFFF;
temp1 &= ~0xFFFF;
temp2 |= temp1;
if (part2 == 1)
type = "lo16/clear";
else
type = "lo16";
break;
case 6:
temp1 = read_uint32_le (data) & ~0xFC000000;
temp2 = offset + programs[ofsbase].vaddr;
temp2 &= ~0xF0000000;
temp2 = ((temp1 << 2) | temp2) + vaddr;
temp2 = (temp2 >> 2) & 0x3FFFFFF;
temp2 |= 0x8000000;
type = "j26";
break;
case 7:
temp1 = read_uint32_le (data) & ~0xFC000000;
temp2 = offset + programs[ofsbase].vaddr;
temp2 &= ~0xF0000000;
temp2 = ((temp1 << 2) | temp2) + vaddr;
temp2 = (temp2 >> 2) & 0x3FFFFFF;
temp2 |= 0xC000000;
type = "jal26";
break;
default:
error (__FILE__ ": invalid relocation type");
return 0;
}
report ("Address base: %02d Offset base: %02d Type: %-12s Offset: 0x%08X Old data: 0x%08X New data: 0x%08X\n",
addrbase, ofsbase, type, offset, read_uint32_le (data), temp2);
}
}
return 1;
}
Code: Select all
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000008 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x0000001C Old data: 0x24520130 New data: 0x24520AB0
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000014 Old data: 0x3C130000 New data: 0x3C130000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000028 Old data: 0x8E700000 New data: 0x8E700980
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x0000003C Old data: 0x0C0001F1 New data: 0x0C0001FF
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000060 Old data: 0x8E700000 New data: 0x8E700980
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x000000B0 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000000B4 Old data: 0xAC430040 New data: 0xAC4309C0
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x000000BC Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000000C0 Old data: 0xAC430044 New data: 0xAC4309C4
Address base: 00 Offset base: 00 Type: j26 Offset: 0x00000104 Old data: 0x0800002C New data: 0x0800006D
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x0000010C Old data: 0x0C0001F1 New data: 0x0C0001F3
Address base: 00 Offset base: 00 Type: j26 Offset: 0x00000120 Old data: 0x08000033 New data: 0x0800007B
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000128 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x0000012C Old data: 0x8C430040 New data: 0x8C4309C0
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000130 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000134 Old data: 0x244A0130 New data: 0x244A0AB0
Address base: 00 Offset base: 00 Type: j26 Offset: 0x00000188 Old data: 0x0800005D New data: 0x0800007F
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000198 Old data: 0x3C100000 New data: 0x3C100000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x0000019C Old data: 0x26100A80 New data: 0x26101400
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x000001B0 Old data: 0x0C0001EF New data: 0x0C0001EF
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x000001D0 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000001D4 Old data: 0xAC430048 New data: 0xAC4309C8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x000001F0 Old data: 0x0C0001EF New data: 0x0C0001FF
Address base: 00 Offset base: 00 Type: j26 Offset: 0x00000204 Old data: 0x08000078 New data: 0x080000F9
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x0000020C Old data: 0x3C060000 New data: 0x3C060000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000214 Old data: 0x24C60A80 New data: 0x24C61400
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x00000228 Old data: 0x0C0001F3 New data: 0x0C0001FB
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000254 Old data: 0x3C050000 New data: 0x3C050000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000258 Old data: 0x8CA20000 New data: 0x8CA20980
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000270 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000274 Old data: 0x24450A80 New data: 0x24451400
Address base: 00 Offset base: 00 Type: hi16 Offset: 0x00000294 Old data: 0x3C040000 New data: 0x3C040000
Address base: 00 Offset base: 00 Type: lo16 Offset: 0x0000029C Old data: 0x24840938 New data: 0x24840938
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000290 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000002B0 Old data: 0xAC400040 New data: 0xAC4009C0
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000344 Old data: 0x3C030000 New data: 0x3C030000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000002B8 Old data: 0xAC600044 New data: 0xAC6009C4
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x000002BC Old data: 0x0C0001ED New data: 0x0C0001EF
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000350 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000002C0 Old data: 0xAC400048 New data: 0xAC4009C8
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x000002CC Old data: 0x3C030000 New data: 0x3C030000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000002D0 Old data: 0xAC620B38 New data: 0xAC6214B8
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x000002F4 Old data: 0x3C050000 New data: 0x3C050000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000300 Old data: 0x8CA20000 New data: 0x8CA20980
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000318 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x0000031C Old data: 0x24450A80 New data: 0x24451400
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000338 Old data: 0x3C100000 New data: 0x3C100000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x0000033C Old data: 0x8E040B38 New data: 0x8E0414B8
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000340 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000348 Old data: 0xAC400040 New data: 0xAC4009C0
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000298 Old data: 0x3C030000 New data: 0x3C030000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000358 Old data: 0xAC600044 New data: 0xAC6009C4
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x0000035C Old data: 0x0C0001EB New data: 0x0C0001FF
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x000002B4 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000360 Old data: 0xAC400048 New data: 0xAC4009C8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x00000380 Old data: 0x0C0001E7 New data: 0x0C0001E7
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x000006D0 Old data: 0x3C120000 New data: 0x3C120000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000384 Old data: 0x8E040B38 New data: 0x8E0414B8
Address base: 00 Offset base: 00 Type: j26 Offset: 0x00000388 Old data: 0x080000DB New data: 0x080000FB
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000398 Old data: 0x3C130000 New data: 0x3C130000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000003A8 Old data: 0x8E640B38 New data: 0x8E6414B8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x000003C4 Old data: 0x0C0001EB New data: 0x0C0001FB
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x000003D0 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000003D4 Old data: 0x8C430044 New data: 0x8C4309C4
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x000003E0 Old data: 0x0C000000 New data: 0x0C0000F8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x000003F4 Old data: 0x0C00004A New data: 0x0C0000FF
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000400 Old data: 0x8E640B38 New data: 0x8E6414B8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x00000404 Old data: 0x0C0001E9 New data: 0x0C0001E9
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000440 Old data: 0x3C120000 New data: 0x3C120000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000454 Old data: 0x8E440B38 New data: 0x8E4414B8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x00000464 Old data: 0x0C0001EB New data: 0x0C0001FB
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000470 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000474 Old data: 0x8C430048 New data: 0x8C4309C8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x00000480 Old data: 0x0C000064 New data: 0x0C000164
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x00000490 Old data: 0x0C000083 New data: 0x0C0001A7
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x0000072C Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000004A4 Old data: 0x24440A80 New data: 0x24441400
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000004E8 Old data: 0x8E440B38 New data: 0x8E4414B8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x000004EC Old data: 0x0C0001E9 New data: 0x0C0001FB
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000524 Old data: 0x3C140000 New data: 0x3C140000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000534 Old data: 0x8E840B38 New data: 0x8E8414B8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x00000554 Old data: 0x0C0001EB New data: 0x0C0001FF
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000560 Old data: 0x3C100000 New data: 0x3C100000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000564 Old data: 0x8E040004 New data: 0x8E040984
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000568 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000570 Old data: 0xAC430B40 New data: 0xAC4314C0
Address base: 00 Offset base: 00 Type: hi16 Offset: 0x00000574 Old data: 0x3C020000 New data: 0x3C020000
Address base: 00 Offset base: 00 Type: lo16 Offset: 0x0000057C Old data: 0x24470944 New data: 0x24470944
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000005E8 Old data: 0x8E040004 New data: 0x8E040984
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x000005F8 Old data: 0x0C0001F3 New data: 0x0C0001FF
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000630 Old data: 0x8E020004 New data: 0x8E020984
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000648 Old data: 0x8E840B38 New data: 0x8E8414B8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x0000064C Old data: 0x0C0001E9 New data: 0x0C0001FB
Address base: 00 Offset base: 00 Type: j26 Offset: 0x00000688 Old data: 0x0800018B New data: 0x080001AB
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000690 Old data: 0x8E020004 New data: 0x8E020984
Address base: 00 Offset base: 00 Type: j26 Offset: 0x000006B0 Old data: 0x0800018B New data: 0x080001AF
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x000006EC Old data: 0x8E440B38 New data: 0x8E4414B8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x000006F4 Old data: 0x0C0001EB New data: 0x0C0001FF
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x00000700 Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000704 Old data: 0x8C430048 New data: 0x8C4309C8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x00000710 Old data: 0x0C000064 New data: 0x0C0001E4
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x00000720 Old data: 0x0C000083 New data: 0x0C0001CB
Address base: 01 Offset base: 00 Type: hi16 Offset: 0x0000049C Old data: 0x3C020000 New data: 0x3C020000
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000734 Old data: 0x24450A80 New data: 0x24451400
Address base: 01 Offset base: 00 Type: lo16 Offset: 0x00000758 Old data: 0x8E440B38 New data: 0x8E4414B8
Address base: 00 Offset base: 00 Type: jal26 Offset: 0x0000075C Old data: 0x0C0001E9 New data: 0x0C0001FF
Address base: 00 Offset base: 00 Type: j26 Offset: 0x00000794 Old data: 0x080001D6 New data: 0x080001F7
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x000007F0 Old data: 0x000008C4 New data: 0x000008C4
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x000007F4 Old data: 0x000008E4 New data: 0x000008E4
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000800 Old data: 0x000008F8 New data: 0x000008F8
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x0000080C Old data: 0x00000888 New data: 0x00000888
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000824 Old data: 0x000008A0 New data: 0x000008A0
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000838 Old data: 0x000008B8 New data: 0x000008B8
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x0000081C Old data: 0x0000079C New data: 0x0000079C
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000818 Old data: 0x00000918 New data: 0x00000918
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000834 Old data: 0x000007BC New data: 0x000007BC
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000830 Old data: 0x00000928 New data: 0x00000928
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000848 Old data: 0x000007CC New data: 0x000007CC
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000844 Old data: 0x00000930 New data: 0x00000930
Address base: 01 Offset base: 00 Type: mips32 Offset: 0x00000870 Old data: 0x00008000 New data: 0x00008980
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000874 Old data: 0x000007E4 New data: 0x000007E4
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000878 Old data: 0x00000804 New data: 0x00000804
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x0000087C Old data: 0x0000080C New data: 0x0000080C
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000880 Old data: 0x0000084C New data: 0x0000084C
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x000008D4 Old data: 0x00000248 New data: 0x00000248
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x000008D8 Old data: 0x000002E0 New data: 0x000002E0
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x000008DC Old data: 0x00000850 New data: 0x00000850
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x000008E0 Old data: 0x00000934 New data: 0x00000934
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000908 Old data: 0x00000390 New data: 0x00000390
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x0000090C Old data: 0x00000438 New data: 0x00000438
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000910 Old data: 0x000006B8 New data: 0x000006B8
Address base: 00 Offset base: 00 Type: mips32 Offset: 0x00000914 Old data: 0x0000051C New data: 0x0000051C
Address base: 01 Offset base: 01 Type: mips32 Offset: 0x00000000 Old data: 0x00000080 New data: 0x00000A00
Address base: 01 Offset base: 01 Type: mips32 Offset: 0x00000004 Old data: 0x00000B40 New data: 0x000014C0
(The output of psp-readelf -a chkreg.prx)
Code: Select all
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: Processor Specific: (ffa0)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x248
Start of program headers: 52 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x10a23001, noreorder, allegrex, eabi32, mips2
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0
There are no sections in this file.
There are no sections in this file.
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x0000a0 0x00000000 0x800008f0 0x00958 0x00958 R E 0x10
LOAD 0x000a00 0x00000980 0x00000000 0x00008 0x00b80 RW 0x40
LOPROC+a1 0x000a10 0x00000000 0x00000000 0x00174 0x00000 0x10
There is no dynamic section in this file.
There are no relocations in this file.
There are no unwind sections in this file.
No version information found in this file.
Yes. But the custom program type is 0x700000A1 (not 0xFFA1).
Accordingly to loadcore.prx, programs is an array of all program headers whose type is LOAD, prgidx is the index of the relocation program (type 0x700000A1), data is a pointer to the relocation program bytes and size is the corresponding size of the relocation program.
Accordingly to loadcore.prx, programs is an array of all program headers whose type is LOAD, prgidx is the index of the relocation program (type 0x700000A1), data is a pointer to the relocation program bytes and size is the corresponding size of the relocation program.
The patch to make prxtool works with the new relocation type is at
http://forums.ps2dev.org/viewtopic.php?p=80441
http://forums.ps2dev.org/viewtopic.php?p=80441
@ hnaves
i just tried out your patch, maybe it doesn't work with the boot file i was trying to disassemble last July. well, i got an "Couldn't load elf file structures" error. well, maybe it only works with prx's but not elf files? anyway, i was away from the psp stuff for a while and didn't have a chance to come back here and say thank you for your work :)
i just tried out your patch, maybe it doesn't work with the boot file i was trying to disassemble last July. well, i got an "Couldn't load elf file structures" error. well, maybe it only works with prx's but not elf files? anyway, i was away from the psp stuff for a while and didn't have a chance to come back here and say thank you for your work :)
I believe it only works with prx's, and decompressed ones at that.D_Street wrote:@ hnaves
i just tried out your patch, maybe it doesn't work with the boot file i was trying to disassemble last July. well, i got an "Couldn't load elf file structures" error. well, maybe it only works with prx's but not elf files? anyway, i was away from the psp stuff for a while and didn't have a chance to come back here and say thank you for your work :)
Programming with:
Geany + Latest PSPSDK from svn
Geany + Latest PSPSDK from svn
just give an example elf here.
and i tracked down the error:
LoadExports() returns false in CProcessPrx::LoadFromFile(const char *szFilename)
and thats because in CProcessPrx::LoadExports(), pExport == NULL at some point.
here is the debug output:
and i tracked down the error:
LoadExports() returns false in CProcessPrx::LoadFromFile(const char *szFilename)
and thats because in CProcessPrx::LoadExports(), pExport == NULL at some point.
here is the debug output:
Code: Select all
PRXTool v1.1 : (c) TyRaNiD 2k6
Built: May 15 2009 23:23:49
Loading BOOT.PBP
Debug: 00000054, 00183588, 00183588
Debug: ELF Header:
Debug: Magic 464C457F
Debug: Class 1
Debug: Data 1
Debug: Idver 1
Debug: Type 0002
Debug: Start 08804124
Debug: PH Offs 00000034
Debug: SH Offs 00183100
Debug: Flags 10A23001
Debug: EH Size 52
Debug: PHEntSize 32
Debug: PHNum 1
Debug: SHEntSize 40
Debug: SHNum 29
Debug: SHStrndx 28
Debug: Program Headers:
Debug: Program Header 0:
Debug: Type: 00000001
Debug: Offset: 00001018
Debug: VAddr: 00000000
Debug: PAddr: 000E740C
Debug: FileSz: 1397892
Debug: MemSz: 3970700
Debug: Flags: 00000007
Debug: Align: 00001000
Debug: Section 0
Debug: Name: 0
Debug: Type: 00000000
Debug: Flags: 00000000
Debug: Addr: 00000000
Debug: Offset: 00000000
Debug: Size: 00000000
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000000
Debug: Entsize: 00000000
Debug: Data 0x7fe20008
Debug: Section 1
Debug: Name: 11 .reginfo
Debug: Type: 70000006
Debug: Flags: 00000000
Debug: Addr: 08804000
Debug: Offset: 00156530
Debug: Size: 00000018
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000001
Debug: Data 0x7ff76538
Debug: Section 2
Debug: Name: 20 .init
Debug: Type: 00000001
Debug: Flags: 00000006
Debug: Addr: 08804018
Debug: Offset: 00001018
Debug: Size: 00000024
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000001
Debug: Entsize: 00000000
Debug: Data 0x7fe21020
Debug: Section 3
Debug: Name: 40 .text
Debug: Type: 00000001
Debug: Flags: 00000006
Debug: Addr: 08804040
Debug: Offset: 00001040
Debug: Size: 000E5C10
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000010
Debug: Entsize: 00000000
Debug: Data 0x7fe21048
Debug: Section 4
Debug: Name: 26 .fini
Debug: Type: 00000001
Debug: Flags: 00000006
Debug: Addr: 088E9C50
Debug: Offset: 000E6C50
Debug: Size: 0000001C
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000001
Debug: Entsize: 00000000
Debug: Data 0x7ff06c58
Debug: Section 5
Debug: Name: 32 .sceStub.text
Debug: Type: 00000001
Debug: Flags: 00000006
Debug: Addr: 088E9C6C
Debug: Offset: 000E6C6C
Debug: Size: 000005C8
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff06c74
Debug: Section 6
Debug: Name: 46 .lib.ent.top
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA234
Debug: Offset: 000E7234
Debug: Size: 00000004
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff0723c
Debug: Section 7
Debug: Name: 59 .lib.ent
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA238
Debug: Offset: 000E7238
Debug: Size: 00000010
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff07240
Debug: Section 8
Debug: Name: 68 .lib.ent.btm
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA248
Debug: Offset: 000E7248
Debug: Size: 00000004
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff07250
Debug: Section 9
Debug: Name: 81 .lib.stub.top
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA24C
Debug: Offset: 000E724C
Debug: Size: 00000004
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff07254
Debug: Section 10
Debug: Name: 95 .lib.stub
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA250
Debug: Offset: 000E7250
Debug: Size: 000001B8
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff07258
Debug: Section 11
Debug: Name: 105 .lib.stub.btm
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA408
Debug: Offset: 000E7408
Debug: Size: 00000004
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff07410
Debug: Section 12
Debug: Name: 119 .rodata.sceModuleInfo
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA40C
Debug: Offset: 000E740C
Debug: Size: 00000034
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff07414
Debug: Section 13
Debug: Name: 141 .rodata.sceResident
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA440
Debug: Offset: 000E7440
Debug: Size: 000001D0
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff07448
Debug: Section 14
Debug: Name: 161 .rodata.sceNid
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA610
Debug: Offset: 000E7610
Debug: Size: 000002E4
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff07618
Debug: Section 15
Debug: Name: 176 .rodata
Debug: Type: 00000001
Debug: Flags: 00000002
Debug: Addr: 088EA900
Debug: Offset: 000E7900
Debug: Size: 00031C13
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000040
Debug: Entsize: 00000000
Debug: Data 0x7ff07908
Debug: Section 16
Debug: Name: 184 .data
Debug: Type: 00000001
Debug: Flags: 00000003
Debug: Addr: 0891C540
Debug: Offset: 00119540
Debug: Size: 0003CEE0
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000040
Debug: Entsize: 00000000
Debug: Data 0x7ff39548
Debug: Section 17
Debug: Name: 190 .eh_frame
Debug: Type: 00000001
Debug: Flags: 00000003
Debug: Addr: 08959420
Debug: Offset: 00156420
Debug: Size: 00000068
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff76428
Debug: Section 18
Debug: Name: 200 .ctors
Debug: Type: 00000001
Debug: Flags: 00000003
Debug: Addr: 08959488
Debug: Offset: 00156488
Debug: Size: 00000008
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff76490
Debug: Section 19
Debug: Name: 207 .dtors
Debug: Type: 00000001
Debug: Flags: 00000003
Debug: Addr: 08959490
Debug: Offset: 00156490
Debug: Size: 00000008
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff76498
Debug: Section 20
Debug: Name: 214 .jcr
Debug: Type: 00000001
Debug: Flags: 00000003
Debug: Addr: 08959498
Debug: Offset: 00156498
Debug: Size: 00000004
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff764a0
Debug: Section 21
Debug: Name: 219 .sbss
Debug: Type: 00000008
Debug: Flags: 10000003
Debug: Addr: 08959500
Debug: Offset: 00156500
Debug: Size: 00000C50
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000080
Debug: Entsize: 00000000
Debug: Data 0x7ff76508
Debug: Section 22
Debug: Name: 225 .bss
Debug: Type: 00000008
Debug: Flags: 00000003
Debug: Addr: 0895A180
Debug: Offset: 00156530
Debug: Size: 0019442C
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000080
Debug: Entsize: 00000000
Debug: Data 0x7ff76538
Debug: Section 23
Debug: Name: 230 .comment
Debug: Type: 00000001
Debug: Flags: 00000000
Debug: Addr: 00000000
Debug: Offset: 00156548
Debug: Size: 000004ED
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000001
Debug: Entsize: 00000000
Debug: Data 0x7ff76550
Debug: Section 24
Debug: Name: 239 .pdr
Debug: Type: 00000001
Debug: Flags: 00000000
Debug: Addr: 00000000
Debug: Offset: 00156A38
Debug: Size: 0002C5A0
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000004
Debug: Entsize: 00000000
Debug: Data 0x7ff76a40
Debug: Section 25
Debug: Name: 244 .mdebug.eabi32
Debug: Type: 00000001
Debug: Flags: 00000000
Debug: Addr: 00000000
Debug: Offset: 00182FD8
Debug: Size: 00000000
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000001
Debug: Entsize: 00000000
Debug: Data 0x7ffa2fe0
Debug: Section 26
Debug: Name: 259 .gcc_compiled_long32
Debug: Type: 00000001
Debug: Flags: 00000000
Debug: Addr: 00000000
Debug: Offset: 00182FD8
Debug: Size: 00000000
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000001
Debug: Entsize: 00000000
Debug: Data 0x7ffa2fe0
Debug: Section 27
Debug: Name: 280 .overlay_area
Debug: Type: 00000008
Debug: Flags: 00000007
Debug: Addr: 08AEE5AC
Debug: Offset: 00156530
Debug: Size: 000DF0F8
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000001
Debug: Entsize: 00000000
Debug: Data 0x7ff76538
Debug: Section 28
Debug: Name: 1 .shstrtab
Debug: Type: 00000003
Debug: Flags: 00000000
Debug: Addr: 00000000
Debug: Offset: 00182FD8
Debug: Size: 00000126
Debug: Link: 00000000
Debug: Info: 00000000
Debug: Addralign: 00000001
Debug: Entsize: 00000000
Debug: Data 0x7ffa2fe0
Debug: Size 16
Debug: Min Address 00000000, Max Address 003C968C
Debug: Loading program 0 0x00000001
Debug: pData 0x7fa50008, iSize 3c968c, iBaseAddr 0x00000000, endian 0
Debug: Module Info:
Debug: Name: tor
Debug: Addr: 0x088EA40C
Debug: Flags: 0x01010000
Debug: GP: 0x08961490
Debug: Exports: 0x088EA238, Exp_end 0x088EA248
Debug: Imports: 0x088EA250, Imp_end 0x088EA408
Debug: Ptr out of region 0x088EA238
Error: Couldn't load elf file structures
Done
Well the real problem is the program header is garbage. No idea what you used to build it, most likely as the ELF is not loaded at the "standard" address you have a custom linker script? Or is this "third party code"?
I am sure I am paranoid, but I would swear some of the changes Sony have made over the years to the way prxes etc. are represented have less to do with saving space and shit like that and more to hamper reverse engineering and break prxtool :)
I am sure I am paranoid, but I would swear some of the changes Sony have made over the years to the way prxes etc. are represented have less to do with saving space and shit like that and more to hamper reverse engineering and break prxtool :)
what if i tell you that any version below revision 2457 would load the elf just fine? so my first thought was that there might be some inconsistency in between the code that introduce this error, not necessarily the elf's fault.TyRaNiD wrote:Well the real problem is the program header is garbage. No idea what you used to build it, most likely as the ELF is not loaded at the "standard" address you have a custom linker script? Or is this "third party code"?
I am sure I am paranoid, but I would swear some of the changes Sony have made over the years to the way prxes etc. are represented have less to do with saving space and shit like that and more to hamper reverse engineering and break prxtool :)
i totally agree with the second part of your comment though :)