-
Notifications
You must be signed in to change notification settings - Fork 138
MIPS binutils
For creating MIPS or RISC-V test traces we use GNU binutils: assembler, linker, and objdump. Usually they are provided for the same architecture as a host machine, but we can build them for cross-compiling, ie generating MIPS programs on x86 machines.
This instruction is for MIPS binutils. to get binutils for RISC-V, follow this instruction.
If you use Debian or Ubuntu (including Windows Linux Subsystem), you may get package with APT:
sudo apt-get install binutils-mips-linux-gnu
For Ubuntu 12.04 and older and Debian, you have to add repositories:
deb https://ftp.de.debian.org/debian squeeze main
deb https://www.emdebian.org/debian squeeze main
If you use OS X, MSys, or other operating systems, you have to build GNU binutils by your own.
This cheat-sheet is based on this following instruction: https://www.linux-mips.org/wiki/Toolchains#Roll-your-own. See it if you have any problem or need more information.
Note: this instruction works only for Linux machines. It was verified on Ubuntu 12.04.1 LTS (GNU/Linux 2.6.32-042stab084.26 x86_64) . |
---|
# Install prerequisites
sudo apt-get install bison flex texinfo
# Download binutils sources from gnu.org FTP server:
wget https://ftp.gnu.org/gnu/binutils/binutils-2.31.tar.bz2
tar xjf binutils-2.31.tar.bz2
# Alternatively, you may clone them with Git:
# git clone git://sourceware.org/git/binutils-gdb.git --branch binutils-2_31
# Create a folder where the binutils will be installed (can be any)
mkdir /opt/cross
# Create a folder for a build process (can be any):
cd /tmp
mkdir build-binutils && cd build-binutils
# Configure build (can dump a lot of info):
# Note that we disabled build of `gprof` and `gdb` as we do not use them.
/path/to/binutils/configure --target=mips-linux-gnu --prefix=/opt/cross --disable-gprof --disable-gdb --disable-werror
# Make sources (can dump a lot of info):
make
# Install (can dump a lot of info, usually requires sudo):
sudo make install
# Update PATH variable to have binaries available:
export PATH=$PATH;/opt/cross/bin
- Create a file with assembler code and save it as
<test name>.s
Note: Specify __start: before the first instruction of your program. This is required by mipt-mips to find a starting point of execution. |
---|
- Generate an object file:
mips-linux-gnu-as <test name>.s -o <test name>.o
- Convert the object file into the binary file:
mips-linux-gnu-ld <test name>.o -o <test name>.out
- (optional) Look the content of .out using (pay attention only to .text section):
mips-linux-gnu-objdump -D <test name>.out
Look for more information here: https://github.com/MIPT-ILab/mips-traces
MIPT-V / MIPT-MIPS — Cycle-accurate pre-silicon simulation.