Using __attribute__((weak)) in the kernel

2010-03-23 Thread Patrick Mahan

All,

Has anyone used the weak function attribute in the kernel?

I have some modules providing APIs that I want to allow them to be either
loaded via kldload or directly built in the kernel.  However, the API functions
are being referenced by code that cannot (at this time) be moved out of the
kernel.  If I understand the use of the weak attribute, I should be able to
define these functions as weak and they should be over-written either by
the real code functions at kernel link or when kldload() is called.

Or am I mis-understanding the use of this attribute?

Thanks,

Patrick
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: Using __attribute__((weak)) in the kernel

2010-03-23 Thread Ryan Stone
I severely doubt that the kernel linker supports that.  I believe that
the only way to accomplish what you're looking for is to leave
function pointers in the kernel that you can call, and your module can
change the function pointers at load/unload.  Don't forget to have
some kind of synchronization to prevent a function pointer from being
called as it is being updated.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org