I have compiled my kernel with the following kernel option enabled. That should be enough.
CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y
CONFIG_DEBUG_INFO=y
I want to implement a tcp socket server under kernel space. However when I debug my kernel, gdb seems can't recognize function symbol. Question marks are shown.
#0 0xffffffffb92ef58a in ?? ()
#1 0xffffffffb92ef6dd in ?? ()
#2 0xffffb4a640c73c38 in ?? ()
#3 0xffff9b0c275587c0 in ?? ()
#4 0xffff9b0c5c9fbc00 in ?? ()
#5 0xffff9b0c7c3ec480 in ?? ()
#6 0xffffffffc063d000 in ?? ()
#7 0xffffffffc063b22e in myserver ()
at /home/river/Desktop/kernel-sock/server.c:75
#8 0xffffffffc063b285 in server_init ()
at /home/river/Desktop/kernel-sock/server.c:88
#9 0xffffffffb8e0218e in ?? ()
#10 0xffff9b0c7ffeb5c0 in ?? ()
#11 0x000000000000001f in ?? ()
#12 0x85ce74a569aec8a5 in ?? ()
The current kernel version is 4.9.82.
I disabled CONFIG_DEBUG_RODATA
and CONFIG_RANDOMIZE_BASE.
CONFIG_RANDOMIZE_MEMORY
randomizes the virtual addresses of memory sections, including physical memory mappings, vmalloc, and vemmap.
I think memory address randomizing is the key.