[wenjing@centos6 script]$ arm-linux-gcc -o hello hello.c
[wenjing@centos6 script]$
[wenjing@centos6 script]$ arm-linux-objdump -d hello //4个字节,32位ARM指令
... ...
... ...
00008468 :
8468: e1a0c00d mov ip, sp
846c: e92dd800 push {fp, ip, lr, pc}
8470: e24cb004 sub fp, ip, #4
8474: e59f000c ldr r0, [pc, #12] ; 8488
8478: ebffffa3 bl 830c <_init+0x24>
847c: e3a03000 mov r3, #0
8480: e1a00003 mov r0, r3
8484: e89da800 ldm sp, {fp, sp, pc}
8488: 0000849c .word 0x0000849c
... ...
... ...
[wenjing@centos6 script]$ arm-linux-gcc -o hello -mthumb hello.c
[wenjing@centos6 script]$
[wenjing@centos6 script]$ arm-linux-objdump -d hello //2个字节,16位ARM指令
... ...
... ...
00008468 :
8468: b580 push {r7, lr}
846a: af00 add r7, sp, #0
846c: 4b03 ldr r3, [pc, #12] ; (847c )
846e: 1c18 adds r0, r3, #0
8470: f7ff ef4c blx 830c <_init+0x24>
8474: 2300 movs r3, #0
8476: 1c18 adds r0, r3, #0
8478: 46bd mov sp, r7
847a: bd80 pop {r7, pc}
847c: 00008490 .word 0x00008490
... ...
... ...
[wenjing@centos6 script]$ gcc -o hello hello.c
[wenjing@centos6 script]$
[wenjing@centos6 script]$ objdump -d hello //CONFUSED!
... ...
... ...
080483b4 :
80483b4: 55 push %ebp
80483b5: 89 e5 mov %esp,%ebp
80483b7: 83 e4 f0 and $0xfffffff0,%esp
80483ba: 83 ec 10 sub $0x10,%esp
80483bd: c7 04 24 94 84 04 08 movl $0x8048494,(%esp)
80483c4: e8 27 ff ff ff call 80482f0
80483c9: b8 00 00 00 00 mov $0x0,%eax
80483ce: c9 leave
80483cf: c3 ret
... ...
... ...
一个程序同时包含ARM32/THUMB16指令
[wenjing@centos6 script]$ cat hello1.c
#include
void funca();
void funcb();
void funca()
{
printf("I am funca\n");
funcb();
}
int main()
{
funca();
return 0;
}
[wenjing@centos6 script]$
[wenjing@centos6 script]$ cat hello2.c
#include
void funcb();
void funcb()
{
printf("I am funcb\n");
}
[wenjing@centos6 script]$
[wenjing@centos6 script]$ arm-linux-gcc -o hello1 -c hello1.c
[wenjing@centos6 script]$ arm-linux-gcc -o hello2 -mthumb -c hello2.c
[wenjing@centos6 script]$
[wenjing@centos6 script]$ arm-linux-gcc -o hello hello1 hello2
[wenjing@centos6 script]$ arm-linux-objdump -d hello | grep "<"
000082e8 <_init>:
000082f8 <.plt>:
82fc: e59fe004 ldr lr, [pc, #4] ; 8308 <_init+0x20>
00008348 <_start>:
00008384 <_call_via_r0>:
00008388 <_call_via_r1>:
0000838c <_call_via_r2>:
00008390 <_call_via_r3>:
00008394 <_call_via_r4>:
00008398 <_call_via_r5>:
0000839c <_call_via_r6>:
000083a0 <_call_via_r7>:
000083a4 <_call_via_r8>:
000083a8 <_call_via_r9>:
000083ac <_call_via_sl>:
000083b0 <_call_via_fp>:
000083b4 <_call_via_ip>:
000083b8 <_call_via_sp>:
000083bc <_call_via_lr>:
000083c0 <__do_global_dtors_aux>:
83c0: e59f3038 ldr r3, [pc, #56] ; 8400 <__do_global_dtors_aux+0x40>
83d4: 1a000007 bne 83f8 <__do_global_dtors_aux+0x38>
83d8: e59f3024 ldr r3, [pc, #36] ; 8404 <__do_global_dtors_aux+0x44>
83e0: 0a000001 beq 83ec <__do_global_dtors_aux+0x2c>
83e4: e59f001c ldr r0, [pc, #28] ; 8408 <__do_global_dtors_aux+0x48>
83e8: ebffffcd bl 8324 <_init+0x3c>
83ec: e59f300c ldr r3, [pc, #12] ; 8400 <__do_global_dtors_aux+0x40>
0000840c :
840c: e59f3040 ldr r3, [pc, #64] ; 8454
841c: 0a000002 beq 842c
8420: e59f0030 ldr r0, [pc, #48] ; 8458
8424: e59f1030 ldr r1, [pc, #48] ; 845c
8428: ebffffc3 bl 833c <_init+0x54>
842c: e59f002c ldr r0, [pc, #44] ; 8460
8438: 0a000003 beq 844c
843c: e59f3020 ldr r3, [pc, #32] ; 8464
8444: 0a000000 beq 844c
00008468 :
8474: e59f0008 ldr r0, [pc, #8] ; 8484
8478: ebffffa3 bl 830c <_init+0x24>
847c: fa000008 blx 84a4
00008488 :
8494: ebfffff3 bl 8468
000084a4 :
84a8: 4b02 ldr r3, [pc, #8] ; (84b4 )
84ac: f7ff ef2e blx 830c <_init+0x24>
000084b8 <_fini>:
[wenjing@centos6 script]$
===================== BUT !!!! =====================
WHY HERE NO SUCH LABEL LIKE funcb_change_to_arm
cross compile tool version different ?
[wenjing@centos6 script]$ arm-linux-gcc --version
arm-linux-gcc (Buildroot 2011.02) 4.3.5
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[wenjing@centos6 script]$
[wenjing@centos6 script]$ arm-linux-objdump --version
GNU objdump (GNU Binutils) 2.21
Copyright 2010 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
=====================Copy target binary to target device=====================
# ./hello
I am funca
I am funcb