kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
To: Lev Olshvang <levonshe@yandex.com>,
	kernelnewbies <kernelnewbies@kernelnewbies.org>,
	linux-il <linux-il@cs.huji.ac.il>
Subject: Re: How to signal kernel that shared library is not in use by any process anymore ?
Date: Sat, 22 Dec 2018 03:34:04 +0100	[thread overview]
Message-ID: <9b7fc566-1a6b-43c5-2ca2-415558533d0d@petrovitsch.priv.at> (raw)
In-Reply-To: <965981545402036@sas1-2b3c3045b736.qloud-c.yandex.net>

Hi all!

On 21/12/2018 15:20, Lev Olshvang wrote:
[...]
> 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. 
> 
> 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 ?

There is no such method TTBOMK. Since the linker (and thus the shared
loader) do not know of this library, they can't do anything (see below).

The C++ application has to resolve the symbols with dlsym() (after a
successful dlopen()) and call it with an appropriate type cast.
After dlclose(), the pointers from dlasym() are invalid (obviously - as
the lib is gone/unmapped).

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

Do not mention that library (when linking the application).

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

You do not call the functions directly (and you cannot as the linker
cannot resolve them anyways as the linker doesn't know the library).

MfG,
	Bernd
-- 
Bernd Petrovitsch                  Email : bernd@petrovitsch.priv.at
                     LUGA : http://www.luga.at

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

      parent reply	other threads:[~2018-12-22  2:35 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
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 [this message]

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=9b7fc566-1a6b-43c5-2ca2-415558533d0d@petrovitsch.priv.at \
    --to=bernd@petrovitsch.priv.at \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).