Hi... On Wed, Apr 16, 2008 at 6:44 AM, Bobby Holley <bobbyholley@xxxxxxxxxxxx> wrote: > Hello, > > I'm porting a kernel module (originally x86) to an OpenWRT environment > (MIPS) running a 2.4 kernel. The module has multiple files. > > In foo.h, there is: > > -- > extern kmem_cache_t *my_cache; > -- > > > then in foo.c (includes foo.h), there is: > > > -- > kmem_cache_t *my_cache; > -- > > > When I loaded the module for the first time I got a segfault, which I > traced to one of the first few lines of the init function: > > > -- > my_cache = kmem_cache_create(...); > -- > > > I spent a lot of time tearing my hair out trying to figure out why > kmem_cache_create was segfaulting before realizing that I got the same > behavior just setting my_cache to any value. I then discovered that if I > declare my_cache as static, the problem goes away (this doesn't work for the > module as a whole, since many files in the module want to access my_cache). Good hint . I think, by putting "static" next to your symbol .... it is put into a memory area that is allocated during module load (thus the address is valid, therefore not triggering segfault). If it's true, then BSS, in MIPS env, isn't assigned zero pages or assigned run time allocated address. just 0.000000002 cents idea, but I am sure you got the point. So the solution? Hack the ld script to make MIPS more or less behave like x86 when dealing with .bss. regards. Mulyadi. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ