* error_code: * bit 0 == 0 means no page found, 1 means protection fault * bit 1 == 0 means read, 1 means write * bit 2 == 0 means kernel, 1 means user-mode * bit 3 == 0 means data, 1 means instruction
Tainted形貌‘G’if all modules loaded have a GPL or compatible license‘P’if any proprietary module has been loaded. Modules without a MODULE_LICENSE or with a MODULE_LICENSE that is not recognised by insmod as GPL compatible are assumed to be proprietary.‘F’if any module was force loaded by “insmod -f”.‘S’if the Oops occurred on an SMP kernel running on hardware that hasn’t been certified as safe to run multiprocessor. Currently this occurs only on various Athlons that are not SMP capable.‘R’if a module was force unloaded by “rmmod -f”.‘M’if any processor has reported a Machine Check Exception.‘B’if a page-release function has found a bad page reference or some unexpected page flags.‘U’if a user or user application specifically requested that the Tainted flag be set.‘D’if the kernel has died recently, i.e. there was an OOPS or BUG.‘W’if a warning has previously been issued by the kernel.‘C’if a staging module / driver has been loaded.‘I’if the kernel is working around a sever bug in the platform’s firmware (BIOS or similar).5、Hardware name: Supermicro Super Server/X11SPi-TF, BIOS 3.4 10/30/2020
oops_module.ko: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), BuildID[sha1]=41b822641db831d48e67d8a67501ce3dc7b9bed9, with debug_info, not stripped
显示with debug_info, not stripped,说明编译时带有了符号表,如果没有的话需要加上-g重新编译。
其中一种方式是在Makefile中增加一行:EXTRA_CFLAGS=-g
复制代码
10、使用addr2line
objdump -t my_module.ko | grep my_module_function
addr2line -e ./oops_module.ko 0x15
demo/oops_module/oops_module.c:10
复制代码
-a:在函数名、文件名和行号信息之前,以十六进制情势表现地址。
-b:指定目标文件的格式为bfdname。
-C:将低级别的符号名解码为用户级别的名字。
-e:指定需要转换地址的可执行文件名,默认文件是a.out。
-f:在表现文件名、行号信息的同时表现函数名。
-s:仅表现每个文件名(the base of each file name)去除目录名。
-i:假如需要转换的地址是一个内联函数,则还将打印返回第一个非内联函数的信息。
-j:读取指定section的偏移而不是绝对地址。
-p:使打印更加人性化:每个地址(location)的信息都打印在一行上。
-r:启用或禁用递归量限制。
--help:打印帮助信息。
--version:打印版本号。
11、faddr2line
和addr2line雷同,我的服务器上没装,没有试用。
附录
源码
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("BSD/GPL");
MODULE_AUTHOR("ZHONGYI");
static int init_oopsdemo(void)
{
printk("oops module init! \n");
*((int*)0x00) = 0x19760817;
return 0;
}
module_init(init_oopsdemo);
static void cleanup_oopsdemo(void)
{
printk("oops module exit! \n");
}
module_exit(cleanup_oopsdemo);
MODULE_LICENSE("GPL");
复制代码
Makefile
KVERS = $(shell uname -r)
#oops_module.c
# Kernel modules
obj-m += oops_module.o
# Specify flags for the module compilation.
#EXTRA_CFLAGS=-g -O0
build: kernel_modules
kernel_modules:
make -C /lib/modules/$(KVERS)/build M=$(CURDIR) modules
clean:
make -C /lib/modules/$(KVERS)/build M=$(CURDIR) clean