gdb not loading kernel module symbols at the correct offset

Kamran Khan krkhan at inspirated.com
Sat Jun 17 21:12:56 EDT 2017


On the guest VM, I'm parsing kernel module's .text address with:

> # cat /sys/module/dm_crypt/sections/{.text,.data}
> 0xffffffffa04ee000
> 0xffffffffa04f3000
> root at ubuntu-zesty:~# cat /proc/kallsyms | grep dm_crypt_exit
> ffffffffa04f14d2 t dm_crypt_exit [dm_crypt]

When I load the module symbols at the .text address, it prompts me for
the correct address:

> (gdb) add-symbol-file drivers/md/dm-crypt.ko 0xffffffffa04ee000 -s .data 0xffffffffa04f3000
> add symbol table from file "drivers/md/dm-crypt.ko" at
> .text_addr = 0xffffffffa04ee000
> .data_addr = 0xffffffffa04f3000
> (y or n) y
> Reading symbols from drivers/md/dm-crypt.ko...done.

But when I query for the module's symbols, they're not loaded at the
appropriate offset, making it impossible to set breakpoints.

> (gdb) info address dm_crypt_exit
> Symbol "dm_crypt_exit" is a function at address 0x4e.
> (gdb) b dm_crypt_exit
> Cannot access memory at address 0x4e

Any ideas what's going wrong?

Thanks,
Kamran.



More information about the Kernelnewbies mailing list