Kernel Module; globals badly initialized, help needed.

Bruno Vetel bruno.vetel at wanadoo.fr
Tue Mar 19 11:22:44 EST 2002


Hi

We had a problem similar to yours with an HHL 1.0. An update of insmod et rmmod from busybox
solved our problem

        Bruno

Goddeeris Frederic <Frederic.Goddeeris at siemens.atea.be> writes:

> (This messages was already posted on the linuxppc-dev list, put posting it
> to this list failed...)
>
> Hi,
>
> I am having lots of problems with global variables that are badly
> initialized in a kernel
> module. I wrote some very simple code showing the problem. The compiler
> I use is gcc 2.95.3
> (the one that comes with HHL2.0).
>
> Is this a compiler problem -do I need to use some special options?- or
> could it
> be a problem with insmod, the kernel, ...?
>
> I had this problem before with DECLARE_WAIT_QUEUE_HEAD where the
> pointers inside the structure where badly initialized. The only
> sollution was to reinitialize the fields at runtime. I posted this issue
> and somebody reported he had seen the same issue.
>
> Who can help we with this?
>
> Thanks!
> Frederic
>
>
> #include <linux/module.h>
> #include <linux/kernel.h>
> #include <linux/init.h>
>
>
> #if defined(CONFIG_SMP)
> #define __SMP__
> #endif
>
> #if defined(CONFIG_MODVERSIONS)
> #define MODVERSIONS
> #include <linux/modversions.h>
> #endif
>
> char MyMemSpace[2*0x100];
> char *MemPointers[2] = {&(MyMemSpace[0]), &(MyMemSpace[0x100])};
>
> typedef struct
> {
> 	char *szName;
> 	char *szName2;
> } MyStruct_t;
>
> MyStruct_t MyStruct[] = {{"A", "A2"}, {"B", "B2"}};
>
> int init_module(void)
> {
> 	printk("TestDriver 3 Loaded\n");
>
> 	printk("MyMemSpace: 0x%lx 0x%lx \n",  (long)&(MyMemSpace[0]),
> (long)&(MyMemSpace[0x100]));
> 	printk("MemPointers: 0x%lx 0x%lx \n", (long)(MemPointers[0]),
> (long)(MemPointers[1]));
>
> 	printk("First Char is MyStruct[0].szName %c\n",
> MyStruct[0].szName[0]);
>
>
> 	return -1;
> }
>
> void cleanup_module(void)
> {
> 	return;
> }
>
>
>
>
> This is what I get:
>
> MyMemSpace: 0xc304a1ec 0xc304a2ec
> MemPointers: 0xc304a1ec 0xc304a3ec
> First Char is MyStruct[0].szName e
>
>
>
>

--

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-embedded mailing list