[PATCH] Fix dladdr return value when cannot find symbol

Carmelo Amoroso carmelo73 at gmail.com
Sun Dec 9 19:26:10 UTC 2007


Nickolai Zeldovich wrote:
> The attached patch makes dladdr() return 0 when it cannot find a 
> matching symbol.  The current behavior of returning 1 makes it 
> impossible for callers to know whether the supplied Dl_info buffer has 
> been filled in with meaningful data.
> 
> Nickolai.
> 


Hi Nickolai,
I had a look at your patch.
According to what man page says on dladdr (on my MacOSX, I'll check on Linux too)

ERRORS
      If an image containing addr cannot be found, dladdr() returns 0.  On suc-
      cess, a non-zero value is returned.

      If the image containing addr is found, but no nearest symbol was found,
      the dli_sname and dli_saddr fields are set to NULL.

your patch seems not be correct. Indeed dladdr should be fixed in a better
way by setting dli_sname and dli_saddr to NULL whn symbol hasn't been found,
and setting always dli_fname and dli_fbase (if there is an object in which
the addr lies in).
This behavior is the same as glibc.

Attached patch tries to fix it. The GNU_HASH part needs to be fixed accordingly.

Anyway, thanks for pointing it out

Any comments ?

Cheers,
Carmelo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dladdr.patch
Url: http://lists.busybox.net/pipermail/uclibc/attachments/20071209/a2396b94/attachment-0001.diff 


More information about the uClibc mailing list