Name: Don't Apply Relocations To Sections We Haven't Copied Author: Rusty Russell Status: Booted on 2.6.0-bk1 D: The module code applies every relocation section given. Obviously, if D: the section has not been copied into the module, there's no point. D: In particular, Alpha has relocs which are only used on debug sections, D: so they don't load with CONFIG_DEBUG_INFO enabled. diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2481-linux-2.6.0-bk1/kernel/module.c .2481-linux-2.6.0-bk1.updated/kernel/module.c --- .2481-linux-2.6.0-bk1/kernel/module.c 2003-11-24 15:42:33.000000000 +1100 +++ .2481-linux-2.6.0-bk1.updated/kernel/module.c 2003-12-30 14:08:40.000000000 +1100 @@ -1618,9 +1618,13 @@ static struct module *load_module(void _ /* Now do relocations. */ for (i = 1; i < hdr->e_shnum; i++) { const char *strtab = (char *)sechdrs[strindex].sh_addr; - if (sechdrs[i].sh_type == SHT_REL) - err = apply_relocate(sechdrs, strtab, symindex, i,mod); - else if (sechdrs[i].sh_type == SHT_RELA) + + /* Skip relocations on non-allocated (ie. debug) sections */ + if (sechdrs[i].sh_type == SHT_REL + && (sechdrs[sechdrs[i].sh_info].sh_flags & SHF_ALLOC)) + err = apply_relocate(sechdrs, strtab, symindex,i, mod); + else if (sechdrs[i].sh_type == SHT_RELA + && (sechdrs[sechdrs[i].sh_info].sh_flags & SHF_ALLOC)) err = apply_relocate_add(sechdrs, strtab, symindex, i, mod); if (err < 0)