This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
A question about a MACRO,EXPORT_SYMBOL
- From: "cheng long" <kevinclcn at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 23 Apr 2006 10:48:31 +0800
- Subject: A question about a MACRO,EXPORT_SYMBOL
Hi, ALL!
In Linux 2.6.11, there is a EXPORT_SYMBOL in <linux/module.h>.
192 #define __EXPORT_SYMBOL(sym, sec) \
193 __CRC_SYMBOL(sym, sec) \
194 static const char __kstrtab_##sym[] \
195 __attribute__((section("__ksymtab_strings"))) \
196 = MODULE_SYMBOL_PREFIX #sym; \
197 static const struct kernel_symbol __ksymtab_##sym \
198 __attribute_used__ \
199 __attribute__((section("__ksymtab" sec), unused)) \
200 = { (unsigned long)&sym, __kstrtab_##sym }
202 #define EXPORT_SYMBOL(sym) \
203 __EXPORT_SYMBOL(sym, "")
29 #ifndef MODULE_SYMBOL_PREFIX
30 #define MODULE_SYMBOL_PREFIX ""
31 #endif
I've simplified as follows.
1 #define EXPORT_SYMBOL(sym) \
2 static const char __kstrtabe_##sym[]=#sym; \
3 static const struct kernel_symbol_ksymtab_##sym \
4 = { (unsigned long)&sym, __kstrtab_##sym }
My questions are:
1. What's the "#" mean in line 2?
2. If the sym is a function, which is a address, the MACRO can't work.
For example,
int func(){ return 1 }
EXPORT_SYMBOL(func);
3 How does it known the sym is not a "static" function, or, if sym is a
static function, what happend?
Thank you very much!
Regards
Cheng