<div dir="ltr">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><br></div><div>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><br></div><div>extern void __attribute__((weak)) myhook(void);</div><div>...</div><div>  if (&myhook) {</div><div>   myhook();<br>  }</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 7, 2017 at 9:34 PM, Simone Atzeni via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
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>
When I run a program the weak symbol function gets called over the function was added by the pass.<br>
<br>
Is it a correct behavior? Is there a way to call the strong symbol function when it’s present in the module?<br>
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>
<br>
Thanks!<br>
Best,<br>
Simone<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>