linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: Exporting symbols from a module.
@ 2001-05-17 18:46 Khachaturov, Vassilii
  0 siblings, 0 replies; 7+ messages in thread
From: Khachaturov, Vassilii @ 2001-05-17 18:46 UTC (permalink / raw)
  To: 'Anders Peter Fugmann', Andreas Dilger; +Cc: linux-kernel

If you have a local makefile with which you wish to build your module 
not linked under the kernel tree in the proper way, you still can
"ride" on the master Makefile.

This way one can eliminate the dependency on your particular 
machine kernel compilation options to be hardwired in the local Makefile.
I.e., once you reconfigure the kernel, your driver will compile
itself when you do a local "make" with the correct set of the new flags.

This is what you can do on 2.2 (Makefile excerpt follows):
EXTRA_CFLAGS := -DDEBUG -DLINUX -I/usr/src/foo/include
MI_OBJS  := your-module.o
O_TARGET := your-module.o
O_OBJS   := your1.o your2.o

# Reuse Linux kernel master makefile on this directory
ifdef MAKING_MODULES
include $(TOPDIR)/Rules.make
else
all::
        cd '/usr/src/linux' && make modules SUBDIRS=$(PWD)
endif

In 2.4 the syntax is different. Rename
MI_OBJS to obj-m and O_OBJS to obj-y to achieve the same goal there:
obj-m  := your-module.o
O_TARGET := your-module.o
obj-y   := your1.o your2.o

HTH,
	Vassilii

> -----Original Message-----
> From: Anders Peter Fugmann [mailto:afu@fugmann.dhs.org]
> Sent: Thursday, May 17, 2001 12:51 PM
> To: Andreas Dilger
> Cc: linux-kernel
> Subject: Re: Exporting symbols from a module.
> 
> 
> Resolved.
> 
> I just looked at what the kernel did whne compiling a module that 
> exported some symbols, and discovered that I needed
> to set CFLAGS to:
> 
> -D__KERNEL__ -I$/usr/src/linux)  -Wall -Wstrict-prototypes \
> -O2 -fomit-frame-pointer -fno-strict-aliasing -pipe \
> -DMODULE  -DMODVERSIONS -include \
> /usr/src/linux/modversions.h
> 
> Now all works correctly, and I can load my modules.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Exporting symbols from a module.
  2001-05-17 11:28       ` Anders Peter Fugmann
@ 2001-05-17 16:51         ` Anders Peter Fugmann
  0 siblings, 0 replies; 7+ messages in thread
From: Anders Peter Fugmann @ 2001-05-17 16:51 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: linux-kernel

Resolved.

I just looked at what the kernel did whne compiling a module that 
exported some symbols, and discovered that I needed
to set CFLAGS to:

-D__KERNEL__ -I$/usr/src/linux)  -Wall -Wstrict-prototypes \
-O2 -fomit-frame-pointer -fno-strict-aliasing -pipe \
-DMODULE  -DMODVERSIONS -include \
/usr/src/linux/modversions.h

Now all works correctly, and I can load my modules.

Thanks for all your help.
eps. the tip when I try to compile it in the kernel tree.

Anders Fugmann



Anders Peter Fugmann wrote:

> Hi Andreas.
> 
> I now see what you mean, and I will give it a try.
> 
> But actually I'm not compiling it under the linux kernel tree, and  I 
> really would like a way to export symbols, while compiling outside the 
> kernel tree. How would I accomplish that?
> 
> Regards
> Anders Fugmann
> 
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Exporting symbols from a module.
  2001-05-15 22:45     ` Andreas Dilger
@ 2001-05-17 11:28       ` Anders Peter Fugmann
  2001-05-17 16:51         ` Anders Peter Fugmann
  0 siblings, 1 reply; 7+ messages in thread
From: Anders Peter Fugmann @ 2001-05-17 11:28 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: linux-kernel

Hi Andreas.

I now see what you mean, and I will give it a try.

But actually I'm not compiling it under the linux kernel tree, and  I 
really would like a way to export symbols, while compiling outside the 
kernel tree. How would I accomplish that?

Regards
Anders Fugmann


Andreas Dilger wrote:

> Anders Fugmann writes:
> 
>>I'm not sure where to put this in my Makefile.
>>(tried, but it did not help)
>>Could you please send an example.
>>
> 
> See fs/Makefile or fs/msdos/Makefile for examples.  I assume you are
> building your module under the kernel tree?
> 
> Cheers, Andreas
> 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Exporting symbols from a module.
  2001-05-15 22:23   ` Anders Peter Fugmann
@ 2001-05-15 22:45     ` Andreas Dilger
  2001-05-17 11:28       ` Anders Peter Fugmann
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Dilger @ 2001-05-15 22:45 UTC (permalink / raw)
  To: Anders Peter Fugmann; +Cc: Andreas Dilger, linux-kernel

Anders Fugmann writes:
> I'm not sure where to put this in my Makefile.
> (tried, but it did not help)
> Could you please send an example.

See fs/Makefile or fs/msdos/Makefile for examples.  I assume you are
building your module under the kernel tree?

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Exporting symbols from a module.
  2001-05-15 21:57 ` Andreas Dilger
@ 2001-05-15 22:23   ` Anders Peter Fugmann
  2001-05-15 22:45     ` Andreas Dilger
  0 siblings, 1 reply; 7+ messages in thread
From: Anders Peter Fugmann @ 2001-05-15 22:23 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: linux-kernel

Hi.
Thanks for your reply.

I'm not sure where to put this in my Makefile.
(tried, but it did not help)
Could you please send an example.

Thanks in advance.
Anders Fugmann

Andreas Dilger wrote:

>>
> I just recently had this problem, and your Makefile is missing:
> 
> export-objs := <file name>.o
> 
> where <file name>.o is the compiled object file from <file name>.c, and
> not the module name (if it is different).
> 
> Cheers, Andreas
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Exporting symbols from a module.
  2001-05-15 18:18 Anders Peter Fugmann
@ 2001-05-15 21:57 ` Andreas Dilger
  2001-05-15 22:23   ` Anders Peter Fugmann
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Dilger @ 2001-05-15 21:57 UTC (permalink / raw)
  To: Anders Peter Fugmann; +Cc: linux-kernel

Anders Fugmann writes:
> I've got a simple question - how export symbols from one module, and use 
> them in another.
> 
> I have two modules - 'kvaser' and 'can_master'.
> 'kvaser' exports some functions, and 'can_master' needs to use call 
> these functions.
> 
> I used EXPORT_SYMBOL, and declared the function extern,
> but i still get unresolved symbols.
> 
>  > insmod kvaser.o
>  > insmod can_master.o
> can_master.o: unresolved symbol can_hw_no_messages
> can_master.o: unresolved symbol can_hw_register
> can_master.o: unresolved symbol can_hw_get_message
> can_master.o: unresolved symbol can_hw_unregister
> can_master.o: unresolved symbol can_hw_listen
> can_master.o: unresolved symbol can_hw_block
> can_master.o: unresolved symbol can_hw_send_message
> 
> 
> Looking in /proc/ksyms, i can find the exported symbols from the kvaser 
> driver, but it they are in a different format than all the others.
> 
> d3d27070 can_hw_register_R__ver_can_hw_register [kvaser]
> d3d27090 can_hw_unregister_R__ver_can_hw_unregister     [kvaser]
> d3d270b0 can_hw_listen_R__ver_can_hw_listen     [kvaser]
> d3d270c4 can_hw_block_R__ver_can_hw_block       [kvaser]
> d3d270e8 can_hw_send_message_R__ver_can_hw_send_message [kvaser]
> d3d270f8 can_hw_get_message_R__ver_can_hw_get_message   [kvaser]
> d3d27108 can_hw_no_messages_R__ver_can_hw_no_messages   [kvaser]
> d3d27000 
> __insmod_kvaser_O/home/afu/cvs/dtu/49422/canbus/src/kvaser.o_M3B01709C_V132100 
I just recently had this problem, and your Makefile is missing:

export-objs := <file name>.o

where <file name>.o is the compiled object file from <file name>.c, and
not the module name (if it is different).

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Exporting symbols from a module.
@ 2001-05-15 18:18 Anders Peter Fugmann
  2001-05-15 21:57 ` Andreas Dilger
  0 siblings, 1 reply; 7+ messages in thread
From: Anders Peter Fugmann @ 2001-05-15 18:18 UTC (permalink / raw)
  To: linux-kernel

Hi.

I've got a simple question - how export symbols from one module, and use 
them in another.

I have two modules - 'kvaser' and 'can_master'.
'kvaser' exports some functions, and 'can_master' needs to use call 
these functions.

I used EXPORT_SYMBOL, and declared the function extern,
but i still get unresolved symbols.

 > insmod kvaser.o
 > insmod can_master.o
can_master.o: unresolved symbol can_hw_no_messages
can_master.o: unresolved symbol can_hw_register
can_master.o: unresolved symbol can_hw_get_message
can_master.o: unresolved symbol can_hw_unregister
can_master.o: unresolved symbol can_hw_listen
can_master.o: unresolved symbol can_hw_block
can_master.o: unresolved symbol can_hw_send_message


Looking in /proc/ksyms, i can find the exported symbols from the kvaser 
driver, but it they are in a different format than all the others.

d3d27070 can_hw_register_R__ver_can_hw_register [kvaser]
d3d27090 can_hw_unregister_R__ver_can_hw_unregister     [kvaser]
d3d270b0 can_hw_listen_R__ver_can_hw_listen     [kvaser]
d3d270c4 can_hw_block_R__ver_can_hw_block       [kvaser]
d3d270e8 can_hw_send_message_R__ver_can_hw_send_message [kvaser]
d3d270f8 can_hw_get_message_R__ver_can_hw_get_message   [kvaser]
d3d27108 can_hw_no_messages_R__ver_can_hw_no_messages   [kvaser]
d3d27000 
__insmod_kvaser_O/home/afu/cvs/dtu/49422/canbus/src/kvaser.o_M3B01709C_V132100 
[kvaser]

the modules are compiled with:
-D__KERNEL__ -DMODULE -Wall -O2 -Wall -Wstrict-prototypes 
-fomit-frame-pointer -fno-strict-aliasing -DEXPORT_SYMTAB

Any ideas appreciated.

Regards Anders Fugmann



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-05-17 18:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-17 18:46 Exporting symbols from a module Khachaturov, Vassilii
  -- strict thread matches above, loose matches on Subject: below --
2001-05-15 18:18 Anders Peter Fugmann
2001-05-15 21:57 ` Andreas Dilger
2001-05-15 22:23   ` Anders Peter Fugmann
2001-05-15 22:45     ` Andreas Dilger
2001-05-17 11:28       ` Anders Peter Fugmann
2001-05-17 16:51         ` Anders Peter Fugmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).