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 

Help understanding PRX sections

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



Joined: 02 Jun 2009
Posts: 226

PostPosted: Fri Sep 18, 2009 8:45 pm    Post subject: Help understanding PRX sections Reply with quote

Hello again!

This time I'm a bit confused about some PRX sections.

.rodata.sceModuleInfo

Is this the correct stucture for this section?

Code:
#define MAX_MODULE_NAME 0x1c

/* .rodata.sceModuleInfo */
typedef struct
{
   Elf32_Half module_attributes;
   Elf32_Half module_version;
   BYTE       module_name[MAX_MODULE_NAME];
   Elf32_Addr gp;
   Elf32_Addr library_entry;
   Elf32_Addr library_entry_end;
   Elf32_Addr library_stubs;
   Elf32_Addr library_stubs_end;
} tModInfoEntry;


The Elf32_Addr, are they actually pointers or am I mistaken the type? File offsets maybe? If they're addresses, how can I relocate them? What is gp used for?

.rel

Code:
/* .rel entry */
typedef struct
{
    Elf32_Addr r_offset; // Offset of relocation
    Elf32_Word r_info;   // Packed information about relocation
} tRelEntry;

// Defines for the r_info field
#define ELF32_R_ADDR_BASE(i) (((i)> >16) & 0xFF)
#define ELF32_R_OFS_BASE(i) (((i)> >8) & 0xFF)
#define ELF32_R_TYPE(i) (i&0xFF)


I quite do not understand what are ADDR_BASE and OFS_BASE used for...

Hope you can enlighten me a bit...
_________________
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
usertestprueba



Joined: 15 Sep 2009
Posts: 12
Location: Spain

PostPosted: Sun Sep 20, 2009 7:46 am    Post subject: Reply with quote

I think nobody knows the answer :-S
(Or maybe they are too lazy to type it here xD)

I think you know more than me about PRXs :-S
Sorry!
Back to top
View user's profile Send private message
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Sun Sep 20, 2009 10:04 am    Post subject: Reply with quote

Of course they know the answer because otherwise they couldn't create an SDK that links PRXs :)

Maybe I'll find something in linker source...
_________________
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
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Sep 20, 2009 2:29 pm    Post subject: Reply with quote

There's lots of info out there on ELF files, including MIPS specific ELF. There's no reason for use to answer when a quick google will turn up the info. As stated many times before, we don't give beginner lessons here.
Back to top
View user's profile Send private message AIM Address
ab5000



Joined: 06 May 2008
Posts: 74

PostPosted: Sun Sep 20, 2009 10:53 pm    Post subject: Re: Help understanding PRX sections Reply with quote

m0skit0 wrote:
Hello again!

This time I'm a bit confused about some PRX sections.

.rodata.sceModuleInfo

Is this the correct stucture for this section?

Code:
#define MAX_MODULE_NAME 0x1c

/* .rodata.sceModuleInfo */
typedef struct
{
   Elf32_Half module_attributes;
   Elf32_Half module_version;
   BYTE       module_name[MAX_MODULE_NAME];
   Elf32_Addr gp;
   Elf32_Addr library_entry;
   Elf32_Addr library_entry_end;
   Elf32_Addr library_stubs;
   Elf32_Addr library_stubs_end;
} tModInfoEntry;


Yes, that's ok.

m0skit0 wrote:
The Elf32_Addr, are they actually pointers or am I mistaken the type?


They're offsets from relocation.

m0skit0 wrote:
What is gp used for?


As you know, usually you need to do a lui/ori to sore a memory address in a registry cause you can use only 16 bits of immediate value.
The compiler just uses a 32KB space for some data (not too big). the $gp is set as the address in the middle of the space. so, if you need to read some data from that space, you can just do an addi: you can move -16KB/+16KB.
_________________
Code:
%:include<stdio.h>
int _(int __,int ___,int ____,int _____)
<%for(;____<___;_____=_____*__,____++);
return _____;%>main()<%printf
("%d\n",_(2,5,0,1));%>
Back to top
View user's profile Send private message
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Mon Sep 21, 2009 6:45 pm    Post subject: Reply with quote

@J.F.: PRXs are not standard ELF neither they have standard MIPS relocation entries. What I'm asking is PRX specific (thus PSP specific), no other ELFs have those entries. Try a Google search about PRX and please tell me if you find something. I didn't, except YAPSPD, which is outdated and sometimes erroneous.

@ab5000: thanks, but I still don't understand the GP thing :P
_________________
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
ab5000



Joined: 06 May 2008
Posts: 74

PostPosted: Mon Sep 21, 2009 11:44 pm    Post subject: Reply with quote

the compiler allocates a 128KB (not 32KB, i made a mistake) space in data section (or the bss section, don't remeber well now). then it set $gp to the adress in the middle of the space.
the compiler uses those 128KB for storing data. suppose it's at 0xABC00000.
so $gp will be at 0xABC0FFFF.
then if you want to get a word from offset 0 from the start of the space...

Code:
lw $t0, -0xFFFF($gp)


or if you want a pointer...

Code:
addi $t0, $gp, -0xFFFF


or maybe you want the byte after 65 KB from start...

Code:
lw $t0, 0x401($gp)


understood?

note that the space isn't exactly 128KB, is 128KB - 1 byte ;)
_________________
Code:
%:include<stdio.h>
int _(int __,int ___,int ____,int _____)
<%for(;____<___;_____=_____*__,____++);
return _____;%>main()<%printf
("%d\n",_(2,5,0,1));%>
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Sep 22, 2009 1:51 am    Post subject: Reply with quote

m0skit0 wrote:
@J.F.: PRXs are not standard ELF neither they have standard MIPS relocation entries. What I'm asking is PRX specific (thus PSP specific), no other ELFs have those entries. Try a Google search about PRX and please tell me if you find something. I didn't, except YAPSPD, which is outdated and sometimes erroneous.


It's not THAT different. If you wish to know the difference, just look at the part of the toolchain that converts the ELF output of the linker into a PRX.
Back to top
View user's profile Send private message AIM Address
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Tue Sep 22, 2009 10:26 pm    Post subject: Reply with quote

About what matters to me (loading code in memory and relocate) it is different. In fact, it has no similarities whatsoever with standards.

Thanks for the advice, that's what I'm doing :)
_________________
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