Specifications
136 asm volatile(" bl 0f" ::: "lr");
(gdb) s
137 asm volatile("0: mflr 3" ::: "r3");
(gdb)
138 asm volatile(" addi 4, 0, 14" ::: "r4");
(gdb)
cpu_init_f is the first C function called from the code in start.C.
10.1.2. Debugging of U-Boot After Relocation
For debugging U-Boot after relocation we need to know the address to which U-Boot relocates itself to. When
no exotic features like PRAM are used, this address usually is <MAXMEM> - CONFIG_SYS_MONITOR_LEN.
In our example with 16MB RAM and CONFIG_SYS_MONITOR_LEN = 192KB this yields the address
0x1000000 - 0x30000 = 0xFD0000.
In other cases, check the source code, and apply some common sense. For example, on Power Architecture®
we use "r2" to hold a pointer to the "global data" structure ("struct global_data"); this structure
contains a field
unsigned long relocaddr; /* Start address of U-Boot in RAM */
which is the start addresses of U-Boot after relocation to RAM. You can easily print this value in gdb like
that:
(gdb) print/x ((gd_t *)$r2)->relocaddr
With this knowledge, we can instruct gdb to forget the old symbol table and reload the symbols with our
calculated offset:
(gdb) symbol-file
Discard symbol table from `/home/dzu/denx/cvs-trees/u-boot/u-boot'? (y or n) y
No symbol file now.
(gdb) add-symbol-file u-boot 0xfd0000
add symbol table from file "u-boot" at
.text_addr = 0xfd0000
(y or n) y
Reading symbols from u-boot...done.
(gdb) b board_init_r
Breakpoint 2 at 0xfd99ac: file board.c, line 533.
(gdb) c
Continuing.
Breakpoint 2, board_init_r (id=0xfbb1f0, dest_addr=16495088) at board.c:533
533 {
(gdb)
board_init_r is the first C routine running in the newly relocated C friendly RAM environment.
The simple example above relocates the symbols of only one section, .text. Other sections of the
executable image (like .data, .bss, etc.) are not relocated and this prevents gdb from accessing static and
global variables by name. See more sophisticated examples in section 10.3. GDB Startup File and Utility
Scripts.
10.2. Linux Kernel Debugging
10.2. Linux Kernel Debugging 131