[root@localhost 桌面]# gedit readdisk.c
#include <stdio.h> #include <fcntl.h> int main() { unsigned char buf[512]; int fd = open("/dev/blk/mmcblk1", O_RDWR); printf("文件描述符%d", fd); if (fd < 0) { // printf("%d\n",errno); return 0; } int num; num = read(fd, buf, 512); printf("读取字数%d", num); printf("\n"); int i, j; for (i = 0; i < 32; i++) { for (j = 0; j < 16; j++) printf("%02X ", buf[i * 16 + j]); printf("\n"); } printf("\n"); close(fd); return 0; }
[root@localhost 桌面]# arm-linux-androideabi-gcc --sysroot=/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/ readdisk.c -o readdisk
++++++++++++++++++++++++++++++++++++
root@kltexx:/data # ./readdisk
error: only position independent executables (PIE) are supported.
[root@localhost 桌面]# arm-linux-androideabi-gcc --sysroot=/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/ -pie -fPIE readdisk.c -o readdisk