In the Ubuntu environment, there are always some problems with the programs compiled with qemu, so use Buildroot to build an environment for compiling mips programs.
Download Buildroot
wget http://buildroot.uclibc.org/downloads/snapshots/buildroot-snapshot.tar.bz2
Unzip
tar -jxvf buildroot-snapshot.tar.bz2
Configure Buildroot
cd buildroot
sudo apt-get install libncurses5-dev patch
make clean
make menuconfig
An interface will appear
Choose Target options
Change Target Architecture to mips big endian
Then go back to the main interface, select Toolchain, and enter
Choose the kernel version of your current system
View version command
uname -a
After configuration, select save to save
Finally, compile
sudo make
After a long wait, after Buildroot is compiled, we will see the newly generated output directory
After entering the buildroot/output/host/bin
directory, you will see the file as shown below, indicating that the compilation has been successful
Test compilation environment
Ready to compile, to be compiled ~/Desktop/code
undervuln_system.c
In order to make the generated files do not rely on dynamic libraries, use here -static
for static compilation
After the compilation is complete, view the generated file
At this point, the environment installation is complete