elf2x - A proper GCC ELF to PS-EXE converter

Downloadable items posted by PSXDEV members are within this forum.
Post Reply
User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

elf2x - A proper GCC ELF to PS-EXE converter

Post by LameGuy64 » September 26th, 2018, 5:29 pm

I wrote this little tool when I experimented with creating my own SDK (called PSn00bSDK) using the latest GCC toolchain to produce PlayStation executables as PSXSDK's elf2exe never seemed to work for me. Plus it didn't really look like a good converter to me judging by its source code which simply runs objdump and captures its output.

elf2x does proper conversion as it extracts relevant sections straight from the ELF file itself. The converter is also aware of the ELF file's load location allowing control of where the executable will be loaded to.

You may need to modify your makefile for your executable to come out properly with this converter which is just a simple matter of adding a -Ttext parameter which is equivalent to the -Xo parameter in the official SDK's ccpsx compiler (which is based on GCC 2.7.2 or 2.8.1).

Code: Select all

For ld:
mipsel-unknown-elf-ld -Ttext=0x80010000 main.o -o myprog.elf

For gcc/g++:
mipsel-unknown-elf-gcc -Wl,-Ttext=0x80010000 main.o -o myprog.elf
You do not have the required permissions to view the files attached to this post.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

Orion_
Verified
Legendary Programmer
Legendary Programmer
Posts: 240
Joined: Aug 13, 2012
I am a: Programmer
PlayStation Model: Net Yaroze
Location: France
Contact:

Post by Orion_ » September 26th, 2018, 8:43 pm

I tried to compile the source with CodeBlocks, this avoid huge DLLs.
But since it's C++ the final exe is still > 400Kbytes
then I tried to convert your source file to standard C (which is trivial), and then the final exe is now 11Kbytes
sorry to be a maniac of size, but I really don't understand why we waste so much space in trade for laziness.
C++ is not required for your program, 95% of your code is standard C.
Anyway, it's a nice tool you made, thanks for sharing.
Retro game development on Playstation and other consoles http://orionsoft.free.fr/

User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Post by LameGuy64 » September 27th, 2018, 10:04 am

That's sadly where tech seems to be heading... Bloat is the future.

I could've used malloc and realloc instead of std::vector but I made this as a quick little tool mostly.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

Orion_
Verified
Legendary Programmer
Legendary Programmer
Posts: 240
Joined: Aug 13, 2012
I am a: Programmer
PlayStation Model: Net Yaroze
Location: France
Contact:

Post by Orion_ » October 3rd, 2018, 5:56 am

Here is the C port of your program, the final exe is only 11kbytes without the need of any DLL (compiled using codeblocks)
http://onorisoft.free.fr/psx/elf2x.zip

I only made a small typo correction in the PS-EXE header string, replaced "Endoresed" by "Endorsed"

I tested it using the PSP SDK from DevKitPro, the cool thing with this SDK is that it support MIPS1 and it's a more recent GCC version 4.3.5 !
You can compil using this command:
psp-gcc -mips1 -c main.c -o main.o
psp-ld -Ttext=0x80010000 main.o -o myprog.elf
elf2x myprog.elf
Retro game development on Playstation and other consoles http://orionsoft.free.fr/

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests