Debugging a Kernel object (ARM + linux)
1. Attach to the target and stop/break.
2. Load vmlinux (the statically linked executable file that contains the Linux kernel).
data.load.elf
A:CC jayant_amber......squashfsvmlinux /strippart 3. /nocode /noclear
3. Now, display the loaded modules (Linux > Display Modules).
4. Now from the TASK.MODule table, note down the .text sections start address (the red-circled address).
5. Well, you got it, we are now gonna use all the ELF info we can extract from the kernel object. Let’s use the arm utilities to help us out. So, just do ‘arm_v5t_le-readelf -a samdrv.ko > dump.dump’.
6. Find the size of the .data section entry in the Sections Headers part from the dumped file.
7. Lets now calculate the address to relocate the .data section to. Subtract the size of the .data section from the magic number of the kernel object we wanna debug.
0xBF1BC920 – 0x3FD0 = 0xBF1B8950
8. Now load the kernel object, and use the following relocation code as well.
data.load.elf A:CCjayant_amber......Libsamdrv.ko /strippart 3. /gnu /nocode /noclear
/reloc .text at 0xBF044000 /reloc .rodata after .text /reloc .data at 0xBF1B8950
/reloc .bss after .data
9. Congratulations, you can now step through the kernel object and debug it.