在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > GNU ARM匯編--(十三)GNU ARM匯編下的linker script

            GNU ARM匯編--(十三)GNU ARM匯編下的linker script

            作者: 時(shí)間:2016-11-26 來源:網(wǎng)絡(luò) 收藏
            在寫GNU ARM匯編下的linker script之前,還是有必要看一下ldr指令,以及l(fā)dr和adr偽指令.

            ldr指令:

            本文引用地址:http://www.biyoush.com/article/201611/321718.htm

            LDR load word into a register Rd <- mem32[address]

            ldr偽指令:

            LDR Rd, =constant

            LDR load constant pseudoinstruction Rd=32-bit constant

            adr偽指令:

            ADR Rd, label

            ADR load address pseudoinstruction Rd=32-bit relative address

            我們的程序從nandflash啟動,運(yùn)行在s3c2440的4K大小的SRAM中,linker script的.text放在. = 0x00000000;處.

            測試代碼如下:

            [cpp]view plaincopy
            1. ldrpc,_main@a
            2. ldrpc,=_main@b
            3. ldrpc,main@c
            4. ldrpc,=main@d
            5. adrpc,_main@e
            6. adrpc,main@e
            7. _main:.wordmain

            main中放置的一個(gè)流水燈.分別測試這六種情況:

            a.成功跳轉(zhuǎn),分析下反匯編:

            [cpp]view plaincopy
            1. 128:e51ff004ldrpc,[pc,#-4];12c<_main>
            2. 0000012c<_main>:
            3. 12c:000002d4.word0x000002d4
            4. ......
            5. 000002d4
              :
            0x00000128+8-4=0x0000012c ldr指令將地址為0x0000012c的word(0x000002d4)放到pc中,那么就跳轉(zhuǎn)到main了.

            b.無法跳轉(zhuǎn),分析下反匯編:

            [cpp]view plaincopy
            1. 128:e59ff244ldrpc,[pc,#580];374
            2. 0000012c<_main>:
            3. 12c:000002d4.word0x000002d4
            4. ......
            5. 000002d4
              :
            0x00000128+580+8=0x00000374 ldr指令將地址為0x00000374的word(374:0000012c.word0x0000012c)放入pc中,自然無法正確跳轉(zhuǎn)

            c.無法跳轉(zhuǎn),分析下反匯編:

            [cpp]view plaincopy
            1. 128:e59ff1a4ldrpc,[pc,#420];2d4
            2. 0000012c<_main>:
            3. 12c:000002d4.word0x000002d4
            4. ......
            5. 000002d4
              :
            0x00000128+420+8=0x000002d4 ldr指令將地址為0x000002d4的word放入pc中,自然也無法跳轉(zhuǎn)

            d.成功跳轉(zhuǎn),分析下反匯編:

            [cpp]view plaincopy
            1. 128:e59ff244ldrpc,[pc,#580];374
            2. 0000012c<_main>:
            3. 12c:000002d4.word0x000002d4
            4. ......
            5. 000002d4
              :
            6. ......
            7. 374:000002d4.word0x000002d4
            0x00000128+580+8=0x00000374 ldr指令將地址為0x00000374的word(000002d4)放入pc中,成功跳轉(zhuǎn)
            e.無法跳轉(zhuǎn),分析下反匯編:

            [cpp]view plaincopy
            1. 128:e24ff004subpc,pc,#4;0x4
            2. 000012c<_main>:
            3. 12c:000002d4.word0x000002d4
            pc=pc+8-4=0x0000012c 所以無法跳轉(zhuǎn)

            f.成功跳轉(zhuǎn),分下下反匯編:

            [cpp]view plaincopy
            1. 128:e28fff69addpc,pc,#420;0x1a4
            2. 0000012c<_main>:
            3. 12c:000002d4.word0x000002d4
            4. ......
            5. 000002d4
              :

            pc=pc+420+8=0x00000128+420+8=0x00002d4 所以成功跳轉(zhuǎn).

            完全理解相對跳轉(zhuǎn)和絕對跳轉(zhuǎn)是為了后面的linker script做準(zhǔn)備的,linker script的理論只是可以看下gnu.org的官方文檔,下面才開始這次的正題.

            給出兩種linker script的寫法:

            1.

            [cpp]view plaincopy
            1. OUTPUT_FORMAT("elf32-littlearm","elf32-littlearm","elf32-littlearm")
            2. OUTPUT_ARCH(arm)
            3. ENTRY(_start)
            4. SECTIONS{
            5. .=0x30000000;
            6. .textALIGN(4):{*(.text)}
            7. .rodataALIGN(4):{*(.rodata)}
            8. .dataALIGN(4):{*(.data)}
            9. .bssALIGN(4):{*(.bss)*(COMMON)}
            10. }

            vma給的是0x30000000,那么跳轉(zhuǎn)就這么跳:


            上一頁 1 2 下一頁

            關(guān)鍵詞: ARM匯編linkerscrip

            評論


            技術(shù)專區(qū)

            關(guān)閉