]> git.hungrycats.org Git - linux/commitdiff
Don't relocate non-allocated regions in modules.
authorLinus Torvalds <torvalds@home.osdl.org>
Wed, 7 Jan 2004 13:47:04 +0000 (05:47 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 7 Jan 2004 13:47:04 +0000 (05:47 -0800)
This fixes loading of modules compiled with debugging on
some platforms.

From Rusty.

kernel/module.c

index 2997c3e89974f2228c4a97abfe587f9c8b2e26fe..65f82a3278dd7536f538425ad36d16cbb85dff0d 100644 (file)
@@ -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)