On 07/15/2014 01:45 PM, Ilya Palachev wrote:
Hi, all.
I have found that package "qemu-accel-armv7l-cross-arm" contains
directory /emul/i586-for-arm/ with cross utilities that accelerate the
build.
Could you explain, how does this construction work?
For example, there are 2 binaries in the chroot environemt:
bash-4.2# file /usr/bin/make
/usr/bin/make: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.16,
BuildID[sha1]=0xe1ed5cff83cb3973a9b8ed363857cd796dba63cf, not stripped
bash-4.2# file /emul/i586-for-arm/usr/bin/make
/emul/i586-for-arm/usr/bin/make: ELF 32-bit LSB executable, Intel
80386, version 1 (SYSV), dynamically linked (uses shared libs), for
GNU/Linux 2.6.16,
BuildID[sha1]=0x90f51594906fdc9f7906c7e119ba8703a616d4b8, not stripped
bash-4.2# whereis make
make: /usr/bin/make /usr/share/man/man1/make.1.gz
bash-4.2# LD_DEBUG=all make 2>&1 | tail -10
27438: binding file make [0] to /emul/i586-for-arm/lib/libc.so.6
[0]: normal symbol `exit' [GLIBC_2.0]
27438: symbol=ferror; lookup in file=make [0]
27438: symbol=ferror; lookup in
file=/emul/i586-for-arm/lib/libc.so.6 [0]
27438: binding file make [0] to /emul/i586-for-arm/lib/libc.so.6
[0]: normal symbol `ferror' [GLIBC_2.0]
27438: symbol=fclose; lookup in file=make [0]
27438: symbol=fclose; lookup in
file=/emul/i586-for-arm/lib/libc.so.6 [0]
27438: binding file make [0] to /emul/i586-for-arm/lib/libc.so.6
[0]: normal symbol `fclose' [GLIBC_2.1]
27438:
27438: calling fini: make [0]
27438:
"whereis" says that "make" is taken from /usr/bin/, but ld.so says
that it is taken from /emul/i586-for-arm/usr/bin/, so we have cross
accelerated executable "make".
How does this work?
ARM binaries don't run natively on x86. So instead when we see an ARM
binary, we execute a binfmt_misc handler instead. Our binfmt_misc
handler (qemu-arm-binfmt) checks whether /emul/i586-for-arm/$0 exists.
If it does, it executes that one. If it doesn't, it calls qemu-arm with $@.
For the glorious details, check out
https://github.com/openSUSE/qemu/blob/opensuse-2.1/linux-user/binfmt.c
Alex
--
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]