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 

About _init and _start

 
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: Thu Jul 16, 2009 1:07 am    Post subject: About _init and _start Reply with quote

Just a quick question: _init is for data intialization and it is executed before _start... is this right? Because ELF header sets entry point for _start address.
_________________
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
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Jul 16, 2009 3:29 am    Post subject: Reply with quote

As long as _start is set to the entry point it runs before _init, well in actual fact your _start routine is responsible for calling _init
Back to top
View user's profile Send private message
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Thu Jul 16, 2009 4:42 am    Post subject: Reply with quote

Arigato sensei :)
_________________
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
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Thu Jul 16, 2009 10:25 am    Post subject: Reply with quote

tyranid what is the difference between module_start and _start ?
does the function module_start call _start ?
Back to top
View user's profile Send private message Send e-mail MSN Messenger
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Jul 16, 2009 3:21 pm    Post subject: Reply with quote

There is no difference, module_start is just a synonym for _start. The reason you will see module_start being used is that the actual name sony used (based on reversing the hash) and so in certain situations we use that name for ease.
Back to top
View user's profile Send private message
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Thu Jul 16, 2009 9:55 pm    Post subject: Reply with quote

when i don"t declare _start and declare module_start the linker complain about _start missing.

Code:

   .globl   module_info
   .section   .rodata.sceModuleInfo,"a",@progbits
   .align   4
   .type   module_info, @object
   .size   module_info, 52
module_info:
   .half   0
   .byte   1
   .byte   1
   .ascii   "Hello world\000"
   .space   15
   .byte   0
   .word   _gp
   .word   __lib_ent_top
   .word   __lib_ent_bottom
   .word   __lib_stub_top
   .word   __lib_stub_bottom
   .set push
        .section .lib.ent.top, "a", @progbits
        .align 2
        .word 0
__lib_ent_top:
        .section .lib.ent.btm, "a", @progbits
        .align 2
__lib_ent_bottom:
        .word 0
        .section .lib.stub.top, "a", @progbits
        .align 2
        .word 0
__lib_stub_top:
        .section .lib.stub.btm, "a", @progbits
        .align 2
__lib_stub_bottom:
        .word 0
IMPORT_START   "LoadExecForKernel",0x00010000
 IMPORT_FUNC   "LoadExecForKernel",0x05572A5F,sceKernelExitGame 
        .set pop
        .text
        .rdata
   .align   2
$LC2:
   .ascii   "Hello World from ASM Mips!\000"
   .align   2
   .globl   module_start
   .set   nomips16

 

    .text
_start:
module_start:
   
   .set   noreorder
   
   addiu   $sp,$sp,-8
   sw   $31,4($sp)
   sw   $fp,0($sp)
   move   $fp,$sp
#   jal   pspDebugScreenInit
#   nop

   lui   $2,%hi($LC2)
   addiu   $4,$2,%lo($LC2)
#   jal   pspDebugScreenPrintf
#   nop

   jal   sceKernelExitGame
   nop

   move   $2,$0
   move   $sp,$fp
   lw   $31,4($sp)
   lw   $fp,0($sp)
   addiu   $sp,$sp,8
   j   $31
   nop

sp-gcc -I. -I/home/f731/pspdev/psp/sdk/include -O2 -G0 -Wall -mno-crt0 -nostartfiles -I. -I/home/f731/pspdev/psp/sdk/include -O2 -G0 -Wall -mno-crt0 -nostartfiles -o helloworld.o helloworld.s
/home/f731/pspdev/lib/gcc/psp/4.3.2/../../../../psp/bin/ld: AVERTISSEMENT: ne peut trouver le symbole d'entrée _start; utilise par défaut 0000000008900018

i try to make a hello world program in asm mips for kernel 3.x

when i add .globl _start the warning dissaspear
Back to top
View user's profile Send private message Send e-mail MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Fri Jul 17, 2009 1:52 am    Post subject: Reply with quote

Add -S to the CFLAGS in the makefile and make one of the simple examples that come with the SDK. That will generate assembly files for everything. That's the best way to figure all that out.
Back to top
View user's profile Send private message AIM Address
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Fri Jul 17, 2009 5:56 am    Post subject: Reply with quote

Done JF thx a lot. I was studying mips assembler with a emulator called
yams. But there was a lot of pseudo code generated that are elf related and not
mips related like progbits etc ...(thx m0skit0 for the explantion)
The purpose was just to make a hello world in asm working on the psp on en 3.x firmware.

nb: I was obliged to add the -c so the linkedit is not performed and the .S file
is not deleted but if you do that you must also see at the source of the crt0.s
of the sdk to have a working sample ;)

psp-gcc -I/home/f731/pspdev/psp/sdk/include -O2 -G0 -Wall -c -S main.c
Back to top
View user's profile Send private message Send e-mail MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Fri Jul 17, 2009 8:40 am    Post subject: Reply with quote

Oh, yeah - I keep forgetting you need to put those two switches together. :)
Back to top
View user's profile Send private message AIM Address
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Jul 18, 2009 3:32 am    Post subject: Reply with quote

When building a program as an ELF it uses _start (for legacy reasons) when building a prx it uses module_start (for crazy reasons)
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