<div dir="ltr"><div>The target is specifically PowerPC64, I've created a bugzilla with the reproducer: <a href="https://bugs.llvm.org/show_bug.cgi?id=45076">https://bugs.llvm.org/show_bug.cgi?id=45076</a> and an explanation of what is causing the failure when linking with LLD.<br></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"><div>It is dropped from DT_NEEDED entries because it only provides definitions resolving weak references.</div></blockquote><div> </div><div>You are right it is not added to DT_NEEDED by any of the linkers, I was looking at the output from ldd which shows it as a dependency and I didn't realize that it wasn't marked as needed. There is still a behavior difference between what lld does: demotes the symbol to undefined and emits a got entry with no dynamic relocation, and what both gold and bfd do: emit the relocation for the got entry. Is this difference intended?<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 28, 2020 at 3:44 PM Fāng-ruì Sòng <<a href="mailto:maskray@google.com">maskray@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, Feb 28, 2020 at 7:24 AM Sean Fertile via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.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"><div dir="ltr">On PowerPC we have a failing address sanitizer test when linking with LLD. The issue is that the symbol '__libc_stack_end' is resolved to an undefined weak symbol when linking with LLD but not when linking (with the exact same command/input) with other linkers. Tracing the symbol I see it is resolved to a definition in the dynamic linker as expected:<div><br></div><div>/home/sfertile/LLVM_MonoRepo/build/lib/clang/11.0.0/lib/linux/libclang_rt.asan-powerpc64le.a(sanitizer_linux.cpp.o): reference to __libc_stack_end<br>/lib/powerpc64le-linux-gnu/libpthread.so.0: reference to __libc_stack_end<br>/lib/powerpc64le-linux-gnu/ld64.so.2: shared definition of __libc_stack_end<br><internal>: reference to __libc_stack_end</div><div><br></div><div>The last line in the trace output shows where we demote the shared definition to an undefined symbol here: <a href="https://github.com/llvm/llvm-project/blob/c8bfed05e21f945b5ac71cd01d62e2854a8ddcf9/lld/ELF/Driver.cpp#L1505" target="_blank">https://github.com/llvm/llvm-project/blob/c8bfed05e21f945b5ac71cd01d62e2854a8ddcf9/lld/ELF/Driver.cpp#L1505</a></div><div><br></div><div>I'm guessing the fix is that if `needsInterpSection()` is true then the dynamic linker should be marked as needed. Its going to end up in the DT_NEEDED anyway so the symbols can't become <span>dangling references. </span>In my case then, the demotion won't happen and everything works as expected. Is this the right direction?</div></div></blockquote></div><br><div>Can you name the target and upload a reproduce file (--reproduce=) ?</div><div><br></div><div>I have checked the x86-64 case: clang -fsanitize=address -fuse-ld=lld a.c -o a -Wl,-y,__libc_stack_end</div><div>The demotion works as expected. ld.so is linked because of AS_NEEDED(...) in libc.so (a linker script).</div><div>It is dropped from DT_NEEDED entries because it only provides definitions resolving weak references.</div><div><br></div><div>--dynamic-linker= pointing to ld.so does not mean ld.so will be added to DT_NEEDED.</div></div>
</blockquote></div>