View previous topic :: View next topic |
Author |
Message |
dinominant Tux's lil' helper
Joined: 27 Oct 2006 Posts: 102
|
Posted: Wed Nov 26, 2014 5:36 pm Post subject: x86_64 and/or i686 chroot on arm host |
|
|
Similar to my other post arm chroot on x86_64 host I am now trying to get my x86_64 chroot working on my arm host (it's actually a raspberry pi). I followed the same procedure and I can run the x86_64 binaries on the arm host, but I cannot chroot into the x86_64 environment.
Running statically linked x86_64 binaries works if I call them manually: Code: | host03 ~ # uname -a
Linux host03 3.12.33 #1 PREEMPT Mon Nov 24 09:31:14 MST 2014 armv6l BCM2708 GNU/Linux
host03 ~ # file /usr/bin/qemu-x86_64
/usr/bin/qemu-x86_64: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=7f186e8257479d38f029c931a94f488878e8dfbe, stripped
host03 ~ # file x86_64-test/bin/busybox
x86_64-test/bin/busybox: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, stripped
host03 ~ # /usr/bin/qemu-x86_64 x86_64-test/bin/busybox cp
BusyBox v1.21.0 (2014-11-10 01:41:36 MST) multi-call binary.
Usage: cp [OPTIONS] SOURCE... DEST
Copy SOURCE(s) to DEST
-a Same as -dpR
-R,-r Recurse
-d,-P Preserve symlinks (default if -R)
-L Follow all symlinks
-H Follow symlinks on command line
-p Preserve file attributes if possible
-f Overwrite
-i Prompt before overwrite
-l,-s Create (sym)links |
However when I chroot into the x86_64 environment I get this error: Code: | host03 ~ # mount -t proc none x86_64-test/proc
host03 ~ # mount --rbind /dev x86_64-test/dev
host03 ~ # mount --rbind /sys x86_64-test/sys
host03 ~ # chroot x86_64-test /bin/bash
chroot: failed to run command ‘/bin/bash’: Exec format error |
Looking at /etc/init.d/qemu-binfmt on the arm host I can see that the magic bits for x86_64 binaries are missing: Code: | # probe cpu type
cpu=`uname -m`
case "$cpu" in
i386|i486|i586|i686|i86pc|BePC|x86_64)
cpu="i386"
;;
armv[4-9]*)
cpu="arm"
;;
esac
# register the interpreter for each cpu except for the native one
if [ $cpu != "i386" -a -x "/usr/bin/qemu-i386" ] ; then
echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "arm" -a -x "/usr/bin/qemu-arm" ] ; then
echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "arm" -a -x "/usr/bin/qemu-armeb" ] ; then
echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb:'"${QEMU_BINFMT_FLAGS}" > /proc/sys/fs/binfmt_misc/register
fi
eend $?
} |
Where can I find those magic bits? I would like to run x86_64 binaries on my raspberri pi (and other arm devices like my tablet) transparently. It would be great if we can get this patched too. Having any binary work on any platform would be fantastic for development purposes.
Last edited by dinominant on Fri Nov 28, 2014 11:40 pm; edited 1 time in total |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Wed Nov 26, 2014 6:12 pm Post subject: |
|
|
Try out the following
Code: |
echo ':x86_64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-x86_64:P' > /proc/sys/fs/binfmt_misc/register
|
and if it works, create a patch for /usr/portage/app-emulation/qemu/files/qemu-binfmt.initd-r1 and file a bug with it attached. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54644 Location: 56N 3W
|
Posted: Wed Nov 26, 2014 9:02 pm Post subject: |
|
|
dinominant,
'Run' is going to be an exaggeration but it might crawl :)
You want to run 64 bit code in an emulator running a 32 bit, in the case of the Pi, CPU.
Good luck.
Still, I remember 32 bit software floating point running on a 8 bit CPU. It was a 6502. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
dinominant Tux's lil' helper
Joined: 27 Oct 2006 Posts: 102
|
Posted: Thu Nov 27, 2014 12:11 am Post subject: |
|
|
Thanks heiwa, I'm making progress
I can now transparently run x86_64 statically linked binaries on arm: Code: | host03 ~ # uname -a
Linux host03 3.12.33 #1 PREEMPT Mon Nov 24 09:31:14 MST 2014 armv6l BCM2708 GNU/Linux
host03 ~ # file x86_64-test/bin/busybox
x86_64-test/bin/busybox: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, stripped
host03 ~ # x86_64-test/bin/busybox cp
BusyBox v1.21.0 (2014-11-10 01:41:36 MST) multi-call binary.
Usage: cp [OPTIONS] SOURCE... DEST
Copy SOURCE(s) to DEST
-a Same as -dpR
-R,-r Recurse
-d,-P Preserve symlinks (default if -R)
-L Follow all symlinks
-H Follow symlinks on command line
-p Preserve file attributes if possible
-f Overwrite
-i Prompt before overwrite
-l,-s Create (sym)links |
However, when I chroot into the environment I get a cryptic segfault. I'm not sure if it is qemu that is crashing or if it is the busybox binary: Code: | host03 ~ # chroot x86_64-test /bin/bash
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault |
It seems that I can run binaries in a 'transient' chroot: Code: | host03 ~ # chroot x86_64-test /bin/busybox cp
BusyBox v1.21.0 (2014-11-10 01:41:36 MST) multi-call binary.
Usage: cp [OPTIONS] SOURCE... DEST
Copy SOURCE(s) to DEST
-a Same as -dpR
-R,-r Recurse
-d,-P Preserve symlinks (default if -R)
-L Follow all symlinks
-H Follow symlinks on command line
-p Preserve file attributes if possible
-f Overwrite
-i Prompt before overwrite
-l,-s Create (sym)links |
But something about the dynamically linked /bin/bash is causing the segfault: Code: | host03 ~ # file x86_64-test/bin/bash
x86_64-test/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped
host03 ~ # chroot x86_64-test /bin/bash
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
host03 ~ # x86_64-test/bin/bash
/lib64/ld-linux-x86-64.so.2: No such file or directory |
It doesn't seem too painfully slow. A friend callenged me to get some windows applications running on the raspberry pi. I'm attempting to do it via a "wine in a x86_64 chroot on arm on pi" proof of concept. It may be slow, but it should work in theory. And who knows, maybe some things like Chip's Challenge will run half decently |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Thu Nov 27, 2014 3:12 am Post subject: |
|
|
If all you're doing it for is that, making a 64-bit chroot when it has to run wine 32-bit multilib anyway (if you can even get that setup to work) is kinda overkill... |
|
Back to top |
|
|
dinominant Tux's lil' helper
Joined: 27 Oct 2006 Posts: 102
|
Posted: Thu Nov 27, 2014 4:44 am Post subject: |
|
|
Ant P. wrote: | If all you're doing it for is that, making a 64-bit chroot when it has to run wine 32-bit multilib anyway (if you can even get that setup to work) is kinda overkill... |
I also have an x86 template that would probably be better to work with, I'll also test that too. Ideally I would like to be able to run any of x86, x86_64, and arm binaries on any one of the three platforms. |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Thu Nov 27, 2014 7:11 am Post subject: |
|
|
For further debugging, put a /bin/sh link to busybox into the chroot and chroot with /bin/sh. Then you should be able to explore better what is working in the chroot and what not. For debugging the dynamic linking problems, you can use 'qemu-x86_64 -strace' to test whether the dynamic linker is found and whether it finds the libraries. |
|
Back to top |
|
|
dinominant Tux's lil' helper
Joined: 27 Oct 2006 Posts: 102
|
Posted: Fri Nov 28, 2014 11:53 pm Post subject: |
|
|
I switched my focus to getting an i686 chroot working on my arm host since that will eliminate some complexity in getting wine to work. Once I get i686 working I'll spend some time trying to get the x86_64 chroot working on my raspberry pi.
So far the i686 chroot on arm is working. I can chroot into my i686 gentoo template on my raspberry pi and run applications |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|