mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] v850 support
@ 2002-12-02  1:29 Rusty Russell
  0 siblings, 0 replies; only message in thread
From: Rusty Russell @ 2002-12-02  1:29 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Linus, please apply.

This from Miles Bader (NEC V850 maintainer) and myself: their
toolchain prefixes user symbols with "_", so requires some minor
modifications (asm-v850/module.h defines MODULE_SYMBOL_PREFIX to "_").

He said this works fine,
Rusty.

Name: symbol prefix support for v850
Author: Miles Bader
Status: Experimental

D: On the v850, the elf toolchain uses a `_' prefix for all user symbols
D: (I'm not sure why, since most toolchains seem to have dropped this sort
D: of thing).
D: 
D: The attached patch adds the ability to deal with this, if the macro
D: MODULE_SYMBOL_PREFIX is defined by <asm/module.h>.  This only affects
D: places where symbol names come from the user, e.g., EXPORT_SYMBOL, or
D: the explicit symbol-names used in kernel/module.c itself.
D: 
D: [Tweaked a little by Rusty]

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9619-linux-2.5.50/include/linux/module.h .9619-linux-2.5.50.updated/include/linux/module.h
--- .9619-linux-2.5.50/include/linux/module.h	2002-11-25 08:44:18.000000000 +1100
+++ .9619-linux-2.5.50.updated/include/linux/module.h	2002-11-29 13:22:32.000000000 +1100
@@ -31,6 +31,11 @@
 #define MODULE_PARM_DESC(var,desc)
 #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))
 struct kernel_symbol
 {
@@ -86,13 +91,13 @@ struct exception_table
 /* 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)))
+#define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #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 }
+	= { (unsigned long)&sym, MODULE_SYMBOL_PREFIX #sym }
 
 #define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym) EXPORT_SYMBOL(sym)
@@ -166,7 +171,7 @@ struct module
 #ifdef CONFIG_MODULE_UNLOAD
 
 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);
 
 /* We only need protection against local interrupts. */
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9619-linux-2.5.50/kernel/module.c .9619-linux-2.5.50.updated/kernel/module.c
--- .9619-linux-2.5.50/kernel/module.c	2002-11-25 08:44:19.000000000 +1100
+++ .9619-linux-2.5.50.updated/kernel/module.c	2002-11-29 13:20:21.000000000 +1100
@@ -37,6 +37,9 @@
 #define DEBUGP(fmt , a...)
 #endif
 
+#define symbol_is(literal, string)				\
+	(strcmp(MODULE_SYMBOL_PREFIX literal, (string)) == 0)
+
 /* 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 */
@@ -630,10 +633,10 @@ static int grab_private_symbols(Elf_Shdr
 	unsigned int 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;
 #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;
 #endif
 	}
@@ -770,7 +773,7 @@ static void simplify_symbols(Elf_Shdr *s
 						       mod,
 						       &ksg);
 			/* 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;
 		}
 	}

--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-12-02  1:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-02  1:29 [PATCH] v850 support Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome