dlopen, dlsym usage
- From: "georgeshagov" <George.Shagov@xxxxxx>
- Date: 28 Apr 2006 00:05:46 -0700
Good time of the day to everyone.
The simplest sample:
#include <dlfcn.h>
int func()
{
}
int main()
{
func();
void* pHandle = dlopen(0, RTLD_NOW | RTLD_GLOBAL);
void* pFn = dlsym(pHandle, "func");
printf("0x%x, 0x%x, Error: %s\n", pHandle, pFn, dlerror());
return 0;
}
the output:
../a.out
0x40013688, 0x0, Error: ./a.out: undefined symbol: func
nm ./a.out
0804956c D _DYNAMIC
08049640 D _GLOBAL_OFFSET_TABLE_
08048534 R _IO_stdin_used
w _Jv_RegisterClasses
0804955c d __CTOR_END__
08049558 d __CTOR_LIST__
08049564 d __DTOR_END__
08049560 d __DTOR_LIST__
08048554 r __FRAME_END__
08049568 d __JCR_END__
08049568 d __JCR_LIST__
0804966c A __bss_start
08049660 D __data_start
080484f0 t __do_global_ctors_aux
08048400 t __do_global_dtors_aux
08049664 d __dso_handle
w __gmon_start__
U __libc_start_main@@GLIBC_2.0
0804966c A _edata
08049670 A _end
08048514 T _fini
08048530 R _fp_hw
0804832c T _init
080483b0 T _start
080483d4 t call_gmon_start
0804966c b completed.1
08049660 W data_start
U dlerror@@GLIBC_2.0
U dlopen@@GLIBC_2.1
U dlsym@@GLIBC_2.0
08048430 t frame_dummy
08048464 T func
08048469 T main
08049668 d p.0
U printf@@GLIBC_2.0
the simplest question: How to get pointer to the function if I know
noly its name for EXECUTABLE module
dlopen dlsym perfectly works for .so modules, but it would appear they
do not for executables.
Can anybody help?
Thank you.
.
- Follow-Ups:
- Re: dlopen, dlsym usage
- From: Robert Clark
- Re: dlopen, dlsym usage
- From: Paul Pluzhnikov
- Re: dlopen, dlsym usage
- From: Maxim Yegorushkin
- Re: dlopen, dlsym usage
- From: Frank Cusack
- Re: dlopen, dlsym usage
- Prev by Date: Re: Failed dependencies during installation
- Next by Date: Re: dlopen, dlsym usage
- Previous by thread: Failed dependencies during installation
- Next by thread: Re: dlopen, dlsym usage
- Index(es):
Relevant Pages
|
|