<html style="direction: ltr;">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
  </head>
  <body bidimailui-charset-is-forced="true" style="direction: ltr;"
    text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 21/12/2018 16:20, Lev Olshvang
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:965981545402036@sas1-2b3c3045b736.qloud-c.yandex.net">
      <pre class="moz-quote-pre" wrap="">
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. 

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 ?
2. And  how to tell the dynamic linker ld-linux.so to postpone the symbol resolution until dlopen()  will load  the library?
3. Whether to compile and link executable with this library or leave unresolved symbols?</pre>
    </blockquote>
    <p>What you are asking for, as asked, is not possible. If you
      explain your use case better, we might better understand what
      you're trying to do.</p>
    <p><br>
    </p>
    <p>With that said, I think you should just link the library.</p>
    <p><br>
    </p>
    <p>All the text segments of the library (i.e. - code) will be loaded
      with a read only shared mapping. This means that if they are not
      used, they will be unmapped the first time memory becomes
      constrained. If you do not use them later on, they will simply not
      be loaded to memory. They will still be mapped, but will not load
      your embedded system's memory in any significant way.</p>
    <p><br>
    </p>
    <p>Shachar<br>
    </p>
    <br>
  </body>
</html>