家里有一台cotext-A9(armv7-a) 的盒子,现在不用了,
一直想着废物利用。于是想怎么为这盒子编译程序。
目标机器:
root@routon-h1:/# uname -a
Linux routon-h1 2.6. # SMP Mon Oct :: CST armv7l GNU/Linux
装了一台 ubuntu 10.04 X86 的虚拟机
root@ubuntu:~# uname -a
Linux ubuntu 2.6.--generic #-Ubuntu SMP Wed Jan :: UTC i686 GNU/Linux root@ubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04. LTS
Release: 10.04
Codename: lucid
安装过程:
apt-get install python-software-properties
add-apt-repository ppa:linaro-maintainers/toolchain
apt-get install gcc-4.4-arm-linux-gnueabi
apt-get install g++-4.4-arm-linux-gnueabi
测试代码:
#include <stdio.h>
main()
{
printf("Hello World\n");
}
编译过程:
root@ubuntu:~# arm-linux-gnueabi-gcc-4.4 -v hello.c
Using built-in specs.
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.6-3ubuntu1~ppa3' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabi/include/c++/4.4.6 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv7-a --with-float=softfp --with-fpu=vfpv3-d16 --with-mode=thumb --disable-werror --enable-checking=release --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include --build=i486-linux-gnu --host=i486-linux-gnu --target=arm-linux-gnueabi --with-headers=/usr/arm-linux-gnueabi/include --with-libs=/usr/arm-linux-gnueabi/lib
Thread model: posix
gcc version 4.4. (Ubuntu/Linaro 4.4.-3ubuntu1~ppa3)
COLLECT_GCC_OPTIONS='-v' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfpv3-d16' '-mthumb'
/usr/lib/gcc/arm-linux-gnueabi/4.4./cc1 -quiet -v hello.c -quiet -dumpbase hello.c -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -auxbase hello -version -o /tmp/ccKJdMkG.s
ignoring duplicate directory "/usr/lib/gcc/arm-linux-gnueabi/4.4.6/../../../../arm-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/arm-linux-gnueabi/4.4./include
/usr/lib/gcc/arm-linux-gnueabi/4.4./include-fixed
/usr/arm-linux-gnueabi/include
End of search list.
GNU C (Ubuntu/Linaro 4.4.-3ubuntu1~ppa3) version 4.4. (arm-linux-gnueabi)
compiled by GNU C version 4.4., GMP version 4.3., MPFR version 2.4.-p1.
GGC heuristics: --param ggc-min-expand= --param ggc-min-heapsize=
Compiler executable checksum: d8b1c137400b627d969f13ef7d115d11
COLLECT_GCC_OPTIONS='-v' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfpv3-d16' '-mthumb'
/usr/lib/gcc/arm-linux-gnueabi/4.4./../../../../arm-linux-gnueabi/bin/as -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mimplicit-it=thumb -meabi= -o /tmp/ccEJ19An.o /tmp/ccKJdMkG.s
COMPILER_PATH=/usr/lib/gcc/arm-linux-gnueabi/4.4./:/usr/lib/gcc/arm-linux-gnueabi/4.4./:/usr/lib/gcc/arm-linux-gnueabi/:/usr/lib/gcc/arm-linux-gnueabi/4.4./:/usr/lib/gcc/arm-linux-gnueabi/:/usr/lib/gcc/arm-linux-gnueabi/4.4./../../../../arm-linux-gnueabi/bin/
LIBRARY_PATH=/usr/lib/gcc/arm-linux-gnueabi/4.4./:/usr/lib/gcc/arm-linux-gnueabi/4.4./../../../../arm-linux-gnueabi/lib/
COLLECT_GCC_OPTIONS='-v' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfpv3-d16' '-mthumb'
/usr/lib/gcc/arm-linux-gnueabi/4.4./collect2 --build-id --eh-frame-hdr -dynamic-linker /lib/ld-linux.so. -X --hash-style=both -m armelf_linux_eabi /usr/lib/gcc/arm-linux-gnueabi/4.4./../../../../arm-linux-gnueabi/lib/crt1.o /usr/lib/gcc/arm-linux-gnueabi/4.4./../../../../arm-linux-gnueabi/lib/crti.o /usr/lib/gcc/arm-linux-gnueabi/4.4./crtbegin.o -L/usr/lib/gcc/arm-linux-gnueabi/4.4. -L/usr/lib/gcc/arm-linux-gnueabi/4.4./../../../../arm-linux-gnueabi/lib /tmp/ccEJ19An.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/arm-linux-gnueabi/4.4./crtend.o /usr/lib/gcc/arm-linux-gnueabi/4.4./../../../../arm-linux-gnueabi/lib/crtn.o
上传目标机器之后执行:
root@routon-h1:/mnt/tool/reverse-h1# ./a.out
Hello World