diff -urN -X dontdiff linux/fs/proc/kcore.c 2326-kcore/fs/proc/kcore.c
--- linux/fs/proc/kcore.c	Sun Nov  7 12:33:03 1999
+++ 2326-kcore/fs/proc/kcore.c	Sun Nov  7 17:28:08 1999
@@ -5,6 +5,7 @@
  *	Jeremy Fitzhardinge <jeremy@sw.oz.au>
  *	Implemented by David Howells <David.Howells@nexor.co.uk>
  *	Modified and incorporated into 2.3.x by Tigran Aivazian <tigran@sco.com>
+ *	Support to dump module's data structures (ELF only), Tigran Aivazian <tigran@sco.com>
  */
 
 #include <linux/config.h>
@@ -14,6 +15,8 @@
 #include <linux/a.out.h>
 #include <linux/elf.h>
 #include <linux/elfcore.h>
+#include <linux/module.h>
+#include <linux/proc_fs.h>
 #include <asm/uaccess.h>
 
 #ifdef CONFIG_KCORE_AOUT
@@ -262,7 +265,7 @@
 	char *page;
 
 	/* work out how much file we allow to be read */
-	size = ((size_t)high_memory - PAGE_OFFSET) + PAGE_SIZE;
+	proc_root_kcore.size = size = get_kcore_size();
 	acc = 0;
 
 	/* see if file pointer already beyond EOF */
diff -urN -X dontdiff linux/fs/proc/proc_misc.c 2326-kcore/fs/proc/proc_misc.c
--- linux/fs/proc/proc_misc.c	Tue Nov  2 01:54:24 1999
+++ 2326-kcore/fs/proc/proc_misc.c	Sun Nov  7 17:16:03 1999
@@ -30,6 +30,7 @@
 #include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/signal.h>
+#include <linux/module.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -550,7 +551,7 @@
 	S_IFREG | S_IRUSR, 1, 0, 0,
 	0, &proc_kmsg_inode_operations
 };
-static struct proc_dir_entry proc_root_kcore = {
+struct proc_dir_entry proc_root_kcore = {
 	0, 5, "kcore",
 	S_IFREG | S_IRUSR, 1, 0, 0,
 	0, &proc_kcore_inode_operations
@@ -613,7 +614,7 @@
 	/* And now for trickier ones */
 	proc_register(&proc_root, &proc_root_kmsg);
 	proc_register(&proc_root, &proc_root_kcore);
-	proc_root_kcore.size = (MAP_NR(high_memory) << PAGE_SHIFT) + PAGE_SIZE;
+	proc_root_kcore.size = get_kcore_size();
 	if (prof_shift) {
 		proc_register(&proc_root, &proc_root_profile);
 		proc_root_profile.size = (1+prof_len) * sizeof(unsigned int);
diff -urN -X dontdiff linux/include/linux/module.h 2326-kcore/include/linux/module.h
--- linux/include/linux/module.h	Thu Aug 19 00:43:29 1999
+++ 2326-kcore/include/linux/module.h	Sun Nov  7 18:05:12 1999
@@ -286,4 +286,5 @@
 #define EXPORT_NO_SYMBOLS
 #endif /* MODULE */
 
+extern unsigned long get_kcore_size(void);
 #endif /* _LINUX_MODULE_H */
diff -urN -X dontdiff linux/include/linux/proc_fs.h 2326-kcore/include/linux/proc_fs.h
--- linux/include/linux/proc_fs.h	Tue Nov  2 01:54:26 1999
+++ 2326-kcore/include/linux/proc_fs.h	Sun Nov  7 17:15:50 1999
@@ -193,6 +193,7 @@
 extern struct proc_dir_entry *proc_bus;
 extern struct proc_dir_entry *proc_sysvipc;
 extern struct proc_dir_entry *proc_root_driver;
+extern struct proc_dir_entry proc_root_kcore;
 
 extern struct inode_operations proc_scsi_inode_operations;
 
diff -urN -X dontdiff linux/kernel/module.c 2326-kcore/kernel/module.c
--- linux/kernel/module.c	Thu Sep 16 21:33:27 1999
+++ 2326-kcore/kernel/module.c	Sun Nov  7 18:22:42 1999
@@ -53,6 +53,26 @@
 static void free_module(struct module *, int tag_freed);
 
 
+/* needed for /proc/kcore, here because kernel_module is static (TA) */
+unsigned long get_kcore_size(void)
+{
+	unsigned long try, size = 0;
+	struct module * m;
+
+	if (module_list == &kernel_module)
+		return ((unsigned long)high_memory - PAGE_OFFSET + PAGE_SIZE);
+
+	/* shouldn't we have a rw spinlock for module_list? */
+	lock_kernel();
+	for (m=module_list; m; m=m->next) {
+		try = (unsigned long)m + m->size;
+		if (try > size)
+			size = try;
+	}
+	unlock_kernel();
+	return (size - PAGE_OFFSET + PAGE_SIZE);
+}
+
 /*
  * Called at boot time
  */
@@ -968,6 +988,13 @@
 }
 
 #else		/* CONFIG_MODULES */
+
+/* no MODULES so high_memory is good enough for /proc/kcore (TA) */
+unsigned long get_kcore_size(void)
+{
+	return ((unsigned long)high_memory - PAGE_OFFSET + PAGE_SIZE);
+}
+
 
 /* Dummy syscalls for people who don't want modules */
 
