getTime.c
#include <stdio.h>
#include <time.h>
#include <string.h>
int main() {
time_t t;
char *strTime;
time(&t);
strTime = ctime(&t);
printf("%s\n", strTime);
return 0;
}
compile on x86
root@jcjung:~/work# gcc getTime.c -o getTime_x86
root@jcjung:~/work# ./getTime_x86
Tue Jan 17 13:53:32 2012
compile on arm
root@jcjung:~/work# arm-none-linux-gnueabi-gcc getTime.c -o getTime_arm
root@jcjung:~/work# ./getTime_arm
bash: ./getTime_arm: 바이너리 파일을 실행할 수 없음
Information of executable files
root@jcjung:~/work# ./getTime_arm
bash: ./getTime_arm: 바이너리 파일을 실행할 수 없음
root@jcjung:~/work# file getTime_x86
getTime_x86: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
root@jcjung:~/work# file getTime_arm
getTime_arm: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
move to tftp shared directory
root@jcjung:~/work# cp getTime_arm /var/lib/tftpboot/
Move to target board
set target board network
bash-3.2# ifconfig eth0 192.168.10.100 up
eth0: link down
bash-3.2# ieth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
bash-3.2# ifconfig
eth0 Link encap:Ethernet HWaddr 02:10:02:01:C0:01
inet addr:192.168.10.100 Bcast:192.168.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:22 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2768 (2.7 KiB) TX bytes:0 (0.0 B)
Interrupt:185 Base address:0xc000
cd /data/linux
bash-3.2# tftp -g 192.168.10.10 -r getTime_arm
bash-3.2# ls -lh
-rw-rw-rw- 1 0 0 5.6k Jan 1 00:25 getTime_arm
bash-3.2# chmod 755 getTime_arm
bash-3.2# ls -lh
-rwxr-xr-x 1 0 0 5.6k Jan 1 00:25 getTime_arm
bash-3.2# ./getTime_arm
bash: ./getTime_arm: No such file or directory
This problem is caused by dynamic linking to find glibc, so we have to change to use static linking
root@jcjung:~/work# arm-none-linux-gnueabi-gcc -static getTime.c -o getTime_arm_static
root@jcjung:~/work# file getTime_arm_static
getTime_arm_static: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, not stripped
root@jcjung:~/work# ls -lh getTime*
-rw-r--r-- 1 root root 198 2012-01-17 13:53 getTime.c
-rwxr-xr-x 1 root root 5.7K 2012-01-17 13:54 getTime_arm
-rwxr-xr-x 1 root root 635K 2012-01-17 14:29 getTime_arm_static
-rwxr-xr-x 1 root root 7.1K 2012-01-17 13:53 getTime_x86
root@jcjung:~/work# cp getTime_arm_static /var/lib/tftpboot/
bash-3.2# tftp -g 192.168.10.10 -r getTime_arm_static
bash-3.2# chmod 755 getTime_arm_static
bash-3.2# ./getTime_arm_static
Sat Jan 1 00:55:25 2000
#include <stdio.h>
#include <time.h>
#include <string.h>
int main() {
time_t t;
char *strTime;
time(&t);
strTime = ctime(&t);
printf("%s\n", strTime);
return 0;
}
compile on x86
root@jcjung:~/work# gcc getTime.c -o getTime_x86
root@jcjung:~/work# ./getTime_x86
Tue Jan 17 13:53:32 2012
compile on arm
root@jcjung:~/work# arm-none-linux-gnueabi-gcc getTime.c -o getTime_arm
root@jcjung:~/work# ./getTime_arm
bash: ./getTime_arm: 바이너리 파일을 실행할 수 없음
Information of executable files
root@jcjung:~/work# ./getTime_arm
bash: ./getTime_arm: 바이너리 파일을 실행할 수 없음
root@jcjung:~/work# file getTime_x86
getTime_x86: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
root@jcjung:~/work# file getTime_arm
getTime_arm: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
move to tftp shared directory
root@jcjung:~/work# cp getTime_arm /var/lib/tftpboot/
Move to target board
set target board network
bash-3.2# ifconfig eth0 192.168.10.100 up
eth0: link down
bash-3.2# ieth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
bash-3.2# ifconfig
eth0 Link encap:Ethernet HWaddr 02:10:02:01:C0:01
inet addr:192.168.10.100 Bcast:192.168.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:22 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2768 (2.7 KiB) TX bytes:0 (0.0 B)
Interrupt:185 Base address:0xc000
cd /data/linux
bash-3.2# tftp -g 192.168.10.10 -r getTime_arm
bash-3.2# ls -lh
-rw-rw-rw- 1 0 0 5.6k Jan 1 00:25 getTime_arm
bash-3.2# chmod 755 getTime_arm
bash-3.2# ls -lh
-rwxr-xr-x 1 0 0 5.6k Jan 1 00:25 getTime_arm
bash-3.2# ./getTime_arm
bash: ./getTime_arm: No such file or directory
This problem is caused by dynamic linking to find glibc, so we have to change to use static linking
root@jcjung:~/work# arm-none-linux-gnueabi-gcc -static getTime.c -o getTime_arm_static
root@jcjung:~/work# file getTime_arm_static
getTime_arm_static: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, not stripped
root@jcjung:~/work# ls -lh getTime*
-rw-r--r-- 1 root root 198 2012-01-17 13:53 getTime.c
-rwxr-xr-x 1 root root 5.7K 2012-01-17 13:54 getTime_arm
-rwxr-xr-x 1 root root 635K 2012-01-17 14:29 getTime_arm_static
-rwxr-xr-x 1 root root 7.1K 2012-01-17 13:53 getTime_x86
root@jcjung:~/work# cp getTime_arm_static /var/lib/tftpboot/
bash-3.2# tftp -g 192.168.10.10 -r getTime_arm_static
bash-3.2# chmod 755 getTime_arm_static
bash-3.2# ./getTime_arm_static
Sat Jan 1 00:55:25 2000