You can also use regular LLVM clang instead of gcc. No building from source or toolchain is required, just download it from here: Link
It has very good linker unlike armips that can do proper Link-Time Optimization and has C++ support from box.
I am using the following set of files to build things, I will notice several important things in forum: GitHub Repository
I mostly similar to GCC CFLAGS but I also add several important flags to remove exceptions, RTTI and some other useless MIPS stuff. Here are they
For linking I use ld.ldd with custom ldscript. You might want to change if you would like to make behaviors be at static place for example. In my example, I use the fact that 0x1200000 is DMACopy'd to 0x80400000 and I put my binaries to 0x1208000 with behavior being at the beginning. Extern symbols are specified in symbols.ld file which is based on frauber's answer and could be enlarged on demand. Headers I use are made to be C++ compliable with float triplet being put as a struct for convenience.
This is LD script I use for linking, to specify object file you could add another section and set it to needed object file like xd.o(.data)
The following way might be a bit harder in general for beginner but it has more power than armips+gcc. One can follow Makefile in repo for more in-depth information
It has very good linker unlike armips that can do proper Link-Time Optimization and has C++ support from box.
I am using the following set of files to build things, I will notice several important things in forum: GitHub Repository
I mostly similar to GCC CFLAGS but I also add several important flags to remove exceptions, RTTI and some other useless MIPS stuff. Here are they
Code:
CFLAGS = -Wall -Wdouble-promotion -Os -mtune=vr4300 -march=mips2 --target=mips-img-elf -fomit-frame-pointer -G0 -I $(INCLUDE_PATH) -mno-check-zero-division -fno-exceptions -fno-builtin -fno-rtti -fno-common -mno-abicalls
For linking I use ld.ldd with custom ldscript. You might want to change if you would like to make behaviors be at static place for example. In my example, I use the fact that 0x1200000 is DMACopy'd to 0x80400000 and I put my binaries to 0x1208000 with behavior being at the beginning. Extern symbols are specified in symbols.ld file which is based on frauber's answer and could be enlarged on demand. Headers I use are made to be C++ compliable with float triplet being put as a struct for convenience.
This is LD script I use for linking, to specify object file you could add another section and set it to needed object file like xd.o(.data)
Code:
INCLUDE symbols.ld
ENTRY(_start)
SECTIONS
{
.sm64 0x80408000 :
{
*(.data)
*(.data.*)
*(.bss)
*(.bss.*)
*(.text)
*(.text.*)
*(.rodata)
*(.rodata.*)
}
/DISCARD/ :
{
*(.MIPS.abiflags)
*(.gnu.attributes)
*(.mdebug.abi32)
*(.comment)
*(.pdr)
*(.reginfo)
}
}
The following way might be a bit harder in general for beginner but it has more power than armips+gcc. One can follow Makefile in repo for more in-depth information