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 nixpkgs/examples.nix at 4e211c1b09e70a1c4d0c164ea51497fd31c30c0b ¡ NixOS/nixpkgs ¡ GitHub .
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:
- I have a hard time understanding what nixpkgs/examples.nix at 4e211c1b09e70a1c4d0c164ea51497fd31c30c0b ¡ NixOS/nixpkgs ¡ GitHub actually declares. What do the keys of the attrsets represent? Whatâs the difference with, and how does that relate to the nixpkgs/platforms.nix at 4e211c1b09e70a1c4d0c164ea51497fd31c30c0b ¡ NixOS/nixpkgs ¡ GitHub?
- What do I need to do to be able to add an entry to it?