交叉编译e2fsprogs For android
由于需要使用dumpe2fs debugfs工具,因此交叉编译了e2fsprogs的源码。
本人在ubuntu 14.04下操作的
1. 下载e2fsprogs的源码
版本是1.42.6
2. 下载NDK
https://developer.android.com/ndk/downloads/index.html
3. 生成standalone toolchain (斜体为具体路径)
cd $NDK_PATH
cd build/tools
./make_standalone_toolchain.sh --install-dir=$TOOLCHAIN_PATH
成功则在$TOOLCHAIN_PATH下生成交叉编译所需的工具
4. 测试是否成功
cd $TOOL_CHAIN/bin
./arm-linux-androideabi-gcc -v
zombie@zombie-OptiPlex-3010:~/Software/NDK/tool-chain/bin$ ./arm-linux-androideabi-gcc -vUsing built-in specs.COLLECT_GCC=./arm-linux-androideabi-gccCOLLECT_LTO_WRAPPER=/home/zombie/Software/NDK/tool-chain/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapperTarget: arm-linux-androideabiConfigured with: /usr/local/google/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/configure --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/buildbot/tmp/build/toolchain/temp-install --with-mpfr=/buildbot/tmp/build/toolchain/temp-install --with-mpc=/buildbot/tmp/build/toolchain/temp-install --with-cloog=/buildbot/tmp/build/toolchain/temp-install --with-isl=/buildbot/tmp/build/toolchain/temp-install --with-ppl=/buildbot/tmp/build/toolchain/temp-install --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-initfini-array --disable-nls --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --with-sysroot=/tmp/59719db9ae19ff43aef46bbcb79596b6/sysroot --with-binutils-version=2.25 --with-mpfr-version=3.1.1 --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-gcc-version=4.9 --with-gdb-version=none --with-gxx-include-dir=/tmp/59719db9ae19ff43aef46bbcb79596b6/include/c++/4.9.x --with-bugurl=http://source.android.com/source/report-bugs.html --enable-languages=c,c++ --disable-bootstrap --enable-plugins --enable-libgomp --enable-gnu-indirect-function --disable-libsanitizer --enable-gold --enable-threads --enable-eh-frame-hdr-for-static --enable-graphite=yes --with-isl-version=0.11.1 --with-cloog-version=0.18.0 --with-arch=armv5te --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=defaultThread model: posixgcc version 4.9.x 20150123 (prerelease) (GCC)
export PATH=$PATH:/$TOOL_CHAIN/bin
5. 编译e2fsprogs
cd $e2fsprogs_PATH
export CFLAGS="-static -O2 -fpie -pie"
export LDFLAGS="-staitc -pie"
./configure --host=arm-linux -target=arm-linux CC=arm-linux-androideabi-gcc --prefix=$OUT_DIR
make (-j8)
make install
6. 成功编译后会在$OUT_DIR/sbin下生成可执行文件
zombie@zombie-OptiPlex-3010:~/e2fsprogs/out/sbin$ lsbadblocks e2fsck filefrag fsck.ext4 mkfs.ext3 tune2fsblkid e2image findfs fsck.ext4dev mkfs.ext4 uuidddebugfs e2label fsck logsave mkfs.ext4devdumpe2fs e2undo fsck.ext2 mke2fs mklost+founde2freefrag e4defrag fsck.ext3 mkfs.ext2 resize2fs
7. 剔除可执行文件符号表信息
cd $OUT_DIR
arm-linux-androideabi-strip *
8. 查看可执行文件信息(关键是statically linked 和 stripped)
file *
zombie@zombie-OptiPlex-3010:~/e2fsprogs/out/sbin$ file *badblocks: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedblkid: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippeddebugfs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippeddumpe2fs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippede2freefrag: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippede2fsck: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippede2image: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippede2label: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippede2undo: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippede4defrag: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedfilefrag: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedfindfs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedfsck: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedfsck.ext2: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedfsck.ext3: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedfsck.ext4: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedfsck.ext4dev: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedlogsave: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedmke2fs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedmkfs.ext2: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedmkfs.ext3: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedmkfs.ext4: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedmkfs.ext4dev: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedmklost+found: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedresize2fs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippedtune2fs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, strippeduuidd: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, stripped
adb push debugfs /data/local/tmp
10. 在手机中运行
adb shell
cd /data/local/tmp
./debugfs
更多相关文章
- Python3原生编写月份计算工具
- 一款常用的 Squid 日志分析工具
- GitHub 标星 8K+!一款开源替代 ls 的工具你值得拥有!
- Linux 环境下实战 Rsync 备份工具及配置 rsync+inotify 实时同步
- [Android]PopupWindow 点击外部区域无法关闭的问题
- 吐血分享!Android源码50例汇总,欢迎各位下载
- Android(安卓)GPIO 控制方案
- Android8.0 PackageManagerService相关 -- APK安装和install 的
- android下调用隐藏源码的问题