bug-glibc
[Top][All Lists]
Advanced

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

Re: Problem with dladdr()?


From: Bryce McKinlay
Subject: Re: Problem with dladdr()?
Date: Fri, 06 Oct 2000 14:38:08 +1300

Ulrich Drepper wrote:

> Bryce McKinlay <address@hidden> writes:
>
> > however in Red Hat 7.0 (glibc-2.1.92-14), this seems to have changed
> > such that the dl_info struct is filled out with some incorrect values,
> > and 0 is not returned:
> >
> > (gdb) p p
> > $2 = (void *) 0x804b90b
> > (gdb) p dl_info
> > $1 = {dli_fname = 0xbffffb6d "/home/bryce/projects/tests/./st",
> >   dli_fbase = 0x8048000, dli_sname = 0x80488b7 "__frame_state_for",
> >   dli_saddr = 0x804b6d0}
> >
> > dli_sname and dli_saddr are wrong here
>
> Nothing is wrong.  Adjust your program.

I'm not convinced. Consider this silly test:

#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif

#include <dlfcn.h>

Dl_info info;

int main (void)
{
  void *adr = (void *) 0x080484bc;

  int ret = dladdr (adr, &info);

  printf ("%u\n", ret);
  printf ("fname %s\n", info.dli_fname);
  printf ("saddr 0x%x\n", info.dli_saddr);
  printf ("sname %s\n", info.dli_sname);
  printf ("fbase 0x%x\n", info.dli_fbase);

  return 0;
}

Replace "adr" with the actual location of main as reported by "nm".

Here's what I get:

$ nm ./a.out | grep main
         U __libc_start_main@@GLIBC_2.0
080484bc T main
$ ./a.out
1
fname ./a.out
saddr 0x80483c4
sname __cxa_finalize
fbase 0x8048000

Here I expect sname and saddr to be "main" and 0x080484bc respectivly. Am I
wrong?

In any case, teh comment in dlfcn.h needs to be updated.

regards

  [ bryce ]







reply via email to

[Prev in Thread] Current Thread [Next in Thread]