0

I want to build a kernel moduel which has external symbols to a static library for my BBB using bitbake.

This issues is that my static lib gets not linked into the kernel module and remains with missing symbols.

Using this Makefile sequence:

obj-m += hcsr04.o
hcsr04-src := hcsr04.o 
SRC := $(shell pwd)
all:
    $(MAKE) -C $(KERNEL_SRC) M=$(SRC)

modules_install:
    $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install

results in a binary which of course has missing symbols as shown by nm like (just a snippet)

         U printk
00000004 b pruData
00000000 b pruDataMem
         U prussdrv_exec_program
         U prussdrv_exit
         U prussdrv_init
         U prussdrv_map_prumem
         U prussdrv_open
         U prussdrv_pru_clear_event
         U prussdrv_pru_disable
         U prussdrv_pruintc_init
         U prussdrv_pru_wait_event

That makes sense for me so far.

Now, if I set my makefile like this (libprussdrv.a is the lib I need to link against):

obj-m += hcsr04.o
hcsr04-src := hcsr04.o 
hcsr04-objs := hcsr04.o libprussdrv.a
SRC := $(shell pwd)
all:
    $(MAKE) -C $(KERNEL_SRC) M=$(SRC)

modules_install:
    $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install

I receive a lot smaller module containing just these symbols:

00000000 d $d
00000000 r $d
00000000 r $d
00000024 r __module_depends
00000000 D __this_module
00000000 r __UNIQUE_ID_srcversion9
0000002d r __UNIQUE_ID_vermagic8
00000000 r ____versions

I tried to specify -l[libpostfix].a to any rules but no success.

Am I on the wrong track or what am I missing to link the library into my kernel module?

x'mpl'
  • 53
  • 11
  • It seems that the answer https://stackoverflow.com/a/34190764/3440745 describes specifically your case - having the same names both for a module and for its source file. But in case of multiple source files this doesn't work. – Tsyvarev Sep 10 '18 at 23:00
  • I already looked into these but did not succeed in building the module. It turned out that this was not caused by the makefile but by a different error which looked quite similar. This isses is therefor duplicated/redundant and can be deleted. – x'mpl' Sep 16 '18 at 18:28

0 Answers0