參考:http://shaojiashuai123456.iteye.com/blog/840015
include/linux/module.h:
/* For every exported symbol, place a struct in the __ksymtab section */
#define __EXPORT_SYMBOL(sym, sec) \
extern typeof(sym) sym; \
__CRC_SYMBOL(sym, sec) \
static const char __kstrtab_##sym[] \
__attribute__((section("__ksymtab_strings"), aligned(1))) \
= MODULE_SYMBOL_PREFIX #sym; \
static const struct kernel_symbol __ksymtab_##sym \
__used \
__attribute__((section("__ksymtab" sec), unused)) \
= { (unsigned long)&sym, __kstrtab_##sym }
#define EXPORT_SYMBOL(sym) \
__EXPORT_SYMBOL(sym, "")
#define EXPORT_SYMBOL_GPL(sym) \
__EXPORT_SYMBOL(sym, "_gpl")
#define EXPORT_SYMBOL_GPL_FUTURE(sym) \
__EXPORT_SYMBOL(sym, "_gpl_future")
1>. __atrribute__ 指定變量或者函數屬性。在此查看詳細http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Variable-Attributes.html#Variable-Attributes。
cat /proc/kallsyms會打印出內核當前的符號表,例如:
...
d8834a24 t snd_free_sgbuf_pages [snd_page_alloc]
c0180d7a U create_proc_entry [snd_page_alloc]
d88341d8 T snd_dma_free_pages [snd_page_alloc]
c013d858 U __get_free_pages [snd_page_alloc]
d8834ab5 t snd_malloc_sgbuf_pages [snd_page_alloc]
c014f906 U kmem_cache_alloc [snd_page_alloc]
c0106dcd U dma_alloc_coherent [snd_page_alloc]
...
其中第一列是該符號在內核地址空間中的地址;第二列是符號屬性,小寫表示局部符號,大寫表示全局符號,具體含義參考man nm; 第三列表示符號字符串.
這裏只顯示EXPORT_SYMBOL,EXPROT_SYMBOL_GPL處理過的符號。
通過more /boot/System.map 可以查看內核符號列表。
可以顯示編譯好內核後所有在內核中的符號,模塊中的要另行查看。
可以顯示編譯好內核後所有在內核中的符號,模塊中的要另行查看。