Re: [patch] solib do not add ldd if in libc

Aleksandar Ristovski
2009-07-21T15:12:19Z

Pedro, I am copying your reply here since my reply to myself
contains better while loop which I actually wanted you to
see. (and I'm replying to you below).

> Aleksandar Ristovski wrote:
>> Hello,
>>
>> On systems (QNX) that have ldd residing in libc, svr4_current_sos will
>> add libc twice. Once while walking the linkmap and second time from
>> r_ldsomap.
>>
>> This patch adds check if ldsolib has already been added and if so,
>> prevents adding duplicate entry.
>>
>>
>> Tested on linux - i386, no regressions; however, it would be good if
>> someone could test for regressions on Solaris.
>>
>
> This time with the right patch.
>
>
>

Pedro Alves wrote:
> On Tuesday 07 July 2009 17:11:21, Aleksandar Ristovski wrote:
>
> [This is not a formal review, just a quick note: ] did
you post the
> patch you intended to post? That while loop looks wrong.
>
> I note that solib_svr4_r_ldsomap's describing comment
seems to
> indicate that a fix there would fit better with its design.
>
> /* Find the link map for the dynamic linker (if it is not
in the
> normal list of loaded shared objects). */
>
> static CORE_ADDR
> solib_svr4_r_ldsomap (struct svr4_info *info)
> {
>

Our r_debug is version 2 and we do have r_ldsomap member. We
set it to our dynamic linker which coincides with libc. My
patch loops through the list of so-s and looks for already
added object; if found, then resets ldsomap to prevent outer
loop from doing another iteration.

I, unfortunately, can not verify that it doesn't break
solaris... I think it doesn't, but I couldn't test it
(AFAIK, solaris has dynamic linker in a separate shared
library and so it should not be found in the so list, but I
don't have Solaris to verify this).

Thanks,