summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/module.h39
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/extable.c51
-rw-r--r--kernel/module.c30
4 files changed, 77 insertions, 45 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index 4f440aa11f21..47ff2bc63e33 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -49,21 +49,6 @@ extern struct module __this_module;
#define THIS_MODULE ((struct module *)0)
#endif
-#ifdef CONFIG_MODULES
-/* Get/put a kernel symbol (calls must be symmetric) */
-void *__symbol_get(const char *symbol);
-void *__symbol_get_gpl(const char *symbol);
-#define symbol_get(x) ((typeof(&x))(__symbol_get(#x)))
-
-/* For every exported symbol, place a struct in the __ksymtab section */
-#define EXPORT_SYMBOL(sym) \
- const struct kernel_symbol __ksymtab_##sym \
- __attribute__((section("__ksymtab"))) \
- = { (unsigned long)&sym, #sym }
-
-#define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym)
-#define EXPORT_SYMBOL_GPL(sym) EXPORT_SYMBOL(sym)
-
struct kernel_symbol_group
{
/* Links us into the global symbol list */
@@ -84,6 +69,22 @@ struct exception_table
const struct exception_table_entry *entry;
};
+
+#ifdef CONFIG_MODULES
+/* Get/put a kernel symbol (calls must be symmetric) */
+void *__symbol_get(const char *symbol);
+void *__symbol_get_gpl(const char *symbol);
+#define symbol_get(x) ((typeof(&x))(__symbol_get(#x)))
+
+/* For every exported symbol, place a struct in the __ksymtab section */
+#define EXPORT_SYMBOL(sym) \
+ const struct kernel_symbol __ksymtab_##sym \
+ __attribute__((section("__ksymtab"))) \
+ = { (unsigned long)&sym, #sym }
+
+#define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym)
+#define EXPORT_SYMBOL_GPL(sym) EXPORT_SYMBOL(sym)
+
struct module_ref
{
atomic_t count;
@@ -302,6 +303,14 @@ extern int module_dummy_usage;
#define cleanup_module(voidarg) __exitfn(void)
#endif
+/*
+ * The exception and symbol tables, and the lock
+ * to protect them.
+ */
+extern spinlock_t modlist_lock;
+extern struct list_head extables;
+extern struct list_head symbols;
+
/* Use symbol_get and symbol_put instead. You'll thank me. */
#define HAVE_INTER_MODULE
extern void inter_module_register(const char *, struct module *, const void *);
diff --git a/kernel/Makefile b/kernel/Makefile
index bc0f6371f222..cddad55cac0d 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -10,7 +10,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
exit.o itimer.o time.o softirq.o resource.o \
sysctl.o capability.o ptrace.o timer.o user.o \
signal.o sys.o kmod.o workqueue.o futex.o platform.o pid.o \
- rcupdate.o intermodule.o
+ rcupdate.o intermodule.o extable.o
obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
obj-$(CONFIG_SMP) += cpu.o
diff --git a/kernel/extable.c b/kernel/extable.c
new file mode 100644
index 000000000000..e26ef5349d23
--- /dev/null
+++ b/kernel/extable.c
@@ -0,0 +1,51 @@
+/* Rewritten by Rusty Russell, on the backs of many others...
+ Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include <asm/semaphore.h>
+
+extern const struct exception_table_entry __start___ex_table[];
+extern const struct exception_table_entry __stop___ex_table[];
+extern const struct kernel_symbol __start___ksymtab[];
+extern const struct kernel_symbol __stop___ksymtab[];
+
+/* Protects extables and symbol tables */
+spinlock_t modlist_lock = SPIN_LOCK_UNLOCKED;
+
+/* The exception and symbol tables: start with kernel only. */
+LIST_HEAD(extables);
+LIST_HEAD(symbols);
+
+static struct exception_table kernel_extable;
+static struct kernel_symbol_group kernel_symbols;
+
+void __init extable_init(void)
+{
+ /* Add kernel symbols to symbol table */
+ kernel_symbols.num_syms = (__stop___ksymtab - __start___ksymtab);
+ kernel_symbols.syms = __start___ksymtab;
+ list_add(&kernel_symbols.list, &symbols);
+
+ /* Add kernel exception table to exception tables */
+ kernel_extable.num_entries = (__stop___ex_table -__start___ex_table);
+ kernel_extable.entry = __start___ex_table;
+ list_add(&kernel_extable.list, &extables);
+}
+
+
diff --git a/kernel/module.c b/kernel/module.c
index 464c3d9320b4..1d8410b0569f 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -37,21 +37,6 @@
#define DEBUGP(fmt , a...)
#endif
-extern const struct exception_table_entry __start___ex_table[];
-extern const struct exception_table_entry __stop___ex_table[];
-extern const struct kernel_symbol __start___ksymtab[];
-extern const struct kernel_symbol __stop___ksymtab[];
-
-/* Protects extables and symbol tables */
-spinlock_t modlist_lock = SPIN_LOCK_UNLOCKED;
-
-/* The exception and symbol tables: start with kernel only. */
-LIST_HEAD(extables);
-static LIST_HEAD(symbols);
-
-static struct exception_table kernel_extable;
-static struct kernel_symbol_group kernel_symbols;
-
/* List of modules, protected by module_mutex */
static DECLARE_MUTEX(module_mutex);
LIST_HEAD(modules); /* FIXME: Accessed w/o lock on oops by some archs */
@@ -1139,7 +1124,7 @@ sys_init_module(void *umod,
/* Now it's a first class citizen! */
spin_lock_irq(&modlist_lock);
- list_add(&mod->symbols.list, &kernel_symbols.list);
+ list_add_tail(&mod->symbols.list, &symbols);
spin_unlock_irq(&modlist_lock);
list_add(&mod->list, &modules);
@@ -1271,19 +1256,6 @@ struct seq_operations modules_op = {
.show = m_show
};
-void __init extable_init(void)
-{
- /* Add kernel symbols to symbol table */
- kernel_symbols.num_syms = (__stop___ksymtab - __start___ksymtab);
- kernel_symbols.syms = __start___ksymtab;
- list_add(&kernel_symbols.list, &symbols);
-
- /* Add kernel exception table to exception tables */
- kernel_extable.num_entries = (__stop___ex_table -__start___ex_table);
- kernel_extable.entry = __start___ex_table;
- list_add(&kernel_extable.list, &extables);
-}
-
/* Obsolete lvalue for broken code which asks about usage */
int module_dummy_usage = 1;
EXPORT_SYMBOL(module_dummy_usage);