Skip to contentSkip to conversation

Exporting symbols from a module.

DISCUSSION Anders Peter Fugmann 2 participants 6 messages May 15, 2001 – May 17, 2001

lore
Share & tools
lore
#0 lore raw

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.

Quoted 2 lines

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

#1 lore raw
Quoted 24 lines · Anders Fugmann

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.

Quoted 2 lines

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.

Quoted 9 lines

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

Signature · 3 lines
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
#2 lore raw

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

Quoted 10 lines · Andreas Dilger
Quoted 1 line

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

#3 lore raw
Quoted 3 lines · Anders Fugmann

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

Signature · 3 lines
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
#4 lore raw

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

Quoted 12 lines · Andreas Dilger
Quoted 4 lines · Anders Fugmann

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

#5 lore raw
In reply to Andreas Dilger

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

Quoted 10 lines · Anders Peter Fugmann

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