Wishing for `pkgsCross.mips*` to exist, failed to contribute it

My need

I am doing binary analysis, and sometimes, I get a binary that is not targeting my host architecture.
For example:

$ file binary.exe
binary.exe: ELF 32-bit MSB executable, MIPS, MIPS-I version 1 (SYSV), statically linked, not stripped

As you can see, it is a binary targeting MIPS 32 bits, in big endian.

Now, as part of my flow, I need to use some of the binutils tools to help me analyse and exploit this binary (mips-linux-as, mips-linux-objdump, etc.).

A potential solution

For other architectures, for example ARM, I usually get away with using pkgsCross.arm-embedded.buildPackages.binutils.

With this, arm-none-eabi-* commands become available.
(And I use makeWrapper to have arm-linux-gnu-* that are more “debian-like” and expected by some tools - see `pythonPackages.pwntools` needs cross-compiled version of `binutils` · Issue #87978 · NixOS/nixpkgs · GitHub)

Sadly there isn’t any pkgsCross.mips* in nixpkgs…

A naive try

It seems that pkgsCross is built using the content of https://github.com/NixOS/nixpkgs/blob/4e211c1b09e70a1c4d0c164ea51497fd31c30c0b/lib/systems/examples.nix .

I tried to add mips32 = { config = "mips-unknown-linux-gnu"; }; to it, but then, when I try to use it, I get the following error:

nix-shell -p pkgsCross.mips32.buildPackages.binutils
error: --- ThrownError --------------------------------------------------------------------------------------------- nix-shell
Package ‘glibc-2.32-46’ in /home/pamplemousse/Workspace/tools/nixpkgs/pkgs/development/libraries/glibc/default.nix:149 is not supported on ‘mips-linux’, refusing to evaluate.
[...]
(use '--show-trace' to show detailed location information)

Questions

So, here are my questions:

2 Likes