From: Christian Hildner <christian.hildner@hob.de>
To: linux-ia64@vger.kernel.org
Subject: Re: Loadable module and kernel gp
Date: Mon, 26 Jan 2004 08:05:30 +0000 [thread overview]
Message-ID: <4014CA4A.4020504@hob.de> (raw)
In-Reply-To: <4010EEC0.7020003@hob.de>
Luck, Tony schrieb:
>>>>>>>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.
>>
Yes, that's it, thanks. Sometimes good solutions are also simple. I'll
try it.
>
>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.
>
I hope the compiler will not explode if I request the pointer to an
inlined function ;-). I like the idea of using kmalloc since this symbol
should be present in almost any kernel.
Thanks
Christian
prev parent reply other threads:[~2004-01-26 8:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-23 9:52 Loadable module and kernel gp Christian Hildner
2004-01-23 10:45 ` Erich Focht
2004-01-23 22:28 ` David Mosberger
2004-01-23 23:14 ` Luck, Tony
2004-01-26 8:05 ` Christian Hildner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4014CA4A.4020504@hob.de \
--to=christian.hildner@hob.de \
--cc=linux-ia64@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.