All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Lev Olshvang <levonshe@yandex.com>
Cc: linux-il <linux-il@cs.huji.ac.il>,
	kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: How to signal kernel that shared library is not in use by any process anymore ?
Date: Fri, 21 Dec 2018 16:31:10 +0100	[thread overview]
Message-ID: <20181221153110.GA14584@kroah.com> (raw)
In-Reply-To: <965981545402036@sas1-2b3c3045b736.qloud-c.yandex.net>

On Fri, Dec 21, 2018 at 05:20:36PM +0300, Lev Olshvang wrote:
> 
> Hi All,
> 
> I have  an executable (C++) which is the exclusive user of the some shared library that it uses only during  the initialization phase.
> 
> I would like to free memory used by this shared library, because I am running on embedded system.
> 
> How can I achieve this?
> 
> I know that dlopen() will load shared library, and hope that following dlclose() will free this lib memory. 

That right there is how you "achieve" this, call dlclose() and all will
be fine.  If your system needs the memory that was being used, it will
reclaim it from the memory that was previously being used by the library
at this point in time.

Nothing else needs to be done.

Have you tested this and found it not to work properly?

> 1. Still  I do not know what method should be used to make dynamic linker look again into executable and resolve symbols of the newly appeared symbols ?

What "newly appeared symbols"?

If you need to load the library again, call dlopen().

> 2. And  how to tell the dynamic linker ld-linux.so to postpone the symbol resolution until dlopen()  will load  the library?

It will not happen until you tell it to, right?

> 3. Whether to compile and link executable with this library or leave unresolved symbols?

It sounds like you don't really know what type of problem you are trying
to solve here.

Back up, what is the real issue you are having with the kernel at this
point in time?

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2018-12-21 15:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-21 14:20 How to signal kernel that shared library is not in use by any process anymore ? Lev Olshvang
2018-12-21 15:31 ` Greg KH [this message]
2018-12-27  7:47   ` Lev Olshvang
2018-12-27  9:43     ` Greg KH
2018-12-21 16:37 ` Lior Okman
2019-01-08 15:56   ` Lev Olshvang
2018-12-22  2:34 ` Bernd Petrovitsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181221153110.GA14584@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=levonshe@yandex.com \
    --cc=linux-il@cs.huji.ac.il \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.