IA64 needs to be able to hook into module unloading to get rid of
the unwind tables for modules. (The actual implementation already
is in arch/ia64/kernel/module.c, David just seems to be to shy to
submit core changes :))
--- 1.11/include/asm-ia64/module.h Wed Mar 26 04:08:03 2003
+++ edited/include/asm-ia64/module.h Thu May 8 10:12:36 2003
@@ -31,4 +31,7 @@
#define ARCH_SHF_SMALL SHF_IA_64_SHORT
+void module_arch_cleanup(struct module *mod);
+#define __HAVE_ARCH_MODULE_CLEANUP 1
+
#endif /* _ASM_IA64_MODULE_H */
--- 1.80/kernel/module.c Wed Apr 30 10:17:38 2003
+++ edited/kernel/module.c Thu May 8 10:13:28 2003
@@ -47,6 +47,11 @@
#define ARCH_SHF_SMALL 0
#endif
+/* Some architectures (like ia64) need to hook into module unloading */
+#ifndef __HAVE_ARCH_MODULE_CLEANUP
+#define module_arch_cleanup(mod) do { } while (0)
+#endif
+
/* If this is set, the section belongs in the init part of the module */
#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))
@@ -909,6 +914,9 @@
spin_lock_irq(&modlist_lock);
list_del(&mod->list);
spin_unlock_irq(&modlist_lock);
+
+ /* Arch-specific cleanup. */
+ module_arch_cleanup(mod);
/* Module unload stuff */
module_unload_free(mod);
>>>>> On Thu, 8 May 2003 18:41:17 +0200, Christoph Hellwig <[email protected]> said:
Christoph> IA64 needs to be able to hook into module unloading to get rid of
Christoph> the unwind tables for modules. (The actual implementation already
Christoph> is in arch/ia64/kernel/module.c, David just seems to be to shy to
Christoph> submit core changes :))
Actually, I did submit it, even though it's Rusty's code. See:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=20030409220021%242cec%40gated-at.bofh.it
Rusty wanted module_arch_cleanup() to be an unconditional thing.
Perhaps Linus disagreed and dropped it because of that. I don't
really care. Just make it work. ;-)
--david
In message <[email protected]> you write:
> IA64 needs to be able to hook into module unloading to get rid of
> the unwind tables for modules. (The actual implementation already
> is in arch/ia64/kernel/module.c, David just seems to be to shy to
> submit core changes :))
Or he was waiting for me. Sorry David. Linus, please apply.
Name: module_arch_cleanup hook
Author: David Mosberger
Status: Trivial
D: The patch below updates the other platforms with
D: module_arch_cleanup(). Also, I added more debug output to
D: kernel/module.c since I found it useful to be able to see the final
D: section layout.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/alpha/kernel/module.c .12078-linux-2.5.69.updated/arch/alpha/kernel/module.c
--- .12078-linux-2.5.69/arch/alpha/kernel/module.c 2003-04-08 11:13:37.000000000 +1000
+++ .12078-linux-2.5.69.updated/arch/alpha/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -300,3 +300,8 @@ module_finalize(const Elf_Ehdr *hdr, con
{
return 0;
}
+
+void
+module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/arm/kernel/module.c .12078-linux-2.5.69.updated/arch/arm/kernel/module.c
--- .12078-linux-2.5.69/arch/arm/kernel/module.c 2003-02-07 19:21:51.000000000 +1100
+++ .12078-linux-2.5.69.updated/arch/arm/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -159,3 +159,8 @@ module_finalize(const Elf32_Ehdr *hdr, c
{
return 0;
}
+
+void
+module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/i386/kernel/module.c .12078-linux-2.5.69.updated/arch/i386/kernel/module.c
--- .12078-linux-2.5.69/arch/i386/kernel/module.c 2003-05-05 12:36:54.000000000 +1000
+++ .12078-linux-2.5.69.updated/arch/i386/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -123,3 +123,7 @@ int module_finalize(const Elf_Ehdr *hdr,
}
return 0;
}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/parisc/kernel/module.c .12078-linux-2.5.69.updated/arch/parisc/kernel/module.c
--- .12078-linux-2.5.69/arch/parisc/kernel/module.c 2003-03-25 12:16:58.000000000 +1100
+++ .12078-linux-2.5.69.updated/arch/parisc/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -568,3 +568,7 @@ int module_finalize(const Elf_Ehdr *hdr,
#endif
return 0;
}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/ppc/kernel/module.c .12078-linux-2.5.69.updated/arch/ppc/kernel/module.c
--- .12078-linux-2.5.69/arch/ppc/kernel/module.c 2003-02-07 19:21:52.000000000 +1100
+++ .12078-linux-2.5.69.updated/arch/ppc/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -269,3 +269,7 @@ int module_finalize(const Elf_Ehdr *hdr,
{
return 0;
}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/ppc64/kernel/module.c .12078-linux-2.5.69.updated/arch/ppc64/kernel/module.c
--- .12078-linux-2.5.69/arch/ppc64/kernel/module.c 2003-02-11 14:25:58.000000000 +1100
+++ .12078-linux-2.5.69.updated/arch/ppc64/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -386,3 +386,7 @@ int module_finalize(const Elf_Ehdr *hdr,
me->extable.entry + me->extable.num_entries);
return 0;
}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/s390/kernel/module.c .12078-linux-2.5.69.updated/arch/s390/kernel/module.c
--- .12078-linux-2.5.69/arch/s390/kernel/module.c 2003-04-20 18:05:03.000000000 +1000
+++ .12078-linux-2.5.69.updated/arch/s390/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -386,3 +386,7 @@ int module_finalize(const Elf_Ehdr *hdr,
kfree(me->arch.syminfo);
return 0;
}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/sparc/kernel/module.c .12078-linux-2.5.69.updated/arch/sparc/kernel/module.c
--- .12078-linux-2.5.69/arch/sparc/kernel/module.c 2003-04-08 11:13:48.000000000 +1000
+++ .12078-linux-2.5.69.updated/arch/sparc/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -145,3 +145,7 @@ int module_finalize(const Elf_Ehdr *hdr,
{
return 0;
}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/sparc64/kernel/module.c .12078-linux-2.5.69.updated/arch/sparc64/kernel/module.c
--- .12078-linux-2.5.69/arch/sparc64/kernel/module.c 2003-04-08 11:13:50.000000000 +1000
+++ .12078-linux-2.5.69.updated/arch/sparc64/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -273,3 +273,7 @@ int module_finalize(const Elf_Ehdr *hdr,
{
return 0;
}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/v850/kernel/module.c .12078-linux-2.5.69.updated/arch/v850/kernel/module.c
--- .12078-linux-2.5.69/arch/v850/kernel/module.c 2003-02-07 19:21:52.000000000 +1100
+++ .12078-linux-2.5.69.updated/arch/v850/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -230,3 +230,8 @@ int apply_relocate_add (Elf32_Shdr *sech
return 0;
}
+
+void
+module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/arch/x86_64/kernel/module.c .12078-linux-2.5.69.updated/arch/x86_64/kernel/module.c
--- .12078-linux-2.5.69/arch/x86_64/kernel/module.c 2003-02-17 11:37:44.000000000 +1100
+++ .12078-linux-2.5.69.updated/arch/x86_64/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -231,3 +231,7 @@ int module_finalize(const Elf_Ehdr *hdr,
{
return 0;
}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/include/linux/moduleloader.h .12078-linux-2.5.69.updated/include/linux/moduleloader.h
--- .12078-linux-2.5.69/include/linux/moduleloader.h 2003-02-07 19:21:54.000000000 +1100
+++ .12078-linux-2.5.69.updated/include/linux/moduleloader.h 2003-05-05 12:47:35.000000000 +1000
@@ -41,4 +41,7 @@ int module_finalize(const Elf_Ehdr *hdr,
const Elf_Shdr *sechdrs,
struct module *mod);
+/* Any cleanup needed when module leaves. */
+void module_arch_cleanup(struct module *mod);
+
#endif
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .12078-linux-2.5.69/kernel/module.c .12078-linux-2.5.69.updated/kernel/module.c
--- .12078-linux-2.5.69/kernel/module.c 2003-05-05 12:37:13.000000000 +1000
+++ .12078-linux-2.5.69.updated/kernel/module.c 2003-05-05 12:47:35.000000000 +1000
@@ -910,6 +910,9 @@ static void free_module(struct module *m
list_del(&mod->list);
spin_unlock_irq(&modlist_lock);
+ /* Arch-specific cleanup. */
+ module_arch_cleanup(mod);
+
/* Module unload stuff */
module_unload_free(mod);
@@ -1276,6 +1279,7 @@ static struct module *load_module(void _
mod->module_init = ptr;
/* Transfer each section which specifies SHF_ALLOC */
+ DEBUGP("final section addresses:\n");
for (i = 0; i < hdr->e_shnum; i++) {
void *dest;
@@ -1293,6 +1297,7 @@ static struct module *load_module(void _
sechdrs[i].sh_size);
/* Update sh_addr to point to copy in image. */
sechdrs[i].sh_addr = (unsigned long)dest;
+ DEBUGP("\t0x%lx %s\n", sechdrs[i].sh_addr, secstrings + sechdrs[i].sh_name);
}
/* Module has been moved. */
mod = (void *)sechdrs[modindex].sh_addr;
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.