arm-linux-gcc
arm-linux-gcc-5.4.0.tar.gz
下载后安装到该目录
muhe221@muhe221:~/soft/arm-linux-gcc-5.4.0$
设置环境变量
export PATH=~/soft/arm-linux-gcc-5.4.0/bin:$PATH
hello.c
#include <stdio.h> int main() { printf("hello world!\n"); return 0; }
muhe221@muhe221:~/cm/test/arm$ arm-linux-gcc -o hello hello.c -static //编译静态链接库
muhe221@muhe221:~/cm/test/arm$ ls
hello hello.c
muhe221@muhe221:~/cm/test/arm$ file hello
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, not stripped
muhe221@muhe221:~/cm/test/arm$ readelf -l hello
Elf file type is EXEC (Executable file)
Entry point 0x10404
There are 6 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
EXIDX 0x077c3c 0x00087c3c 0x00087c3c 0x00630 0x00630 R 0x4
LOAD 0x000000 0x00010000 0x00010000 0x78270 0x78270 R E 0x10000
LOAD 0x078270 0x00098270 0x00098270 0x00f5c 0x02084 RW 0x10000
NOTE 0x0000f4 0x000100f4 0x000100f4 0x00020 0x00020 R 0x4
TLS 0x078270 0x00098270 0x00098270 0x00010 0x00028 R 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10
Section to Segment mapping:
Segment Sections...
00 .ARM.exidx
01 .note.ABI-tag .rel.dyn .init .iplt .text __libc_freeres_fn __libc_thread_freeres_fn .fini .rodata __libc_subfreeres __libc_atexit __libc_thread_subfreeres .ARM.extab .ARM.exidx .eh_frame
02 .tdata .init_array .fini_array .jcr .data.rel.ro .got .data .bss __libc_freeres_ptrs
03 .note.ABI-tag
04 .tdata .tbss
05
E:\work>adb push C:\Users\c00390379\Desktop\hello /system C:\Users\c00390379\Desktop\hello: 1 file pushed. 15.1 MB/s (618468 bytes in 0.039s) E:\work>adb shell K9x:/ # cd system 126|kirin990:/system # chmod 777 hello K9x:/system # ./hello hello world!
另外如果使用arm-linux-gcc -o hello hello.c编译出来的hello依赖其他so。

浙公网安备 33010602011771号