How to rename a kernel module name without renaming the .ko passed to insmod?

笑着哭i 提交于 2019-12-05 09:19:46

Rename your obj-m in Makefile and set dependency of obj-m to original module.

For example, I have file hello.c that contain all of my source code. But I want module to be mynewname.

Here is whole Makefile that does this:

obj-m := mynewname.o 
mynewname-objs := hello.o

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD  := $(shell pwd)

default:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

clean:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) clean

I set obj-m to mynewname.o and make mynewname.o dependant on hello.o. After invoking make you'll get mynewname.ko.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!