<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 微软雅黑; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span>Yeah, I just checked the Linux man page to notice that there is a flag RTLD_NODELETE</div><div>I just took a look at a book called "The Linux Programming Interface"</div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);"></span><a href="https://books.google.com.hk/books?id=2SAQAQAAQBAJ&pg=PA861&lpg=PA861&dq=susv3+RTLD_NODELETE&source=bl&ots=qQy3e8EDzr&sig=eINfLM3BX8bD2FrS9BHXn7wNhDQ&hl=zh-CN&sa=X&ved=0ahUKEwjW1-PJhK7UAhUBwJQKHeX2C7MQ6AEIIDAA#v=onepage&q=susv3%20RTLD_NODELETE&f=false" style="font-size: 10.5pt; line-height: 1.5; background-color: window;">https://books.google.com.hk/books?id=2SAQAQAAQBAJ&pg=PA861&lpg=PA861&dq=susv3+RTLD_NODELETE&source=bl&ots=qQy3e8EDzr&sig=eINfLM3BX8bD2FrS9BHXn7wNhDQ&hl=zh-CN&sa=X&ved=0ahUKEwjW1-PJhK7UAhUBwJQKHeX2C7MQ6AEIIDAA#v=onepage&q=susv3%20RTLD_NODELETE&f=false</a><span style="color: rgb(0, 0, 0); font-size: 10.5pt; line-height: 1.5; background-color: rgba(0, 0, 0, 0);"> </span></div><div><span style="color: rgb(0, 0, 0); font-size: 10.5pt; line-height: 1.5; background-color: rgba(0, 0, 0, 0);">And this may be copied from Linux man page.</span></div><div><span style="color: rgb(0, 0, 0); font-size: 10.5pt; line-height: 1.5; background-color: rgba(0, 0, 0, 0);"><br></span></div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);"></span>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>Best wishes,</div><div>xuelin.tian@qkmtech.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:chrisj@rtems.org">Chris Johns</a></div><div><b>Date:</b> 2017-06-07 07:55</div><div><b>To:</b> <a href="mailto:xuelin.tian@qkmtech.com">xuelin.tian@qkmtech.com</a></div><div><b>CC:</b> <a href="mailto:users@rtems.org">users@rtems.org</a></div><div><b>Subject:</b> Re: About dlclose in rtl</div></div></div><div><div>On 06/06/2017 19:11, xuelin.tian@qkmtech.com wrote:</div>
<div>> I check this flag becomes available in SUSv3 standard after glibc2.2. </div>
<div> </div>
<div>Do you have a link to the standard you found so I could have a look?</div>
<div> </div>
<div>I found the The Open Group Base Specifications Issue 7, IEEE Std 1003.1™-2008,</div>
<div>2016 Edition and there is no mention of this option:</div>
<div> </div>
<div>http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlopen.html</div>
<div> </div>
<div>This Linux man page:</div>
<div> </div>
<div>https://linux.die.net/man/3/dlopen</div>
<div> </div>
<div>states the flags RTLD_NODELETE, RTLD_NOLOAD and RTLD_DEEPBIND are not in</div>
<div>POSIX.1-2001. A recent debian install says the same thing.</div>
<div> </div>
<div>> My concern is whether dlclose can reset (or delete) the static variables defined</div>
<div>> in loaded xxx.rap. Or we need to delete static variables manually?</div>
<div> </div>
<div>Anything declared in the loaded module is removed from the address space with</div>
<div>dlclose and the memory is returned to the heap.</div>
<div> </div>
<div>The underlying detail used to implement dynamic loading on RTEMS is different to</div>
<div>Unix and I am not sure what the exact semantics required are and if it is</div>
<div>possible to match them on RTEMS.</div>
<div> </div>
<div>I cannot determine the intent for these glibc additions. For example the dlopen</div>
<div>Linux man page's doco for RTLD_NODELETE provides a rather specific piece of</div>
<div>detail related to static variables and I am left wondering why are static</div>
<div>variables the only type of data effected and why not functions or anything else</div>
<div>in the module? FreeBSD's man page avoids such specifics. I am then left</div>
<div>wondering what the difference between calling dlopen and never calling dlclose</div>
<div>on the module is verses calling dlopen with RTLD_NODELETE and calling dlclose on</div>
<div>the module? Are symbols removed from the symbol table or is there more happening</div>
<div>here? Is it just a way to simplify user management of dynamically loaded</div>
<div>modules? I do not know.</div>
<div> </div>
<div>In RTEMS calling dlopen, dlclose and then dlopen is not the same as Unix. My</div>
<div>understanding for Unix is the shared library is loaded to the same address each</div>
<div>time and this means RTLD_NODELETE and the man page comment "the library's static</div>
<div>variables are not reinitialized if the library is reloaded with dlopen() at a</div>
<div>later time" is achievable. On RTEMS the load address is related to the state of</div>
<div>the C heap (if using the standard RTL allocator) when dlopen is called so the</div>
<div>load address can change. I suppose implementing RTLD_NODELETE would mean the</div>
<div>module is only unloaded if the reference count is 0 and RTLD_NODELETE is not</div>
<div>set. The RTLD_NOLOAD flag is interesting, an app would not need to hold and</div>
<div>maintain the dlopen returned handle. This makes me wonder if these additions are</div>
<div>all to help make using loaded modules simpler.</div>
<div> </div>
<div>Chris</div>
</div></blockquote>
</body></html>