Closed sp193 closed 5 years ago
I don't understand how getbit_8 translated into the assembly version of getbit. Why does bb seem to be in big-endian? What happened to the +1 in the expression? What is the logical OR of 0xFF0000 for?
For now, I am trying to see if it is related to the Signature and PackedELF data being too close to the instructions at _start.
From the EE restrictions documentation, having data adjacent to instructions may result in a wrong instruction being fetched, data destroyed or FPU division being affected, if the data & instructions have a certain pattern. A workaround is to add 5 or more nop/combination of nop & sync.p on the boundary between the data and instructions.
Since we don't know why "bad" files can be made, let's just see if this commit will make the problem disappear. Related commit: 80246fe7
It's been about 2 weeks since I have made the commit mentioned above, and I have not seen a single broken file being generated ever since. I guess it took care of the issue, so I'll be closing this ticket. Please feel free to reopen it if it pops up again.
As for an explanation why, I am quite convinced that it has to do with allowing data to exist so close to code... although I don't see any bit patterns exactly matching the descriptions under (17) and (18). However, the description for (2) does not specify any particular bit pattern.
This shows the 5 words before the code at _start, of one of those bad files:
0x4e4512ab 01001110 01000101 00010010 10101011
0x242c35e1 00100100 00101100 00110101 11100001
0x40254992 01000000 00100101 01001001 10010010
0x000000ff 00000000 00000000 00000000 11111111
0x3145324e 00110001 01000101 00110010 01001110 <- _signature
0x01c46c60 00000001 11000100 01101100 01100000
I got a broken file today. I also noticed today that there's this dummy.s file, which contains some data and is very close to code. I have removed it in 65a1c5d. I'll keep this issue open again for a while, to see if the bug comes back.
Just wondering if you plan to give us a new recompiled version: https://github.com/ps2dev/ps2-packer/releases
Sometimes, ps2-packer will generate files that will not unpack properly. It rarely occurs and the problem seems to shift about, depending on the size of the built ELF.
It was already there in 2015, so I don't know when it started to happen (I always thought it was there). Anyway, I noticed that nobody wrote an issue entry for it, so here it is.
For example, this is a failed unpacking of OPL (forgot what version, but I kept the bad file and it is dated 22 January 2015):
The exception occurs at line 130 of n2e.s. It does not occur at the first iteration of the loop, but somewhere after.
I have this feeling that this is not actually where the problem is. I have been noticing tell-tale signs that the unpacker was executed repeatedly; I have stepped through this before and noticed that it will eventually jump to the EPC of the unpacked ELF. While stepping through that loop, I remember that eventually m_pos would become something like 0xFFFF00.
It's not a lot of details because I couldn't see why it happened and have no idea how to test it in detail, but I hope it'll do as a bug report.