1

I have a LKM named RtmNetlinkLKM.c and compiles and run fine. The moment I update its Makefile to compile with other src files, it starts giving warning:

WARNING: modpost: missing MODULE_LICENSE()

The following MODULE_LICENSE("GPL"); is already present in kernel module file.

Previous Makefile, module compiles fine

obj-m += RtmNetlinkLKM.o
all:
    make -C /lib/modules/`uname -r`/build M=$(PWD) modules
clean:
    make -C /lib/modules/`uname -r`/build M=$(PWD) clean

updated Makefile, module now compiles with a warning

obj-m += RtmNetlinkLKM.o
RtmNetlinkLKM-objs += rt_kern.o gluethread/glthread.o << Added two more sources
all:
    make -C /lib/modules/`uname -r`/build M=$(PWD) modules
clean:
    make -C /lib/modules/`uname -r`/build M=$(PWD) clean
    rm -f rt_kern.o
    rm -f gluethread/glthread.o

When compiled using second Makefile, it gives stated warning. When I add MODULE_LICENSE("GPL") in gluethread/glthread.c , warning goes away. I don't understand, why do I need to add "GPL" license in glthread.c when it is not a module but contain functions to be used by module (It is a linked list mini-library). Why doesn't it complain with other src file rt_kern.c in a similar way. I had never made any changes in original module file RtmNetlink.c throughout this process.

dragosht
  • 3,237
  • 2
  • 23
  • 32
Abhishek Sagar
  • 1,189
  • 4
  • 20
  • 44
  • List `RtmNetlinkLKM-objs` specifies object files to be created (from corresponded sources). This list contains `rt_kern.o` and `gluethread/glthread.o`, but doesn't contain `RtmNetlinkLKM.o`. (Well, the list simply couldn't contain `RtmNetlinkLKM.o` as Linux kernel build system doesn't support listing of an object file with the same name as the target module.) – Tsyvarev Feb 22 '20 at 20:18
  • So, r u suggesting to include RtmNetlinkLKM.o to the list or not sir ? Even if i add, same warning still coming up. – Abhishek Sagar Feb 22 '20 at 20:25
  • See that question: https://stackoverflow.com/questions/13606075/building-a-kernel-module-from-several-source-files-which-one-of-them-has-the-sam. – Tsyvarev Feb 22 '20 at 21:54

1 Answers1

0

Thanks to @Gautham Kantharaju in link provided by @Tsyvarev for solving my problem. While compiling multiple source files into a single module, the main reason for the warning seems to be, ".. it is not possible to have the module name and the source name to be the same."

If anyone else has the same question, I think following Makefile should solve the issue.

# give your module a different Name

obj-m += newModuleName.o
newModuleName-objs += RtmNetlinkLKM.o rt_kern.o gluethread/glthread.o 

all:
    make -C /lib/modules/`uname -r`/build M=$(PWD) modules
clean:
    make -C /lib/modules/`uname -r`/build M=$(PWD) clean
    
user45698746
  • 305
  • 2
  • 13