<div dir="ltr"><div dir="ltr">On Wed, Jan 30, 2019 at 6:05 AM Joerg Sonnenberger via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">joerg added a comment.<br>
<br>
Neither GNU ld nor gold implement really useful behavior here. Ideally, every library would be linked with -z defs, but that normally doesn't work because on many systems certain symbols are imported from the main program by default. A good example are the entry points of the dynamic linker. A bad example historically speaking is libwrap. From a user perspective it would be desirable to have a way to say "This symbol will be supplied by someone else" when linking a shared library or potentially even the main binary. That would allow whitelisting intentionally undefined symbols and allow avoiding any symbol resolution dance for shared libraries. A single pass over the symbol tables is still necessary for the sake of knowing the defined symbols and for potential copy relocations, but no further work should be needed.<br></blockquote><div><br></div><div>I think this feature is useful since you can catch errors at static-link-time that would otherwise be run-time errors. I agree that the way how this is implemented is rather ad-hoc; for the linker, there's no way to distinguish symbols that are intentionally left undefined from ones that are undefined by mistake. But still this is a widely accepted feature, and it is better than nothing.</div><div><br></div><div>There's a concern though. gold ignores undefined symbols in system libraries in some specific directories (e.g. /lib or usr/lib) as a heuristic to not emit a false warning, as the libraries in the system directory tend to have undefined symbols that are resolved by the loader in a special manner.</div><div><br></div><div>Ray, did you try building something with this patch? Didn't you see any false errors?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Repository:<br>
  rLLD LLVM Linker<br>
<br>
CHANGES SINCE LAST ACTION<br>
  <a href="https://reviews.llvm.org/D57385/new/" rel="noreferrer" target="_blank">https://reviews.llvm.org/D57385/new/</a><br>
<br>
<a href="https://reviews.llvm.org/D57385" rel="noreferrer" target="_blank">https://reviews.llvm.org/D57385</a><br>
<br>
<br>
<br>
</blockquote></div></div>