public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* function Named
@ 2005-07-07 12:54 raja
  2005-07-07 13:43 ` Richard B. Johnson
  2005-07-07 13:52 ` Paulo Marques
  0 siblings, 2 replies; 5+ messages in thread
From: raja @ 2005-07-07 12:54 UTC (permalink / raw)
  To: linux-kernel

hi,
    Is there any way to get the function address by only knowing the 
function Name
thanking you,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: function Named
  2005-07-07 12:54 function Named raja
@ 2005-07-07 13:43 ` Richard B. Johnson
  2005-07-07 13:56   ` Jens Axboe
  2005-07-07 13:52 ` Paulo Marques
  1 sibling, 1 reply; 5+ messages in thread
From: Richard B. Johnson @ 2005-07-07 13:43 UTC (permalink / raw)
  To: raja; +Cc: linux-kernel

On Thu, 7 Jul 2005, raja wrote:

> hi,
>    Is there any way to get the function address by only knowing the
> function Name
> thanking you,
> -

 	printf("%p\n", function());   // User code
 	printk("%p\n", function());   // Kernel code

This gives you the offset in virtual address-space. Inside the
kernel, one can obtain the physical address. User-code code
can't find out the physical address in any direct way.


Cheers,
Dick Johnson
Penguin : Linux version 2.6.12 on an i686 machine (5537.79 BogoMips).
  Notice : All mail here is now cached for review by Dictator Bush.
                  98.36% of all statistics are fiction.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: function Named
  2005-07-07 12:54 function Named raja
  2005-07-07 13:43 ` Richard B. Johnson
@ 2005-07-07 13:52 ` Paulo Marques
  1 sibling, 0 replies; 5+ messages in thread
From: Paulo Marques @ 2005-07-07 13:52 UTC (permalink / raw)
  To: raja; +Cc: linux-kernel

raja wrote:
> hi,
>    Is there any way to get the function address by only knowing the 
> function Name

See "kallsyms_lookup_name" in include/linux/kallsyms.h (implemented in 
kernel/kallsyms.c).

Beware:

  - CONFIG_KALLSYMS might be undefined. In that case it always returns 0

  - the function returns the address of *any* known symbol, not just 
functions (this can be easily improved to also return the symbol type)

  - the function is extremely inefficient, as it does a linear search 
over all the symbols. kallsyms is optimized to work the other way 
around: get the name from the address.

-- 
Paulo Marques - www.grupopie.com

It is a mistake to think you can solve any major problems
just with potatoes.
Douglas Adams

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: function Named
  2005-07-07 13:43 ` Richard B. Johnson
@ 2005-07-07 13:56   ` Jens Axboe
  2005-07-07 13:59     ` Richard B. Johnson
  0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2005-07-07 13:56 UTC (permalink / raw)
  To: Richard B. Johnson; +Cc: raja, linux-kernel

On Thu, Jul 07 2005, Richard B. Johnson wrote:
> On Thu, 7 Jul 2005, raja wrote:
> 
> >hi,
> >   Is there any way to get the function address by only knowing the
> >function Name
> >thanking you,
> >-
> 
> 	printf("%p\n", function());   // User code
> 	printk("%p\n", function());   // Kernel code

Yup that'll work fine, provided 'function' takes no arguments and
returns its own address.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: function Named
  2005-07-07 13:56   ` Jens Axboe
@ 2005-07-07 13:59     ` Richard B. Johnson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard B. Johnson @ 2005-07-07 13:59 UTC (permalink / raw)
  To: Jens Axboe; +Cc: raja, linux-kernel

On Thu, 7 Jul 2005, Jens Axboe wrote:

> On Thu, Jul 07 2005, Richard B. Johnson wrote:
>> On Thu, 7 Jul 2005, raja wrote:
>>
>>> hi,
>>>   Is there any way to get the function address by only knowing the
>>> function Name
>>> thanking you,
>>> -
>>
>> 	printf("%p\n", function());   // User code
>> 	printk("%p\n", function());   // Kernel code
>
> Yup that'll work fine, provided 'function' takes no arguments and
> returns its own address.

Sorry meant..........

 	printf("%p\n", function);   // User code
>

I wanted to show that 'function' was a `function()`.

> -- 
> Jens Axboe
>
>

Cheers,
Dick Johnson
Penguin : Linux version 2.6.12 on an i686 machine (5537.79 BogoMips).
  Notice : All mail here is now cached for review by Dictator Bush.
                  98.36% of all statistics are fiction.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-07-07 14:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-07 12:54 function Named raja
2005-07-07 13:43 ` Richard B. Johnson
2005-07-07 13:56   ` Jens Axboe
2005-07-07 13:59     ` Richard B. Johnson
2005-07-07 13:52 ` Paulo Marques

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox