Confused about how to apply add-symbol-file in gdb

Chan Kim ckim at etri.re.kr
Mon Jul 18 04:43:16 EDT 2022


Hello all,

I thought I know how to apply add-symbol-file command in gdb but now I'm
confused.
I'm using qemu to test booting linux using u-boot. (arm64)
I've loaded u-boot at 0x4000000 and loaded linux Image (binary, not elf) at
0x80010000. The dtb is loaded at 0x80000000.
(because qemu loads the dtb file at the first address of RAM (which is
0x80000000) I moved kernel image to 0x80010000)
After the PC jumps to linux, I can follow the source while the PC value uses
physical address.
I think this is possible that I gave gdb this command.
add-symbol-file vmlinux -s .head.text 0x80010000 -s .text 0x80020000
(using readelf -e vmlinux command, I can see the section offsets relative to
the start of the Image file. The output starts like this.
Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .head.text        PROGBITS         ffffffc010000000  00010000
       0000000000010000  0000000000000000  AX       0     0     65536
  [ 2] .text             PROGBITS         ffffffc010010000  00020000
       0000000000aa4dc8  0000000000000008  AX       0     0     2048
  [ 3] .got.plt          PROGBITS         ffffffc010ab4dc8  00ac4dc8
       0000000000000018  0000000000000008  WA       0     0     8
  [ 4] .rodata           PROGBITS         ffffffc010ac0000  00ad0000
       0000000000645018  0000000000000000  WA       0     0     4096
  [ 5] .pci_fixup        PROGBITS         ffffffc011105020  01115020
       00000000000025e0  0000000000000000   A       0     0     16
  [ 6] __ksymtab         PROGBITS         ffffffc011107600  01117600
       000000000000b3b8  0000000000000000   A       0     0     4
  [ 7] __ksymtab_gpl     PROGBITS         ffffffc0111129b8  011229b8
...

Now, at the end of __primary_switch function, the PC value becomes virtual.
But I can't follow kernel source from that point.
Until now, I have placed kernel Image at 0x80000000 and dtb was at
0x82800000 and just by giving "add-symbol-file vmlinux" again, there was no
problem following the kernel source in virtual address.
How should I give the add-symbol-file command when the Image is now at
0x80010000??
Any comment welcome.
Thank you.

Chan Kim







More information about the Kernelnewbies mailing list