Skip to content

Instantly share code, notes, and snippets.

@tsunghanlin
Created January 11, 2017 05:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsunghanlin/8aedf591867059f522a128f03f98a50d to your computer and use it in GitHub Desktop.
Save tsunghanlin/8aedf591867059f522a128f03f98a50d to your computer and use it in GitHub Desktop.
Debugging u-boot with relocation

Debugging in uboot, especially after uboot relocated, can refer to:

For armv8 target, 'relocaddr' is stored in register x0 (arch/arm/lib/crt0_64.S:102)

$ aarch64-elf-gdb u-boot -x start.gdb 
GNU gdb (Linaro GDB 2015.08) 7.10.0.20151014-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=aarch64-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.launchpad.net/gcc-linaro>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from u-boot...done.
_start () at arch/arm/cpu/armv8/start.S:22
22		b	reset
(gdb) b crt0_64.S :103
Breakpoint 1 at 0x880023c4: file arch/arm/lib/crt0_64.S, line 103.
(gdb) c
Continuing.

Breakpoint 1, _main () at arch/arm/lib/crt0_64.S:103
103		b	relocate_code
6: /x $x29 = 0x8800008c
5: /x $x30 = 0xfffae3c8
4: /x $x18 = 0xfdfa9e00
3: /x $x0 = 0xfffac000
2: /x $sp = 0xfdfa86d0
1: /x $pc = 0x880023c4
(gdb) symbol-file 
Discard symbol table from `/home/johnny/work/u-boot/u-boot'? (y or n) y
Error in re-setting breakpoint 1: No symbol table is loaded.  Use the "file" command.
No symbol file now.
(gdb) add-symbol-file u-boot 0xfffac000
add symbol table from file "u-boot" at
	.text_addr = 0xfffac000
(y or n) y
Reading symbols from u-boot...done.
(gdb) b board_init_r
Breakpoint 2 at 0xfffb70b4: file common/board_r.c, line 976.
(gdb) c
Continuing.

Breakpoint 2, board_init_r (new_gd=0xfdfa9e00, dest_addr=4294623232) at common/board_r.c:976
976	{
(gdb) b arch/arm/lib/bootm.c:198
Breakpoint 3 at 0xfffae680: file arch/arm/lib/bootm.c, line 198.
(gdb) c
Continuing.

Breakpoint 3, do_nonsec_virt_switch () at arch/arm/lib/bootm.c:198
198		armv8_switch_to_el2();
(gdb) stepi
.
.
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment