単純なカーネル オブジェクトを作成しています。しかし、どういうわけか変数は EXPORT_SYMBIL マクロでエクスポートされません。ソースは次のとおりです。
#include <linux/module.h>
#include <linux/init.h>
MODULE_LICENSE("Dual BSD/GPL");
int hello_int __attribute__ ((__unused__));
EXPORT_SYMBOL(hello_int);
static int hello_init(void)
{
        printk(KERN_ALERT "driver loaded\n");
        return 0;
}
static void hello_exit(void)
{
        printk(KERN_ALERT "driver unloaded\n");
}
module_init(hello_init);
module_exit(hello_exit);
しかし。
# insmod hello.ko
# cat /proc/kallsyms | grep hello
d9fb0000 t hello_exit   [hello]
d9fb000c t hello_init   [hello]
d9fb0000 t cleanup_module       [hello]
d9fb000c t init_module  [hello]
d9f6374e t br_hello_timer_expired       [bridge]
d9f64027 t show_hello_timer     [bridge]
d9f640fb t store_hello_time     [bridge]
d9f64264 t set_hello_time       [bridge]
d9f641ee t show_hello_time      [bridge]
hello_int はありません。しかし確かに、
# cat Module.symvers
0x8ed8de1a      hello_int       /home/ken/myprojects/hello/hello        EXPORT_SYMBOL
なぜ?何か問題でも?
# uname -a
Linux debian-6-0-6-i386 2.6.32-5-686 #1 SMP Sun Sep 23 09:49:36 UTC 2012 i686 GNU/Linux
これがこのための Makefile です。
obj-m := hello.o
all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean