Using EXPORT_SYMBOL in a 64bit architecture

Submitted by Anonymous
on September 7, 2009 - 3:08pm

Dear friends,

I have hacked a kernel and created a module that invokes some functions from this kernel. The mods work perfectly on my workstation, but I'm having several problems on a 64bit server which runs the exactly same Linux distribution.

The distro is a Ubuntu 7.04 and the kernel is 2.6.20.3-ubuntu1.

The only difference is that my workstation is i686 and the server is x86_64.

The first problem I had was exporting the symbol. When compiling the kernel as x86_64, I've noticed some complains regarding the line where I use the EXPORT_SYMBOL() macro to make the kernel function visible to my module. No matter what I did, the function would always show up as local in the /proc/kallsyms table. The return type of the function is a pointer, and the warning messages mentioned EXPORT_SYMBOL() expects an "int" function. I guessed the 64-bit architecture could have a different storage space for "int" and "void *", so I decided to build my kernel hacks in instead of compiling it as a module in order not to need the macro (building it in should make it global).

That worked. Now the function shows up as "T" and not "t" in /proc/kallsyms.

However, my module is producing a weird message when compiling:


root# make
make -C /usr/src/linux-source-2.6.20.3-ubuntu1-felipe SUBDIRS=/data/felipe_module modules
make[1]: Entering directory `/usr/src/linux-source-2.6.20.3-ubuntu1-felipe'
CC [M] /data/felipe_module/felipe_module.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "felipe_exported_function" [/data/felipe_module/felipe_module.ko] undefined!
LD [M] /data/felipe_module/felipe_module.ko
make[1]: Leaving directory `/usr/src/linux-source-2.6.20.3-ubuntu1-felipe'
root#

As you can see, the module does compile. But when trying to load it, I get the following error:


FATAL: Error inserting felipe_module (/lib/modules/...snip.../felipe_module.ko): Unknown symbol in module, or unknown parameter (see dmesg)

dmesg complains about the following:


root# dmesg | tail
...snip...
[867004.677598] felipe_module: Unknown symbol felipe_exported_function
root#

I'm running out of ideas. It is not any "include" issue, as I have checked that the prototype is correctly listed. And again, it doesn't produce any warning/errors in my workstation.

Anyone could share some thoughts?

Very best,
Felipe

preprocessor output

on
September 7, 2009 - 5:45pm

The return type of the function is a pointer, and the warning messages mentioned EXPORT_SYMBOL() expects an "int" function.

Do you have the original warning message? If there's something wrong with the prototype and the compiler somehow doesn't know your symbol, it is assumed to have the default type, which is int.

Have you had a look at the preprocessor output? I don't have 2.6.20 sources at hand, but according to the 2.6.24 sources the type of the exported symbol is not important, it is declared with

extern typeof(sym) sym;

. You have included linux/module.h, I suppose, else

EXPORT_SYMBOL(sym);

wouldn't be expanded as a macro and strange things would happen.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.