Re: How does solib handline shared library unloads?

Daniel Jacobowitz
2005-11-01T13:51:49Z

On Tue, Nov 01, 2005 at 08:45:47AM -0500, Christopher Faylor wrote:
> On Tue, Nov 01, 2005 at 07:58:35AM +0100, Mark Kettenis wrote:
> >> Date: Tue, 1 Nov 2005 00:39:34 -0500
> >> From: Christopher Faylor
> >>
> >> Can anyone enlighten me as to how information about a library is
> >> relinquished when a library loaded via dlopen is unloaded via dlclose?
> >> Theoretically, the information about the library should be removed and
> >> the library should not be listed by "info sharedlibrary".
> >>
> >> I don't see any way for this to be handled in solib.c and inf*.c but I'm
> >> sure I'm just missing something obvious. I haven't written a test case
> >> yet to see how it is being handled but I was hoping someone could
> >> clarify this for me.
> >
> >It happens as part of solib_add(), which should be called for every
> >shared library events, not just dlopen()s. See the code in
> >update_solib_list() for the code that actually removes libraries from
> >GDB's internal list.
>
> Is this handled as part of the so breakpoint stuff? I was trying to
> avoid implementing that but I will if I have to.

Well, that's how we get to solib_add for svr4 targets; but it should
work to get there off an explicit DLL unload event, anyway. I think.

> >That said, I think I have convinced myself in the past that there is a
> >big gaping memory leak.
>
> I was wondering about that. I thought there might be a big memory leak
> there since it doesn't look like objfile's are being freed.

I'm not sure... ideally, I'd rather they were neither freed nor leaked,
since we're likely to load them again. But that may be a lot of work
yet.

--
Daniel Jacobowitz
CodeSourcery, LLC