I've been wanting to make a guide for setup compilation environment for COBRA payload (cell binaries),
ever since I learned through efforts and helps from many other developers, I began to think it would be nice to share my experience with
you all just in case if anyone wants to compile their own Cobra payload with available sources.
This is W.I.P. meaning work-in-process, so this guide will continuously be updated hopefully one day I could write a full tutorial of how to port cobra for different fw versions.
By the way @haxxxen @_NzV_ did nice job on porting Cobra to psl1ght, so maybe this guide seems not really needed but this was how originally done from long ago, also backward compatible with all cobra sources including @haxxxen 's 4.21 / 7.1, which is why I keep insist on using this.
Maybe in near future I should try port my own with psl1ght and make another guide like this but that's just a thought anyways let's start.
The original guide
COBRA 7.00 - PSX-Scene
The cobra dev wrote this really really well, and this is like a bible to me, I've read this about maybe more than 30 times, and still it gives me new info everytime I read this. Maybe I'm just dumb.. lol
This guide is based on this sentence
The source code of components is in SRC folder. The main components of Cobra expect the toolchain found at BSC page, with gcc 4.1.1. install all ppu* files for your architecture.
This was way too short for me at the beginning, so I'd assume some people may feel like how I felt, so that was one of those reason I decided to write this guide. :)
Requirement
1. Windows + Virtual Machine such as Virtual Box or VMWare or native Fedora
- VMware Virtualization for Desktop & Server, Application, Public & Hybrid Clouds | United States
- https://www.virtualbox.org/
You can use Windows + VM or just Native Fedora on dual boot system if you ever intend to do.
Currently I installed Fedora 22 LXDE edition on my netbook and KDE version via VM / Windows 8.1 on my desktop.
2. Fedora 22 LiveCD or pre-installed VM image
- Fedora official website
https://getfedora.org/en/workstation/download/
- Pre-installed Fedora 22 VM image link
Fedora Virtual Machine
************************************************** ****************
[EXPRESS SETUP] here is a VM image with Fedora7 that has all the necessary pre-compiled CELL SDK3 toolchain + compilers with this VM image you can skip the step 3. and 4. which some may find trouble some.
Thanks @haxxxen for providing the link
http://www.mmnt.net/db/0/0/ftp.daimi...andra/IBM-Cell
![]()
************************************************** ****************
Either one works fine, you can setup the whole OS from the scratch just to have fun with, or get the one that's ready-to-boot but you still need to install CELL SDK as well.
3. CELL SDK 3.0 or 3.1 [at your choice]
Reference : Cell Programming IBM - PS3 Developer wiki
- 3.0 rpm packages
BSC File List: Browsing - /projects/deepcomputing/linuxoncell/cellsimulator/sdk3.0/custom/header.html
- 3.1 rpm packages
LINK 1
http://www.bsc.es/projects/deepcompu...Fedora/x86_64/
LINK 2 the full package Uploaded on mediafire
http://www.mediafire.com/download/tk.../cellsdk31.rar
NOTE
![]()
The Cobra dev recommended gcc 4.1.1, however from my experience, gcc version didn't really matter, you can start with what's recommended and make an adjustment to your dev environment at your choice.
My current setup is Fedora 22 64bit + CellSDK 3.1 + ppu-gcc 4.1.1 version, [native gcc compiler is already included when you install the official fedora package, however that's not enough to compile cobra payload source.]
Download/Install all those ppu rpm packages, and then install all of them. I think gcc-fortran wasn't needed besides you will have an issue with installation due to dependency, so forget about it if it ever gives you any issue.
4. Setup an environment path for the toolchain
You need to edit .bashrc file from your HOME folder, it's hidden file so you need to make it shown to edit with any text editor
![]()
So put this inside the file
5. Place pre-compiled scetool inside /usr/bin/ folder.
in case you're getting a compilation error from stage1
Place pre-compiled scetool inside /usr/bin/ folder.
You generally don't have an access to this path, so you need to get "root" access first by typing
"sudo -s" on terminal, then do
"chmod 777 /usr/bin/" then you can place scetool in that path.
also in case of you're getting key errors while compiling stage1
make sure to put data folder that has all the up-to-date keys for kernel signing process
FYI, my sources on github already includes this pre-compiled scetool and data folder with keys
There you go, now you're ready to compile COBRA sources :)
here is my log from a compilation of stage2
[joonx86@localhost stage2]$ make dbg
make -f Makefile_475D_DEBUG --no-print-directory
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o start.o start.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ps3mapi_core.o ps3mapi_core.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o main.o main.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o crypto.o crypto.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o modulespatch.o modulespatch.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o config.o config.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o drm.o drm.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o psp_s.o psp_s.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o mappath.o mappath.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o storage_ext.o storage_ext.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o region.o region.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o psp.o psp.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o cobra.o cobra.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o permissions.o permissions.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o sm_ext.o sm_ext.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/usb.o ../lv2/src/usb.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/patch.o ../lv2/src/patch.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/interrupt.o ../lv2/src/interrupt.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/interrupt_c.o ../lv2/src/interrupt_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/io.o ../lv2/src/io.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/libc.o ../lv2/src/libc.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/libc_c.o ../lv2/src/libc_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/memory.o ../lv2/src/memory.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/memory_c.o ../lv2/src/memory_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/thread.o ../lv2/src/thread.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/thread_c.o ../lv2/src/thread_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/process.o ../lv2/src/process.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/synchronization.o ../lv2/src/synchronization.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/modules.o ../lv2/src/modules.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/modules_c.o ../lv2/src/modules_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/storage.o ../lv2/src/storage.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/object.o ../lv2/src/object.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/security.o ../lv2/src/security.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/time.o ../lv2/src/time.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/hid.o ../lv2/src/hid.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/pad.o ../lv2/src/pad.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/syscall.o ../lv2/src/syscall.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv1/src/hvcall.o ../lv1/src/hvcall.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv1/src/stor.o ../lv1/src/stor.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv1/src/device.o ../lv1/src/device.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o laboratory.o laboratory.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../debug/src/debug.o ../debug/src/debug.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../debug/src/printf.o ../debug/src/printf.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../debug/src/debug_util.o ../debug/src/debug_util.c
ppu-gcc -T stage2.ld -nostartfiles -nostdlib -nodefaultlibs -Wl,-static -L. -Wl,--gc-sections -Wl,-Map=stage2.map -o stage2.elf start.o ps3mapi_core.o main.o crypto.o modulespatch.o config.o drm.o psp_s.o mappath.o storage_ext.o region.o psp.o cobra.o permissions.o sm_ext.o ../lv2/src/usb.o ../lv2/src/patch.o ../lv2/src/interrupt.o ../lv2/src/interrupt_c.o ../lv2/src/io.o ../lv2/src/libc.o ../lv2/src/libc_c.o ../lv2/src/memory.o ../lv2/src/memory_c.o ../lv2/src/thread.o ../lv2/src/thread_c.o ../lv2/src/process.o ../lv2/src/synchronization.o ../lv2/src/modules.o ../lv2/src/modules_c.o ../lv2/src/storage.o ../lv2/src/object.o ../lv2/src/security.o ../lv2/src/time.o ../lv2/src/hid.o ../lv2/src/pad.o ../lv2/src/syscall.o ../lv1/src/hvcall.o ../lv1/src/stor.o ../lv1/src/device.o laboratory.o ../debug/src/debug.o ../debug/src/printf.o ../debug/src/debug_util.o
ppu-objcopy -O binary stage2.elf stage2.dex.debug
rm -f *.o *.elf *.bin *.map *.lzma ../lv2/src/*.o ../lv1/src/*.o ../debug/src/*.o
Hope this helped!
Many thanks to @evilsperm @haxxxen and @habib for sharing awesome tips :)
ever since I learned through efforts and helps from many other developers, I began to think it would be nice to share my experience with
you all just in case if anyone wants to compile their own Cobra payload with available sources.
This is W.I.P. meaning work-in-process, so this guide will continuously be updated hopefully one day I could write a full tutorial of how to port cobra for different fw versions.
By the way @haxxxen @_NzV_ did nice job on porting Cobra to psl1ght, so maybe this guide seems not really needed but this was how originally done from long ago, also backward compatible with all cobra sources including @haxxxen 's 4.21 / 7.1, which is why I keep insist on using this.
Maybe in near future I should try port my own with psl1ght and make another guide like this but that's just a thought anyways let's start.
The original guide
COBRA 7.00 - PSX-Scene
The cobra dev wrote this really really well, and this is like a bible to me, I've read this about maybe more than 30 times, and still it gives me new info everytime I read this. Maybe I'm just dumb.. lol
This guide is based on this sentence
Quote:
The source code of components is in SRC folder. The main components of Cobra expect the toolchain found at BSC page, with gcc 4.1.1. install all ppu* files for your architecture.
Requirement
1. Windows + Virtual Machine such as Virtual Box or VMWare or native Fedora
- VMware Virtualization for Desktop & Server, Application, Public & Hybrid Clouds | United States
- https://www.virtualbox.org/
You can use Windows + VM or just Native Fedora on dual boot system if you ever intend to do.
Currently I installed Fedora 22 LXDE edition on my netbook and KDE version via VM / Windows 8.1 on my desktop.
2. Fedora 22 LiveCD or pre-installed VM image
- Fedora official website
https://getfedora.org/en/workstation/download/
- Pre-installed Fedora 22 VM image link
Fedora Virtual Machine
************************************************** ****************
Spoiler
[EXPRESS SETUP] here is a VM image with Fedora7 that has all the necessary pre-compiled CELL SDK3 toolchain + compilers with this VM image you can skip the step 3. and 4. which some may find trouble some.
Thanks @haxxxen for providing the link
http://www.mmnt.net/db/0/0/ftp.daimi...andra/IBM-Cell

************************************************** ****************
Either one works fine, you can setup the whole OS from the scratch just to have fun with, or get the one that's ready-to-boot but you still need to install CELL SDK as well.
3. CELL SDK 3.0 or 3.1 [at your choice]
Reference : Cell Programming IBM - PS3 Developer wiki
- 3.0 rpm packages
BSC File List: Browsing - /projects/deepcomputing/linuxoncell/cellsimulator/sdk3.0/custom/header.html
- 3.1 rpm packages
LINK 1
http://www.bsc.es/projects/deepcompu...Fedora/x86_64/
LINK 2 the full package Uploaded on mediafire
http://www.mediafire.com/download/tk.../cellsdk31.rar
NOTE

The Cobra dev recommended gcc 4.1.1, however from my experience, gcc version didn't really matter, you can start with what's recommended and make an adjustment to your dev environment at your choice.
My current setup is Fedora 22 64bit + CellSDK 3.1 + ppu-gcc 4.1.1 version, [native gcc compiler is already included when you install the official fedora package, however that's not enough to compile cobra payload source.]
Download/Install all those ppu rpm packages, and then install all of them. I think gcc-fortran wasn't needed besides you will have an issue with installation due to dependency, so forget about it if it ever gives you any issue.
4. Setup an environment path for the toolchain
You need to edit .bashrc file from your HOME folder, it's hidden file so you need to make it shown to edit with any text editor

So put this inside the file
Code:
# CELL SDK 3.1 Path
export PATH=$PATH:/opt/ibm/systemsim-cell/bin:/opt/cell/toolchain/bin
in case you're getting a compilation error from stage1
Code:
sh: scetool: command not found
Cannot open temp.elf
Makefile_475C:44: recipe for target 'stage1_475C.bin' failed
make[1]: *** [stage1_475C.bin] Error 255
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2
You generally don't have an access to this path, so you need to get "root" access first by typing
"sudo -s" on terminal, then do
"chmod 777 /usr/bin/" then you can place scetool in that path.
also in case of you're getting key errors while compiling stage1
make sure to put data folder that has all the up-to-date keys for kernel signing process
FYI, my sources on github already includes this pre-compiled scetool and data folder with keys
There you go, now you're ready to compile COBRA sources :)
here is my log from a compilation of stage2
Spoiler
[joonx86@localhost stage2]$ make dbg
make -f Makefile_475D_DEBUG --no-print-directory
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o start.o start.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ps3mapi_core.o ps3mapi_core.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o main.o main.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o crypto.o crypto.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o modulespatch.o modulespatch.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o config.o config.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o drm.o drm.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o psp_s.o psp_s.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o mappath.o mappath.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o storage_ext.o storage_ext.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o region.o region.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o psp.o psp.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o cobra.o cobra.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o permissions.o permissions.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o sm_ext.o sm_ext.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/usb.o ../lv2/src/usb.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/patch.o ../lv2/src/patch.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/interrupt.o ../lv2/src/interrupt.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/interrupt_c.o ../lv2/src/interrupt_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/io.o ../lv2/src/io.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/libc.o ../lv2/src/libc.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/libc_c.o ../lv2/src/libc_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/memory.o ../lv2/src/memory.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/memory_c.o ../lv2/src/memory_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/thread.o ../lv2/src/thread.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/thread_c.o ../lv2/src/thread_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/process.o ../lv2/src/process.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/synchronization.o ../lv2/src/synchronization.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/modules.o ../lv2/src/modules.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/modules_c.o ../lv2/src/modules_c.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/storage.o ../lv2/src/storage.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/object.o ../lv2/src/object.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/security.o ../lv2/src/security.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/time.o ../lv2/src/time.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/hid.o ../lv2/src/hid.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/pad.o ../lv2/src/pad.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv2/src/syscall.o ../lv2/src/syscall.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv1/src/hvcall.o ../lv1/src/hvcall.S
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv1/src/stor.o ../lv1/src/stor.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../lv1/src/device.o ../lv1/src/device.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o laboratory.o laboratory.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../debug/src/debug.o ../debug/src/debug.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../debug/src/printf.o ../debug/src/printf.c
ppu-gcc -ffunction-sections -fdata-sections -Os -m64 -fno-builtin -fno-exceptions -Os -Wall -Wno-strict-aliasing -Wno-multichar -I../lv2/include -I../lv1/include -I../cryptcode/include -I../debug/include -DLV2 -DFIRMWARE_4_75DEX -DCFW -DUSE_LV1_PEEK_POKE -ffreestanding --std=gnu99 -DDEBUG -DTEST -c -o ../debug/src/debug_util.o ../debug/src/debug_util.c
ppu-gcc -T stage2.ld -nostartfiles -nostdlib -nodefaultlibs -Wl,-static -L. -Wl,--gc-sections -Wl,-Map=stage2.map -o stage2.elf start.o ps3mapi_core.o main.o crypto.o modulespatch.o config.o drm.o psp_s.o mappath.o storage_ext.o region.o psp.o cobra.o permissions.o sm_ext.o ../lv2/src/usb.o ../lv2/src/patch.o ../lv2/src/interrupt.o ../lv2/src/interrupt_c.o ../lv2/src/io.o ../lv2/src/libc.o ../lv2/src/libc_c.o ../lv2/src/memory.o ../lv2/src/memory_c.o ../lv2/src/thread.o ../lv2/src/thread_c.o ../lv2/src/process.o ../lv2/src/synchronization.o ../lv2/src/modules.o ../lv2/src/modules_c.o ../lv2/src/storage.o ../lv2/src/object.o ../lv2/src/security.o ../lv2/src/time.o ../lv2/src/hid.o ../lv2/src/pad.o ../lv2/src/syscall.o ../lv1/src/hvcall.o ../lv1/src/stor.o ../lv1/src/device.o laboratory.o ../debug/src/debug.o ../debug/src/printf.o ../debug/src/debug_util.o
ppu-objcopy -O binary stage2.elf stage2.dex.debug
rm -f *.o *.elf *.bin *.map *.lzma ../lv2/src/*.o ../lv1/src/*.o ../debug/src/*.o
Hope this helped!
Many thanks to @evilsperm @haxxxen and @habib for sharing awesome tips :)