[Click] Kernel static objects

springbo at cs.wisc.edu springbo at cs.wisc.edu
Thu Jul 24 11:07:34 EDT 2008


Hi,



I've run into a couple of problems when using static objects in kernel
level code. I'm using the click sources from the dev tree as of two weeks
ago, the 2.6.19.2 kernel, gcc v4.1.2 20071124 and a x86_64 multi-threaded
target.



The symbols __cxa_atexit and __dso_handle are undefined when I use static
objects in my elements (See the commented paragraph of
http://www.cygwin.com/ml/ecos-discuss/2003-07/msg00036.html for a concise
explanation). I don't have any destructor dependencies so I simply
supplied my own definitions for these symbols:



#if CLICK_LINUXMODULE

void* __cxa_atexit = &__cxa_atexit;

void* __dso_handle = &__dso_handle;

#endif



Gcc inserts the undefined symbols __cxa_guard_acquire and
__cxa_guard_release into the code to prevent the problem of c++ scoped
static initialization not being thread safe
(http://blogs.msdn.com/oldnewthing/archive/2004/03/08/85901.aspx). One
solution to this is to not use static variables at block scope.
Unfortunately this isn't an option for me since I've run into the "static
initialization order fiasco". Appending "-fno-threadsafe-statics" to the
end of LINUXCFLAGS in the linuxmodule Makefile suppresses the symbols, but
leaves me open to the thread safe issue.



Does anyone have a solution for the __cxa_guard_acquire/release problem?
Or any ideas as to how to proceed?



Thank You,

Kevin Springborn



More information about the click mailing list