[patch] 2.4.0-test1-ac13 module_init

From: Keith Owens (kaos@ocs.com.au)
Date: Sun Jun 11 2000 - 04:31:46 EST


The use of aliases in module_init and module_exit makes gcc think that
the aliased routine is not used, resulting in a lot of warnings. This
patch suppresses the warnings.

Index: 0-test1-ac13.3/include/linux/init.h
--- 0-test1-ac13.3/include/linux/init.h Fri, 26 May 2000 13:10:01 +1000 kaos (linux-2.4/Y/50_init.h 1.1 644)
+++ 0-test1-ac13.4/include/linux/init.h Sun, 11 Jun 2000 19:21:58 +1000 kaos (linux-2.4/Y/50_init.h 1.2 644)
@@ -96,10 +96,19 @@
 #define __FINIT
 #define __INITDATA
 
-/* Not sure what version aliases were introduced in, but certainly in 2.91.66. */
+/* Not sure what version aliases were introduced in, but certainly in 2.91.66.
+ * Using aliases can make gcc think that the function we alias to is not used,
+ * resulting in spurious and annoying warning messages. Take a dummy reference
+ * to the function to suppress the warning; the .dummyref section is ignored
+ * when the module is loaded. If gcc stops issuing spurious warnings for
+ * aliases, remove the dummy reference.
+ */
+
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 91)
-#define module_init(x) int init_module(void) __attribute__((alias(#x)));
-#define module_exit(x) void cleanup_module(void) __attribute__((alias(#x)));
+#define module_init(x) int init_module(void) __attribute__((alias(#x))); \
+const void *__dummyref_##x __attribute__((section(".dummyref"))) = (void *)(&x);
+#define module_exit(x) void cleanup_module(void) __attribute__((alias(#x))); \
+const void *__dummyref_##x __attribute__((section(".dummyref"))) = (void *)(&x);
 #else
 #define module_init(x) int init_module(void) { return x(); }
 #define module_exit(x) void cleanup_module(void) { x(); }
@@ -107,7 +116,7 @@
 
 #define __setup(str,func) /* nothing */
 
-#endif
+#endif /* MODULE */
 
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
 #define __initlocaldata __initdata

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jun 15 2000 - 21:00:22 EST