The instructions are very precise, following them you get your statically linked
Just to be safe (in case the original source disappears), I'll back up the instructions for myself:
- Prerequisite: you already have downloaded Sourcery CodeBench Lite (which includes a free GNU toolchain and cross-compiler), make sure you select ARM GNU/Linux and then IA32 GNU/Linux.
- Download the strace source distribution from the SourceForge strace project.
- Extract the strace package on your linux machine.
- Set your compiler information:
export CFLAGS="-O2 -static"
CFLAGS is by default
-g -O2, but we need static linking and (optionally) no debug information. You can even leave out
-static, but in that case you'll have to ship the compiled executable with all the referenced shared libs from the cross compiler!
your_cross_compiler_folder/bin into your
- Change your current folder to the strace folder (where you extracted the source), use command:
Optionally you might want to specify a prefix with
- Verify the result (eg. static linking) with the command:
You shall see:
strace: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, statically linked, not stripped
- Optionally you can strip symbols from it with:
(if you only need the executable)
Or package it into a TGZ:
mkdir -p "$tmpdir/data/local"
make install-strip prefix="$tmpdir/data/local"
fakeroot -- sh -c "chmod -R a+rX,u+w,go-w data && chown -R root:root data && tar czf \"$packagefile\" data"
rm -rf "$tmpdir"
Done, you have another powerful tool for your Android.
To use it to trace an already running app (APK), run
to get the PID of the process, then use the
/data/local/bin/strace -p 4132
P.S.: I've made a few changes (imho optimizations) to the original instructions.
Update (2013.05.23): I've reapplied the same instructions to compile strace v4.7 with Sourcery CodeBench Lite 2013.05-24. I installed the latter with the linux installer (arm-2013.05-24-arm-none-linux-gnueabi.bin) in my user home directory on a 32-bit Ubuntu 10.10 (x86) server. I've attached the compiled TGZ package that you can simply extract into your filesystem and it'll put all strace files into
Update (2014.01.25): I've reapplied the same instructions to compile strace v4.8 with Sourcery CodeBench Lite 2013.05-24 (note that the compilation failed with the latest version -which was 2013.11-33 at the time of writing-, so I reverted back to 2013.05-24). This time I used a 32-bit Ubuntu 12.04 (x86) virtual machine. I've attached the compiled TGZ package that you can simply extract into your filesystem and it'll put all strace files into