Linux: modpost does not build anything

前端 未结 12 1045
-上瘾入骨i
-上瘾入骨i 2020-12-20 14:58

I am having problems getting any kernel modules to build on my machine. Whenever I build a module, modpost always says there are zero modules:

MODPOST 0 modu         


        
相关标签:
12条回答
  • 2020-12-20 15:18

    I solved this problem by correcting Makefile, i.e.:

    obj-m := modulename.o
    
    0 讨论(0)
  • 2020-12-20 15:20

    I spent all day glued to my computer fighting this precise problem..which ended up mysteriously disappearing like for OP.

    I can at least offer this meager detail from my experience: I was getting the same output as OP (for make V=1) and putting print statements in ${kernel_directory}/scripts/makefile.build showed that obj-m was strangely NOT being set after including my makefile, even though it was clearly typed as above.

    I did a bunch of fooling around with the line "obj-m += hello.o" and the ones around it. Eventually it magically worked..although it looked exactly the same as before in the end. Maybe I had copied those lines from a tutorial online and it contained some sort of invalid/incorrect character?

    For anyone experiencing this, verify that obj-m is in fact getting set to hello.o
    If it mysteriously isn't, delete the line, hell the whole Makefile, and retype it.

    I know that's not much help; I wish I could reproduce what happened!

    0 讨论(0)
  • 2020-12-20 15:22

    I guess you copied the contents of the Makefile from a PDF or some HTML document. The hyphens used are somewhat weird. Just try replacing the hyphens in the makefile; it will work like a charm.

    0 讨论(0)
  • 2020-12-20 15:22

    I had the same problem. Finally, I rebuilt the kernel, rewrote the makefile. It worked finally.

    I guess the main reason is because I had M=$(PWD) modules in the following line right after make ARCH=arm...

    0 讨论(0)
  • 2020-12-20 15:23

    I can only guess your kernel build environment is botched, because it passes both the theoretical check (the look of the developer) as well as the practical test:

    make -C /lib/modules/2.6.36-rc8-32-desktop/build M=/dev/shm modules
    make[1]: Entering directory `/usr/src/linux-2.6.36-rc8-32-obj/x86_64/desktop'
    make -C ../../../linux-2.6.36-rc8-32 O=/usr/src/linux-2.6.36-rc8-32-obj/x86_64/desktop/. modules
      CC [M]  /dev/shm/hello.o
      Building modules, stage 2.
      MODPOST 1 modules
      CC      /dev/shm/hello.mod.o
      LD [M]  /dev/shm/hello.ko
    make[1]: Leaving directory `/usr/src/linux-2.6.36-rc8-32-obj/x86_64/desktop'
    
    0 讨论(0)
  • 2020-12-20 15:25

    I was able to solve this problem by putting the

    obj-m += <module name>.o
    

    In a separate file named Kbuild. See Linux/documentation/kbuild/modules.txt for a hint as to why this might work

    0 讨论(0)
提交回复
热议问题