From 1a6100caae4257b3992e1e747340bf49de1e8c38 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 7 Jan 2004 05:47:04 -0800 Subject: [PATCH] Don't relocate non-allocated regions in modules. This fixes loading of modules compiled with debugging on some platforms. From Rusty. --- kernel/module.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/module.c b/kernel/module.c index 2997c3e89974f..65f82a3278dd7 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1618,6 +1618,16 @@ static struct module *load_module(void __user *umod, /* Now do relocations. */ for (i = 1; i < hdr->e_shnum; i++) { const char *strtab = (char *)sechdrs[strindex].sh_addr; + unsigned int info = sechdrs[i].sh_info; + + /* Not a valid relocation section? */ + if (info >= hdr->e_shnum) + continue; + + /* Don't bother with non-allocated sections */ + if (!(sechdrs[info].sh_flags & SHF_ALLOC)) + continue; + if (sechdrs[i].sh_type == SHT_REL) err = apply_relocate(sechdrs, strtab, symindex, i,mod); else if (sechdrs[i].sh_type == SHT_RELA) -- 2.53.0