arm-linux-gcc thumb,ARM32位指令及THUMB16位指令

[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

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-mthumbhello.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

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 :

000082f8 :

82fc:       e59fe004        ldr     lr, [pc, #4]    ; 8308

00008348 :

00008384 :

00008388 :

0000838c :

00008390 :

00008394 :

00008398 :

0000839c :

000083a0 :

000083a4 :

000083a8 :

000083ac :

000083b0 :

000083b4 :

000083b8 :

000083bc :

000083c0 :

83c0:       e59f3038        ldr     r3, [pc, #56]   ; 8400

83d4:       1a000007        bne     83f8

83d8:       e59f3024        ldr     r3, [pc, #36]   ; 8404

83e0:       0a000001        beq     83ec

83e4:       e59f001c        ldr     r0, [pc, #28]   ; 8408

83e8:       ebffffcd        bl      8324

83ec:       e59f300c        ldr     r3, [pc, #12]   ; 8400

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

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

847c:       fa000008        blx     84a4

00008488 :

8494:       ebfffff3        bl      8468

000084a4 :

84a8:       4b02            ldr     r3, [pc, #8]    ; (84b4 )

84ac:       f7ff ef2e       blx     830c

000084b8 :

[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

阅读(1938) | 评论(0) | 转发(0) |

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值