@@ -59,8 +59,24 @@ KSYM(__kcrctab_\name):
#endif
.endm
#undef __put
-#define EXPORT_SYMBOL(name) __EXPORT_SYMBOL name,KSYM_FUNC(KSYM(name))
-#define EXPORT_SYMBOL_GPL(name) __EXPORT_SYMBOL name,KSYM_FUNC(KSYM(name)),_gpl
-#define EXPORT_DATA_SYMBOL(name) __EXPORT_SYMBOL name,KSYM(name)
-#define EXPORT_DATA_SYMBOL_GPL(name) __EXPORT_SYMBOL name,KSYM(name),_gpl
+
+#ifdef CONFIG_TRIM_UNUSED_KSYMS
+#include <linux/kconfig.h>
+#include <generated/autoksyms.h>
+#define ___EXPORT_SYMBOL(name, val, sec) \
+ __cond_export_sym(name, val, sec, config_enabled(__KSYM_##name))
+#define __cond_export_sym(name, val, sec, conf) \
+ ___cond_export_sym(name, val, sec, conf)
+#define ___cond_export_sym(name, val, sec, enabled) \
+ __cond_export_sym_##enabled(name, val, sec)
+#define __cond_export_sym_1(name, val, sec) __EXPORT_SYMBOL name, val, sec
+#define __cond_export_sym_0(name, val, sec) /* nothing */
+#else
+#define ___EXPORT_SYMBOL(name, val, sec) __EXPORT_SYMBOL name, val, sec
+#endif
+
+#define EXPORT_SYMBOL(name) ___EXPORT_SYMBOL(name,KSYM_FUNC(KSYM(name)),())
+#define EXPORT_SYMBOL_GPL(name) ___EXPORT_SYMBOL(name,KSYM_FUNC(KSYM(name)),_gpl)
+#define EXPORT_DATA_SYMBOL(name) ___EXPORT_SYMBOL(name,KSYM(name),())
+#define EXPORT_DATA_SYMBOL_GPL(name) ___EXPORT_SYMBOL(name,KSYM(name),_gpl)
#endif