内核模块找不到调试符号 [英] kernel module no debugging symbols found
本文介绍了内核模块找不到调试符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
user @ c4:$ insmod mmaptest.ko
我可以验证它是通过
user @ c4:$ cat / proc / modules
mmaptest 12727 0 - Live 0x0000000000000000(OF)
,但所有段均以0x00地址列出。
user @ c4 $:$ systool -vm mmaptest
Module =mmaptest
属性:
coresize =12727
initsize =0
initstate =live
refcnt =0
srcversion =EABEF6F90BEAAD0D15B576A
taint =OF
uevent =<仅存储方法>
参数:
count =0
部分:
.bss =0x0000000000000000
.data =0x0000000000000000
.exit.text =0x0000000000000000
.gnu.linkonce.this_module =0x0000000000000000
.init.text =0x0000000000000000
.note.gnu.build-id = 0x0000000000000000
.rodata =0x0000000000000000
.rodata.str1.1 =0x0000000000000000
.rodata.str1.8 =0x0000000000000000
.smp_locks =0x0000000000000000
.strtab =0x0000000000000000
.symtab =0x0000000000000000
.text =0x0000000000000000
__mcount_loc =0x0000000000000000
__param =0x0000000000000000$因此,当我尝试从不正确的(?)地址的模块文本段中加载符号时,我得到:
p>
(gdb)add-symbol-file /home/mmaptest/mmaptest.ko 0x00
从文件中添加符号表/ home / mmaptest / mmaptest .ko在
.text_addr = 0x0
(y或n)y
读取/home/mmaptest/mmaptest.ko...中的符号(没有找到调试符号**) ...完成。
这是关于模块本身还是加载到内核代码中的情况?为什么所有地址都是0x000000000000?
解决方案
我的标记不正确。调试符号表是用这个makefile构建的:
obj -m + = mmaptest.o
MY_CFLAGS + = -g -DDEBUG
ccflags-y + = $ {MY_CFLAGS}
CC + = $ {MY_CFLAGS}
全部:
make -C / lib / modules / $(shell uname -r)/ build M = $(PWD)模块
debug:
make -C / lib / modules / $(shell uname -r)/ build M = $(PWD)模块
EXTRA_CFLAGS =$(MY_CFLAGS)
clean:make -C / lib / modules / $(shell uname -r)/ build M = $(PWD)clean
现在可以验证:
peter @ c4:$ readelf -S mmaptest.ko | grep debug
$ b $ [24] .debug_info PROGBITS 0000000000000000 00000d40
[25] .rela.debug_info RELA 0000000000000000 00018260
[26] .debug_abbrev PROGBITS 0000000000000000 0000d577
[27 ] .debug_loc PROGBITS 0000000000000000 0000dd54
[28] .rela.debug_loc RELA 0000000000000000 00029510
[29] .debug_aranges PROGBITS 0000000000000000 0000e5d5
[30] .rela.debug_arang RELA 0000000000000000 0002a3e0
[31] .debug_ranges PROGBITS 0000000000000000 0000e645
[32] .rela.debug_range RELA 0000000000000000 0002a458
[33] .debug_line PROGBITS 0000000000000000 0000e815
[34] .rela.debug_line RELA 0000000000000000 0002a878
[35] .debug_str PROGBITS 0000000000000000 0000f4cd
[38] .debug_frame PROGBITS 0000000000000000 00016e80
[39] .rela.deb ug_frame RELA 0000000000000000 0002a8c0
从文件/home/peter/projects/svn/linux_kernel/mmaptest/mmaptest.ko添加符号表
at .text_addr = 0x0
(y或n)y
读取/home/peter/projects/svn/linux_kernel/mmaptest/mmaptest.ko...done中的符号。
(gdb)
After I loaded linux kernel module with
user@c4:$ insmod mmaptest.ko
I can verify that it is loaded via
user@c4:$ cat /proc/modules
mmaptest 12727 0 - Live 0x0000000000000000 (OF)
but all segments are listed with 0x00 addresses.
user@c4$:$ systool -vm mmaptest
Module = "mmaptest"
Attributes:
coresize = "12727"
initsize = "0"
initstate = "live"
refcnt = "0"
srcversion = "EABEF6F90BEAAD0D15B576A"
taint = "OF"
uevent = <store method only>
Parameters:
count = "0"
Sections:
.bss = "0x0000000000000000"
.data = "0x0000000000000000"
.exit.text = "0x0000000000000000"
.gnu.linkonce.this_module= "0x0000000000000000"
.init.text = "0x0000000000000000"
.note.gnu.build-id = "0x0000000000000000"
.rodata = "0x0000000000000000"
.rodata.str1.1 = "0x0000000000000000"
.rodata.str1.8 = "0x0000000000000000"
.smp_locks = "0x0000000000000000"
.strtab = "0x0000000000000000"
.symtab = "0x0000000000000000"
.text = "0x0000000000000000"
__mcount_loc = "0x0000000000000000"
__param = "0x0000000000000000"
Thus when I try to load symbols from module text segment at incorrect (?) addresses I get:
(gdb) add-symbol-file /home/mmaptest/mmaptest.ko 0x00
add symbol table from file "/home/mmaptest/mmaptest.ko" at
.text_addr = 0x0
(y or n) y
Reading symbols from /home/mmaptest/mmaptest.ko...(**no debugging symbols found**)...done.
Is this the case about module itself or loading into kernel code? Why all addresses are 0x000000000000?
解决方案
My flags were incorrect. Debugging symbol table is built with this makefile:
obj-m += mmaptest.o
MY_CFLAGS += -g -DDEBUG
ccflags-y += ${MY_CFLAGS}
CC += ${MY_CFLAGS}
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
debug:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
EXTRA_CFLAGS="$(MY_CFLAGS)"
clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
This can be verified now with:
peter@c4:$ readelf -S mmaptest.ko | grep debug
[24] .debug_info PROGBITS 0000000000000000 00000d40
[25] .rela.debug_info RELA 0000000000000000 00018260
[26] .debug_abbrev PROGBITS 0000000000000000 0000d577
[27] .debug_loc PROGBITS 0000000000000000 0000dd54
[28] .rela.debug_loc RELA 0000000000000000 00029510
[29] .debug_aranges PROGBITS 0000000000000000 0000e5d5
[30] .rela.debug_arang RELA 0000000000000000 0002a3e0
[31] .debug_ranges PROGBITS 0000000000000000 0000e645
[32] .rela.debug_range RELA 0000000000000000 0002a458
[33] .debug_line PROGBITS 0000000000000000 0000e815
[34] .rela.debug_line RELA 0000000000000000 0002a878
[35] .debug_str PROGBITS 0000000000000000 0000f4cd
[38] .debug_frame PROGBITS 0000000000000000 00016e80
[39] .rela.debug_frame RELA 0000000000000000 0002a8c0
add symbol table from file "/home/peter/projects/svn/linux_kernel/mmaptest/mmaptest.ko"
at .text_addr = 0x0
(y or n) y
Reading symbols from /home/peter/projects/svn/linux_kernel/mmaptest/mmaptest.ko...done.
(gdb)
这篇关于内核模块找不到调试符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文