RE: Loadable module and kernel gp

From: Luck, Tony <tony.luck_at_intel.com>
Date: 2004-01-24 10:14:51
> >>>>> On Fri, 23 Jan 2004 10:52:00 +0100, Christian Hildner 
> <christian.hildner@hob.de> said:
> 
>   Christian> Hi, does anybody know a simple way for a loadable module
>   Christian> to get the gp value of the kernel? Is there any sample
>   Christian> code?
> 
> The safest way is probably to materialize a function pointer for a
> function that is known to be in the kernel (and exported) and then to
> read the second word.

In case "materialzie a function pointer" is total greek:

#include <linux/slab.h>

struct fptr {
	unsigned long func_addr;
	unsigned long gp;
};

your_routine()
{
	struct fptr = (struct fptr *)kmalloc; /*function known to be in kernel */

	printk("Kernel gp is %lx\n", fptr->gp);
}


Untested ... kmalloc is declared "inline" so that might mess things
up.  Just choose some other exported thing if it is.
-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Fri Jan 23 18:17:00 2004

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:21 EST