Commit 7bf6b27c authored by Kai Germaschewski's avatar Kai Germaschewski Committed by Linus Torvalds

kbuild/modules: Save space on symbol list

The current code reserves 60 bytes for the symbol string of every
exported symbol, unnecessarily wasting kernel memory since most symbols
are much shorter. We revert to the 2.4 solution where the actual strings
are saved out of line and only the pointers are kept.

The latest module-init-tools already handle this case, people who are
using older versions need to update to make sure depmod works
properly.

Saves 80 KB in vmlinux with my .config.
parent 11aa9341
...@@ -52,7 +52,7 @@ o Gnu C 2.95.3 # gcc --version ...@@ -52,7 +52,7 @@ o Gnu C 2.95.3 # gcc --version
o Gnu make 3.78 # make --version o Gnu make 3.78 # make --version
o binutils 2.9.5.0.25 # ld -v o binutils 2.9.5.0.25 # ld -v
o util-linux 2.10o # fdformat --version o util-linux 2.10o # fdformat --version
o module-init-tools 0.9 # rmmod -V o module-init-tools 0.9.8 # rmmod -V
o e2fsprogs 1.29 # tune2fs o e2fsprogs 1.29 # tune2fs
o jfsutils 1.0.14 # fsck.jfs -V o jfsutils 1.0.14 # fsck.jfs -V
o reiserfsprogs 3.6.3 # reiserfsck -V 2>&1|grep reiserfsprogs o reiserfsprogs 3.6.3 # reiserfsck -V 2>&1|grep reiserfsprogs
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
__vermagic : { *(__vermagic) } \ __vermagic : { *(__vermagic) } \
\ \
/* Kernel symbol table */ \ /* Kernel symbol table */ \
. = ALIGN(64); \
__start___ksymtab = .; \ __start___ksymtab = .; \
__ksymtab : { *(__ksymtab) } \ __ksymtab : { *(__ksymtab) } \
__stop___ksymtab = .; \ __stop___ksymtab = .; \
...@@ -18,6 +17,9 @@ ...@@ -18,6 +17,9 @@
__gpl_ksymtab : { *(__gpl_ksymtab) } \ __gpl_ksymtab : { *(__gpl_ksymtab) } \
__stop___gpl_ksymtab = .; \ __stop___gpl_ksymtab = .; \
\ \
/* Kernel symbol table: strings */ \
__ksymtab_strings : { *(__ksymtab_strings) } \
\
/* All kernel symbols */ \ /* All kernel symbols */ \
__start___kallsyms = .; \ __start___kallsyms = .; \
__kallsyms : { *(__kallsyms) } \ __kallsyms : { *(__kallsyms) } \
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
struct kernel_symbol struct kernel_symbol
{ {
unsigned long value; unsigned long value;
char name[MODULE_NAME_LEN]; const char *name;
}; };
/* These are either module local, or the kernel's dummy ones. */ /* These are either module local, or the kernel's dummy ones. */
...@@ -140,17 +140,23 @@ void *__symbol_get_gpl(const char *symbol); ...@@ -140,17 +140,23 @@ void *__symbol_get_gpl(const char *symbol);
#define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #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 \ static const char __kstrtab_##sym[] \
__attribute__((section("__ksymtab"))) \ __attribute__((section("__ksymtab_strings"))) \
= { (unsigned long)&sym, MODULE_SYMBOL_PREFIX #sym } = MODULE_SYMBOL_PREFIX #sym; \
static const struct kernel_symbol __ksymtab_##sym \
__attribute__((section("__ksymtab"))) \
= { (unsigned long)&sym, __kstrtab_##sym }
#define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym) #define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym)
#define EXPORT_SYMBOL_GPL(sym) \ #define EXPORT_SYMBOL_GPL(sym) \
const struct kernel_symbol __ksymtab_##sym \ static const char __kstrtab_##sym[] \
__attribute__((section("__gpl_ksymtab"))) \ __attribute__((section("__ksymtab_strings"))) \
= { (unsigned long)&sym, #sym } = MODULE_SYMBOL_PREFIX #sym; \
static const struct kernel_symbol __ksymtab_##sym \
__attribute__((section("__gpl_ksymtab"))) \
= { (unsigned long)&sym, __kstrtab_##sym }
struct module_ref struct module_ref
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
IN_PER_CPU=0 IN_PER_CPU=0
} }
/__per_cpu$$/ && ! / __ksymtab_/ { /__per_cpu$$/ && ! ( / __ksymtab_/ || / __kstrtab_/ ) {
if (!IN_PER_CPU) { if (!IN_PER_CPU) {
print $$3 " not in per-cpu section" > "/dev/stderr"; print $$3 " not in per-cpu section" > "/dev/stderr";
FOUND=1; FOUND=1;
......
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