Welcome! Log In Create A New Profile

Advanced

geckoloader / Loading and run the stub

Posted by ShovAge 
geckoloader / Loading and run the stub
January 15, 2009 06:55PM
Hello everyone,

I'm currently examining the source of geckoloader. (I want to learn how create a stub and a loader.)

So I examined the stub code and quickly the loader code.
All this code make sense for me

However regarding the boot code, I see these global variables at the beginning of the code :

extern u8 stub_bin[];
extern u32 stub_bin_size;
extern u8 loader_dol[];
extern u32 loader_dol_size;

But, I did not find where are defined these variables on the other source files.

In fact, I want to know how to load the stub code in the stub_bin[] array.
Because I have a stub.dol but this is a file, this is not in memory.

I assume that there's a way to push the stub code in a special section of the dol file.

How to do it ? And then how to use it ?

Could someone give me some clues ?

I hope that my question is making sense.
Maybe I'm totally wrong, (programming is just a hobby for me).

Regards,
ShovAge

Please ignore my poor english.
Re: geckoloader / Loading and run the stub
January 15, 2009 07:10PM
The stub and loader parts get compiled to .elf and objdump is used to extract the blobs to .bin. The toplevel Makefile then uses bin2s to make a compilable .S out of the .bins. Those get compiled by the boot part, it's just a way to include the blob in the resulting geckoloader.elf.

The externs you mentioned are in those .S files.
Re: geckoloader / Loading and run the stub
January 15, 2009 10:08PM
Thanks a lot for your help.
Your answer really helps.

If I'm right, the executable sections from stub and loader are extracted to a bin file.
Then this bin file is converted to an ASM source file.
Then these files are compiled in the same time than geckoloader and included in geckoloder.elf
That's it ?

I tried objdump on my linux box.
It seems that the original objdump is only used for the IA32 architecture.

So, I found the executable powerpc-gekko-objdump.
I do not really know how to use it.

I tried it:
powerpc-gekko-objdump --target=binary -d geckoloader.elf

I used -d because we have the following description in the help page:
-d, --disassemble Display assembler contents of executable sections

I assume that we have to set an architecture. The command give me these choices:
supported architectures: rs6000:6000 rs6000:rs1 rs6000:rsc rs6000:rs2 powerpc:common powerpc:common64 powerpc:603 powerpc:EC603e powerpc:604 powerpc:403 powerpc:601 powerpc:620 powerpc:630 powerpc:a35 powerpc:rs64ii powerpc:rs64iii powerpc:7400 powerpc:e500 powerpc:e500mc powerpc:MPC8XX powerpc:750

I did not suceed to extract the executable section. :/

And, I had a look on Makefiles to see when objdump is used without success.
Where can I found the comands on the Makefiles ?
And, withotu the Makefiles, how can I manually extract executable section and compile an other program with included .S files ?

Thanks again.

Rgds,
ShovAge
Re: geckoloader / Loading and run the stub
January 15, 2009 10:23PM
Uh-oh, my bad, its objcopy not objdump. For this toolchain you use powerpc-gekko-objcopy with the arguments "-O binary ", see stub/Makefile.
bin2s is included in devkitPPC, thats the tool you want to use to turn blobs into a .S to integrate it into another project.
Re: geckoloader / Loading and run the stub
January 15, 2009 10:51PM
Great !
That's working !

Happy to play with this new tool ! :)

Thanks for your help !
Sorry, only registered users may post in this forum.

Click here to login