2012年5月18日 星期五

Debug/Run Linux with ICE

1) Open AXD
2) Select "File" -> "Load Memory From File"
   --> Select "arch/arm/boot/Image" and load to address 0x8000 (This is kernel image without zlib header and the original Linux  image with debug info is "vmlinux")

[mingfeng_wu@vl-sa3sw1 linux-2.6.35.12]$ arm-unknown-linux-uclibcgnueabi-objdump -d vmlinux | less

vmlinux:     file format elf32-littlearm


Disassembly of section .init:

c0008000 <stext>:
c0008000:       e321f0d3        msr     CPSR_c, #211    ; 0xd3
c0008004:       ee109f10        mrc     15, 0, r9, cr0, cr0, {0}
c0008008:       eb0000ba        bl      c00082f8 <__lookup_processor_type>
c000800c:       e1b0a005        movs    sl, r5
c0008010:       0a00005e        beq     c0008190 <__error_p>
c0008014:       eb0000d0        bl      c000835c <__lookup_machine_type>
c0008018:       e1b08005        movs    r8, r5
c000801c:       0a000071        beq     c00081e8 <__error_a>
c0008020:       eb0000df        bl      c00083a4 <__vet_atags>
c0008024:       eb000013        bl      c0008078 <__create_page_tables>
c0008028:       e59fd0f0        ldr     sp, [pc, #240]  ; c0008120 <__switch_data>
c000802c:       e28fe000        add     lr, pc, #0
c0008030:       e28af010        add     pc, sl, #16

c0008034 <__enable_mmu>:
c0008034:       e3800002        orr     r0, r0, #2
c0008038:       e3a0501f        mov     r5, #31
c000803c:       ee035f10        mcr     15, 0, r5, cr3, cr0, {0}
c0008040:       ee024f10        mcr     15, 0, r4, cr2, cr0, {0}
c0008044:       ea000005        b       c0008060 <__turn_mmu_on>
c0008048:       e1a00000        nop                     ; (mov r0, r0)
c000804c:       e1a00000        nop                     ; (mov r0, r0)
c0008050:       e1a00000        nop                     ; (mov r0, r0)
c0008054:       e1a00000        nop                     ; (mov r0, r0)
c0008058:       e1a00000        nop                     ; (mov r0, r0)
c000805c:       e1a00000        nop                     ; (mov r0, r0)

.............

You can see that we have to load the "arch/arm/boot/Image" and load to address 0x8000.

3) After successfully loading the image to ICE, set the PC to 0x8000
4) Modify register r1 to "xxx" <-- MACH_TYPE_XXX
4) You can set breakpoint or watchpoint or just press run

沒有留言:

張貼留言