[Click] Kernel static objects

Eddie Kohler kohler at cs.ucla.edu
Thu Jul 24 12:35:02 EDT 2008


Hi Kevin,

This is what Element static_initialize() and static_cleanup() are for.  Is 
there any way you can change your static objects into static *pointers*, which 
being plain old data types should not cause GCC to introduce 
__cxa_atexit/__dso_handle, then initialize the pointers in static_initialize() 
and destroy them in static_cleanup()?

Eddie


springbo at cs.wisc.edu wrote:
> 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
> 
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click


More information about the click mailing list