如果download到memory裡的程式有誤,
程式的執行一定不正確。
我們用比對的方式,驗證load進去的code與原始的內容是否相同。
(1) 把memory的內容dump出來。
用Andesight裡的memory view的export功能
記得先在gdb command view裡打
set trust-readonly-sections off讀出來的memory才是真實的內容。
type要選擇RAW binary
Attachment:
export.gif [ 19.68 KiB | Viewed 8185 times ]
用hex editor(16進位檔案編輯器)可以讀檔,例如下面我用pspad開啟檔案
Attachment:
pspad.gif [ 26.07 KiB | Viewed 8185 times ]
(2)從*.adx檔(elf檔),把程式剪出來..
舉個例子..下面.nds32_init的起始點為.adx檔的0x1000開始。(請看File offset)
Attachment:
adx.gif [ 26.31 KiB | Viewed 8185 times ]
Sections:
Idx Name Size VMA LMA File off Algn
0 .nds32_init 00000004 00500000 00500000 00001000 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .init 00000004 00500004 00500004 00001004 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .text 00001dd8 00500010 00500010 00001010 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .rodata 00000020 00501de8 00501de8 00002de8 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
剛才找到這個編輯器滿好用的。
Cygnus Hex Editor 官網如下,要抓Cygnus Hex Editor,非Free版才有這個功能
http://www.softcircuits.com/cygnus/下面是刪除0~0x1000內容的步驟
Attachment:
del1.gif [ 14.41 KiB | Viewed 8182 times ]
Attachment:
del2.gif [ 35.5 KiB | Viewed 8182 times ]
(3)比對hex檔案的內容,下面是我比對結果的截圖
Attachment:
cyg.gif [ 41.68 KiB | Viewed 8183 times ]