Commit 0788fd34 authored by Linus Torvalds's avatar Linus Torvalds

Parts of "module.c" was needed even when no module support

was enabled, so split it up into "extable.c"
parent aedcae64
...@@ -49,21 +49,6 @@ extern struct module __this_module; ...@@ -49,21 +49,6 @@ extern struct module __this_module;
#define THIS_MODULE ((struct module *)0) #define THIS_MODULE ((struct module *)0)
#endif #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 struct kernel_symbol_group
{ {
/* Links us into the global symbol list */ /* Links us into the global symbol list */
...@@ -84,6 +69,22 @@ struct exception_table ...@@ -84,6 +69,22 @@ struct exception_table
const struct exception_table_entry *entry; 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 struct module_ref
{ {
atomic_t count; atomic_t count;
...@@ -302,6 +303,14 @@ extern int module_dummy_usage; ...@@ -302,6 +303,14 @@ extern int module_dummy_usage;
#define cleanup_module(voidarg) __exitfn(void) #define cleanup_module(voidarg) __exitfn(void)
#endif #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. */ /* Use symbol_get and symbol_put instead. You'll thank me. */
#define HAVE_INTER_MODULE #define HAVE_INTER_MODULE
extern void inter_module_register(const char *, struct module *, const void *); extern void inter_module_register(const char *, struct module *, const void *);
......
...@@ -10,7 +10,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ ...@@ -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 \ exit.o itimer.o time.o softirq.o resource.o \
sysctl.o capability.o ptrace.o timer.o user.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 \ 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_GENERIC_ISA_DMA) += dma.o
obj-$(CONFIG_SMP) += cpu.o obj-$(CONFIG_SMP) += cpu.o
......
/* 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);
}
...@@ -37,21 +37,6 @@ ...@@ -37,21 +37,6 @@
#define DEBUGP(fmt , a...) #define DEBUGP(fmt , a...)
#endif #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 */ /* List of modules, protected by module_mutex */
static DECLARE_MUTEX(module_mutex); static DECLARE_MUTEX(module_mutex);
LIST_HEAD(modules); /* FIXME: Accessed w/o lock on oops by some archs */ LIST_HEAD(modules); /* FIXME: Accessed w/o lock on oops by some archs */
...@@ -1139,7 +1124,7 @@ sys_init_module(void *umod, ...@@ -1139,7 +1124,7 @@ sys_init_module(void *umod,
/* Now it's a first class citizen! */ /* Now it's a first class citizen! */
spin_lock_irq(&modlist_lock); 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); spin_unlock_irq(&modlist_lock);
list_add(&mod->list, &modules); list_add(&mod->list, &modules);
...@@ -1271,19 +1256,6 @@ struct seq_operations modules_op = { ...@@ -1271,19 +1256,6 @@ struct seq_operations modules_op = {
.show = m_show .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 */ /* Obsolete lvalue for broken code which asks about usage */
int module_dummy_usage = 1; int module_dummy_usage = 1;
EXPORT_SYMBOL(module_dummy_usage); EXPORT_SYMBOL(module_dummy_usage);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment