[PATCH] Fix dladdr return value when cannot find symbol

Nickolai Zeldovich nickolai at cs.stanford.edu
Sun Dec 9 20:05:16 UTC 2007


 On Dec 9, 2007 11:26 AM, Carmelo Amoroso <carmelo73 at gmail.com> wrote:
> Attached patch tries to fix it. The GNU_HASH part needs to be fixed accordingly.
>
> Any comments ?

I think that should work.  Minor point:

> --- ldso/libdl/libdl.c  (revision 20633)
> +++ ldso/libdl/libdl.c  (working copy)
> @@ -723,8 +723,11 @@
>                 _dl_if_debug_print("Module \"%s\" at %p\n",
>                                    tpnt->libname, DL_LOADADDR_BASE(tpnt->loadaddr));
>
> -               if (DL_ADDR_IN_LOADADDR((ElfW(Addr)) __address, tpnt, pelf))
> +               if (DL_ADDR_IN_LOADADDR((ElfW(Addr)) __address, tpnt, pelf)) {
>                         pelf = tpnt;
> +                       /* Found, stop looping */
> +                       break;
> +               }
>         }
>
>         if (!pelf) {

I don't think this change is necessary or correct.  With this change,
the code can exit having found any shared library mapped at any lower
address.  Instead, you need to iterate over all loaded ELF files to
find the nearest shared library mapped at a lower address (see the
comment for DL_ADDR_IN_LOADADDR in dl-defs.h).

Nickolai.



More information about the uClibc mailing list