[Vm-dev] [Pharo-users] VM/Image magic numbers (Re: Pharo 6 snap install)

K K Subbu kksubbu.ml at gmail.com
Wed Apr 19 10:35:37 UTC 2017

On Wednesday 19 April 2017 02:41 AM, Luke Gorrie wrote:

> I would really like a copy of the script that checks the magic number
> and starts the right VM. David, could you share yours please?

You can use the binfmt_misc kernel module to get the kernel to launch 
the right VM. binfmt_misc is already loaded on all recent linux kernels 
for running qemu and python bytecodes, so you should be able to register 
image patterns directly in /proc/sys/fs/binfmt_misc/register or through 
update-binfmts utility.

$ sudo update-binfmts --install spur64 /usr/bin64/spur --offset 0 
--magic '\xb5\x09\x01\x00'
will install the interpreter spur64 running from /usr/bin64/spur to run 
64-bit little-endian files (magic 68021)

$ sudo update-binfmts --remove spur64 /usr/bin64/spur

For you own testing, you can use this alias

$ alias sqmagic='od -An -N4 -t x1'
$ alias sqmagic64='od -An -j4 -N4 -t x1'
for 64-bit bigendian images

You may want to filter the output through "tr -d ' '" to eliminate the 

HTH .. Subbu

More information about the Vm-dev mailing list