2002-03-18 06:25:49

by Jason Li

[permalink] [raw]
Subject: EXPORT_SYMBOL doesn't work


Hi,

Have been puzzled by the problem for a couple of hours now, can some
experts here please help me out. Thanks very much for any info you can
provide here. Please remember to reply back to me also as I am not on
the list yet.

I am trying to use module to do kernel development. Currently I have
some code to be loaded as a module. In the code though I need some hooks
to the existing kernel.

Basically I am working on the bridge code. In the bridge there is a hook
created by myslef as:



int (*fdbIoSwitchHook)(
unsigned long arg0,
unsigned long arg1,
unsigned long arg2)=NULL;
EXPORT_SYMBOL(fdbIoSwitchHook);


The hook will be connected by my module on module_init:

fdbIoSwitchHook = myFdbFunc;

But the symbol fdbIoSwitchHook can't bve resolved by the insmod for my
module.

I saw there is no fdbIoSwitchHook in the /proc/ksyms. My kernel is
versioned it seems.


When I compile the export_symbol file, it did complained:
gcc -D__KERNEL__ -I/home/jli/cvs2/exos/linux/include -Wall
-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
-march=i686 -c -o br_ioctl.o br_ioctl.c
br_ioctl.c:26: warning: type defaults to `int' in declaration of
`EXPORT_SYMBOL'
br_ioctl.c:26: warning: parameter names (without types) in function
declaration
br_ioctl.c:26: warning: data definition has no type or storage class
br_ioctl.c: In function `br_ioctl_device':
br_ioctl.c:206: warning: implicit declaration of function `fdbShow'

Can someone please shed some light on this please? I don't understand
why the symbol is not exported and what I need to do to finished my task
ahead.

Best regards,
Jason


2002-03-18 06:35:11

by Keith Owens

[permalink] [raw]
Subject: Re: EXPORT_SYMBOL doesn't work

On Sun, 17 Mar 2002 22:25:16 -0800,
Jason Li <[email protected]> wrote:
>int (*fdbIoSwitchHook)(
> unsigned long arg0,
> unsigned long arg1,
> unsigned long arg2)=NULL;
>EXPORT_SYMBOL(fdbIoSwitchHook);
>gcc -D__KERNEL__ -I/home/jli/cvs2/exos/linux/include -Wall
>-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
>-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
>-march=i686 -c -o br_ioctl.o br_ioctl.c
>br_ioctl.c:26: warning: type defaults to `int' in declaration of
>`EXPORT_SYMBOL'

#include <linux/module.h>

Also add br_ioctl.o to export-objs in Makefile.

2002-03-18 19:12:12

by Jason Li

[permalink] [raw]
Subject: Re: EXPORT_SYMBOL doesn't work

Keith Owens wrote:
>
> On Sun, 17 Mar 2002 22:25:16 -0800,
> Jason Li <[email protected]> wrote:
> >int (*fdbIoSwitchHook)(
> > unsigned long arg0,
> > unsigned long arg1,
> > unsigned long arg2)=NULL;
> >EXPORT_SYMBOL(fdbIoSwitchHook);
> >gcc -D__KERNEL__ -I/home/jli/cvs2/exos/linux/include -Wall
> >-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
> >-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
> >-march=i686 -c -o br_ioctl.o br_ioctl.c
> >br_ioctl.c:26: warning: type defaults to `int' in declaration of
> >`EXPORT_SYMBOL'
>
> #include <linux/module.h>
>
> Also add br_ioctl.o to export-objs in Makefile.

Thanks alot. It works.

Now another problem with versioning. It seems even after I have the
following in my module c file the symbol generated is not versioned:

#define MODULE
#include <linux/modversions.h>
#include <linux/kernel.h>

When I do nm on the module, fdbIoSwitchHook is still a pure name without
the version info. Can you please tell me how to enable the versioning
for the symbol fdbIoSwitchHook?

Appreciate your help!

-Jason

2002-03-18 19:20:42

by Tom Rini

[permalink] [raw]
Subject: Re: EXPORT_SYMBOL doesn't work

On Mon, Mar 18, 2002 at 11:11:46AM -0800, Jason Li wrote:
> Keith Owens wrote:
> >
> > On Sun, 17 Mar 2002 22:25:16 -0800,
> > Jason Li <[email protected]> wrote:
> > >int (*fdbIoSwitchHook)(
> > > unsigned long arg0,
> > > unsigned long arg1,
> > > unsigned long arg2)=NULL;
> > >EXPORT_SYMBOL(fdbIoSwitchHook);
> > >gcc -D__KERNEL__ -I/home/jli/cvs2/exos/linux/include -Wall
> > >-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
> > >-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
> > >-march=i686 -c -o br_ioctl.o br_ioctl.c
> > >br_ioctl.c:26: warning: type defaults to `int' in declaration of
> > >`EXPORT_SYMBOL'
> >
> > #include <linux/module.h>
> >
> > Also add br_ioctl.o to export-objs in Makefile.
>
> Thanks alot. It works.
>
> Now another problem with versioning. It seems even after I have the
> following in my module c file the symbol generated is not versioned:

Backup your .config, run 'distclean' or 'mrproper' and try again.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

2002-03-18 19:32:44

by Jason Li

[permalink] [raw]
Subject: Re: EXPORT_SYMBOL doesn't work

Tom Rini wrote:
>
> On Mon, Mar 18, 2002 at 11:11:46AM -0800, Jason Li wrote:
> > Keith Owens wrote:
> > >
> > > On Sun, 17 Mar 2002 22:25:16 -0800,
> > > Jason Li <[email protected]> wrote:
> > > >int (*fdbIoSwitchHook)(
> > > > unsigned long arg0,
> > > > unsigned long arg1,
> > > > unsigned long arg2)=NULL;
> > > >EXPORT_SYMBOL(fdbIoSwitchHook);
> > > >gcc -D__KERNEL__ -I/home/jli/cvs2/exos/linux/include -Wall
> > > >-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
> > > >-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
> > > >-march=i686 -c -o br_ioctl.o br_ioctl.c
> > > >br_ioctl.c:26: warning: type defaults to `int' in declaration of
> > > >`EXPORT_SYMBOL'
> > >
> > > #include <linux/module.h>
> > >
> > > Also add br_ioctl.o to export-objs in Makefile.
> >
> > Thanks alot. It works.
> >
> > Now another problem with versioning. It seems even after I have the
> > following in my module c file the symbol generated is not versioned:
>
> Backup your .config, run 'distclean' or 'mrproper' and try again.
>
> --
> Tom Rini (TR1265)
> http://gate.crashing.org/~trini/

I followed Keith's instruction. It seems now the problem is that the
inlucde/linux/module/netsym.ver (i put the EXPORT_SYMBOL in netsym.c
now) doesn't have the vesion for the fdbIoSwatichHook symbol.


I wonder if someone tell me how to gernerate the file with latest info,
I may be able to fix this.

In the meantime I did a distclean, and will see.

Thanks,
Jason

2002-03-18 19:43:44

by Jason Li

[permalink] [raw]
Subject: Re: EXPORT_SYMBOL doesn't work

Tom Rini wrote:
>
> On Mon, Mar 18, 2002 at 11:11:46AM -0800, Jason Li wrote:
> > Keith Owens wrote:
> > >
> > > On Sun, 17 Mar 2002 22:25:16 -0800,
> > > Jason Li <[email protected]> wrote:
> > > >int (*fdbIoSwitchHook)(
> > > > unsigned long arg0,
> > > > unsigned long arg1,
> > > > unsigned long arg2)=NULL;
> > > >EXPORT_SYMBOL(fdbIoSwitchHook);
> > > >gcc -D__KERNEL__ -I/home/jli/cvs2/exos/linux/include -Wall
> > > >-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
> > > >-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
> > > >-march=i686 -c -o br_ioctl.o br_ioctl.c
> > > >br_ioctl.c:26: warning: type defaults to `int' in declaration of
> > > >`EXPORT_SYMBOL'
> > >
> > > #include <linux/module.h>
> > >
> > > Also add br_ioctl.o to export-objs in Makefile.
> >
> > Thanks alot. It works.
> >
> > Now another problem with versioning. It seems even after I have the
> > following in my module c file the symbol generated is not versioned:
>
> Backup your .config, run 'distclean' or 'mrproper' and try again.
>
> --
> Tom Rini (TR1265)
> http://gate.crashing.org/~trini/

Just did a distclean. Now the inluce/linux/modules/netsym.ver has the
fdbIoSwitchHook version info.

Recompiled the module. Did a nm on the module, and saw the version info
for the symbol. But when I dod insmod, it still complained about
unresolved symbol fdbIoSwitchHook.

It seems now the version is different between the kernel and the module.
Should I wait for the bzImage compilation to complete and install the
new kernel?


Thanks a lot,
Jason

2002-03-18 19:46:25

by Keith Owens

[permalink] [raw]
Subject: Re: EXPORT_SYMBOL doesn't work

On Mon, 18 Mar 2002 11:11:46 -0800,
Jason Li <[email protected]> wrote:
>Now another problem with versioning. It seems even after I have the
>following in my module c file the symbol generated is not versioned:
>
>#define MODULE
>#include <linux/modversions.h>
>#include <linux/kernel.h>

Never include modverversions.h yourself, the kernel build process
automatically includes it when required. See also
http://www.tux.org/lkml/#s8-8.

2002-03-19 00:23:14

by Tom Rini

[permalink] [raw]
Subject: Re: EXPORT_SYMBOL doesn't work

On Mon, Mar 18, 2002 at 11:43:20AM -0800, Jason Li wrote:
> Tom Rini wrote:
> >
> > On Mon, Mar 18, 2002 at 11:11:46AM -0800, Jason Li wrote:
> > > Keith Owens wrote:
> > > >
> > > > On Sun, 17 Mar 2002 22:25:16 -0800,
> > > > Jason Li <[email protected]> wrote:
> > > > >int (*fdbIoSwitchHook)(
> > > > > unsigned long arg0,
> > > > > unsigned long arg1,
> > > > > unsigned long arg2)=NULL;
> > > > >EXPORT_SYMBOL(fdbIoSwitchHook);
> > > > >gcc -D__KERNEL__ -I/home/jli/cvs2/exos/linux/include -Wall
> > > > >-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
> > > > >-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
> > > > >-march=i686 -c -o br_ioctl.o br_ioctl.c
> > > > >br_ioctl.c:26: warning: type defaults to `int' in declaration of
> > > > >`EXPORT_SYMBOL'
> > > >
> > > > #include <linux/module.h>
> > > >
> > > > Also add br_ioctl.o to export-objs in Makefile.
> > >
> > > Thanks alot. It works.
> > >
> > > Now another problem with versioning. It seems even after I have the
> > > following in my module c file the symbol generated is not versioned:
> >
> > Backup your .config, run 'distclean' or 'mrproper' and try again.
> >
> > --
> > Tom Rini (TR1265)
> > http://gate.crashing.org/~trini/
>
> Just did a distclean. Now the inluce/linux/modules/netsym.ver has the
> fdbIoSwitchHook version info.
>
> Recompiled the module. Did a nm on the module, and saw the version info
> for the symbol. But when I dod insmod, it still complained about
> unresolved symbol fdbIoSwitchHook.
>
> It seems now the version is different between the kernel and the module.
> Should I wait for the bzImage compilation to complete and install the
> new kernel?

There are annoying depenancies with modversions. Basically the safe way
is that if you change any export (add/remove), you should do a
'distclean', recompile everything and switch to that.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

2002-03-20 06:20:00

by Jason Li

[permalink] [raw]
Subject: Re: EXPORT_SYMBOL doesn't work

Tom Rini wrote:
>
> On Mon, Mar 18, 2002 at 11:43:20AM -0800, Jason Li wrote:
> > Tom Rini wrote:
> > >
> > > On Mon, Mar 18, 2002 at 11:11:46AM -0800, Jason Li wrote:
> > > > Keith Owens wrote:
> > > > >
> > > > > On Sun, 17 Mar 2002 22:25:16 -0800,
> > > > > Jason Li <[email protected]> wrote:
> > > > > >int (*fdbIoSwitchHook)(
> > > > > > unsigned long arg0,
> > > > > > unsigned long arg1,
> > > > > > unsigned long arg2)=NULL;
> > > > > >EXPORT_SYMBOL(fdbIoSwitchHook);
> > > > > >gcc -D__KERNEL__ -I/home/jli/cvs2/exos/linux/include -Wall
> > > > > >-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
> > > > > >-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
> > > > > >-march=i686 -c -o br_ioctl.o br_ioctl.c
> > > > > >br_ioctl.c:26: warning: type defaults to `int' in declaration of
> > > > > >`EXPORT_SYMBOL'
> > > > >
> > > > > #include <linux/module.h>
> > > > >
> > > > > Also add br_ioctl.o to export-objs in Makefile.
> > > >
> > > > Thanks alot. It works.
> > > >
> > > > Now another problem with versioning. It seems even after I have the
> > > > following in my module c file the symbol generated is not versioned:
> > >
> > > Backup your .config, run 'distclean' or 'mrproper' and try again.
> > >
> > > --
> > > Tom Rini (TR1265)
> > > http://gate.crashing.org/~trini/
> >
> > Just did a distclean. Now the inluce/linux/modules/netsym.ver has the
> > fdbIoSwitchHook version info.
> >
> > Recompiled the module. Did a nm on the module, and saw the version info
> > for the symbol. But when I dod insmod, it still complained about
> > unresolved symbol fdbIoSwitchHook.
> >
> > It seems now the version is different between the kernel and the module.
> > Should I wait for the bzImage compilation to complete and install the
> > new kernel?
>
> There are annoying depenancies with modversions. Basically the safe way
> is that if you change any export (add/remove), you should do a
> 'distclean', recompile everything and switch to that.
>
> --
> Tom Rini (TR1265)
> http://gate.crashing.org/~trini/

In case I haven't concluded this thread yet, all the info worked for me.

After the distclean everything is in place and it works nicely now.

Will try more when I get a little bit more time.

Huge thanks to Tom and Keith for their input.

-Jason