[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <4B0B10FA.7030402@tuffmail.co.uk>
Date: Mon, 23 Nov 2009 22:47:22 +0000
From: Alan Jenkins <alan-jenkins@...fmail.co.uk>
To: Rusty Russell <rusty@...tcorp.com.au>
CC: Alex Chiang <achiang@...com>, Tony Luck <tony.luck@...il.com>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: [PATCH] modpost: fix modules on ia64 - use @fptr() on exported function
symbols
On function descriptor architectures (powerpc and ia64), we need to export
the address of the function descriptor and not the actual function.
The C compiler naturally does this for us. However we now export vmlinux
symbols using the assembler, in order to sort the exports.
This is not a problem on powerpc. On powerpc, the function descriptor
is simply "printk" (the action function entry point is ".printk").
But ia64 assembly needs special handling. The function descriptor for
printk(), for example, is "@fptr(printk)".
I have tested that modpost now generates the desired assembly code when
run against an IA64 module. I have not tested with an actual IA64
vmlinux, assembler, compiler or processor. I assume that the IA64
assembler defines __ia64__, just as the i386 assembler defines __i386__.
Reported-by: Alex Chiang <achiang@...com>
Signed-off-by: Alan Jenkins <alan-jenkins@...fmail.co.uk>
---
include/linux/mod_export.h | 17 +++++++++++++++--
scripts/mod/modpost.c | 22 +++++++++++++++++++++-
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/include/linux/mod_export.h b/include/linux/mod_export.h
index 394795e..3f4e38a 100644
--- a/include/linux/mod_export.h
+++ b/include/linux/mod_export.h
@@ -111,6 +111,12 @@ struct kernel_symbol {
#define SYM(sym) PASTE(SYMBOL_PREFIX, sym)
#endif
+#ifdef __ia64__
+#define FSYM(x) @fptr(SYM(x))
+#else
+#define FSYM(x) SYM(x)
+#endif
+
#ifdef CONFIG_MODVERSIONS
#define __CRC_SYMBOL(sym, crcsec) \
@@ -125,7 +131,7 @@ struct kernel_symbol {
#define __CRC_SYMBOL(sym, section)
#endif
-#define __EXPORT_SYMBOL(sym, sec, strsec, crcsec) \
+#define __EXPORT_SYMBOL_VALUE(sym, symvalue, sec, strsec, crcsec) \
.globl SYM(sym); \
\
__CRC_SYMBOL(sym, crcsec) \
@@ -138,10 +144,17 @@ struct kernel_symbol {
.pushsection sec, "a"; \
ALGN; \
SYM(__ksymtab_##sym): \
- PTR SYM(sym); \
+ PTR symvalue; \
PTR SYM(__kstrtab_##sym); \
.popsection;
+#define __EXPORT_DATA_SYMBOL(sym, sec, strsec, crcsec) \
+ __EXPORT_SYMBOL_VALUE(sym, SYM(sym), sec, strsec, crcsec)
+
+#define __EXPORT_FUNCTION_SYMBOL(sym, sec, strsec, crcsec) \
+ __EXPORT_SYMBOL_VALUE(sym, FSYM(sym), sec, strsec, crcsec)
+
+
#endif /* __MODPOST_EXPORTS__ */
#endif /* __GENKSYMS__ */
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index b5a801d..31256d7 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -158,6 +158,7 @@ struct symbol {
unsigned int kernel:1; /* 1 if symbol is from kernel
* (only for external modules) **/
unsigned int preloaded:1; /* 1 if symbol from Module.symvers */
+ unsigned int function:1; /* 1 if symbol refers to a function */
enum export export; /* Type of export */
char name[0];
};
@@ -582,6 +583,17 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
}
}
+static void mark_function_symbols(Elf_Sym *sym, const char *symname)
+{
+ struct symbol *export_symbol;
+
+ export_symbol = find_symbol(symname);
+ if (!export_symbol)
+ return;
+
+ export_symbol->function = (ELF_ST_TYPE(sym->st_info) == STT_FUNC);
+}
+
/**
* Parse tag=value strings from .modinfo section
**/
@@ -1619,6 +1631,13 @@ static void read_symbols(char *modname)
handle_modversions(mod, &info, sym, symname);
handle_moddevtable(mod, &info, sym, symname);
}
+
+ for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
+ symname = info.strtab + sym->st_name;
+
+ mark_function_symbols(sym, symname);
+ }
+
if (!is_vmlinux(modname) ||
(is_vmlinux(modname) && vmlinux_section_warnings))
check_sec_ref(mod, modname, &info);
@@ -2027,10 +2046,11 @@ static void write_exports(const char *fname)
for (i = 0; i < n; i++) {
sym = symbols[i];
- buf_printf(&buf, "__EXPORT_SYMBOL(%s,"
+ buf_printf(&buf, "__EXPORT_%s_SYMBOL(%s,"
" __ksymtab%s_sorted,"
" __ksymtab_strings_sorted,"
" __kcrctab%s_sorted)\n",
+ sym->function ? "FUNCTION" : "DATA",
sym->name,
section_names[sym->export],
section_names[sym->export]);
--
1.6.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists