[Add] 添加oops测试用ko模块
This commit is contained in:
@ -49,6 +49,9 @@ ifeq (, ${CONFIG_NO_TP})
|
||||
OTHERS += cp_ext_tp
|
||||
endif
|
||||
|
||||
KO_LIST += testing
|
||||
OTHERS += cp_testing
|
||||
|
||||
$(info ** [ KO_LIST ] ** = $(KO_LIST))
|
||||
|
||||
export CROSS_COMPILE=$(patsubst "%",%,$(CONFIG_CROSS_COMPILE_KERNEL))
|
||||
@ -69,12 +72,18 @@ wireless:
|
||||
wiegand-gpio:
|
||||
@$(call MAKE_EXT_KO, extdrv/${@})
|
||||
|
||||
testing:
|
||||
@$(call MAKE_EXT_KO, extdrv/${@})
|
||||
|
||||
cp_ext_wireless:
|
||||
@find extdrv/wireless -name '*.ko' -print -exec cp {} $(INSTALL_DIR)/3rd/ \;
|
||||
|
||||
cp_ext_tp:
|
||||
@find extdrv/tp -name '*.ko' -print -exec cp {} $(INSTALL_DIR)/3rd/ \;
|
||||
|
||||
cp_testing:
|
||||
@find extdrv/testing -name '*.ko' -print -exec cp {} $(INSTALL_DIR)/3rd/ \;
|
||||
|
||||
clean:
|
||||
@for subdir in $(SUBDIRS); do cd $$subdir && $(MAKE) clean && cd $(CUR_DIR); done
|
||||
@rm -f $(INSTALL_DIR)/*.ko
|
||||
|
||||
24
osdrv/extdrv/testing/Makefile
Normal file
24
osdrv/extdrv/testing/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Makefile for the Linux testings.
|
||||
#
|
||||
|
||||
obj-m += oops.o
|
||||
|
||||
all:
|
||||
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNEL_DIR) M=$(shell pwd) modules
|
||||
|
||||
strip:
|
||||
$(CROSS_COMPILE)strip $(MODULE_NAME).ko --strip-unneeded
|
||||
|
||||
clean:
|
||||
find . -name *.d -delete
|
||||
find . -name *.ko | xargs -i rm -rf {}
|
||||
find . -name Module.symvers | xargs -i rm -rf {}
|
||||
find . -name Module.markers | xargs -i rm -rf {}
|
||||
find . -name modules.order | xargs -i rm -rf {}
|
||||
find . -name *.mod.c | xargs -i rm -rf {}
|
||||
find . -name *.mod | xargs -i rm -rf {}
|
||||
find . -name *.o | xargs -i rm -rf {}
|
||||
find . -name *.cmd | xargs -i rm -rf {}
|
||||
find . -name *~ | xargs -i rm -rf {}
|
||||
rm -fr .tmp_versions
|
||||
20
osdrv/extdrv/testing/oops.c
Normal file
20
osdrv/extdrv/testing/oops.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
static int __init trigger_oops_init(void) {
|
||||
int *ptr = (int *)0; // 强制类型转换0地址为指针并尝试读取
|
||||
|
||||
printk(KERN_ALERT "Oops will trigger now!\n");
|
||||
printk(KERN_ALERT "Dereferenced NULL pointer value: %d\n", *ptr);
|
||||
|
||||
return 0; // 加载模块不应该有返回值,但这里返回0避免编译警告。
|
||||
}
|
||||
|
||||
static void __exit trigger_oops_exit(void) {
|
||||
printk(KERN_ALERT "Oops trigger module exiting\n");
|
||||
}
|
||||
|
||||
module_init(trigger_oops_init);
|
||||
module_exit(trigger_oops_exit);
|
||||
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
Reference in New Issue
Block a user