NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: problem using dladdr API in NetBSD



Hi,
It worked for me when i changed the rtld code
in the headers.c file

Line No:792        for (symoffset = 0; symoffset < obj->strsz; symoffset++) {
                            ........
                          ..........
             }

Since the obj->nchains is not getting filled, i chaged the condition
in the for loop to
as shown above.
I assume that the size of the nchains got from the has table is same
as obj->strsz i.e string table size.
Please correct me if my assumption is wrong.

Thanks in Advance,
Channagoud


2008/10/10 Christos Zoulas <christos%astron.com@localhost>:
> In article 
> <515c64960810092215y19d00664nf201170263dd3e64%mail.gmail.com@localhost>,
> Channa  <channa.kad%gmail.com@localhost> wrote:
>>Hi All,
>>I am executing the following test case on NetBSD 3.1 to check the
>>functionality of dladdr ()
>>
>>int main () {
>>  void *handle;
>>  int (*sym) (void);
>>  Dl_info info;
>>  int ret;
>>  int test_fail=0;
>>  handle = dlopen (LIB_NAME , RTLD_NOW);
>>  if (handle == NULL)  {
>>    printf("Dlopen failed\n");
>>    return -1
>> }
>>  sym = dlsym (handle, SYM_NAME);
>>  if (sym == NULL) {
>>    printf("Dlsym failed\n");
>>     return -1;
>> }
>>  memset (&info, 0, sizeof (info));
>>  ret = dladdr (sym, &info);
>>  printf ("address of symbol : %s  = %lx\n", SYM_NAME,sym);
>>  printf ("info.dli_fname = %p (\"%s\")\n", info.dli_fname, info.dli_fname);
>>  printf ("info.dli_fbase = %p\n", info.dli_fbase);
>>  printf ("info.dli_sname = %p (\"%s\")\n", info.dli_sname, info.dli_sname);
>>  printf ("info.dli_saddr = %p\n", info.dli_saddr);
>>  dlclose (handle);
>>}
>>
>>I am always getting the info.dli_sname as NULL string.
>>dladdr is not able to find the symbol.
>>On checking the code in rtld.c
>>
>>Line No:792        for (symoffset = 0; symoffset < obj->nchains; symoffset++) 
>>{
>>                             ........
>>                           ..........
>>              }
>>
>>The dladdr is not entering this loop, sicne obj->nchains is 0 always.
>>
>>Can anyone tell me what is the problem??
>>Any help will be greatly appreciated.
>
> Dunno, works for me on
> NetBSD rebar.astron.com 4.99.1 NetBSD 4.99.1 (ASTRON) #2: Fri Sep  8 15:10:53 
> EDT 2006  
> christos%rebar.astron.com@localhost:/usr/src/sys/arch/i386/compile/ASTRON i386
>
> address of symbol : printf  = 0xbbbac360
> info.dli_fname = 0xbbbee0c0 ("/usr/lib/libc.so.12")
> info.dli_fbase = 0xbbb0f000
> info.dli_sname = 0xbbb206ad ("printf")
> info.dli_saddr = 0xbbbac360
>
> christos
>
>


Home | Main Index | Thread Index | Old Index