Emulating Linux-MIPS in Perl - Part 4: Bits and Ends and Links
This is the final part, which ties together some loose ends and finally has some download links, too (I didn't know where best to put these files).
Download
I've provided three files - the emulator itself (run), which can run (some statically-linked, non-threaded) MIPS I binaries, and two versions of it that embed dash (dash.run) and bash (bash.run). The bash one takes its sweet while to start, especially if you have programmable completion enabled. The dash.run one should start reasonably quickly.
64 Bit Perls
The emulator needs a 64 bit perl (which is the standard nowadays even on 32 bit systems).
To ensure Perl does 64 bit integer types, it contains this line:
pack "Q", 5; # make sure it's a 64 bit perl
This dies ("Invalid type 'Q' in pack") on pure 32 bit perls.
Creating the standalone binaries
As seen in the first part, the emulator can either run MIPS binaries passed as first argument:
./run dash ...
Or it can embed a binary:
./dash.run ...
The versions with embedded binaries are trivial to create: the following shell script created dash.run
from run and bin/dash:
( cat run echo __DATA__ cat bin/dash ) >dash.run chmod 755 dash.run
A similar fragment works for other binaries.
And that...
... is it, for MIPS.