交叉编译环境下gcc编译汇编文件

1、arm-linux-gcc:
首先编写C程序,假设名字为test.c,保存test.c文件内容:
  1. #include<stdio.h>  
  2. int main()  
  3. {  
  4.         printf("hello.world!\n");  
  5.         return 0;  
  6. }  




在X86架构下的电脑上生成ARM架构的汇编代码有两种方式:
1、使用交叉编译工具链:arm-linux-gcc,指定-S选项可以生成汇编中间文件。
2、使用arm-linux-objdump反汇编arm二进制文件。

1、arm-linux-gcc:
首先编写C程序,假设名字为test.c,保存test.c文件内容:
  1. #include<stdio.h>  
  2. int main()  
  3. {  
  4.         printf("hello.world!\n");  
  5.         return 0;  
  6. }  


使用方法如下:
在使用arm-linux-gcc编译C源文件时,使用-S选项可以将C文件(test.c为例)编译到汇编阶段,生成arm汇编代码,使用方式如下:
arm-linux-gcc  -march=armv7-a -mtune=cortex-a9  test.c -S -o test.asm  
生成arm汇编文件test.asm。
说明:
-march可以指定目标ARM的架构可选参数见(man gcc)
-mtune(类似于-mcpu)可以具体到ARM处理器类型。
注意:
Specifying both -march= and -mcpu= is redundant, and may not in fact have done what you expected in previous compiler versions (maybe even depending on the order in which the arguments were given). The -march switch selects a "generic" ARMv7-A CPU, and -mcpu selects specifically a Cortex-A8 CPU with tuning specific for that core.

Either use "-march=armv7-a -mtune=cortex-a8", or just use "-mcpu=cortex-a8".
所以只用一个-mcpu=cortex-a9也可以

test.asm内容:
[plain]  view plain copy print ?
  1. <pre name="code" class="plain">  1         .arch armv4t  
  2.   2         .fpu softvfp  
  3.   3         .eabi_attribute 20, 1  
  4.   4         .eabi_attribute 21, 1  
  5.   5         .eabi_attribute 23, 3  
  6.   6         .eabi_attribute 24, 1  
  7.   7         .eabi_attribute 25, 1  
  8.   8         .eabi_attribute 26, 2  
  9.   9         .eabi_attribute 30, 6  
  10.  10         .eabi_attribute 18, 4  
  11.  11         .file   "test.c"  
  12.  12         .section        .rodata  
  13.  13         .align  2  
  14.  14 .LC0:  
  15.  15         .ascii  "hello.world!\000"  
  16.  16         .text  
  17.  17         .align  2  
  18.  18         .global main  
  19.  19         .type   main, %function  
  20.  20 main:  
  21.  21         .fnstart  
  22.  22 .LFB2:  
  23.  23         @ Function supports interworking.  
  24.  24         @ args = 0, pretend = 0, frame = 0  
  25.  25         @ frame_needed = 1, uses_anonymous_args = 0  
  26.  26         stmfd   sp!, {fp, lr}  
  27.  27         .save {fp, lr}  
  28.  28 .LCFI0:  
  29.  29         .setfp fp, sp, #4  
  30.  30         add     fp, sp, #4  
  31.  31 .LCFI1:  
  32.  32         ldr     r0, .L3  
  33.  33         bl      puts  
  34.  34         mov     r3, #0  
  35.  35         mov     r0, r3  
  36.  36         sub     sp, fp, #4  
  37.  <pre name="code" class="plain"> 36         sub     sp, fp, #4  
  38.  37         ldmfd   sp!, {fp, lr}  
  39.  38         bx      lr  
  40.  39 .L4:  
  41.  40         .align  2  
  42.  41 .L3:  
  43.  42         .word   .LC0  
  44.  43 .LFE2:  
  45.  44         .fnend  
  46.  45         .size   main, .-main  
  47.  46         .ident  "GCC: (Sourcery G++ Lite 2009q1-176) 4.3.3"  
  48.  47         .section        .note.GNU-stack,"",%progbits  
  49. </pre>  
  50. <pre></pre>  
  51. <pre></pre>  
  52. <pre></pre>  
  53. <pre></pre>  
  54. <pre></pre>  
  55. <pre></pre>  
  56. <pre></pre>  
  57. <pre></pre>  
  58. <pre></pre>  
  59. <pre></pre>  
  60. <pre></pre>  
  61. <pre></pre>  
  62. <pre></pre>  
  63. <pre></pre>  
  64. <pre></pre>  
  65. <pre></pre>  
  66. <pre></pre>  
  67. <pre></pre>  
  68. <pre></pre>  
  69. <pre></pre>  
  70. <pre></pre>  
  71. <pre></pre>  
  72. <pre></pre>  
  73. <pre></pre>  
  74. </pre>  

另外,使用arm-linux-objdump 反汇编过程如下:
(1)交叉编译:
arm-linux-gcc test.c -o test ,生成test二进制文件(此处可以加入-O2选项优化代码:arm-linux-gcc test.c -O2 -o test)
(2)反汇编:
arm-linux-objdump -alD test > test.txt
生成test.txt文件,内容如下:
[plain]  view plain copy print ?
  1. test:     file format elf32-littlearm  
  2. test  
  3.   
  4.   
  5. Disassembly of section .interp:  
  6.   
  7. 00008134 <.interp>:  
  8.     8134:   62696c2f    rsbvs   r6, r9, #12032  ; 0x2f00  
  9.     8138:   2d646c2f    stclcs  12, cr6, [r4, #-188]!  
  10.     813c:   756e696c    strbvc  r6, [lr, #-2412]!  
  11.     8140:   6f732e78    svcvs   0x00732e78  
  12.     8144:   Address 0x00008144 is out of bounds.  
  13.   
  14.   
  15. Disassembly of section .note.ABI-tag:  
  16.   
  17. 00008148 <.note.ABI-tag>:  
  18.     8148:   00000004    .word   0x00000004  
  19.     814c:   00000010    .word   0x00000010  
  20.     8150:   00000001    .word   0x00000001  
  21.     8154:   00554e47    .word   0x00554e47  
  22.     8158:   00000000    .word   0x00000000  
  23.     815c:   00000002    .word   0x00000002  
  24.     8160:   00000006    .word   0x00000006  
  25.     8164:   0000000e    .word   0x0000000e  
  26.   
  27. Disassembly of section .hash:  
  28.   
  29. 00008168 <.hash>:  
  30.     8168:   00000003    andeq   r0, r0, r3  
  31.     816c:   00000008    andeq   r0, r0, r8  
  32.     8170:   00000005    andeq   r0, r0, r5  
  33.     8174:   00000006    andeq   r0, r0, r6  
  34.     8178:   00000007    andeq   r0, r0, r7  
  35.     ...  
  36.     8188:   00000002    andeq   r0, r0, r2  
  37.     818c:   00000000    andeq   r0, r0, r0  
  38.     8190:   00000004    andeq   r0, r0, r4  
  39.     8194:   00000003    andeq   r0, r0, r3  
  40.     8198:   00000001    andeq   r0, r0, r1  
  41.   
  42. Disassembly of section .dynsym:  
  43.   
  44. 0000819c <.dynsym>:  
  45.     ...  
  46.     81ac:   0000006f    andeq   r0, r0, pc, rrx  
  47.     81b0:   00008354    andeq   r8, r0, r4, asr r3  
  48.     81b4:   00000000    andeq   r0, r0, r0  
  49.     81b8:   00000012    andeq   r0, r0, r2, lsl r0  
  50.     81bc:   00000075    andeq   r0, r0, r5, ror r0  
  51.     81c0:   00008360    andeq   r8, r0, r0, ror #6  
  52.     81c4:   00000000    andeq   r0, r0, r0  
  53.     81c8:   00000012    andeq   r0, r0, r2, lsl r0  
  54.     81cc:   0000000f    andeq   r0, r0, pc  
  55.     ...  
  56.     81d8:   00000012    andeq   r0, r0, r2, lsl r0  
  57.     81dc:   00000026    andeq   r0, r0, r6, lsr #32  
  58.     ...  
  59.     81e8:   00000020    andeq   r0, r0, r0, lsr #32  
  60.     81ec:   00000035    andeq   r0, r0, r5, lsr r0  
  61.     ...  
  62.     81f8:   00000020    andeq   r0, r0, r0, lsr #32  
  63.     81fc:   0000006a    andeq   r0, r0, sl, rrx  
  64.     8200:   00008378    andeq   r8, r0, r8, ror r3  
  65.     8204:   00000000    andeq   r0, r0, r0  
  66.     8208:   00000012    andeq   r0, r0, r2, lsl r0  
  67.     820c:   00000049    andeq   r0, r0, r9, asr #32  
  68.     ...  
  69.     8218:   00000012    andeq   r0, r0, r2, lsl r0  
  70.   
  71. Disassembly of section .dynstr:  
  72.   
  73. 0000821c <.dynstr>:  
  74.     821c:   62696c00    rsbvs   r6, r9, #0  ; 0x0  
  75.     8220:   5f636367    svcpl   0x00636367  
  76.     8224:   6f732e73    svcvs   0x00732e73  
  77.     8228:   5f00312e    svcpl   0x0000312e  
  78.     822c:   6165615f    cmnvs   r5, pc, asr r1  
  79.     8230:   755f6962    ldrbvc  r6, [pc, #-2402]    ; 78d6 <_init-0xa5a>  
  80.     8234:   6e69776e    cdpvs   7, 6, cr7, cr9, cr14, {3}  
  81.     8238:   70635f64    rsbvc   r5, r3, r4, ror #30  
  82.     823c:   72705f70    rsbsvc  r5, r0, #448    ; 0x1c0  
  83.     8240:   5f5f0030    svcpl   0x005f0030  
  84.     8244:   6e6f6d67    cdpvs   13, 6, cr6, cr15, cr7, {3}  
  85.     8248:   6174735f    cmnvs   r4, pc, asr r3  
  86.     824c:   5f5f7472    svcpl   0x005f7472  
  87.     8250:   764a5f00    strbvc  r5, [sl], -r0, lsl #30  
  88.     8254:   6765525f    undefined  
  89.     8258:   65747369    ldrbvs  r7, [r4, #-873]!  
  90.     825c:   616c4372    smcvs   50226  
  91.     8260:   73657373    cmnvc   r5, #-872415231 ; 0xcc000001  
  92.     8264:   615f5f00    cmpvs   pc, r0, lsl #30  
  93.     8268:   69626165    stmdbvs r2!, {r0, r2, r5, r6, r8, sp, lr}^  
  94.     826c:   776e755f    undefined  
  95.     8270:   5f646e69    svcpl   0x00646e69  
  96.     8274:   5f707063    svcpl   0x00707063  
  97.     8278:   00317270    eorseq  r7, r1, r0, ror r2  
  98.     827c:   6362696c    cmnvs   r2, #1769472    ; 0x1b0000  
  99.     8280:   2e6f732e    cdpcs   3, 6, cr7, cr15, cr14, {1}  
  100.     8284:   75700036    ldrbvc  r0, [r0, #-54]!  
  101.     8288:   61007374    tstvs   r0, r4, ror r3  
  102.     828c:   74726f62    ldrbtvc r6, [r2], #-3938  
  103.     8290:   6c5f5f00    mrrcvs  15, 0, r5, pc, cr0  
  104.     8294:   5f636269    svcpl   0x00636269  
  105.     8298:   72617473    rsbvc   r7, r1, #1929379840 ; 0x73000000  
  106.     829c:   616d5f74    smcvs   54772  
  107.     82a0:   47006e69    strmi   r6, [r0, -r9, ror #28]  
  108.     82a4:   335f4343    cmpcc   pc, #201326593  ; 0xc000001  
  109.     82a8:   4700352e    strmi   r3, [r0, -lr, lsr #10]  
  110.     82ac:   4342494c    movtmi  r4, #10572  ; 0x294c  
  111.     82b0:   342e325f    strtcc  r3, [lr], #-607  
  112.     ...  
  113.   
  114. Disassembly of section .gnu.version:  
  115.   
  116. 000082b6 <.gnu.version>:  
  117.     82b6:   00020000    andeq   r0, r2, r0  
  118.     82ba:   00030002    andeq   r0, r3, r2  
  119.     82be:   00000000    andeq   r0, r0, r0  
  120.     82c2:   00030002    andeq   r0, r3, r2  
  121.   
  122. Disassembly of section .gnu.version_r:  
  123.   
  124. 000082c8 <.gnu.version_r>:  
  125.     82c8:   00010001    andeq   r0, r1, r1  
  126.     82cc:   00000001    andeq   r0, r0, r1  
  127.     82d0:   00000010    andeq   r0, r0, r0, lsl r0  
  128.     82d4:   00000020    andeq   r0, r0, r0, lsr #32  
  129.     82d8:   0b792655    bleq    1e51c34 <__bss_end__+0x1e415ac>  
  130.     82dc:   00030000    andeq   r0, r3, r0  
  131.     82e0:   00000087    andeq   r0, r0, r7, lsl #1  
  132.     82e4:   00000000    andeq   r0, r0, r0  
  133.     82e8:   00010001    andeq   r0, r1, r1  
  134.     82ec:   00000060    andeq   r0, r0, r0, rrx  
  135.     82f0:   00000010    andeq   r0, r0, r0, lsl r0  
  136.     82f4:   00000000    andeq   r0, r0, r0  
  137.     82f8:   0d696914    stcleq  9, cr6, [r9, #-80]!  
  138.     82fc:   00020000    andeq   r0, r2, r0  
  139.     8300:   0000008f    andeq   r0, r0, pc, lsl #1  
  140.     8304:   00000000    andeq   r0, r0, r0  
  141.   
  142. Disassembly of section .rel.dyn:  
  143.   
  144. 00008308 <.rel.dyn>:  
  145.     8308:   00010678    andeq   r0, r1, r8, ror r6  
  146.     830c:   00000415    andeq   r0, r0, r5, lsl r4  
  147.   
  148. Disassembly of section .rel.plt:  
  149.   
  150. 00008310 <.rel.plt>:  
  151.     8310:   00010668    andeq   r0, r1, r8, ror #12  
  152.     8314:   00000116    andeq   r0, r0, r6, lsl r1  
  153.     8318:   0001066c    andeq   r0, r1, ip, ror #12  
  154.     831c:   00000216    andeq   r0, r0, r6, lsl r2  
  155.     8320:   00010670    andeq   r0, r1, r0, ror r6  
  156.     8324:   00000416    andeq   r0, r0, r6, lsl r4  
  157.     8328:   00010674    andeq   r0, r1, r4, ror r6  
  158.     832c:   00000616    andeq   r0, r0, r6, lsl r6  
  159.   
  160. Disassembly of section .init:  
  161.   
  162. 00008330 <_init>:  
  163. _init():  
  164.     8330:   e92d4010    push    {r4, lr}  
  165.     8334:   eb000020    bl  83bc <call_gmon_start>  
  166.     8338:   e8bd4010    pop {r4, lr}  
  167.     833c:   e12fff1e    bx  lr  
  168.   
  169. Disassembly of section .plt:  
  170.   
  171. 00008340 <.plt>:  
  172.     8340:   e52de004    push    {lr}        ; (str lr, [sp, #-4]!)  
  173.     8344:   e59fe004    ldr lr, [pc, #4]    ; 8350 <_init+0x20>  
  174.     8348:   e08fe00e    add lr, pc, lr  
  175.     834c:   e5bef008    ldr pc, [lr, #8]!  
  176.     8350:   0000830c    .word   0x0000830c  
  177.     8354:   e28fc600    add ip, pc, #0  ; 0x0  
  178.     8358:   e28cca08    add ip, ip, #32768  ; 0x8000  
  179.     835c:   e5bcf30c    ldr pc, [ip, #780]!  
  180.     8360:   e28fc600    add ip, pc, #0  ; 0x0  
  181.     8364:   e28cca08    add ip, ip, #32768  ; 0x8000  
  182.     8368:   e5bcf304    ldr pc, [ip, #772]!  
  183.     836c:   e28fc600    add ip, pc, #0  ; 0x0  
  184.     8370:   e28cca08    add ip, ip, #32768  ; 0x8000  
  185.     8374:   e5bcf2fc    ldr pc, [ip, #764]!  
  186.     8378:   e28fc600    add ip, pc, #0  ; 0x0  
  187.     837c:   e28cca08    add ip, ip, #32768  ; 0x8000  
  188.     8380:   e5bcf2f4    ldr pc, [ip, #756]!  
  189.   
  190. Disassembly of section .text:  
  191.   
  192. 00008384 <_start>:  
  193. _start():  
  194.     8384:   e59fc024    ldr ip, [pc, #36]   ; 83b0 <_start+0x2c>  
  195.     8388:   e3a0b000    mov fp, #0  ; 0x0  
  196.     838c:   e49d1004    pop {r1}        ; (ldr r1, [sp], #4)  
  197.     8390:   e1a0200d    mov r2, sp  
  198.     8394:   e52d2004    push    {r2}        ; (str r2, [sp, #-4]!)  
  199.     8398:   e52d0004    push    {r0}        ; (str r0, [sp, #-4]!)  
  200.     839c:   e59f0010    ldr r0, [pc, #16]   ; 83b4 <_start+0x30>  
  201.     83a0:   e59f3010    ldr r3, [pc, #16]   ; 83b8 <_start+0x34>  
  202.     83a4:   e52dc004    push    {ip}        ; (str ip, [sp, #-4]!)  
  203.     83a8:   ebffffec    bl  8360 <_init+0x30>  
  204.     83ac:   ebffffe8    bl  8354 <_init+0x24>  
  205.     83b0:   00008460    .word   0x00008460  
  206.     83b4:   00008438    .word   0x00008438  
  207.     83b8:   00008464    .word   0x00008464  
  208.   
  209. 000083bc <call_gmon_start>:  
  210. call_gmon_start():  
  211.     83bc:   e59f301c    ldr r3, [pc, #28]   ; 83e0 <call_gmon_start+0x24>  
  212.     83c0:   e59f201c    ldr r2, [pc, #28]   ; 83e4 <call_gmon_start+0x28>  
  213.     83c4:   e08f3003    add r3, pc, r3  
  214.     83c8:   e7931002    ldr r1, [r3, r2]  
  215.     83cc:   e3510000    cmp r1, #0  ; 0x0  
  216.     83d0:   e92d4010    push    {r4, lr}  
  217.     83d4:   1bffffe4    blne    836c <_init+0x3c>  
  218.     83d8:   e8bd4010    pop {r4, lr}  
  219.     83dc:   e12fff1e    bx  lr  
  220.     83e0:   00008290    .word   0x00008290  
  221.     83e4:   0000001c    .word   0x0000001c  
  222.   
  223. 000083e8 <__do_global_dtors_aux>:  
  224. __do_global_dtors_aux():  
  225.     83e8:   e59f2010    ldr r2, [pc, #16]   ; 8400 <__do_global_dtors_aux+0x18>  
  226.     83ec:   e5d23000    ldrb    r3, [r2]  
  227.     83f0:   e3530000    cmp r3, #0  ; 0x0  
  228.     83f4:   03a03001    moveq   r3, #1  ; 0x1  
  229.     83f8:   05c23000    strbeq  r3, [r2]  
  230.     83fc:   e12fff1e    bx  lr  
  231.     8400:   00010684    .word   0x00010684  
  232.   
  233. 00008404 <frame_dummy>:  
  234. frame_dummy():  
  235.     8404:   e59f0024    ldr r0, [pc, #36]   ; 8430 <frame_dummy+0x2c>  
  236.     8408:   e5903000    ldr r3, [r0]  
  237.     840c:   e3530000    cmp r3, #0  ; 0x0  
  238.     8410:   e92d4010    push    {r4, lr}  
  239.     8414:   0a000003    beq 8428 <frame_dummy+0x24>  
  240.     8418:   e59f3014    ldr r3, [pc, #20]   ; 8434 <frame_dummy+0x30>  
  241.     841c:   e3530000    cmp r3, #0  ; 0x0  
  242.     8420:   11a0e00f    movne   lr, pc  
  243.     8424:   112fff13    bxne    r3  
  244.     8428:   e8bd4010    pop {r4, lr}  
  245.     842c:   e12fff1e    bx  lr  
  246.     8430:   00010568    .word   0x00010568  
  247.     8434:   00000000    .word   0x00000000  
  248.   
  249. 00008438 <main>:  
  250. main():  
  251.     8438:   e92d4800    push    {fp, lr}  
  252.     843c:   e28db004    add fp, sp, #4  ; 0x4  
  253.     8440:   e59f0014    ldr r0, [pc, #20]   ; 845c <main+0x24>  
  254.     8444:   ebffffcb    bl  8378 <_init+0x48>  
  255.     8448:   e3a03000    mov r3, #0  ; 0x0  
  256.     844c:   e1a00003    mov r0, r3  
  257.     8450:   e24bd004    sub sp, fp, #4  ; 0x4  
  258.     8454:   e8bd4800    pop {fp, lr}  
  259.     8458:   e12fff1e    bx  lr  
  260.     845c:   000084e8    .word   0x000084e8  
  261.   
  262. 00008460 <__libc_csu_fini>:  
  263. __libc_csu_fini():  
  264.     8460:   e12fff1e    bx  lr  
  265.   
  266. 00008464 <__libc_csu_init>:  
  267. __libc_csu_init():  
  268.     8464:   e92d47f0    push    {r4, r5, r6, r7, r8, r9, sl, lr}  
  269.     8468:   e1a08001    mov r8, r1  
  270.     846c:   e1a07002    mov r7, r2  
  271.     8470:   e1a0a000    mov sl, r0  
  272.     8474:   ebffffad    bl  8330 <_init>  
  273.     8478:   e59f104c    ldr r1, [pc, #76]   ; 84cc <__libc_csu_init+0x68>  
  274.     847c:   e59f304c    ldr r3, [pc, #76]   ; 84d0 <__libc_csu_init+0x6c>  
  275.     8480:   e59f204c    ldr r2, [pc, #76]   ; 84d4 <__libc_csu_init+0x70>  
  276.     8484:   e0613003    rsb r3, r1, r3  
  277.     8488:   e08f2002    add r2, pc, r2  
  278.     848c:   e1b05143    asrs    r5, r3, #2  
  279.     8490:   e0822001    add r2, r2, r1  
  280.     8494:   0a00000a    beq 84c4 <__libc_csu_init+0x60>  
  281.     8498:   e1a06002    mov r6, r2  
  282.     849c:   e3a04000    mov r4, #0  ; 0x0  
  283.     84a0:   e1a0000a    mov r0, sl  
  284.     84a4:   e1a01008    mov r1, r8  
  285.     84a8:   e1a02007    mov r2, r7  
  286.     84ac:   e796c104    ldr ip, [r6, r4, lsl #2]  
  287.     84b0:   e1a0e00f    mov lr, pc  
  288.     84b4:   e12fff1c    bx  ip  
  289.     84b8:   e2844001    add r4, r4, #1  ; 0x1  
  290.     84bc:   e1540005    cmp r4, r5  
  291.     84c0:   3afffff6    bcc 84a0 <__libc_csu_init+0x3c>  
  292.     84c4:   e8bd47f0    pop {r4, r5, r6, r7, r8, r9, sl, lr}  
  293.     84c8:   e12fff1e    bx  lr  
  294.     84cc:   ffffff04    .word   0xffffff04  
  295.     84d0:   ffffff08    .word   0xffffff08  
  296.     84d4:   000081cc    .word   0x000081cc  
  297.   
  298. Disassembly of section .fini:  
  299.   
  300. 000084d8 <_fini>:  
  301. _fini():  
  302.     84d8:   e92d4010    push    {r4, lr}  
  303.     84dc:   e8bd4010    pop {r4, lr}  
  304.     84e0:   e12fff1e    bx  lr  
  305.   
  306. Disassembly of section .rodata:  
  307.   
  308. 000084e4 <_IO_stdin_used>:  
  309.     84e4:   00020001    .word   0x00020001  
  310.     84e8:   6c6c6568    .word   0x6c6c6568  
  311.     84ec:   6f772e6f    .word   0x6f772e6f  
  312.     84f0:   21646c72    .word   0x21646c72  
  313.     84f4:   00000000    .word   0x00000000  
  314.   
  315. Disassembly of section .ARM.extab:  
  316.   
  317. 000084f8 <.ARM.extab>:  
  318.     84f8:   81019b40    .word   0x81019b40  
  319.     84fc:   8480b0b0    .word   0x8480b0b0  
  320.     8500:   00000000    .word   0x00000000  
  321.   
  322. Disassembly of section .ARM.exidx:  
  323.   
  324. 00008504 <.ARM.exidx>:  
  325.     8504:   7fff7afc    .word   0x7fff7afc  
  326.     8508:   80b0b0b0    .word   0x80b0b0b0  
  327.     850c:   7ffffe34    .word   0x7ffffe34  
  328.     8510:   00000001    .word   0x00000001  
  329.     8514:   7ffffea8    .word   0x7ffffea8  
  330.     8518:   80a8b0b0    .word   0x80a8b0b0  
  331.     851c:   7ffffecc    .word   0x7ffffecc  
  332.     8520:   80b0b0b0    .word   0x80b0b0b0  
  333.     8524:   7ffffee0    .word   0x7ffffee0  
  334.     8528:   80a8b0b0    .word   0x80a8b0b0  
  335.     852c:   7fffff0c    .word   0x7fffff0c  
  336.     8530:   7fffffc8    .word   0x7fffffc8  
  337.     8534:   7fffff2c    .word   0x7fffff2c  
  338.     8538:   80b0b0b0    .word   0x80b0b0b0  
  339.     853c:   7fffff28    .word   0x7fffff28  
  340.     8540:   80aeb0b0    .word   0x80aeb0b0  
  341.     8544:   7fffff94    .word   0x7fffff94  
  342.     8548:   00000001    .word   0x00000001  
  343.     854c:   7fff7ab4    .word   0x7fff7ab4  
  344.     8550:   80b0b0b0    .word   0x80b0b0b0  
  345.     8554:   7fffff90    .word   0x7fffff90  
  346.     8558:   00000001    .word   0x00000001  
  347.   
  348. Disassembly of section .eh_frame:  
  349.   
  350. 0000855c <__FRAME_END__>:  
  351.     855c:   00000000    .word   0x00000000  
  352.   
  353. Disassembly of section .init_array:  
  354.   
  355. 00010560 <__frame_dummy_init_array_entry>:  
  356. __init_array_start():  
  357.    10560:   00008404    .word   0x00008404  
  358.   
  359. Disassembly of section .fini_array:  
  360.   
  361. 00010564 <__do_global_dtors_aux_fini_array_entry>:  
  362.    10564:   000083e8    .word   0x000083e8  
  363.   
  364. Disassembly of section .jcr:  
  365.   
  366. 00010568 <__JCR_END__>:  
  367.    10568:   00000000    .word   0x00000000  
  368.   
  369. Disassembly of section .dynamic:  
  370.   
  371. 0001056c <_DYNAMIC>:  
  372.    1056c:   00000001    andeq   r0, r0, r1  
  373.    10570:   00000001    andeq   r0, r0, r1  
  374.    10574:   00000001    andeq   r0, r0, r1  
  375.    10578:   00000060    andeq   r0, r0, r0, rrx  
  376.    1057c:   0000000c    andeq   r0, r0, ip  
  377.    10580:   00008330    andeq   r8, r0, r0, lsr r3  
  378.    10584:   0000000d    andeq   r0, r0, sp  
  379.    10588:   000084d8    ldrdeq  r8, [r0], -r8  
  380.    1058c:   00000019    andeq   r0, r0, r9, lsl r0  
  381.    10590:   00010560    andeq   r0, r1, r0, ror #10  
  382.    10594:   0000001b    andeq   r0, r0, fp, lsl r0  
  383.    10598:   00000004    andeq   r0, r0, r4  
  384.    1059c:   0000001a    andeq   r0, r0, sl, lsl r0  
  385.    105a0:   00010564    andeq   r0, r1, r4, ror #10  
  386.    105a4:   0000001c    andeq   r0, r0, ip, lsl r0  
  387.    105a8:   00000004    andeq   r0, r0, r4  
  388.    105ac:   00000004    andeq   r0, r0, r4  
  389.    105b0:   00008168    andeq   r8, r0, r8, ror #2  
  390.    105b4:   00000005    andeq   r0, r0, r5  
  391.    105b8:   0000821c    andeq   r8, r0, ip, lsl r2  
  392.    105bc:   00000006    andeq   r0, r0, r6  
  393.    105c0:   0000819c    muleq   r0, ip, r1  
  394.    105c4:   0000000a    andeq   r0, r0, sl  
  395.    105c8:   00000099    muleq   r0, r9, r0  
  396.    105cc:   0000000b    andeq   r0, r0, fp  
  397.    105d0:   00000010    andeq   r0, r0, r0, lsl r0  
  398.    105d4:   00000015    andeq   r0, r0, r5, lsl r0  
  399.    105d8:   00000000    andeq   r0, r0, r0  
  400.    105dc:   00000003    andeq   r0, r0, r3  
  401.    105e0:   0001065c    andeq   r0, r1, ip, asr r6  
  402.    105e4:   00000002    andeq   r0, r0, r2  
  403.    105e8:   00000020    andeq   r0, r0, r0, lsr #32  
  404.    105ec:   00000014    andeq   r0, r0, r4, lsl r0  
  405.    105f0:   00000011    andeq   r0, r0, r1, lsl r0  
  406.    105f4:   00000017    andeq   r0, r0, r7, lsl r0  
  407.    105f8:   00008310    andeq   r8, r0, r0, lsl r3  
  408.    105fc:   00000011    andeq   r0, r0, r1, lsl r0  
  409.    10600:   00008308    andeq   r8, r0, r8, lsl #6  
  410.    10604:   00000012    andeq   r0, r0, r2, lsl r0  
  411.    10608:   00000008    andeq   r0, r0, r8  
  412.    1060c:   00000013    andeq   r0, r0, r3, lsl r0  
  413.    10610:   00000008    andeq   r0, r0, r8  
  414.    10614:   6ffffffe    svcvs   0x00fffffe  
  415.    10618:   000082c8    andeq   r8, r0, r8, asr #5  
  416.    1061c:   6fffffff    svcvs   0x00ffffff  
  417.    10620:   00000002    andeq   r0, r0, r2  
  418.    10624:   6ffffff0    svcvs   0x00fffff0  
  419.    10628:   000082b6    strheq  r8, [r0], -r6  
  420.     ...  
  421.   
  422. Disassembly of section .got:  
  423.   
  424. 0001065c <_GLOBAL_OFFSET_TABLE_>:  
  425.    1065c:   0001056c    andeq   r0, r1, ip, ror #10  
  426.     ...  
  427.    10668:   00008340    andeq   r8, r0, r0, asr #6  
  428.    1066c:   00008340    andeq   r8, r0, r0, asr #6  
  429.    10670:   00008340    andeq   r8, r0, r0, asr #6  
  430.    10674:   00008340    andeq   r8, r0, r0, asr #6  
  431.    10678:   00000000    andeq   r0, r0, r0  
  432.   
  433. Disassembly of section .data:  
  434.   
  435. 0001067c <__data_start>:  
  436. __data_start():  
  437.    1067c:   00000000    .word   0x00000000  
  438.   
  439. 00010680 <__dso_handle>:  
  440.    10680:   00000000    .word   0x00000000  
  441.   
  442. Disassembly of section .bss:  
  443.   
  444. 00010684 <completed.5903>:  
  445.    10684:   00000000    andeq   r0, r0, r0  
  446.   
  447. Disassembly of section .ARM.attributes:  
  448.   
  449. 00000000 <.ARM.attributes>:  
  450.    0:   00002541    andeq   r2, r0, r1, asr #10  
  451.    4:   61656100    cmnvs   r5, r0, lsl #2  
  452.    8:   01006962    tsteq   r0, r2, ror #18  
  453.    c:   0000001b    andeq   r0, r0, fp, lsl r0  
  454.   10:   00543405    subseq  r3, r4, r5, lsl #8  
  455.   14:   01080206    tsteq   r8, r6, lsl #4  
  456.   18:   04120109    ldreq   r0, [r2], #-265  
  457.   1c:   01150114    tsteq   r5, r4, lsl r1  
  458.   20:   01180317    tsteq   r8, r7, lsl r3  
  459.   24:   Address 0x00000024 is out of bounds.  
  460.   
  461.   
  462. Disassembly of section .comment:  
  463.   
  464. 00000000 <.comment>:  
  465.    0:   43434700    movtmi  r4, #14080  ; 0x3700  
  466.    4:   5328203a    teqpl   r8, #58 ; 0x3a  
  467.    8:   6372756f    cmnvs   r2, #465567744  ; 0x1bc00000  
  468.    c:   20797265    rsbscs  r7, r9, r5, ror #4  
  469.   10:   202b2b47    eorcs   r2, fp, r7, asr #22  
  470.   14:   6574694c    ldrbvs  r6, [r4, #-2380]!  
  471.   18:   30303220    eorscc  r3, r0, r0, lsr #4  
  472.   1c:   2d317139    ldfcss  f7, [r1, #-228]!  
  473.   20:   29363731    ldmdbcs r6!, {r0, r4, r5, r8, r9, sl, ip, sp}  
  474.   24:   332e3420    teqcc   lr, #536870912  ; 0x20000000  
  475.   28:   Address 0x00000028 is out of bounds.  
  476.   
  477.   
  478. Disassembly of section .debug_frame:  
  479.   
  480. 00000000 <.debug_frame>:  
  481.    0:   0000000c    andeq   r0, r0, ip  
  482.    4:   ffffffff    undefined instruction 0xffffffff  
  483.    8:   7c010001    stcvc   0, cr0, [r1], {1}  
  484.    c:   000d0c0e    andeq   r0, sp, lr, lsl #24  
  485.   10:   0000000c    andeq   r0, r0, ip  
  486.   14:   00000000    andeq   r0, r0, r0  
  487.   18:   00008460    andeq   r8, r0, r0, ror #8  
  488.   1c:   00000004    andeq   r0, r0, r4  
  489.   20:   00000020    andeq   r0, r0, r0, lsr #32  
  490.   24:   00000000    andeq   r0, r0, r0  
  491.   28:   00008464    andeq   r8, r0, r4, ror #8  
  492.   2c:   00000074    andeq   r0, r0, r4, ror r0  
  493.   30:   8e200e44    cdphi   14, 2, cr0, cr0, cr4, {2}  
  494.   34:   89028a01    stmdbhi r2, {r0, r9, fp, pc}  
  495.   38:   87048803    strhi   r8, [r4, -r3, lsl #16]  
  496.   3c:   85068605    strhi   r8, [r6, #-1541]  
  497.   40:   00088407    andeq   r8, r8, r7, lsl #8  
解释:第一列是段地址与段偏移,第二列是指令操作码,对应ARM指令手册(ARM Architecture Reference Manual)可以看到



对比使用-S选项生成的test.asm和反汇编生成的test.txt的区别为:
(1)反汇编可以生成ARM指令操作码,-S生成的汇编没有指令码
(2)反汇编的代码是经过编译器优化过的。
(3)反汇编代码量很大。
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值