# Building kernel modules without kernel source code



## holycow (Apr 2, 2009)

Hi! I am new to FreeBSD, and have been an avid Linux user till now. I was wondering if there is a way to build a FreeBSD kernel module without the actual kernel source code installed. (Like linux has the /lib/modules/<kernelversion>/ directory which allows us to build a kernel module against, by using just the specified interfaces). I tried googling for this, to no use 

Thanks in advance!


----------



## fronclynne (Apr 2, 2009)

*Or is this a theoretical question?*

Would be extremely difficult.

Is there a reason you can't just extract the full kernel sources somewhere?


----------



## holycow (Apr 2, 2009)

Yes there is a very good reason why I cant do it. The actual kernel has been "proprieterized", and the source code not released to me. 

I tried compiling on vanilla FreeBSD 6.1, and it does load successfully into the proprietary FreeBSD kernel, but panics the kernel as soon as I start using it.


----------



## holycow (Apr 2, 2009)

> Or is this a theoretical question?

How I would have wished it was a theoretical question only! But unfortunately if I cant do this soon, I better have a very good reason why it cannot be done. I do not have enough knowledge to say exactly why it can or cannot be done.

My *unsupported* belief is that - Linux, due to GPL issues, has a well defined set of symbols exported (through EXPORT_SYMBOL and EXPORT_SYMBOL_GPL), But freeBSD not encumbered by GPL has no such interfaces, and you can technically call into any function inside the core kernel. Does this make any sense? Can it be true? I do not have enough experience with FreeBSD to verify it myself.


----------



## gordon@ (Apr 2, 2009)

holycow said:
			
		

> Yes there is a very good reason why I cant do it. The actual kernel has been "proprieterized", and the source code not released to me.
> 
> I tried compiling on vanilla FreeBSD 6.1, and it does load successfully into the proprietary FreeBSD kernel, but panics the kernel as soon as I start using it.



Well, you might be out of luck here. It wouldn't be that hard for your vendor to make sure you can't load modules. Your best recourse is to ask them if it would be possible to get a package to build the module.

The BSD license specifically allows the vendor to do this sort of thing, so you might have a hard time if the vendor doesn't want to cooperate (and you might be breaking your license anyway).


----------



## holycow (Apr 2, 2009)

Actually the vendor has made a commitment to help us, but it is just that he is, lets just say, a bit overworked.  . So we clearly do not have any legal issues with trying to load in our module. Also I am pretty sure he does not explicitly prevent loading modules (or fail them when loaded).

So is it technically impossible to build a kernel module without the complete kernel source code? any other files (like kernel header files) can be used to make this happen?


----------

