forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

misaligned relocs

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
willow :--)



Joined: 13 Jan 2007
Posts: 126

PostPosted: Mon Mar 22, 2010 10:21 pm    Post subject: misaligned relocs Reply with quote

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
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Tue Mar 23, 2010 3:38 am    Post subject: Reply with quote

Relocs should at least be 2 or 4 byte aligned depends obviously on the reloc.
Back to top
View user's profile Send private message
willow :--)



Joined: 13 Jan 2007
Posts: 126

PostPosted: Tue Mar 23, 2010 8:34 am    Post subject: Reply with quote

but isn't even a 2 byte alignment a problem from the PSP's hardware point of view?
_________________
Wagic. Play that card game against an AI on your PSP
Back to top
View user's profile Send private message
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Tue Mar 23, 2010 11:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Tue Mar 23, 2010 11:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group