Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug Linux kernel pre-decompression stage

I am trying to use GDB to debug a Linux kernel zImage before it is decompressed. The kernel is running on an ARM target and I have a JTAG debugger connected to it with a GDB server stub. The target has to load a boot loader. The boot loader reads the kernel image from flash and puts it in RAM at 0x20008000, then branches to that location.

I have started GDB and connected to the remote target, then I use GDB's add-symbol-file command like so:

add-symbol-file arch/arm/boot/compressed/vmlinux 0x20008000 -readnow

When I set a breakpoint for that address, it does trap at the correct place - right when it branches to the kernel. However, GDB shows the wrong line from the source of arch/arm/boot/compressed/head.S. It's 4 lines behind. How can I fix this?

I also have tried adding the -s section addr option to add-symbol-file with -s .start 0x20008000; this results in exactly the same problem.

like image 764
Shawn J. Goff Avatar asked Mar 05 '12 23:03

Shawn J. Goff


People also ask

What are Bootargs?

From The iPhone Wiki. These are boot arguments that the iOS kernel accepts. These can be booted with a patched iBoot; untethered BootROM jailbreaks such as redsn0w and checkra1n do this when you set custom boot-args.


1 Answers

There are assembler macros that print out stuff when compiling with low level debug. You have to make sure the macros are appropriate for your board.

linux-latest/arch/arm$ find . -name debug-macro.S | wc
 56      56    2306

Find the file for your board and ensure the correct serial port registers are hit. You can instrument the code with out using JTAG. These macros are used in the decompress code. Of course configure with *CONFIG_DEBUG_LL*.

Most likely the ATAGs are not correct or one of the other requirements. Checkout Documentation/arm/Booting to make sure you have registers set properly. Note there is a new requirement with recent kernels to send a dt list.

like image 92
artless noise Avatar answered Sep 22 '22 14:09

artless noise