Skip to contentSkip to conversation

module_arch_cleanup()

PATCH In review Christoph Hellwig 3 participants 3 messages May 8, 2003

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 module_arch_cleanup()

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 :))

include/asm-ia64/module.h +3 -0
@@ -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 */
kernel/module.c +8 -0
@@ -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);
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Christoph Hellwig

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
#2 lore raw
In reply to Christoph Hellwig

In message <[email protected]> you write:

Quoted 4 lines

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.

arch/alpha/kernel/module.c +5 -0
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
@@ -300,3 +300,8 @@ module_finalize(const Elf_Ehdr *hdr, con
 {
 	return 0;
 }
+
+void
+module_arch_cleanup(struct module *mod)
+{
+}
arch/arm/kernel/module.c +5 -0
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
@@ -159,3 +159,8 @@ module_finalize(const Elf32_Ehdr *hdr, c
 {
 	return 0;
 }
+
+void
+module_arch_cleanup(struct module *mod)
+{
+}
arch/i386/kernel/module.c +4 -0
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
@@ -123,3 +123,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 	} 	
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
arch/parisc/kernel/module.c +4 -0
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
@@ -568,3 +568,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 #endif
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
arch/ppc/kernel/module.c +4 -0
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
@@ -269,3 +269,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 {
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
arch/ppc64/kernel/module.c +4 -0
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
@@ -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)
+{
+}
arch/s390/kernel/module.c +4 -0
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
@@ -386,3 +386,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 		kfree(me->arch.syminfo);
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
arch/sparc/kernel/module.c +4 -0
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
@@ -145,3 +145,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 {
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
arch/sparc64/kernel/module.c +4 -0
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
@@ -273,3 +273,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 {
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
arch/v850/kernel/module.c +5 -0
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
@@ -230,3 +230,8 @@ int apply_relocate_add (Elf32_Shdr *sech
 
 	return 0;
 }
+
+void
+module_arch_cleanup(struct module *mod)
+{
+}
arch/x86_64/kernel/module.c +4 -0
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
@@ -231,3 +231,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 {
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
include/linux/moduleloader.h +3 -0
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
@@ -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
kernel/module.c +5 -0
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
@@ -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.