Re: determining load address of module

David Woodhouse (David.Woodhouse@mvhi.com)
Wed, 01 Dec 1999 19:00:29 +0000


rajukv@wipinfo.soft.net said:
> How do I determine the loaded address of a module at runtime? ie, I
> want to query this from the init_module() of the module.

&((char *)__this_module)[__this_module->size_of_struct]

As in...

Index: Documentation/sysrq.txt
===================================================================
RCS file: /cvs/linux/Documentation/sysrq.txt,v
retrieving revision 1.2
diff -u -w -r1.2 sysrq.txt
--- Documentation/sysrq.txt 1999/06/29 14:48:32 1.2
+++ Documentation/sysrq.txt 1999/07/01 13:58:13
@@ -58,9 +58,6 @@
'l' - Send a SIGKILL to all processes, INCLUDING init. (Your system
will be non-functional after this.)

-'d' - List all the currently-loaded modules, along with the address at
- which they are loaded.
-
* Okay, so what can I use them for?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Well, un'R'aw is very handy when your X server or a svgalib program crashes.
@@ -90,10 +87,6 @@
t'E'rm and k'I'll are useful if you have some sort of runaway process you
are unable to kill any other way, especially if it's spawning other
processes.
-
-The mo'D'ule listing function is useful if your kernel has just oopsed in a
-module - you need to know the address at which each module is loaded in order
-to have any more than a whelk's chance in a supernova of tracing the problem.

* Sometimes SysRQ seems to get 'stuck' after using it, what can I do?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: drivers/char/sysrq.c
===================================================================
RCS file: /cvs/linux/drivers/char/sysrq.c,v
retrieving revision 1.2
diff -u -w -r1.2 sysrq.c
--- drivers/char/sysrq.c 1999/06/29 14:48:34 1.2
+++ drivers/char/sysrq.c 1999/07/01 13:58:38
@@ -69,12 +69,6 @@
printk("Keyboard mode set to XLATE\n");
}
break;
-#ifdef CONFIG_MODULES
- case 'd': /* D -- moDule listing */
- printk("Module list:\n");
- list_modules();
- break;
-#endif
#ifdef CONFIG_VT
case 'k': /* K -- SAK */
printk("SAK\n");
@@ -145,9 +139,6 @@
printk("Boot "
#ifdef CONFIG_APM
"Off "
-#endif
-#ifdef CONFIG_MODULES
- "moDulelist "
#endif
"Sync Unmount showPc showTasks showMem loglevel0-8 tErm kIll killalL\n");
/* Don't use 'A' as it's handled specially on the Sparc */
Index: kernel/module.c
===================================================================
RCS file: /cvs/linux/kernel/module.c,v
retrieving revision 1.3
diff -u -w -r1.3 module.c
--- kernel/module.c 1999/06/29 14:48:46 1.3
+++ kernel/module.c 1999/07/01 13:59:28
@@ -988,25 +988,6 @@
return 0;
}

-/*
- * List the load address of all the currently loaded modules, for debugging
- * purposes. Perhaps the oops routines should all call this automatically?
- */
-
-void list_modules()
-{
- struct module *mlist = module_list;
-
- printk(" Name Address\n");
-
- while (mlist && mlist->next) /* Don't do the last one */
- {
- printk ("%-16s %p\n", mlist->name,
- &((char *)mlist)[mlist->size_of_struct] );
- mlist = mlist->next;
- }
-}
-
#else /* CONFIG_MODULES */

/* Dummy syscalls for people who don't want modules */

--
dwmw2

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/