Skip to content

MIPS binutils

Pavel I. Kryukov edited this page May 25, 2018 · 26 revisions

Introduction

For creating MIPS 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.


Get GNU Binutils from package repository

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 http://ftp.de.debian.org/debian squeeze main
deb http://www.emdebian.org/debian squeeze main

Build Binutils manually

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: http://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 prerequisties

Binutils build requires some tools which may be not installed on your home system. It is advised to run a following command before build:

sudo apt-get install bison flex texinfo
  • Get binutils sources

Binutils sources are available as submodule in MIPT-MIPS:

git submodule init
git submodule update
cd binutils

Alternatively, you may download sources from gnu.org FTP server

  • 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):
/path/to/binutils/configure --target=mips-linux-gnu --prefix=/opt/cross --disable-gprof --disable-gdb --disable-werror

Note that we disabled build of gprof and gdb as we do not use them.

  • Make sources (can dump a lot of info):
make
  • Install (can dump a lot of info, usually requires sudo):
make install

After that you should now have the cross-binutils installed under /opt/cross/bin/ with names prefixed by mips-linux-gnu-. Add them to PATH variable to have available:

export PATH=$PATH;/opt/cross/bin

Clone this wiki locally