From Virtualsquare
Jump to: navigation, search

The umbinfmt module can be loaded in the usual way:

$ um_add_service umbinfmt

Using Qemu to run foreign code

Mount umbinfmt on a directory, mounting it on the directory used by the kernel binfmt support makes all the existing binfmt scripts compatible with umbinfmt.

$ mount -t umbinfmt none /proc/sys/fs/binfmt_misc

The following commands:

$ echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x
ff\xff:/usr/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register
$ echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x
ff\xff:/usr/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register

define the emulators to be invoked when an exec system call tries to load ppc or arm executables. (each echo command must be typed on a single line. The commands have been split on several lines just to fit in the example box). It is also possible to use the script provided with Qemu sources commenting out the kernel module loading command: /sbin/modprobe binfmt_misc.

It is possible in this way to run foreign executables

$ uname -a
Linux [...] i686 GNU/Linux
$ file ./ls
./ls: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for GN
U/Linux 2.2.0, dynamically linked (uses shared libs), stripped
$ ./ls /
bin         etc         lost+found  proc        tmp
boot        lib         mnt         sbin        usr
Personal tools