| View previous topic :: View next topic |
| Author |
Message |
willow :--)
Joined: 13 Jan 2007 Posts: 126
|
Posted: Mon Mar 22, 2010 10:21 pm Post subject: misaligned relocs |
|
|
For a school project I have to relocate a prx.
After a few tests I realized that some reloc addresses in some homebrews are not word aligned. I saw that tools such as prxtool and jcpsp don't care about those misaligned relocs and treat them as the others. Which works because the PC architecture they run on doesn't seem to care about word alignment.
However when trying that on the PSP, the PSP fails because the address to relocate is not 4 bytes aligned.
Now, If I follow what prxtool and jcpsp do (a.k.a work as if word alignement didn't matter), the idea is to overcome the psp limitation by reading 8 bytes, relocating inside this array of 8 bytes, and putting the 2 words back.
Before:
N+0:XX XX YY YY
N+4:YY YY XX XX
After
N+0:XX XX ZZ ZZ
N+4:ZZ ZZ XX XX
(imagine that the stuff I have to relocate are those YY YY YY YY at N+2. If I ask the PSP to grab the word at N+2, it will crash )
Now... isn't it weird that gcc generates relocs that are not word aligned? Am I missing something?
I'm not an expert at that, but I also wonder how the PSP handles misaligned relocs when it relocs with hardware. And obviously, it does handle the case since the homebrews I'm testing do run on a cfw psp _________________ Wagic. Play that card game against an AI on your PSP |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Tue Mar 23, 2010 3:38 am Post subject: |
|
|
| Relocs should at least be 2 or 4 byte aligned depends obviously on the reloc. |
|
| Back to top |
|
 |
willow :--)
Joined: 13 Jan 2007 Posts: 126
|
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Tue Mar 23, 2010 11:03 pm Post subject: |
|
|
Not if you're using lh instruction. It's a problem if you use lw. _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Tue Mar 23, 2010 11:04 pm Post subject: |
|
|
Not if you're using lh instruction. It's a problem if you use lw. _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
|