View Single Post
Old 10-24-2013, 09:57 PM   #13
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Lightbulb

building qemu-arm statically from GIT

Clone the latest qemu from git http://git.qemu.org/qemu.git, then configure and make it
cd ~/GIT/qemu/arm-linux-user

git clone http://git.qemu.org/qemu.git

cd qemu

./configure --target-list="arm-linux-user" --disable-kvm --disable-strip --disable-xen --disable-spice --disable-werror --prefix=/usr/local --disable-bsd-user --static

make; make install

Check if we NEED to register the type with binfmt_misc...
dev binfmt_misc # cat /proc/sys/fs/binfmt_misc/qemu-arm
Code:
enabled
interpreter /usr/bin/qemu-arm-static
flags: OC
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff00fffffffffffffffffeffffff
If this WASN'T populated... echo to register
(Only if the above is NOT already registered)
Code:
echo ":qemu-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\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm:" > /proc/sys/fs/binfmt_misc/register
(note that this stipulates /usr/local/bin/qemu-arm make that w/e you want)

since I already HAVE the debian version on my system move that binary it out the way and use that binfmt_misc registration for ourselves...

mv /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static-debian
cp /home/me/GIT/qemu/arm-linux-user/qemu-arm /usr/bin/qemu-arm-static

mount something we want to chroot into
sudo mount -t ext /home/me/IMAGES-FOR-DEBIAN/jessie.ext3 /mnt/jessie/

check what we built is kosher.
me@dev ~/GIT/qemu/arm-linux-user $ readelf -d ./qemu-arm
Quote:
There is no dynamic section in this file.
me@dev ~/GIT/qemu/arm-linux-user $ ./qemu-arm -version
Quote:
qemu-arm version 1.6.50, Copyright (c) 2003-2008 Fabrice Bellard
(as opposed to 1.0.50 in the repos)

me@dev ~/GIT/qemu/arm-linux-user $ ./qemu-arm --help
Spoiler:
Quote:
usage: qemu-arm [options] program [arguments...]
Linux CPU emulator (compiled for arm emulation)

Options and associated environment variables:

Argument Env-variable Description
-h print this help
-g port QEMU_GDB wait gdb connection to 'port'
-L path QEMU_LD_PREFIX set the elf interpreter prefix to 'path'
-s size QEMU_STACK_SIZE set the stack size to 'size' bytes
-cpu model QEMU_CPU select CPU (-cpu help for list)
-E var=value QEMU_SET_ENV sets targets environment variable (see below)
-U var QEMU_UNSET_ENV unsets targets environment variable (see below)
-0 argv0 QEMU_ARGV0 forces target process argv[0] to be 'argv0'
-r uname QEMU_UNAME set qemu uname release string to 'uname'
-B address QEMU_GUEST_BASE set guest_base address to 'address'
-R size QEMU_RESERVED_VA reserve 'size' bytes for guest virtual address space
-d item[,...] QEMU_LOG enable logging of specified items (use '-d help' for a list of items)
-D logfile QEMU_LOG_FILENAME write logs to 'logfile' (default stderr)
-p pagesize QEMU_PAGESIZE set the host page size to 'pagesize'
-singlestep QEMU_SINGLESTEP run in singlestep mode
-strace QEMU_STRACE log system calls
-version QEMU_VERSION display version information and exit

Defaults:
QEMU_LD_PREFIX = /usr/gnemul/qemu-arm
QEMU_STACK_SIZE = 8388608 byte

You can use -E and -U options or the QEMU_SET_ENV and
QEMU_UNSET_ENV environment variables to set and unset
environment variables for the target process.
It is possible to provide several variables by separating them
by commas in getsubopt(3) style. Additionally it is possible to
provide the -E and -U options multiple times.
The following lines are equivalent:
-E var1=val2 -E var2=val2 -U LD_PRELOAD -U LD_DEBUG
-E var1=val2,var2=val2 -U LD_PRELOAD,LD_DEBUG
QEMU_SET_ENV=var1=val2,var2=val2 QEMU_UNSET_ENV=LD_PRELOAD,LD_DEBUG
Note that if you provide several changes to a single variable
the last change will stay in effect.

copy it into our debian victim
cp /usr/bin/qemu-arm-static /home/me/IMAGES-FOR-DEBIAN/usr/bin/qemu-arm-static

chroot in

sudo chroot /mnt/debian /bin/bash

Quote:
root@dev:/#cat /etc/debian_version
jessie/sid
For reference...
Debian build log
https://buildd.debian.org/status/fet...amp=1322591568
What those build warnings mean to end users.
https://lists.gnu.org/archive/html/q.../msg04789.html

seems to work okay.

Last edited by twobob; 10-24-2013 at 10:03 PM.
twobob is offline   Reply With Quote