REPOST: Fatal section alignment bug in module handling (Linux 2.1.20)

Markus Gutschke (
6 Jan 1997 08:27:02 +0100

[ I already posted this message a few days ago, but I never saw it
turn up on the mailing list; so here is a repost. ]

The new-style module handling as available in Linux 2.1.20 (with the
patches from modutils-970103.tar.gz) suffers from a fatal alignment
problem. There is a similar bug in the handling of the exception

A Linux 2.1.20 kernel image has (among others) these section:
".kstrtab", "__ksymtab", ".fixup", "__ex_table". The beginning and end
of the sections "__ksymtab" and "__ex_table" is marked by the symbols
"__start___ksymtab"/"__stop___ksymtab" and
"__start___ex_table"/"__stop___extable". While the beginning of the
sections gets properly aligned according to the type of data that it
contains, the symbols do not get aligned. "__start___ksymtab" does not
actually point to the beginning of "__ksymtab", but to the end of
".kstrtab"; thus it can be off by up to three bytes. Obviously, this
will result in kernel "oops's" when trying to use modules.

As I could not find any documentation on how the "__start" and
"__stop" symbols were created (does anybody care to elaborate?), I
cludged the code in "include/linux/module.h" to force stronger
alignment. This is not the proper solution, though! A correct solution
would ensure that "__start" always points to the actual beginning of
the new segment.

If you notice the same problems, but you are desperate to test Linux
2.1.20, then as a work-around use this definition in

#define __EXPORT_SYMBOL(sym, str) \
const struct { char s[sizeof(str)]; \
char __attribute__ ((aligned(4))) a[0];} \
__kstrtab_##sym __attribute__((section(".kstrtab"))) \
= { str }; \
const struct module_symbol __ksymtab_##sym \
__attribute__((section("__ksymtab"))) = \
{ (unsigned long)&sym, (char *)& __kstrtab_##sym }


Markus Gutschke          Internet:
Schlage 5a               PGP public key: finger -l
D-48268 Greven-Gimbte
Germany                            >>> I prefer encrypted e-mail <<<