NetBSD-Users archive

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

problem using dladdr API



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.

Thanks in Advance,
Channa


Home | Main Index | Thread Index | Old Index