Commit 1504317a authored by Rusty Russell's avatar Rusty Russell Committed by James Bottomley

[PATCH] v850 support

On the v850, the elf toolchain uses a `_' prefix for all user symbols
(I'm not sure why, since most toolchains seem to have dropped this sort
of thing).

The attached patch adds the ability to deal with this, if the macro
MODULE_SYMBOL_PREFIX is defined by <asm/module.h>.  This only affects
places where symbol names come from the user, e.g., EXPORT_SYMBOL, or
the explicit symbol-names used in kernel/module.c itself.

[Tweaked a little by Rusty, original by Miles Bader]
parent a110ac32
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
#define MODULE_PARM_DESC(var,desc) #define MODULE_PARM_DESC(var,desc)
#define print_modules() #define print_modules()
/* v850 toolchain uses a `_' prefix for all user symbols */
#ifndef MODULE_SYMBOL_PREFIX
#define MODULE_SYMBOL_PREFIX ""
#endif
#define MODULE_NAME_LEN (64 - sizeof(unsigned long)) #define MODULE_NAME_LEN (64 - sizeof(unsigned long))
struct kernel_symbol struct kernel_symbol
{ {
...@@ -90,13 +95,13 @@ struct exception_table ...@@ -90,13 +95,13 @@ struct exception_table
/* Get/put a kernel symbol (calls must be symmetric) */ /* Get/put a kernel symbol (calls must be symmetric) */
void *__symbol_get(const char *symbol); void *__symbol_get(const char *symbol);
void *__symbol_get_gpl(const char *symbol); void *__symbol_get_gpl(const char *symbol);
#define symbol_get(x) ((typeof(&x))(__symbol_get(#x))) #define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x)))
/* For every exported symbol, place a struct in the __ksymtab section */ /* For every exported symbol, place a struct in the __ksymtab section */
#define EXPORT_SYMBOL(sym) \ #define EXPORT_SYMBOL(sym) \
const struct kernel_symbol __ksymtab_##sym \ const struct kernel_symbol __ksymtab_##sym \
__attribute__((section("__ksymtab"))) \ __attribute__((section("__ksymtab"))) \
= { (unsigned long)&sym, #sym } = { (unsigned long)&sym, MODULE_SYMBOL_PREFIX #sym }
#define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym) #define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym)
#define EXPORT_SYMBOL_GPL(sym) EXPORT_SYMBOL(sym) #define EXPORT_SYMBOL_GPL(sym) EXPORT_SYMBOL(sym)
...@@ -170,7 +175,7 @@ struct module ...@@ -170,7 +175,7 @@ struct module
#ifdef CONFIG_MODULE_UNLOAD #ifdef CONFIG_MODULE_UNLOAD
void __symbol_put(const char *symbol); void __symbol_put(const char *symbol);
#define symbol_put(x) __symbol_put(#x) #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)
void symbol_put_addr(void *addr); void symbol_put_addr(void *addr);
/* We only need protection against local interrupts. */ /* We only need protection against local interrupts. */
......
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
#define DEBUGP(fmt , a...) #define DEBUGP(fmt , a...)
#endif #endif
#define symbol_is(literal, string) \
(strcmp(MODULE_SYMBOL_PREFIX literal, (string)) == 0)
/* 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 */
...@@ -630,10 +633,10 @@ static int grab_private_symbols(Elf_Shdr *sechdrs, ...@@ -630,10 +633,10 @@ static int grab_private_symbols(Elf_Shdr *sechdrs,
unsigned int i; unsigned int i;
for (i = 1; i < sechdrs[symbolsec].sh_size/sizeof(*sym); i++) { for (i = 1; i < sechdrs[symbolsec].sh_size/sizeof(*sym); i++) {
if (strcmp("__initfn", strtab + sym[i].st_name) == 0) if (symbol_is("__initfn", strtab + sym[i].st_name))
mod->init = (void *)sym[i].st_value; mod->init = (void *)sym[i].st_value;
#ifdef CONFIG_MODULE_UNLOAD #ifdef CONFIG_MODULE_UNLOAD
if (strcmp("__exitfn", strtab + sym[i].st_name) == 0) if (symbol_is("__exitfn", strtab + sym[i].st_name))
mod->exit = (void *)sym[i].st_value; mod->exit = (void *)sym[i].st_value;
#endif #endif
} }
...@@ -770,7 +773,7 @@ static void simplify_symbols(Elf_Shdr *sechdrs, ...@@ -770,7 +773,7 @@ static void simplify_symbols(Elf_Shdr *sechdrs,
mod, mod,
&ksg); &ksg);
/* We fake up "__this_module" */ /* We fake up "__this_module" */
if (strcmp(strtab+sym[i].st_name, "__this_module")==0) if (symbol_is("__this_module", strtab+sym[i].st_name))
sym[i].st_value = (unsigned long)mod; sym[i].st_value = (unsigned long)mod;
} }
} }
......
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