<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">DiOn Jan 8, 2017, at 10:57 AM, Reid Kleckner via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">ELF dynamic loaders generally do not distinguish between weak and strong symbols. They only look at the visibility, which can be internal, hidden, default, or protected.</div></div></blockquote><div><br class=""></div><div>Was it always the case?</div><div><br class=""></div><div>The only thing I find in the doc is the description of the environment variable: LD_DYNAMIC_WEAK "(glibc since 2.1.91) Allow weak symbols to be overridden (reverting to old glibc behaviour)."</div><div><div><blockquote type="cite" class=""></blockquote></div></div><div><br class=""></div><div>Just curious…</div><div><br class=""></div><div>—</div><div>Mehdi</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">If you're trying to allow the main program to customize some aspect of your LD_PRELOAD'ed tool, you probably want to use an extern weak symbol. I forget the details on how to do this, but it looks something like this:</div><div class=""><br class=""></div><div class="">extern void __attribute__((weak)) myhook(void);</div><div class="">...</div><div class=""> if (&myhook) {</div><div class=""> myhook();<br class=""> }</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Jan 7, 2017 at 9:34 PM, Simone Atzeni via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br class="">
<br class="">
I have a pass that add a function in the module where the “main” is. Then, I have the same function declared as weak symbol in a shared library that I load at runtime with LD_PRELOAD.<br class="">
When I run a program the weak symbol function gets called over the function was added by the pass.<br class="">
<br class="">
Is it a correct behavior? Is there a way to call the strong symbol function when it’s present in the module?<br class="">
In other words, when I don’t apply the pass I want the program to call the weak symbol function, otherwise when I apply the pass I want the program to call the function added by the pass.<br class="">
<br class="">
Thanks!<br class="">
Best,<br class="">
Simone<br class="">
______________________________<wbr class="">_________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
</blockquote></div><br class=""></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></body></html>