function Named
hi,
Is there any way to get the function address by only knowing the
function Name
thanking you,
Quoted 5 lines · raja
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 codeThis 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.
Quoted 10 lines · Richard B. Johnson
Quoted 5 lines · raja
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.
Signature · 1 line
Jens Axboe
Quoted 9 lines · Jens Axboe
Quoted 8 lines · Richard B. Johnson
Quoted 5 lines · raja
hi,
Is there any way to get the function address by only knowing the
function Name
thanking you,
-
Quoted 5 lines
Quoted 2 lines
printf("%p\n", function()); // User code printk("%p\n", function()); // Kernel codeYup that'll work fine, provided 'function' takes no arguments and returns its own address.
Sorry meant..........
printf("%p\n", function); // User code
Quoted 1 line
I wanted to show that 'function' was a function().
Quoted 4 lines
Signature · 1 line
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.
Quoted 3 lines · raja
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.
Signature · 5 lines
Paulo Marques - www.grupopie.com It is a mistake to think you can solve any major problems just with potatoes. Douglas Adams