Trace32 symbol relocation
Trace32 relocation
Trace32 Debugging Environment in this posting
The host PC environment is a Windows 11 (x86 PC).
The target board environment is an ARM-A U-Boot
Trace32 symbol relocation is primarily used when debugging U-Boot, as the bootloader itself performs code relocation.
U-Boot bootloader
U-Boot performs relocation to move itself from a limited initial memory (like SRAM or ROM) to a larger memory area (usually DRAM) after initialization.
The main reasons are:
Limited Initial Memory: SRAM or ROM is too small to hold the full U-Boot image.
DRAM Initialization: DRAM is not available at early boot; it must be initialized first.
Code and Data Relocation: After moving to DRAM, pointers, global variables, and function tables must be updated to work correctly.
Stable Runtime Environment: Relocation allows proper use of BSS, stack, and global data in DRAM.
In short, relocation ensures U-Boot can run reliably in a larger, fully initialized memory environment.
Load U-Boot elf
Please refer to the basic debug posting for instructions on how to load symbols.
relocation view..
Relocation
You need to identify the relocation offset first.
There are two cases:
An environment where the U-Boot console is available.
An environment where the console is not available.
Opt1. In U-Boot console
Use bdinfo In console.
=> bdinfo
boot_params = 0x0000000000000000
DRAM bank = 0x0000000000000000
-> start = 0x0000000020000000
-> size = 0x00000000a0000000
DRAM bank = 0x0000000000000001
-> start = 0x00000001a0000000
-> size = 0x0000000160000000
flashstart = 0x0000000000000000
flashsize = 0x0000000000000000
flashoffset = 0x0000000000000000
baudrate = 115200 bps
relocaddr = 0x0000000037f42000
reloc off = 0x0000000007f42000
Build = 64-bit
current eth = unknown
eth-1addr = (not set)
IP addr = 192.168.0.99
fdt_blob = 0x0000000031f393a0
lmb_dump_all:
memory.count = 0x2
memory[0] [0x20000000-0xbfffffff], 0xa0000000 bytes, flags: none
memory[1] [0x1a0000000-0x2ffffffff], 0x160000000 bytes, flags: none
reserved.count = 0x2
reserved[0] [0x30f39390-0xbfffffff], 0x8f0c6c70 bytes, flags: no-overwrite
reserved[1] [0x1a0000000-0x2ffffffff], 0x160000000 bytes, flags: no-overwrite
devicetree = separate
arch_number = 0x0000000000000000
TLB addr = 0x0000000037ff0000
irq_sp = 0x0000000031f39390
sp start = 0x0000000031f39390
Early malloc usage: 1880 / 2000
In this case, reloc offset is 0x7f42000 .
then, run this command in Trace32 PowerView
B:: sYmbol.RELOCate.shift 0x7f42000
Opt2. No U-Boot console
If the console is not available,
you need to find the relocation offset using the ELF symbol information.
Information related to relocation is stored in the gd(Global Data) symbol.
In this case, reloc offset is 0x7f42000 .
then, run this command in Trace32 PowerView
B:: sYmbol.RELOCate.shift 0x7f42000
Result
Before relocation:
After relocation:
Appendix
Relocation offset
Once the relocation address is determined,
subtracting the code’s entry point from it gives the relocation offset.
$ readelf -h u-boot
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: AArch64
Version: 0x1
Entry point address: 0x30000000
Start of program headers: 64 (bytes into file)
Start of section headers: 6399408 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 2
Size of section headers: 64 (bytes)
Number of section headers: 22
Section header string table index: 21
Relocation address is 0x37f42000 .
Entry point is 0x30000000 .
So, reloc offset is 0x7f42000 .